Skip to content

Commit 2caf4f2

Browse files
committed
Use embedded_time
1 parent c68c36c commit 2caf4f2

File tree

10 files changed

+20
-14
lines changed

10 files changed

+20
-14
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ nb = "0.1"
3333
paste = "1"
3434
rtcc = "0.2"
3535
stm32f3 = "0.12"
36+
embedded-time = "0.10"
3637

3738
[dependencies.embedded-hal-can]
3839
version = "0.1.0"

src/i2c.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
77
use core::convert::TryFrom;
88
use core::ops::Deref;
9+
use embedded_time::rate::Hertz;
910

1011
use crate::{
1112
gpio::{gpioa, gpiob, AF4},
1213
hal::blocking::i2c::{Read, Write, WriteRead},
1314
pac::{i2c1::RegisterBlock, rcc::cfgr3::I2C1SW_A, I2C1, RCC},
1415
rcc::{Clocks, APB1},
15-
time::{Hertz, U32Ext},
1616
};
1717

1818
#[cfg(not(feature = "gpio-f333"))]
@@ -451,7 +451,7 @@ macro_rules! i2c {
451451
fn clock(clocks: &Clocks) -> Hertz {
452452
// NOTE(unsafe) atomic read with no side effects
453453
match unsafe { (*RCC::ptr()).cfgr3.read().$i2cXsw().variant() } {
454-
I2C1SW_A::HSI => 8.mhz().into(),
454+
I2C1SW_A::HSI => Hertz(8_000_000),
455455
I2C1SW_A::SYSCLK => clocks.sysclk(),
456456
}
457457
}

src/prelude.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ pub use crate::flash::FlashExt as _stm32f3xx_hal_flash_FlashExt;
66
pub use crate::gpio::GpioExt as _stm32f3xx_hal_gpio_GpioExt;
77
pub use crate::hal::prelude::*;
88
pub use crate::rcc::RccExt as _stm32f3xx_hal_rcc_RccExt;
9-
pub use crate::time::U32Ext as _stm32f3xx_hal_time_U32Ext;
9+
pub use embedded_time::duration::*;
10+
pub use embedded_time::rate::*;
1011
#[cfg(feature = "unproven")]
1112
pub use crate::{
1213
hal::digital::v2::InputPin as _embedded_hal_digital_InputPin,

src/pwm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,10 @@ use crate::{
159159
gpio::{self, gpioa, gpiob},
160160
hal::PwmPin,
161161
pac::{RCC, TIM15, TIM16, TIM17, TIM2},
162-
rcc::Clocks,
163-
time::Hertz,
162+
rcc::Clocks
164163
};
165164
use core::marker::PhantomData;
165+
use embedded_time::rate::Hertz;
166166

167167
#[cfg(any(
168168
feature = "stm32f302xb",

src/rcc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ use crate::pac::{
6060
};
6161

6262
use crate::flash::ACR;
63-
use crate::time::Hertz;
63+
use embedded_time::rate::Hertz;
6464

6565
/// Extension trait that constrains the `RCC` peripheral
6666
pub trait RccExt {

src/serial.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ use crate::{
55
hal::{blocking, serial},
66
pac::{USART1, USART2, USART3},
77
rcc::{Clocks, APB1, APB2},
8-
time::Bps,
98
};
9+
1010
use cfg_if::cfg_if;
1111
use core::{convert::Infallible, marker::PhantomData, ptr};
12+
use embedded_time::rate::Baud;
1213

1314
cfg_if! {
1415
if #[cfg(any(feature = "stm32f302", feature = "stm32f303"))] {
@@ -111,7 +112,7 @@ macro_rules! hal {
111112
pub fn $usartX(
112113
usart: $USARTX,
113114
pins: (TX, RX),
114-
baud_rate: Bps,
115+
baud_rate: Baud,
115116
clocks: Clocks,
116117
apb: &mut $APB,
117118
) -> Self

src/spi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ use crate::rcc::APB1;
131131
feature = "stm32f398"
132132
))]
133133
use crate::rcc::APB2;
134-
use crate::time::Hertz;
135134
use core::marker::PhantomData;
135+
use embedded_time::rate::Hertz;
136136

137137
/// SPI error
138138
#[derive(Debug)]

src/time.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Time units
22
3+
/*
34
use cortex_m::peripheral::DWT;
45
56
use crate::rcc::Clocks;
@@ -126,3 +127,4 @@ impl Instant {
126127
DWT::get_cycle_count().wrapping_sub(self.now)
127128
}
128129
}
130+
*/

src/timer.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ use crate::pac::{TIM15, TIM16, TIM17, TIM2, TIM6};
5252
use crate::pac::{TIM3, TIM7};
5353

5454
use void::Void;
55+
use embedded_time::rate::Hertz;
5556

5657
use crate::rcc::{Clocks, APB1, APB2};
57-
use crate::time::Hertz;
58+
5859

5960
/// Associated clocks with timers
6061
pub trait PclkSrc {

src/watchdog.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use crate::hal::watchdog::{Watchdog, WatchdogEnable};
88

99
use crate::pac::{DBGMCU, IWDG};
10-
use crate::time::MilliSeconds;
10+
use embedded_time::duration::Milliseconds;
1111

1212
const LSI_KHZ: u32 = 40;
1313
const MAX_PR: u8 = 8;
@@ -54,13 +54,13 @@ impl IndependentWatchDog {
5454
}
5555

5656
/// Returns the interval in ms
57-
pub fn interval(&self) -> MilliSeconds {
57+
pub fn interval(&self) -> Milliseconds {
5858
while self.is_pr_updating() {}
5959

6060
let pr = self.iwdg.pr.read().pr().bits();
6161
let rl = self.iwdg.rlr.read().rl().bits();
6262
let ms = Self::timeout_period(pr, rl);
63-
MilliSeconds(ms)
63+
Milliseconds(ms)
6464
}
6565

6666
/// pr: Prescaler divider bits, rl: reload value
@@ -93,7 +93,7 @@ impl IndependentWatchDog {
9393
}
9494

9595
impl WatchdogEnable for IndependentWatchDog {
96-
type Time = MilliSeconds;
96+
type Time = Milliseconds;
9797

9898
fn start<T: Into<Self::Time>>(&mut self, period: T) {
9999
self.setup(period.into().0);

0 commit comments

Comments
 (0)