Imagine a toy app with a button that turns an LED on when pressed and off when released. The on/off events are captured in an interrupt handler. Because the interrupt code should be short, I wanted to queue up the interrupts and process them in the app’s loop().
Is it possible to use std::queue variables in an interrupt handler? My code is below… a bunch of compiler errors due to use of volatile as queue type and container type.
I think there is a library somewhere but circular buffers are so simple (one array, two indices) I’d do my own - any library would just add extra overhead IMO.
Is this all you’re doing in loop()? If your loop is quick enough I am wondering why you would need to queue these events. Of course if you’re doing long operations and need to replay events in between I understand.
That sounds like a great idea! I'd much prefer an existing implementation than rolling my own if I can help it. Do you know where any documentation is for the DeviceOS wrappers for the FreeRTOS queue functions?
Oh, and in the FreeRTOS docs, I see this:
Note that interrupts must NOT use API functions that do not end in “FromISR”.
Do the DeviceOS functions have "FromISR" variants?