Skip to content

Commit 5f7e6a6

Browse files
Rework timers so there are no warnings
1 parent 2aa1d1b commit 5f7e6a6

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/timers.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@
2424
//! }
2525
//! ```
2626
27-
#[cfg(feature = "stm32f030")]
28-
use crate::stm32::{RCC, TIM1, TIM14, TIM15, TIM16, TIM17, TIM3, TIM6, TIM7};
29-
#[cfg(feature = "stm32f042")]
30-
use crate::stm32::{RCC, TIM1, TIM14, TIM16, TIM17, TIM2, TIM3};
27+
use crate::stm32;
3128
use cortex_m::peripheral::syst::SystClkSource;
3229
use cortex_m::peripheral::SYST;
3330

@@ -111,6 +108,7 @@ impl Periodic for Timer<SYST> {}
111108
macro_rules! timers {
112109
($($TIM:ident: ($tim:ident, $timXen:ident, $timXrst:ident, $apbenr:ident, $apbrstr:ident),)+) => {
113110
$(
111+
use crate::stm32::$TIM;
114112
impl Timer<$TIM> {
115113
// XXX(why not name this `new`?) bummer: constructors need to have different names
116114
// even if the `$TIM` are non overlapping (compare to the `free` function below
@@ -121,7 +119,7 @@ macro_rules! timers {
121119
T: Into<Hertz>,
122120
{
123121
// NOTE(unsafe) This executes only during initialisation
124-
let rcc = unsafe { &(*RCC::ptr()) };
122+
let rcc = unsafe { &(*stm32::RCC::ptr()) };
125123

126124
// enable and reset peripheral to a clean slate state
127125
rcc.$apbenr.modify(|_, w| w.$timXen().set_bit());
@@ -159,8 +157,7 @@ macro_rules! timers {
159157

160158
/// Releases the TIM peripheral
161159
pub fn release(self) -> $TIM {
162-
use crate::stm32::RCC;
163-
let rcc = unsafe { &(*RCC::ptr()) };
160+
let rcc = unsafe { &(*stm32::RCC::ptr()) };
164161
// Pause counter
165162
self.tim.cr1.modify(|_, w| w.cen().clear_bit());
166163
// Disable timer

0 commit comments

Comments
 (0)