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

fifo check on interrupt

parent a96d7e33
No related branches found
No related tags found
No related merge requests found
// Tracks the state of our instance, *not* the state of the radio. // 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, Idle,
Rx { Rx {
data: [u8; PACKET_LEN], data: [u8; PACKET_LEN],
......
...@@ -171,6 +171,10 @@ where ...@@ -171,6 +171,10 @@ where
} }
pub fn interrupt(&mut self) -> Result<(), TransferError<Spi::Error>> { pub fn interrupt(&mut self) -> Result<(), TransferError<Spi::Error>> {
if self.radio.fifo_underflow_pending().te()? {
return Err(TransferError::FifoOverflow);
}
match &mut self.state { match &mut self.state {
InternalState::Idle => { InternalState::Idle => {
// we were not expecting an interrupt // we were not expecting an interrupt
...@@ -252,6 +256,7 @@ where ...@@ -252,6 +256,7 @@ where
InternalState::Tx { data, i, .. } => (data, i), InternalState::Tx { data, i, .. } => (data, i),
_ => return Ok(()), _ => return Ok(()),
}; };
// only look at the slice we haven't sent yet // only look at the slice we haven't sent yet
let data = &mut data[*i..]; let data = &mut data[*i..];
......
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