Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lora: Make sx126x antenna rx/tx pins optional #1216

Closed
wants to merge 2 commits 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
5 changes: 2 additions & 3 deletions embassy-lora/src/sx126x/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ where
spi: SPI,
cs: CTRL,
reset: CTRL,
antenna_rx: CTRL,
antenna_tx: CTRL,
antenna_rx: Option<CTRL>,
antenna_tx: Option<CTRL>,
dio1: WAIT,
busy: WAIT,
enable_public_network: bool,
Expand Down Expand Up @@ -110,7 +110,6 @@ where
CTRL: 'm,
WAIT: 'm,
BUS: 'm;

fn rx<'m>(&'m mut self, config: RfConfig, receiving_buffer: &'m mut [u8]) -> Self::RxFuture<'m> {
trace!("RX START");
async move {
Expand Down
29 changes: 20 additions & 9 deletions embassy-lora/src/sx126x/sx126x_lora/board_specific.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ where

// Initialize the TCXO power pin
pub(super) async fn brd_io_tcxo_init(&mut self) -> Result<(), RadioError<BUS>> {
let timeout = self.brd_get_board_tcxo_wakeup_time() << 6;
self.sub_set_dio3_as_tcxo_ctrl(TcxoCtrlVoltage::Ctrl1V7, timeout)
.await?;
//let timeout = self.brd_get_board_tcxo_wakeup_time() << 6;
//self.sub_set_dio3_as_tcxo_ctrl(TcxoCtrlVoltage::Ctrl1V7, timeout).await?;
Ok(())
}

Expand Down Expand Up @@ -207,22 +206,34 @@ where

// Quiesce the antenna(s).
pub(super) fn brd_ant_sleep(&mut self) -> Result<(), RadioError<BUS>> {
self.antenna_tx.set_low().map_err(|_| AntTx)?;
self.antenna_rx.set_low().map_err(|_| AntRx)?;
if let Some(antenna_tx) = &mut self.antenna_tx {
antenna_tx.set_low().map_err(|_| AntTx)?;
}
if let Some(antenna_rx) = &mut self.antenna_rx {
antenna_rx.set_low().map_err(|_| AntRx)?;
}
Ok(())
}

// Prepare the antenna(s) for a receive operation
pub(super) fn brd_ant_set_rx(&mut self) -> Result<(), RadioError<BUS>> {
self.antenna_tx.set_low().map_err(|_| AntTx)?;
self.antenna_rx.set_high().map_err(|_| AntRx)?;
if let Some(antenna_tx) = &mut self.antenna_tx {
antenna_tx.set_low().map_err(|_| AntTx)?;
}
if let Some(antenna_rx) = &mut self.antenna_rx {
antenna_rx.set_high().map_err(|_| AntRx)?;
}
Ok(())
}

// Prepare the antenna(s) for a send operation
pub(super) fn brd_ant_set_tx(&mut self) -> Result<(), RadioError<BUS>> {
self.antenna_rx.set_low().map_err(|_| AntRx)?;
self.antenna_tx.set_high().map_err(|_| AntTx)?;
if let Some(antenna_tx) = &mut self.antenna_tx {
antenna_tx.set_low().map_err(|_| AntTx)?;
}
if let Some(antenna_rx) = &mut self.antenna_rx {
antenna_rx.set_high().map_err(|_| AntRx)?;
}
Ok(())
}

Expand Down
14 changes: 11 additions & 3 deletions embassy-lora/src/sx126x/sx126x_lora/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ pub struct LoRa<SPI, CTRL, WAIT> {
spi: SPI,
cs: CTRL,
reset: CTRL,
antenna_rx: CTRL,
antenna_tx: CTRL,
antenna_rx: Option<CTRL>,
antenna_tx: Option<CTRL>,
dio1: WAIT,
busy: WAIT,
operating_mode: RadioMode,
Expand All @@ -52,7 +52,15 @@ where
WAIT: Wait,
{
/// Builds and returns a new instance of the radio. Only one instance of the radio should exist at a time ()
pub fn new(spi: SPI, cs: CTRL, reset: CTRL, antenna_rx: CTRL, antenna_tx: CTRL, dio1: WAIT, busy: WAIT) -> Self {
pub fn new(
spi: SPI,
cs: CTRL,
reset: CTRL,
antenna_rx: Option<CTRL>,
antenna_tx: Option<CTRL>,
dio1: WAIT,
busy: WAIT,
) -> Self {
Self {
spi,
cs,
Expand Down