Hello
I am working with volatile long variables, which are beeing modified in ISRs.
To ensure an atomic access to these variables outside of the ISRs, I am using a function which is making a copy of the value, while interrupts are disabled.
u32 ATOMIC32(volatile u32 *var) //--------------------------------------------- // avoid ISR during access to the 4 bytes of a // volatile long, which might be modified in ISR // => Atomic volatile access oustide of ISR //--------------------------------------------- { u32 temp; cli(); temp=*var; sei(); return(temp); }
My question is, if anybody knows a smarter (respectively more efficient) way to do this, (e.g. with a macro- or inline-definition)?
Thanks for any hint!
Pater