From 4b9722c3efc900383b43d14c396deee82bc0604e Mon Sep 17 00:00:00 2001 From: Wilfried Chauveau Date: Wed, 16 Aug 2023 18:02:30 +0100 Subject: [PATCH] timer: add an assert to the ref clock operating frequency --- rp2040-hal/src/timer.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rp2040-hal/src/timer.rs b/rp2040-hal/src/timer.rs index 4f8f9dff5..b922bad82 100644 --- a/rp2040-hal/src/timer.rs +++ b/rp2040-hal/src/timer.rs @@ -16,7 +16,7 @@ use crate::{ clocks::ReferenceClock, pac::{self, RESETS, TIMER}, resets::SubsystemReset, - typelevel::Sealed, + typelevel::Sealed, Clock, }; /// Instant type used by the Timer & Alarm methods. @@ -59,7 +59,8 @@ impl Timer { /// Make sure that clocks and watchdog are configured, so /// that timer ticks happen at a frequency of 1MHz. /// Otherwise, `Timer` won't work as expected. - pub fn new(timer: TIMER, resets: &mut RESETS, _clocks: &ReferenceClock) -> Self { + pub fn new(timer: TIMER, resets: &mut RESETS, clocks: &ReferenceClock) -> Self { + assert_eq!(clocks.freq().to_Hz(), 1_000_000); timer.reset_bring_down(resets); timer.reset_bring_up(resets); Self { _private: () }