Skip to content

Commit

Permalink
Make RegFifoTxBaseAddr and RegFifoRxBaseAddr registers use configurable
Browse files Browse the repository at this point in the history
In LoRa::new these are set to 0 which is not default (RegFifoTxBaseAddr
is 0x80 after reset). This however cannot be modified after LoRa
structure creation - so e.g. in LoRa::configure it cannot be configured
back to the same value (0) as in LoRa::new.
  • Loading branch information
akloboucnik committed Aug 10, 2022
1 parent 967c7e7 commit b49fa4c
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ where
if version == VERSION_CHECK {
sx127x.set_mode(RadioMode::Sleep)?;
sx127x.set_frequency(frequency)?;
sx127x.write_register(Register::RegFifoTxBaseAddr.addr(), 0)?;
sx127x.write_register(Register::RegFifoRxBaseAddr.addr(), 0)?;
sx127x.set_fifo_tx_base(0)?;
sx127x.set_fifo_rx_base(0)?;
let lna = sx127x.read_register(Register::RegLna.addr())?;
sx127x.write_register(Register::RegLna.addr(), lna | 0x03)?;
sx127x.write_register(Register::RegModemConfig3.addr(), 0x04)?;
Expand Down Expand Up @@ -734,6 +734,22 @@ where

self.write_register(Register::RegPaRamp as u8, pa_ramp)
}

pub fn set_fifo_rx_base(
&mut self,
base_addr: u8,
) -> Result<(), Error<E, CS::Error, RESET::Error>> {
self.write_register(Register::RegFifoRxBaseAddr.addr(), base_addr)?;
Ok(())
}

pub fn set_fifo_tx_base(
&mut self,
base_addr: u8,
) -> Result<(), Error<E, CS::Error, RESET::Error>> {
self.write_register(Register::RegFifoTxBaseAddr.addr(), base_addr)?;
Ok(())
}
}
/// Modes of the radio and their corresponding register values.
#[derive(Clone, Copy)]
Expand Down

0 comments on commit b49fa4c

Please sign in to comment.