#ifndef _IRQLOCK_H_INCLUDED
#define _IRQLOCK_H_INCLUDED

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

namespace f4ll {

class IrqLock {
public:
	inline IrqLock() : m_primask(__get_PRIMASK()) {
		__disable_irq();
	}
	inline void Release() {
		__set_PRIMASK(m_primask);
	}

	inline ~IrqLock() {
		__set_PRIMASK(m_primask);
	}
private:
	uint32_t m_primask;
};

}

#endif	//	_IRQLOCK_H_INCLUDED
