* Add Config * Add Cache and remove pre-commit action * [pre-commit.ci lite] apply automatic fixes * Remove freeze * Fix * Update action * Use latest stable Python 3 version * Improve caching * Improve cache tag * Improve bot message * fix(typos): Fix typos * fix(typos): Fix more typos * refactor(udp_server): Convert script from Python 2 to 3 * Fix whitespace * Clang-format fixes * Prettier fixes * Black formatting * Manual fixes * Line endings * Fix flake and make Vale manual * Fix flake and reformat --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Co-authored-by: Rodrigo Garcia <rodrigo.garcia@espressif.com>
34 lines
952 B
C++
34 lines
952 B
C++
/*
|
|
* FunctionalInterrupt.cpp
|
|
*
|
|
* Created on: 8 jul. 2018
|
|
* Author: Herman
|
|
*/
|
|
|
|
#include "FunctionalInterrupt.h"
|
|
#include "Arduino.h"
|
|
|
|
typedef void (*voidFuncPtr)(void);
|
|
typedef void (*voidFuncPtrArg)(void*);
|
|
|
|
extern "C" {
|
|
extern void __attachInterruptFunctionalArg(uint8_t pin, voidFuncPtrArg userFunc, void* arg, int intr_type, bool functional);
|
|
}
|
|
|
|
void ARDUINO_ISR_ATTR interruptFunctional(void* arg) {
|
|
InterruptArgStructure* localArg = (InterruptArgStructure*)arg;
|
|
if (localArg->interruptFunction) {
|
|
localArg->interruptFunction();
|
|
}
|
|
}
|
|
|
|
void attachInterrupt(uint8_t pin, std::function<void(void)> intRoutine, int mode) {
|
|
// use the local interrupt routine which takes the ArgStructure as argument
|
|
__attachInterruptFunctionalArg(pin, (voidFuncPtrArg)interruptFunctional, new InterruptArgStructure{ intRoutine }, mode, true);
|
|
}
|
|
|
|
extern "C" {
|
|
void cleanupFunctional(void* arg) {
|
|
delete (InterruptArgStructure*)arg;
|
|
}
|
|
}
|