From f3bb8fe52246694b29996bb1a8521abf67bf20bf Mon Sep 17 00:00:00 2001 From: Priit Laes Date: Tue, 28 Nov 2023 16:18:03 +0200 Subject: [PATCH 1/3] sx126x: Make sure to export TcxoCtrlVoltage --- src/sx1261_2/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sx1261_2/mod.rs b/src/sx1261_2/mod.rs index ea81f8b..21eaa20 100644 --- a/src/sx1261_2/mod.rs +++ b/src/sx1261_2/mod.rs @@ -3,6 +3,7 @@ mod radio_kind_params; use defmt::debug; use embedded_hal_async::delay::DelayUs; use embedded_hal_async::spi::*; +pub use radio_kind_params::TcxoCtrlVoltage; use radio_kind_params::*; use crate::mod_params::*; From aba4c975a5df7128a2ca2e89171e0d70b912acf1 Mon Sep 17 00:00:00 2001 From: Priit Laes Date: Tue, 28 Nov 2023 16:18:31 +0200 Subject: [PATCH 2/3] sx126x: Use correct spelling for tcxo --- src/sx1261_2/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sx1261_2/mod.rs b/src/sx1261_2/mod.rs index 21eaa20..4162840 100644 --- a/src/sx1261_2/mod.rs +++ b/src/sx1261_2/mod.rs @@ -50,7 +50,7 @@ pub struct Config { /// LoRa chip variant on this board pub chip: Sx126xVariant, /// Configuration for TCXO and its voltage selection - pub txco_ctrl: Option, + pub tcxo_ctrl: Option, } /// Base for the RadioKind implementation for the LoRa chip kind and board type @@ -306,7 +306,7 @@ where } async fn set_oscillator(&mut self) -> Result<(), RadioError> { - if let Some(voltage) = self.config.txco_ctrl { + if let Some(voltage) = self.config.tcxo_ctrl { let timeout = BRD_TCXO_WAKEUP_TIME << 6; // duration allowed for TCXO to reach 32MHz let op_code_and_tcxo_control = [ OpCode::SetTCXOMode.value(), From 4aead11d4a4ff10ff3f11279ebf90b341ae98ff7 Mon Sep 17 00:00:00 2001 From: Priit Laes Date: Tue, 28 Nov 2023 19:44:36 +0200 Subject: [PATCH 3/3] sx126x: Make DC-DC / LDO configurable --- src/sx1261_2/mod.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/sx1261_2/mod.rs b/src/sx1261_2/mod.rs index 4162840..4a3e663 100644 --- a/src/sx1261_2/mod.rs +++ b/src/sx1261_2/mod.rs @@ -51,6 +51,8 @@ pub struct Config { pub chip: Sx126xVariant, /// Configuration for TCXO and its voltage selection pub tcxo_ctrl: Option, + /// Whether board is using optional DCDC in addition to LDO + pub use_dcdc: bool, } /// Base for the RadioKind implementation for the LoRa chip kind and board type @@ -321,10 +323,14 @@ where Ok(()) } - // Set the power regulators operating mode to DC_DC. Using only LDO implies that the Rx/Tx current is doubled. async fn set_regulator_mode(&mut self) -> Result<(), RadioError> { - let op_code_and_regulator_mode = [OpCode::SetRegulatorMode.value(), RegulatorMode::UseDCDC.value()]; - self.intf.write(&op_code_and_regulator_mode, false).await + // SX1261/2 can use optional DC-DC to reduce power usage, + // but this is related to the hardware implementation of the board. + if self.config.use_dcdc { + let reg_data = [OpCode::SetRegulatorMode.value(), RegulatorMode::UseDCDC.value()]; + self.intf.write(®_data, false).await?; + } + Ok(()) } async fn set_tx_rx_buffer_base_address(