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.
pub(crate) enum InternalState<const PACKET_LEN: usize> {
#[derive(Debug)]
pub enum InternalState<const PACKET_LEN: usize> {
Idle,
Rx {
data: [u8; PACKET_LEN],
......
......@@ -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..];
......
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