SX1262 is now finally stable due to these key changes: - Interrupt handling: To circumvent erratum 3.11 level interrupts are utilized. Unsure if this was actually an issue as only the DIO1 IRQ is installed, but it should be done nonetheless to avoid problems once more GPIO interrupts are used. - RadioLib HAL: Use the hooks for beginnig and ending a train of SPI transactions to lock and reserve the device, making it more reliable. Also, CS handling is removed as RadioLib manages this manually. - Board T-Lora Pager: Step down SPI frequency to reasonable rate
57 lines
1.4 KiB
C++
57 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <driver/gpio.h>
|
|
|
|
/**
|
|
* An interrupt handler class which can trigger any given IRAM service routine
|
|
* for falling/rising edge level changes and oneshot level detection.
|
|
* This class is needed if the erratum 3.11 from ESP32 Series SoC Errata Version v2.9 applies.
|
|
* In short, once an edge sensitive interrupt is installed, subsequent interrupts may not work.
|
|
* This class uses high/low level interrupts to handle both edge detection and oneshot detection of levels
|
|
* which circumvents this problem.
|
|
*/
|
|
class LevelInterruptHandler {
|
|
public:
|
|
enum class Type {
|
|
HighOneshot,
|
|
LowOneshot,
|
|
PositiveEdge,
|
|
NegativeEdge
|
|
};
|
|
|
|
using ServiceRoutine = void(*)(void* ctx);
|
|
|
|
private:
|
|
enum class State {
|
|
Low,
|
|
High
|
|
};
|
|
|
|
const gpio_num_t pin;
|
|
const Type type;
|
|
const ServiceRoutine isr;
|
|
void* context;
|
|
State state;
|
|
|
|
static void handlePositiveEdge(void* isr_arg);
|
|
static void handleNegativeEdge(void* isr_arg);
|
|
static void handleOneshot(void* isr_arg);
|
|
|
|
public:
|
|
LevelInterruptHandler(const gpio_num_t pin, const Type type, ServiceRoutine isr, void* context)
|
|
: pin(pin)
|
|
, type(type)
|
|
, isr(isr)
|
|
, context(context)
|
|
{}
|
|
|
|
virtual ~LevelInterruptHandler() {
|
|
disarm();
|
|
}
|
|
|
|
|
|
void install();
|
|
void arm();
|
|
void disarm();
|
|
};
|