Skip to content

Commit

Permalink
Fix compile tests and restrict source to Gclk0
Browse files Browse the repository at this point in the history
  • Loading branch information
rnd-ash committed Dec 10, 2024
1 parent 0e7b0a6 commit cf5123f
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions hal/src/delay.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Delays
use atsamd_hal_macros::hal_cfg;
use cortex_m::peripheral::syst::SystClkSource;
use cortex_m::peripheral::SYST;

Expand All @@ -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 {
Expand All @@ -27,15 +32,18 @@ impl Delay {
}
}

pub fn new_with_source<S>(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<S>(mut syst: SYST, gclk0: S) -> (Self, S::Inc)
where S: Source<Id = Gclk0Id> + Increment {
syst.set_clock_source(SystClkSource::Core);
(
Delay {
syst,
sysclock: source.freq(),
sysclock: gclk0.freq(),
},
source.inc()
gclk0.inc()
)
}

Expand Down

0 comments on commit cf5123f

Please sign in to comment.