Hi, is there some possibility that I get a warning of the compiler (c++), if I use a non-atomic access to some variable in a non-interrupt function?
Mostly this concerns bit changes, e. g. if I use any non-atomic access to reset an interrupt enable flag, this of course is very dangerous.
E. g. it will be very crucial, the in the non-interrupt code I never should enable any EXTI interrupt like this (STM32F4):
EXTI->IMR |= EXTI_IMR_MR2;
But instead I alays should use the atomic version:
SetStBit( EXTI->IMR, EXTI_IMR_MR2)
(SetStBit is my macro to do the bit-banding access to set a bit).
I am a bit scared, that I by some accident might forget this and use the non-atomic version by accident somewhere in my code.
The nicest thing for me would be, if there would be a specifier like "atomic" for variables. It would be a bit similar to "volatile", at least volatile of course is also linked to the interrupts somehow ... . But atomic would have no implication on the compile process, but only on the "production of warning".
I could then disable the corresponding warning inside my interrupt code, and enable it in the "main"/non-interrupt code - this would be super-great and helpful!