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

Commit

Permalink
sx127x: Implement Tcxo configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
plaes committed Oct 26, 2023
1 parent 80a68ef commit d90b0d3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/sx1276_7_8_9/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pub enum Sx127xVariant {
pub struct Config {
/// LoRa chip used on specific board
pub chip: Sx127xVariant,
/// Whether board is using crystal oscillator or external clock
pub tcxo_used: bool,
}

/// Base for the RadioKind implementation for the LoRa chip kind and board type
Expand Down Expand Up @@ -277,7 +279,16 @@ where
}

async fn set_oscillator(&mut self) -> Result<(), RadioError> {
self.write_register(Register::RegTcxo, TCXO_FOR_OSCILLATOR, false).await
if !self.config.tcxo_used {
return Ok(());
}

// Configure Tcxo as input
let reg = match self.config.chip {
Sx127xVariant::Sx1272 => Register::RegTcxoSX1272,
Sx127xVariant::Sx1276_7_8_9 => Register::RegTcxoSX1276,
};
self.write_register(reg, TCXO_FOR_OSCILLATOR, false).await
}

async fn set_regulator_mode(&mut self) -> Result<(), RadioError> {
Expand Down
3 changes: 2 additions & 1 deletion src/sx1276_7_8_9/radio_kind_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@ pub enum Register {
RegInvertiq2 = 0x3b,
RegDioMapping1 = 0x40,
RegVersion = 0x42,
RegTcxo = 0x4b,
RegPaDacSX1272 = 0x5a,
RegPaDacSX1276 = 0x4d,
RegTcxoSX1276 = 0x4b,
RegTcxoSX1272 = 0x58,
}

impl Register {
Expand Down

0 comments on commit d90b0d3

Please sign in to comment.