Skip to content

Commit b50f403

Browse files
committed
spi_busy
1 parent 21425a4 commit b50f403

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/spi.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,9 @@ where
379379
}
380380
}
381381
// Wait for final TXE
382-
while self.spi.sr.read().txe().bit_is_clear() {}
382+
while !self.is_tx_empty() {}
383383
// Wait for final !BSY
384-
while self.spi.sr.read().bsy().bit_is_set() {}
384+
while self.is_busy() {}
385385
// Clear OVR set due to dropped received values
386386
let _ = self.read_data_reg();
387387
let _ = self.spi.sr.read();
@@ -429,16 +429,25 @@ where
429429
}
430430

431431
/// Returns true if the tx register is empty (and can accept data)
432+
#[inline]
432433
pub fn is_tx_empty(&self) -> bool {
433434
self.spi.sr.read().txe().bit_is_set()
434435
}
435436

436437
/// Returns true if the rx register is not empty (and can be read)
438+
#[inline]
437439
pub fn is_rx_not_empty(&self) -> bool {
438440
self.spi.sr.read().rxne().bit_is_set()
439441
}
440442

443+
/// Returns true if the transfer is in progress
444+
#[inline]
445+
pub fn is_busy(&self) -> bool {
446+
self.spi.sr.read().bsy().bit_is_set()
447+
}
448+
441449
/// Returns true if data are received and the previous data have not yet been read from SPI_DR.
450+
#[inline]
442451
pub fn is_overrun(&self) -> bool {
443452
self.spi.sr.read().ovr().bit_is_set()
444453
}

0 commit comments

Comments
 (0)