@@ -18,7 +18,7 @@ use crate::hal::{
18
18
gpio:: { gpioc, Output , PushPull } ,
19
19
pac:: { interrupt, Interrupt , Peripherals , TIM2 } ,
20
20
prelude:: * ,
21
- timer:: { CountDownTimer , Event , Timer } ,
21
+ timer:: { CounterMs , Event } ,
22
22
} ;
23
23
24
24
use core:: cell:: RefCell ;
@@ -38,14 +38,14 @@ type LedPin = gpioc::PC13<Output<PushPull>>;
38
38
static G_LED : Mutex < RefCell < Option < LedPin > > > = Mutex :: new ( RefCell :: new ( None ) ) ;
39
39
40
40
// 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 ) ) ;
42
42
43
43
// Define an interupt handler, i.e. function to call when interrupt occurs.
44
44
// This specific interrupt will "trip" when the timer TIM2 times out
45
45
#[ interrupt]
46
46
fn TIM2 ( ) {
47
47
static mut LED : Option < LedPin > = None ;
48
- static mut TIM : Option < CountDownTimer < TIM2 > > = None ;
48
+ static mut TIM : Option < CounterMs < TIM2 > > = None ;
49
49
50
50
let led = LED . get_or_insert_with ( || {
51
51
cortex_m:: interrupt:: free ( |cs| {
@@ -86,7 +86,8 @@ fn main() -> ! {
86
86
cortex_m:: interrupt:: free ( |cs| * G_LED . borrow ( cs) . borrow_mut ( ) = Some ( led) ) ;
87
87
88
88
// 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 ( ) ;
90
91
91
92
// Generate an interrupt when the timer expires
92
93
timer. listen ( Event :: Update ) ;
0 commit comments