Skip to content

Commit 4b9722c

Browse files
committed
timer: add an assert to the ref clock operating frequency
1 parent 5763a2e commit 4b9722c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

rp2040-hal/src/timer.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::{
1616
clocks::ReferenceClock,
1717
pac::{self, RESETS, TIMER},
1818
resets::SubsystemReset,
19-
typelevel::Sealed,
19+
typelevel::Sealed, Clock,
2020
};
2121

2222
/// Instant type used by the Timer & Alarm methods.
@@ -59,7 +59,8 @@ impl Timer {
5959
/// Make sure that clocks and watchdog are configured, so
6060
/// that timer ticks happen at a frequency of 1MHz.
6161
/// Otherwise, `Timer` won't work as expected.
62-
pub fn new(timer: TIMER, resets: &mut RESETS, _clocks: &ReferenceClock) -> Self {
62+
pub fn new(timer: TIMER, resets: &mut RESETS, clocks: &ReferenceClock) -> Self {
63+
assert_eq!(clocks.freq().to_Hz(), 1_000_000);
6364
timer.reset_bring_down(resets);
6465
timer.reset_bring_up(resets);
6566
Self { _private: () }

0 commit comments

Comments
 (0)