From 29168c7dd05da67c1a803633221f4d15703449d1 Mon Sep 17 00:00:00 2001 From: Ashcon Mohseninia Date: Tue, 10 Dec 2024 08:31:48 +0100 Subject: [PATCH] Fix compile tests and restrict source to Gclk0 --- hal/src/delay.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/hal/src/delay.rs b/hal/src/delay.rs index 0ba8b4ac458b..cfc423bcf121 100644 --- a/hal/src/delay.rs +++ b/hal/src/delay.rs @@ -1,5 +1,6 @@ //! Delays +use atsamd_hal_macros::hal_cfg; use cortex_m::peripheral::syst::SystClkSource; use cortex_m::peripheral::SYST; @@ -8,7 +9,11 @@ use crate::ehal::delay::DelayNs; use crate::ehal_02; use crate::time::Hertz; use crate::typelevel::Increment; -use crate::clock::v2::Source; + +#[hal_cfg("rtc-d5x")] +use crate::clock::v2::{ + Source, gclk::Gclk0Id +}; /// System timer (SysTick) as a delay provider pub struct Delay { @@ -27,15 +32,18 @@ impl Delay { } } - pub fn new_with_source(mut syst: SYST, source: S) -> (Self, S::Inc) - where S: Source + Increment { + #[hal_cfg("rtc-d5x")] + /// Configures the system timer (SysTick) as a delay provide, compatible + /// with the V2 clocking API + pub fn new_with_source(mut syst: SYST, gclk0: S) -> (Self, S::Inc) + where S: Source + Increment { syst.set_clock_source(SystClkSource::Core); ( Delay { syst, - sysclock: source.freq(), + sysclock: gclk0.freq(), }, - source.inc() + gclk0.inc() ) }