Change TIMSK1 atomically in mm::IsrSetEnabled
parent
dd7042e567
commit
1007402b24
|
|
@ -20,10 +20,12 @@ Motion motion;
|
||||||
/// ISR state manipulation
|
/// ISR state manipulation
|
||||||
static inline void IsrSetEnabled(bool state) {
|
static inline void IsrSetEnabled(bool state) {
|
||||||
#ifdef __AVR__
|
#ifdef __AVR__
|
||||||
|
// NOTE: ATOMIC_BLOCK is split across branches to split the function into two optimal calls at
|
||||||
|
// compile-time
|
||||||
if (state)
|
if (state)
|
||||||
TIMSK1 |= (1 << OCIE1A);
|
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { TIMSK1 |= (1 << OCIE1A); }
|
||||||
else
|
else
|
||||||
TIMSK1 &= ~(1 << OCIE1A);
|
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { TIMSK1 &= ~(1 << OCIE1A); }
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue