Skip to content

Commit

Permalink
Implement DelayMs for Milliseconds and DelayUs for Microseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
Sh3Rm4n committed Jun 10, 2021
1 parent f708a69 commit 23e0882
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Support for GPIO output slew rate configuration ([#189])
- Support for GPIO interrupts ([#189])
- `ld` feature, which enables the memory.x generation ([#216])
- Implement `DelayMs` for `Milliseconds` and `DelayUs` for `Microseconds` ([#234])

### Changed

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

[#234]: https://github.com/stm32-rs/stm32f3xx-hal/pull/234
[#229]: https://github.com/stm32-rs/stm32f3xx-hal/pull/229
[#227]: https://github.com/stm32-rs/stm32f3xx-hal/pull/227
[#220]: https://github.com/stm32-rs/stm32f3xx-hal/pull/220
Expand Down
14 changes: 14 additions & 0 deletions src/delay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use cortex_m::peripheral::SYST;

use crate::hal::blocking::delay::{DelayMs, DelayUs};
use crate::rcc::Clocks;
use crate::time::duration::{Microseconds, Milliseconds};
use crate::time::fixed_point::FixedPoint;

/// System timer (SysTick) as a delay provider
pub struct Delay {
Expand Down Expand Up @@ -106,3 +108,15 @@ impl DelayUs<u8> for Delay {
self.delay_us(u32::from(us))
}
}

impl DelayUs<Microseconds> for Delay {
fn delay_us(&mut self, us: Microseconds) {
self.delay_us(us.integer());
}
}

impl DelayMs<Milliseconds> for Delay {
fn delay_ms(&mut self, ms: Milliseconds) {
self.delay_ms(ms.integer());
}
}

0 comments on commit 23e0882

Please sign in to comment.