Skip to content
Snippets Groups Projects
Commit 9857af6e authored by Stephen D's avatar Stephen D
Browse files

fix bug when switching from rx to tx

parent 10d86731
No related branches found
No related tags found
No related merge requests found
Pipeline #3632 passed
...@@ -71,6 +71,10 @@ where ...@@ -71,6 +71,10 @@ where
self.radio.get_rssi() self.radio.get_rssi()
} }
pub fn sleep(&mut self) -> Result<(), RfError<Spi::Error>> {
self.radio.sleep()
}
pub fn set_channel(&mut self, channel: u8) { pub fn set_channel(&mut self, channel: u8) {
self.channel = channel; self.channel = channel;
} }
...@@ -160,6 +164,12 @@ where ...@@ -160,6 +164,12 @@ where
let len = tx_buf.len(); let len = tx_buf.len();
assert!(len < 8192, "Packet length cannot be above 8191 bytes"); assert!(len < 8192, "Packet length cannot be above 8191 bytes");
if matches!(self.state, InternalState::Rx { .. }) {
// if we're in the middle of rxing, we need to cancel that first
// otherwise it gets confused
self.radio.set_state(State::Sleep).txe()?;
}
self.radio.clear_fifo().txe()?; self.radio.clear_fifo().txe()?;
self.radio.clear_ph_and_modem_interrupts().txe()?; self.radio.clear_ph_and_modem_interrupts().txe()?;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment