From 9c8f5cbfef19be68609dd7fd190d331c8a27536e Mon Sep 17 00:00:00 2001 From: "jacob.eva" Date: Wed, 1 Jan 2025 17:29:47 +0000 Subject: [PATCH] Enable SX1272/6/8 support again --- Boards.h | 4 +-- Interfaces.h | 5 ++-- RNode_Firmware_CE.ino | 63 +++++++++++++++++++------------------------ 3 files changed, 32 insertions(+), 40 deletions(-) diff --git a/Boards.h b/Boards.h index c4b2f72..0f18411 100644 --- a/Boards.h +++ b/Boards.h @@ -290,7 +290,7 @@ }; #elif BOARD_MODEL == BOARD_LORA32_V2_1 - #define HAS_DISPLAY true + #define HAS_DISPLAY false #define DISPLAY OLED #define HAS_BLUETOOTH true #define HAS_BLE true @@ -299,7 +299,7 @@ #define HAS_EEPROM true #define INTERFACE_COUNT 1 - const uint8_t interfaces[INTERFACE_COUNT] = {SX127X}; + const uint8_t interfaces[INTERFACE_COUNT] = {INT_SX1276}; #if HAS_TCXO == true const bool interface_cfg[INTERFACE_COUNT][3] = { // SX127X diff --git a/Interfaces.h b/Interfaces.h index b243dcc..dc68d21 100644 --- a/Interfaces.h +++ b/Interfaces.h @@ -1,6 +1,7 @@ #define INT_SX127X 0x00 -#define INT_SX1276 0x01 -#define INT_SX1278 0x02 +#define INT_SX1272 0x01 +#define INT_SX1276 0x02 +#define INT_SX1278 0x03 #define INT_SX126X 0x10 #define INT_SX1262 0x11 #define INT_SX128X 0x20 diff --git a/RNode_Firmware_CE.ino b/RNode_Firmware_CE.ino index 8afd056..981e596 100644 --- a/RNode_Firmware_CE.ino +++ b/RNode_Firmware_CE.ino @@ -88,6 +88,19 @@ char sbuf[128]; uint8_t *packet_queue[INTERFACE_COUNT]; +void ISR_VECT packet_received() { + if (!tx_flag) { + for (int i = 0; i < INTERFACE_COUNT; i++) { + if (digitalRead(interface_pins[i][5])) { + receive_callback(interface_obj[i], i, interface_obj[i]->getPacketLength()); + break; + } + } + } else { + tx_flag = false; + } +} + void setup() { #if MCU_VARIANT == MCU_ESP32 boot_seq(); @@ -205,8 +218,7 @@ void setup() { break; } - // \todo CURRENTLY NOT SUPPORTED DUE TO REQUIREMENT FOR DIO1 pin in RadioLib, should be fixed soon... - /*case INT_SX1272: + case INT_SX1272: { SX1272* radio; if (interface_cfg[i][0]) { @@ -227,7 +239,7 @@ void setup() { config->bw = 125.0; status = radio->begin(config->freq, config->bw, config->sf, config->cr, 0x12, config->txp); - radio->setDio1Action(packet_received); + radio->setDio1Action(packet_received, RISING); if (status == RADIOLIB_ERR_NONE) { status = radio->explicitHeader(); } @@ -248,8 +260,8 @@ void setup() { if (interface_cfg[i][0]) { radio = new SX1276(new Module(interface_pins[i][0], interface_pins[i][5], interface_pins[i][6], RADIOLIB_NC)); } else { + radio = new SX1276(new Module(interface_pins[i][0], interface_pins[i][5], interface_pins[i][6], RADIOLIB_NC, interface_spi[0])); interface_spi[0].begin(); - }radio = new SX1276(new Module(interface_pins[i][0], interface_pins[i][5], interface_pins[i][6], RADIOLIB_NC, interface_spi[0])); } interface_obj[i] = (PhysicalLayer*)radio; @@ -261,9 +273,10 @@ void setup() { config->sf = 7; config->cr = 7; config->bw = 125.0; + config->txp = 2; // txpower can only be set to minimum of 2dBm on this model status = radio->begin(config->freq, config->bw, config->sf, config->cr, 0x12, config->txp); - radio->setDio1Action(packet_received); + radio->setDio0Action(packet_received, RISING); if (status == RADIOLIB_ERR_NONE) { status = radio->explicitHeader(); } @@ -299,7 +312,7 @@ void setup() { config->bw = 125.0; status = radio->begin(config->freq, config->bw, config->sf, config->cr, 0x12, config->txp); - radio->setDio1Action(packet_received); + radio->setDio1Action(packet_received, RISING); if (status == RADIOLIB_ERR_NONE) { status = radio->explicitHeader(); } @@ -314,7 +327,6 @@ void setup() { } break; } - */ case INT_SX1280: { @@ -454,19 +466,6 @@ void setup() { validate_status(); } -void ISR_VECT packet_received() { - if (!tx_flag) { - for (int i = 0; i < INTERFACE_COUNT; i++) { - if (digitalRead(interface_pins[i][5])) { - receive_callback(interface_obj[i], i, interface_obj[i]->getPacketLength()); - break; - } - } - } else { - tx_flag = false; - } -} - inline void kiss_write_packet(int index) { // We need to convert the interface index to the command byte representation uint8_t cmd_byte = getInterfaceCommandByte(index); @@ -593,9 +592,16 @@ bool startRadio(PhysicalLayer* radio, uint8_t index) { update_radio_params(radio, config); radio->setFrequency(config->freq); break; + case INT_SX1272: case INT_SX1276: case INT_SX1278: - // \todo + // wake up module + digitalWrite(interface_pins[index][0], LOW); + delay(10); + digitalWrite(interface_pins[index][0], HIGH); + status = radio->standby(); + update_radio_params(radio, config); + radio->setFrequency(config->freq); break; case INT_SX1280: // wake up module @@ -1288,21 +1294,6 @@ void serialCallback(uint8_t sbyte) { } #endif - } else if (command == CMD_FW_LENGTH) { - if (sbyte == FESC) { - ESCAPE = true; - } else { - if (ESCAPE) { - if (sbyte == TFEND) sbyte = FEND; - if (sbyte == TFESC) sbyte = FESC; - ESCAPE = false; - } - if (frame_len < CMD_L) cmdbuf[frame_len++] = sbyte; - } - - if (frame_len == FW_LENGTH_LEN) { - set_fw_length(cmdbuf); - } } } }