Skip to content

Commit 23e0882

Browse files
committed
Implement DelayMs for Milliseconds and DelayUs for Microseconds
1 parent f708a69 commit 23e0882

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1717
- Support for GPIO output slew rate configuration ([#189])
1818
- Support for GPIO interrupts ([#189])
1919
- `ld` feature, which enables the memory.x generation ([#216])
20+
- Implement `DelayMs` for `Milliseconds` and `DelayUs` for `Microseconds` ([#234])
2021

2122
### Changed
2223

@@ -322,6 +323,7 @@ let clocks = rcc
322323
[defmt]: https://github.com/knurling-rs/defmt
323324
[filter]: https://defmt.ferrous-systems.com/filtering.html
324325

326+
[#234]: https://github.com/stm32-rs/stm32f3xx-hal/pull/234
325327
[#229]: https://github.com/stm32-rs/stm32f3xx-hal/pull/229
326328
[#227]: https://github.com/stm32-rs/stm32f3xx-hal/pull/227
327329
[#220]: https://github.com/stm32-rs/stm32f3xx-hal/pull/220

src/delay.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ use cortex_m::peripheral::SYST;
1212

1313
use crate::hal::blocking::delay::{DelayMs, DelayUs};
1414
use crate::rcc::Clocks;
15+
use crate::time::duration::{Microseconds, Milliseconds};
16+
use crate::time::fixed_point::FixedPoint;
1517

1618
/// System timer (SysTick) as a delay provider
1719
pub struct Delay {
@@ -106,3 +108,15 @@ impl DelayUs<u8> for Delay {
106108
self.delay_us(u32::from(us))
107109
}
108110
}
111+
112+
impl DelayUs<Microseconds> for Delay {
113+
fn delay_us(&mut self, us: Microseconds) {
114+
self.delay_us(us.integer());
115+
}
116+
}
117+
118+
impl DelayMs<Milliseconds> for Delay {
119+
fn delay_ms(&mut self, ms: Milliseconds) {
120+
self.delay_ms(ms.integer());
121+
}
122+
}

0 commit comments

Comments
 (0)