aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Andres Vahter <andres@vahter.me> 2023-09-05 09:04:16 +0300
committerGravatar Emil Fresk <emil.fresk@gmail.com> 2023-09-06 18:48:36 +0000
commit54aec9b3989162a60534620b80cde78d2d5cc1ba (patch)
tree6b533778530b4c41fce2c9aec1ed2db59597b17f
parent7dcc59d4ed6921e8e94ab5f0fbe712216050b1fc (diff)
downloadrtic-54aec9b3989162a60534620b80cde78d2d5cc1ba.tar.gz
rtic-54aec9b3989162a60534620b80cde78d2d5cc1ba.tar.zst
rtic-54aec9b3989162a60534620b80cde78d2d5cc1ba.zip
add embedded-hal-async impl to stm32
-rw-r--r--rtic-monotonics/src/stm32.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/rtic-monotonics/src/stm32.rs b/rtic-monotonics/src/stm32.rs
index 780ecbe4..3232f4ae 100644
--- a/rtic-monotonics/src/stm32.rs
+++ b/rtic-monotonics/src/stm32.rs
@@ -217,6 +217,19 @@ macro_rules! make_timer {
}
}
+ #[cfg(feature = "embedded-hal-async")]
+ impl embedded_hal_async::delay::DelayUs for $mono_name {
+ #[inline]
+ async fn delay_us(&mut self, us: u32) {
+ Self::delay((us as u64).micros()).await;
+ }
+
+ #[inline]
+ async fn delay_ms(&mut self, ms: u32) {
+ Self::delay((ms as u64).millis()).await;
+ }
+ }
+
impl Monotonic for $mono_name {
type Instant = fugit::TimerInstantU64<TIMER_HZ>;
type Duration = fugit::TimerDurationU64<TIMER_HZ>;