|
| 1 | +// |
| 2 | +// Created by dave on 23/12/2020. |
| 3 | +// |
| 4 | + |
| 5 | +#ifndef TASKMANAGERIO_BASICINTERRUPTABSTRACTION_H |
| 6 | +#define TASKMANAGERIO_BASICINTERRUPTABSTRACTION_H |
| 7 | + |
| 8 | +#include <TaskPlatformDeps.h> |
| 9 | +#include <TaskManagerIO.h> |
| 10 | + |
| 11 | +#ifdef IOA_USE_ARDUINO |
| 12 | + |
| 13 | +inline void internalHandleInterrupt(pintype_t pin, RawIntHandler fn, uint8_t mode) { |
| 14 | +#if defined(ARDUINO_MBED_MODE) || (ARDUINO_API_VERSION >= 10200) |
| 15 | + ::attachInterrupt(pin, fn, (PinStatus)mode); |
| 16 | +#elif defined(PARTICLE) |
| 17 | + ::attachInterrupt(pin, fn, (InterruptMode)mode); |
| 18 | +#else |
| 19 | + ::attachInterrupt(pin, fn, mode); |
| 20 | +#endif // Interrupt mode conditionals |
| 21 | +} |
| 22 | + |
| 23 | +/** |
| 24 | + * For Arduino devices when NOT using IoAbstraction, this is the minimum possible implementation that can call |
| 25 | + * through to the Arduino platform ::attachInterrupt call. You can pass a pointer to one of these to the task manager |
| 26 | + * interrupt functions. If you are using IoAbstraction, all IoAbstractionRef's implement InterruptAbstraction. |
| 27 | + */ |
| 28 | +class BasicArduinoInterruptAbstraction : public InterruptAbstraction { |
| 29 | + void attachInterrupt(pintype_t pin, RawIntHandler fn, uint8_t mode) override { |
| 30 | + internalHandleInterrupt(pin, fn, mode); |
| 31 | + } |
| 32 | +}; |
| 33 | +#endif // IOA_USE_ARDUINO - Arduino Only |
| 34 | + |
| 35 | +#endif //TASKMANAGERIO_BASICINTERRUPTABSTRACTION_H |
0 commit comments