Fix SPI semaphore lockup issue on ESP32

This commit is contained in:
jacob.eva 2024-08-06 17:37:47 +01:00
parent a4fe2baf78
commit 721cee3603
No known key found for this signature in database
GPG Key ID: 0B92E083BBCCAA1E
5 changed files with 112 additions and 114 deletions

View File

@ -726,17 +726,6 @@
}; };
#endif #endif
#define INTERFACE_SPI
// Required because on RAK4631, non-default SPI pins must be initialised when class is declared.
const SPIClass interface_spi[1] = {
// SX1262
SPIClass(
NRF_SPIM2,
interface_pins[0][3],
interface_pins[0][1],
interface_pins[0][2]
)
};
const int pin_disp_cs = SS; const int pin_disp_cs = SS;
const int pin_disp_dc = WB_IO1; const int pin_disp_dc = WB_IO1;
@ -752,10 +741,4 @@
#endif #endif
#endif #endif
#ifndef INTERFACE_SPI
// INTERFACE_SPI is only required on NRF52 platforms, as the SPI pins are set in the class constructor and not by a setter method.
// Even if custom SPI interfaces are not needed, the array must exist to prevent compilation errors.
#define INTERFACE_SPI
const SPIClass interface_spi[1];
#endif
#endif #endif

View File

@ -17,10 +17,25 @@
#include <SPI.h> #include <SPI.h>
#include "Utilities.h" #include "Utilities.h"
#if BOARD_MODEL == BOARD_HELTEC32_V3 #if MCU_VARIANT == MCU_NRF52
// Default stack size for loop function on Heltec32 V3 is not large enough, #define INTERFACE_SPI
// must be increased to 11kb to prevent crashes. // Required because on RAK4631, non-default SPI pins must be initialised when class is declared.
SET_LOOP_TASK_STACK_SIZE(11 * 1024); // 11KB SPIClass interface_spi[1] = {
// SX1262
SPIClass(
NRF_SPIM2,
interface_pins[0][3],
interface_pins[0][1],
interface_pins[0][2]
)
};
#endif
#ifndef INTERFACE_SPI
// INTERFACE_SPI is only required on NRF52 platforms, as the SPI pins are set in the class constructor and not by a setter method.
// Even if custom SPI interfaces are not needed, the array must exist to prevent compilation errors.
#define INTERFACE_SPI
SPIClass interface_spi[1];
#endif #endif
FIFOBuffer serialFIFO; FIFOBuffer serialFIFO;
@ -134,13 +149,13 @@ void setup() {
sx126x* obj; sx126x* obj;
// if default spi enabled // if default spi enabled
if (interface_cfg[i][0]) { if (interface_cfg[i][0]) {
obj = new sx126x(i, SPI, interface_cfg[i][1], obj = new sx126x(i, &SPI, interface_cfg[i][1],
interface_cfg[i][2], interface_pins[i][0], interface_pins[i][1], interface_cfg[i][2], interface_pins[i][0], interface_pins[i][1],
interface_pins[i][2], interface_pins[i][3], interface_pins[i][6], interface_pins[i][2], interface_pins[i][3], interface_pins[i][6],
interface_pins[i][5], interface_pins[i][4], interface_pins[i][8]); interface_pins[i][5], interface_pins[i][4], interface_pins[i][8]);
} }
else { else {
obj = new sx126x(i, interface_spi[i], interface_cfg[i][1], obj = new sx126x(i, &interface_spi[i], interface_cfg[i][1],
interface_cfg[i][2], interface_pins[i][0], interface_pins[i][1], interface_cfg[i][2], interface_pins[i][0], interface_pins[i][1],
interface_pins[i][2], interface_pins[i][3], interface_pins[i][6], interface_pins[i][2], interface_pins[i][3], interface_pins[i][6],
interface_pins[i][5], interface_pins[i][4], interface_pins[i][8]); interface_pins[i][5], interface_pins[i][4], interface_pins[i][8]);
@ -157,12 +172,12 @@ void setup() {
sx127x* obj; sx127x* obj;
// if default spi enabled // if default spi enabled
if (interface_cfg[i][0]) { if (interface_cfg[i][0]) {
obj = new sx127x(i, SPI, interface_pins[i][0], obj = new sx127x(i, &SPI, interface_pins[i][0],
interface_pins[i][1], interface_pins[i][2], interface_pins[i][3], interface_pins[i][1], interface_pins[i][2], interface_pins[i][3],
interface_pins[i][6], interface_pins[i][5], interface_pins[i][4]); interface_pins[i][6], interface_pins[i][5], interface_pins[i][4]);
} }
else { else {
obj = new sx127x(i, interface_spi[i], interface_pins[i][0], obj = new sx127x(i, &interface_spi[i], interface_pins[i][0],
interface_pins[i][1], interface_pins[i][2], interface_pins[i][3], interface_pins[i][1], interface_pins[i][2], interface_pins[i][3],
interface_pins[i][6], interface_pins[i][5], interface_pins[i][4]); interface_pins[i][6], interface_pins[i][5], interface_pins[i][4]);
} }
@ -177,13 +192,13 @@ void setup() {
sx128x* obj; sx128x* obj;
// if default spi enabled // if default spi enabled
if (interface_cfg[i][0]) { if (interface_cfg[i][0]) {
obj = new sx128x(i, SPI, interface_cfg[i][1], obj = new sx128x(i, &SPI, interface_cfg[i][1],
interface_pins[i][0], interface_pins[i][1], interface_pins[i][2], interface_pins[i][0], interface_pins[i][1], interface_pins[i][2],
interface_pins[i][3], interface_pins[i][6], interface_pins[i][5], interface_pins[i][3], interface_pins[i][6], interface_pins[i][5],
interface_pins[i][4], interface_pins[i][8], interface_pins[i][7]); interface_pins[i][4], interface_pins[i][8], interface_pins[i][7]);
} }
else { else {
obj = new sx128x(i, interface_spi[i], interface_cfg[i][1], obj = new sx128x(i, &interface_spi[i], interface_cfg[i][1],
interface_pins[i][0], interface_pins[i][1], interface_pins[i][2], interface_pins[i][0], interface_pins[i][1], interface_pins[i][2],
interface_pins[i][3], interface_pins[i][6], interface_pins[i][5], interface_pins[i][3], interface_pins[i][6], interface_pins[i][5],
interface_pins[i][4], interface_pins[i][8], interface_pins[i][7]); interface_pins[i][4], interface_pins[i][8], interface_pins[i][7]);

160
Radio.cpp
View File

@ -4,7 +4,7 @@
// Modifications and additions copyright 2024 by Mark Qvist & Jacob Eva // Modifications and additions copyright 2024 by Mark Qvist & Jacob Eva
// Obviously still under the MIT license. // Obviously still under the MIT license.
#include "Radio.h" #include "Radio.hpp"
#if PLATFORM == PLATFORM_ESP32 #if PLATFORM == PLATFORM_ESP32
#if defined(ESP32) and !defined(CONFIG_IDF_TARGET_ESP32S3) #if defined(ESP32) and !defined(CONFIG_IDF_TARGET_ESP32S3)
@ -106,7 +106,7 @@ void ISR_VECT onDio0Rise() {
} }
} }
sx126x::sx126x(uint8_t index, SPIClass spi, bool tcxo, bool dio2_as_rf_switch, int ss, int sclk, int mosi, int miso, int reset, int dio0, int busy, int rxen) : sx126x::sx126x(uint8_t index, SPIClass* spi, bool tcxo, bool dio2_as_rf_switch, int ss, int sclk, int mosi, int miso, int reset, int dio0, int busy, int rxen) :
RadioInterface(index), RadioInterface(index),
_spiSettings(8E6, MSBFIRST, SPI_MODE0), _spiModem(spi), _ss(ss), _spiSettings(8E6, MSBFIRST, SPI_MODE0), _spiModem(spi), _ss(ss),
_sclk(sclk), _mosi(mosi), _miso(miso), _reset(reset), _dio0(dio0), _sclk(sclk), _mosi(mosi), _miso(miso), _reset(reset), _dio0(dio0),
@ -130,12 +130,12 @@ bool sx126x::preInit() {
// todo: check if this change causes issues on any platforms // todo: check if this change causes issues on any platforms
#if MCU_VARIANT == MCU_ESP32 #if MCU_VARIANT == MCU_ESP32
if (_sclk != -1 && _miso != -1 && _mosi != -1 && _ss != -1) { if (_sclk != -1 && _miso != -1 && _mosi != -1 && _ss != -1) {
_spiModem.begin(_sclk, _miso, _mosi, _ss); _spiModem->begin(_sclk, _miso, _mosi, _ss);
} else { } else {
_spiModem.begin(); _spiModem->begin();
} }
#else #else
_spiModem.begin(); _spiModem->begin();
#endif #endif
// check version (retry for up to 2 seconds) // check version (retry for up to 2 seconds)
@ -177,15 +177,15 @@ uint8_t ISR_VECT sx126x::singleTransfer(uint8_t opcode, uint16_t address, uint8_
digitalWrite(_ss, LOW); digitalWrite(_ss, LOW);
_spiModem.beginTransaction(_spiSettings); _spiModem->beginTransaction(_spiSettings);
_spiModem.transfer(opcode); _spiModem->transfer(opcode);
_spiModem.transfer((address & 0xFF00) >> 8); _spiModem->transfer((address & 0xFF00) >> 8);
_spiModem.transfer(address & 0x00FF); _spiModem->transfer(address & 0x00FF);
if (opcode == OP_READ_REGISTER_6X) { if (opcode == OP_READ_REGISTER_6X) {
_spiModem.transfer(0x00); _spiModem->transfer(0x00);
} }
response = _spiModem.transfer(value); response = _spiModem->transfer(value);
_spiModem.endTransaction(); _spiModem->endTransaction();
digitalWrite(_ss, HIGH); digitalWrite(_ss, HIGH);
@ -222,15 +222,15 @@ void sx126x::executeOpcode(uint8_t opcode, uint8_t *buffer, uint8_t size)
digitalWrite(_ss, LOW); digitalWrite(_ss, LOW);
_spiModem.beginTransaction(_spiSettings); _spiModem->beginTransaction(_spiSettings);
_spiModem.transfer(opcode); _spiModem->transfer(opcode);
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
{ {
_spiModem.transfer(buffer[i]); _spiModem->transfer(buffer[i]);
} }
_spiModem.endTransaction(); _spiModem->endTransaction();
digitalWrite(_ss, HIGH); digitalWrite(_ss, HIGH);
} }
@ -241,16 +241,16 @@ void sx126x::executeOpcodeRead(uint8_t opcode, uint8_t *buffer, uint8_t size)
digitalWrite(_ss, LOW); digitalWrite(_ss, LOW);
_spiModem.beginTransaction(_spiSettings); _spiModem->beginTransaction(_spiSettings);
_spiModem.transfer(opcode); _spiModem->transfer(opcode);
_spiModem.transfer(0x00); _spiModem->transfer(0x00);
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
{ {
buffer[i] = _spiModem.transfer(0x00); buffer[i] = _spiModem->transfer(0x00);
} }
_spiModem.endTransaction(); _spiModem->endTransaction();
digitalWrite(_ss, HIGH); digitalWrite(_ss, HIGH);
} }
@ -261,17 +261,17 @@ void sx126x::writeBuffer(const uint8_t* buffer, size_t size)
digitalWrite(_ss, LOW); digitalWrite(_ss, LOW);
_spiModem.beginTransaction(_spiSettings); _spiModem->beginTransaction(_spiSettings);
_spiModem.transfer(OP_FIFO_WRITE_6X); _spiModem->transfer(OP_FIFO_WRITE_6X);
_spiModem.transfer(_fifo_tx_addr_ptr); _spiModem->transfer(_fifo_tx_addr_ptr);
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
{ {
_spiModem.transfer(buffer[i]); _spiModem->transfer(buffer[i]);
_fifo_tx_addr_ptr++; _fifo_tx_addr_ptr++;
} }
_spiModem.endTransaction(); _spiModem->endTransaction();
digitalWrite(_ss, HIGH); digitalWrite(_ss, HIGH);
} }
@ -282,17 +282,17 @@ void sx126x::readBuffer(uint8_t* buffer, size_t size)
digitalWrite(_ss, LOW); digitalWrite(_ss, LOW);
_spiModem.beginTransaction(_spiSettings); _spiModem->beginTransaction(_spiSettings);
_spiModem.transfer(OP_FIFO_READ_6X); _spiModem->transfer(OP_FIFO_READ_6X);
_spiModem.transfer(_fifo_rx_addr_ptr); _spiModem->transfer(_fifo_rx_addr_ptr);
_spiModem.transfer(0x00); _spiModem->transfer(0x00);
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
{ {
buffer[i] = _spiModem.transfer(0x00); buffer[i] = _spiModem->transfer(0x00);
} }
_spiModem.endTransaction(); _spiModem->endTransaction();
digitalWrite(_ss, HIGH); digitalWrite(_ss, HIGH);
} }
@ -451,7 +451,7 @@ void sx126x::end()
sleep(); sleep();
// stop SPI // stop SPI
_spiModem.end(); _spiModem->end();
_bitrate = 0; _bitrate = 0;
@ -676,7 +676,7 @@ void sx126x::onReceive(void(*callback)(uint8_t, int))
executeOpcode(OP_SET_IRQ_FLAGS_6X, buf, 8); executeOpcode(OP_SET_IRQ_FLAGS_6X, buf, 8);
#ifdef SPI_HAS_NOTUSINGINTERRUPT #ifdef SPI_HAS_NOTUSINGINTERRUPT
_spiModem.usingInterrupt(digitalPinToInterrupt(_dio0)); _spiModem->usingInterrupt(digitalPinToInterrupt(_dio0));
#endif #endif
// make function available // make function available
extern void onDio0Rise(); extern void onDio0Rise();
@ -685,7 +685,7 @@ void sx126x::onReceive(void(*callback)(uint8_t, int))
} else { } else {
detachInterrupt(digitalPinToInterrupt(_dio0)); detachInterrupt(digitalPinToInterrupt(_dio0));
#ifdef SPI_HAS_NOTUSINGINTERRUPT #ifdef SPI_HAS_NOTUSINGINTERRUPT
_spiModem.notUsingInterrupt(digitalPinToInterrupt(_dio0)); _spiModem->notUsingInterrupt(digitalPinToInterrupt(_dio0));
#endif #endif
} }
} }
@ -1081,7 +1081,7 @@ void sx126x::clearIRQStatus() {
#define SYNC_WORD_7X 0x12 #define SYNC_WORD_7X 0x12
sx127x::sx127x(uint8_t index, SPIClass spi, int ss, int sclk, int mosi, int miso, int reset, int dio0, int busy) : sx127x::sx127x(uint8_t index, SPIClass* spi, int ss, int sclk, int mosi, int miso, int reset, int dio0, int busy) :
RadioInterface(index), RadioInterface(index),
_spiSettings(8E6, MSBFIRST, SPI_MODE0), _spiSettings(8E6, MSBFIRST, SPI_MODE0),
_spiModem(spi), _spiModem(spi),
@ -1116,12 +1116,12 @@ bool sx127x::preInit() {
// todo: check if this change causes issues on any platforms // todo: check if this change causes issues on any platforms
#if MCU_VARIANT == MCU_ESP32 #if MCU_VARIANT == MCU_ESP32
if (_sclk != -1 && _miso != -1 && _mosi != -1 && _ss != -1) { if (_sclk != -1 && _miso != -1 && _mosi != -1 && _ss != -1) {
_spiModem.begin(_sclk, _miso, _mosi, _ss); _spiModem->begin(_sclk, _miso, _mosi, _ss);
} else { } else {
_spiModem.begin(); _spiModem->begin();
} }
#else #else
_spiModem.begin(); _spiModem->begin();
#endif #endif
// Check modem version // Check modem version
@ -1143,10 +1143,10 @@ uint8_t ISR_VECT sx127x::singleTransfer(uint8_t address, uint8_t value) {
uint8_t response; uint8_t response;
digitalWrite(_ss, LOW); digitalWrite(_ss, LOW);
_spiModem.beginTransaction(_spiSettings); _spiModem->beginTransaction(_spiSettings);
_spiModem.transfer(address); _spiModem->transfer(address);
response = _spiModem.transfer(value); response = _spiModem->transfer(value);
_spiModem.endTransaction(); _spiModem->endTransaction();
digitalWrite(_ss, HIGH); digitalWrite(_ss, HIGH);
return response; return response;
@ -1193,7 +1193,7 @@ int sx127x::begin() {
void sx127x::end() { void sx127x::end() {
sleep(); sleep();
_spiModem.end(); _spiModem->end();
_bitrate = 0; _bitrate = 0;
_radio_online = false; _radio_online = false;
_preinit_done = false; _preinit_done = false;
@ -1331,7 +1331,7 @@ void sx127x::onReceive(void(*callback)(uint8_t, int)) {
writeRegister(REG_DIO_MAPPING_1_7X, 0x00); writeRegister(REG_DIO_MAPPING_1_7X, 0x00);
#ifdef SPI_HAS_NOTUSINGINTERRUPT #ifdef SPI_HAS_NOTUSINGINTERRUPT
_spiModem.usingInterrupt(digitalPinToInterrupt(_dio0)); _spiModem->usingInterrupt(digitalPinToInterrupt(_dio0));
#endif #endif
// make function available // make function available
@ -1343,7 +1343,7 @@ void sx127x::onReceive(void(*callback)(uint8_t, int)) {
detachInterrupt(digitalPinToInterrupt(_dio0)); detachInterrupt(digitalPinToInterrupt(_dio0));
#ifdef SPI_HAS_NOTUSINGINTERRUPT #ifdef SPI_HAS_NOTUSINGINTERRUPT
_spiModem.notUsingInterrupt(digitalPinToInterrupt(_dio0)); _spiModem->notUsingInterrupt(digitalPinToInterrupt(_dio0));
#endif #endif
} }
} }
@ -1599,7 +1599,7 @@ void sx127x::clearIRQStatus() {
#define FREQ_DIV_8X (double)pow(2.0, 18.0) #define FREQ_DIV_8X (double)pow(2.0, 18.0)
#define FREQ_STEP_8X (double)(XTAL_FREQ_8X / FREQ_DIV_8X) #define FREQ_STEP_8X (double)(XTAL_FREQ_8X / FREQ_DIV_8X)
sx128x::sx128x(uint8_t index, SPIClass spi, bool tcxo, int ss, int sclk, int mosi, int miso, int reset, int dio0, int busy, int rxen, int txen) : sx128x::sx128x(uint8_t index, SPIClass* spi, bool tcxo, int ss, int sclk, int mosi, int miso, int reset, int dio0, int busy, int rxen, int txen) :
RadioInterface(index), RadioInterface(index),
_spiSettings(8E6, MSBFIRST, SPI_MODE0), _spiSettings(8E6, MSBFIRST, SPI_MODE0),
_spiModem(spi), _spiModem(spi),
@ -1626,12 +1626,12 @@ bool sx128x::preInit() {
// todo: check if this change causes issues on any platforms // todo: check if this change causes issues on any platforms
#if MCU_VARIANT == MCU_ESP32 #if MCU_VARIANT == MCU_ESP32
if (_sclk != -1 && _miso != -1 && _mosi != -1 && _ss != -1) { if (_sclk != -1 && _miso != -1 && _mosi != -1 && _ss != -1) {
_spiModem.begin(_sclk, _miso, _mosi, _ss); _spiModem->begin(_sclk, _miso, _mosi, _ss);
} else { } else {
_spiModem.begin(); _spiModem->begin();
} }
#else #else
_spiModem.begin(); _spiModem->begin();
#endif #endif
// check version (retry for up to 2 seconds) // check version (retry for up to 2 seconds)
@ -1676,15 +1676,15 @@ uint8_t ISR_VECT sx128x::singleTransfer(uint8_t opcode, uint16_t address, uint8_
digitalWrite(_ss, LOW); digitalWrite(_ss, LOW);
_spiModem.beginTransaction(_spiSettings); _spiModem->beginTransaction(_spiSettings);
_spiModem.transfer(opcode); _spiModem->transfer(opcode);
_spiModem.transfer((address & 0xFF00) >> 8); _spiModem->transfer((address & 0xFF00) >> 8);
_spiModem.transfer(address & 0x00FF); _spiModem->transfer(address & 0x00FF);
if (opcode == OP_READ_REGISTER_8X) { if (opcode == OP_READ_REGISTER_8X) {
_spiModem.transfer(0x00); _spiModem->transfer(0x00);
} }
response = _spiModem.transfer(value); response = _spiModem->transfer(value);
_spiModem.endTransaction(); _spiModem->endTransaction();
digitalWrite(_ss, HIGH); digitalWrite(_ss, HIGH);
@ -1734,15 +1734,15 @@ void sx128x::executeOpcode(uint8_t opcode, uint8_t *buffer, uint8_t size)
digitalWrite(_ss, LOW); digitalWrite(_ss, LOW);
_spiModem.beginTransaction(_spiSettings); _spiModem->beginTransaction(_spiSettings);
_spiModem.transfer(opcode); _spiModem->transfer(opcode);
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
{ {
_spiModem.transfer(buffer[i]); _spiModem->transfer(buffer[i]);
} }
_spiModem.endTransaction(); _spiModem->endTransaction();
digitalWrite(_ss, HIGH); digitalWrite(_ss, HIGH);
} }
@ -1753,16 +1753,16 @@ void sx128x::executeOpcodeRead(uint8_t opcode, uint8_t *buffer, uint8_t size)
digitalWrite(_ss, LOW); digitalWrite(_ss, LOW);
_spiModem.beginTransaction(_spiSettings); _spiModem->beginTransaction(_spiSettings);
_spiModem.transfer(opcode); _spiModem->transfer(opcode);
_spiModem.transfer(0x00); _spiModem->transfer(0x00);
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
{ {
buffer[i] = _spiModem.transfer(0x00); buffer[i] = _spiModem->transfer(0x00);
} }
_spiModem.endTransaction(); _spiModem->endTransaction();
digitalWrite(_ss, HIGH); digitalWrite(_ss, HIGH);
} }
@ -1773,17 +1773,17 @@ void sx128x::writeBuffer(const uint8_t* buffer, size_t size)
digitalWrite(_ss, LOW); digitalWrite(_ss, LOW);
_spiModem.beginTransaction(_spiSettings); _spiModem->beginTransaction(_spiSettings);
_spiModem.transfer(OP_FIFO_WRITE_8X); _spiModem->transfer(OP_FIFO_WRITE_8X);
_spiModem.transfer(_fifo_tx_addr_ptr); _spiModem->transfer(_fifo_tx_addr_ptr);
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
{ {
_spiModem.transfer(buffer[i]); _spiModem->transfer(buffer[i]);
_fifo_tx_addr_ptr++; _fifo_tx_addr_ptr++;
} }
_spiModem.endTransaction(); _spiModem->endTransaction();
digitalWrite(_ss, HIGH); digitalWrite(_ss, HIGH);
} }
@ -1794,17 +1794,17 @@ void sx128x::readBuffer(uint8_t* buffer, size_t size)
digitalWrite(_ss, LOW); digitalWrite(_ss, LOW);
_spiModem.beginTransaction(_spiSettings); _spiModem->beginTransaction(_spiSettings);
_spiModem.transfer(OP_FIFO_READ_8X); _spiModem->transfer(OP_FIFO_READ_8X);
_spiModem.transfer(_fifo_rx_addr_ptr); _spiModem->transfer(_fifo_rx_addr_ptr);
_spiModem.transfer(0x00); _spiModem->transfer(0x00);
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
{ {
buffer[i] = _spiModem.transfer(0x00); buffer[i] = _spiModem->transfer(0x00);
} }
_spiModem.endTransaction(); _spiModem->endTransaction();
digitalWrite(_ss, HIGH); digitalWrite(_ss, HIGH);
} }
@ -1921,7 +1921,7 @@ void sx128x::end()
sleep(); sleep();
// stop SPI // stop SPI
_spiModem.end(); _spiModem->end();
_bitrate = 0; _bitrate = 0;
@ -2130,7 +2130,7 @@ void sx128x::onReceive(void(*callback)(uint8_t, int))
executeOpcode(OP_SET_IRQ_FLAGS_8X, buf, 8); executeOpcode(OP_SET_IRQ_FLAGS_8X, buf, 8);
//#ifdef SPI_HAS_NOTUSINGINTERRUPT //#ifdef SPI_HAS_NOTUSINGINTERRUPT
// _spiModem.usingInterrupt(digitalPinToInterrupt(_dio0)); // _spiModem->usingInterrupt(digitalPinToInterrupt(_dio0));
//#endif //#endif
// make function available // make function available
@ -2140,7 +2140,7 @@ void sx128x::onReceive(void(*callback)(uint8_t, int))
} else { } else {
detachInterrupt(digitalPinToInterrupt(_dio0)); detachInterrupt(digitalPinToInterrupt(_dio0));
//#ifdef SPI_HAS_NOTUSINGINTERRUPT //#ifdef SPI_HAS_NOTUSINGINTERRUPT
// _spiModem.notUsingInterrupt(digitalPinToInterrupt(_dio0)); // _spiModem->notUsingInterrupt(digitalPinToInterrupt(_dio0));
//#endif //#endif
} }
} }

View File

@ -333,7 +333,7 @@ protected:
class sx126x : public RadioInterface { class sx126x : public RadioInterface {
public: public:
sx126x(uint8_t index, SPIClass spi, bool tcxo, bool dio2_as_rf_switch, int ss, int sclk, int mosi, int miso, int reset, int sx126x(uint8_t index, SPIClass* spi, bool tcxo, bool dio2_as_rf_switch, int ss, int sclk, int mosi, int miso, int reset, int
dio0, int busy, int rxen); dio0, int busy, int rxen);
int begin(); int begin();
@ -425,7 +425,7 @@ private:
private: private:
SPISettings _spiSettings; SPISettings _spiSettings;
SPIClass _spiModem; SPIClass* _spiModem;
int _ss; int _ss;
int _sclk; int _sclk;
int _mosi; int _mosi;
@ -454,7 +454,7 @@ private:
class sx127x : public RadioInterface { class sx127x : public RadioInterface {
public: public:
sx127x(uint8_t index, SPIClass spi, int ss, int sclk, int mosi, int miso, int reset, int dio0, int busy); sx127x(uint8_t index, SPIClass* spi, int ss, int sclk, int mosi, int miso, int reset, int dio0, int busy);
int begin(); int begin();
void end(); void end();
@ -529,7 +529,7 @@ private:
private: private:
SPISettings _spiSettings; SPISettings _spiSettings;
SPIClass _spiModem; SPIClass* _spiModem;
int _ss; int _ss;
int _sclk; int _sclk;
int _mosi; int _mosi;
@ -548,7 +548,7 @@ private:
class sx128x : public RadioInterface { class sx128x : public RadioInterface {
public: public:
sx128x(uint8_t index, SPIClass spi, bool tcxo, int ss, int sclk, int mosi, int miso, int reset, int dio0, int busy, int rxen, int txen); sx128x(uint8_t index, SPIClass* spi, bool tcxo, int ss, int sclk, int mosi, int miso, int reset, int dio0, int busy, int rxen, int txen);
int begin(); int begin();
void end(); void end();
@ -636,7 +636,7 @@ private:
private: private:
SPISettings _spiSettings; SPISettings _spiSettings;
SPIClass _spiModem; SPIClass* _spiModem;
int _ss; int _ss;
int _sclk; int _sclk;
int _mosi; int _mosi;

View File

@ -13,7 +13,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "Radio.h" #include "Radio.hpp"
#include "Config.h" #include "Config.h"
// Included for sorting // Included for sorting