Skip to content

Commit 05f3e34

Browse files
committed
Move the bsy polling to check_send.
1 parent 9044ed1 commit 05f3e34

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

src/spi.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ where
400400
nb::Error::Other(Error::ModeFault)
401401
} else if sr.crcerr().bit_is_set() {
402402
nb::Error::Other(Error::Crc)
403-
} else if sr.txe().bit_is_set() {
403+
} else if sr.txe().bit_is_set() && sr.bsy().bit_is_clear() {
404404
return Ok(());
405405
} else {
406406
nb::Error::WouldBlock
@@ -481,15 +481,8 @@ where
481481
bufcap -= 1;
482482
}
483483

484-
loop {
485-
let sr = self.spi.sr.read();
486-
if !sr.bsy().bit_is_set() {
487-
break;
488-
}
489-
}
490-
491484
// Do one last status register check before continuing
492-
self.check_send().ok();
485+
nb::block!(self.check_send()).ok();
493486
Ok(())
494487
}
495488
}
@@ -532,15 +525,8 @@ where
532525
self.send_u16(word.clone());
533526
}
534527

535-
loop {
536-
let sr = self.spi.sr.read();
537-
if !sr.bsy().bit_is_set() {
538-
break;
539-
}
540-
}
541-
542528
// Do one last status register check before continuing
543-
self.check_send().ok();
529+
nb::block!(self.check_send()).ok();
544530
Ok(())
545531
}
546532
}

0 commit comments

Comments
 (0)