Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

sx126x: Make DIO2 functionality configurable #45

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/sx1261_2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ pub struct Config {
pub tcxo_ctrl: Option<TcxoCtrlVoltage>,
/// Whether board is using optional DCDC in addition to LDO
pub use_dcdc: bool,
/// Whether board is using DIO2 as RF switch (true) or as an IRQ
pub use_dio2_as_rfswitch: bool,
}

/// Base for the RadioKind implementation for the LoRa chip kind and board type
Expand Down Expand Up @@ -252,10 +254,11 @@ where

// Use DIO2 to control an RF Switch, depending on the board type.
async fn init_rf_switch(&mut self) -> Result<(), RadioError> {
if self.config.chip != Sx126xVariant::Stm32wl {
let op_code_and_indicator = [OpCode::SetRFSwitchMode.value(), true as u8];
self.intf.write(&op_code_and_indicator, false).await?;
}
let reg_data = [
OpCode::SetDIO2AsRfSwitchCtrl.value(),
self.config.use_dio2_as_rfswitch as u8,
];
self.intf.write(&reg_data, false).await?;
Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion src/sx1261_2/radio_kind_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pub enum OpCode {
ClrErrors = 0x07,
SetTCXOMode = 0x97,
SetTxFallbackMode = 0x93,
SetRFSwitchMode = 0x9D,
SetDIO2AsRfSwitchCtrl = 0x9d,
SetStopRxTimerOnPreamble = 0x9F,
SetLoRaSymbTimeout = 0xA0,
}
Expand Down