Skip to content

Commit

Permalink
Merge pull request #665 from stm32-rs/rcc
Browse files Browse the repository at this point in the history
rcc::Enable::is_
  • Loading branch information
burrbull authored Jul 4, 2023
2 parents dcb11fe + a9425a3 commit 938576f
Show file tree
Hide file tree
Showing 4 changed files with 225 additions and 225 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Changed

- `rcc::Enable`, `rcc::LPEnable` traits, timclk in `Clocks` instead of prescalers [#665]
- move gpio, dma impls, adc pins in subdir, remove unused `From` impls [#658] [#664]
- Bump `embedded-hal` to `1.0.0-alpha.10`. See [their changelog][embedded-hal-1.0.0-alpha.10] for further details. Note that this included breaking changes to the previous alpha APIs. [#663]
- Fix race condition in sending start condition in I2C. [#662]
Expand All @@ -17,6 +18,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
[#662]: https://github.com/stm32-rs/stm32f4xx-hal/pull/662
[#663]: https://github.com/stm32-rs/stm32f4xx-hal/pull/663
[#664]: https://github.com/stm32-rs/stm32f4xx-hal/pull/664
[#665]: https://github.com/stm32-rs/stm32f4xx-hal/pull/665
[embedded-hal-1.0.0-alpha.10]: https://github.com/rust-embedded/embedded-hal/blob/v1.0.0-alpha.10/embedded-hal/CHANGELOG.md

## [v0.16.2] - 2023-06-27
Expand Down
14 changes: 12 additions & 2 deletions src/rcc/enable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,36 @@ macro_rules! bus_enable {
bb::clear(Self::Bus::enr(rcc), $bit);
}
}
#[inline(always)]
fn is_enabled() -> bool {
let rcc = pac::RCC::ptr();
(Self::Bus::enr(unsafe { &*rcc }).read().bits() >> $bit) & 0x1 != 0
}
}
};
}
macro_rules! bus_lpenable {
($PER:ident => $bit:literal) => {
impl LPEnable for crate::pac::$PER {
#[inline(always)]
fn low_power_enable(rcc: &RccRB) {
fn enable_in_low_power(rcc: &RccRB) {
unsafe {
bb::set(Self::Bus::lpenr(rcc), $bit);
}
// Stall the pipeline to work around erratum 2.1.13 (DM00037591)
cortex_m::asm::dsb();
}
#[inline(always)]
fn low_power_disable(rcc: &RccRB) {
fn disable_in_low_power(rcc: &RccRB) {
unsafe {
bb::clear(Self::Bus::lpenr(rcc), $bit);
}
}
#[inline(always)]
fn is_enabled_in_low_power() -> bool {
let rcc = pac::RCC::ptr();
(Self::Bus::lpenr(unsafe { &*rcc }).read().bits() >> $bit) & 0x1 != 0
}
}
};
}
Expand Down
Loading

0 comments on commit 938576f

Please sign in to comment.