1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-21 21:22:31 +03:00

Functional Interrupts initial

This commit is contained in:
hreintke
2016-12-08 16:53:59 +01:00
committed by Ivan Grokhotkov
parent 3f5d06bc12
commit ba0e049b83
3 changed files with 64 additions and 7 deletions

View File

@ -0,0 +1,24 @@
#include <FunctionalInterrupt.h>
// Duplicate typedefs from core_esp8266_wiring_digital_c
typedef void (*voidFuncPtr)(void);
// Helper functions for Functional interrupt routines
extern "C" void ICACHE_RAM_ATTR __attachInterruptArg(uint8_t pin, voidFuncPtr userFunc, void*fp , int mode);
// Structure for communication
struct ArgStructure {
std::function<void(void)> reqFunction;
};
void interruptFunctional(void* arg)
{
((ArgStructure*)arg)->reqFunction();
}
void attachInterrupt(uint8_t pin, std::function<void(void)> intRoutine, int mode)
{
// use the local interrupt routine which takes the ArgStructure as argument
__attachInterruptArg (pin, (voidFuncPtr)interruptFunctional, new ArgStructure{intRoutine}, mode);
}