You've already forked arduino-LoRa
mirror of
https://github.com/sandeepmistry/arduino-LoRa.git
synced 2025-07-10 22:00:57 +03:00
Add receive callback mode using DIO0
This commit is contained in:
18
src/LoRa.h
18
src/LoRa.h
@ -4,6 +4,10 @@
|
||||
#include <Arduino.h>
|
||||
#include <SPI.h>
|
||||
|
||||
#define LORA_DEFAULT_SS_PIN 10
|
||||
#define LORA_DEFAULT_RESET_PIN 9
|
||||
#define LORA_DEFAULT_DIO0_PIN 2
|
||||
|
||||
class LoRaClass : public Stream {
|
||||
public:
|
||||
LoRaClass();
|
||||
@ -27,21 +31,33 @@ public:
|
||||
virtual int peek();
|
||||
virtual void flush();
|
||||
|
||||
void setPins(int ss, int reset);
|
||||
void onReceive(void(*callback)(int));
|
||||
|
||||
void receive();
|
||||
void idle();
|
||||
void sleep();
|
||||
|
||||
void setPins(int ss = LORA_DEFAULT_SS_PIN, int reset = LORA_DEFAULT_RESET_PIN, int dio0 = LORA_DEFAULT_DIO0_PIN);
|
||||
|
||||
void dumpRegisters(Stream& out);
|
||||
|
||||
private:
|
||||
void handleDio0Rise();
|
||||
|
||||
uint8_t readRegister(uint8_t address);
|
||||
void writeRegister(uint8_t address, uint8_t value);
|
||||
uint8_t singleTransfer(uint8_t address, uint8_t value);
|
||||
|
||||
static void onDio0Rise();
|
||||
|
||||
private:
|
||||
SPISettings _spiSettings;
|
||||
int _ss;
|
||||
int _reset;
|
||||
int _dio0;
|
||||
int _frequency;
|
||||
int _packetIndex;
|
||||
void (*_onReceive)(int);
|
||||
};
|
||||
|
||||
extern LoRaClass LoRa;
|
||||
|
Reference in New Issue
Block a user