aboutsummaryrefslogtreecommitdiff
path: root/src/delay.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/delay.rs')
-rw-r--r--src/delay.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/delay.rs b/src/delay.rs
index 8d3e00c..17dc654 100644
--- a/src/delay.rs
+++ b/src/delay.rs
@@ -30,6 +30,7 @@ impl Delay {
}
/// Delay using the Cortex-M systick for a certain duration, µs.
+ #[inline]
pub fn delay_us(&mut self, us: u32) {
let ticks = (us as u64) * (self.ahb_frequency as u64) / 1_000_000;
@@ -57,14 +58,8 @@ impl Delay {
}
/// Delay using the Cortex-M systick for a certain duration, ms.
- pub fn delay_ms(&mut self, ms: u32) {
- self.delay_us(ms * 1_000);
- }
-}
-
-impl DelayMs<u32> for Delay {
#[inline]
- fn delay_ms(&mut self, mut ms: u32) {
+ pub fn delay_ms(&mut self, mut ms: u32) {
// 4294967 is the highest u32 value which you can multiply by 1000 without overflow
while ms > 4294967 {
Delay::delay_us(self, 4294967000u32);
@@ -74,6 +69,13 @@ impl DelayMs<u32> for Delay {
}
}
+impl DelayMs<u32> for Delay {
+ #[inline]
+ fn delay_ms(&mut self, ms: u32) {
+ Delay::delay_ms(self, ms);
+ }
+}
+
// This is a workaround to allow `delay_ms(42)` construction without specifying a type.
impl DelayMs<i32> for Delay {
#[inline(always)]