@@ -18,7 +18,7 @@ use crate::hal::{
1818 gpio:: { gpioc, Output , PushPull } ,
1919 pac:: { interrupt, Interrupt , Peripherals , TIM2 } ,
2020 prelude:: * ,
21- timer:: { CountDownTimer , Event , Timer } ,
21+ timer:: { CounterMs , Event } ,
2222} ;
2323
2424use core:: cell:: RefCell ;
@@ -38,14 +38,14 @@ type LedPin = gpioc::PC13<Output<PushPull>>;
3838static G_LED : Mutex < RefCell < Option < LedPin > > > = Mutex :: new ( RefCell :: new ( None ) ) ;
3939
4040// Make timer interrupt registers globally available
41- static G_TIM : Mutex < RefCell < Option < CountDownTimer < TIM2 > > > > = Mutex :: new ( RefCell :: new ( None ) ) ;
41+ static G_TIM : Mutex < RefCell < Option < CounterMs < TIM2 > > > > = Mutex :: new ( RefCell :: new ( None ) ) ;
4242
4343// Define an interupt handler, i.e. function to call when interrupt occurs.
4444// This specific interrupt will "trip" when the timer TIM2 times out
4545#[ interrupt]
4646fn TIM2 ( ) {
4747 static mut LED : Option < LedPin > = None ;
48- static mut TIM : Option < CountDownTimer < TIM2 > > = None ;
48+ static mut TIM : Option < CounterMs < TIM2 > > = None ;
4949
5050 let led = LED . get_or_insert_with ( || {
5151 cortex_m:: interrupt:: free ( |cs| {
@@ -86,7 +86,8 @@ fn main() -> ! {
8686 cortex_m:: interrupt:: free ( |cs| * G_LED . borrow ( cs) . borrow_mut ( ) = Some ( led) ) ;
8787
8888 // Set up a timer expiring after 1s
89- let mut timer = Timer :: new ( dp. TIM2 , & clocks) . start_count_down ( 1 . Hz ( ) ) ;
89+ let mut timer = dp. TIM2 . counter_ms ( & clocks) ;
90+ timer. start ( 1 . secs ( ) ) . unwrap ( ) ;
9091
9192 // Generate an interrupt when the timer expires
9293 timer. listen ( Event :: Update ) ;
0 commit comments