From b25db1f42c95f7b578fbe526c8c464e3bf2d5599 Mon Sep 17 00:00:00 2001 From: Andrik45719 Date: Thu, 6 Mar 2025 10:44:53 +0200 Subject: [PATCH] E22-400M SX126X_DIO3_TCXO_VOLTAGE fix (#6232) Added TCXO voltage setting for SX1268 based module to fix error: Calibration failed, device errors: 0x20 SX126x init result -707 --- src/main.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index a82fde4be..e5e1a2537 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1017,6 +1017,22 @@ void setup() #endif #if defined(USE_SX1268) +#if defined(SX126X_DIO3_TCXO_VOLTAGE) && defined(TCXO_OPTIONAL) + if ((!rIf) && (config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_LORA_24)) { + // try using the specified TCXO voltage + auto *sxIf = new SX1268Interface(RadioLibHAL, SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY); + sxIf->setTCXOVoltage(SX126X_DIO3_TCXO_VOLTAGE); + if (!sxIf->init()) { + LOG_WARN("No SX1268 radio with TCXO, Vref %fV", SX126X_DIO3_TCXO_VOLTAGE); + delete sxIf; + rIf = NULL; + } else { + LOG_INFO("SX1268 init success, TCXO, Vref %fV", SX126X_DIO3_TCXO_VOLTAGE); + rIf = sxIf; + radioType = SX1268_RADIO; + } + } +#endif if ((!rIf) && (config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_LORA_24)) { rIf = new SX1268Interface(RadioLibHAL, SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY); if (!rIf->init()) { @@ -1276,4 +1292,4 @@ void loop() } } -#endif \ No newline at end of file +#endif