Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow USB to work with V2 clocking API #808

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Allow delay to be constructed with source (Clock V2)
  • Loading branch information
rnd-ash authored and jbeaurivage committed Jan 5, 2025
commit e0db45736d42ca9b75f4702c9b66646742a50e44
14 changes: 14 additions & 0 deletions hal/src/delay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use crate::clock::GenericClockController;
use crate::ehal::delay::DelayNs;
use crate::ehal_02;
use crate::time::Hertz;
use crate::typelevel::Increment;
use crate::clock::v2::Source;

/// System timer (SysTick) as a delay provider
pub struct Delay {
Expand All @@ -25,6 +27,18 @@ impl Delay {
}
}

pub fn new_with_source<S>(mut syst: SYST, source: S) -> (Self, S::Inc)
where S: Source + Increment {
syst.set_clock_source(SystClkSource::Core);
(
Delay {
syst,
sysclock: source.freq(),
},
source.inc()
)
}

/// Releases the system timer (SysTick) resource
pub fn free(self) -> SYST {
self.syst
Expand Down