@@ -16,7 +16,8 @@ use crate::{
1616 clocks:: ReferenceClock ,
1717 pac:: { self , RESETS , TIMER } ,
1818 resets:: SubsystemReset ,
19- typelevel:: Sealed , Clock ,
19+ typelevel:: Sealed ,
20+ Clock , Watchdog ,
2021} ;
2122
2223/// Instant type used by the Timer & Alarm methods.
@@ -59,8 +60,16 @@ impl Timer {
5960 /// Make sure that clocks and watchdog are configured, so
6061 /// that timer ticks happen at a frequency of 1MHz.
6162 /// Otherwise, `Timer` won't work as expected.
62- pub fn new ( timer : TIMER , resets : & mut RESETS , clocks : & ReferenceClock ) -> Self {
63- assert_eq ! ( clocks. freq( ) . to_Hz( ) , 1_000_000 ) ;
63+ pub fn new (
64+ timer : TIMER ,
65+ resets : & mut RESETS ,
66+ watchdog : & Watchdog ,
67+ clocks : & ReferenceClock ,
68+ ) -> Self {
69+ assert_eq ! (
70+ clocks. freq( ) . to_Hz( ) / u32 :: from( watchdog. cycles_per_ticks( ) ) ,
71+ 1_000_000
72+ ) ;
6473 timer. reset_bring_down ( resets) ;
6574 timer. reset_bring_up ( resets) ;
6675 Self { _private : ( ) }
@@ -185,8 +194,9 @@ impl eh1_0_alpha::delay::DelayUs for Timer {
185194/// // Make sure to initialize clocks, otherwise the timer wouldn't work
186195/// // properly. Omitted here for terseness.
187196/// let clocks: rp2040_hal::clocks::ClocksManager = todo!();
197+ /// let watchdog: rp2040_hal::Watchdog = todo!();
188198/// // Configure the Timer peripheral in count-down mode
189- /// let timer = rp2040_hal::Timer::new(pac.TIMER, &mut pac.RESETS, &clocks);
199+ /// let timer = rp2040_hal::Timer::new(pac.TIMER, &mut pac.RESETS, &watchdog, & clocks.reference_clock );
190200/// let mut count_down = timer.count_down();
191201/// // Create a count_down timer for 500 milliseconds
192202/// count_down.start(500.millis());
0 commit comments