@@ -14,7 +14,7 @@ use crate::hal::{
14
14
gpio:: { gpioa, Output , PushPull } ,
15
15
prelude:: * ,
16
16
stm32:: { interrupt, Interrupt , Peripherals , TIM2 } ,
17
- timer:: { Event , Timer } ,
17
+ timer:: { CountDownTimer , Event , Timer } ,
18
18
} ;
19
19
20
20
use core:: cell:: RefCell ;
@@ -36,14 +36,14 @@ type LEDPIN = gpioa::PA5<Output<PushPull>>;
36
36
static G_LED : Mutex < RefCell < Option < LEDPIN > > > = Mutex :: new ( RefCell :: new ( None ) ) ;
37
37
38
38
// Make timer interrupt registers globally available
39
- static G_TIM : Mutex < RefCell < Option < Timer < TIM2 > > > > = Mutex :: new ( RefCell :: new ( None ) ) ;
39
+ static G_TIM : Mutex < RefCell < Option < CountDownTimer < TIM2 > > > > = Mutex :: new ( RefCell :: new ( None ) ) ;
40
40
41
41
// Define an interupt handler, i.e. function to call when interrupt occurs.
42
42
// This specific interrupt will "trip" when the timer TIM2 times out
43
43
#[ interrupt]
44
44
fn TIM2 ( ) {
45
45
static mut LED : Option < LEDPIN > = None ;
46
- static mut TIM : Option < Timer < TIM2 > > = None ;
46
+ static mut TIM : Option < CountDownTimer < TIM2 > > = None ;
47
47
48
48
let led = LED . get_or_insert_with ( || {
49
49
cortex_m:: interrupt:: free ( |cs| {
@@ -79,7 +79,7 @@ fn main() -> ! {
79
79
cortex_m:: interrupt:: free ( |cs| * G_LED . borrow ( cs) . borrow_mut ( ) = Some ( led) ) ;
80
80
81
81
// Set up a timer expiring after 1s
82
- let mut timer = Timer :: tim2 ( dp. TIM2 , 1 . hz ( ) , clocks ) ;
82
+ let mut timer = Timer :: new ( dp. TIM2 , & clocks ) . start_count_down ( 1 . hz ( ) ) ;
83
83
84
84
// Generate an interrupt when the timer expires
85
85
timer. listen ( Event :: TimeOut ) ;
0 commit comments