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

variable length rx

parent 414f15b2
No related branches found
No related tags found
1 merge request!2Variable packet length
Pipeline #3371 passed
...@@ -81,10 +81,13 @@ where ...@@ -81,10 +81,13 @@ where
matches!(self.state, InternalState::Idle) matches!(self.state, InternalState::Idle)
} }
pub fn start_rx(&mut self, rx_forever: bool) -> Result<(), Spi::Error> { // Len is none when using a variable-length packet
pub fn start_rx(&mut self, len: Option<usize>, rx_forever: bool) -> Result<(), Spi::Error> {
self.radio.clear_fifo()?; self.radio.clear_fifo()?;
self.radio.clear_ph_and_modem_interrupts()?; self.radio.clear_ph_and_modem_interrupts()?;
let len = len.unwrap_or(0);
self.state = InternalState::Rx { self.state = InternalState::Rx {
data: [0; MAX_PACKET_LEN], data: [0; MAX_PACKET_LEN],
i: 0, i: 0,
...@@ -96,8 +99,8 @@ where ...@@ -96,8 +99,8 @@ where
START_RX, START_RX,
self.channel, self.channel,
0, 0,
(MAX_PACKET_LEN >> 8).try_into().unwrap(), (len >> 8).try_into().unwrap(),
(MAX_PACKET_LEN & 0xff).try_into().unwrap(), (len & 0xff).try_into().unwrap(),
State::Rx.into(), State::Rx.into(),
if rx_forever { if rx_forever {
State::Rx.into() State::Rx.into()
......
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