#pragma once

#include <inttypes.h>
#include <stm32f4xx.h>

namespace f4ll {

class irq_lock
{
public:
    inline irq_lock()
        : m_primask(__get_PRIMASK())
    {
        __disable_irq();
    }
    inline void release() { __set_PRIMASK(m_primask); }

    inline ~irq_lock() { __set_PRIMASK(m_primask); }

private:
    uint32_t m_primask;
};
}
