diff --git a/src/mesh/STM32WLE5JCInterface.cpp b/src/mesh/STM32WLE5JCInterface.cpp index f6e4b3512a2..567cd4c00f0 100644 --- a/src/mesh/STM32WLE5JCInterface.cpp +++ b/src/mesh/STM32WLE5JCInterface.cpp @@ -19,8 +19,8 @@ bool STM32WLE5JCInterface::init() RadioLibInterface::init(); // https://github.com/Seeed-Studio/LoRaWan-E5-Node/blob/main/Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver/radio_driver.c -#if (!defined(_VARIANT_RAK3172_)) - setTCXOVoltage(1.7); +#if defined(SX126X_DIO3_TCXO_VOLTAGE) + setTCXOVoltage(SX126X_DIO3_TCXO_VOLTAGE); #endif lora.setRfSwitchTable(rfswitch_pins, rfswitch_table); @@ -29,6 +29,17 @@ bool STM32WLE5JCInterface::init() int res = lora.begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength, tcxoVoltage); +#if defined(TCXO_OPTIONAL) + // If a TCXO was requested but isn't actually populated (e.g. non-T RAK3172), retry on XTAL + if (res != RADIOLIB_ERR_NONE && res != RADIOLIB_ERR_CHIP_NOT_FOUND && tcxoVoltage > 0) { + LOG_WARN("STM32WLx init failed with TCXO Vref %fV (err %d), retrying without TCXO", tcxoVoltage, res); + setTCXOVoltage(0); + res = lora.begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength, tcxoVoltage); + if (res == RADIOLIB_ERR_NONE) + LOG_INFO("STM32WLx init success without TCXO (XTAL mode)"); + } +#endif + LOG_INFO("STM32WLx init result %d", res); LOG_INFO("Frequency set to %f", getFreq()); diff --git a/variants/stm32/CDEBYTE_E77-MBL/variant.h b/variants/stm32/CDEBYTE_E77-MBL/variant.h index 686326137a7..b2f84f23536 100644 --- a/variants/stm32/CDEBYTE_E77-MBL/variant.h +++ b/variants/stm32/CDEBYTE_E77-MBL/variant.h @@ -22,4 +22,11 @@ Do not expect a working Meshtastic device with this target. #define SERIAL_PRINT_PORT 1 #define EBYTE_E77_MBL + +// LoRa +// Hardware varies by unit: SN >= 3202995 has a TCXO, older units have XTAL only - +// https://github.com/olliw42/mLRS-docu/blob/main/docs/EBYTE_E77_MBL.md +#define TCXO_OPTIONAL +#define SX126X_DIO3_TCXO_VOLTAGE 1.7 + #endif diff --git a/variants/stm32/rak3172/variant.h b/variants/stm32/rak3172/variant.h index 75e3e0c919e..4d718333789 100644 --- a/variants/stm32/rak3172/variant.h +++ b/variants/stm32/rak3172/variant.h @@ -24,4 +24,10 @@ Do not expect a working Meshtastic device with this target. #define RAK3172 #define SERIAL_PRINT_PORT 1 +// LoRa +// RAK3172: no TCXO, RAK3172-T: 3.0V TCXO - +// https://github.com/RAKWireless/RAK-STM32-RUI/blob/e5a28be8fab1a492bd9223dd425ca33a8a297d90/variants/WisDuo_RAK3172-T_Board/radio_conf.h#L91 +#define TCXO_OPTIONAL +#define SX126X_DIO3_TCXO_VOLTAGE 3.0 + #endif diff --git a/variants/stm32/wio-e5/variant.h b/variants/stm32/wio-e5/variant.h index da2c623fb3b..ad733ff5f49 100644 --- a/variants/stm32/wio-e5/variant.h +++ b/variants/stm32/wio-e5/variant.h @@ -19,4 +19,8 @@ Do not expect a working Meshtastic device with this target. #define WIO_E5 +// LoRa +// https://github.com/Seeed-Studio/LoRaWan-E5-Node/blob/163c05379b1805dd8f2c061d4557a69985acc953/Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver/radio_driver.c#L94 +#define SX126X_DIO3_TCXO_VOLTAGE 1.7 + #endif