Interrupt-safe way to set function pointer in HiTech C on PIC32
I have an ISR defined to trigger on an external interrupt. The external interrupt may not always be enabled, but under certain circumstances I want to be able to register a function to be called ONCE within the interrupt from within the main code. The function might be replaced by another one, or removed, before the next interrupt. I don't know much about techniques for synchronisation on the PIC32, but I've come up with the following: volatile BOOL callbackInterrupted = FALSE; volatile BOOL callbackWritten = FALSE; void (*myCallback)() = NULL; void RegisterCallback(void (*callback)()) { do {