Skip to content

Commit ff94c7d

Browse files
committed
Implement async DelayUs for NoDelay
1 parent 8d03c73 commit ff94c7d

File tree

1 file changed

+18
-1
lines changed
  • embedded-hal-bus/src/spi

1 file changed

+18
-1
lines changed

embedded-hal-bus/src/spi/mod.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,25 @@ where
3939
/// Dummy `DelayUs` implementation that panics on use.
4040
pub struct NoDelay;
4141

42+
#[cold]
43+
fn no_delay_panic() {
44+
panic!("You've tried to execute a SPI transaction containing a `Operation::Delay` in a `SpiDevice` created with `new_no_delay()`. Create it with `new()` instead, passing a `DelayUs` implementation.");
45+
}
46+
4247
impl embedded_hal::delay::DelayUs for NoDelay {
4348
fn delay_us(&mut self, _us: u32) {
44-
panic!("You've tried to execute a SPI transaction containing a `Operation::Delay` in a `SpiDevice` created with `new_no_delay()`. Create it with `new()` instead, passing a `DelayUs` implementation.")
49+
no_delay_panic();
50+
}
51+
}
52+
53+
#[cfg(feature = "async")]
54+
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
55+
impl embedded_hal_async::delay::DelayUs for NoDelay {
56+
async fn delay_us(&mut self, _us: u32) {
57+
no_delay_panic();
58+
}
59+
60+
async fn delay_ms(&mut self, _us: u32) {
61+
no_delay_panic();
4562
}
4663
}

0 commit comments

Comments
 (0)