diff options
author | 2022-01-02 18:13:28 +0000 | |
---|---|---|
committer | 2022-01-02 18:13:28 +0000 | |
commit | 2e2cb78a842f702f78f74e470216eb5139b4a264 (patch) | |
tree | 7ffcad44fe62db0117632bf41a32304170920097 /src/delay.rs | |
parent | 4b536898ca8da6d20bd54d91fd7938aae0c538bf (diff) | |
parent | e62dee61f41df76922ee13a830a24bbec2f932f5 (diff) | |
download | cortex-m-2e2cb78a842f702f78f74e470216eb5139b4a264.tar.gz cortex-m-2e2cb78a842f702f78f74e470216eb5139b4a264.tar.zst cortex-m-2e2cb78a842f702f78f74e470216eb5139b4a264.zip |
Merge #375v0.7.4
375: Prepare v0.7.4 r=thejpster a=adamgreig
I've created a new branch, `v0.7.x`, which is currently at the latest non-breaking commit (so includes #346 #349 #347 #351 #339 #352 #348 #363 #362 #361 but does not include #342), to track the 0.7 series since master now contains breaking changes for v0.8.
This PR (which targets the new branch) cherry-picks #372 #369 #374 and bumps the version to v0.7.4 (and updates CHANGELOG) ready for a new v0.7.4 release. Once complete I'll also backport the changelog entries and bump the version in master to 0.7.4.
I think this is everything that should be in 0.7 -- the only excluded PRs from master are #342 and #367 I believe, and I don't think we have any open PRs targeting 0.7 either.
Any other thoughts on items for inclusion in 0.7.4 (or other changelog entries I missed)?
Co-authored-by: bors[bot] <26634292+bors[bot]@users.noreply.github.com>
Co-authored-by: Adam Greig <adam@adamgreig.com>
Diffstat (limited to 'src/delay.rs')
-rw-r--r-- | src/delay.rs | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/delay.rs b/src/delay.rs index 8ed1fea..66a63bf 100644 --- a/src/delay.rs +++ b/src/delay.rs @@ -6,7 +6,7 @@ use embedded_hal::blocking::delay::{DelayMs, DelayUs}; /// System timer (SysTick) as a delay provider. pub struct Delay { syst: SYST, - ahb_frequency: u32, + frequency: u32, } impl Delay { @@ -14,13 +14,19 @@ impl Delay { /// /// `ahb_frequency` is a frequency of the AHB bus in Hz. #[inline] - pub fn new(mut syst: SYST, ahb_frequency: u32) -> Self { - syst.set_clock_source(SystClkSource::Core); + pub fn new(syst: SYST, ahb_frequency: u32) -> Self { + Self::with_source(syst, ahb_frequency, SystClkSource::Core) + } - Delay { - syst, - ahb_frequency, - } + /// Configures the system timer (SysTick) as a delay provider + /// with a clock source. + /// + /// `frequency` is the frequency of your `clock_source` in Hz. + #[inline] + pub fn with_source(mut syst: SYST, frequency: u32, clock_source: SystClkSource) -> Self { + syst.set_clock_source(clock_source); + + Delay { syst, frequency } } /// Releases the system timer (SysTick) resource. @@ -32,7 +38,7 @@ impl Delay { /// Delay using the Cortex-M systick for a certain duration, in µs. #[allow(clippy::missing_inline_in_public_items)] pub fn delay_us(&mut self, us: u32) { - let ticks = (u64::from(us)) * (u64::from(self.ahb_frequency)) / 1_000_000; + let ticks = (u64::from(us)) * (u64::from(self.frequency)) / 1_000_000; let full_cycles = ticks >> 24; if full_cycles > 0 { |