Fixed intermittent init failure on AVR

This commit is contained in:
Mark Qvist 2023-02-18 12:14:15 +01:00
parent 7211a3423c
commit 2b37fa7454
2 changed files with 26 additions and 18 deletions

View File

@ -19,7 +19,7 @@
#define CONFIG_H #define CONFIG_H
#define MAJ_VERS 0x01 #define MAJ_VERS 0x01
#define MIN_VERS 0x39 #define MIN_VERS 0x3A
#define PLATFORM_AVR 0x90 #define PLATFORM_AVR 0x90
#define PLATFORM_ESP32 0x80 #define PLATFORM_ESP32 0x80

View File

@ -88,25 +88,33 @@ void setup() {
// pins for the LoRa module // pins for the LoRa module
LoRa.setPins(pin_cs, pin_reset, pin_dio); LoRa.setPins(pin_cs, pin_reset, pin_dio);
if (LoRa.preInit()) { #if MCU_VARIANT == MCU_ESP32
sx1276_installed = true; // Check installed transceiver chip and
uint32_t lfr = LoRa.getFrequency(); // probe boot parameters.
if (lfr == 0) { if (LoRa.preInit()) {
// Normal boot sx1276_installed = true;
} else if (lfr == M_FRQ_R) { uint32_t lfr = LoRa.getFrequency();
// Quick reboot if (lfr == 0) {
#if HAS_CONSOLE // Normal boot
if (rtc_get_reset_reason(0) == POWERON_RESET) { } else if (lfr == M_FRQ_R) {
console_active = true; // Quick reboot
} #if HAS_CONSOLE
#endif if (rtc_get_reset_reason(0) == POWERON_RESET) {
console_active = true;
}
#endif
} else {
// Unknown boot
}
LoRa.setFrequency(M_FRQ_S);
} else { } else {
// Unknown boot sx1276_installed = false;
} }
LoRa.setFrequency(M_FRQ_S); #else
} else { // Older variants only came with SX1276/78 chips,
sx1276_installed = false; // so assume that to be the case for now.
} sx1276_installed = true;
#endif
#if HAS_DISPLAY #if HAS_DISPLAY
disp_ready = display_init(); disp_ready = display_init();