File tree Expand file tree Collapse file tree 7 files changed +21
-8
lines changed
Expand file tree Collapse file tree 7 files changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -9,15 +9,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99
1010### Added
1111
12+ - ` count_down ` constructor for ` Timer ` -> ` CountDownTimer ` without start [ #382 ]
1213- Implementation of RTIC Monotonic for TIM2 & TIM5 under ` rtic ` feature [ #380 ]
1314- ` IoPin ` for ` Output<OpenDrain>> <-> Input<Floating>> ` [ #374 ]
1415
16+ [ #382 ] : https://github.com/stm32-rs/stm32f4xx-hal/pull/382
1517[ #380 ] : https://github.com/stm32-rs/stm32f4xx-hal/pull/380
1618[ #374 ] : https://github.com/stm32-rs/stm32f4xx-hal/pull/374
1719
1820### Changed
1921
20- - [ breaking-change] Remove all deprecated
2122- [ breaking-change] Bump ` stm32f4 ` to 0.14. Update RTIC based examples to use ` rtic ` 0.6 [ #367 ]
2223- [ breaking-change] Bump ` bxcan ` to 0.6 [ #371 ]
2324
Original file line number Diff line number Diff line change @@ -127,7 +127,8 @@ fn main() -> ! {
127127 disp. flush ( ) . unwrap ( ) ;
128128
129129 // Create a 1ms periodic interrupt from TIM2
130- let mut timer = Timer :: new ( dp. TIM2 , & clocks) . start_count_down ( 1 . hz ( ) ) ;
130+ let mut timer = Timer :: new ( dp. TIM2 , & clocks) . count_down ( ) ;
131+ timer. start ( 1 . hz ( ) ) ;
131132 timer. listen ( Event :: TimeOut ) ;
132133
133134 free ( |cs| {
Original file line number Diff line number Diff line change @@ -79,7 +79,8 @@ fn main() -> ! {
7979 cortex_m:: interrupt:: free ( |cs| * G_LED . borrow ( cs) . borrow_mut ( ) = Some ( led) ) ;
8080
8181 // Set up a timer expiring after 1s
82- let mut timer = Timer :: new ( dp. TIM2 , & clocks) . start_count_down ( 1 . hz ( ) ) ;
82+ let mut timer = Timer :: new ( dp. TIM2 , & clocks) . count_down ( ) ;
83+ timer. start ( 1 . hz ( ) ) ;
8384
8485 // Generate an interrupt when the timer expires
8586 timer. listen ( Event :: TimeOut ) ;
Original file line number Diff line number Diff line change @@ -93,7 +93,8 @@ fn main() -> ! {
9393 disp. flush ( ) . unwrap ( ) ;
9494
9595 // Create a 1ms periodic interrupt from TIM2
96- let mut timer = Timer :: new ( dp. TIM2 , & clocks) . start_count_down ( 1 . hz ( ) ) ;
96+ let mut timer = Timer :: new ( dp. TIM2 , & clocks) . count_down ( ) ;
97+ timer. start ( 1 . hz ( ) ) ;
9798 timer. listen ( Event :: TimeOut ) ;
9899
99100 free ( |cs| {
Original file line number Diff line number Diff line change @@ -29,7 +29,8 @@ fn main() -> ! {
2929 let clocks = rcc. cfgr . sysclk ( 24 . mhz ( ) ) . freeze ( ) ;
3030
3131 // Create a timer based on SysTick
32- let mut timer = Timer :: new ( dp. TIM1 , & clocks) . start_count_down ( 1 . hz ( ) ) ;
32+ let mut timer = Timer :: new ( dp. TIM1 , & clocks) . count_down ( ) ;
33+ timer. start ( 1 . hz ( ) ) ;
3334
3435 hprintln ! ( "hello!" ) . unwrap ( ) ;
3536 // wait until timer expires
Original file line number Diff line number Diff line change @@ -30,7 +30,8 @@ fn main() -> ! {
3030 let clocks = rcc. cfgr . sysclk ( 24 . mhz ( ) ) . freeze ( ) ;
3131
3232 // Create a timer based on SysTick
33- let mut timer = Timer :: syst ( cp. SYST , & clocks) . start_count_down ( 24 . hz ( ) ) ;
33+ let mut timer = Timer :: syst ( cp. SYST , & clocks) . count_down ( ) ;
34+ timer. start ( 24 . hz ( ) ) ;
3435
3536 hprintln ! ( "hello!" ) . unwrap ( ) ;
3637 // wait until timer expires
Original file line number Diff line number Diff line change @@ -30,6 +30,14 @@ pub struct CountDownTimer<TIM> {
3030 clk : Hertz ,
3131}
3232
33+ impl < TIM > Timer < TIM > {
34+ /// Creates CountDownTimer
35+ pub fn count_down ( self ) -> CountDownTimer < TIM > {
36+ let Self { tim, clk } = self ;
37+ CountDownTimer { tim, clk }
38+ }
39+ }
40+
3341impl < TIM > Timer < TIM >
3442where
3543 CountDownTimer < TIM > : CountDown < Time = Hertz > ,
3947 where
4048 T : Into < Hertz > ,
4149 {
42- let Self { tim, clk } = self ;
43- let mut timer = CountDownTimer { tim, clk } ;
50+ let mut timer = self . count_down ( ) ;
4451 timer. start ( timeout) ;
4552 timer
4653 }
You can’t perform that action at this time.
0 commit comments