Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
64 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef FUNCTIONALINTERRUPT_H | ||
#define FUNCTIONALINTERRUPT_H | ||
|
||
#include <stddef.h> | ||
#include <stdint.h> | ||
#include <functional> | ||
|
||
extern "C" { | ||
#include "c_types.h" | ||
#include "ets_sys.h" | ||
} | ||
|
||
void attachInterrupt(uint8_t pin, std::function<void(void)> intRoutine, int mode); | ||
|
||
#endif //INTERRUPTS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters