IoAbstraction
IoAbstraction copied to clipboard
Add support for function objects in ioDeviceAttachInterrupt
Would it be possible to support non-static class methods as callbacks in ioDeviceAttachInterrupt?
I ran across this post where they came up with this to work around the limitation.
We'll need to take a look at this in terms of safety, if as it looks it's already supported on ESP, then it could certainly be conditional for ESP32 and ESP8266 boards.
Wow, how time flies, it's been a really busy year, but I've taken a look at this now and it looks like it would work for at least ESP32 and STM32Duino.
see https://github.com/davetcc/TaskManagerIO/issues/42
will be added in the next release of taskmanager
Unfortunately, ESP32 does not support this directly, STM32 does, but I'm not sure how safe it even is on STM32 as I don't know how safe std::function objects are in an interrupt context.
Memory visibility and safety in interrupts is my major concern, if anything goes wrong, it would be extremely difficult to debug.
At any rate, we no longer really recommend the original interrupt marshalling, instead we suggest that people use events to handle the raw interrupt and just trigger the event. I thought this would be an easy one supported by ESP32, but unfortunately it is not. I'd recommend you just use that class in your own code with a task manager BaseEvent.