From 2b37fa7454666db2868f86d9dda373399f393443 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sat, 18 Feb 2023 12:14:15 +0100 Subject: [PATCH] Fixed intermittent init failure on AVR --- Config.h | 2 +- RNode_Firmware.ino | 42 +++++++++++++++++++++++++----------------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/Config.h b/Config.h index 719e6d8..3d5c834 100644 --- a/Config.h +++ b/Config.h @@ -19,7 +19,7 @@ #define CONFIG_H #define MAJ_VERS 0x01 - #define MIN_VERS 0x39 + #define MIN_VERS 0x3A #define PLATFORM_AVR 0x90 #define PLATFORM_ESP32 0x80 diff --git a/RNode_Firmware.ino b/RNode_Firmware.ino index 929a7cf..b48e4c3 100644 --- a/RNode_Firmware.ino +++ b/RNode_Firmware.ino @@ -88,25 +88,33 @@ void setup() { // pins for the LoRa module LoRa.setPins(pin_cs, pin_reset, pin_dio); - if (LoRa.preInit()) { - sx1276_installed = true; - uint32_t lfr = LoRa.getFrequency(); - if (lfr == 0) { - // Normal boot - } else if (lfr == M_FRQ_R) { - // Quick reboot - #if HAS_CONSOLE - if (rtc_get_reset_reason(0) == POWERON_RESET) { - console_active = true; - } - #endif + #if MCU_VARIANT == MCU_ESP32 + // Check installed transceiver chip and + // probe boot parameters. + if (LoRa.preInit()) { + sx1276_installed = true; + uint32_t lfr = LoRa.getFrequency(); + if (lfr == 0) { + // Normal boot + } else if (lfr == M_FRQ_R) { + // Quick reboot + #if HAS_CONSOLE + if (rtc_get_reset_reason(0) == POWERON_RESET) { + console_active = true; + } + #endif + } else { + // Unknown boot + } + LoRa.setFrequency(M_FRQ_S); } else { - // Unknown boot + sx1276_installed = false; } - LoRa.setFrequency(M_FRQ_S); - } else { - sx1276_installed = false; - } + #else + // Older variants only came with SX1276/78 chips, + // so assume that to be the case for now. + sx1276_installed = true; + #endif #if HAS_DISPLAY disp_ready = display_init();