I push a button so APP_DIN_NotifyToggle gets called
I quickly push a button again, before the previous APP_DIN_NotifyToggle was finished?
Could I possibly see some problems with race conditions? Or can I trust that APP_DIN_NotifyToggle is run with no pre-emption??
I’m guessing the former would make the most sense. I’m also seeing some bugs which I suspect might be attributed to race conditions, but that might also be due to shared data between APP_Background and the notify hooks, now that I think of it…
MIOS32_SRIO will set a “changed” flag whenever a DIN pin has toggled during a scan.
Even if the pin is toggled back to the original value, APP_DIN_NotifyToggle will still be called, but with the current value.
In other words: it won’t be called twice.
If any edge is for interest, then you’ve to use the APP_SRIO_ServiceFinish() hook and detect pin changes from there (see also the various $MIOS32_PATH/modules/blm* examples) - but this is an interrupt. Time consuming operations (e.g. MIDI output) shouldn’t be done from there. You would need to implement a queue mechanism if any pin change is really for interest.
I’m also seeing some bugs which I suspect might be attributed to race conditions
If you would describe your use case a little bit further, I could give you more concrete help how to solve the issues in your application…