Improve hardware abstraction layer
This commit is contained in:
parent
88549baf83
commit
ec3d4eaf20
56 changed files with 1002 additions and 1853 deletions
|
@ -49,7 +49,7 @@ void setup() {
|
||||||
|
|
||||||
// set the function that will be called
|
// set the function that will be called
|
||||||
// when new packet is received
|
// when new packet is received
|
||||||
radio.setGdo0Action(setFlag);
|
radio.setGdo0Action(setFlag, RISING);
|
||||||
|
|
||||||
// start listening for packets
|
// start listening for packets
|
||||||
Serial.print(F("[CC1101] Starting to listen ... "));
|
Serial.print(F("[CC1101] Starting to listen ... "));
|
||||||
|
|
|
@ -51,7 +51,7 @@ void setup() {
|
||||||
// NOTE: Unlike other modules (such as SX127x),
|
// NOTE: Unlike other modules (such as SX127x),
|
||||||
// different GDOx pins are used for
|
// different GDOx pins are used for
|
||||||
// transmit and receive interrupts!
|
// transmit and receive interrupts!
|
||||||
radio.setGdo2Action(setFlag);
|
radio.setGdo2Action(setFlag, FALLING);
|
||||||
|
|
||||||
// start transmitting the first packet
|
// start transmitting the first packet
|
||||||
Serial.print(F("[CC1101] Sending first packet ... "));
|
Serial.print(F("[CC1101] Sending first packet ... "));
|
||||||
|
|
|
@ -32,7 +32,7 @@ STM32WLx radio = new STM32WLx_Module();
|
||||||
|
|
||||||
// set RF switch configuration for Nucleo WL55JC1
|
// set RF switch configuration for Nucleo WL55JC1
|
||||||
// NOTE: other boards may be different!
|
// NOTE: other boards may be different!
|
||||||
static const RADIOLIB_PIN_TYPE rfswitch_pins[] =
|
static const uint8_t rfswitch_pins[] =
|
||||||
{PC3, PC4, PC5};
|
{PC3, PC4, PC5};
|
||||||
static const Module::RfSwitchMode_t rfswitch_table[] = {
|
static const Module::RfSwitchMode_t rfswitch_table[] = {
|
||||||
{STM32WLx::MODE_IDLE, {LOW, LOW, LOW}},
|
{STM32WLx::MODE_IDLE, {LOW, LOW, LOW}},
|
||||||
|
|
|
@ -31,7 +31,7 @@ STM32WLx radio = new STM32WLx_Module();
|
||||||
|
|
||||||
// set RF switch configuration for Nucleo WL55JC1
|
// set RF switch configuration for Nucleo WL55JC1
|
||||||
// NOTE: other boards may be different!
|
// NOTE: other boards may be different!
|
||||||
static const RADIOLIB_PIN_TYPE rfswitch_pins[] =
|
static const uint8_t rfswitch_pins[] =
|
||||||
{PC3, PC4, PC5};
|
{PC3, PC4, PC5};
|
||||||
static const Module::RfSwitchMode_t rfswitch_table[] = {
|
static const Module::RfSwitchMode_t rfswitch_table[] = {
|
||||||
{STM32WLx::MODE_IDLE, {LOW, LOW, LOW}},
|
{STM32WLx::MODE_IDLE, {LOW, LOW, LOW}},
|
||||||
|
|
|
@ -28,7 +28,7 @@ STM32WLx radio = new STM32WLx_Module();
|
||||||
|
|
||||||
// set RF switch configuration for Nucleo WL55JC1
|
// set RF switch configuration for Nucleo WL55JC1
|
||||||
// NOTE: other boards may be different!
|
// NOTE: other boards may be different!
|
||||||
static const RADIOLIB_PIN_TYPE rfswitch_pins[] =
|
static const uint8_t rfswitch_pins[] =
|
||||||
{PC3, PC4, PC5};
|
{PC3, PC4, PC5};
|
||||||
static const Module::RfSwitchMode_t rfswitch_table[] = {
|
static const Module::RfSwitchMode_t rfswitch_table[] = {
|
||||||
{STM32WLx::MODE_IDLE, {LOW, LOW, LOW}},
|
{STM32WLx::MODE_IDLE, {LOW, LOW, LOW}},
|
||||||
|
|
|
@ -23,7 +23,7 @@ STM32WLx radio = new STM32WLx_Module();
|
||||||
|
|
||||||
// set RF switch configuration for Nucleo WL55JC1
|
// set RF switch configuration for Nucleo WL55JC1
|
||||||
// NOTE: other boards may be different!
|
// NOTE: other boards may be different!
|
||||||
static const RADIOLIB_PIN_TYPE rfswitch_pins[] =
|
static const uint8_t rfswitch_pins[] =
|
||||||
{PC3, PC4, PC5};
|
{PC3, PC4, PC5};
|
||||||
static const Module::RfSwitchMode_t rfswitch_table[] = {
|
static const Module::RfSwitchMode_t rfswitch_table[] = {
|
||||||
{STM32WLx::MODE_IDLE, {LOW, LOW, LOW}},
|
{STM32WLx::MODE_IDLE, {LOW, LOW, LOW}},
|
||||||
|
|
|
@ -47,11 +47,11 @@ void setup() {
|
||||||
|
|
||||||
// set the function that will be called
|
// set the function that will be called
|
||||||
// when LoRa preamble is not detected within CAD timeout period
|
// when LoRa preamble is not detected within CAD timeout period
|
||||||
radio.setDio0Action(setFlagTimeout);
|
radio.setDio0Action(setFlagTimeout, RISING);
|
||||||
|
|
||||||
// set the function that will be called
|
// set the function that will be called
|
||||||
// when LoRa preamble is detected
|
// when LoRa preamble is detected
|
||||||
radio.setDio1Action(setFlagDetected);
|
radio.setDio1Action(setFlagDetected, RISING);
|
||||||
|
|
||||||
// start scanning the channel
|
// start scanning the channel
|
||||||
Serial.print(F("[SX1278] Starting scan for LoRa preamble ... "));
|
Serial.print(F("[SX1278] Starting scan for LoRa preamble ... "));
|
||||||
|
|
|
@ -53,11 +53,11 @@ void setup() {
|
||||||
// set the function that will be called
|
// set the function that will be called
|
||||||
// when LoRa preamble is not detected within CAD timeout period
|
// when LoRa preamble is not detected within CAD timeout period
|
||||||
// or when a packet is received
|
// or when a packet is received
|
||||||
radio.setDio0Action(setFlagTimeout);
|
radio.setDio0Action(setFlagTimeout, RISING);
|
||||||
|
|
||||||
// set the function that will be called
|
// set the function that will be called
|
||||||
// when LoRa preamble is detected
|
// when LoRa preamble is detected
|
||||||
radio.setDio1Action(setFlagDetected);
|
radio.setDio1Action(setFlagDetected, RISING);
|
||||||
|
|
||||||
// start scanning the channel
|
// start scanning the channel
|
||||||
Serial.print(F("[SX1278] Starting scan for LoRa preamble ... "));
|
Serial.print(F("[SX1278] Starting scan for LoRa preamble ... "));
|
||||||
|
|
|
@ -60,7 +60,7 @@ void setup() {
|
||||||
|
|
||||||
// set the function that will be called
|
// set the function that will be called
|
||||||
// when new packet is received
|
// when new packet is received
|
||||||
radio.setDio0Action(setFlag);
|
radio.setDio0Action(setFlag, RISING);
|
||||||
|
|
||||||
#if defined(INITIATING_NODE)
|
#if defined(INITIATING_NODE)
|
||||||
// send the first packet on this node
|
// send the first packet on this node
|
||||||
|
|
|
@ -96,10 +96,10 @@ void setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the function to call when reception is finished
|
// set the function to call when reception is finished
|
||||||
radio.setDio0Action(setRxFlag);
|
radio.setDio0Action(setRxFlag, RISING);
|
||||||
|
|
||||||
// set the function to call when we need to change frequency
|
// set the function to call when we need to change frequency
|
||||||
radio.setDio1Action(setFHSSFlag);
|
radio.setDio1Action(setFHSSFlag, RISING);
|
||||||
|
|
||||||
// start listening for LoRa packets
|
// start listening for LoRa packets
|
||||||
Serial.print(F("[SX1278] Starting to listen ... "));
|
Serial.print(F("[SX1278] Starting to listen ... "));
|
||||||
|
|
|
@ -51,7 +51,7 @@ void setup() {
|
||||||
|
|
||||||
// set the function that will be called
|
// set the function that will be called
|
||||||
// when new packet is received
|
// when new packet is received
|
||||||
radio.setDio0Action(setFlag);
|
radio.setDio0Action(setFlag, RISING);
|
||||||
|
|
||||||
// start listening for LoRa packets
|
// start listening for LoRa packets
|
||||||
Serial.print(F("[SX1278] Starting to listen ... "));
|
Serial.print(F("[SX1278] Starting to listen ... "));
|
||||||
|
|
|
@ -108,10 +108,10 @@ void setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the function to call when transmission is finished
|
// set the function to call when transmission is finished
|
||||||
radio.setDio0Action(setTxFlag);
|
radio.setDio0Action(setTxFlag, RISING);
|
||||||
|
|
||||||
// set the function to call when we need to change frequency
|
// set the function to call when we need to change frequency
|
||||||
radio.setDio1Action(setFHSSFlag);
|
radio.setDio1Action(setFHSSFlag, RISING);
|
||||||
|
|
||||||
// start transmitting the first packet
|
// start transmitting the first packet
|
||||||
Serial.print(F("[SX1278] Sending first packet ... "));
|
Serial.print(F("[SX1278] Sending first packet ... "));
|
||||||
|
|
|
@ -50,7 +50,7 @@ void setup() {
|
||||||
|
|
||||||
// set the function that will be called
|
// set the function that will be called
|
||||||
// when packet transmission is finished
|
// when packet transmission is finished
|
||||||
radio.setDio0Action(setFlag);
|
radio.setDio0Action(setFlag, RISING);
|
||||||
|
|
||||||
// start transmitting the first packet
|
// start transmitting the first packet
|
||||||
Serial.print(F("[SX1278] Sending first packet ... "));
|
Serial.print(F("[SX1278] Sending first packet ... "));
|
||||||
|
|
146
src/ArduinoHal.cpp
Normal file
146
src/ArduinoHal.cpp
Normal file
|
@ -0,0 +1,146 @@
|
||||||
|
#include "ArduinoHal.h"
|
||||||
|
|
||||||
|
#if defined(RADIOLIB_BUILD_ARDUINO)
|
||||||
|
|
||||||
|
ArduinoHal::ArduinoHal(SPIClass& spi, SPISettings spiSettings): Hal(INPUT, OUTPUT, LOW, HIGH, RISING, FALLING), _spi(&spi), _spiSettings(spiSettings) {}
|
||||||
|
|
||||||
|
ArduinoHal::ArduinoHal(): Hal(INPUT, OUTPUT, LOW, HIGH, RISING, FALLING), _spi(&RADIOLIB_DEFAULT_SPI), _initInterface(true) {}
|
||||||
|
|
||||||
|
void ArduinoHal::init() {
|
||||||
|
if(_initInterface) {
|
||||||
|
spiBegin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ArduinoHal::term() {
|
||||||
|
if(_initInterface) {
|
||||||
|
spiEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void inline ArduinoHal::pinMode(uint8_t pin, uint8_t mode) {
|
||||||
|
if (pin == RADIOLIB_NC) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
::pinMode(pin, RADIOLIB_ARDUINOHAL_PIN_MODE_CAST mode);
|
||||||
|
}
|
||||||
|
void inline ArduinoHal::digitalWrite(uint8_t pin, uint8_t value) {
|
||||||
|
if (pin == RADIOLIB_NC) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
::digitalWrite(pin, RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST value);
|
||||||
|
}
|
||||||
|
uint8_t inline ArduinoHal::digitalRead(uint8_t pin) {
|
||||||
|
if (pin == RADIOLIB_NC) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return ::digitalRead(pin);
|
||||||
|
}
|
||||||
|
void inline ArduinoHal::attachInterrupt(uint8_t interruptNum, void (*interruptCb)(void), uint8_t mode) {
|
||||||
|
if (interruptNum == RADIOLIB_NC) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
::attachInterrupt(interruptNum, interruptCb, RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST mode);
|
||||||
|
}
|
||||||
|
void inline ArduinoHal::detachInterrupt(uint8_t interruptNum) {
|
||||||
|
if (interruptNum == RADIOLIB_NC) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
::detachInterrupt(interruptNum);
|
||||||
|
}
|
||||||
|
void inline ArduinoHal::delay(unsigned long ms) {
|
||||||
|
::delay(ms);
|
||||||
|
}
|
||||||
|
void inline ArduinoHal::delayMicroseconds(unsigned long us) {
|
||||||
|
::delayMicroseconds(us);
|
||||||
|
}
|
||||||
|
unsigned long inline ArduinoHal::millis() {
|
||||||
|
return ::millis();
|
||||||
|
}
|
||||||
|
unsigned long inline ArduinoHal::micros() {
|
||||||
|
return ::micros();
|
||||||
|
}
|
||||||
|
long inline ArduinoHal::pulseIn(uint8_t pin, uint8_t state, unsigned long timeout) {
|
||||||
|
if (pin == RADIOLIB_NC) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return ::pulseIn(pin, state, timeout);
|
||||||
|
}
|
||||||
|
void inline ArduinoHal::spiBegin() {
|
||||||
|
_spi->begin();
|
||||||
|
}
|
||||||
|
void inline ArduinoHal::spiBeginTransaction() {
|
||||||
|
_spi->beginTransaction(_spiSettings);
|
||||||
|
}
|
||||||
|
uint8_t inline ArduinoHal::spiTransfer(uint8_t b) {
|
||||||
|
return _spi->transfer(b);
|
||||||
|
}
|
||||||
|
void inline ArduinoHal::spiEndTransaction() {
|
||||||
|
_spi->endTransaction();
|
||||||
|
}
|
||||||
|
void inline ArduinoHal::spiEnd() {
|
||||||
|
_spi->end();
|
||||||
|
}
|
||||||
|
void inline ArduinoHal::tone(uint8_t pin, unsigned int frequency, unsigned long duration) {
|
||||||
|
#if !defined(RADIOLIB_TONE_UNSUPPORTED)
|
||||||
|
if (pin == RADIOLIB_NC) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
::tone(pin, frequency, duration);
|
||||||
|
#elif defined(ESP32)
|
||||||
|
// ESP32 tone() emulation
|
||||||
|
(void)duration;
|
||||||
|
if(_prev == -1) {
|
||||||
|
ledcAttachPin(pin, RADIOLIB_TONE_ESP32_CHANNEL);
|
||||||
|
}
|
||||||
|
if(_prev != frequency) {
|
||||||
|
ledcWriteTone(RADIOLIB_TONE_ESP32_CHANNEL, frequency);
|
||||||
|
}
|
||||||
|
_prev = frequency;
|
||||||
|
#elif defined(RADIOLIB_MBED_TONE_OVERRIDE)
|
||||||
|
// better tone for mbed OS boards
|
||||||
|
(void)duration;
|
||||||
|
if(!pwmPin) {
|
||||||
|
pwmPin = new mbed::PwmOut(digitalPinToPinName(pin));
|
||||||
|
}
|
||||||
|
pwmPin->period(1.0 / frequency);
|
||||||
|
pwmPin->write(0.5);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
void inline ArduinoHal::noTone(uint8_t pin) {
|
||||||
|
#if !defined(RADIOLIB_TONE_UNSUPPORTED) and defined(ARDUINO_ARCH_STM32)
|
||||||
|
if (pin == RADIOLIB_NC) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
::noTone(pin, false);
|
||||||
|
#elif !defined(RADIOLIB_TONE_UNSUPPORTED)
|
||||||
|
if (pin == RADIOLIB_NC) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
::noTone(pin);
|
||||||
|
#elif defined(ESP32)
|
||||||
|
if (pin == RADIOLIB_NC) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// ESP32 tone() emulation
|
||||||
|
ledcDetachPin(pin);
|
||||||
|
ledcWrite(RADIOLIB_TONE_ESP32_CHANNEL, 0);
|
||||||
|
_prev = -1;
|
||||||
|
#elif defined(RADIOLIB_MBED_TONE_OVERRIDE)
|
||||||
|
if (pin == RADIOLIB_NC) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// better tone for mbed OS boards
|
||||||
|
(void)pin;
|
||||||
|
pwmPin->suspend();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
void inline ArduinoHal::yield() {
|
||||||
|
#if !defined(RADIOLIB_YIELD_UNSUPPORTED)
|
||||||
|
::yield();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
uint8_t inline ArduinoHal::pinToInterrupt(uint8_t pin) {
|
||||||
|
return digitalPinToInterrupt(pin);
|
||||||
|
}
|
||||||
|
#endif
|
62
src/ArduinoHal.h
Normal file
62
src/ArduinoHal.h
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
#include "TypeDef.h"
|
||||||
|
|
||||||
|
#if !defined(_RADIOLIB_ARDUINOHAL_H)
|
||||||
|
#define _RADIOLIB_ARDUINOHAL_H
|
||||||
|
|
||||||
|
#if defined(RADIOLIB_BUILD_ARDUINO)
|
||||||
|
|
||||||
|
#if defined(RADIOLIB_MBED_TONE_OVERRIDE)
|
||||||
|
#include "mbed.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "Hal.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <SPI.h>
|
||||||
|
|
||||||
|
class ArduinoHal : public Hal {
|
||||||
|
public:
|
||||||
|
ArduinoHal();
|
||||||
|
ArduinoHal(SPIClass& spi, SPISettings spiSettings = RADIOLIB_DEFAULT_SPI_SETTINGS);
|
||||||
|
|
||||||
|
void init() override;
|
||||||
|
void term() override;
|
||||||
|
|
||||||
|
void pinMode(uint8_t pin, uint8_t mode) override;
|
||||||
|
void digitalWrite(uint8_t pin, uint8_t value) override;
|
||||||
|
uint8_t digitalRead(uint8_t pin) override;
|
||||||
|
void attachInterrupt(uint8_t interruptNum, void (*interruptCb)(void), uint8_t mode) override;
|
||||||
|
void detachInterrupt(uint8_t interruptNum) override;
|
||||||
|
void delay(unsigned long ms) override;
|
||||||
|
void delayMicroseconds(unsigned long us) override;
|
||||||
|
unsigned long millis() override;
|
||||||
|
unsigned long micros() override;
|
||||||
|
long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout) override;
|
||||||
|
void spiBegin() override;
|
||||||
|
void spiBeginTransaction() override;
|
||||||
|
uint8_t spiTransfer(uint8_t b) override;
|
||||||
|
void spiEndTransaction() override;
|
||||||
|
void spiEnd() override;
|
||||||
|
void tone(uint8_t pin, unsigned int frequency, unsigned long duration = 0) override;
|
||||||
|
void noTone(uint8_t pin) override;
|
||||||
|
void yield() override;
|
||||||
|
uint8_t pinToInterrupt(uint8_t pin) override;
|
||||||
|
|
||||||
|
#if !defined(RADIOLIB_GODMODE)
|
||||||
|
private:
|
||||||
|
#endif
|
||||||
|
SPIClass* _spi = NULL;
|
||||||
|
SPISettings _spiSettings = RADIOLIB_DEFAULT_SPI_SETTINGS;
|
||||||
|
bool _initInterface = false;
|
||||||
|
|
||||||
|
#if defined(RADIOLIB_MBED_TONE_OVERRIDE)
|
||||||
|
mbed::PwmOut *pwmPin = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ESP32)
|
||||||
|
int32_t _prev = -1;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
825
src/BuildOpt.h
825
src/BuildOpt.h
|
@ -7,21 +7,16 @@
|
||||||
#define RADIOLIB_BUILD_ARDUINO
|
#define RADIOLIB_BUILD_ARDUINO
|
||||||
#else
|
#else
|
||||||
// generic build
|
// generic build
|
||||||
|
#include <stdio.h>
|
||||||
#define RADIOLIB_BUILD_GENERIC
|
#define RADIOLIB_BUILD_GENERIC
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(RADIOLIB_BUILD_ARDUINO)
|
#if defined(RADIOLIB_BUILD_ARDUINO)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Platform-specific configuration.
|
* Platform-specific configuration.
|
||||||
*
|
*
|
||||||
* RADIOLIB_PLATFORM - platform name, used in debugging to quickly check the correct platform is detected.
|
* RADIOLIB_PLATFORM - platform name, used in debugging to quickly check the correct platform is detected.
|
||||||
* RADIOLIB_PIN_TYPE - which type should be used for pin numbers in functions like digitalRead().
|
* RADIOLIB_NC - alias for unused pin, usually the largest possible value of uint8_t.
|
||||||
* RADIOLIB_PIN_MODE - which type should be used for pin modes in functions like pinMode().
|
|
||||||
* RADIOLIB_PIN_STATUS - which type should be used for pin values in functions like digitalWrite().
|
|
||||||
* RADIOLIB_INTERRUPT_STATUS - which type should be used for pin changes in functions like attachInterrupt().
|
|
||||||
* RADIOLIB_DIGITAL_PIN_TO_INTERRUPT - function/macro to be used to convert digital pin number to interrupt pin number.
|
|
||||||
* RADIOLIB_NC - alias for unused pin, usually the largest possible value of RADIOLIB_PIN_TYPE.
|
|
||||||
* RADIOLIB_DEFAULT_SPI - default SPIClass instance to use.
|
* RADIOLIB_DEFAULT_SPI - default SPIClass instance to use.
|
||||||
* RADIOLIB_NONVOLATILE - macro to place variable into program storage (usually Flash).
|
* RADIOLIB_NONVOLATILE - macro to place variable into program storage (usually Flash).
|
||||||
* RADIOLIB_NONVOLATILE_READ_BYTE - function/macro to read variables saved in program storage (usually Flash).
|
* RADIOLIB_NONVOLATILE_READ_BYTE - function/macro to read variables saved in program storage (usually Flash).
|
||||||
|
@ -43,44 +38,9 @@
|
||||||
// name for your platform
|
// name for your platform
|
||||||
#define RADIOLIB_PLATFORM "Custom"
|
#define RADIOLIB_PLATFORM "Custom"
|
||||||
|
|
||||||
// the following parameters must always be defined
|
// the following must be defined if the Arduino core does not support tone or yield function
|
||||||
#define RADIOLIB_PIN_TYPE uint8_t
|
|
||||||
#define RADIOLIB_PIN_MODE uint8_t
|
|
||||||
#define RADIOLIB_PIN_STATUS uint8_t
|
|
||||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
|
||||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
|
||||||
#define RADIOLIB_NC (0xFF)
|
|
||||||
#define RADIOLIB_DEFAULT_SPI SPI
|
|
||||||
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
|
|
||||||
#define RADIOLIB_NONVOLATILE PROGMEM
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
|
|
||||||
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
|
|
||||||
|
|
||||||
// Arduino API callbacks
|
|
||||||
// the following are signatures of Arduino API functions of the custom platform
|
|
||||||
// for example, pinMode on Arduino Uno is defined as void pinMode(uint8_t pin, uint8_t mode)
|
|
||||||
// all of the callbacks below are taken from Arduino Uno
|
|
||||||
#define RADIOLIB_CB_ARGS_PIN_MODE (void, pinMode, uint8_t pin, uint8_t mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_WRITE (void, digitalWrite, uint8_t pin, uint8_t value)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_READ (int, digitalRead, uint8_t pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_TONE (void, tone, uint8_t _pin, unsigned int frequency, unsigned long duration)
|
|
||||||
#define RADIOLIB_CB_ARGS_NO_TONE (void, noTone, uint8_t _pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_ATTACH_INTERRUPT (void, attachInterrupt, uint8_t interruptNum, void (*userFunc)(void), int mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DETACH_INTERRUPT (void, detachInterrupt, uint8_t interruptNum)
|
|
||||||
#define RADIOLIB_CB_ARGS_YIELD (void, yield, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY (void, delay, unsigned long ms)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY_MICROSECONDS (void, delayMicroseconds, unsigned int us)
|
|
||||||
#define RADIOLIB_CB_ARGS_MILLIS (unsigned long, millis, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_MICROS (unsigned long, micros, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_PULSE_IN (unsigned long, pulseIn, uint8_t pin, uint8_t state, unsigned long timeout)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN (void, SPIbegin, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN_TRANSACTION (void, SPIbeginTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_TRANSFER (uint8_t, SPItransfer, uint8_t b)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END_TRANSACTION (void, SPIendTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END (void, SPIend, void)
|
|
||||||
|
|
||||||
// the following must be defined if the Arduino core does not support tone function
|
|
||||||
//#define RADIOLIB_TONE_UNSUPPORTED
|
//#define RADIOLIB_TONE_UNSUPPORTED
|
||||||
|
//#define RADIOLIB_YIELD_UNSUPPORTED
|
||||||
|
|
||||||
// some of RadioLib drivers may be excluded, to prevent collisions with platforms (or to speed up build process)
|
// some of RadioLib drivers may be excluded, to prevent collisions with platforms (or to speed up build process)
|
||||||
// the following is a complete list of all possible exclusion macros, uncomment any of them to disable that driver
|
// the following is a complete list of all possible exclusion macros, uncomment any of them to disable that driver
|
||||||
|
@ -105,671 +65,107 @@
|
||||||
//#define RADIOLIB_EXCLUDE_RTTY
|
//#define RADIOLIB_EXCLUDE_RTTY
|
||||||
//#define RADIOLIB_EXCLUDE_SSTV
|
//#define RADIOLIB_EXCLUDE_SSTV
|
||||||
//#define RADIOLIB_EXCLUDE_DIRECT_RECEIVE
|
//#define RADIOLIB_EXCLUDE_DIRECT_RECEIVE
|
||||||
|
#elif defined(__AVR__) && !(defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) || defined(ARDUINO_ARCH_MEGAAVR))
|
||||||
#else
|
|
||||||
#if defined(__AVR__) && !(defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) || defined(ARDUINO_ARCH_MEGAAVR))
|
|
||||||
// Arduino AVR boards (except for megaAVR) - Uno, Mega etc.
|
// Arduino AVR boards (except for megaAVR) - Uno, Mega etc.
|
||||||
#define RADIOLIB_PLATFORM "Arduino AVR"
|
#define RADIOLIB_PLATFORM "Arduino AVR"
|
||||||
#define RADIOLIB_PIN_TYPE uint8_t
|
|
||||||
#define RADIOLIB_PIN_MODE uint8_t
|
|
||||||
#define RADIOLIB_PIN_STATUS uint8_t
|
|
||||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
|
||||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
|
||||||
#define RADIOLIB_NC (0xFF)
|
|
||||||
#define RADIOLIB_DEFAULT_SPI SPI
|
|
||||||
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
|
|
||||||
#define RADIOLIB_NONVOLATILE PROGMEM
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
|
|
||||||
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
|
|
||||||
|
|
||||||
// Arduino API callbacks
|
|
||||||
#define RADIOLIB_CB_ARGS_PIN_MODE (void, pinMode, uint8_t pin, uint8_t mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_WRITE (void, digitalWrite, uint8_t pin, uint8_t value)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_READ (int, digitalRead, uint8_t pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_TONE (void, tone, uint8_t _pin, unsigned int frequency, unsigned long duration)
|
|
||||||
#define RADIOLIB_CB_ARGS_NO_TONE (void, noTone, uint8_t _pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_ATTACH_INTERRUPT (void, attachInterrupt, uint8_t interruptNum, void (*userFunc)(void), int mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DETACH_INTERRUPT (void, detachInterrupt, uint8_t interruptNum)
|
|
||||||
#define RADIOLIB_CB_ARGS_YIELD (void, yield, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY (void, delay, unsigned long ms)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY_MICROSECONDS (void, delayMicroseconds, unsigned int us)
|
|
||||||
#define RADIOLIB_CB_ARGS_MILLIS (unsigned long, millis, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_MICROS (unsigned long, micros, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_PULSE_IN (unsigned long, pulseIn, uint8_t pin, uint8_t state, unsigned long timeout)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN (void, SPIbegin, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN_TRANSACTION (void, SPIbeginTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_TRANSFER (uint8_t, SPItransfer, uint8_t b)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END_TRANSACTION (void, SPIendTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END (void, SPIend, void)
|
|
||||||
|
|
||||||
#elif defined(ESP8266)
|
#elif defined(ESP8266)
|
||||||
// ESP8266 boards
|
// ESP8266 boards
|
||||||
#define RADIOLIB_PLATFORM "ESP8266"
|
#define RADIOLIB_PLATFORM "ESP8266"
|
||||||
#define RADIOLIB_PIN_TYPE uint8_t
|
|
||||||
#define RADIOLIB_PIN_MODE uint8_t
|
|
||||||
#define RADIOLIB_PIN_STATUS uint8_t
|
|
||||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
|
||||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
|
||||||
#define RADIOLIB_NC (0xFF)
|
|
||||||
#define RADIOLIB_DEFAULT_SPI SPI
|
|
||||||
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
|
|
||||||
#define RADIOLIB_NONVOLATILE PROGMEM
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
|
|
||||||
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
|
|
||||||
|
|
||||||
// Arduino API callbacks
|
|
||||||
#define RADIOLIB_CB_ARGS_PIN_MODE (void, pinMode, uint8_t pin, uint8_t mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_WRITE (void, digitalWrite, uint8_t pin, uint8_t value)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_READ (int, digitalRead, uint8_t pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_TONE (void, tone, uint8_t _pin, unsigned int frequency, unsigned long duration)
|
|
||||||
#define RADIOLIB_CB_ARGS_NO_TONE (void, noTone, uint8_t _pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_ATTACH_INTERRUPT (void, attachInterrupt, uint8_t pin, void (*)(void), int mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DETACH_INTERRUPT (void, detachInterrupt, uint8_t interruptNum)
|
|
||||||
#define RADIOLIB_CB_ARGS_YIELD (void, yield, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY (void, delay, unsigned long)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY_MICROSECONDS (void, delayMicroseconds, unsigned int us)
|
|
||||||
#define RADIOLIB_CB_ARGS_MILLIS (unsigned long, millis, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_MICROS (unsigned long, micros, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_PULSE_IN (unsigned long, pulseIn, uint8_t pin, uint8_t state, unsigned long timeout)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN (void, SPIbegin, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN_TRANSACTION (void, SPIbeginTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_TRANSFER (uint8_t, SPItransfer, uint8_t b)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END_TRANSACTION (void, SPIendTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END (void, SPIend, void)
|
|
||||||
|
|
||||||
#elif defined(ESP32)
|
#elif defined(ESP32)
|
||||||
// ESP32 boards
|
// ESP32 boards
|
||||||
#define RADIOLIB_PLATFORM "ESP32"
|
#define RADIOLIB_PLATFORM "ESP32"
|
||||||
#define RADIOLIB_PIN_TYPE uint8_t
|
|
||||||
#define RADIOLIB_PIN_MODE uint8_t
|
|
||||||
#define RADIOLIB_PIN_STATUS uint8_t
|
|
||||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
|
||||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
|
||||||
#define RADIOLIB_NC (0xFF)
|
|
||||||
#define RADIOLIB_DEFAULT_SPI SPI
|
|
||||||
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
|
|
||||||
#define RADIOLIB_NONVOLATILE PROGMEM
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
|
|
||||||
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
|
|
||||||
|
|
||||||
// ESP32 doesn't support tone(), but it can be emulated via LED control peripheral
|
// ESP32 doesn't support tone(), but it can be emulated via LED control peripheral
|
||||||
#define RADIOLIB_TONE_UNSUPPORTED
|
#define RADIOLIB_TONE_UNSUPPORTED
|
||||||
#define RADIOLIB_TONE_ESP32_CHANNEL (1)
|
#define RADIOLIB_TONE_ESP32_CHANNEL (1)
|
||||||
|
|
||||||
// Arduino API callbacks
|
|
||||||
#define RADIOLIB_CB_ARGS_PIN_MODE (void, pinMode, uint8_t pin, uint8_t mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_WRITE (void, digitalWrite, uint8_t pin, uint8_t value)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_READ (int, digitalRead, uint8_t pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_TONE (void, tone, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_NO_TONE (void, noTone, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_ATTACH_INTERRUPT (void, attachInterrupt, uint8_t pin, void (*)(void), int mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DETACH_INTERRUPT (void, detachInterrupt, uint8_t pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_YIELD (void, yield, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY (void, delay, uint32_t)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY_MICROSECONDS (void, delayMicroseconds, uint32_t us)
|
|
||||||
#define RADIOLIB_CB_ARGS_MILLIS (unsigned long, millis, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_MICROS (unsigned long, micros, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_PULSE_IN (unsigned long, pulseIn, uint8_t pin, uint8_t state, unsigned long timeout)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN (void, SPIbegin, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN_TRANSACTION (void, SPIbeginTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_TRANSFER (uint8_t, SPItransfer, uint8_t b)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END_TRANSACTION (void, SPIendTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END (void, SPIend, void)
|
|
||||||
|
|
||||||
#elif defined(ARDUINO_ARCH_STM32)
|
#elif defined(ARDUINO_ARCH_STM32)
|
||||||
// official STM32 Arduino core (https://github.com/stm32duino/Arduino_Core_STM32)
|
// official STM32 Arduino core (https://github.com/stm32duino/Arduino_Core_STM32)
|
||||||
#define RADIOLIB_PLATFORM "Arduino STM32 (official)"
|
#define RADIOLIB_PLATFORM "Arduino STM32 (official)"
|
||||||
#define RADIOLIB_PIN_TYPE uint32_t
|
|
||||||
#define RADIOLIB_PIN_MODE uint32_t
|
|
||||||
#define RADIOLIB_PIN_STATUS uint32_t
|
|
||||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
|
||||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
|
||||||
#define RADIOLIB_NC (0xFFFFFFFF)
|
|
||||||
#define RADIOLIB_DEFAULT_SPI SPI
|
|
||||||
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
|
|
||||||
#define RADIOLIB_NONVOLATILE PROGMEM
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
|
|
||||||
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
|
|
||||||
|
|
||||||
// Arduino API callbacks
|
|
||||||
#define RADIOLIB_CB_ARGS_PIN_MODE (void, pinMode, uint32_t dwPin, uint32_t dwMode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_WRITE (void, digitalWrite, uint32_t dwPin, uint32_t dwVal)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_READ (int, digitalRead, uint32_t ulPin)
|
|
||||||
#define RADIOLIB_CB_ARGS_TONE (void, tone, uint8_t _pin, unsigned int frequency, unsigned long duration)
|
|
||||||
#define RADIOLIB_CB_ARGS_NO_TONE (void, noTone, uint8_t _pin, bool destruct)
|
|
||||||
#define RADIOLIB_CB_ARGS_ATTACH_INTERRUPT (void, attachInterrupt, uint32_t pin, callback_function_t callback, uint32_t mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DETACH_INTERRUPT (void, detachInterrupt, uint32_t pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_YIELD (void, yield, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY (void, delay, uint32_t ms)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY_MICROSECONDS (void, delayMicroseconds, uint32_t us)
|
|
||||||
#define RADIOLIB_CB_ARGS_MILLIS (uint32_t, millis, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_MICROS (uint32_t, micros, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_PULSE_IN (uint32_t, pulseIn, uint32_t pin, uint32_t state, uint32_t timeout)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN (void, SPIbegin, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN_TRANSACTION (void, SPIbeginTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_TRANSFER (uint8_t, SPItransfer, uint8_t b)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END_TRANSACTION (void, SPIendTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END (void, SPIend, void)
|
|
||||||
|
|
||||||
#elif defined(SAMD_SERIES)
|
#elif defined(SAMD_SERIES)
|
||||||
// Adafruit SAMD boards (M0 and M4)
|
// Adafruit SAMD boards (M0 and M4)
|
||||||
#define RADIOLIB_PLATFORM "Adafruit SAMD"
|
#define RADIOLIB_PLATFORM "Adafruit SAMD"
|
||||||
#define RADIOLIB_PIN_TYPE uint32_t
|
|
||||||
#define RADIOLIB_PIN_MODE uint32_t
|
|
||||||
#define RADIOLIB_PIN_STATUS uint32_t
|
|
||||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
|
||||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
|
||||||
#define RADIOLIB_NC (0xFFFFFFFF)
|
|
||||||
#define RADIOLIB_DEFAULT_SPI SPI
|
|
||||||
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
|
|
||||||
#define RADIOLIB_NONVOLATILE PROGMEM
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
|
|
||||||
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
|
|
||||||
|
|
||||||
// Arduino API callbacks
|
|
||||||
#define RADIOLIB_CB_ARGS_PIN_MODE (void, pinMode, uint32_t dwPin, uint32_t dwMode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_WRITE (void, digitalWrite, uint32_t dwPin, uint32_t dwVal)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_READ (int, digitalRead, uint32_t ulPin)
|
|
||||||
#define RADIOLIB_CB_ARGS_TONE (void, tone, uint32_t _pin, uint32_t frequency, uint32_t duration)
|
|
||||||
#define RADIOLIB_CB_ARGS_NO_TONE (void, noTone, uint32_t _pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_ATTACH_INTERRUPT (void, attachInterrupt, uint32_t pin, voidFuncPtr callback, uint32_t mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DETACH_INTERRUPT (void, detachInterrupt, uint32_t pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_YIELD (void, yield, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY (void, delay, unsigned long dwMs)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY_MICROSECONDS (void, delayMicroseconds, unsigned int)
|
|
||||||
#define RADIOLIB_CB_ARGS_MILLIS (unsigned long, millis, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_MICROS (unsigned long, micros, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_PULSE_IN (uint32_t, pulseIn, uint32_t pin, uint32_t state, uint32_t timeout)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN (void, SPIbegin, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN_TRANSACTION (void, SPIbeginTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_TRANSFER (uint8_t, SPItransfer, uint8_t b)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END_TRANSACTION (void, SPIendTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END (void, SPIend, void)
|
|
||||||
|
|
||||||
#elif defined(ARDUINO_ARCH_SAMD)
|
#elif defined(ARDUINO_ARCH_SAMD)
|
||||||
// Arduino SAMD (Zero, MKR, etc.)
|
// Arduino SAMD (Zero, MKR, etc.)
|
||||||
#define RADIOLIB_PLATFORM "Arduino SAMD"
|
#define RADIOLIB_PLATFORM "Arduino SAMD"
|
||||||
#define RADIOLIB_PIN_TYPE pin_size_t
|
|
||||||
#define RADIOLIB_PIN_MODE PinMode
|
|
||||||
#define RADIOLIB_PIN_STATUS PinStatus
|
|
||||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
|
||||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
|
||||||
#define RADIOLIB_NC (0xFF)
|
|
||||||
#define RADIOLIB_DEFAULT_SPI SPI
|
|
||||||
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
|
|
||||||
#define RADIOLIB_NONVOLATILE PROGMEM
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
|
|
||||||
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
|
|
||||||
|
|
||||||
// Arduino API callbacks
|
|
||||||
#define RADIOLIB_CB_ARGS_PIN_MODE (void, pinMode, pin_size_t pinNumber, PinMode pinMode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_WRITE (void, digitalWrite, pin_size_t pinNumber, PinStatus status)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_READ (PinStatus, digitalRead, pin_size_t pinNumber)
|
|
||||||
#define RADIOLIB_CB_ARGS_TONE (void, tone, unsigned char outputPin, unsigned int frequency, unsigned long duration)
|
|
||||||
#define RADIOLIB_CB_ARGS_NO_TONE (void, noTone, uint8_t outputPin)
|
|
||||||
#define RADIOLIB_CB_ARGS_ATTACH_INTERRUPT (void, attachInterrupt, pin_size_t pin, voidFuncPtr callback, PinStatus mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DETACH_INTERRUPT (void, detachInterrupt, pin_size_t pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_YIELD (void, yield, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY (void, delay, unsigned long)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY_MICROSECONDS (void, delayMicroseconds, unsigned int us)
|
|
||||||
#define RADIOLIB_CB_ARGS_MILLIS (unsigned long, millis, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_MICROS (unsigned long, micros, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_PULSE_IN (uint32_t, pulseIn, pin_size_t pin, uint8_t state, uint32_t timeout)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN (void, SPIbegin, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN_TRANSACTION (void, SPIbeginTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_TRANSFER (uint8_t, SPItransfer, uint8_t b)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END_TRANSACTION (void, SPIendTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END (void, SPIend, void)
|
|
||||||
|
|
||||||
|
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PinMode)
|
||||||
|
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
|
||||||
|
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
|
||||||
#elif defined(__SAM3X8E__)
|
#elif defined(__SAM3X8E__)
|
||||||
// Arduino Due
|
// Arduino Due
|
||||||
#define RADIOLIB_PLATFORM "Arduino Due"
|
#define RADIOLIB_PLATFORM "Arduino Due"
|
||||||
#define RADIOLIB_PIN_TYPE uint32_t
|
|
||||||
#define RADIOLIB_PIN_MODE uint32_t
|
|
||||||
#define RADIOLIB_PIN_STATUS uint32_t
|
|
||||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
|
||||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
|
||||||
#define RADIOLIB_NC (0xFFFFFFFF)
|
|
||||||
#define RADIOLIB_DEFAULT_SPI SPI
|
|
||||||
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
|
|
||||||
#define RADIOLIB_NONVOLATILE PROGMEM
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
|
|
||||||
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
|
|
||||||
#define RADIOLIB_TONE_UNSUPPORTED
|
#define RADIOLIB_TONE_UNSUPPORTED
|
||||||
|
|
||||||
// Arduino API callbacks
|
|
||||||
#define RADIOLIB_CB_ARGS_PIN_MODE (void, pinMode, uint32_t dwPin, uint32_t dwMode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_WRITE (void, digitalWrite, uint32_t dwPin, uint32_t dwVal)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_READ (int, digitalRead, uint32_t ulPin)
|
|
||||||
#define RADIOLIB_CB_ARGS_TONE (void, tone, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_NO_TONE (void, noTone, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_ATTACH_INTERRUPT (void, attachInterrupt, uint32_t pin, void (*callback)(void), uint32_t mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DETACH_INTERRUPT (void, detachInterrupt, uint32_t pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_YIELD (void, yield, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY (void, delay, uint32_t dwMs)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY_MICROSECONDS (void, delayMicroseconds, uint32_t usec)
|
|
||||||
#define RADIOLIB_CB_ARGS_MILLIS (uint32_t, millis, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_MICROS (uint32_t, micros, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_PULSE_IN (uint32_t, pulseIn, uint32_t pin, uint32_t state, uint32_t timeout)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN (void, SPIbegin, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN_TRANSACTION (void, SPIbeginTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_TRANSFER (uint8_t, SPItransfer, uint8_t b)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END_TRANSACTION (void, SPIendTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END (void, SPIend, void)
|
|
||||||
|
|
||||||
#elif (defined(NRF52832_XXAA) || defined(NRF52840_XXAA)) && !defined(ARDUINO_ARDUINO_NANO33BLE)
|
#elif (defined(NRF52832_XXAA) || defined(NRF52840_XXAA)) && !defined(ARDUINO_ARDUINO_NANO33BLE)
|
||||||
// Adafruit nRF52 boards
|
// Adafruit nRF52 boards
|
||||||
#define RADIOLIB_PLATFORM "Adafruit nRF52"
|
#define RADIOLIB_PLATFORM "Adafruit nRF52"
|
||||||
#define RADIOLIB_PIN_TYPE uint32_t
|
|
||||||
#define RADIOLIB_PIN_MODE uint32_t
|
|
||||||
#define RADIOLIB_PIN_STATUS uint32_t
|
|
||||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
|
||||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
|
||||||
#define RADIOLIB_NC (0xFFFFFFFF)
|
|
||||||
#define RADIOLIB_DEFAULT_SPI SPI
|
|
||||||
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
|
|
||||||
#define RADIOLIB_NONVOLATILE PROGMEM
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
|
|
||||||
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
|
|
||||||
|
|
||||||
// Arduino API callbacks
|
|
||||||
#define RADIOLIB_CB_ARGS_PIN_MODE (void, pinMode, uint32_t dwPin, uint32_t dwMode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_WRITE (void, digitalWrite, uint32_t dwPin, uint32_t dwVal)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_READ (int, digitalRead, uint32_t ulPin)
|
|
||||||
#define RADIOLIB_CB_ARGS_TONE (void, tone, uint8_t pin, unsigned int frequency, unsigned long duration)
|
|
||||||
#define RADIOLIB_CB_ARGS_NO_TONE (void, noTone, uint8_t pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_ATTACH_INTERRUPT (int, attachInterrupt, uint32_t pin, voidFuncPtr callback, uint32_t mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DETACH_INTERRUPT (void, detachInterrupt, uint32_t pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_YIELD (void, yield, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY (void, delay, uint32_t dwMs)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY_MICROSECONDS (void, delayMicroseconds, uint32_t usec)
|
|
||||||
#define RADIOLIB_CB_ARGS_MILLIS (uint32_t, millis, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_MICROS (uint32_t, micros, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_PULSE_IN (uint32_t, pulseIn, uint32_t pin, uint32_t state, uint32_t timeout)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN (void, SPIbegin, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN_TRANSACTION (void, SPIbeginTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_TRANSFER (uint8_t, SPItransfer, uint8_t b)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END_TRANSACTION (void, SPIendTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END (void, SPIend, void)
|
|
||||||
|
|
||||||
#elif defined(ARDUINO_ARC32_TOOLS)
|
#elif defined(ARDUINO_ARC32_TOOLS)
|
||||||
// Intel Curie
|
// Intel Curie
|
||||||
#define RADIOLIB_PLATFORM "Intel Curie"
|
#define RADIOLIB_PLATFORM "Intel Curie"
|
||||||
#define RADIOLIB_PIN_TYPE uint8_t
|
|
||||||
#define RADIOLIB_PIN_MODE uint8_t
|
|
||||||
#define RADIOLIB_PIN_STATUS uint8_t
|
|
||||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
|
||||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
|
||||||
#define RADIOLIB_NC (0xFF)
|
|
||||||
#define RADIOLIB_DEFAULT_SPI SPI
|
|
||||||
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
|
|
||||||
#define RADIOLIB_NONVOLATILE PROGMEM
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
|
|
||||||
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
|
|
||||||
|
|
||||||
// Arduino API callbacks
|
|
||||||
#define RADIOLIB_CB_ARGS_PIN_MODE (void, pinMode, uint8_t pin, uint8_t mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_WRITE (void, digitalWrite, uint8_t pin, uint8_t val)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_READ (int, digitalRead, uint8_t pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_TONE (void, tone, uint32_t _pin, unsigned int frequency, unsigned long duration)
|
|
||||||
#define RADIOLIB_CB_ARGS_NO_TONE (void, noTone, uint32_t _pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_ATTACH_INTERRUPT (void, attachInterrupt, uint32_t pin, void (*callback)(void), uint32_t mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DETACH_INTERRUPT (void, detachInterrupt, uint32_t pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_YIELD (void, yield, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY (void, delay, uint32_t dwMs)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY_MICROSECONDS (void, delayMicroseconds, uint32_t dwUs)
|
|
||||||
#define RADIOLIB_CB_ARGS_MILLIS (uint64_t, millis, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_MICROS (uint64_t, micros, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_PULSE_IN (uint32_t, pulseIn, uint32_t pin, uint32_t state, uint32_t timeout)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN (void, SPIbegin, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN_TRANSACTION (void, SPIbeginTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_TRANSFER (uint8_t, SPItransfer, uint8_t b)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END_TRANSACTION (void, SPIendTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END (void, SPIend, void)
|
|
||||||
|
|
||||||
#elif defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) || defined(PORTDUINO)
|
#elif defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) || defined(PORTDUINO)
|
||||||
// Arduino megaAVR boards - Uno Wifi Rev.2, Nano Every
|
// Arduino megaAVR boards - Uno Wifi Rev.2, Nano Every
|
||||||
#define RADIOLIB_PLATFORM "Arduino megaAVR"
|
#define RADIOLIB_PLATFORM "Arduino megaAVR"
|
||||||
#define RADIOLIB_PIN_TYPE uint8_t
|
|
||||||
#define RADIOLIB_PIN_MODE PinMode
|
|
||||||
#define RADIOLIB_PIN_STATUS PinStatus
|
|
||||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
|
||||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
|
||||||
#define RADIOLIB_NC (0xFF)
|
|
||||||
#define RADIOLIB_DEFAULT_SPI SPI
|
|
||||||
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
|
|
||||||
#define RADIOLIB_NONVOLATILE PROGMEM
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
|
|
||||||
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
|
|
||||||
|
|
||||||
// Arduino API callbacks
|
|
||||||
#define RADIOLIB_CB_ARGS_PIN_MODE (void, pinMode, uint8_t pin, PinMode mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_WRITE (void, digitalWrite, uint8_t pin, PinStatus val)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_READ (PinStatus, digitalRead, uint8_t pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_TONE (void, tone, uint8_t pin, unsigned int frequency, unsigned long duration)
|
|
||||||
#define RADIOLIB_CB_ARGS_NO_TONE (void, noTone, uint8_t pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_ATTACH_INTERRUPT (void, attachInterrupt, uint8_t pin, void (*userFunc)(void), PinStatus mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DETACH_INTERRUPT (void, detachInterrupt, uint8_t pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_YIELD (void, yield, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY (void, delay, unsigned long ms)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY_MICROSECONDS (void, delayMicroseconds, unsigned int us)
|
|
||||||
#define RADIOLIB_CB_ARGS_MILLIS (unsigned long, millis, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_MICROS (unsigned long, micros, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_PULSE_IN (unsigned long, pulseIn, uint8_t pin, uint8_t state, unsigned long timeout)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN (void, SPIbegin, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN_TRANSACTION (void, SPIbeginTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_TRANSFER (uint8_t, SPItransfer, uint8_t b)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END_TRANSACTION (void, SPIendTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END (void, SPIend, void)
|
|
||||||
|
|
||||||
#elif defined(ARDUINO_ARCH_APOLLO3)
|
#elif defined(ARDUINO_ARCH_APOLLO3)
|
||||||
// Sparkfun Apollo3 boards
|
// Sparkfun Apollo3 boards
|
||||||
#define RADIOLIB_PLATFORM "Sparkfun Apollo3"
|
#define RADIOLIB_PLATFORM "Sparkfun Apollo3"
|
||||||
#define RADIOLIB_PIN_TYPE pin_size_t
|
|
||||||
#define RADIOLIB_PIN_MODE Arduino_PinMode
|
|
||||||
#define RADIOLIB_PIN_STATUS PinStatus
|
|
||||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
|
||||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
|
||||||
#define RADIOLIB_NC (0xFF)
|
|
||||||
#define RADIOLIB_DEFAULT_SPI SPI
|
|
||||||
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
|
|
||||||
#define RADIOLIB_NONVOLATILE PROGMEM
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
|
|
||||||
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
|
|
||||||
|
|
||||||
// Arduino API callbacks
|
|
||||||
#define RADIOLIB_CB_ARGS_PIN_MODE (void, pinMode, pin_size_t pinName, Arduino_PinMode pinMode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_WRITE (void, digitalWrite, pin_size_t pinName, PinStatus val)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_READ (PinStatus, digitalRead, pin_size_t pinName)
|
|
||||||
#define RADIOLIB_CB_ARGS_TONE (void, tone, uint8_t _pin, unsigned int frequency, unsigned long duration)
|
|
||||||
#define RADIOLIB_CB_ARGS_NO_TONE (void, noTone, uint8_t _pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_ATTACH_INTERRUPT (void, attachInterrupt, pin_size_t interruptNumber, voidFuncPtr callback, PinStatus mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DETACH_INTERRUPT (void, detachInterrupt, pin_size_t interruptNumber)
|
|
||||||
#define RADIOLIB_CB_ARGS_YIELD (void, yield, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY (void, delay, unsigned long ms)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY_MICROSECONDS (void, delayMicroseconds, unsigned int us)
|
|
||||||
#define RADIOLIB_CB_ARGS_MILLIS (unsigned long, millis, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_MICROS (unsigned long, micros, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_PULSE_IN (unsigned long, pulseIn, pin_size_t pin, uint8_t state, unsigned long timeout)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN (void, SPIbegin, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN_TRANSACTION (void, SPIbeginTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_TRANSFER (uint8_t, SPItransfer, uint8_t b)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END_TRANSACTION (void, SPIendTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END (void, SPIend, void)
|
|
||||||
|
|
||||||
|
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (Arduino_PinMode)
|
||||||
|
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
|
||||||
|
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
|
||||||
#elif defined(ARDUINO_ARDUINO_NANO33BLE)
|
#elif defined(ARDUINO_ARDUINO_NANO33BLE)
|
||||||
// Arduino Nano 33 BLE
|
// Arduino Nano 33 BLE
|
||||||
#define RADIOLIB_PLATFORM "Arduino Nano 33 BLE"
|
#define RADIOLIB_PLATFORM "Arduino Nano 33 BLE"
|
||||||
#define RADIOLIB_PIN_TYPE pin_size_t
|
|
||||||
#define RADIOLIB_PIN_MODE PinMode
|
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PinMode)
|
||||||
#define RADIOLIB_PIN_STATUS PinStatus
|
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
|
||||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
|
||||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
|
||||||
#define RADIOLIB_NC (0xFF)
|
|
||||||
#define RADIOLIB_DEFAULT_SPI SPI
|
|
||||||
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
|
|
||||||
#define RADIOLIB_NONVOLATILE PROGMEM
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
|
|
||||||
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
|
|
||||||
|
|
||||||
// Arduino mbed OS boards have a really bad tone implementation which will crash after a couple seconds
|
// Arduino mbed OS boards have a really bad tone implementation which will crash after a couple seconds
|
||||||
#define RADIOLIB_TONE_UNSUPPORTED
|
#define RADIOLIB_TONE_UNSUPPORTED
|
||||||
#define RADIOLIB_MBED_TONE_OVERRIDE
|
#define RADIOLIB_MBED_TONE_OVERRIDE
|
||||||
|
|
||||||
// Arduino API callbacks
|
|
||||||
#define RADIOLIB_CB_ARGS_PIN_MODE (void, pinMode, pin_size_t pin, PinMode mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_WRITE (void, digitalWrite, pin_size_t pin, PinStatus val)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_READ (PinStatus, digitalRead, pin_size_t pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_TONE (void, tone, uint8_t pin, unsigned int frequency, unsigned long duration)
|
|
||||||
#define RADIOLIB_CB_ARGS_NO_TONE (void, noTone, uint8_t pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_ATTACH_INTERRUPT (void, attachInterrupt, pin_size_t interruptNum, voidFuncPtr func, PinStatus mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DETACH_INTERRUPT (void, detachInterrupt, pin_size_t interruptNum)
|
|
||||||
#define RADIOLIB_CB_ARGS_YIELD (void, yield, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY (void, delay, unsigned long ms)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY_MICROSECONDS (void, delayMicroseconds, unsigned int us)
|
|
||||||
#define RADIOLIB_CB_ARGS_MILLIS (unsigned long, millis, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_MICROS (unsigned long, micros, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_PULSE_IN (unsigned long, pulseIn, pin_size_t pin, uint8_t state, unsigned long timeout)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN (void, SPIbegin, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN_TRANSACTION (void, SPIbeginTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_TRANSFER (uint8_t, SPItransfer, uint8_t b)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END_TRANSACTION (void, SPIendTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END (void, SPIend, void)
|
|
||||||
|
|
||||||
#elif defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4)
|
#elif defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4)
|
||||||
// Arduino Portenta H7
|
// Arduino Portenta H7
|
||||||
#define RADIOLIB_PLATFORM "Portenta H7"
|
#define RADIOLIB_PLATFORM "Portenta H7"
|
||||||
#define RADIOLIB_PIN_TYPE pin_size_t
|
|
||||||
#define RADIOLIB_PIN_MODE PinMode
|
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PinMode)
|
||||||
#define RADIOLIB_PIN_STATUS PinStatus
|
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
|
||||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
|
||||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
|
||||||
#define RADIOLIB_NC (0xFF)
|
|
||||||
#define RADIOLIB_DEFAULT_SPI SPI
|
|
||||||
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
|
|
||||||
#define RADIOLIB_NONVOLATILE PROGMEM
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
|
|
||||||
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
|
|
||||||
|
|
||||||
// Arduino mbed OS boards have a really bad tone implementation which will crash after a couple seconds
|
// Arduino mbed OS boards have a really bad tone implementation which will crash after a couple seconds
|
||||||
#define RADIOLIB_TONE_UNSUPPORTED
|
#define RADIOLIB_TONE_UNSUPPORTED
|
||||||
#define RADIOLIB_MBED_TONE_OVERRIDE
|
#define RADIOLIB_MBED_TONE_OVERRIDE
|
||||||
|
|
||||||
// Arduino API callbacks
|
|
||||||
#define RADIOLIB_CB_ARGS_PIN_MODE (void, pinMode, pin_size_t pin, PinMode mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_WRITE (void, digitalWrite, pin_size_t pin, PinStatus val)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_READ (PinStatus, digitalRead, pin_size_t pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_TONE (void, tone, uint8_t pin, unsigned int frequency, unsigned long duration)
|
|
||||||
#define RADIOLIB_CB_ARGS_NO_TONE (void, noTone, uint8_t pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_ATTACH_INTERRUPT (void, attachInterrupt, pin_size_t interruptNum, voidFuncPtr func, PinStatus mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DETACH_INTERRUPT (void, detachInterrupt, pin_size_t interruptNum)
|
|
||||||
#define RADIOLIB_CB_ARGS_YIELD (void, yield, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY (void, delay, unsigned long ms)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY_MICROSECONDS (void, delayMicroseconds, unsigned int us)
|
|
||||||
#define RADIOLIB_CB_ARGS_MILLIS (unsigned long, millis, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_MICROS (unsigned long, micros, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_PULSE_IN (unsigned long, pulseIn, pin_size_t pin, uint8_t state, unsigned long timeout)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN (void, SPIbegin, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN_TRANSACTION (void, SPIbeginTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_TRANSFER (uint8_t, SPItransfer, uint8_t b)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END_TRANSACTION (void, SPIendTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END (void, SPIend, void)
|
|
||||||
|
|
||||||
#elif defined(__STM32F4__) || defined(__STM32F1__)
|
#elif defined(__STM32F4__) || defined(__STM32F1__)
|
||||||
// Arduino STM32 core by Roger Clark (https://github.com/rogerclarkmelbourne/Arduino_STM32)
|
// Arduino STM32 core by Roger Clark (https://github.com/rogerclarkmelbourne/Arduino_STM32)
|
||||||
#define RADIOLIB_PLATFORM "STM32duino (unofficial)"
|
#define RADIOLIB_PLATFORM "STM32duino (unofficial)"
|
||||||
#define RADIOLIB_PIN_TYPE uint8_t
|
|
||||||
#define RADIOLIB_PIN_MODE WiringPinMode
|
|
||||||
#define RADIOLIB_PIN_STATUS uint8_t
|
|
||||||
#define RADIOLIB_INTERRUPT_STATUS ExtIntTriggerMode
|
|
||||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
|
||||||
#define RADIOLIB_NC (0xFF)
|
|
||||||
#define RADIOLIB_DEFAULT_SPI SPI
|
|
||||||
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
|
|
||||||
#define RADIOLIB_NONVOLATILE PROGMEM
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
|
|
||||||
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
|
|
||||||
|
|
||||||
// Arduino API callbacks
|
|
||||||
#define RADIOLIB_CB_ARGS_PIN_MODE (void, pinMode, uint8 pin, WiringPinMode mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_WRITE (void, digitalWrite, uint8 pin, uint8 val)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_READ (uint32_t, digitalRead, uint8 pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_TONE (void, tone, uint32_t _pin, uint32_t frequency, uint32_t duration)
|
|
||||||
#define RADIOLIB_CB_ARGS_NO_TONE (void, noTone, uint32_t _pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_ATTACH_INTERRUPT (void, attachInterrupt, uint8 pin, voidFuncPtr handler, ExtIntTriggerMode mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DETACH_INTERRUPT (void, detachInterrupt, uint8 pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_YIELD (void, yield, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY (void, delay, unsigned long ms)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY_MICROSECONDS (void, delayMicroseconds, uint32 us)
|
|
||||||
#define RADIOLIB_CB_ARGS_MILLIS (uint32_t, millis, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_MICROS (uint32_t, micros, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_PULSE_IN (uint32_t, pulseIn, uint32_t ulPin, uint32_t ulState, uint32_t ulTimeout)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN (void, SPIbegin, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN_TRANSACTION (void, SPIbeginTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_TRANSFER (uint8_t, SPItransfer, uint8_t b)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END_TRANSACTION (void, SPIendTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END (void, SPIend, void)
|
|
||||||
|
|
||||||
|
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (WiringPinMode)
|
||||||
|
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (ExtIntTriggerMode)
|
||||||
#elif defined(ARDUINO_ARCH_MEGAAVR)
|
#elif defined(ARDUINO_ARCH_MEGAAVR)
|
||||||
// MegaCoreX by MCUdude (https://github.com/MCUdude/MegaCoreX)
|
// MegaCoreX by MCUdude (https://github.com/MCUdude/MegaCoreX)
|
||||||
#define RADIOLIB_PLATFORM "MegaCoreX"
|
#define RADIOLIB_PLATFORM "MegaCoreX"
|
||||||
#define RADIOLIB_PIN_TYPE uint8_t
|
|
||||||
#define RADIOLIB_PIN_MODE uint8_t
|
|
||||||
#define RADIOLIB_PIN_STATUS uint8_t
|
|
||||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
|
||||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
|
||||||
#define RADIOLIB_NC (0xFF)
|
|
||||||
#define RADIOLIB_DEFAULT_SPI SPI
|
|
||||||
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
|
|
||||||
#define RADIOLIB_NONVOLATILE PROGMEM
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
|
|
||||||
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
|
|
||||||
|
|
||||||
// Arduino API callbacks
|
|
||||||
#define RADIOLIB_CB_ARGS_PIN_MODE (void, pinMode, uint8_t pin, uint8_t mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_WRITE (void, digitalWrite, uint8_t pin, uint8_t value)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_READ (uint8_t, digitalRead, uint8_t pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_TONE (void, tone, uint8_t _pin, unsigned int frequency, unsigned long duration)
|
|
||||||
#define RADIOLIB_CB_ARGS_NO_TONE (void, noTone, uint8_t _pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_ATTACH_INTERRUPT (void, attachInterrupt, uint8_t pin, void (*userFunc)(void), uint8_t mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DETACH_INTERRUPT (void, detachInterrupt, uint8_t interruptNum)
|
|
||||||
#define RADIOLIB_CB_ARGS_YIELD (void, yield, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY (void, delay, unsigned long ms)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY_MICROSECONDS (void, delayMicroseconds, unsigned int us)
|
|
||||||
#define RADIOLIB_CB_ARGS_MILLIS (unsigned long, millis, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_MICROS (unsigned long, micros, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_PULSE_IN (unsigned long, pulseIn, uint8_t pin, uint8_t state, unsigned long timeout)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN (void, SPIbegin, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN_TRANSACTION (void, SPIbeginTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_TRANSFER (uint8_t, SPItransfer, uint8_t b)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END_TRANSACTION (void, SPIendTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END (void, SPIend, void)
|
|
||||||
|
|
||||||
#elif defined(ARDUINO_ARCH_MBED_RP2040)
|
#elif defined(ARDUINO_ARCH_MBED_RP2040)
|
||||||
// Raspberry Pi Pico (official mbed core)
|
// Raspberry Pi Pico (official mbed core)
|
||||||
#define RADIOLIB_PLATFORM "Raspberry Pi Pico"
|
#define RADIOLIB_PLATFORM "Raspberry Pi Pico"
|
||||||
#define RADIOLIB_PIN_TYPE pin_size_t
|
|
||||||
#define RADIOLIB_PIN_MODE PinMode
|
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PinMode)
|
||||||
#define RADIOLIB_PIN_STATUS PinStatus
|
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
|
||||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
|
||||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
|
||||||
#define RADIOLIB_NC (0xFF)
|
|
||||||
#define RADIOLIB_DEFAULT_SPI SPI
|
|
||||||
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
|
|
||||||
#define RADIOLIB_NONVOLATILE PROGMEM
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
|
|
||||||
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
|
|
||||||
|
|
||||||
// Arduino mbed OS boards have a really bad tone implementation which will crash after a couple seconds
|
// Arduino mbed OS boards have a really bad tone implementation which will crash after a couple seconds
|
||||||
#define RADIOLIB_TONE_UNSUPPORTED
|
#define RADIOLIB_TONE_UNSUPPORTED
|
||||||
#define RADIOLIB_MBED_TONE_OVERRIDE
|
#define RADIOLIB_MBED_TONE_OVERRIDE
|
||||||
|
|
||||||
// Arduino API callbacks
|
|
||||||
#define RADIOLIB_CB_ARGS_PIN_MODE (void, pinMode, pin_size_t pin, PinMode mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_WRITE (void, digitalWrite, pin_size_t pin, PinStatus val)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_READ (PinStatus, digitalRead, pin_size_t pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_TONE (void, tone, uint8_t pin, unsigned int frequency, unsigned long duration)
|
|
||||||
#define RADIOLIB_CB_ARGS_NO_TONE (void, noTone, uint8_t pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_ATTACH_INTERRUPT (void, attachInterrupt, pin_size_t interruptNum, voidFuncPtr func, PinStatus mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DETACH_INTERRUPT (void, detachInterrupt, pin_size_t interruptNum)
|
|
||||||
#define RADIOLIB_CB_ARGS_YIELD (void, yield, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY (void, delay, unsigned long ms)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY_MICROSECONDS (void, delayMicroseconds, unsigned int us)
|
|
||||||
#define RADIOLIB_CB_ARGS_MILLIS (unsigned long, millis, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_MICROS (unsigned long, micros, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_PULSE_IN (unsigned long, pulseIn, pin_size_t pin, uint8_t state, unsigned long timeout)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN (void, SPIbegin, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN_TRANSACTION (void, SPIbeginTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_TRANSFER (uint8_t, SPItransfer, uint8_t b)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END_TRANSACTION (void, SPIendTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END (void, SPIend, void)
|
|
||||||
|
|
||||||
#elif defined(ARDUINO_ARCH_RP2040)
|
#elif defined(ARDUINO_ARCH_RP2040)
|
||||||
// Raspberry Pi Pico (unofficial core)
|
// Raspberry Pi Pico (unofficial core)
|
||||||
#define RADIOLIB_PLATFORM "Raspberry Pi Pico (unofficial)"
|
#define RADIOLIB_PLATFORM "Raspberry Pi Pico (unofficial)"
|
||||||
#define RADIOLIB_PIN_TYPE pin_size_t
|
|
||||||
#define RADIOLIB_PIN_MODE PinMode
|
|
||||||
#define RADIOLIB_PIN_STATUS PinStatus
|
|
||||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
|
||||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
|
||||||
#define RADIOLIB_NC (0xFF)
|
|
||||||
#define RADIOLIB_DEFAULT_SPI SPI
|
|
||||||
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
|
|
||||||
#define RADIOLIB_NONVOLATILE PROGMEM
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
|
|
||||||
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
|
|
||||||
|
|
||||||
// Arduino API callbacks
|
|
||||||
#define RADIOLIB_CB_ARGS_PIN_MODE (void, pinMode, pin_size_t pin, PinMode mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_WRITE (void, digitalWrite, pin_size_t pin, PinStatus val)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_READ (PinStatus, digitalRead, pin_size_t pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_TONE (void, tone, uint8_t pin, unsigned int frequency, unsigned long duration)
|
|
||||||
#define RADIOLIB_CB_ARGS_NO_TONE (void, noTone, uint8_t pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_ATTACH_INTERRUPT (void, attachInterrupt, pin_size_t interruptNum, voidFuncPtr func, PinStatus mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DETACH_INTERRUPT (void, detachInterrupt, pin_size_t interruptNum)
|
|
||||||
#define RADIOLIB_CB_ARGS_YIELD (void, yield, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY (void, delay, unsigned long ms)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY_MICROSECONDS (void, delayMicroseconds, unsigned int us)
|
|
||||||
#define RADIOLIB_CB_ARGS_MILLIS (unsigned long, millis, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_MICROS (unsigned long, micros, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_PULSE_IN (unsigned long, pulseIn, pin_size_t pin, uint8_t state, unsigned long timeout)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN (void, SPIbegin, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN_TRANSACTION (void, SPIbeginTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_TRANSFER (uint8_t, SPItransfer, uint8_t b)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END_TRANSACTION (void, SPIendTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END (void, SPIend, void)
|
|
||||||
|
|
||||||
|
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PinMode)
|
||||||
|
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
|
||||||
|
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
|
||||||
#elif defined(__ASR6501__) || defined(ARDUINO_ARCH_ASR650X) || defined(DARDUINO_ARCH_ASR6601)
|
#elif defined(__ASR6501__) || defined(ARDUINO_ARCH_ASR650X) || defined(DARDUINO_ARCH_ASR6601)
|
||||||
// CubeCell
|
// CubeCell
|
||||||
#define RADIOLIB_PLATFORM "CubeCell"
|
#define RADIOLIB_PLATFORM "CubeCell"
|
||||||
#define RADIOLIB_PIN_TYPE uint8_t
|
|
||||||
#define RADIOLIB_PIN_MODE PINMODE
|
|
||||||
#define RADIOLIB_PIN_STATUS uint8_t
|
|
||||||
#define RADIOLIB_INTERRUPT_STATUS IrqModes
|
|
||||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
|
||||||
#define RADIOLIB_NC (0xFF)
|
|
||||||
#define RADIOLIB_DEFAULT_SPI SPI
|
|
||||||
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(1000000, MSBFIRST, SPI_MODE0) // see issue #709
|
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(1000000, MSBFIRST, SPI_MODE0) // see issue #709
|
||||||
#define RADIOLIB_NONVOLATILE PROGMEM
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
|
|
||||||
|
|
||||||
// Arduino API callbacks
|
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PINMODE)
|
||||||
#define RADIOLIB_CB_ARGS_PIN_MODE (void, pinMode, uint8_t pin, PINMODE mode)
|
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (IrqModes)
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_WRITE (void, digitalWrite, uint8_t pin_name, uint8_t level)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_READ (uint8_t, digitalRead, uint8_t pin_name)
|
|
||||||
#define RADIOLIB_CB_ARGS_TONE (void, tone, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_NO_TONE (void, noTone, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_ATTACH_INTERRUPT (void, attachInterrupt, uint8_t pin_name, GpioIrqHandler GpioIrqHandlerCallback, IrqModes interrupt_mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DETACH_INTERRUPT (void, detachInterrupt, uint8_t pin_name)
|
|
||||||
#define RADIOLIB_CB_ARGS_YIELD (void, yield, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY (void, delay, uint32_t milliseconds)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY_MICROSECONDS (void, delayMicroseconds, uint16 microseconds)
|
|
||||||
#define RADIOLIB_CB_ARGS_MILLIS (uint32_t, millis, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_MICROS (uint32_t, micros, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_PULSE_IN (uint32_t, pulseIn, uint8_t pin_name, uint8_t mode, uint32_t timeout)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN (void, SPIbegin, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN_TRANSACTION (void, SPIbeginTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_TRANSFER (uint8_t, SPItransfer, uint8_t b)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END_TRANSACTION (void, SPIendTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END (void, SPIend, void)
|
|
||||||
|
|
||||||
// provide an easy access to the on-board module
|
// provide an easy access to the on-board module
|
||||||
#include "board-config.h"
|
#include "board-config.h"
|
||||||
|
@ -792,42 +188,9 @@
|
||||||
#if defined(yield)
|
#if defined(yield)
|
||||||
#undef yield
|
#undef yield
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif defined(RASPI)
|
#elif defined(RASPI)
|
||||||
// RaspiDuino framework (https://github.com/me-no-dev/RasPiArduino)
|
// RaspiDuino framework (https://github.com/me-no-dev/RasPiArduino)
|
||||||
#define RADIOLIB_PLATFORM "RasPiArduino"
|
#define RADIOLIB_PLATFORM "RasPiArduino"
|
||||||
#define RADIOLIB_PIN_TYPE uint8_t
|
|
||||||
#define RADIOLIB_PIN_MODE uint8_t
|
|
||||||
#define RADIOLIB_PIN_STATUS uint8_t
|
|
||||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
|
||||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
|
||||||
#define RADIOLIB_NC (0xFF)
|
|
||||||
#define RADIOLIB_DEFAULT_SPI SPI
|
|
||||||
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
|
|
||||||
#define RADIOLIB_NONVOLATILE PROGMEM
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
|
|
||||||
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
|
|
||||||
|
|
||||||
// Arduino API callbacks
|
|
||||||
#define RADIOLIB_CB_ARGS_PIN_MODE (void, pinMode, uint8_t pin, uint8_t mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_WRITE (void, digitalWrite, uint8_t pin, uint8_t value)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_READ (int, digitalRead, uint8_t pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_TONE (void, tone, uint8_t _pin, unsigned int frequency, unsigned long duration)
|
|
||||||
#define RADIOLIB_CB_ARGS_NO_TONE (void, noTone, uint8_t _pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_ATTACH_INTERRUPT (void, attachInterrupt, uint8_t interruptNum, void (*userFunc)(void), int mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DETACH_INTERRUPT (void, detachInterrupt, uint8_t interruptNum)
|
|
||||||
#define RADIOLIB_CB_ARGS_YIELD (void, yield, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY (void, delay, uint32_t ms)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY_MICROSECONDS (void, delayMicroseconds, unsigned int us)
|
|
||||||
#define RADIOLIB_CB_ARGS_MILLIS (unsigned long, millis, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_MICROS (unsigned long, micros, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_PULSE_IN (unsigned long, pulseIn, uint8_t pin, uint8_t state, unsigned long timeout)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN (void, SPIbegin, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN_TRANSACTION (void, SPIbeginTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_TRANSFER (uint8_t, SPItransfer, uint8_t b)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END_TRANSACTION (void, SPIendTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END (void, SPIend, void)
|
|
||||||
|
|
||||||
// let's start off easy - no tone on this platform, that can happen
|
// let's start off easy - no tone on this platform, that can happen
|
||||||
#define RADIOLIB_TONE_UNSUPPORTED
|
#define RADIOLIB_TONE_UNSUPPORTED
|
||||||
|
@ -848,90 +211,72 @@
|
||||||
#undef micros
|
#undef micros
|
||||||
inline unsigned long micros() { return((unsigned long)(STCV)); };
|
inline unsigned long micros() { return((unsigned long)(STCV)); };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif defined(TEENSYDUINO)
|
#elif defined(TEENSYDUINO)
|
||||||
// Teensy
|
// Teensy
|
||||||
#define RADIOLIB_PLATFORM "Teensy"
|
#define RADIOLIB_PLATFORM "Teensy"
|
||||||
#define RADIOLIB_PIN_TYPE uint8_t
|
|
||||||
#define RADIOLIB_PIN_MODE uint8_t
|
|
||||||
#define RADIOLIB_PIN_STATUS uint8_t
|
|
||||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
|
||||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
|
||||||
#define RADIOLIB_NC (0xFF)
|
|
||||||
#define RADIOLIB_DEFAULT_SPI SPI
|
|
||||||
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
|
|
||||||
#define RADIOLIB_NONVOLATILE PROGMEM
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
|
|
||||||
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
|
|
||||||
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
|
|
||||||
|
|
||||||
// Arduino API callbacks
|
|
||||||
#define RADIOLIB_CB_ARGS_PIN_MODE (void, pinMode, uint8_t pin, uint8_t mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_WRITE (void, digitalWrite, uint8_t pin, uint8_t value)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_READ (uint8_t, digitalRead, uint8_t pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_TONE (void, tone, uint8_t _pin, short unsigned int frequency, long unsigned int duration)
|
|
||||||
#define RADIOLIB_CB_ARGS_NO_TONE (void, noTone, uint8_t _pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_ATTACH_INTERRUPT (void, attachInterrupt, uint8_t interruptNum, void (*userFunc)(void), int mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DETACH_INTERRUPT (void, detachInterrupt, uint8_t interruptNum)
|
|
||||||
#define RADIOLIB_CB_ARGS_YIELD (void, yield, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY (void, delay, unsigned long ms)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY_MICROSECONDS (void, delayMicroseconds, long unsigned int us)
|
|
||||||
#define RADIOLIB_CB_ARGS_MILLIS (unsigned long, millis, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_MICROS (unsigned long, micros, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_PULSE_IN (unsigned long, pulseIn, uint8_t pin, uint8_t state, unsigned long timeout)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN (void, SPIbegin, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN_TRANSACTION (void, SPIbeginTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_TRANSFER (uint8_t, SPItransfer, uint8_t b)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END_TRANSACTION (void, SPIendTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END (void, SPIend, void)
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// other Arduino platforms not covered by the above list - this may or may not work
|
// other Arduino platforms not covered by the above list - this may or may not work
|
||||||
#define RADIOLIB_PLATFORM "Unknown Arduino"
|
#define RADIOLIB_PLATFORM "Unknown Arduino"
|
||||||
#define RADIOLIB_UNKNOWN_PLATFORM
|
#define RADIOLIB_UNKNOWN_PLATFORM
|
||||||
#define RADIOLIB_PIN_TYPE uint8_t
|
#endif
|
||||||
#define RADIOLIB_PIN_MODE uint8_t
|
|
||||||
#define RADIOLIB_PIN_STATUS uint8_t
|
#if !defined(RADIOLIB_NC)
|
||||||
#define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
|
|
||||||
#define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
|
|
||||||
#define RADIOLIB_NC (0xFF)
|
#define RADIOLIB_NC (0xFF)
|
||||||
|
#endif
|
||||||
|
#if !defined(RADIOLIB_DEFAULT_SPI)
|
||||||
#define RADIOLIB_DEFAULT_SPI SPI
|
#define RADIOLIB_DEFAULT_SPI SPI
|
||||||
|
#endif
|
||||||
|
#if !defined(RADIOLIB_DEFAULT_SPI_SETTINGS)
|
||||||
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
|
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
|
||||||
|
#endif
|
||||||
|
#if !defined(RADIOLIB_NONVOLATILE)
|
||||||
#define RADIOLIB_NONVOLATILE PROGMEM
|
#define RADIOLIB_NONVOLATILE PROGMEM
|
||||||
|
#endif
|
||||||
|
#if !defined(RADIOLIB_NONVOLATILE_READ_BYTE)
|
||||||
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
|
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
|
||||||
|
#endif
|
||||||
|
#if !defined(RADIOLIB_NONVOLATILE_READ_DWORD)
|
||||||
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
|
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
|
||||||
|
#endif
|
||||||
|
#if !defined(RADIOLIB_TYPE_ALIAS)
|
||||||
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
|
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
|
||||||
|
|
||||||
// Arduino API callbacks
|
|
||||||
#define RADIOLIB_CB_ARGS_PIN_MODE (void, pinMode, uint8_t pin, uint8_t mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_WRITE (void, digitalWrite, uint8_t pin, uint8_t value)
|
|
||||||
#define RADIOLIB_CB_ARGS_DIGITAL_READ (int, digitalRead, uint8_t pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_TONE (void, tone, uint8_t _pin, unsigned int frequency, unsigned long duration)
|
|
||||||
#define RADIOLIB_CB_ARGS_NO_TONE (void, noTone, uint8_t _pin)
|
|
||||||
#define RADIOLIB_CB_ARGS_ATTACH_INTERRUPT (void, attachInterrupt, uint8_t interruptNum, void (*userFunc)(void), int mode)
|
|
||||||
#define RADIOLIB_CB_ARGS_DETACH_INTERRUPT (void, detachInterrupt, uint8_t interruptNum)
|
|
||||||
#define RADIOLIB_CB_ARGS_YIELD (void, yield, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY (void, delay, unsigned long ms)
|
|
||||||
#define RADIOLIB_CB_ARGS_DELAY_MICROSECONDS (void, delayMicroseconds, unsigned int us)
|
|
||||||
#define RADIOLIB_CB_ARGS_MILLIS (unsigned long, millis, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_MICROS (unsigned long, micros, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_PULSE_IN (unsigned long, pulseIn, uint8_t pin, uint8_t state, unsigned long timeout)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN (void, SPIbegin, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_BEGIN_TRANSACTION (void, SPIbeginTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_TRANSFER (uint8_t, SPItransfer, uint8_t b)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END_TRANSACTION (void, SPIendTransaction, void)
|
|
||||||
#define RADIOLIB_CB_ARGS_SPI_END (void, SPIend, void)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(RADIOLIB_ARDUINOHAL_PIN_MODE_CAST)
|
||||||
|
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST
|
||||||
|
#endif
|
||||||
|
#if !defined(RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST)
|
||||||
|
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST
|
||||||
|
#endif
|
||||||
|
#if !defined(RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST)
|
||||||
|
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
// generic non-Arduino platform
|
// generic non-Arduino platform
|
||||||
#define RADIOLIB_PLATFORM "Generic"
|
#define RADIOLIB_PLATFORM "Generic"
|
||||||
|
|
||||||
// platform properties may be defined here, or somewhere else in the build system
|
#define RADIOLIB_NC (0xFF)
|
||||||
#include "noarduino.h"
|
#define RADIOLIB_NONVOLATILE
|
||||||
|
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) (*((uint8_t *)(void *)(addr)))
|
||||||
|
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) (*((uint32_t *)(void *)(addr)))
|
||||||
|
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
|
||||||
|
|
||||||
|
#if !defined(RADIOLIB_DEBUG_PORT)
|
||||||
|
#define RADIOLIB_DEBUG_PORT stdout
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DEC 10
|
||||||
|
#define HEX 16
|
||||||
|
#define OCT 8
|
||||||
|
#define BIN 2
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
typedef uint8_t byte;
|
||||||
|
|
||||||
|
using std::max;
|
||||||
|
using std::min;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -950,7 +295,7 @@
|
||||||
|
|
||||||
// set which output port should be used for debug output
|
// set which output port should be used for debug output
|
||||||
// may be Serial port (on Arduino) or file like stdout or stderr (on generic platforms)
|
// may be Serial port (on Arduino) or file like stdout or stderr (on generic platforms)
|
||||||
#if !defined(RADIOLIB_DEBUG_PORT)
|
#if defined(RADIOLIB_BUILD_ARDUINO) && !defined(RADIOLIB_DEBUG_PORT)
|
||||||
#define RADIOLIB_DEBUG_PORT Serial
|
#define RADIOLIB_DEBUG_PORT Serial
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1068,24 +413,6 @@
|
||||||
*/
|
*/
|
||||||
#define RADIOLIB_ASSERT(STATEVAR) { if((STATEVAR) != RADIOLIB_ERR_NONE) { return(STATEVAR); } }
|
#define RADIOLIB_ASSERT(STATEVAR) { if((STATEVAR) != RADIOLIB_ERR_NONE) { return(STATEVAR); } }
|
||||||
|
|
||||||
/*
|
|
||||||
* Macros that create callback for the hardware abstraction layer.
|
|
||||||
*
|
|
||||||
* This is the most evil thing I have ever created. I am deeply sorry to anyone currently reading this text.
|
|
||||||
* Come one, come all and witness the horror:
|
|
||||||
* Variadics, forced expansions, inlined function, string concatenation, and it even messes up access specifiers.
|
|
||||||
*/
|
|
||||||
#define RADIOLIB_FIRST(arg, ...) arg
|
|
||||||
#define RADIOLIB_REST(arg, ...) __VA_ARGS__
|
|
||||||
#define RADIOLIB_EXP(...) __VA_ARGS__
|
|
||||||
|
|
||||||
#define RADIOLIB_GENERATE_CALLBACK_RET_FUNC(RET, FUNC, ...) public: typedef RET (*FUNC##_cb_t)(__VA_ARGS__); void setCb_##FUNC(FUNC##_cb_t cb) { cb_##FUNC = cb; }; private: FUNC##_cb_t cb_##FUNC = nullptr;
|
|
||||||
#define RADIOLIB_GENERATE_CALLBACK_RET(RET, ...) RADIOLIB_GENERATE_CALLBACK_RET_FUNC(RET, __VA_ARGS__)
|
|
||||||
#define RADIOLIB_GENERATE_CALLBACK(CB) RADIOLIB_GENERATE_CALLBACK_RET(RADIOLIB_EXP(RADIOLIB_FIRST CB), RADIOLIB_EXP(RADIOLIB_REST CB))
|
|
||||||
|
|
||||||
#define RADIOLIB_GENERATE_CALLBACK_SPI_RET_FUNC(RET, FUNC, ...) public: typedef RET (Module::*FUNC##_cb_t)(__VA_ARGS__); void setCb_##FUNC(FUNC##_cb_t cb) { cb_##FUNC = cb; }; private: FUNC##_cb_t cb_##FUNC = nullptr;
|
|
||||||
#define RADIOLIB_GENERATE_CALLBACK_SPI_RET(RET, ...) RADIOLIB_GENERATE_CALLBACK_SPI_RET_FUNC(RET, __VA_ARGS__)
|
|
||||||
#define RADIOLIB_GENERATE_CALLBACK_SPI(CB) RADIOLIB_GENERATE_CALLBACK_SPI_RET(RADIOLIB_EXP(RADIOLIB_FIRST CB), RADIOLIB_EXP(RADIOLIB_REST CB))
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Macro to check variable is within constraints - this is commonly used to check parameter ranges. Requires RADIOLIB_CHECK_RANGE to be enabled
|
\brief Macro to check variable is within constraints - this is commonly used to check parameter ranges. Requires RADIOLIB_CHECK_RANGE to be enabled
|
||||||
|
|
17
src/Hal.cpp
Normal file
17
src/Hal.cpp
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "Hal.h"
|
||||||
|
|
||||||
|
Hal::Hal(const uint8_t input, const uint8_t output, const uint8_t low, const uint8_t high, const uint8_t rising, const uint8_t falling)
|
||||||
|
: GpioModeInput(input),
|
||||||
|
GpioModeOutput(output),
|
||||||
|
GpioLevelLow(high),
|
||||||
|
GpioLevelHigh(low),
|
||||||
|
GpioInterruptRising(rising),
|
||||||
|
GpioInterruptFalling(falling) {}
|
||||||
|
|
||||||
|
void Hal::init(){};
|
||||||
|
void Hal::term(){};
|
||||||
|
void Hal::tone(uint8_t pin, unsigned int frequency, unsigned long duration){};
|
||||||
|
void Hal::noTone(uint8_t pin){};
|
||||||
|
void Hal::yield(){};
|
||||||
|
uint8_t Hal::pinToInterrupt(uint8_t pin) { return pin; };
|
42
src/Hal.h
Normal file
42
src/Hal.h
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#if !defined(_RADIOLIB_HAL_H)
|
||||||
|
#define _RADIOLIB_HAL_H
|
||||||
|
|
||||||
|
class Hal {
|
||||||
|
public:
|
||||||
|
const uint8_t GpioModeInput;
|
||||||
|
const uint8_t GpioModeOutput;
|
||||||
|
const uint8_t GpioLevelLow;
|
||||||
|
const uint8_t GpioLevelHigh;
|
||||||
|
const uint8_t GpioInterruptRising;
|
||||||
|
const uint8_t GpioInterruptFalling;
|
||||||
|
|
||||||
|
Hal(const uint8_t input, const uint8_t output, const uint8_t low, const uint8_t high, const uint8_t rising, const uint8_t falling);
|
||||||
|
|
||||||
|
virtual void init();
|
||||||
|
virtual void term();
|
||||||
|
|
||||||
|
virtual void pinMode(uint8_t pin, uint8_t mode) = 0;
|
||||||
|
virtual void digitalWrite(uint8_t pin, uint8_t value) = 0;
|
||||||
|
virtual uint8_t digitalRead(uint8_t pin) = 0;
|
||||||
|
virtual void attachInterrupt(uint8_t interruptNum, void (*interruptCb)(void), uint8_t mode) = 0;
|
||||||
|
virtual void detachInterrupt(uint8_t interruptNum) = 0;
|
||||||
|
virtual void delay(unsigned long ms) = 0;
|
||||||
|
virtual void delayMicroseconds(unsigned long us) = 0;
|
||||||
|
virtual unsigned long millis() = 0;
|
||||||
|
virtual unsigned long micros() = 0;
|
||||||
|
virtual long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout) = 0;
|
||||||
|
virtual void spiBegin() = 0;
|
||||||
|
virtual void spiBeginTransaction() = 0;
|
||||||
|
virtual uint8_t spiTransfer(uint8_t b) = 0;
|
||||||
|
virtual void spiEndTransaction() = 0;
|
||||||
|
virtual void spiEnd() = 0;
|
||||||
|
|
||||||
|
virtual void tone(uint8_t pin, unsigned int frequency, unsigned long duration = 0);
|
||||||
|
virtual void noTone(uint8_t pin);
|
||||||
|
virtual void yield();
|
||||||
|
virtual uint8_t pinToInterrupt(uint8_t pin);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
434
src/Module.cpp
434
src/Module.cpp
|
@ -1,94 +1,24 @@
|
||||||
|
#define __STDC_FORMAT_MACROS
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include "Module.h"
|
#include "Module.h"
|
||||||
|
|
||||||
#if defined(RADIOLIB_BUILD_ARDUINO)
|
#if defined(RADIOLIB_BUILD_ARDUINO)
|
||||||
|
#include "ArduinoHal.h"
|
||||||
// we need this to emulate tone() on mbed Arduino boards
|
Module::Module(uint8_t cs, uint8_t irq, uint8_t rst, uint8_t gpio) : _cs(cs), _irq(irq), _rst(rst), _gpio(gpio) {
|
||||||
#if defined(RADIOLIB_MBED_TONE_OVERRIDE)
|
this->hal = new ArduinoHal;
|
||||||
#include "mbed.h"
|
|
||||||
mbed::PwmOut *pwmPin = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE gpio):
|
|
||||||
_cs(cs),
|
|
||||||
_irq(irq),
|
|
||||||
_rst(rst),
|
|
||||||
_gpio(gpio)
|
|
||||||
{
|
|
||||||
_spi = &RADIOLIB_DEFAULT_SPI;
|
|
||||||
_initInterface = true;
|
|
||||||
|
|
||||||
// this is Arduino build, pre-set callbacks
|
|
||||||
setCb_pinMode(::pinMode);
|
|
||||||
setCb_digitalRead(::digitalRead);
|
|
||||||
setCb_digitalWrite(::digitalWrite);
|
|
||||||
#if !defined(RADIOLIB_TONE_UNSUPPORTED)
|
|
||||||
setCb_tone(::tone);
|
|
||||||
setCb_noTone(::noTone);
|
|
||||||
#endif
|
|
||||||
setCb_attachInterrupt(::attachInterrupt);
|
|
||||||
setCb_detachInterrupt(::detachInterrupt);
|
|
||||||
#if !defined(RADIOLIB_YIELD_UNSUPPORTED)
|
|
||||||
setCb_yield(::yield);
|
|
||||||
#endif
|
|
||||||
setCb_delay(::delay);
|
|
||||||
setCb_delayMicroseconds(::delayMicroseconds);
|
|
||||||
setCb_millis(::millis);
|
|
||||||
setCb_micros(::micros);
|
|
||||||
setCb_pulseIn(::pulseIn);
|
|
||||||
setCb_SPIbegin(&Module::SPIbegin);
|
|
||||||
setCb_SPIbeginTransaction(&Module::SPIbeginTransaction);
|
|
||||||
setCb_SPItransfer(&Module::SPItransfer);
|
|
||||||
setCb_SPIendTransaction(&Module::SPIendTransaction);
|
|
||||||
setCb_SPIend(&Module::SPIend);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE gpio, SPIClass& spi, SPISettings spiSettings):
|
Module::Module(uint8_t cs, uint8_t irq, uint8_t rst, uint8_t gpio, SPIClass& spi, SPISettings spiSettings) : _cs(cs), _irq(irq), _rst(rst), _gpio(gpio) {
|
||||||
_cs(cs),
|
this->hal = new ArduinoHal(spi, spiSettings);
|
||||||
_irq(irq),
|
|
||||||
_rst(rst),
|
|
||||||
_gpio(gpio),
|
|
||||||
_spiSettings(spiSettings)
|
|
||||||
{
|
|
||||||
_spi = &spi;
|
|
||||||
_initInterface = false;
|
|
||||||
|
|
||||||
// this is Arduino build, pre-set callbacks
|
|
||||||
setCb_pinMode(::pinMode);
|
|
||||||
setCb_digitalRead(::digitalRead);
|
|
||||||
setCb_digitalWrite(::digitalWrite);
|
|
||||||
#if !defined(RADIOLIB_TONE_UNSUPPORTED)
|
|
||||||
setCb_tone(::tone);
|
|
||||||
setCb_noTone(::noTone);
|
|
||||||
#endif
|
|
||||||
setCb_attachInterrupt(::attachInterrupt);
|
|
||||||
setCb_detachInterrupt(::detachInterrupt);
|
|
||||||
#if !defined(RADIOLIB_YIELD_UNSUPPORTED)
|
|
||||||
setCb_yield(::yield);
|
|
||||||
#endif
|
|
||||||
setCb_delay(::delay);
|
|
||||||
setCb_delayMicroseconds(::delayMicroseconds);
|
|
||||||
setCb_millis(::millis);
|
|
||||||
setCb_micros(::micros);
|
|
||||||
setCb_pulseIn(::pulseIn);
|
|
||||||
setCb_SPIbegin(&Module::SPIbegin);
|
|
||||||
setCb_SPIbeginTransaction(&Module::SPIbeginTransaction);
|
|
||||||
setCb_SPItransfer(&Module::SPItransfer);
|
|
||||||
setCb_SPIendTransaction(&Module::SPIendTransaction);
|
|
||||||
setCb_SPIend(&Module::SPIend);
|
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
|
|
||||||
Module::Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE gpio):
|
|
||||||
_cs(cs),
|
|
||||||
_irq(irq),
|
|
||||||
_rst(rst),
|
|
||||||
_gpio(gpio)
|
|
||||||
{
|
|
||||||
// not an Arduino build, it's up to the user to set all callbacks
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Module::Module(Hal *hal, uint8_t cs, uint8_t irq, uint8_t rst, uint8_t gpio) : _cs(cs), _irq(irq), _rst(rst), _gpio(gpio) {
|
||||||
|
this->hal = hal;
|
||||||
|
}
|
||||||
|
|
||||||
Module::Module(const Module& mod) {
|
Module::Module(const Module& mod) {
|
||||||
*this = mod;
|
*this = mod;
|
||||||
}
|
}
|
||||||
|
@ -96,35 +26,23 @@ Module::Module(const Module& mod) {
|
||||||
Module& Module::operator=(const Module& mod) {
|
Module& Module::operator=(const Module& mod) {
|
||||||
this->SPIreadCommand = mod.SPIreadCommand;
|
this->SPIreadCommand = mod.SPIreadCommand;
|
||||||
this->SPIwriteCommand = mod.SPIwriteCommand;
|
this->SPIwriteCommand = mod.SPIwriteCommand;
|
||||||
this->_cs = mod.getCs();
|
this->_cs = mod._cs;
|
||||||
this->_irq = mod.getIrq();
|
this->_irq = mod._irq;
|
||||||
this->_rst = mod.getRst();
|
this->_rst = mod._rst;
|
||||||
this->_gpio = mod.getGpio();
|
this->_gpio = mod._gpio;
|
||||||
|
|
||||||
return(*this);
|
return(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::init() {
|
void Module::init() {
|
||||||
this->pinMode(_cs, OUTPUT);
|
this->hal->init();
|
||||||
this->digitalWrite(_cs, HIGH);
|
this->hal->pinMode(_cs, this->hal->GpioModeOutput);
|
||||||
#if defined(RADIOLIB_BUILD_ARDUINO)
|
this->hal->digitalWrite(_cs, this->hal->GpioLevelHigh);
|
||||||
if(_initInterface) {
|
|
||||||
(this->*cb_SPIbegin)();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::term() {
|
void Module::term() {
|
||||||
// stop hardware interfaces (if they were initialized by the library)
|
// stop hardware interfaces (if they were initialized by the library)
|
||||||
#if defined(RADIOLIB_BUILD_ARDUINO)
|
this->hal->term();
|
||||||
if(!_initInterface) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(_spi != nullptr) {
|
|
||||||
this->SPIend();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t Module::SPIgetRegValue(uint16_t reg, uint8_t msb, uint8_t lsb) {
|
int16_t Module::SPIgetRegValue(uint16_t reg, uint8_t msb, uint8_t lsb) {
|
||||||
|
@ -150,9 +68,9 @@ int16_t Module::SPIsetRegValue(uint16_t reg, uint8_t value, uint8_t msb, uint8_t
|
||||||
#if defined(RADIOLIB_SPI_PARANOID)
|
#if defined(RADIOLIB_SPI_PARANOID)
|
||||||
// check register value each millisecond until check interval is reached
|
// check register value each millisecond until check interval is reached
|
||||||
// some registers need a bit of time to process the change (e.g. SX127X_REG_OP_MODE)
|
// some registers need a bit of time to process the change (e.g. SX127X_REG_OP_MODE)
|
||||||
uint32_t start = this->micros();
|
uint32_t start = this->hal->micros();
|
||||||
uint8_t readValue = 0x00;
|
uint8_t readValue = 0x00;
|
||||||
while(this->micros() - start < (checkInterval * 1000)) {
|
while(this->hal->micros() - start < (checkInterval * 1000)) {
|
||||||
readValue = SPIreadRegister(reg);
|
readValue = SPIreadRegister(reg);
|
||||||
if((readValue & checkMask) == (newValue & checkMask)) {
|
if((readValue & checkMask) == (newValue & checkMask)) {
|
||||||
// check passed, we can stop the loop
|
// check passed, we can stop the loop
|
||||||
|
@ -216,17 +134,17 @@ void Module::SPIwriteRegister(uint16_t reg, uint8_t data) {
|
||||||
|
|
||||||
void Module::SPItransfer(uint8_t cmd, uint16_t reg, uint8_t* dataOut, uint8_t* dataIn, size_t numBytes) {
|
void Module::SPItransfer(uint8_t cmd, uint16_t reg, uint8_t* dataOut, uint8_t* dataIn, size_t numBytes) {
|
||||||
// start SPI transaction
|
// start SPI transaction
|
||||||
this->beginTransaction();
|
this->hal->spiBeginTransaction();
|
||||||
|
|
||||||
// pull CS low
|
// pull CS low
|
||||||
this->digitalWrite(_cs, LOW);
|
this->hal->digitalWrite(this->_cs, this->hal->GpioLevelLow);
|
||||||
|
|
||||||
// send SPI register address with access command
|
// send SPI register address with access command
|
||||||
if(this->SPIaddrWidth <= 8) {
|
if(this->SPIaddrWidth <= 8) {
|
||||||
this->transfer(reg | cmd);
|
this->hal->spiTransfer(reg | cmd);
|
||||||
} else {
|
} else {
|
||||||
this->transfer((reg >> 8) | cmd);
|
this->hal->spiTransfer((reg >> 8) | cmd);
|
||||||
this->transfer(reg & 0xFF);
|
this->hal->spiTransfer(reg & 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(RADIOLIB_VERBOSE)
|
#if defined(RADIOLIB_VERBOSE)
|
||||||
|
@ -242,14 +160,14 @@ void Module::SPItransfer(uint8_t cmd, uint16_t reg, uint8_t* dataOut, uint8_t* d
|
||||||
if(cmd == SPIwriteCommand) {
|
if(cmd == SPIwriteCommand) {
|
||||||
if(dataOut != NULL) {
|
if(dataOut != NULL) {
|
||||||
for(size_t n = 0; n < numBytes; n++) {
|
for(size_t n = 0; n < numBytes; n++) {
|
||||||
this->transfer(dataOut[n]);
|
this->hal->spiTransfer(dataOut[n]);
|
||||||
RADIOLIB_VERBOSE_PRINT("%X\t", dataOut[n]);
|
RADIOLIB_VERBOSE_PRINT("%X\t", dataOut[n]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (cmd == SPIreadCommand) {
|
} else if (cmd == SPIreadCommand) {
|
||||||
if(dataIn != NULL) {
|
if(dataIn != NULL) {
|
||||||
for(size_t n = 0; n < numBytes; n++) {
|
for(size_t n = 0; n < numBytes; n++) {
|
||||||
dataIn[n] = this->transfer(0x00);
|
dataIn[n] = this->hal->spiTransfer(0x00);
|
||||||
RADIOLIB_VERBOSE_PRINT("%X\t", dataIn[n]);
|
RADIOLIB_VERBOSE_PRINT("%X\t", dataIn[n]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,10 +175,10 @@ void Module::SPItransfer(uint8_t cmd, uint16_t reg, uint8_t* dataOut, uint8_t* d
|
||||||
RADIOLIB_VERBOSE_PRINTLN();
|
RADIOLIB_VERBOSE_PRINTLN();
|
||||||
|
|
||||||
// release CS
|
// release CS
|
||||||
this->digitalWrite(_cs, HIGH);
|
this->hal->digitalWrite(this->_cs, this->hal->GpioLevelHigh);
|
||||||
|
|
||||||
// end SPI transaction
|
// end SPI transaction
|
||||||
this->endTransaction();
|
this->hal->spiEndTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t Module::SPIreadStream(uint8_t cmd, uint8_t* data, size_t numBytes, bool waitForGpio, bool verify) {
|
int16_t Module::SPIreadStream(uint8_t cmd, uint8_t* data, size_t numBytes, bool waitForGpio, bool verify) {
|
||||||
|
@ -311,7 +229,6 @@ int16_t Module::SPIcheckStream() {
|
||||||
if(this->SPIparseStatusCb != nullptr) {
|
if(this->SPIparseStatusCb != nullptr) {
|
||||||
this->SPIstreamError = this->SPIparseStatusCb(spiStatus);
|
this->SPIstreamError = this->SPIparseStatusCb(spiStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return(state);
|
return(state);
|
||||||
|
@ -323,24 +240,24 @@ int16_t Module::SPItransferStream(uint8_t* cmd, uint8_t cmdLen, bool write, uint
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ensure GPIO is low
|
// ensure GPIO is low
|
||||||
uint32_t start = this->millis();
|
uint32_t start = this->hal->millis();
|
||||||
while(this->digitalRead(this->getGpio())) {
|
while(this->hal->digitalRead(this->_gpio)) {
|
||||||
this->yield();
|
this->hal->yield();
|
||||||
if(this->millis() - start >= timeout) {
|
if(this->hal->millis() - start >= timeout) {
|
||||||
this->digitalWrite(this->getCs(), HIGH);
|
this->hal->digitalWrite(this->_cs, this->hal->GpioLevelLow);
|
||||||
return(RADIOLIB_ERR_SPI_CMD_TIMEOUT);
|
return(RADIOLIB_ERR_SPI_CMD_TIMEOUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// pull NSS low
|
// pull NSS low
|
||||||
this->digitalWrite(this->getCs(), LOW);
|
this->hal->digitalWrite(this->_cs, this->hal->GpioLevelLow);
|
||||||
|
|
||||||
// start transfer
|
// start transfer
|
||||||
this->beginTransaction();
|
this->hal->spiBeginTransaction();
|
||||||
|
|
||||||
// send command byte(s)
|
// send command byte(s)
|
||||||
for(uint8_t n = 0; n < cmdLen; n++) {
|
for(uint8_t n = 0; n < cmdLen; n++) {
|
||||||
this->transfer(cmd[n]);
|
this->hal->spiTransfer(cmd[n]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// variable to save error during SPI transfer
|
// variable to save error during SPI transfer
|
||||||
|
@ -350,7 +267,7 @@ int16_t Module::SPItransferStream(uint8_t* cmd, uint8_t cmdLen, bool write, uint
|
||||||
if(write) {
|
if(write) {
|
||||||
for(size_t n = 0; n < numBytes; n++) {
|
for(size_t n = 0; n < numBytes; n++) {
|
||||||
// send byte
|
// send byte
|
||||||
uint8_t in = this->transfer(dataOut[n]);
|
uint8_t in = this->hal->spiTransfer(dataOut[n]);
|
||||||
#if defined(RADIOLIB_VERBOSE)
|
#if defined(RADIOLIB_VERBOSE)
|
||||||
debugBuff[n] = in;
|
debugBuff[n] = in;
|
||||||
#endif
|
#endif
|
||||||
|
@ -363,7 +280,7 @@ int16_t Module::SPItransferStream(uint8_t* cmd, uint8_t cmdLen, bool write, uint
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// skip the first byte for read-type commands (status-only)
|
// skip the first byte for read-type commands (status-only)
|
||||||
uint8_t in = this->transfer(this->SPInopCommand);
|
uint8_t in = this->hal->spiTransfer(this->SPInopCommand);
|
||||||
#if defined(RADIOLIB_VERBOSE)
|
#if defined(RADIOLIB_VERBOSE)
|
||||||
debugBuff[0] = in;
|
debugBuff[0] = in;
|
||||||
#endif
|
#endif
|
||||||
|
@ -378,22 +295,22 @@ int16_t Module::SPItransferStream(uint8_t* cmd, uint8_t cmdLen, bool write, uint
|
||||||
// read the data
|
// read the data
|
||||||
if(state == RADIOLIB_ERR_NONE) {
|
if(state == RADIOLIB_ERR_NONE) {
|
||||||
for(size_t n = 0; n < numBytes; n++) {
|
for(size_t n = 0; n < numBytes; n++) {
|
||||||
dataIn[n] = this->transfer(this->SPInopCommand);
|
dataIn[n] = this->hal->spiTransfer(this->SPInopCommand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// stop transfer
|
// stop transfer
|
||||||
this->endTransaction();
|
this->hal->spiEndTransaction();
|
||||||
this->digitalWrite(this->getCs(), HIGH);
|
this->hal->digitalWrite(this->_cs, this->hal->GpioLevelHigh);
|
||||||
|
|
||||||
// wait for GPIO to go high and then low
|
// wait for GPIO to go high and then low
|
||||||
if(waitForGpio) {
|
if(waitForGpio) {
|
||||||
this->delayMicroseconds(1);
|
this->hal->delayMicroseconds(1);
|
||||||
uint32_t start = this->millis();
|
uint32_t start = this->hal->millis();
|
||||||
while(this->digitalRead(this->getGpio())) {
|
while(this->hal->digitalRead(this->_gpio)) {
|
||||||
this->yield();
|
this->hal->yield();
|
||||||
if(this->millis() - start >= timeout) {
|
if(this->hal->millis() - start >= timeout) {
|
||||||
state = RADIOLIB_ERR_SPI_CMD_TIMEOUT;
|
state = RADIOLIB_ERR_SPI_CMD_TIMEOUT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -440,238 +357,15 @@ void Module::waitForMicroseconds(uint32_t start, uint32_t len) {
|
||||||
}
|
}
|
||||||
this->TimerFlag = false;
|
this->TimerFlag = false;
|
||||||
while(!this->TimerFlag) {
|
while(!this->TimerFlag) {
|
||||||
this->yield();
|
this->hal->yield();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
while(this->micros() - start < len) {
|
while(this->hal->micros() - start < len) {
|
||||||
this->yield();
|
this->hal->yield();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::pinMode(RADIOLIB_PIN_TYPE pin, RADIOLIB_PIN_MODE mode) {
|
|
||||||
if((pin == RADIOLIB_NC) || (cb_pinMode == nullptr)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cb_pinMode(pin, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Module::digitalWrite(RADIOLIB_PIN_TYPE pin, RADIOLIB_PIN_STATUS value) {
|
|
||||||
if((pin == RADIOLIB_NC) || (cb_digitalWrite == nullptr)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cb_digitalWrite(pin, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
RADIOLIB_PIN_STATUS Module::digitalRead(RADIOLIB_PIN_TYPE pin) {
|
|
||||||
if((pin == RADIOLIB_NC) || (cb_digitalRead == nullptr)) {
|
|
||||||
return((RADIOLIB_PIN_STATUS)0);
|
|
||||||
}
|
|
||||||
return(cb_digitalRead(pin));
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(ESP32)
|
|
||||||
// we need to cache the previous tone value for emulation on ESP32
|
|
||||||
int32_t prev = -1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void Module::tone(RADIOLIB_PIN_TYPE pin, uint16_t value, uint32_t duration) {
|
|
||||||
#if !defined(RADIOLIB_TONE_UNSUPPORTED)
|
|
||||||
if((pin == RADIOLIB_NC) || (cb_tone == nullptr)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cb_tone(pin, value, duration);
|
|
||||||
#else
|
|
||||||
if(pin == RADIOLIB_NC) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#if defined(ESP32)
|
|
||||||
// ESP32 tone() emulation
|
|
||||||
(void)duration;
|
|
||||||
if(prev == -1) {
|
|
||||||
ledcAttachPin(pin, RADIOLIB_TONE_ESP32_CHANNEL);
|
|
||||||
}
|
|
||||||
if(prev != value) {
|
|
||||||
ledcWriteTone(RADIOLIB_TONE_ESP32_CHANNEL, value);
|
|
||||||
}
|
|
||||||
prev = value;
|
|
||||||
#elif defined(RADIOLIB_MBED_TONE_OVERRIDE)
|
|
||||||
// better tone for mbed OS boards
|
|
||||||
(void)duration;
|
|
||||||
if(!pwmPin) {
|
|
||||||
pwmPin = new mbed::PwmOut(digitalPinToPinName(pin));
|
|
||||||
}
|
|
||||||
pwmPin->period(1.0 / value);
|
|
||||||
pwmPin->write(0.5);
|
|
||||||
#else
|
|
||||||
(void)value;
|
|
||||||
(void)duration;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void Module::noTone(RADIOLIB_PIN_TYPE pin) {
|
|
||||||
#if !defined(RADIOLIB_TONE_UNSUPPORTED)
|
|
||||||
if((pin == RADIOLIB_NC) || (cb_noTone == nullptr)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#if defined(ARDUINO_ARCH_STM32)
|
|
||||||
cb_noTone(pin, false);
|
|
||||||
#else
|
|
||||||
cb_noTone(pin);
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
if(pin == RADIOLIB_NC) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#if defined(ESP32)
|
|
||||||
// ESP32 tone() emulation
|
|
||||||
ledcDetachPin(pin);
|
|
||||||
ledcWrite(RADIOLIB_TONE_ESP32_CHANNEL, 0);
|
|
||||||
prev = -1;
|
|
||||||
#elif defined(RADIOLIB_MBED_TONE_OVERRIDE)
|
|
||||||
// better tone for mbed OS boards
|
|
||||||
(void)pin;
|
|
||||||
pwmPin->suspend();
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void Module::attachInterrupt(RADIOLIB_PIN_TYPE interruptNum, void (*userFunc)(void), RADIOLIB_INTERRUPT_STATUS mode) {
|
|
||||||
if((interruptNum == RADIOLIB_NC) || (cb_attachInterrupt == nullptr)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cb_attachInterrupt(interruptNum, userFunc, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Module::detachInterrupt(RADIOLIB_PIN_TYPE interruptNum) {
|
|
||||||
if((interruptNum == RADIOLIB_NC) || (cb_detachInterrupt == nullptr)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cb_detachInterrupt(interruptNum);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Module::yield() {
|
|
||||||
if(cb_yield == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#if !defined(RADIOLIB_YIELD_UNSUPPORTED)
|
|
||||||
cb_yield();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void Module::delay(uint32_t ms) {
|
|
||||||
if(cb_delay == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cb_delay(ms);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Module::delayMicroseconds(uint32_t us) {
|
|
||||||
if(cb_delayMicroseconds == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cb_delayMicroseconds(us);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t Module::millis() {
|
|
||||||
if(cb_millis == nullptr) {
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
return(cb_millis());
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t Module::micros() {
|
|
||||||
if(cb_micros == nullptr) {
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
return(cb_micros());
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t Module::pulseIn(RADIOLIB_PIN_TYPE pin, RADIOLIB_PIN_STATUS state, uint32_t timeout) {
|
|
||||||
if(cb_pulseIn == nullptr) {
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
return(cb_pulseIn(pin, state, timeout));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Module::begin() {
|
|
||||||
if(cb_SPIbegin == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#if defined(RADIOLIB_BUILD_ARDUINO)
|
|
||||||
(this->*cb_SPIbegin)();
|
|
||||||
#else
|
|
||||||
cb_SPIbegin();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void Module::beginTransaction() {
|
|
||||||
if(cb_SPIbeginTransaction == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#if defined(RADIOLIB_BUILD_ARDUINO)
|
|
||||||
(this->*cb_SPIbeginTransaction)();
|
|
||||||
#else
|
|
||||||
cb_SPIbeginTransaction();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t Module::transfer(uint8_t b) {
|
|
||||||
if(cb_SPItransfer == nullptr) {
|
|
||||||
return(0xFF);
|
|
||||||
}
|
|
||||||
#if defined(RADIOLIB_BUILD_ARDUINO)
|
|
||||||
return((this->*cb_SPItransfer)(b));
|
|
||||||
#else
|
|
||||||
return(cb_SPItransfer(b));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void Module::endTransaction() {
|
|
||||||
if(cb_SPIendTransaction == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#if defined(RADIOLIB_BUILD_ARDUINO)
|
|
||||||
(this->*cb_SPIendTransaction)();
|
|
||||||
#else
|
|
||||||
cb_SPIendTransaction();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void Module::end() {
|
|
||||||
if(cb_SPIend == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#if defined(RADIOLIB_BUILD_ARDUINO)
|
|
||||||
(this->*cb_SPIend)();
|
|
||||||
#else
|
|
||||||
cb_SPIend();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(RADIOLIB_BUILD_ARDUINO)
|
|
||||||
void Module::SPIbegin() {
|
|
||||||
_spi->begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Module::SPIbeginTransaction() {
|
|
||||||
_spi->beginTransaction(_spiSettings);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t Module::SPItransfer(uint8_t b) {
|
|
||||||
return(_spi->transfer(b));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Module::SPIendTransaction() {
|
|
||||||
_spi->endTransaction();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Module::SPIend() {
|
|
||||||
_spi->end();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint8_t Module::flipBits(uint8_t b) {
|
uint8_t Module::flipBits(uint8_t b) {
|
||||||
b = (b & 0xF0) >> 4 | (b & 0x0F) << 4;
|
b = (b & 0xF0) >> 4 | (b & 0x0F) << 4;
|
||||||
b = (b & 0xCC) >> 2 | (b & 0x33) << 2;
|
b = (b & 0xCC) >> 2 | (b & 0x33) << 2;
|
||||||
|
@ -771,26 +465,26 @@ size_t Module::serialPrintf(const char* format, ...) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void Module::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) {
|
void Module::setRfSwitchPins(uint8_t rxEn, uint8_t txEn) {
|
||||||
// This can be on the stack, setRfSwitchTable copies the contents
|
// This can be on the stack, setRfSwitchTable copies the contents
|
||||||
const RADIOLIB_PIN_TYPE pins[] = {
|
const uint8_t pins[] = {
|
||||||
rxEn, txEn, RADIOLIB_NC,
|
rxEn, txEn, RADIOLIB_NC,
|
||||||
};
|
};
|
||||||
// This must be static, since setRfSwitchTable stores a reference.
|
// This must be static, since setRfSwitchTable stores a reference.
|
||||||
static constexpr RfSwitchMode_t table[] = {
|
static const RfSwitchMode_t table[] = {
|
||||||
{MODE_IDLE, {LOW, LOW}},
|
{MODE_IDLE, {this->hal->GpioLevelLow, this->hal->GpioLevelLow}},
|
||||||
{MODE_RX, {HIGH, LOW}},
|
{MODE_RX, {this->hal->GpioLevelHigh, this->hal->GpioLevelLow}},
|
||||||
{MODE_TX, {LOW, HIGH}},
|
{MODE_TX, {this->hal->GpioLevelLow, this->hal->GpioLevelHigh}},
|
||||||
END_OF_MODE_TABLE,
|
END_OF_MODE_TABLE,
|
||||||
};
|
};
|
||||||
setRfSwitchTable(pins, table);
|
setRfSwitchTable(pins, table);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setRfSwitchTable(const RADIOLIB_PIN_TYPE (&pins)[3], const RfSwitchMode_t table[]) {
|
void Module::setRfSwitchTable(const uint8_t (&pins)[3], const RfSwitchMode_t table[]) {
|
||||||
memcpy(_rfSwitchPins, pins, sizeof(_rfSwitchPins));
|
memcpy(_rfSwitchPins, pins, sizeof(_rfSwitchPins));
|
||||||
_rfSwitchTable = table;
|
_rfSwitchTable = table;
|
||||||
for(size_t i = 0; i < RFSWITCH_MAX_PINS; i++)
|
for(size_t i = 0; i < RFSWITCH_MAX_PINS; i++)
|
||||||
this->pinMode(pins[i], OUTPUT);
|
this->hal->pinMode(pins[i], this->hal->GpioModeOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Module::RfSwitchMode_t *Module::findRfSwitchMode(uint8_t mode) const {
|
const Module::RfSwitchMode_t *Module::findRfSwitchMode(uint8_t mode) const {
|
||||||
|
@ -811,11 +505,11 @@ void Module::setRfSwitchState(uint8_t mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// set pins
|
// set pins
|
||||||
const RADIOLIB_PIN_STATUS *value = &row->values[0];
|
const uint8_t *value = &row->values[0];
|
||||||
for(size_t i = 0; i < RFSWITCH_MAX_PINS; i++) {
|
for(size_t i = 0; i < RFSWITCH_MAX_PINS; i++) {
|
||||||
RADIOLIB_PIN_TYPE pin = _rfSwitchPins[i];
|
uint8_t pin = _rfSwitchPins[i];
|
||||||
if (pin != RADIOLIB_NC)
|
if (pin != RADIOLIB_NC)
|
||||||
this->digitalWrite(pin, *value);
|
this->hal->digitalWrite(pin, *value);
|
||||||
++value;
|
++value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
229
src/Module.h
229
src/Module.h
|
@ -1,8 +1,8 @@
|
||||||
|
#include "TypeDef.h"
|
||||||
|
#include "Hal.h"
|
||||||
#if !defined(_RADIOLIB_MODULE_H)
|
#if !defined(_RADIOLIB_MODULE_H)
|
||||||
#define _RADIOLIB_MODULE_H
|
#define _RADIOLIB_MODULE_H
|
||||||
|
|
||||||
#include "TypeDef.h"
|
|
||||||
|
|
||||||
#if defined(RADIOLIB_BUILD_ARDUINO)
|
#if defined(RADIOLIB_BUILD_ARDUINO)
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -45,7 +45,7 @@ class Module {
|
||||||
*/
|
*/
|
||||||
struct RfSwitchMode_t {
|
struct RfSwitchMode_t {
|
||||||
uint8_t mode;
|
uint8_t mode;
|
||||||
RADIOLIB_PIN_STATUS values[RFSWITCH_MAX_PINS];
|
uint8_t values[RFSWITCH_MAX_PINS];
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -69,9 +69,8 @@ class Module {
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(RADIOLIB_BUILD_ARDUINO)
|
#if defined(RADIOLIB_BUILD_ARDUINO)
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Arduino Module constructor. Will use the default SPI interface and automatically initialize it
|
\brief Arduino Module constructor. Will use the default SPI interface and automatically initialize it.
|
||||||
|
|
||||||
\param cs Arduino pin to be used as chip select.
|
\param cs Arduino pin to be used as chip select.
|
||||||
|
|
||||||
|
@ -81,7 +80,7 @@ class Module {
|
||||||
|
|
||||||
\param gpio Arduino pin to be used as additional interrupt/GPIO.
|
\param gpio Arduino pin to be used as additional interrupt/GPIO.
|
||||||
*/
|
*/
|
||||||
Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE gpio = RADIOLIB_NC);
|
Module(uint8_t cs, uint8_t irq, uint8_t rst, uint8_t gpio = RADIOLIB_NC);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Arduino Module constructor. Will not attempt SPI interface initialization.
|
\brief Arduino Module constructor. Will not attempt SPI interface initialization.
|
||||||
|
@ -98,24 +97,23 @@ class Module {
|
||||||
|
|
||||||
\param spiSettings SPI interface settings.
|
\param spiSettings SPI interface settings.
|
||||||
*/
|
*/
|
||||||
Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE gpio, SPIClass& spi, SPISettings spiSettings = RADIOLIB_DEFAULT_SPI_SETTINGS);
|
Module(uint8_t cs, uint8_t irq, uint8_t rst, uint8_t gpio, SPIClass& spi, SPISettings spiSettings = RADIOLIB_DEFAULT_SPI_SETTINGS);
|
||||||
|
#endif
|
||||||
#else
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Default constructor.
|
\brief Module constructor.
|
||||||
|
|
||||||
\param cs Pin to be used as chip select.
|
\param hal A Hardware abstraction layer instance. An ArduinoHal instance for example.
|
||||||
|
|
||||||
\param irq Pin to be used as interrupt/GPIO.
|
\param cs Arduino pin to be used as chip select.
|
||||||
|
|
||||||
\param rst Pin to be used as hardware reset for the module.
|
\param irq Arduino pin to be used as interrupt/GPIO.
|
||||||
|
|
||||||
\param gpio Pin to be used as additional interrupt/GPIO.
|
\param rst Arduino pin to be used as hardware reset for the module.
|
||||||
|
|
||||||
|
\param gpio Arduino pin to be used as additional interrupt/GPIO.
|
||||||
*/
|
*/
|
||||||
Module(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE gpio = RADIOLIB_NC);
|
Module(Hal *hal, uint8_t cs, uint8_t irq, uint8_t rst, uint8_t gpio = RADIOLIB_NC);
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Copy constructor.
|
\brief Copy constructor.
|
||||||
|
@ -133,6 +131,8 @@ class Module {
|
||||||
|
|
||||||
// public member variables
|
// public member variables
|
||||||
|
|
||||||
|
Hal* hal = NULL;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Basic SPI read command. Defaults to 0x00.
|
\brief Basic SPI read command. Defaults to 0x00.
|
||||||
*/
|
*/
|
||||||
|
@ -409,28 +409,28 @@ class Module {
|
||||||
|
|
||||||
\returns Pin number of SPI chip select configured in the constructor.
|
\returns Pin number of SPI chip select configured in the constructor.
|
||||||
*/
|
*/
|
||||||
RADIOLIB_PIN_TYPE getCs() const { return(_cs); }
|
uint8_t getCs() const { return(_cs); }
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Access method to get the pin number of interrupt/GPIO.
|
\brief Access method to get the pin number of interrupt/GPIO.
|
||||||
|
|
||||||
\returns Pin number of interrupt/GPIO configured in the constructor.
|
\returns Pin number of interrupt/GPIO configured in the constructor.
|
||||||
*/
|
*/
|
||||||
RADIOLIB_PIN_TYPE getIrq() const { return(_irq); }
|
uint8_t getIrq() const { return(_irq); }
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Access method to get the pin number of hardware reset pin.
|
\brief Access method to get the pin number of hardware reset pin.
|
||||||
|
|
||||||
\returns Pin number of hardware reset pin configured in the constructor.
|
\returns Pin number of hardware reset pin configured in the constructor.
|
||||||
*/
|
*/
|
||||||
RADIOLIB_PIN_TYPE getRst() const { return(_rst); }
|
uint8_t getRst() const { return(_rst); }
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Access method to get the pin number of second interrupt/GPIO.
|
\brief Access method to get the pin number of second interrupt/GPIO.
|
||||||
|
|
||||||
\returns Pin number of second interrupt/GPIO configured in the constructor.
|
\returns Pin number of second interrupt/GPIO configured in the constructor.
|
||||||
*/
|
*/
|
||||||
RADIOLIB_PIN_TYPE getGpio() const { return(_gpio); }
|
uint8_t getGpio() const { return(_gpio); }
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Some modules contain external RF switch controlled by pins.
|
\brief Some modules contain external RF switch controlled by pins.
|
||||||
|
@ -448,7 +448,7 @@ class Module {
|
||||||
\param rxEn RX enable pin.
|
\param rxEn RX enable pin.
|
||||||
\param txEn TX enable pin.
|
\param txEn TX enable pin.
|
||||||
*/
|
*/
|
||||||
void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn);
|
void setRfSwitchPins(uint8_t rxEn, uint8_t txEn);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Some modules contain external RF switch controlled by pins.
|
\brief Some modules contain external RF switch controlled by pins.
|
||||||
|
@ -494,7 +494,7 @@ class Module {
|
||||||
|
|
||||||
\code
|
\code
|
||||||
// In global scope, define the pin array and mode table
|
// In global scope, define the pin array and mode table
|
||||||
static const RADIOLIB_PIN_TYPE rfswitch_pins[] =
|
static const uint8_t rfswitch_pins[] =
|
||||||
{PA0, PA1, RADIOLIB_NC};
|
{PA0, PA1, RADIOLIB_NC};
|
||||||
static const Module::RfSwitchMode_t rfswitch_table[] = {
|
static const Module::RfSwitchMode_t rfswitch_table[] = {
|
||||||
{Module::MODE_IDLE, {LOW, LOW}},
|
{Module::MODE_IDLE, {LOW, LOW}},
|
||||||
|
@ -512,7 +512,7 @@ class Module {
|
||||||
\endcode
|
\endcode
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void setRfSwitchTable(const RADIOLIB_PIN_TYPE (&pins)[RFSWITCH_MAX_PINS], const RfSwitchMode_t table[]);
|
void setRfSwitchTable(const uint8_t (&pins)[RFSWITCH_MAX_PINS], const RfSwitchMode_t table[]);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Find a mode in the RfSwitchTable.
|
* \brief Find a mode in the RfSwitchTable.
|
||||||
|
@ -541,137 +541,6 @@ class Module {
|
||||||
*/
|
*/
|
||||||
void waitForMicroseconds(uint32_t start, uint32_t len);
|
void waitForMicroseconds(uint32_t start, uint32_t len);
|
||||||
|
|
||||||
// Arduino core overrides
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Arduino core pinMode override that checks RADIOLIB_NC as alias for unused pin.
|
|
||||||
|
|
||||||
\param pin Pin to change the mode of.
|
|
||||||
|
|
||||||
\param mode Which mode to set.
|
|
||||||
*/
|
|
||||||
void pinMode(RADIOLIB_PIN_TYPE pin, RADIOLIB_PIN_MODE mode);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Arduino core digitalWrite override that checks RADIOLIB_NC as alias for unused pin.
|
|
||||||
|
|
||||||
\param pin Pin to write to.
|
|
||||||
|
|
||||||
\param value Whether to set the pin high or low.
|
|
||||||
*/
|
|
||||||
void digitalWrite(RADIOLIB_PIN_TYPE pin, RADIOLIB_PIN_STATUS value);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Arduino core digitalWrite override that checks RADIOLIB_NC as alias for unused pin.
|
|
||||||
|
|
||||||
\param pin Pin to read from.
|
|
||||||
|
|
||||||
\returns Pin value.
|
|
||||||
*/
|
|
||||||
RADIOLIB_PIN_STATUS digitalRead(RADIOLIB_PIN_TYPE pin);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Arduino core tone override that checks RADIOLIB_NC as alias for unused pin and RADIOLIB_TONE_UNSUPPORTED to make sure the platform does support tone.
|
|
||||||
|
|
||||||
\param pin Pin to write to.
|
|
||||||
|
|
||||||
\param value Frequency to output.
|
|
||||||
*/
|
|
||||||
void tone(RADIOLIB_PIN_TYPE pin, uint16_t value, uint32_t duration = 0);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Arduino core noTone override that checks RADIOLIB_NC as alias for unused pin and RADIOLIB_TONE_UNSUPPORTED to make sure the platform does support tone.
|
|
||||||
|
|
||||||
\param pin Pin to write to.
|
|
||||||
*/
|
|
||||||
void noTone(RADIOLIB_PIN_TYPE pin);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Arduino core attachInterrupt override.
|
|
||||||
|
|
||||||
\param interruptNum Interrupt number.
|
|
||||||
|
|
||||||
\param userFunc Interrupt service routine.
|
|
||||||
|
|
||||||
\param mode Pin hcange direction.
|
|
||||||
*/
|
|
||||||
void attachInterrupt(RADIOLIB_PIN_TYPE interruptNum, void (*userFunc)(void), RADIOLIB_INTERRUPT_STATUS mode);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Arduino core detachInterrupt override.
|
|
||||||
|
|
||||||
\param interruptNum Interrupt number.
|
|
||||||
*/
|
|
||||||
void detachInterrupt(RADIOLIB_PIN_TYPE interruptNum);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Arduino core yield override.
|
|
||||||
*/
|
|
||||||
void yield();
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Arduino core delay override.
|
|
||||||
|
|
||||||
\param ms Delay length in milliseconds.
|
|
||||||
*/
|
|
||||||
void delay(uint32_t ms);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Arduino core delayMicroseconds override.
|
|
||||||
|
|
||||||
\param us Delay length in microseconds.
|
|
||||||
*/
|
|
||||||
void delayMicroseconds(uint32_t us);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Arduino core millis override.
|
|
||||||
*/
|
|
||||||
uint32_t millis();
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Arduino core micros override.
|
|
||||||
*/
|
|
||||||
uint32_t micros();
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Arduino core pulseIn override.
|
|
||||||
*/
|
|
||||||
uint32_t pulseIn(RADIOLIB_PIN_TYPE pin, RADIOLIB_PIN_STATUS state, uint32_t timeout);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Arduino core SPI begin override.
|
|
||||||
*/
|
|
||||||
void begin();
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Arduino core SPI beginTransaction override.
|
|
||||||
*/
|
|
||||||
void beginTransaction();
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Arduino core SPI transfer override.
|
|
||||||
*/
|
|
||||||
uint8_t transfer(uint8_t b);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Arduino core SPI endTransaction override.
|
|
||||||
*/
|
|
||||||
void endTransaction();
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Arduino core SPI end override.
|
|
||||||
*/
|
|
||||||
void end();
|
|
||||||
|
|
||||||
// helper functions to set up SPI overrides on Arduino
|
|
||||||
#if defined(RADIOLIB_BUILD_ARDUINO)
|
|
||||||
void SPIbegin();
|
|
||||||
void SPIend();
|
|
||||||
virtual void SPIbeginTransaction();
|
|
||||||
virtual uint8_t SPItransfer(uint8_t b);
|
|
||||||
virtual void SPIendTransaction();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Function to reflect bits within a byte.
|
\brief Function to reflect bits within a byte.
|
||||||
*/
|
*/
|
||||||
|
@ -711,58 +580,18 @@ class Module {
|
||||||
#if !defined(RADIOLIB_GODMODE)
|
#if !defined(RADIOLIB_GODMODE)
|
||||||
private:
|
private:
|
||||||
#endif
|
#endif
|
||||||
|
uint8_t _cs = RADIOLIB_NC;
|
||||||
// pins
|
uint8_t _irq = RADIOLIB_NC;
|
||||||
RADIOLIB_PIN_TYPE _cs = RADIOLIB_NC;
|
uint8_t _rst = RADIOLIB_NC;
|
||||||
RADIOLIB_PIN_TYPE _irq = RADIOLIB_NC;
|
uint8_t _gpio = RADIOLIB_NC;
|
||||||
RADIOLIB_PIN_TYPE _rst = RADIOLIB_NC;
|
|
||||||
RADIOLIB_PIN_TYPE _gpio = RADIOLIB_NC;
|
|
||||||
|
|
||||||
// SPI interface (Arduino only)
|
|
||||||
#if defined(RADIOLIB_BUILD_ARDUINO)
|
|
||||||
SPIClass* _spi = NULL;
|
|
||||||
SPISettings _spiSettings = RADIOLIB_DEFAULT_SPI_SETTINGS;
|
|
||||||
bool _initInterface = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// RF switch pins and table
|
// RF switch pins and table
|
||||||
RADIOLIB_PIN_TYPE _rfSwitchPins[RFSWITCH_MAX_PINS] = { RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC };
|
uint8_t _rfSwitchPins[RFSWITCH_MAX_PINS] = { RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC };
|
||||||
const RfSwitchMode_t *_rfSwitchTable = nullptr;
|
const RfSwitchMode_t *_rfSwitchTable = nullptr;
|
||||||
|
|
||||||
#if defined(RADIOLIB_INTERRUPT_TIMING)
|
#if defined(RADIOLIB_INTERRUPT_TIMING)
|
||||||
uint32_t _prevTimingLen = 0;
|
uint32_t _prevTimingLen = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// hardware abstraction layer callbacks
|
|
||||||
// this is placed at the end of Module class because the callback generator macros
|
|
||||||
// screw with the private/public access specifiers
|
|
||||||
RADIOLIB_GENERATE_CALLBACK(RADIOLIB_CB_ARGS_PIN_MODE);
|
|
||||||
RADIOLIB_GENERATE_CALLBACK(RADIOLIB_CB_ARGS_DIGITAL_WRITE);
|
|
||||||
RADIOLIB_GENERATE_CALLBACK(RADIOLIB_CB_ARGS_DIGITAL_READ);
|
|
||||||
RADIOLIB_GENERATE_CALLBACK(RADIOLIB_CB_ARGS_TONE);
|
|
||||||
RADIOLIB_GENERATE_CALLBACK(RADIOLIB_CB_ARGS_NO_TONE);
|
|
||||||
RADIOLIB_GENERATE_CALLBACK(RADIOLIB_CB_ARGS_ATTACH_INTERRUPT);
|
|
||||||
RADIOLIB_GENERATE_CALLBACK(RADIOLIB_CB_ARGS_DETACH_INTERRUPT);
|
|
||||||
RADIOLIB_GENERATE_CALLBACK(RADIOLIB_CB_ARGS_YIELD);
|
|
||||||
RADIOLIB_GENERATE_CALLBACK(RADIOLIB_CB_ARGS_DELAY);
|
|
||||||
RADIOLIB_GENERATE_CALLBACK(RADIOLIB_CB_ARGS_DELAY_MICROSECONDS);
|
|
||||||
RADIOLIB_GENERATE_CALLBACK(RADIOLIB_CB_ARGS_MILLIS);
|
|
||||||
RADIOLIB_GENERATE_CALLBACK(RADIOLIB_CB_ARGS_MICROS);
|
|
||||||
RADIOLIB_GENERATE_CALLBACK(RADIOLIB_CB_ARGS_PULSE_IN);
|
|
||||||
|
|
||||||
#if defined(RADIOLIB_BUILD_ARDUINO)
|
|
||||||
RADIOLIB_GENERATE_CALLBACK_SPI(RADIOLIB_CB_ARGS_SPI_BEGIN);
|
|
||||||
RADIOLIB_GENERATE_CALLBACK_SPI(RADIOLIB_CB_ARGS_SPI_BEGIN_TRANSACTION);
|
|
||||||
RADIOLIB_GENERATE_CALLBACK_SPI(RADIOLIB_CB_ARGS_SPI_TRANSFER);
|
|
||||||
RADIOLIB_GENERATE_CALLBACK_SPI(RADIOLIB_CB_ARGS_SPI_END_TRANSACTION);
|
|
||||||
RADIOLIB_GENERATE_CALLBACK_SPI(RADIOLIB_CB_ARGS_SPI_END);
|
|
||||||
#else
|
|
||||||
RADIOLIB_GENERATE_CALLBACK(RADIOLIB_CB_ARGS_SPI_BEGIN);
|
|
||||||
RADIOLIB_GENERATE_CALLBACK(RADIOLIB_CB_ARGS_SPI_BEGIN_TRANSACTION);
|
|
||||||
RADIOLIB_GENERATE_CALLBACK(RADIOLIB_CB_ARGS_SPI_TRANSFER);
|
|
||||||
RADIOLIB_GENERATE_CALLBACK(RADIOLIB_CB_ARGS_SPI_END_TRANSACTION);
|
|
||||||
RADIOLIB_GENERATE_CALLBACK(RADIOLIB_CB_ARGS_SPI_END);
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -38,6 +38,12 @@
|
||||||
#include "TypeDef.h"
|
#include "TypeDef.h"
|
||||||
#include "Module.h"
|
#include "Module.h"
|
||||||
|
|
||||||
|
#include "Hal.h"
|
||||||
|
#if defined(RADIOLIB_BUILD_ARDUINO)
|
||||||
|
#include "ArduinoHal.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// warnings are printed in this file since BuildOpt.h is compiled in multiple places
|
// warnings are printed in this file since BuildOpt.h is compiled in multiple places
|
||||||
|
|
||||||
// check God mode
|
// check God mode
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "CC1101.h"
|
#include "CC1101.h"
|
||||||
|
#include <math.h>
|
||||||
#if !defined(RADIOLIB_EXCLUDE_CC1101)
|
#if !defined(RADIOLIB_EXCLUDE_CC1101)
|
||||||
|
|
||||||
CC1101::CC1101(Module* module) : PhysicalLayer(RADIOLIB_CC1101_FREQUENCY_STEP_SIZE, RADIOLIB_CC1101_MAX_PACKET_LENGTH) {
|
CC1101::CC1101(Module* module) : PhysicalLayer(RADIOLIB_CC1101_FREQUENCY_STEP_SIZE, RADIOLIB_CC1101_MAX_PACKET_LENGTH) {
|
||||||
|
@ -14,7 +15,7 @@ int16_t CC1101::begin(float freq, float br, float freqDev, float rxBw, int8_t po
|
||||||
_mod->SPIreadCommand = RADIOLIB_CC1101_CMD_READ;
|
_mod->SPIreadCommand = RADIOLIB_CC1101_CMD_READ;
|
||||||
_mod->SPIwriteCommand = RADIOLIB_CC1101_CMD_WRITE;
|
_mod->SPIwriteCommand = RADIOLIB_CC1101_CMD_WRITE;
|
||||||
_mod->init();
|
_mod->init();
|
||||||
_mod->pinMode(_mod->getIrq(), INPUT);
|
_mod->hal->pinMode(_mod->getIrq(), _mod->hal->GpioModeInput);
|
||||||
|
|
||||||
// try to find the CC1101 chip
|
// try to find the CC1101 chip
|
||||||
uint8_t i = 0;
|
uint8_t i = 0;
|
||||||
|
@ -25,7 +26,7 @@ int16_t CC1101::begin(float freq, float br, float freqDev, float rxBw, int8_t po
|
||||||
flagFound = true;
|
flagFound = true;
|
||||||
} else {
|
} else {
|
||||||
RADIOLIB_DEBUG_PRINTLN("CC1101 not found! (%d of 10 tries) RADIOLIB_CC1101_REG_VERSION == 0x%04X, expected 0x0004/0x0014", i + 1, version);
|
RADIOLIB_DEBUG_PRINTLN("CC1101 not found! (%d of 10 tries) RADIOLIB_CC1101_REG_VERSION == 0x%04X, expected 0x0004/0x0014", i + 1, version);
|
||||||
_mod->delay(10);
|
_mod->hal->delay(10);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,22 +100,22 @@ int16_t CC1101::transmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// wait for transmission start or timeout
|
// wait for transmission start or timeout
|
||||||
uint32_t start = _mod->micros();
|
uint32_t start = _mod->hal->micros();
|
||||||
while(!_mod->digitalRead(_mod->getGpio())) {
|
while(!_mod->hal->digitalRead(_mod->getGpio())) {
|
||||||
_mod->yield();
|
_mod->hal->yield();
|
||||||
|
|
||||||
if(_mod->micros() - start > timeout) {
|
if(_mod->hal->micros() - start > timeout) {
|
||||||
finishTransmit();
|
finishTransmit();
|
||||||
return(RADIOLIB_ERR_TX_TIMEOUT);
|
return(RADIOLIB_ERR_TX_TIMEOUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait for transmission end or timeout
|
// wait for transmission end or timeout
|
||||||
start = _mod->micros();
|
start = _mod->hal->micros();
|
||||||
while(_mod->digitalRead(_mod->getGpio())) {
|
while(_mod->hal->digitalRead(_mod->getGpio())) {
|
||||||
_mod->yield();
|
_mod->hal->yield();
|
||||||
|
|
||||||
if(_mod->micros() - start > timeout) {
|
if(_mod->hal->micros() - start > timeout) {
|
||||||
finishTransmit();
|
finishTransmit();
|
||||||
return(RADIOLIB_ERR_TX_TIMEOUT);
|
return(RADIOLIB_ERR_TX_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
@ -132,11 +133,11 @@ int16_t CC1101::receive(uint8_t* data, size_t len) {
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// wait for packet or timeout
|
// wait for packet or timeout
|
||||||
uint32_t start = _mod->micros();
|
uint32_t start = _mod->hal->micros();
|
||||||
while(!_mod->digitalRead(_mod->getIrq())) {
|
while(!_mod->hal->digitalRead(_mod->getIrq())) {
|
||||||
_mod->yield();
|
_mod->hal->yield();
|
||||||
|
|
||||||
if(_mod->micros() - start > timeout) {
|
if(_mod->hal->micros() - start > timeout) {
|
||||||
standby();
|
standby();
|
||||||
SPIsendCommand(RADIOLIB_CC1101_CMD_FLUSH_RX);
|
SPIsendCommand(RADIOLIB_CC1101_CMD_FLUSH_RX);
|
||||||
return(RADIOLIB_ERR_RX_TIMEOUT);
|
return(RADIOLIB_ERR_RX_TIMEOUT);
|
||||||
|
@ -219,27 +220,27 @@ int16_t CC1101::packetMode() {
|
||||||
return(state);
|
return(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CC1101::setGdo0Action(void (*func)(void), RADIOLIB_INTERRUPT_STATUS dir) {
|
void CC1101::setGdo0Action(void (*func)(void), uint8_t dir) {
|
||||||
_mod->attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, dir);
|
_mod->hal->attachInterrupt(_mod->hal->pinToInterrupt(_mod->getIrq()), func, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CC1101::clearGdo0Action() {
|
void CC1101::clearGdo0Action() {
|
||||||
_mod->detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()));
|
_mod->hal->detachInterrupt(_mod->hal->pinToInterrupt(_mod->getIrq()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CC1101::setGdo2Action(void (*func)(void), RADIOLIB_INTERRUPT_STATUS dir) {
|
void CC1101::setGdo2Action(void (*func)(void), uint8_t dir) {
|
||||||
if(_mod->getGpio() == RADIOLIB_NC) {
|
if(_mod->getGpio() == RADIOLIB_NC) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_mod->pinMode(_mod->getGpio(), INPUT);
|
_mod->hal->pinMode(_mod->getGpio(), _mod->hal->GpioModeInput);
|
||||||
_mod->attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio()), func, dir);
|
_mod->hal->attachInterrupt(_mod->hal->pinToInterrupt(_mod->getGpio()), func, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CC1101::clearGdo2Action() {
|
void CC1101::clearGdo2Action() {
|
||||||
if(_mod->getGpio() == RADIOLIB_NC) {
|
if(_mod->getGpio() == RADIOLIB_NC) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_mod->detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio()));
|
_mod->hal->detachInterrupt(_mod->hal->pinToInterrupt(_mod->getGpio()));
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t CC1101::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
int16_t CC1101::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
|
@ -309,7 +310,7 @@ int16_t CC1101::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
*
|
*
|
||||||
* TODO: test this on real hardware
|
* TODO: test this on real hardware
|
||||||
*/
|
*/
|
||||||
_mod->delayMicroseconds(250);
|
_mod->hal->delayMicroseconds(250);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,17 +372,17 @@ int16_t CC1101::readData(uint8_t* data, size_t len) {
|
||||||
|
|
||||||
uint8_t bytesInFIFO = SPIgetRegValue(RADIOLIB_CC1101_REG_RXBYTES, 6, 0);
|
uint8_t bytesInFIFO = SPIgetRegValue(RADIOLIB_CC1101_REG_RXBYTES, 6, 0);
|
||||||
size_t readBytes = 0;
|
size_t readBytes = 0;
|
||||||
uint32_t lastPop = millis();
|
uint32_t lastPop = _mod->hal->millis();
|
||||||
|
|
||||||
// keep reading from FIFO until we get all the packet.
|
// keep reading from FIFO until we get all the packet.
|
||||||
while (readBytes < length) {
|
while (readBytes < length) {
|
||||||
if (bytesInFIFO == 0) {
|
if (bytesInFIFO == 0) {
|
||||||
if (millis() - lastPop > 5) {
|
if (_mod->hal->millis() - lastPop > 5) {
|
||||||
// readData was required to read a packet longer than the one received.
|
// readData was required to read a packet longer than the one received.
|
||||||
RADIOLIB_DEBUG_PRINTLN("No data for more than 5mS. Stop here.");
|
RADIOLIB_DEBUG_PRINTLN("No data for more than 5mS. Stop here.");
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
delay(1);
|
_mod->hal->delay(1);
|
||||||
bytesInFIFO = SPIgetRegValue(RADIOLIB_CC1101_REG_RXBYTES, 6, 0);
|
bytesInFIFO = SPIgetRegValue(RADIOLIB_CC1101_REG_RXBYTES, 6, 0);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -391,7 +392,7 @@ int16_t CC1101::readData(uint8_t* data, size_t len) {
|
||||||
uint8_t bytesToRead = min((uint8_t)(length - readBytes), bytesInFIFO);
|
uint8_t bytesToRead = min((uint8_t)(length - readBytes), bytesInFIFO);
|
||||||
SPIreadRegisterBurst(RADIOLIB_CC1101_REG_FIFO, bytesToRead, &(data[readBytes]));
|
SPIreadRegisterBurst(RADIOLIB_CC1101_REG_FIFO, bytesToRead, &(data[readBytes]));
|
||||||
readBytes += bytesToRead;
|
readBytes += bytesToRead;
|
||||||
lastPop = millis();
|
lastPop = _mod->hal->millis();
|
||||||
|
|
||||||
// Get how many bytes are left in FIFO.
|
// Get how many bytes are left in FIFO.
|
||||||
bytesInFIFO = SPIgetRegValue(RADIOLIB_CC1101_REG_RXBYTES, 6, 0);
|
bytesInFIFO = SPIgetRegValue(RADIOLIB_CC1101_REG_RXBYTES, 6, 0);
|
||||||
|
@ -401,7 +402,7 @@ int16_t CC1101::readData(uint8_t* data, size_t len) {
|
||||||
bool isAppendStatus = SPIgetRegValue(RADIOLIB_CC1101_REG_PKTCTRL1, 2, 2) == RADIOLIB_CC1101_APPEND_STATUS_ON;
|
bool isAppendStatus = SPIgetRegValue(RADIOLIB_CC1101_REG_PKTCTRL1, 2, 2) == RADIOLIB_CC1101_APPEND_STATUS_ON;
|
||||||
|
|
||||||
// for some reason, we need this delay here to get the correct status bytes
|
// for some reason, we need this delay here to get the correct status bytes
|
||||||
delay(3);
|
_mod->hal->delay(3);
|
||||||
|
|
||||||
// If status byte is enabled at least 2 bytes (2 status bytes + any following packet) will remain in FIFO.
|
// If status byte is enabled at least 2 bytes (2 status bytes + any following packet) will remain in FIFO.
|
||||||
if (isAppendStatus) {
|
if (isAppendStatus) {
|
||||||
|
@ -898,11 +899,11 @@ int16_t CC1101::setEncoding(uint8_t encoding) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CC1101::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) {
|
void CC1101::setRfSwitchPins(uint8_t rxEn, uint8_t txEn) {
|
||||||
_mod->setRfSwitchPins(rxEn, txEn);
|
_mod->setRfSwitchPins(rxEn, txEn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CC1101::setRfSwitchTable(const RADIOLIB_PIN_TYPE (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]) {
|
void CC1101::setRfSwitchTable(const uint8_t (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]) {
|
||||||
_mod->setRfSwitchTable(pins, table);
|
_mod->setRfSwitchTable(pins, table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -912,7 +913,7 @@ uint8_t CC1101::randomByte() {
|
||||||
RADIOLIB_DEBUG_PRINTLN("CC1101::randomByte");
|
RADIOLIB_DEBUG_PRINTLN("CC1101::randomByte");
|
||||||
|
|
||||||
// wait a bit for the RSSI reading to stabilise
|
// wait a bit for the RSSI reading to stabilise
|
||||||
_mod->delay(10);
|
_mod->hal->delay(10);
|
||||||
|
|
||||||
// read RSSI value 8 times, always keep just the least significant bit
|
// read RSSI value 8 times, always keep just the least significant bit
|
||||||
uint8_t randByte = 0x00;
|
uint8_t randByte = 0x00;
|
||||||
|
@ -932,15 +933,15 @@ int16_t CC1101::getChipVersion() {
|
||||||
|
|
||||||
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
|
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
|
||||||
void CC1101::setDirectAction(void (*func)(void)) {
|
void CC1101::setDirectAction(void (*func)(void)) {
|
||||||
setGdo0Action(func);
|
setGdo0Action(func, _mod->hal->GpioInterruptRising);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CC1101::readBit(RADIOLIB_PIN_TYPE pin) {
|
void CC1101::readBit(uint8_t pin) {
|
||||||
updateDirectBuffer((uint8_t)_mod->digitalRead(pin));
|
updateDirectBuffer((uint8_t)_mod->hal->digitalRead(pin));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int16_t CC1101::setDIOMapping(RADIOLIB_PIN_TYPE pin, uint8_t value) {
|
int16_t CC1101::setDIOMapping(uint8_t pin, uint8_t value) {
|
||||||
if (pin > 2)
|
if (pin > 2)
|
||||||
return RADIOLIB_ERR_INVALID_DIO_PIN;
|
return RADIOLIB_ERR_INVALID_DIO_PIN;
|
||||||
|
|
||||||
|
@ -952,7 +953,7 @@ int16_t CC1101::config() {
|
||||||
SPIsendCommand(RADIOLIB_CC1101_CMD_RESET);
|
SPIsendCommand(RADIOLIB_CC1101_CMD_RESET);
|
||||||
|
|
||||||
// Wait a ridiculous amount of time to be sure radio is ready.
|
// Wait a ridiculous amount of time to be sure radio is ready.
|
||||||
_mod->delay(150);
|
_mod->hal->delay(150);
|
||||||
|
|
||||||
// enable automatic frequency synthesizer calibration
|
// enable automatic frequency synthesizer calibration
|
||||||
int16_t state = SPIsetRegValue(RADIOLIB_CC1101_REG_MCSM0, RADIOLIB_CC1101_FS_AUTOCAL_IDLE_TO_RXTX, 5, 4);
|
int16_t state = SPIsetRegValue(RADIOLIB_CC1101_REG_MCSM0, RADIOLIB_CC1101_FS_AUTOCAL_IDLE_TO_RXTX, 5, 4);
|
||||||
|
@ -1082,17 +1083,17 @@ void CC1101::SPIwriteRegisterBurst(uint8_t reg, uint8_t* data, size_t len) {
|
||||||
|
|
||||||
void CC1101::SPIsendCommand(uint8_t cmd) {
|
void CC1101::SPIsendCommand(uint8_t cmd) {
|
||||||
// pull NSS low
|
// pull NSS low
|
||||||
_mod->digitalWrite(_mod->getCs(), LOW);
|
_mod->hal->digitalWrite(_mod->getCs(), _mod->hal->GpioLevelLow);
|
||||||
|
|
||||||
// start transfer
|
// start transfer
|
||||||
_mod->beginTransaction();
|
_mod->hal->spiBeginTransaction();
|
||||||
|
|
||||||
// send the command byte
|
// send the command byte
|
||||||
_mod->transfer(cmd);
|
_mod->hal->spiTransfer(cmd);
|
||||||
|
|
||||||
// stop transfer
|
// stop transfer
|
||||||
_mod->endTransaction();
|
_mod->hal->spiEndTransaction();
|
||||||
_mod->digitalWrite(_mod->getCs(), HIGH);
|
_mod->hal->digitalWrite(_mod->getCs(), _mod->hal->GpioLevelHigh);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -644,9 +644,9 @@ class CC1101: public PhysicalLayer {
|
||||||
|
|
||||||
\param func ISR to call.
|
\param func ISR to call.
|
||||||
|
|
||||||
\param dir Signal change direction. Defaults to RISING.
|
\param dir Signal change direction.
|
||||||
*/
|
*/
|
||||||
void setGdo0Action(void (*func)(void), RADIOLIB_INTERRUPT_STATUS dir = RISING);
|
void setGdo0Action(void (*func)(void), uint8_t dir);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Clears interrupt service routine to call when GDO0 activates.
|
\brief Clears interrupt service routine to call when GDO0 activates.
|
||||||
|
@ -658,9 +658,9 @@ class CC1101: public PhysicalLayer {
|
||||||
|
|
||||||
\param func ISR to call.
|
\param func ISR to call.
|
||||||
|
|
||||||
\param dir Signal change direction. Defaults to FALLING.
|
\param dir Signal change direction.
|
||||||
*/
|
*/
|
||||||
void setGdo2Action(void (*func)(void), RADIOLIB_INTERRUPT_STATUS dir = FALLING);
|
void setGdo2Action(void (*func)(void), uint8_t dir);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Clears interrupt service routine to call when GDO0 activates.
|
\brief Clears interrupt service routine to call when GDO0 activates.
|
||||||
|
@ -953,10 +953,10 @@ class CC1101: public PhysicalLayer {
|
||||||
int16_t setEncoding(uint8_t encoding) override;
|
int16_t setEncoding(uint8_t encoding) override;
|
||||||
|
|
||||||
/*! \copydoc Module::setRfSwitchPins */
|
/*! \copydoc Module::setRfSwitchPins */
|
||||||
void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn);
|
void setRfSwitchPins(uint8_t rxEn, uint8_t txEn);
|
||||||
|
|
||||||
/*! \copydoc Module::setRfSwitchTable */
|
/*! \copydoc Module::setRfSwitchTable */
|
||||||
void setRfSwitchTable(const RADIOLIB_PIN_TYPE (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]);
|
void setRfSwitchTable(const uint8_t (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Get one truly random byte from RSSI noise.
|
\brief Get one truly random byte from RSSI noise.
|
||||||
|
@ -985,7 +985,7 @@ class CC1101: public PhysicalLayer {
|
||||||
|
|
||||||
\param pin Pin on which to read.
|
\param pin Pin on which to read.
|
||||||
*/
|
*/
|
||||||
void readBit(RADIOLIB_PIN_TYPE pin);
|
void readBit(uint8_t pin);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -997,7 +997,7 @@ class CC1101: public PhysicalLayer {
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t setDIOMapping(RADIOLIB_PIN_TYPE pin, uint8_t value);
|
int16_t setDIOMapping(uint8_t pin, uint8_t value);
|
||||||
|
|
||||||
#if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL)
|
#if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL)
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "RF69.h"
|
#include "RF69.h"
|
||||||
|
#include <math.h>
|
||||||
#if !defined(RADIOLIB_EXCLUDE_RF69)
|
#if !defined(RADIOLIB_EXCLUDE_RF69)
|
||||||
|
|
||||||
RF69::RF69(Module* module) : PhysicalLayer(RADIOLIB_RF69_FREQUENCY_STEP_SIZE, RADIOLIB_RF69_MAX_PACKET_LENGTH) {
|
RF69::RF69(Module* module) : PhysicalLayer(RADIOLIB_RF69_FREQUENCY_STEP_SIZE, RADIOLIB_RF69_MAX_PACKET_LENGTH) {
|
||||||
|
@ -12,7 +13,7 @@ Module* RF69::getMod() {
|
||||||
int16_t RF69::begin(float freq, float br, float freqDev, float rxBw, int8_t power, uint8_t preambleLen) {
|
int16_t RF69::begin(float freq, float br, float freqDev, float rxBw, int8_t power, uint8_t preambleLen) {
|
||||||
// set module properties
|
// set module properties
|
||||||
_mod->init();
|
_mod->init();
|
||||||
_mod->pinMode(_mod->getIrq(), INPUT);
|
_mod->hal->pinMode(_mod->getIrq(), _mod->hal->GpioModeInput);
|
||||||
|
|
||||||
// try to find the RF69 chip
|
// try to find the RF69 chip
|
||||||
uint8_t i = 0;
|
uint8_t i = 0;
|
||||||
|
@ -27,7 +28,7 @@ int16_t RF69::begin(float freq, float br, float freqDev, float rxBw, int8_t powe
|
||||||
flagFound = true;
|
flagFound = true;
|
||||||
} else {
|
} else {
|
||||||
RADIOLIB_DEBUG_PRINTLN("RF69 not found! (%d of 10 tries) RADIOLIB_RF69_REG_VERSION == 0x%04X, expected 0x0024", i + 1, version);
|
RADIOLIB_DEBUG_PRINTLN("RF69 not found! (%d of 10 tries) RADIOLIB_RF69_REG_VERSION == 0x%04X, expected 0x0024", i + 1, version);
|
||||||
_mod->delay(10);
|
_mod->hal->delay(10);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,11 +95,11 @@ int16_t RF69::begin(float freq, float br, float freqDev, float rxBw, int8_t powe
|
||||||
}
|
}
|
||||||
|
|
||||||
void RF69::reset() {
|
void RF69::reset() {
|
||||||
_mod->pinMode(_mod->getRst(), OUTPUT);
|
_mod->hal->pinMode(_mod->getRst(), _mod->hal->GpioModeOutput);
|
||||||
_mod->digitalWrite(_mod->getRst(), HIGH);
|
_mod->hal->digitalWrite(_mod->getRst(), _mod->hal->GpioLevelHigh);
|
||||||
_mod->delay(1);
|
_mod->hal->delay(1);
|
||||||
_mod->digitalWrite(_mod->getRst(), LOW);
|
_mod->hal->digitalWrite(_mod->getRst(), _mod->hal->GpioLevelLow);
|
||||||
_mod->delay(10);
|
_mod->hal->delay(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t RF69::transmit(uint8_t* data, size_t len, uint8_t addr) {
|
int16_t RF69::transmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
|
@ -110,11 +111,11 @@ int16_t RF69::transmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// wait for transmission end or timeout
|
// wait for transmission end or timeout
|
||||||
uint32_t start = _mod->micros();
|
uint32_t start = _mod->hal->micros();
|
||||||
while(!_mod->digitalRead(_mod->getIrq())) {
|
while(!_mod->hal->digitalRead(_mod->getIrq())) {
|
||||||
_mod->yield();
|
_mod->hal->yield();
|
||||||
|
|
||||||
if(_mod->micros() - start > timeout) {
|
if(_mod->hal->micros() - start > timeout) {
|
||||||
finishTransmit();
|
finishTransmit();
|
||||||
return(RADIOLIB_ERR_TX_TIMEOUT);
|
return(RADIOLIB_ERR_TX_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
@ -132,11 +133,11 @@ int16_t RF69::receive(uint8_t* data, size_t len) {
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// wait for packet reception or timeout
|
// wait for packet reception or timeout
|
||||||
uint32_t start = _mod->micros();
|
uint32_t start = _mod->hal->micros();
|
||||||
while(!_mod->digitalRead(_mod->getIrq())) {
|
while(!_mod->hal->digitalRead(_mod->getIrq())) {
|
||||||
_mod->yield();
|
_mod->hal->yield();
|
||||||
|
|
||||||
if(_mod->micros() - start > timeout) {
|
if(_mod->hal->micros() - start > timeout) {
|
||||||
standby();
|
standby();
|
||||||
clearIRQFlags();
|
clearIRQFlags();
|
||||||
return(RADIOLIB_ERR_RX_TIMEOUT);
|
return(RADIOLIB_ERR_RX_TIMEOUT);
|
||||||
|
@ -271,26 +272,26 @@ int16_t RF69::startReceive(uint32_t timeout, uint16_t irqFlags, uint16_t irqMask
|
||||||
}
|
}
|
||||||
|
|
||||||
void RF69::setDio0Action(void (*func)(void)) {
|
void RF69::setDio0Action(void (*func)(void)) {
|
||||||
_mod->attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, RISING);
|
_mod->hal->attachInterrupt(_mod->hal->pinToInterrupt(_mod->getIrq()), func, _mod->hal->GpioInterruptRising);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RF69::clearDio0Action() {
|
void RF69::clearDio0Action() {
|
||||||
_mod->detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()));
|
_mod->hal->detachInterrupt(_mod->hal->pinToInterrupt(_mod->getIrq()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RF69::setDio1Action(void (*func)(void)) {
|
void RF69::setDio1Action(void (*func)(void)) {
|
||||||
if(_mod->getGpio() == RADIOLIB_NC) {
|
if(_mod->getGpio() == RADIOLIB_NC) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_mod->pinMode(_mod->getGpio(), INPUT);
|
_mod->hal->pinMode(_mod->getGpio(), _mod->hal->GpioModeInput);
|
||||||
_mod->attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio()), func, RISING);
|
_mod->hal->attachInterrupt(_mod->hal->pinToInterrupt(_mod->getGpio()), func, _mod->hal->GpioInterruptRising);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RF69::clearDio1Action() {
|
void RF69::clearDio1Action() {
|
||||||
if(_mod->getGpio() == RADIOLIB_NC) {
|
if(_mod->getGpio() == RADIOLIB_NC) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_mod->detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio()));
|
_mod->hal->detachInterrupt(_mod->hal->pinToInterrupt(_mod->getGpio()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RF69::setFifoEmptyAction(void (*func)(void)) {
|
void RF69::setFifoEmptyAction(void (*func)(void)) {
|
||||||
|
@ -298,10 +299,10 @@ void RF69::setFifoEmptyAction(void (*func)(void)) {
|
||||||
if(_mod->getGpio() == RADIOLIB_NC) {
|
if(_mod->getGpio() == RADIOLIB_NC) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_mod->pinMode(_mod->getGpio(), INPUT);
|
_mod->hal->pinMode(_mod->getGpio(), _mod->hal->GpioModeInput);
|
||||||
|
|
||||||
// we need to invert the logic here (as compared to setDio1Action), since we are using the "FIFO not empty interrupt"
|
// we need to invert the logic here (as compared to setDio1Action), since we are using the "FIFO not empty interrupt"
|
||||||
_mod->attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio()), func, FALLING);
|
_mod->hal->attachInterrupt(_mod->hal->pinToInterrupt(_mod->getGpio()), func, _mod->hal->GpioInterruptFalling);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RF69::clearFifoEmptyAction() {
|
void RF69::clearFifoEmptyAction() {
|
||||||
|
@ -758,7 +759,7 @@ int16_t RF69::getTemperature() {
|
||||||
// wait until measurement is finished
|
// wait until measurement is finished
|
||||||
while(_mod->SPIgetRegValue(RADIOLIB_RF69_REG_TEMP_1, 2, 2) == RADIOLIB_RF69_TEMP_MEAS_RUNNING) {
|
while(_mod->SPIgetRegValue(RADIOLIB_RF69_REG_TEMP_1, 2, 2) == RADIOLIB_RF69_TEMP_MEAS_RUNNING) {
|
||||||
// check every 10 us
|
// check every 10 us
|
||||||
_mod->delay(10);
|
_mod->hal->delay(10);
|
||||||
}
|
}
|
||||||
int8_t rawTemp = _mod->SPIgetRegValue(RADIOLIB_RF69_REG_TEMP_2);
|
int8_t rawTemp = _mod->SPIgetRegValue(RADIOLIB_RF69_REG_TEMP_2);
|
||||||
|
|
||||||
|
@ -916,11 +917,11 @@ int16_t RF69::setRSSIThreshold(float dbm) {
|
||||||
return _mod->SPIsetRegValue(RADIOLIB_RF69_REG_RSSI_THRESH, (uint8_t)(-2.0 * dbm), 7, 0);
|
return _mod->SPIsetRegValue(RADIOLIB_RF69_REG_RSSI_THRESH, (uint8_t)(-2.0 * dbm), 7, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RF69::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) {
|
void RF69::setRfSwitchPins(uint8_t rxEn, uint8_t txEn) {
|
||||||
_mod->setRfSwitchPins(rxEn, txEn);
|
_mod->setRfSwitchPins(rxEn, txEn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RF69::setRfSwitchTable(const RADIOLIB_PIN_TYPE (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]) {
|
void RF69::setRfSwitchTable(const uint8_t (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]) {
|
||||||
_mod->setRfSwitchTable(pins, table);
|
_mod->setRfSwitchTable(pins, table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -929,7 +930,7 @@ uint8_t RF69::randomByte() {
|
||||||
setMode(RADIOLIB_RF69_RX);
|
setMode(RADIOLIB_RF69_RX);
|
||||||
|
|
||||||
// wait a bit for the RSSI reading to stabilise
|
// wait a bit for the RSSI reading to stabilise
|
||||||
_mod->delay(10);
|
_mod->hal->delay(10);
|
||||||
|
|
||||||
// read RSSI value 8 times, always keep just the least significant bit
|
// read RSSI value 8 times, always keep just the least significant bit
|
||||||
uint8_t randByte = 0x00;
|
uint8_t randByte = 0x00;
|
||||||
|
@ -948,12 +949,12 @@ void RF69::setDirectAction(void (*func)(void)) {
|
||||||
setDio1Action(func);
|
setDio1Action(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RF69::readBit(RADIOLIB_PIN_TYPE pin) {
|
void RF69::readBit(uint8_t pin) {
|
||||||
updateDirectBuffer((uint8_t)_mod->digitalRead(pin));
|
updateDirectBuffer((uint8_t)_mod->hal->digitalRead(pin));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int16_t RF69::setDIOMapping(RADIOLIB_PIN_TYPE pin, uint8_t value) {
|
int16_t RF69::setDIOMapping(uint8_t pin, uint8_t value) {
|
||||||
if(pin > 5) {
|
if(pin > 5) {
|
||||||
return(RADIOLIB_ERR_INVALID_DIO_PIN);
|
return(RADIOLIB_ERR_INVALID_DIO_PIN);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1035,10 +1035,10 @@ class RF69: public PhysicalLayer {
|
||||||
int16_t setRSSIThreshold(float dbm);
|
int16_t setRSSIThreshold(float dbm);
|
||||||
|
|
||||||
/*! \copydoc Module::setRfSwitchPins */
|
/*! \copydoc Module::setRfSwitchPins */
|
||||||
void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn);
|
void setRfSwitchPins(uint8_t rxEn, uint8_t txEn);
|
||||||
|
|
||||||
/*! \copydoc Module::setRfSwitchTable */
|
/*! \copydoc Module::setRfSwitchTable */
|
||||||
void setRfSwitchTable(const RADIOLIB_PIN_TYPE (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]);
|
void setRfSwitchTable(const uint8_t (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Get one truly random byte from RSSI noise.
|
\brief Get one truly random byte from RSSI noise.
|
||||||
|
@ -1067,7 +1067,7 @@ class RF69: public PhysicalLayer {
|
||||||
|
|
||||||
\param pin Pin on which to read.
|
\param pin Pin on which to read.
|
||||||
*/
|
*/
|
||||||
void readBit(RADIOLIB_PIN_TYPE pin);
|
void readBit(uint8_t pin);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -1079,7 +1079,7 @@ class RF69: public PhysicalLayer {
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t setDIOMapping(RADIOLIB_PIN_TYPE pin, uint8_t value);
|
int16_t setDIOMapping(uint8_t pin, uint8_t value);
|
||||||
|
|
||||||
#if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL)
|
#if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL)
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -8,8 +8,8 @@ SX1231::SX1231(Module* mod) : RF69(mod) {
|
||||||
int16_t SX1231::begin(float freq, float br, float freqDev, float rxBw, int8_t power, uint8_t preambleLen) {
|
int16_t SX1231::begin(float freq, float br, float freqDev, float rxBw, int8_t power, uint8_t preambleLen) {
|
||||||
// set module properties
|
// set module properties
|
||||||
_mod->init();
|
_mod->init();
|
||||||
_mod->pinMode(_mod->getIrq(), INPUT);
|
_mod->hal->pinMode(_mod->getIrq(), _mod->hal->GpioModeInput);
|
||||||
_mod->pinMode(_mod->getRst(), OUTPUT);
|
_mod->hal->pinMode(_mod->getRst(), _mod->hal->GpioModeOutput);
|
||||||
|
|
||||||
// try to find the SX1231 chip
|
// try to find the SX1231 chip
|
||||||
uint8_t i = 0;
|
uint8_t i = 0;
|
||||||
|
@ -21,7 +21,7 @@ int16_t SX1231::begin(float freq, float br, float freqDev, float rxBw, int8_t po
|
||||||
_chipRevision = version;
|
_chipRevision = version;
|
||||||
} else {
|
} else {
|
||||||
RADIOLIB_DEBUG_PRINTLN("SX1231 not found! (%d of 10 tries) RF69_REG_VERSION == 0x%04X, expected 0x0021 / 0x0022 / 0x0023", i + 1, version);
|
RADIOLIB_DEBUG_PRINTLN("SX1231 not found! (%d of 10 tries) RF69_REG_VERSION == 0x%04X, expected 0x0021 / 0x0022 / 0x0023", i + 1, version);
|
||||||
_mod->delay(10);
|
_mod->hal->delay(10);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@ This file is licensed under the MIT License: https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
#if !defined(RADIOLIB_EXCLUDE_STM32WLX)
|
#if !defined(RADIOLIB_EXCLUDE_STM32WLX)
|
||||||
|
|
||||||
|
#include "../../ArduinoHal.h"
|
||||||
|
|
||||||
// This defines some dummy pin numbers (starting at NUM_DIGITAL_PINS to
|
// This defines some dummy pin numbers (starting at NUM_DIGITAL_PINS to
|
||||||
// guarantee these are not valid regular pin numbers) that can be passed
|
// guarantee these are not valid regular pin numbers) that can be passed
|
||||||
// to the parent Module class, to be stored here and then passed back to
|
// to the parent Module class, to be stored here and then passed back to
|
||||||
|
@ -20,23 +22,11 @@ enum {
|
||||||
RADIOLIB_STM32WLx_VIRTUAL_PIN_RESET,
|
RADIOLIB_STM32WLx_VIRTUAL_PIN_RESET,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Stm32wlxHal : public ArduinoHal {
|
||||||
|
public:
|
||||||
|
Stm32wlxHal(): ArduinoHal(SubGhz.SPI, SubGhz.spi_settings) {}
|
||||||
|
|
||||||
STM32WLx_Module::STM32WLx_Module():
|
void pinMode(uint8_t dwPin, uint8_t dwMode) {
|
||||||
Module(
|
|
||||||
RADIOLIB_STM32WLx_VIRTUAL_PIN_NSS,
|
|
||||||
RADIOLIB_STM32WLx_VIRTUAL_PIN_IRQ,
|
|
||||||
RADIOLIB_STM32WLx_VIRTUAL_PIN_RESET,
|
|
||||||
RADIOLIB_STM32WLx_VIRTUAL_PIN_BUSY,
|
|
||||||
SubGhz.SPI,
|
|
||||||
SubGhz.spi_settings
|
|
||||||
)
|
|
||||||
{
|
|
||||||
setCb_pinMode(virtualPinMode);
|
|
||||||
setCb_digitalWrite(virtualDigitalWrite);
|
|
||||||
setCb_digitalRead(virtualDigitalRead);
|
|
||||||
}
|
|
||||||
|
|
||||||
void STM32WLx_Module::virtualPinMode(uint32_t dwPin, uint32_t dwMode) {
|
|
||||||
switch(dwPin) {
|
switch(dwPin) {
|
||||||
case RADIOLIB_STM32WLx_VIRTUAL_PIN_NSS:
|
case RADIOLIB_STM32WLx_VIRTUAL_PIN_NSS:
|
||||||
case RADIOLIB_STM32WLx_VIRTUAL_PIN_BUSY:
|
case RADIOLIB_STM32WLx_VIRTUAL_PIN_BUSY:
|
||||||
|
@ -50,7 +40,7 @@ void STM32WLx_Module::virtualPinMode(uint32_t dwPin, uint32_t dwMode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void STM32WLx_Module::virtualDigitalWrite(uint32_t dwPin, uint32_t dwVal) {
|
void digitalWrite(uint8_t dwPin, uint8_t dwVal) {
|
||||||
switch (dwPin) {
|
switch (dwPin) {
|
||||||
case RADIOLIB_STM32WLx_VIRTUAL_PIN_NSS:
|
case RADIOLIB_STM32WLx_VIRTUAL_PIN_NSS:
|
||||||
SubGhz.setNssActive(dwVal == LOW);
|
SubGhz.setNssActive(dwVal == LOW);
|
||||||
|
@ -71,7 +61,7 @@ void STM32WLx_Module::virtualDigitalWrite(uint32_t dwPin, uint32_t dwVal) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int STM32WLx_Module::virtualDigitalRead(uint32_t ulPin) {
|
uint8_t digitalRead(uint8_t ulPin) {
|
||||||
switch (ulPin) {
|
switch (ulPin) {
|
||||||
case RADIOLIB_STM32WLx_VIRTUAL_PIN_BUSY:
|
case RADIOLIB_STM32WLx_VIRTUAL_PIN_BUSY:
|
||||||
return(SubGhz.isBusy() ? HIGH : LOW);
|
return(SubGhz.isBusy() ? HIGH : LOW);
|
||||||
|
@ -102,5 +92,15 @@ int STM32WLx_Module::virtualDigitalRead(uint32_t ulPin) {
|
||||||
return(::digitalRead(ulPin));
|
return(::digitalRead(ulPin));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
STM32WLx_Module::STM32WLx_Module():
|
||||||
|
Module(
|
||||||
|
new Stm32wlxHal,
|
||||||
|
RADIOLIB_STM32WLx_VIRTUAL_PIN_NSS,
|
||||||
|
RADIOLIB_STM32WLx_VIRTUAL_PIN_IRQ,
|
||||||
|
RADIOLIB_STM32WLx_VIRTUAL_PIN_RESET,
|
||||||
|
RADIOLIB_STM32WLx_VIRTUAL_PIN_BUSY
|
||||||
|
) {}
|
||||||
|
|
||||||
#endif // !defined(RADIOLIB_EXCLUDE_STM32WLX)
|
#endif // !defined(RADIOLIB_EXCLUDE_STM32WLX)
|
||||||
|
|
|
@ -31,17 +31,6 @@ class STM32WLx_Module : public Module {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
STM32WLx_Module();
|
STM32WLx_Module();
|
||||||
|
|
||||||
#if !defined(RADIOLIB_GODMODE)
|
|
||||||
private:
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Replacement callbacks to handle virtual pins. These are static,
|
|
||||||
// since they replace global functions that cannot take any this
|
|
||||||
// pointer for context.
|
|
||||||
static void virtualPinMode(uint32_t dwPin, uint32_t dwMode);
|
|
||||||
static void virtualDigitalWrite(uint32_t dwPin, uint32_t dwVal);
|
|
||||||
static int virtualDigitalRead(uint32_t ulPin);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !defined(RADIOLIB_EXCLUDE_STM32WLX)
|
#endif // !defined(RADIOLIB_EXCLUDE_STM32WLX)
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "SX126x.h"
|
#include "SX126x.h"
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
#if !defined(RADIOLIB_EXCLUDE_SX126X)
|
#if !defined(RADIOLIB_EXCLUDE_SX126X)
|
||||||
|
|
||||||
SX126x::SX126x(Module* mod) : PhysicalLayer(RADIOLIB_SX126X_FREQUENCY_STEP_SIZE, RADIOLIB_SX126X_MAX_PACKET_LENGTH) {
|
SX126x::SX126x(Module* mod) : PhysicalLayer(RADIOLIB_SX126X_FREQUENCY_STEP_SIZE, RADIOLIB_SX126X_MAX_PACKET_LENGTH) {
|
||||||
|
@ -13,8 +15,8 @@ Module* SX126x::getMod() {
|
||||||
int16_t SX126x::begin(uint8_t cr, uint8_t syncWord, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO) {
|
int16_t SX126x::begin(uint8_t cr, uint8_t syncWord, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO) {
|
||||||
// set module properties
|
// set module properties
|
||||||
_mod->init();
|
_mod->init();
|
||||||
_mod->pinMode(_mod->getIrq(), INPUT);
|
_mod->hal->pinMode(_mod->getIrq(), _mod->hal->GpioModeInput);
|
||||||
_mod->pinMode(_mod->getGpio(), INPUT);
|
_mod->hal->pinMode(_mod->getGpio(), _mod->hal->GpioModeInput);
|
||||||
_mod->SPIreadCommand = RADIOLIB_SX126X_CMD_READ_REGISTER;
|
_mod->SPIreadCommand = RADIOLIB_SX126X_CMD_READ_REGISTER;
|
||||||
_mod->SPIwriteCommand = RADIOLIB_SX126X_CMD_WRITE_REGISTER;
|
_mod->SPIwriteCommand = RADIOLIB_SX126X_CMD_WRITE_REGISTER;
|
||||||
_mod->SPInopCommand = RADIOLIB_SX126X_CMD_NOP;
|
_mod->SPInopCommand = RADIOLIB_SX126X_CMD_NOP;
|
||||||
|
@ -95,8 +97,8 @@ int16_t SX126x::begin(uint8_t cr, uint8_t syncWord, uint16_t preambleLength, flo
|
||||||
int16_t SX126x::beginFSK(float br, float freqDev, float rxBw, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO) {
|
int16_t SX126x::beginFSK(float br, float freqDev, float rxBw, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO) {
|
||||||
// set module properties
|
// set module properties
|
||||||
_mod->init();
|
_mod->init();
|
||||||
_mod->pinMode(_mod->getIrq(), INPUT);
|
_mod->hal->pinMode(_mod->getIrq(), _mod->hal->GpioModeInput);
|
||||||
_mod->pinMode(_mod->getGpio(), INPUT);
|
_mod->hal->pinMode(_mod->getGpio(), _mod->hal->GpioModeInput);
|
||||||
_mod->SPIreadCommand = RADIOLIB_SX126X_CMD_READ_REGISTER;
|
_mod->SPIreadCommand = RADIOLIB_SX126X_CMD_READ_REGISTER;
|
||||||
_mod->SPIwriteCommand = RADIOLIB_SX126X_CMD_WRITE_REGISTER;
|
_mod->SPIwriteCommand = RADIOLIB_SX126X_CMD_WRITE_REGISTER;
|
||||||
_mod->SPInopCommand = RADIOLIB_SX126X_CMD_NOP;
|
_mod->SPInopCommand = RADIOLIB_SX126X_CMD_NOP;
|
||||||
|
@ -188,10 +190,10 @@ int16_t SX126x::beginFSK(float br, float freqDev, float rxBw, uint16_t preambleL
|
||||||
|
|
||||||
int16_t SX126x::reset(bool verify) {
|
int16_t SX126x::reset(bool verify) {
|
||||||
// run the reset sequence
|
// run the reset sequence
|
||||||
_mod->pinMode(_mod->getRst(), OUTPUT);
|
_mod->hal->pinMode(_mod->getRst(), _mod->hal->GpioModeOutput);
|
||||||
_mod->digitalWrite(_mod->getRst(), LOW);
|
_mod->hal->digitalWrite(_mod->getRst(), _mod->hal->GpioLevelLow);
|
||||||
_mod->delay(1);
|
_mod->hal->delay(1);
|
||||||
_mod->digitalWrite(_mod->getRst(), HIGH);
|
_mod->hal->digitalWrite(_mod->getRst(), _mod->hal->GpioLevelHigh);
|
||||||
|
|
||||||
// return immediately when verification is disabled
|
// return immediately when verification is disabled
|
||||||
if(!verify) {
|
if(!verify) {
|
||||||
|
@ -199,7 +201,7 @@ int16_t SX126x::reset(bool verify) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// set mode to standby - SX126x often refuses first few commands after reset
|
// set mode to standby - SX126x often refuses first few commands after reset
|
||||||
uint32_t start = _mod->millis();
|
uint32_t start = _mod->hal->millis();
|
||||||
while(true) {
|
while(true) {
|
||||||
// try to set mode to standby
|
// try to set mode to standby
|
||||||
int16_t state = standby();
|
int16_t state = standby();
|
||||||
|
@ -209,13 +211,13 @@ int16_t SX126x::reset(bool verify) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// standby command failed, check timeout and try again
|
// standby command failed, check timeout and try again
|
||||||
if(_mod->millis() - start >= 1000) {
|
if(_mod->hal->millis() - start >= 1000) {
|
||||||
// timed out, possibly incorrect wiring
|
// timed out, possibly incorrect wiring
|
||||||
return(state);
|
return(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait a bit to not spam the module
|
// wait a bit to not spam the module
|
||||||
_mod->delay(100);
|
_mod->hal->delay(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,15 +254,15 @@ int16_t SX126x::transmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// wait for packet transmission or timeout
|
// wait for packet transmission or timeout
|
||||||
uint32_t start = _mod->micros();
|
uint32_t start = _mod->hal->micros();
|
||||||
while(!_mod->digitalRead(_mod->getIrq())) {
|
while(!_mod->hal->digitalRead(_mod->getIrq())) {
|
||||||
_mod->yield();
|
_mod->hal->yield();
|
||||||
if(_mod->micros() - start > timeout) {
|
if(_mod->hal->micros() - start > timeout) {
|
||||||
finishTransmit();
|
finishTransmit();
|
||||||
return(RADIOLIB_ERR_TX_TIMEOUT);
|
return(RADIOLIB_ERR_TX_TIMEOUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uint32_t elapsed = _mod->micros() - start;
|
uint32_t elapsed = _mod->hal->micros() - start;
|
||||||
|
|
||||||
// update data rate
|
// update data rate
|
||||||
_dataRate = (len*8.0)/((float)elapsed/1000000.0);
|
_dataRate = (len*8.0)/((float)elapsed/1000000.0);
|
||||||
|
@ -302,10 +304,10 @@ int16_t SX126x::receive(uint8_t* data, size_t len) {
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// wait for packet reception or timeout
|
// wait for packet reception or timeout
|
||||||
uint32_t start = _mod->micros();
|
uint32_t start = _mod->hal->micros();
|
||||||
while(!_mod->digitalRead(_mod->getIrq())) {
|
while(!_mod->hal->digitalRead(_mod->getIrq())) {
|
||||||
_mod->yield();
|
_mod->hal->yield();
|
||||||
if(_mod->micros() - start > timeout) {
|
if(_mod->hal->micros() - start > timeout) {
|
||||||
fixImplicitTimeout();
|
fixImplicitTimeout();
|
||||||
clearIrqStatus();
|
clearIrqStatus();
|
||||||
standby();
|
standby();
|
||||||
|
@ -419,8 +421,8 @@ int16_t SX126x::scanChannel(uint8_t symbolNum, uint8_t detPeak, uint8_t detMin)
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// wait for channel activity detected or timeout
|
// wait for channel activity detected or timeout
|
||||||
while(!_mod->digitalRead(_mod->getIrq())) {
|
while(!_mod->hal->digitalRead(_mod->getIrq())) {
|
||||||
_mod->yield();
|
_mod->hal->yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
// check CAD result
|
// check CAD result
|
||||||
|
@ -438,7 +440,7 @@ int16_t SX126x::sleep(bool retainConfig) {
|
||||||
int16_t state = _mod->SPIwriteStream(RADIOLIB_SX126X_CMD_SET_SLEEP, &sleepMode, 1, false, false);
|
int16_t state = _mod->SPIwriteStream(RADIOLIB_SX126X_CMD_SET_SLEEP, &sleepMode, 1, false, false);
|
||||||
|
|
||||||
// wait for SX126x to safely enter sleep mode
|
// wait for SX126x to safely enter sleep mode
|
||||||
_mod->delay(1);
|
_mod->hal->delay(1);
|
||||||
|
|
||||||
return(state);
|
return(state);
|
||||||
}
|
}
|
||||||
|
@ -456,11 +458,11 @@ int16_t SX126x::standby(uint8_t mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SX126x::setDio1Action(void (*func)(void)) {
|
void SX126x::setDio1Action(void (*func)(void)) {
|
||||||
_mod->attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, RISING);
|
_mod->hal->attachInterrupt(_mod->hal->pinToInterrupt(_mod->getIrq()), func, _mod->hal->GpioInterruptRising);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SX126x::clearDio1Action() {
|
void SX126x::clearDio1Action() {
|
||||||
_mod->detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()));
|
_mod->hal->detachInterrupt(_mod->hal->pinToInterrupt(_mod->getIrq()));
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t SX126x::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
int16_t SX126x::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
|
@ -517,8 +519,8 @@ int16_t SX126x::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// wait for BUSY to go low (= PA ramp up done)
|
// wait for BUSY to go low (= PA ramp up done)
|
||||||
while(_mod->digitalRead(_mod->getGpio())) {
|
while(_mod->hal->digitalRead(_mod->getGpio())) {
|
||||||
_mod->yield();
|
_mod->hal->yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
return(state);
|
return(state);
|
||||||
|
@ -1357,11 +1359,11 @@ int16_t SX126x::setEncoding(uint8_t encoding) {
|
||||||
return(setWhitening(encoding));
|
return(setWhitening(encoding));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SX126x::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) {
|
void SX126x::setRfSwitchPins(uint8_t rxEn, uint8_t txEn) {
|
||||||
_mod->setRfSwitchPins(rxEn, txEn);
|
_mod->setRfSwitchPins(rxEn, txEn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SX126x::setRfSwitchTable(const RADIOLIB_PIN_TYPE (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]) {
|
void SX126x::setRfSwitchTable(const uint8_t (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]) {
|
||||||
_mod->setRfSwitchTable(pins, table);
|
_mod->setRfSwitchTable(pins, table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1395,7 +1397,7 @@ uint8_t SX126x::randomByte() {
|
||||||
setRx(RADIOLIB_SX126X_RX_TIMEOUT_INF);
|
setRx(RADIOLIB_SX126X_RX_TIMEOUT_INF);
|
||||||
|
|
||||||
// wait a bit for the RSSI reading to stabilise
|
// wait a bit for the RSSI reading to stabilise
|
||||||
_mod->delay(10);
|
_mod->hal->delay(10);
|
||||||
|
|
||||||
// read RSSI value 8 times, always keep just the least significant bit
|
// read RSSI value 8 times, always keep just the least significant bit
|
||||||
uint8_t randByte = 0x00;
|
uint8_t randByte = 0x00;
|
||||||
|
@ -1433,8 +1435,8 @@ void SX126x::setDirectAction(void (*func)(void)) {
|
||||||
setDio1Action(func);
|
setDio1Action(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SX126x::readBit(RADIOLIB_PIN_TYPE pin) {
|
void SX126x::readBit(uint8_t pin) {
|
||||||
updateDirectBuffer((uint8_t)_mod->digitalRead(pin));
|
updateDirectBuffer((uint8_t)_mod->hal->digitalRead(pin));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1953,9 +1955,9 @@ int16_t SX126x::config(uint8_t modem) {
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// wait for calibration completion
|
// wait for calibration completion
|
||||||
_mod->delay(5);
|
_mod->hal->delay(5);
|
||||||
while(_mod->digitalRead(_mod->getGpio())) {
|
while(_mod->hal->digitalRead(_mod->getGpio())) {
|
||||||
_mod->yield();
|
_mod->hal->yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
// check calibration result
|
// check calibration result
|
||||||
|
@ -2010,7 +2012,7 @@ bool SX126x::findChip(const char* verStr) {
|
||||||
_mod->hexdump((uint8_t*)version, 16, RADIOLIB_SX126X_REG_VERSION_STRING);
|
_mod->hexdump((uint8_t*)version, 16, RADIOLIB_SX126X_REG_VERSION_STRING);
|
||||||
RADIOLIB_DEBUG_PRINTLN("Expected string: %s", verStr);
|
RADIOLIB_DEBUG_PRINTLN("Expected string: %s", verStr);
|
||||||
#endif
|
#endif
|
||||||
_mod->delay(10);
|
_mod->hal->delay(10);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1031,10 +1031,10 @@ class SX126x: public PhysicalLayer {
|
||||||
int16_t setEncoding(uint8_t encoding) override;
|
int16_t setEncoding(uint8_t encoding) override;
|
||||||
|
|
||||||
/*! \copydoc Module::setRfSwitchPins */
|
/*! \copydoc Module::setRfSwitchPins */
|
||||||
void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn);
|
void setRfSwitchPins(uint8_t rxEn, uint8_t txEn);
|
||||||
|
|
||||||
/*! \copydoc Module::setRfSwitchTable */
|
/*! \copydoc Module::setRfSwitchTable */
|
||||||
void setRfSwitchTable(const RADIOLIB_PIN_TYPE (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]);
|
void setRfSwitchTable(const uint8_t (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Forces LoRa low data rate optimization. Only available in LoRa mode. After calling this method, LDRO will always be set to
|
\brief Forces LoRa low data rate optimization. Only available in LoRa mode. After calling this method, LDRO will always be set to
|
||||||
|
@ -1083,7 +1083,7 @@ class SX126x: public PhysicalLayer {
|
||||||
|
|
||||||
\param pin Pin on which to read.
|
\param pin Pin on which to read.
|
||||||
*/
|
*/
|
||||||
void readBit(RADIOLIB_PIN_TYPE pin);
|
void readBit(uint8_t pin);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "SX1272.h"
|
#include "SX1272.h"
|
||||||
|
#include <math.h>
|
||||||
#if !defined(RADIOLIB_EXCLUDE_SX127X)
|
#if !defined(RADIOLIB_EXCLUDE_SX127X)
|
||||||
|
|
||||||
SX1272::SX1272(Module* mod) : SX127x(mod) {
|
SX1272::SX1272(Module* mod) : SX127x(mod) {
|
||||||
|
@ -71,11 +72,11 @@ int16_t SX1272::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t
|
||||||
}
|
}
|
||||||
|
|
||||||
void SX1272::reset() {
|
void SX1272::reset() {
|
||||||
_mod->pinMode(_mod->getRst(), OUTPUT);
|
_mod->hal->pinMode(_mod->getRst(), _mod->hal->GpioModeOutput);
|
||||||
_mod->digitalWrite(_mod->getRst(), HIGH);
|
_mod->hal->digitalWrite(_mod->getRst(), _mod->hal->GpioLevelHigh);
|
||||||
_mod->delay(1);
|
_mod->hal->delay(1);
|
||||||
_mod->digitalWrite(_mod->getRst(), LOW);
|
_mod->hal->digitalWrite(_mod->getRst(), _mod->hal->GpioLevelLow);
|
||||||
_mod->delay(5);
|
_mod->hal->delay(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t SX1272::setFrequency(float freq) {
|
int16_t SX1272::setFrequency(float freq) {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "SX1278.h"
|
#include "SX1278.h"
|
||||||
|
#include <math.h>
|
||||||
#if !defined(RADIOLIB_EXCLUDE_SX127X)
|
#if !defined(RADIOLIB_EXCLUDE_SX127X)
|
||||||
|
|
||||||
SX1278::SX1278(Module* mod) : SX127x(mod) {
|
SX1278::SX1278(Module* mod) : SX127x(mod) {
|
||||||
|
@ -71,11 +72,11 @@ int16_t SX1278::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t
|
||||||
}
|
}
|
||||||
|
|
||||||
void SX1278::reset() {
|
void SX1278::reset() {
|
||||||
_mod->pinMode(_mod->getRst(), OUTPUT);
|
_mod->hal->pinMode(_mod->getRst(), _mod->hal->GpioModeOutput);
|
||||||
_mod->digitalWrite(_mod->getRst(), LOW);
|
_mod->hal->digitalWrite(_mod->getRst(), _mod->hal->GpioLevelLow);
|
||||||
_mod->delay(1);
|
_mod->hal->delay(1);
|
||||||
_mod->digitalWrite(_mod->getRst(), HIGH);
|
_mod->hal->digitalWrite(_mod->getRst(), _mod->hal->GpioLevelHigh);
|
||||||
_mod->delay(5);
|
_mod->hal->delay(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t SX1278::setFrequency(float freq) {
|
int16_t SX1278::setFrequency(float freq) {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "SX127x.h"
|
#include "SX127x.h"
|
||||||
|
#include <math.h>
|
||||||
#if !defined(RADIOLIB_EXCLUDE_SX127X)
|
#if !defined(RADIOLIB_EXCLUDE_SX127X)
|
||||||
|
|
||||||
SX127x::SX127x(Module* mod) : PhysicalLayer(RADIOLIB_SX127X_FREQUENCY_STEP_SIZE, RADIOLIB_SX127X_MAX_PACKET_LENGTH) {
|
SX127x::SX127x(Module* mod) : PhysicalLayer(RADIOLIB_SX127X_FREQUENCY_STEP_SIZE, RADIOLIB_SX127X_MAX_PACKET_LENGTH) {
|
||||||
|
@ -12,8 +13,8 @@ Module* SX127x::getMod() {
|
||||||
int16_t SX127x::begin(uint8_t chipVersion, uint8_t syncWord, uint16_t preambleLength) {
|
int16_t SX127x::begin(uint8_t chipVersion, uint8_t syncWord, uint16_t preambleLength) {
|
||||||
// set module properties
|
// set module properties
|
||||||
_mod->init();
|
_mod->init();
|
||||||
_mod->pinMode(_mod->getIrq(), INPUT);
|
_mod->hal->pinMode(_mod->getIrq(), _mod->hal->GpioModeInput);
|
||||||
_mod->pinMode(_mod->getGpio(), INPUT);
|
_mod->hal->pinMode(_mod->getGpio(), _mod->hal->GpioModeInput);
|
||||||
|
|
||||||
// try to find the SX127x chip
|
// try to find the SX127x chip
|
||||||
if(!SX127x::findChip(chipVersion)) {
|
if(!SX127x::findChip(chipVersion)) {
|
||||||
|
@ -59,8 +60,8 @@ int16_t SX127x::begin(uint8_t chipVersion, uint8_t syncWord, uint16_t preambleLe
|
||||||
int16_t SX127x::beginFSK(uint8_t chipVersion, float freqDev, float rxBw, uint16_t preambleLength, bool enableOOK) {
|
int16_t SX127x::beginFSK(uint8_t chipVersion, float freqDev, float rxBw, uint16_t preambleLength, bool enableOOK) {
|
||||||
// set module properties
|
// set module properties
|
||||||
_mod->init();
|
_mod->init();
|
||||||
_mod->pinMode(_mod->getIrq(), INPUT);
|
_mod->hal->pinMode(_mod->getIrq(), _mod->hal->GpioModeInput);
|
||||||
_mod->pinMode(_mod->getGpio(), INPUT);
|
_mod->hal->pinMode(_mod->getGpio(), _mod->hal->GpioModeInput);
|
||||||
|
|
||||||
// try to find the SX127x chip
|
// try to find the SX127x chip
|
||||||
if(!SX127x::findChip(chipVersion)) {
|
if(!SX127x::findChip(chipVersion)) {
|
||||||
|
@ -152,10 +153,10 @@ int16_t SX127x::transmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// wait for packet transmission or timeout
|
// wait for packet transmission or timeout
|
||||||
start = _mod->micros();
|
start = _mod->hal->micros();
|
||||||
while(!_mod->digitalRead(_mod->getIrq())) {
|
while(!_mod->hal->digitalRead(_mod->getIrq())) {
|
||||||
_mod->yield();
|
_mod->hal->yield();
|
||||||
if(_mod->micros() - start > timeout) {
|
if(_mod->hal->micros() - start > timeout) {
|
||||||
finishTransmit();
|
finishTransmit();
|
||||||
return(RADIOLIB_ERR_TX_TIMEOUT);
|
return(RADIOLIB_ERR_TX_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
@ -170,10 +171,10 @@ int16_t SX127x::transmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// wait for transmission end or timeout
|
// wait for transmission end or timeout
|
||||||
start = _mod->micros();
|
start = _mod->hal->micros();
|
||||||
while(!_mod->digitalRead(_mod->getIrq())) {
|
while(!_mod->hal->digitalRead(_mod->getIrq())) {
|
||||||
_mod->yield();
|
_mod->hal->yield();
|
||||||
if(_mod->micros() - start > timeout) {
|
if(_mod->hal->micros() - start > timeout) {
|
||||||
finishTransmit();
|
finishTransmit();
|
||||||
return(RADIOLIB_ERR_TX_TIMEOUT);
|
return(RADIOLIB_ERR_TX_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
@ -183,7 +184,7 @@ int16_t SX127x::transmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// update data rate
|
// update data rate
|
||||||
uint32_t elapsed = _mod->micros() - start;
|
uint32_t elapsed = _mod->hal->micros() - start;
|
||||||
_dataRate = (len*8.0)/((float)elapsed/1000000.0);
|
_dataRate = (len*8.0)/((float)elapsed/1000000.0);
|
||||||
|
|
||||||
return(finishTransmit());
|
return(finishTransmit());
|
||||||
|
@ -208,19 +209,19 @@ int16_t SX127x::receive(uint8_t* data, size_t len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait for packet reception or timeout
|
// wait for packet reception or timeout
|
||||||
uint32_t start = _mod->micros();
|
uint32_t start = _mod->hal->micros();
|
||||||
while(!_mod->digitalRead(_mod->getIrq())) {
|
while(!_mod->hal->digitalRead(_mod->getIrq())) {
|
||||||
_mod->yield();
|
_mod->hal->yield();
|
||||||
|
|
||||||
if(_mod->getGpio() == RADIOLIB_NC) {
|
if(_mod->getGpio() == RADIOLIB_NC) {
|
||||||
// no GPIO pin provided, use software timeout
|
// no GPIO pin provided, use software timeout
|
||||||
if(_mod->micros() - start > timeout) {
|
if(_mod->hal->micros() - start > timeout) {
|
||||||
clearIRQFlags();
|
clearIRQFlags();
|
||||||
return(RADIOLIB_ERR_RX_TIMEOUT);
|
return(RADIOLIB_ERR_RX_TIMEOUT);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// GPIO provided, use that
|
// GPIO provided, use that
|
||||||
if(_mod->digitalRead(_mod->getGpio())) {
|
if(_mod->hal->digitalRead(_mod->getGpio())) {
|
||||||
clearIRQFlags();
|
clearIRQFlags();
|
||||||
return(RADIOLIB_ERR_RX_TIMEOUT);
|
return(RADIOLIB_ERR_RX_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
@ -237,10 +238,10 @@ int16_t SX127x::receive(uint8_t* data, size_t len) {
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// wait for packet reception or timeout
|
// wait for packet reception or timeout
|
||||||
uint32_t start = _mod->micros();
|
uint32_t start = _mod->hal->micros();
|
||||||
while(!_mod->digitalRead(_mod->getIrq())) {
|
while(!_mod->hal->digitalRead(_mod->getIrq())) {
|
||||||
_mod->yield();
|
_mod->hal->yield();
|
||||||
if(_mod->micros() - start > timeout) {
|
if(_mod->hal->micros() - start > timeout) {
|
||||||
clearIRQFlags();
|
clearIRQFlags();
|
||||||
return(RADIOLIB_ERR_RX_TIMEOUT);
|
return(RADIOLIB_ERR_RX_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
@ -259,9 +260,9 @@ int16_t SX127x::scanChannel() {
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// wait for channel activity detected or timeout
|
// wait for channel activity detected or timeout
|
||||||
while(!_mod->digitalRead(_mod->getIrq())) {
|
while(!_mod->hal->digitalRead(_mod->getIrq())) {
|
||||||
_mod->yield();
|
_mod->hal->yield();
|
||||||
if(_mod->digitalRead(_mod->getGpio())) {
|
if(_mod->hal->digitalRead(_mod->getGpio())) {
|
||||||
return(RADIOLIB_PREAMBLE_DETECTED);
|
return(RADIOLIB_PREAMBLE_DETECTED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -425,31 +426,31 @@ int16_t SX127x::startReceive(uint32_t mode, uint16_t irqFlags, uint16_t irqMask,
|
||||||
return(startReceive((uint8_t)len, (uint8_t)mode));
|
return(startReceive((uint8_t)len, (uint8_t)mode));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SX127x::setDio0Action(void (*func)(void), RADIOLIB_INTERRUPT_STATUS dir) {
|
void SX127x::setDio0Action(void (*func)(void), uint8_t dir) {
|
||||||
_mod->attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, dir);
|
_mod->hal->attachInterrupt(_mod->hal->pinToInterrupt(_mod->getIrq()), func, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SX127x::clearDio0Action() {
|
void SX127x::clearDio0Action() {
|
||||||
_mod->detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()));
|
_mod->hal->detachInterrupt(_mod->hal->pinToInterrupt(_mod->getIrq()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SX127x::setDio1Action(void (*func)(void), RADIOLIB_INTERRUPT_STATUS dir) {
|
void SX127x::setDio1Action(void (*func)(void), uint8_t dir) {
|
||||||
if(_mod->getGpio() == RADIOLIB_NC) {
|
if(_mod->getGpio() == RADIOLIB_NC) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_mod->attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio()), func, dir);
|
_mod->hal->attachInterrupt(_mod->hal->pinToInterrupt(_mod->getGpio()), func, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SX127x::clearDio1Action() {
|
void SX127x::clearDio1Action() {
|
||||||
if(_mod->getGpio() == RADIOLIB_NC) {
|
if(_mod->getGpio() == RADIOLIB_NC) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_mod->detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getGpio()));
|
_mod->hal->detachInterrupt(_mod->hal->pinToInterrupt(_mod->getGpio()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SX127x::setFifoEmptyAction(void (*func)(void)) {
|
void SX127x::setFifoEmptyAction(void (*func)(void)) {
|
||||||
// set DIO1 to the FIFO empty event (the register setting is done in startTransmit)
|
// set DIO1 to the FIFO empty event (the register setting is done in startTransmit)
|
||||||
setDio1Action(func);
|
setDio1Action(func, _mod->hal->GpioInterruptRising);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SX127x::clearFifoEmptyAction() {
|
void SX127x::clearFifoEmptyAction() {
|
||||||
|
@ -462,7 +463,7 @@ void SX127x::setFifoFullAction(void (*func)(void)) {
|
||||||
_mod->SPIsetRegValue(RADIOLIB_SX127X_REG_DIO_MAPPING_1, RADIOLIB_SX127X_DIO1_PACK_FIFO_LEVEL, 5, 4);
|
_mod->SPIsetRegValue(RADIOLIB_SX127X_REG_DIO_MAPPING_1, RADIOLIB_SX127X_DIO1_PACK_FIFO_LEVEL, 5, 4);
|
||||||
|
|
||||||
// set DIO1 to the FIFO full event
|
// set DIO1 to the FIFO full event
|
||||||
setDio1Action(func);
|
setDio1Action(func, _mod->hal->GpioInterruptRising);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SX127x::clearFifoFullAction() {
|
void SX127x::clearFifoFullAction() {
|
||||||
|
@ -1266,11 +1267,11 @@ uint8_t SX127x::getModemStatus() {
|
||||||
return(_mod->SPIreadRegister(RADIOLIB_SX127X_REG_MODEM_STAT));
|
return(_mod->SPIreadRegister(RADIOLIB_SX127X_REG_MODEM_STAT));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SX127x::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) {
|
void SX127x::setRfSwitchPins(uint8_t rxEn, uint8_t txEn) {
|
||||||
_mod->setRfSwitchPins(rxEn, txEn);
|
_mod->setRfSwitchPins(rxEn, txEn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SX127x::setRfSwitchTable(const RADIOLIB_PIN_TYPE (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]) {
|
void SX127x::setRfSwitchTable(const uint8_t (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]) {
|
||||||
_mod->setRfSwitchTable(pins, table);
|
_mod->setRfSwitchTable(pins, table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1285,7 +1286,7 @@ uint8_t SX127x::randomByte() {
|
||||||
setMode(RADIOLIB_SX127X_RX);
|
setMode(RADIOLIB_SX127X_RX);
|
||||||
|
|
||||||
// wait a bit for the RSSI reading to stabilise
|
// wait a bit for the RSSI reading to stabilise
|
||||||
_mod->delay(10);
|
_mod->hal->delay(10);
|
||||||
|
|
||||||
// read RSSI value 8 times, always keep just the least significant bit
|
// read RSSI value 8 times, always keep just the least significant bit
|
||||||
uint8_t randByte = 0x00;
|
uint8_t randByte = 0x00;
|
||||||
|
@ -1326,7 +1327,7 @@ int8_t SX127x::getTempRaw() {
|
||||||
_mod->SPIsetRegValue(RADIOLIB_SX127X_REG_IMAGE_CAL, RADIOLIB_SX127X_TEMP_MONITOR_ON, 0, 0);
|
_mod->SPIsetRegValue(RADIOLIB_SX127X_REG_IMAGE_CAL, RADIOLIB_SX127X_TEMP_MONITOR_ON, 0, 0);
|
||||||
|
|
||||||
// wait
|
// wait
|
||||||
_mod->delayMicroseconds(200);
|
_mod->hal->delayMicroseconds(200);
|
||||||
|
|
||||||
// disable temperature reading
|
// disable temperature reading
|
||||||
_mod->SPIsetRegValue(RADIOLIB_SX127X_REG_IMAGE_CAL, RADIOLIB_SX127X_TEMP_MONITOR_OFF, 0, 0);
|
_mod->SPIsetRegValue(RADIOLIB_SX127X_REG_IMAGE_CAL, RADIOLIB_SX127X_TEMP_MONITOR_OFF, 0, 0);
|
||||||
|
@ -1432,7 +1433,7 @@ bool SX127x::findChip(uint8_t ver) {
|
||||||
flagFound = true;
|
flagFound = true;
|
||||||
} else {
|
} else {
|
||||||
RADIOLIB_DEBUG_PRINTLN("SX127x not found! (%d of 10 tries) RADIOLIB_SX127X_REG_VERSION == 0x%04X, expected 0x00%X", i + 1, version, ver);
|
RADIOLIB_DEBUG_PRINTLN("SX127x not found! (%d of 10 tries) RADIOLIB_SX127X_REG_VERSION == 0x%04X, expected 0x00%X", i + 1, version, ver);
|
||||||
_mod->delay(10);
|
_mod->hal->delay(10);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1504,11 +1505,11 @@ int16_t SX127x::invertIQ(bool invertIQ) {
|
||||||
|
|
||||||
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
|
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
|
||||||
void SX127x::setDirectAction(void (*func)(void)) {
|
void SX127x::setDirectAction(void (*func)(void)) {
|
||||||
setDio1Action(func);
|
setDio1Action(func, _mod->hal->GpioInterruptRising);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SX127x::readBit(RADIOLIB_PIN_TYPE pin) {
|
void SX127x::readBit(uint8_t pin) {
|
||||||
updateDirectBuffer((uint8_t)_mod->digitalRead(pin));
|
updateDirectBuffer((uint8_t)_mod->hal->digitalRead(pin));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1533,7 +1534,7 @@ void SX127x::clearFHSSInt(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t SX127x::setDIOMapping(RADIOLIB_PIN_TYPE pin, uint8_t value) {
|
int16_t SX127x::setDIOMapping(uint8_t pin, uint8_t value) {
|
||||||
if (pin > 5)
|
if (pin > 5)
|
||||||
return RADIOLIB_ERR_INVALID_DIO_PIN;
|
return RADIOLIB_ERR_INVALID_DIO_PIN;
|
||||||
|
|
||||||
|
|
|
@ -725,9 +725,9 @@ class SX127x: public PhysicalLayer {
|
||||||
|
|
||||||
\param func Pointer to interrupt service routine.
|
\param func Pointer to interrupt service routine.
|
||||||
|
|
||||||
\param dir Signal change direction. Defaults to RISING.
|
\param dir Signal change direction.
|
||||||
*/
|
*/
|
||||||
void setDio0Action(void (*func)(void), RADIOLIB_INTERRUPT_STATUS dir = RISING);
|
void setDio0Action(void (*func)(void), uint8_t dir);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Clears interrupt service routine to call when DIO0 activates.
|
\brief Clears interrupt service routine to call when DIO0 activates.
|
||||||
|
@ -739,9 +739,9 @@ class SX127x: public PhysicalLayer {
|
||||||
|
|
||||||
\param func Pointer to interrupt service routine.
|
\param func Pointer to interrupt service routine.
|
||||||
|
|
||||||
\param dir Signal change direction. Defaults to RISING.
|
\param dir Signal change direction.
|
||||||
*/
|
*/
|
||||||
void setDio1Action(void (*func)(void), RADIOLIB_INTERRUPT_STATUS dir = RISING);
|
void setDio1Action(void (*func)(void), uint8_t dir);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Clears interrupt service routine to call when DIO1 activates.
|
\brief Clears interrupt service routine to call when DIO1 activates.
|
||||||
|
@ -1155,10 +1155,10 @@ class SX127x: public PhysicalLayer {
|
||||||
int8_t getTempRaw();
|
int8_t getTempRaw();
|
||||||
|
|
||||||
/*! \copydoc Module::setRfSwitchPins */
|
/*! \copydoc Module::setRfSwitchPins */
|
||||||
void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn);
|
void setRfSwitchPins(uint8_t rxEn, uint8_t txEn);
|
||||||
|
|
||||||
/*! \copydoc Module::setRfSwitchTable */
|
/*! \copydoc Module::setRfSwitchTable */
|
||||||
void setRfSwitchTable(const RADIOLIB_PIN_TYPE (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]);
|
void setRfSwitchTable(const uint8_t (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Get one truly random byte from RSSI noise.
|
\brief Get one truly random byte from RSSI noise.
|
||||||
|
@ -1196,7 +1196,7 @@ class SX127x: public PhysicalLayer {
|
||||||
|
|
||||||
\param pin Pin on which to read.
|
\param pin Pin on which to read.
|
||||||
*/
|
*/
|
||||||
void readBit(RADIOLIB_PIN_TYPE pin);
|
void readBit(uint8_t pin);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -1236,7 +1236,7 @@ class SX127x: public PhysicalLayer {
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t setDIOMapping(RADIOLIB_PIN_TYPE pin, uint8_t value);
|
int16_t setDIOMapping(uint8_t pin, uint8_t value);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Configure DIO mapping to use RSSI or Preamble Detect for pins that support it.
|
\brief Configure DIO mapping to use RSSI or Preamble Detect for pins that support it.
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "SX1280.h"
|
#include "SX1280.h"
|
||||||
|
#include <string.h>
|
||||||
#if !defined(RADIOLIB_EXCLUDE_SX128X)
|
#if !defined(RADIOLIB_EXCLUDE_SX128X)
|
||||||
|
|
||||||
SX1280::SX1280(Module* mod) : SX1281(mod) {
|
SX1280::SX1280(Module* mod) : SX1281(mod) {
|
||||||
|
@ -11,10 +12,10 @@ int16_t SX1280::range(bool master, uint32_t addr, uint16_t calTable[3][6]) {
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// wait until ranging is finished
|
// wait until ranging is finished
|
||||||
uint32_t start = _mod->millis();
|
uint32_t start = _mod->hal->millis();
|
||||||
while(!_mod->digitalRead(_mod->getIrq())) {
|
while(!_mod->hal->digitalRead(_mod->getIrq())) {
|
||||||
_mod->yield();
|
_mod->hal->yield();
|
||||||
if(_mod->millis() - start > 10000) {
|
if(_mod->hal->millis() - start > 10000) {
|
||||||
clearIrqStatus();
|
clearIrqStatus();
|
||||||
standby();
|
standby();
|
||||||
return(RADIOLIB_ERR_RANGING_TIMEOUT);
|
return(RADIOLIB_ERR_RANGING_TIMEOUT);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "SX128x.h"
|
#include "SX128x.h"
|
||||||
|
#include <math.h>
|
||||||
#if !defined(RADIOLIB_EXCLUDE_SX128X)
|
#if !defined(RADIOLIB_EXCLUDE_SX128X)
|
||||||
|
|
||||||
SX128x::SX128x(Module* mod) : PhysicalLayer(RADIOLIB_SX128X_FREQUENCY_STEP_SIZE, RADIOLIB_SX128X_MAX_PACKET_LENGTH) {
|
SX128x::SX128x(Module* mod) : PhysicalLayer(RADIOLIB_SX128X_FREQUENCY_STEP_SIZE, RADIOLIB_SX128X_MAX_PACKET_LENGTH) {
|
||||||
|
@ -12,8 +13,8 @@ Module* SX128x::getMod() {
|
||||||
int16_t SX128x::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength) {
|
int16_t SX128x::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength) {
|
||||||
// set module properties
|
// set module properties
|
||||||
_mod->init();
|
_mod->init();
|
||||||
_mod->pinMode(_mod->getIrq(), INPUT);
|
_mod->hal->pinMode(_mod->getIrq(), _mod->hal->GpioModeInput);
|
||||||
_mod->pinMode(_mod->getGpio(), INPUT);
|
_mod->hal->pinMode(_mod->getGpio(), _mod->hal->GpioModeInput);
|
||||||
_mod->SPIreadCommand = RADIOLIB_SX128X_CMD_READ_REGISTER;
|
_mod->SPIreadCommand = RADIOLIB_SX128X_CMD_READ_REGISTER;
|
||||||
_mod->SPIwriteCommand = RADIOLIB_SX128X_CMD_WRITE_REGISTER;
|
_mod->SPIwriteCommand = RADIOLIB_SX128X_CMD_WRITE_REGISTER;
|
||||||
_mod->SPInopCommand = RADIOLIB_SX128X_CMD_NOP;
|
_mod->SPInopCommand = RADIOLIB_SX128X_CMD_NOP;
|
||||||
|
@ -73,8 +74,8 @@ int16_t SX128x::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync
|
||||||
int16_t SX128x::beginGFSK(float freq, uint16_t br, float freqDev, int8_t power, uint16_t preambleLength) {
|
int16_t SX128x::beginGFSK(float freq, uint16_t br, float freqDev, int8_t power, uint16_t preambleLength) {
|
||||||
// set module properties
|
// set module properties
|
||||||
_mod->init();
|
_mod->init();
|
||||||
_mod->pinMode(_mod->getIrq(), INPUT);
|
_mod->hal->pinMode(_mod->getIrq(), _mod->hal->GpioModeInput);
|
||||||
_mod->pinMode(_mod->getGpio(), INPUT);
|
_mod->hal->pinMode(_mod->getGpio(), _mod->hal->GpioModeInput);
|
||||||
_mod->SPIreadCommand = RADIOLIB_SX128X_CMD_READ_REGISTER;
|
_mod->SPIreadCommand = RADIOLIB_SX128X_CMD_READ_REGISTER;
|
||||||
_mod->SPIwriteCommand = RADIOLIB_SX128X_CMD_WRITE_REGISTER;
|
_mod->SPIwriteCommand = RADIOLIB_SX128X_CMD_WRITE_REGISTER;
|
||||||
_mod->SPInopCommand = RADIOLIB_SX128X_CMD_NOP;
|
_mod->SPInopCommand = RADIOLIB_SX128X_CMD_NOP;
|
||||||
|
@ -142,8 +143,8 @@ int16_t SX128x::beginGFSK(float freq, uint16_t br, float freqDev, int8_t power,
|
||||||
int16_t SX128x::beginBLE(float freq, uint16_t br, float freqDev, int8_t power, uint8_t dataShaping) {
|
int16_t SX128x::beginBLE(float freq, uint16_t br, float freqDev, int8_t power, uint8_t dataShaping) {
|
||||||
// set module properties
|
// set module properties
|
||||||
_mod->init();
|
_mod->init();
|
||||||
_mod->pinMode(_mod->getIrq(), INPUT);
|
_mod->hal->pinMode(_mod->getIrq(), _mod->hal->GpioModeInput);
|
||||||
_mod->pinMode(_mod->getGpio(), INPUT);
|
_mod->hal->pinMode(_mod->getGpio(), _mod->hal->GpioModeInput);
|
||||||
_mod->SPIreadCommand = RADIOLIB_SX128X_CMD_READ_REGISTER;
|
_mod->SPIreadCommand = RADIOLIB_SX128X_CMD_READ_REGISTER;
|
||||||
_mod->SPIwriteCommand = RADIOLIB_SX128X_CMD_WRITE_REGISTER;
|
_mod->SPIwriteCommand = RADIOLIB_SX128X_CMD_WRITE_REGISTER;
|
||||||
_mod->SPInopCommand = RADIOLIB_SX128X_CMD_NOP;
|
_mod->SPInopCommand = RADIOLIB_SX128X_CMD_NOP;
|
||||||
|
@ -197,8 +198,8 @@ int16_t SX128x::beginBLE(float freq, uint16_t br, float freqDev, int8_t power, u
|
||||||
int16_t SX128x::beginFLRC(float freq, uint16_t br, uint8_t cr, int8_t power, uint16_t preambleLength, uint8_t dataShaping) {
|
int16_t SX128x::beginFLRC(float freq, uint16_t br, uint8_t cr, int8_t power, uint16_t preambleLength, uint8_t dataShaping) {
|
||||||
// set module properties
|
// set module properties
|
||||||
_mod->init();
|
_mod->init();
|
||||||
_mod->pinMode(_mod->getIrq(), INPUT);
|
_mod->hal->pinMode(_mod->getIrq(), _mod->hal->GpioModeInput);
|
||||||
_mod->pinMode(_mod->getGpio(), INPUT);
|
_mod->hal->pinMode(_mod->getGpio(), _mod->hal->GpioModeInput);
|
||||||
_mod->SPIreadCommand = RADIOLIB_SX128X_CMD_READ_REGISTER;
|
_mod->SPIreadCommand = RADIOLIB_SX128X_CMD_READ_REGISTER;
|
||||||
_mod->SPIwriteCommand = RADIOLIB_SX128X_CMD_WRITE_REGISTER;
|
_mod->SPIwriteCommand = RADIOLIB_SX128X_CMD_WRITE_REGISTER;
|
||||||
_mod->SPInopCommand = RADIOLIB_SX128X_CMD_NOP;
|
_mod->SPInopCommand = RADIOLIB_SX128X_CMD_NOP;
|
||||||
|
@ -261,10 +262,10 @@ int16_t SX128x::beginFLRC(float freq, uint16_t br, uint8_t cr, int8_t power, uin
|
||||||
|
|
||||||
int16_t SX128x::reset(bool verify) {
|
int16_t SX128x::reset(bool verify) {
|
||||||
// run the reset sequence - same as SX126x, as SX128x docs don't seem to mention this
|
// run the reset sequence - same as SX126x, as SX128x docs don't seem to mention this
|
||||||
_mod->pinMode(_mod->getRst(), OUTPUT);
|
_mod->hal->pinMode(_mod->getRst(), _mod->hal->GpioModeOutput);
|
||||||
_mod->digitalWrite(_mod->getRst(), LOW);
|
_mod->hal->digitalWrite(_mod->getRst(), _mod->hal->GpioLevelLow);
|
||||||
_mod->delay(1);
|
_mod->hal->delay(1);
|
||||||
_mod->digitalWrite(_mod->getRst(), HIGH);
|
_mod->hal->digitalWrite(_mod->getRst(), _mod->hal->GpioLevelHigh);
|
||||||
|
|
||||||
// return immediately when verification is disabled
|
// return immediately when verification is disabled
|
||||||
if(!verify) {
|
if(!verify) {
|
||||||
|
@ -272,7 +273,7 @@ int16_t SX128x::reset(bool verify) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// set mode to standby
|
// set mode to standby
|
||||||
uint32_t start = _mod->millis();
|
uint32_t start = _mod->hal->millis();
|
||||||
while(true) {
|
while(true) {
|
||||||
// try to set mode to standby
|
// try to set mode to standby
|
||||||
int16_t state = standby();
|
int16_t state = standby();
|
||||||
|
@ -282,13 +283,13 @@ int16_t SX128x::reset(bool verify) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// standby command failed, check timeout and try again
|
// standby command failed, check timeout and try again
|
||||||
if(_mod->millis() - start >= 3000) {
|
if(_mod->hal->millis() - start >= 3000) {
|
||||||
// timed out, possibly incorrect wiring
|
// timed out, possibly incorrect wiring
|
||||||
return(state);
|
return(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait a bit to not spam the module
|
// wait a bit to not spam the module
|
||||||
_mod->delay(10);
|
_mod->hal->delay(10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,10 +319,10 @@ int16_t SX128x::transmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// wait for packet transmission or timeout
|
// wait for packet transmission or timeout
|
||||||
uint32_t start = _mod->micros();
|
uint32_t start = _mod->hal->micros();
|
||||||
while(!_mod->digitalRead(_mod->getIrq())) {
|
while(!_mod->hal->digitalRead(_mod->getIrq())) {
|
||||||
_mod->yield();
|
_mod->hal->yield();
|
||||||
if(_mod->micros() - start > timeout) {
|
if(_mod->hal->micros() - start > timeout) {
|
||||||
finishTransmit();
|
finishTransmit();
|
||||||
return(RADIOLIB_ERR_TX_TIMEOUT);
|
return(RADIOLIB_ERR_TX_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
@ -352,10 +353,10 @@ int16_t SX128x::receive(uint8_t* data, size_t len) {
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// wait for packet reception or timeout
|
// wait for packet reception or timeout
|
||||||
uint32_t start = _mod->micros();
|
uint32_t start = _mod->hal->micros();
|
||||||
while(!_mod->digitalRead(_mod->getIrq())) {
|
while(!_mod->hal->digitalRead(_mod->getIrq())) {
|
||||||
_mod->yield();
|
_mod->hal->yield();
|
||||||
if(_mod->micros() - start > timeout) {
|
if(_mod->hal->micros() - start > timeout) {
|
||||||
clearIrqStatus();
|
clearIrqStatus();
|
||||||
standby();
|
standby();
|
||||||
return(RADIOLIB_ERR_RX_TIMEOUT);
|
return(RADIOLIB_ERR_RX_TIMEOUT);
|
||||||
|
@ -415,8 +416,8 @@ int16_t SX128x::scanChannel() {
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// wait for channel activity detected or timeout
|
// wait for channel activity detected or timeout
|
||||||
while(!_mod->digitalRead(_mod->getIrq())) {
|
while(!_mod->hal->digitalRead(_mod->getIrq())) {
|
||||||
_mod->yield();
|
_mod->hal->yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
// check CAD result
|
// check CAD result
|
||||||
|
@ -445,7 +446,7 @@ int16_t SX128x::sleep(bool retainConfig) {
|
||||||
int16_t state = _mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_SLEEP, &sleepConfig, 1, false, false);
|
int16_t state = _mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_SLEEP, &sleepConfig, 1, false, false);
|
||||||
|
|
||||||
// wait for SX128x to safely enter sleep mode
|
// wait for SX128x to safely enter sleep mode
|
||||||
_mod->delay(1);
|
_mod->hal->delay(1);
|
||||||
|
|
||||||
return(state);
|
return(state);
|
||||||
}
|
}
|
||||||
|
@ -463,11 +464,11 @@ int16_t SX128x::standby(uint8_t mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SX128x::setDio1Action(void (*func)(void)) {
|
void SX128x::setDio1Action(void (*func)(void)) {
|
||||||
_mod->attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, RISING);
|
_mod->hal->attachInterrupt(_mod->hal->pinToInterrupt(_mod->getIrq()), func, _mod->hal->GpioInterruptRising);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SX128x::clearDio1Action() {
|
void SX128x::clearDio1Action() {
|
||||||
_mod->detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()));
|
_mod->hal->detachInterrupt(_mod->hal->pinToInterrupt(_mod->getIrq()));
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t SX128x::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
int16_t SX128x::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
|
@ -527,8 +528,8 @@ int16_t SX128x::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// wait for BUSY to go low (= PA ramp up done)
|
// wait for BUSY to go low (= PA ramp up done)
|
||||||
while(_mod->digitalRead(_mod->getGpio())) {
|
while(_mod->hal->digitalRead(_mod->getGpio())) {
|
||||||
_mod->yield();
|
_mod->hal->yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
return(state);
|
return(state);
|
||||||
|
@ -1265,11 +1266,11 @@ int16_t SX128x::setEncoding(uint8_t encoding) {
|
||||||
return(setWhitening(encoding));
|
return(setWhitening(encoding));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SX128x::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) {
|
void SX128x::setRfSwitchPins(uint8_t rxEn, uint8_t txEn) {
|
||||||
_mod->setRfSwitchPins(rxEn, txEn);
|
_mod->setRfSwitchPins(rxEn, txEn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SX128x::setRfSwitchTable(const RADIOLIB_PIN_TYPE (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]) {
|
void SX128x::setRfSwitchTable(const uint8_t (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]) {
|
||||||
_mod->setRfSwitchTable(pins, table);
|
_mod->setRfSwitchTable(pins, table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1299,7 +1300,7 @@ void SX128x::setDirectAction(void (*func)(void)) {
|
||||||
(void)func;
|
(void)func;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SX128x::readBit(RADIOLIB_PIN_TYPE pin) {
|
void SX128x::readBit(uint8_t pin) {
|
||||||
// SX128x is unable to perform direct mode reception
|
// SX128x is unable to perform direct mode reception
|
||||||
// this method is implemented only for PhysicalLayer compatibility
|
// this method is implemented only for PhysicalLayer compatibility
|
||||||
(void)pin;
|
(void)pin;
|
||||||
|
|
|
@ -817,10 +817,10 @@ class SX128x: public PhysicalLayer {
|
||||||
int16_t setEncoding(uint8_t encoding) override;
|
int16_t setEncoding(uint8_t encoding) override;
|
||||||
|
|
||||||
/*! \copydoc Module::setRfSwitchPins */
|
/*! \copydoc Module::setRfSwitchPins */
|
||||||
void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn);
|
void setRfSwitchPins(uint8_t rxEn, uint8_t txEn);
|
||||||
|
|
||||||
/*! \copydoc Module::setRfSwitchTable */
|
/*! \copydoc Module::setRfSwitchTable */
|
||||||
void setRfSwitchTable(const RADIOLIB_PIN_TYPE (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]);
|
void setRfSwitchTable(const uint8_t (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Dummy random method, to ensure PhysicalLayer compatibility.
|
\brief Dummy random method, to ensure PhysicalLayer compatibility.
|
||||||
|
@ -851,7 +851,7 @@ class SX128x: public PhysicalLayer {
|
||||||
|
|
||||||
\param pin Ignored.
|
\param pin Ignored.
|
||||||
*/
|
*/
|
||||||
void readBit(RADIOLIB_PIN_TYPE pin);
|
void readBit(uint8_t pin);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL)
|
#if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "Si443x.h"
|
#include "Si443x.h"
|
||||||
|
#include <math.h>
|
||||||
#if !defined(RADIOLIB_EXCLUDE_SI443X)
|
#if !defined(RADIOLIB_EXCLUDE_SI443X)
|
||||||
|
|
||||||
Si443x::Si443x(Module* mod) : PhysicalLayer(RADIOLIB_SI443X_FREQUENCY_STEP_SIZE, RADIOLIB_SI443X_MAX_PACKET_LENGTH) {
|
Si443x::Si443x(Module* mod) : PhysicalLayer(RADIOLIB_SI443X_FREQUENCY_STEP_SIZE, RADIOLIB_SI443X_MAX_PACKET_LENGTH) {
|
||||||
|
@ -12,9 +13,9 @@ Module* Si443x::getMod() {
|
||||||
int16_t Si443x::begin(float br, float freqDev, float rxBw, uint8_t preambleLen) {
|
int16_t Si443x::begin(float br, float freqDev, float rxBw, uint8_t preambleLen) {
|
||||||
// set module properties
|
// set module properties
|
||||||
_mod->init();
|
_mod->init();
|
||||||
_mod->pinMode(_mod->getIrq(), INPUT);
|
_mod->hal->pinMode(_mod->getIrq(), _mod->hal->GpioModeInput);
|
||||||
_mod->pinMode(_mod->getRst(), OUTPUT);
|
_mod->hal->pinMode(_mod->getRst(), _mod->hal->GpioModeOutput);
|
||||||
_mod->digitalWrite(_mod->getRst(), LOW);
|
_mod->hal->digitalWrite(_mod->getRst(), _mod->hal->GpioLevelLow);
|
||||||
|
|
||||||
// try to find the Si443x chip
|
// try to find the Si443x chip
|
||||||
if(!Si443x::findChip()) {
|
if(!Si443x::findChip()) {
|
||||||
|
@ -67,11 +68,11 @@ int16_t Si443x::begin(float br, float freqDev, float rxBw, uint8_t preambleLen)
|
||||||
}
|
}
|
||||||
|
|
||||||
void Si443x::reset() {
|
void Si443x::reset() {
|
||||||
_mod->pinMode(_mod->getRst(), OUTPUT);
|
_mod->hal->pinMode(_mod->getRst(), _mod->hal->GpioModeOutput);
|
||||||
_mod->digitalWrite(_mod->getRst(), HIGH);
|
_mod->hal->digitalWrite(_mod->getRst(), _mod->hal->GpioLevelHigh);
|
||||||
_mod->delay(1);
|
_mod->hal->delay(1);
|
||||||
_mod->digitalWrite(_mod->getRst(), LOW);
|
_mod->hal->digitalWrite(_mod->getRst(), _mod->hal->GpioLevelLow);
|
||||||
_mod->delay(100);
|
_mod->hal->delay(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t Si443x::transmit(uint8_t* data, size_t len, uint8_t addr) {
|
int16_t Si443x::transmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
|
@ -83,10 +84,10 @@ int16_t Si443x::transmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// wait for transmission end or timeout
|
// wait for transmission end or timeout
|
||||||
uint32_t start = _mod->micros();
|
uint32_t start = _mod->hal->micros();
|
||||||
while(_mod->digitalRead(_mod->getIrq())) {
|
while(_mod->hal->digitalRead(_mod->getIrq())) {
|
||||||
_mod->yield();
|
_mod->hal->yield();
|
||||||
if(_mod->micros() - start > timeout) {
|
if(_mod->hal->micros() - start > timeout) {
|
||||||
finishTransmit();
|
finishTransmit();
|
||||||
return(RADIOLIB_ERR_TX_TIMEOUT);
|
return(RADIOLIB_ERR_TX_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
@ -104,9 +105,9 @@ int16_t Si443x::receive(uint8_t* data, size_t len) {
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// wait for packet reception or timeout
|
// wait for packet reception or timeout
|
||||||
uint32_t start = _mod->micros();
|
uint32_t start = _mod->hal->micros();
|
||||||
while(_mod->digitalRead(_mod->getIrq())) {
|
while(_mod->hal->digitalRead(_mod->getIrq())) {
|
||||||
if(_mod->micros() - start > timeout) {
|
if(_mod->hal->micros() - start > timeout) {
|
||||||
standby();
|
standby();
|
||||||
clearIRQFlags();
|
clearIRQFlags();
|
||||||
return(RADIOLIB_ERR_RX_TIMEOUT);
|
return(RADIOLIB_ERR_RX_TIMEOUT);
|
||||||
|
@ -206,11 +207,11 @@ int16_t Si443x::packetMode() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Si443x::setIrqAction(void (*func)(void)) {
|
void Si443x::setIrqAction(void (*func)(void)) {
|
||||||
_mod->attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, FALLING);
|
_mod->hal->attachInterrupt(_mod->hal->pinToInterrupt(_mod->getIrq()), func, _mod->hal->GpioInterruptFalling);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Si443x::clearIrqAction() {
|
void Si443x::clearIrqAction() {
|
||||||
_mod->detachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()));
|
_mod->hal->detachInterrupt(_mod->hal->pinToInterrupt(_mod->getIrq()));
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t Si443x::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
int16_t Si443x::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
|
@ -575,11 +576,11 @@ int16_t Si443x::setDataShaping(uint8_t sh) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Si443x::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) {
|
void Si443x::setRfSwitchPins(uint8_t rxEn, uint8_t txEn) {
|
||||||
_mod->setRfSwitchPins(rxEn, txEn);
|
_mod->setRfSwitchPins(rxEn, txEn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Si443x::setRfSwitchTable(const RADIOLIB_PIN_TYPE (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]) {
|
void Si443x::setRfSwitchTable(const uint8_t (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]) {
|
||||||
_mod->setRfSwitchTable(pins, table);
|
_mod->setRfSwitchTable(pins, table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -588,7 +589,7 @@ uint8_t Si443x::randomByte() {
|
||||||
_mod->SPIwriteRegister(RADIOLIB_SI443X_REG_OP_FUNC_CONTROL_1, RADIOLIB_SI443X_RX_ON | RADIOLIB_SI443X_XTAL_ON);
|
_mod->SPIwriteRegister(RADIOLIB_SI443X_REG_OP_FUNC_CONTROL_1, RADIOLIB_SI443X_RX_ON | RADIOLIB_SI443X_XTAL_ON);
|
||||||
|
|
||||||
// wait a bit for the RSSI reading to stabilise
|
// wait a bit for the RSSI reading to stabilise
|
||||||
_mod->delay(10);
|
_mod->hal->delay(10);
|
||||||
|
|
||||||
// read RSSI value 8 times, always keep just the least significant bit
|
// read RSSI value 8 times, always keep just the least significant bit
|
||||||
uint8_t randByte = 0x00;
|
uint8_t randByte = 0x00;
|
||||||
|
@ -611,8 +612,8 @@ void Si443x::setDirectAction(void (*func)(void)) {
|
||||||
setIrqAction(func);
|
setIrqAction(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Si443x::readBit(RADIOLIB_PIN_TYPE pin) {
|
void Si443x::readBit(uint8_t pin) {
|
||||||
updateDirectBuffer((uint8_t)_mod->digitalRead(pin));
|
updateDirectBuffer((uint8_t)_mod->hal->digitalRead(pin));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -684,7 +685,7 @@ bool Si443x::findChip() {
|
||||||
flagFound = true;
|
flagFound = true;
|
||||||
} else {
|
} else {
|
||||||
RADIOLIB_DEBUG_PRINTLN("Si443x not found! (%d of 10 tries) RADIOLIB_SI443X_REG_DEVICE_VERSION == 0x%02X, expected 0x0%X", i + 1, version, RADIOLIB_SI443X_DEVICE_VERSION);
|
RADIOLIB_DEBUG_PRINTLN("Si443x not found! (%d of 10 tries) RADIOLIB_SI443X_REG_DEVICE_VERSION == 0x%02X, expected 0x0%X", i + 1, version, RADIOLIB_SI443X_DEVICE_VERSION);
|
||||||
_mod->delay(10);
|
_mod->hal->delay(10);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -810,10 +810,10 @@ class Si443x: public PhysicalLayer {
|
||||||
int16_t setDataShaping(uint8_t sh) override;
|
int16_t setDataShaping(uint8_t sh) override;
|
||||||
|
|
||||||
/*! \copydoc Module::setRfSwitchPins */
|
/*! \copydoc Module::setRfSwitchPins */
|
||||||
void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn);
|
void setRfSwitchPins(uint8_t rxEn, uint8_t txEn);
|
||||||
|
|
||||||
/*! \copydoc Module::setRfSwitchTable */
|
/*! \copydoc Module::setRfSwitchTable */
|
||||||
void setRfSwitchTable(const RADIOLIB_PIN_TYPE (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]);
|
void setRfSwitchTable(const uint8_t (&pins)[Module::RFSWITCH_MAX_PINS], const Module::RfSwitchMode_t table[]);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Get one truly random byte from RSSI noise.
|
\brief Get one truly random byte from RSSI noise.
|
||||||
|
@ -842,7 +842,7 @@ class Si443x: public PhysicalLayer {
|
||||||
|
|
||||||
\param pin Pin on which to read.
|
\param pin Pin on which to read.
|
||||||
*/
|
*/
|
||||||
void readBit(RADIOLIB_PIN_TYPE pin);
|
void readBit(uint8_t pin);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "nRF24.h"
|
#include "nRF24.h"
|
||||||
|
#include <string.h>
|
||||||
#if !defined(RADIOLIB_EXCLUDE_NRF24)
|
#if !defined(RADIOLIB_EXCLUDE_NRF24)
|
||||||
|
|
||||||
nRF24::nRF24(Module* mod) : PhysicalLayer(RADIOLIB_NRF24_FREQUENCY_STEP_SIZE, RADIOLIB_NRF24_MAX_PACKET_LENGTH) {
|
nRF24::nRF24(Module* mod) : PhysicalLayer(RADIOLIB_NRF24_FREQUENCY_STEP_SIZE, RADIOLIB_NRF24_MAX_PACKET_LENGTH) {
|
||||||
|
@ -14,14 +15,14 @@ int16_t nRF24::begin(int16_t freq, int16_t dataRate, int8_t power, uint8_t addrW
|
||||||
_mod->SPIreadCommand = RADIOLIB_NRF24_CMD_READ;
|
_mod->SPIreadCommand = RADIOLIB_NRF24_CMD_READ;
|
||||||
_mod->SPIwriteCommand = RADIOLIB_NRF24_CMD_WRITE;
|
_mod->SPIwriteCommand = RADIOLIB_NRF24_CMD_WRITE;
|
||||||
_mod->init();
|
_mod->init();
|
||||||
_mod->pinMode(_mod->getIrq(), INPUT);
|
_mod->hal->pinMode(_mod->getIrq(), _mod->hal->GpioModeInput);
|
||||||
|
|
||||||
// set pin mode on RST (connected to nRF24 CE pin)
|
// set pin mode on RST (connected to nRF24 CE pin)
|
||||||
_mod->pinMode(_mod->getRst(), OUTPUT);
|
_mod->hal->pinMode(_mod->getRst(), _mod->hal->GpioModeOutput);
|
||||||
_mod->digitalWrite(_mod->getRst(), LOW);
|
_mod->hal->digitalWrite(_mod->getRst(), _mod->hal->GpioLevelLow);
|
||||||
|
|
||||||
// wait for minimum power-on reset duration
|
// wait for minimum power-on reset duration
|
||||||
_mod->delay(100);
|
_mod->hal->delay(100);
|
||||||
|
|
||||||
// check SPI connection
|
// check SPI connection
|
||||||
int16_t val = _mod->SPIgetRegValue(RADIOLIB_NRF24_REG_SETUP_AW);
|
int16_t val = _mod->SPIgetRegValue(RADIOLIB_NRF24_REG_SETUP_AW);
|
||||||
|
@ -79,7 +80,7 @@ int16_t nRF24::standby(uint8_t mode) {
|
||||||
// make sure carrier output is disabled
|
// make sure carrier output is disabled
|
||||||
_mod->SPIsetRegValue(RADIOLIB_NRF24_REG_RF_SETUP, RADIOLIB_NRF24_CONT_WAVE_OFF, 7, 7);
|
_mod->SPIsetRegValue(RADIOLIB_NRF24_REG_RF_SETUP, RADIOLIB_NRF24_CONT_WAVE_OFF, 7, 7);
|
||||||
_mod->SPIsetRegValue(RADIOLIB_NRF24_REG_RF_SETUP, RADIOLIB_NRF24_PLL_LOCK_OFF, 4, 4);
|
_mod->SPIsetRegValue(RADIOLIB_NRF24_REG_RF_SETUP, RADIOLIB_NRF24_PLL_LOCK_OFF, 4, 4);
|
||||||
_mod->digitalWrite(_mod->getRst(), LOW);
|
_mod->hal->digitalWrite(_mod->getRst(), _mod->hal->GpioLevelLow);
|
||||||
|
|
||||||
// use standby-1 mode
|
// use standby-1 mode
|
||||||
return(_mod->SPIsetRegValue(RADIOLIB_NRF24_REG_CONFIG, mode, 1, 1));
|
return(_mod->SPIsetRegValue(RADIOLIB_NRF24_REG_CONFIG, mode, 1, 1));
|
||||||
|
@ -91,9 +92,9 @@ int16_t nRF24::transmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// wait until transmission is finished
|
// wait until transmission is finished
|
||||||
uint32_t start = _mod->micros();
|
uint32_t start = _mod->hal->micros();
|
||||||
while(_mod->digitalRead(_mod->getIrq())) {
|
while(_mod->hal->digitalRead(_mod->getIrq())) {
|
||||||
_mod->yield();
|
_mod->hal->yield();
|
||||||
|
|
||||||
// check maximum number of retransmits
|
// check maximum number of retransmits
|
||||||
if(getStatus(RADIOLIB_NRF24_MAX_RT)) {
|
if(getStatus(RADIOLIB_NRF24_MAX_RT)) {
|
||||||
|
@ -102,7 +103,7 @@ int16_t nRF24::transmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check timeout: 15 retries * 4ms (max Tx time as per datasheet)
|
// check timeout: 15 retries * 4ms (max Tx time as per datasheet)
|
||||||
if(_mod->micros() - start >= 60000) {
|
if(_mod->hal->micros() - start >= 60000) {
|
||||||
finishTransmit();
|
finishTransmit();
|
||||||
return(RADIOLIB_ERR_TX_TIMEOUT);
|
return(RADIOLIB_ERR_TX_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
@ -117,12 +118,12 @@ int16_t nRF24::receive(uint8_t* data, size_t len) {
|
||||||
RADIOLIB_ASSERT(state);
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
// wait for Rx_DataReady or timeout
|
// wait for Rx_DataReady or timeout
|
||||||
uint32_t start = _mod->micros();
|
uint32_t start = _mod->hal->micros();
|
||||||
while(_mod->digitalRead(_mod->getIrq())) {
|
while(_mod->hal->digitalRead(_mod->getIrq())) {
|
||||||
_mod->yield();
|
_mod->hal->yield();
|
||||||
|
|
||||||
// check timeout: 15 retries * 4ms (max Tx time as per datasheet)
|
// check timeout: 15 retries * 4ms (max Tx time as per datasheet)
|
||||||
if(_mod->micros() - start >= 60000) {
|
if(_mod->hal->micros() - start >= 60000) {
|
||||||
standby();
|
standby();
|
||||||
clearIRQ();
|
clearIRQ();
|
||||||
return(RADIOLIB_ERR_RX_TIMEOUT);
|
return(RADIOLIB_ERR_RX_TIMEOUT);
|
||||||
|
@ -144,7 +145,7 @@ int16_t nRF24::transmitDirect(uint32_t frf) {
|
||||||
int16_t state = _mod->SPIsetRegValue(RADIOLIB_NRF24_REG_CONFIG, RADIOLIB_NRF24_PTX, 0, 0);
|
int16_t state = _mod->SPIsetRegValue(RADIOLIB_NRF24_REG_CONFIG, RADIOLIB_NRF24_PTX, 0, 0);
|
||||||
state |= _mod->SPIsetRegValue(RADIOLIB_NRF24_REG_RF_SETUP, RADIOLIB_NRF24_CONT_WAVE_ON, 7, 7);
|
state |= _mod->SPIsetRegValue(RADIOLIB_NRF24_REG_RF_SETUP, RADIOLIB_NRF24_CONT_WAVE_ON, 7, 7);
|
||||||
state |= _mod->SPIsetRegValue(RADIOLIB_NRF24_REG_RF_SETUP, RADIOLIB_NRF24_PLL_LOCK_ON, 4, 4);
|
state |= _mod->SPIsetRegValue(RADIOLIB_NRF24_REG_RF_SETUP, RADIOLIB_NRF24_PLL_LOCK_ON, 4, 4);
|
||||||
_mod->digitalWrite(_mod->getRst(), HIGH);
|
_mod->hal->digitalWrite(_mod->getRst(), _mod->hal->GpioLevelHigh);
|
||||||
return(state);
|
return(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +156,7 @@ int16_t nRF24::receiveDirect() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void nRF24::setIrqAction(void (*func)(void)) {
|
void nRF24::setIrqAction(void (*func)(void)) {
|
||||||
_mod->attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, FALLING);
|
_mod->hal->attachInterrupt(_mod->hal->pinToInterrupt(_mod->getIrq()), func, _mod->hal->GpioInterruptFalling);
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t nRF24::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
int16_t nRF24::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
|
@ -191,9 +192,9 @@ int16_t nRF24::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
SPIwriteTxPayload(data, len);
|
SPIwriteTxPayload(data, len);
|
||||||
|
|
||||||
// CE high to start transmitting
|
// CE high to start transmitting
|
||||||
_mod->digitalWrite(_mod->getRst(), HIGH);
|
_mod->hal->digitalWrite(_mod->getRst(), _mod->hal->GpioLevelHigh);
|
||||||
_mod->delay(1);
|
_mod->hal->delay(1);
|
||||||
_mod->digitalWrite(_mod->getRst(), LOW);
|
_mod->hal->digitalWrite(_mod->getRst(), _mod->hal->GpioLevelLow);
|
||||||
|
|
||||||
return(state);
|
return(state);
|
||||||
}
|
}
|
||||||
|
@ -224,10 +225,10 @@ int16_t nRF24::startReceive() {
|
||||||
SPItransfer(RADIOLIB_NRF24_CMD_FLUSH_RX);
|
SPItransfer(RADIOLIB_NRF24_CMD_FLUSH_RX);
|
||||||
|
|
||||||
// CE high to start receiving
|
// CE high to start receiving
|
||||||
_mod->digitalWrite(_mod->getRst(), HIGH);
|
_mod->hal->digitalWrite(_mod->getRst(), _mod->hal->GpioLevelHigh);
|
||||||
|
|
||||||
// wait to enter Rx state
|
// wait to enter Rx state
|
||||||
_mod->delay(1);
|
_mod->hal->delay(1);
|
||||||
|
|
||||||
return(state);
|
return(state);
|
||||||
}
|
}
|
||||||
|
@ -558,7 +559,7 @@ void nRF24::setDirectAction(void (*func)(void)) {
|
||||||
(void)func;
|
(void)func;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nRF24::readBit(RADIOLIB_PIN_TYPE pin) {
|
void nRF24::readBit(uint8_t pin) {
|
||||||
// nRF24 is unable to perform direct mode actions
|
// nRF24 is unable to perform direct mode actions
|
||||||
// this method is implemented only for PhysicalLayer compatibility
|
// this method is implemented only for PhysicalLayer compatibility
|
||||||
(void)pin;
|
(void)pin;
|
||||||
|
@ -601,7 +602,7 @@ int16_t nRF24::config() {
|
||||||
|
|
||||||
// power up
|
// power up
|
||||||
_mod->SPIsetRegValue(RADIOLIB_NRF24_REG_CONFIG, RADIOLIB_NRF24_POWER_UP, 1, 1);
|
_mod->SPIsetRegValue(RADIOLIB_NRF24_REG_CONFIG, RADIOLIB_NRF24_POWER_UP, 1, 1);
|
||||||
_mod->delay(5);
|
_mod->hal->delay(5);
|
||||||
|
|
||||||
return(state);
|
return(state);
|
||||||
}
|
}
|
||||||
|
@ -616,26 +617,26 @@ void nRF24::SPIwriteTxPayload(uint8_t* data, uint8_t numBytes) {
|
||||||
|
|
||||||
void nRF24::SPItransfer(uint8_t cmd, bool write, uint8_t* dataOut, uint8_t* dataIn, uint8_t numBytes) {
|
void nRF24::SPItransfer(uint8_t cmd, bool write, uint8_t* dataOut, uint8_t* dataIn, uint8_t numBytes) {
|
||||||
// start transfer
|
// start transfer
|
||||||
_mod->digitalWrite(_mod->getCs(), LOW);
|
_mod->hal->digitalWrite(_mod->getCs(), _mod->hal->GpioLevelLow);
|
||||||
_mod->beginTransaction();
|
_mod->hal->spiBeginTransaction();
|
||||||
|
|
||||||
// send command
|
// send command
|
||||||
_mod->transfer(cmd);
|
_mod->hal->spiTransfer(cmd);
|
||||||
|
|
||||||
// send data
|
// send data
|
||||||
if(write) {
|
if(write) {
|
||||||
for(uint8_t i = 0; i < numBytes; i++) {
|
for(uint8_t i = 0; i < numBytes; i++) {
|
||||||
_mod->transfer(dataOut[i]);
|
_mod->hal->spiTransfer(dataOut[i]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(uint8_t i = 0; i < numBytes; i++) {
|
for(uint8_t i = 0; i < numBytes; i++) {
|
||||||
dataIn[i] = _mod->transfer(0x00);
|
dataIn[i] = _mod->hal->spiTransfer(0x00);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// stop transfer
|
// stop transfer
|
||||||
_mod->endTransaction();
|
_mod->hal->spiEndTransaction();
|
||||||
_mod->digitalWrite(_mod->getCs(), HIGH);
|
_mod->hal->digitalWrite(_mod->getCs(), _mod->hal->GpioLevelHigh);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -528,7 +528,7 @@ class nRF24: public PhysicalLayer {
|
||||||
|
|
||||||
\param pin Ignored.
|
\param pin Ignored.
|
||||||
*/
|
*/
|
||||||
void readBit(RADIOLIB_PIN_TYPE pin);
|
void readBit(uint8_t pin);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL)
|
#if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "AFSK.h"
|
#include "AFSK.h"
|
||||||
#if !defined(RADIOLIB_EXCLUDE_AFSK)
|
#if !defined(RADIOLIB_EXCLUDE_AFSK)
|
||||||
|
|
||||||
AFSKClient::AFSKClient(PhysicalLayer* phy, RADIOLIB_PIN_TYPE pin): _pin(pin) {
|
AFSKClient::AFSKClient(PhysicalLayer* phy, uint8_t pin): _pin(pin) {
|
||||||
_phy = phy;
|
_phy = phy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,13 +20,13 @@ int16_t AFSKClient::tone(uint16_t freq, bool autoStart) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Module* mod = _phy->getMod();
|
Module* mod = _phy->getMod();
|
||||||
mod->tone(_pin, freq);
|
mod->hal->tone(_pin, freq);
|
||||||
return(RADIOLIB_ERR_NONE);
|
return(RADIOLIB_ERR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t AFSKClient::noTone(bool keepOn) {
|
int16_t AFSKClient::noTone(bool keepOn) {
|
||||||
Module* mod = _phy->getMod();
|
Module* mod = _phy->getMod();
|
||||||
mod->noTone(_pin);
|
mod->hal->noTone(_pin);
|
||||||
if(keepOn) {
|
if(keepOn) {
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ class AFSKClient {
|
||||||
|
|
||||||
\param pin The pin that will be used for audio output.
|
\param pin The pin that will be used for audio output.
|
||||||
*/
|
*/
|
||||||
AFSKClient(PhysicalLayer* phy, RADIOLIB_PIN_TYPE pin);
|
AFSKClient(PhysicalLayer* phy, uint8_t pin);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Initialization method.
|
\brief Initialization method.
|
||||||
|
@ -56,7 +56,7 @@ class AFSKClient {
|
||||||
private:
|
private:
|
||||||
#endif
|
#endif
|
||||||
PhysicalLayer* _phy;
|
PhysicalLayer* _phy;
|
||||||
RADIOLIB_PIN_TYPE _pin;
|
uint8_t _pin;
|
||||||
|
|
||||||
// allow specific classes access the private PhysicalLayer pointer
|
// allow specific classes access the private PhysicalLayer pointer
|
||||||
friend class RTTYClient;
|
friend class RTTYClient;
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
#include "APRS.h"
|
#include "APRS.h"
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <ctype.h>
|
||||||
#if !defined(RADIOLIB_EXCLUDE_APRS)
|
#if !defined(RADIOLIB_EXCLUDE_APRS)
|
||||||
|
|
||||||
APRSClient::APRSClient(AX25Client* ax) {
|
APRSClient::APRSClient(AX25Client* ax) {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "AX25.h"
|
#include "AX25.h"
|
||||||
|
#include <string.h>
|
||||||
#if !defined(RADIOLIB_EXCLUDE_AX25)
|
#if !defined(RADIOLIB_EXCLUDE_AX25)
|
||||||
|
|
||||||
AX25Frame::AX25Frame(const char* destCallsign, uint8_t destSSID, const char* srcCallsign, uint8_t srcSSID, uint8_t control)
|
AX25Frame::AX25Frame(const char* destCallsign, uint8_t destSSID, const char* srcCallsign, uint8_t srcSSID, uint8_t control)
|
||||||
|
@ -409,7 +410,7 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) {
|
||||||
|
|
||||||
// check each bit
|
// check each bit
|
||||||
for(uint16_t mask = 0x80; mask >= 0x01; mask >>= 1) {
|
for(uint16_t mask = 0x80; mask >= 0x01; mask >>= 1) {
|
||||||
uint32_t start = mod->micros();
|
uint32_t start = mod->hal->micros();
|
||||||
if(stuffedFrameBuff[i] & mask) {
|
if(stuffedFrameBuff[i] & mask) {
|
||||||
_audio->tone(_afskMark, false);
|
_audio->tone(_afskMark, false);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
#include "ExternalRadio.h"
|
#include "ExternalRadio.h"
|
||||||
|
|
||||||
|
#if defined(RADIOLIB_BUILD_ARDUINO)
|
||||||
ExternalRadio::ExternalRadio() : PhysicalLayer(1, 0) {
|
ExternalRadio::ExternalRadio() : PhysicalLayer(1, 0) {
|
||||||
mod = new Module(RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC);
|
mod = new Module(RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ExternalRadio::ExternalRadio(Hal *hal) : PhysicalLayer(1, 0) {
|
||||||
|
mod = new Module(hal, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC);
|
||||||
|
}
|
||||||
|
|
||||||
Module* ExternalRadio::getMod() {
|
Module* ExternalRadio::getMod() {
|
||||||
return(mod);
|
return(mod);
|
||||||
|
|
|
@ -3,12 +3,17 @@
|
||||||
|
|
||||||
#include "../../TypeDef.h"
|
#include "../../TypeDef.h"
|
||||||
#include "../../Module.h"
|
#include "../../Module.h"
|
||||||
|
#include "../../ArduinoHal.h"
|
||||||
|
|
||||||
#include "../PhysicalLayer/PhysicalLayer.h"
|
#include "../PhysicalLayer/PhysicalLayer.h"
|
||||||
|
|
||||||
class ExternalRadio: public PhysicalLayer {
|
class ExternalRadio: public PhysicalLayer {
|
||||||
public:
|
public:
|
||||||
|
#if defined(RADIOLIB_BUILD_ARDUINO)
|
||||||
ExternalRadio();
|
ExternalRadio();
|
||||||
|
#endif
|
||||||
|
ExternalRadio(Hal *hal);
|
||||||
|
|
||||||
Module* getMod();
|
Module* getMod();
|
||||||
private:
|
private:
|
||||||
Module* mod;
|
Module* mod;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "FSK4.h"
|
#include "FSK4.h"
|
||||||
|
#include <math.h>
|
||||||
#if !defined(RADIOLIB_EXCLUDE_FSK4)
|
#if !defined(RADIOLIB_EXCLUDE_FSK4)
|
||||||
|
|
||||||
FSK4Client::FSK4Client(PhysicalLayer* phy) {
|
FSK4Client::FSK4Client(PhysicalLayer* phy) {
|
||||||
|
@ -80,7 +81,7 @@ size_t FSK4Client::write(uint8_t b) {
|
||||||
|
|
||||||
void FSK4Client::tone(uint8_t i) {
|
void FSK4Client::tone(uint8_t i) {
|
||||||
Module* mod = _phy->getMod();
|
Module* mod = _phy->getMod();
|
||||||
uint32_t start = mod->micros();
|
uint32_t start = mod->hal->micros();
|
||||||
transmitDirect(_base + _tones[i], _baseHz + _tonesHz[i]);
|
transmitDirect(_base + _tones[i], _baseHz + _tonesHz[i]);
|
||||||
mod->waitForMicroseconds(start, _bitDuration);
|
mod->waitForMicroseconds(start, _bitDuration);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "Hellschreiber.h"
|
#include "Hellschreiber.h"
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
#if !defined(RADIOLIB_EXCLUDE_HELLSCHREIBER)
|
#if !defined(RADIOLIB_EXCLUDE_HELLSCHREIBER)
|
||||||
|
|
||||||
HellClient::HellClient(PhysicalLayer* phy) {
|
HellClient::HellClient(PhysicalLayer* phy) {
|
||||||
|
@ -34,7 +36,7 @@ size_t HellClient::printGlyph(uint8_t* buff) {
|
||||||
bool transmitting = false;
|
bool transmitting = false;
|
||||||
for(uint8_t mask = 0x40; mask >= 0x01; mask >>= 1) {
|
for(uint8_t mask = 0x40; mask >= 0x01; mask >>= 1) {
|
||||||
for(int8_t i = RADIOLIB_HELL_FONT_HEIGHT - 1; i >= 0; i--) {
|
for(int8_t i = RADIOLIB_HELL_FONT_HEIGHT - 1; i >= 0; i--) {
|
||||||
uint32_t start = mod->micros();
|
uint32_t start = mod->hal->micros();
|
||||||
if((buff[i] & mask) && (!transmitting)) {
|
if((buff[i] & mask) && (!transmitting)) {
|
||||||
transmitting = true;
|
transmitting = true;
|
||||||
transmitDirect(_base, _baseHz);
|
transmitDirect(_base, _baseHz);
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
#include "Morse.h"
|
#include "Morse.h"
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <math.h>
|
||||||
#if !defined(RADIOLIB_EXCLUDE_MORSE)
|
#if !defined(RADIOLIB_EXCLUDE_MORSE)
|
||||||
|
|
||||||
MorseClient::MorseClient(PhysicalLayer* phy) {
|
MorseClient::MorseClient(PhysicalLayer* phy) {
|
||||||
|
@ -59,7 +62,7 @@ int MorseClient::read(byte* symbol, byte* len, float low, float high) {
|
||||||
Module* mod = _phy->getMod();
|
Module* mod = _phy->getMod();
|
||||||
|
|
||||||
// measure pulse duration in us
|
// measure pulse duration in us
|
||||||
uint32_t duration = mod->pulseIn(_audio->_pin, LOW, 4*_basePeriod);
|
uint32_t duration = mod->hal->pulseIn(_audio->_pin, mod->hal->GpioLevelLow, 4*_basePeriod);
|
||||||
|
|
||||||
// decide if this is a signal, or pause
|
// decide if this is a signal, or pause
|
||||||
if((duration > low*_basePeriod) && (duration < high*_basePeriod)) {
|
if((duration > low*_basePeriod) && (duration < high*_basePeriod)) {
|
||||||
|
@ -74,8 +77,8 @@ int MorseClient::read(byte* symbol, byte* len, float low, float high) {
|
||||||
if((pauseCounter > 0) && (signalCounter == 1)) {
|
if((pauseCounter > 0) && (signalCounter == 1)) {
|
||||||
// start of dot or dash
|
// start of dot or dash
|
||||||
pauseCounter = 0;
|
pauseCounter = 0;
|
||||||
signalStart = mod->millis();
|
signalStart = mod->hal->millis();
|
||||||
uint32_t pauseLen = mod->millis() - pauseStart;
|
uint32_t pauseLen = mod->hal->millis() - pauseStart;
|
||||||
|
|
||||||
if((pauseLen >= low*(float)_letterSpace) && (pauseLen <= high*(float)_letterSpace)) {
|
if((pauseLen >= low*(float)_letterSpace) && (pauseLen <= high*(float)_letterSpace)) {
|
||||||
return(RADIOLIB_MORSE_CHAR_COMPLETE);
|
return(RADIOLIB_MORSE_CHAR_COMPLETE);
|
||||||
|
@ -87,8 +90,8 @@ int MorseClient::read(byte* symbol, byte* len, float low, float high) {
|
||||||
} else if((signalCounter > 0) && (pauseCounter == 1)) {
|
} else if((signalCounter > 0) && (pauseCounter == 1)) {
|
||||||
// end of dot or dash
|
// end of dot or dash
|
||||||
signalCounter = 0;
|
signalCounter = 0;
|
||||||
pauseStart = mod->millis();
|
pauseStart = mod->hal->millis();
|
||||||
uint32_t signalLen = mod->millis() - signalStart;
|
uint32_t signalLen = mod->hal->millis() - signalStart;
|
||||||
|
|
||||||
if((signalLen >= low*(float)_dotLength) && (signalLen <= high*(float)_dotLength)) {
|
if((signalLen >= low*(float)_dotLength) && (signalLen <= high*(float)_dotLength)) {
|
||||||
RADIOLIB_DEBUG_PRINT(".");
|
RADIOLIB_DEBUG_PRINT(".");
|
||||||
|
@ -135,7 +138,7 @@ size_t MorseClient::write(uint8_t b) {
|
||||||
if(b == ' ') {
|
if(b == ' ') {
|
||||||
RADIOLIB_DEBUG_PRINTLN("space");
|
RADIOLIB_DEBUG_PRINTLN("space");
|
||||||
standby();
|
standby();
|
||||||
mod->waitForMicroseconds(mod->micros(), _wordSpace*1000);
|
mod->waitForMicroseconds(mod->hal->micros(), _wordSpace*1000);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,16 +157,16 @@ size_t MorseClient::write(uint8_t b) {
|
||||||
if (code & RADIOLIB_MORSE_DASH) {
|
if (code & RADIOLIB_MORSE_DASH) {
|
||||||
RADIOLIB_DEBUG_PRINT("-");
|
RADIOLIB_DEBUG_PRINT("-");
|
||||||
transmitDirect(_base, _baseHz);
|
transmitDirect(_base, _baseHz);
|
||||||
mod->waitForMicroseconds(mod->micros(), _dashLength*1000);
|
mod->waitForMicroseconds(mod->hal->micros(), _dashLength*1000);
|
||||||
} else {
|
} else {
|
||||||
RADIOLIB_DEBUG_PRINT(".");
|
RADIOLIB_DEBUG_PRINT(".");
|
||||||
transmitDirect(_base, _baseHz);
|
transmitDirect(_base, _baseHz);
|
||||||
mod->waitForMicroseconds(mod->micros(), _dotLength*1000);
|
mod->waitForMicroseconds(mod->hal->micros(), _dotLength*1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// symbol space
|
// symbol space
|
||||||
standby();
|
standby();
|
||||||
mod->waitForMicroseconds(mod->micros(), _dotLength*1000);
|
mod->waitForMicroseconds(mod->hal->micros(), _dotLength*1000);
|
||||||
|
|
||||||
// move onto the next bit
|
// move onto the next bit
|
||||||
code >>= 1;
|
code >>= 1;
|
||||||
|
@ -171,7 +174,7 @@ size_t MorseClient::write(uint8_t b) {
|
||||||
|
|
||||||
// letter space
|
// letter space
|
||||||
standby();
|
standby();
|
||||||
mod->waitForMicroseconds(mod->micros(), _letterSpace*1000 - _dotLength*1000);
|
mod->waitForMicroseconds(mod->hal->micros(), _letterSpace*1000 - _dotLength*1000);
|
||||||
RADIOLIB_DEBUG_PRINTLN();
|
RADIOLIB_DEBUG_PRINTLN();
|
||||||
|
|
||||||
return(1);
|
return(1);
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
#include "Pager.h"
|
#include "Pager.h"
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
#if !defined(RADIOLIB_EXCLUDE_PAGER)
|
#if !defined(RADIOLIB_EXCLUDE_PAGER)
|
||||||
|
|
||||||
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
|
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
|
||||||
// this is a massive hack, but we need a global-scope ISR to manage the bit reading
|
// this is a massive hack, but we need a global-scope ISR to manage the bit reading
|
||||||
// let's hope nobody ever tries running two POCSAG receivers at the same time
|
// let's hope nobody ever tries running two POCSAG receivers at the same time
|
||||||
static PhysicalLayer* _readBitInstance = NULL;
|
static PhysicalLayer* _readBitInstance = NULL;
|
||||||
static RADIOLIB_PIN_TYPE _readBitPin = RADIOLIB_NC;
|
static uint8_t _readBitPin = RADIOLIB_NC;
|
||||||
|
|
||||||
#if defined(ESP8266) || defined(ESP32)
|
#if defined(ESP8266) || defined(ESP32)
|
||||||
ICACHE_RAM_ATTR
|
ICACHE_RAM_ATTR
|
||||||
|
@ -221,7 +223,7 @@ int16_t PagerClient::transmit(uint8_t* data, size_t len, uint32_t addr, uint8_t
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
|
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
|
||||||
int16_t PagerClient::startReceive(RADIOLIB_PIN_TYPE pin, uint32_t addr, uint32_t mask) {
|
int16_t PagerClient::startReceive(uint8_t pin, uint32_t addr, uint32_t mask) {
|
||||||
// save the variables
|
// save the variables
|
||||||
_readBitPin = pin;
|
_readBitPin = pin;
|
||||||
_filterAddr = addr;
|
_filterAddr = addr;
|
||||||
|
@ -241,7 +243,7 @@ int16_t PagerClient::startReceive(RADIOLIB_PIN_TYPE pin, uint32_t addr, uint32_t
|
||||||
|
|
||||||
// now set up the direct mode reception
|
// now set up the direct mode reception
|
||||||
Module* mod = _phy->getMod();
|
Module* mod = _phy->getMod();
|
||||||
mod->pinMode(pin, INPUT);
|
mod->hal->pinMode(pin, mod->hal->GpioModeInput);
|
||||||
|
|
||||||
// set direct sync word to the frame sync word
|
// set direct sync word to the frame sync word
|
||||||
// the logic here is inverted, because modules like SX1278
|
// the logic here is inverted, because modules like SX1278
|
||||||
|
@ -453,7 +455,7 @@ void PagerClient::write(uint32_t codeWord) {
|
||||||
Module* mod = _phy->getMod();
|
Module* mod = _phy->getMod();
|
||||||
for(int8_t i = 31; i >= 0; i--) {
|
for(int8_t i = 31; i >= 0; i--) {
|
||||||
uint32_t mask = (uint32_t)0x01 << i;
|
uint32_t mask = (uint32_t)0x01 << i;
|
||||||
uint32_t start = mod->micros();
|
uint32_t start = mod->hal->micros();
|
||||||
|
|
||||||
// figure out the shift direction - start by assuming the bit is 0
|
// figure out the shift direction - start by assuming the bit is 0
|
||||||
int16_t change = _shift;
|
int16_t change = _shift;
|
||||||
|
@ -471,12 +473,12 @@ void PagerClient::write(uint32_t codeWord) {
|
||||||
// now transmit the shifted frequency
|
// now transmit the shifted frequency
|
||||||
_phy->transmitDirect(_baseRaw + change);
|
_phy->transmitDirect(_baseRaw + change);
|
||||||
|
|
||||||
// this is pretty silly, while(mod->micros() ... ) would be enough
|
// this is pretty silly, while(mod->hal->micros() ... ) would be enough
|
||||||
// but for some reason, MegaCore throws a linker error on it
|
// but for some reason, MegaCore throws a linker error on it
|
||||||
// "relocation truncated to fit: R_AVR_7_PCREL against `no symbol'"
|
// "relocation truncated to fit: R_AVR_7_PCREL against `no symbol'"
|
||||||
uint32_t now = mod->micros();
|
uint32_t now = mod->hal->micros();
|
||||||
while(now - start < _bitDuration) {
|
while(now - start < _bitDuration) {
|
||||||
now = mod->micros();
|
now = mod->hal->micros();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,7 +157,7 @@ class PagerClient {
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t startReceive(RADIOLIB_PIN_TYPE pin, uint32_t addr, uint32_t mask = 0xFFFFF);
|
int16_t startReceive(uint8_t pin, uint32_t addr, uint32_t mask = 0xFFFFF);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Get the number of POCSAG batches available in buffer. Limited by the size of direct mode buffer!
|
\brief Get the number of POCSAG batches available in buffer. Limited by the size of direct mode buffer!
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "PhysicalLayer.h"
|
#include "PhysicalLayer.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
PhysicalLayer::PhysicalLayer(float freqStep, size_t maxPacketLength) {
|
PhysicalLayer::PhysicalLayer(float freqStep, size_t maxPacketLength) {
|
||||||
_freqStep = freqStep;
|
_freqStep = freqStep;
|
||||||
|
@ -379,13 +380,13 @@ void PhysicalLayer::setDirectAction(void (*func)(void)) {
|
||||||
(void)func;
|
(void)func;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicalLayer::readBit(RADIOLIB_PIN_TYPE pin) {
|
void PhysicalLayer::readBit(uint8_t pin) {
|
||||||
(void)pin;
|
(void)pin;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int16_t PhysicalLayer::setDIOMapping(RADIOLIB_PIN_TYPE pin, uint8_t value) {
|
int16_t PhysicalLayer::setDIOMapping(uint8_t pin, uint8_t value) {
|
||||||
(void)pin;
|
(void)pin;
|
||||||
(void)value;
|
(void)value;
|
||||||
return(RADIOLIB_ERR_UNSUPPORTED);
|
return(RADIOLIB_ERR_UNSUPPORTED);
|
||||||
|
|
|
@ -360,7 +360,7 @@ class PhysicalLayer {
|
||||||
|
|
||||||
\param pin Pin on which to read.
|
\param pin Pin on which to read.
|
||||||
*/
|
*/
|
||||||
virtual void readBit(RADIOLIB_PIN_TYPE pin);
|
virtual void readBit(uint8_t pin);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Get the number of direct mode bytes currently available in buffer.
|
\brief Get the number of direct mode bytes currently available in buffer.
|
||||||
|
@ -393,7 +393,7 @@ class PhysicalLayer {
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
virtual int16_t setDIOMapping(RADIOLIB_PIN_TYPE pin, uint8_t value);
|
virtual int16_t setDIOMapping(uint8_t pin, uint8_t value);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Sets interrupt service routine to call when DIO1 activates.
|
\brief Sets interrupt service routine to call when DIO1 activates.
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "RTTY.h"
|
#include "RTTY.h"
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
#if !defined(RADIOLIB_EXCLUDE_RTTY)
|
#if !defined(RADIOLIB_EXCLUDE_RTTY)
|
||||||
|
|
||||||
ITA2String::ITA2String(char c) {
|
ITA2String::ITA2String(char c) {
|
||||||
|
@ -409,14 +411,14 @@ size_t RTTYClient::println(double d, int digits) {
|
||||||
|
|
||||||
void RTTYClient::mark() {
|
void RTTYClient::mark() {
|
||||||
Module* mod = _phy->getMod();
|
Module* mod = _phy->getMod();
|
||||||
uint32_t start = mod->micros();
|
uint32_t start = mod->hal->micros();
|
||||||
transmitDirect(_base + _shift, _baseHz + _shiftHz);
|
transmitDirect(_base + _shift, _baseHz + _shiftHz);
|
||||||
mod->waitForMicroseconds(start, _bitDuration);
|
mod->waitForMicroseconds(start, _bitDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RTTYClient::space() {
|
void RTTYClient::space() {
|
||||||
Module* mod = _phy->getMod();
|
Module* mod = _phy->getMod();
|
||||||
uint32_t start = mod->micros();
|
uint32_t start = mod->hal->micros();
|
||||||
transmitDirect(_base, _baseHz);
|
transmitDirect(_base, _baseHz);
|
||||||
mod->waitForMicroseconds(start, _bitDuration);
|
mod->waitForMicroseconds(start, _bitDuration);
|
||||||
}
|
}
|
||||||
|
|
|
@ -291,7 +291,7 @@ uint16_t SSTVClient::getPictureHeight() const {
|
||||||
|
|
||||||
void SSTVClient::tone(float freq, uint32_t len) {
|
void SSTVClient::tone(float freq, uint32_t len) {
|
||||||
Module* mod = _phy->getMod();
|
Module* mod = _phy->getMod();
|
||||||
uint32_t start = mod->micros();
|
uint32_t start = mod->hal->micros();
|
||||||
#if !defined(RADIOLIB_EXCLUDE_AFSK)
|
#if !defined(RADIOLIB_EXCLUDE_AFSK)
|
||||||
if(_audio != nullptr) {
|
if(_audio != nullptr) {
|
||||||
_audio->tone(freq, false);
|
_audio->tone(freq, false);
|
||||||
|
|
Loading…
Add table
Reference in a new issue