diff --git a/src/internal_state.rs b/src/internal_state.rs index 8cd9d54d4ffc43c847db91419308096bffa2b6b6..43dab00dfb6a93c4686fc49ae3588b3ffe5c2974 100644 --- a/src/internal_state.rs +++ b/src/internal_state.rs @@ -1,5 +1,6 @@ // Tracks the state of our instance, *not* the state of the radio. -pub(crate) enum InternalState<const PACKET_LEN: usize> { +#[derive(Debug)] +pub enum InternalState<const PACKET_LEN: usize> { Idle, Rx { data: [u8; PACKET_LEN], diff --git a/src/lib.rs b/src/lib.rs index 68e415da094946df33fdad46bce57b43ca9e7c64..afcf228a6d64139e1c8bbbf6a6c399b351126d87 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -171,6 +171,10 @@ where } pub fn interrupt(&mut self) -> Result<(), TransferError<Spi::Error>> { + if self.radio.fifo_underflow_pending().te()? { + return Err(TransferError::FifoOverflow); + } + match &mut self.state { InternalState::Idle => { // we were not expecting an interrupt @@ -252,6 +256,7 @@ where InternalState::Tx { data, i, .. } => (data, i), _ => return Ok(()), }; + // only look at the slice we haven't sent yet let data = &mut data[*i..];