@@ -14,13 +14,12 @@ use crate::hal::{
1414 gpio:: { gpioa, Output , PushPull } ,
1515 pac:: { interrupt, Interrupt , Peripherals , TIM2 } ,
1616 prelude:: * ,
17- timer:: { CountDownTimer , Event , Timer } ,
17+ timer:: { CounterUs , Event , Timer } ,
1818} ;
1919
2020use core:: cell:: RefCell ;
2121use cortex_m:: { asm:: wfi, interrupt:: Mutex } ;
2222use cortex_m_rt:: entry;
23- use embedded_hal:: timer:: CountDown ;
2423
2524// NOTE You can uncomment 'hprintln' here and in the code below for a bit more
2625// verbosity at runtime, at the cost of throwing off the timing of the blink
@@ -36,14 +35,14 @@ type LedPin = gpioa::PA5<Output<PushPull>>;
3635static G_LED : Mutex < RefCell < Option < LedPin > > > = Mutex :: new ( RefCell :: new ( None ) ) ;
3736
3837// Make timer interrupt registers globally available
39- static G_TIM : Mutex < RefCell < Option < CountDownTimer < TIM2 > > > > = Mutex :: new ( RefCell :: new ( None ) ) ;
38+ static G_TIM : Mutex < RefCell < Option < CounterUs < TIM2 > > > > = Mutex :: new ( RefCell :: new ( None ) ) ;
4039
4140// Define an interupt handler, i.e. function to call when interrupt occurs.
4241// This specific interrupt will "trip" when the timer TIM2 times out
4342#[ interrupt]
4443fn TIM2 ( ) {
4544 static mut LED : Option < LedPin > = None ;
46- static mut TIM : Option < CountDownTimer < TIM2 > > = None ;
45+ static mut TIM : Option < CounterUs < TIM2 > > = None ;
4746
4847 let led = LED . get_or_insert_with ( || {
4948 cortex_m:: interrupt:: free ( |cs| {
@@ -79,8 +78,8 @@ fn main() -> ! {
7978 cortex_m:: interrupt:: free ( |cs| * G_LED . borrow ( cs) . borrow_mut ( ) = Some ( led) ) ;
8079
8180 // Set up a timer expiring after 1s
82- let mut timer = Timer :: new ( dp. TIM2 , & clocks) . count_down ( ) ;
83- timer. start ( 1 . hz ( ) ) ;
81+ let mut timer = Timer :: new ( dp. TIM2 , & clocks) . counter ( ) ;
82+ timer. start ( 1 . secs ( ) ) . unwrap ( ) ;
8483
8584 // Generate an interrupt when the timer expires
8685 timer. listen ( Event :: TimeOut ) ;
0 commit comments