IrqLock (c++)
This commit is contained in:
parent
3232fe1d30
commit
ee09dcef00
1 changed files with 27 additions and 0 deletions
27
components/f4ll/inc/irqlock.h
Normal file
27
components/f4ll/inc/irqlock.h
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#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
|
Loading…
Add table
Add a link
Reference in a new issue