Skip to content

Commit 938576f

Browse files
authored
Merge pull request #665 from stm32-rs/rcc
rcc::Enable::is_
2 parents dcb11fe + a9425a3 commit 938576f

File tree

4 files changed

+225
-225
lines changed

4 files changed

+225
-225
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99

1010
### Changed
1111

12+
- `rcc::Enable`, `rcc::LPEnable` traits, timclk in `Clocks` instead of prescalers [#665]
1213
- move gpio, dma impls, adc pins in subdir, remove unused `From` impls [#658] [#664]
1314
- 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]
1415
- Fix race condition in sending start condition in I2C. [#662]
@@ -17,6 +18,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1718
[#662]: https://github.com/stm32-rs/stm32f4xx-hal/pull/662
1819
[#663]: https://github.com/stm32-rs/stm32f4xx-hal/pull/663
1920
[#664]: https://github.com/stm32-rs/stm32f4xx-hal/pull/664
21+
[#665]: https://github.com/stm32-rs/stm32f4xx-hal/pull/665
2022
[embedded-hal-1.0.0-alpha.10]: https://github.com/rust-embedded/embedded-hal/blob/v1.0.0-alpha.10/embedded-hal/CHANGELOG.md
2123

2224
## [v0.16.2] - 2023-06-27

src/rcc/enable.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,36 @@ macro_rules! bus_enable {
1818
bb::clear(Self::Bus::enr(rcc), $bit);
1919
}
2020
}
21+
#[inline(always)]
22+
fn is_enabled() -> bool {
23+
let rcc = pac::RCC::ptr();
24+
(Self::Bus::enr(unsafe { &*rcc }).read().bits() >> $bit) & 0x1 != 0
25+
}
2126
}
2227
};
2328
}
2429
macro_rules! bus_lpenable {
2530
($PER:ident => $bit:literal) => {
2631
impl LPEnable for crate::pac::$PER {
2732
#[inline(always)]
28-
fn low_power_enable(rcc: &RccRB) {
33+
fn enable_in_low_power(rcc: &RccRB) {
2934
unsafe {
3035
bb::set(Self::Bus::lpenr(rcc), $bit);
3136
}
3237
// Stall the pipeline to work around erratum 2.1.13 (DM00037591)
3338
cortex_m::asm::dsb();
3439
}
3540
#[inline(always)]
36-
fn low_power_disable(rcc: &RccRB) {
41+
fn disable_in_low_power(rcc: &RccRB) {
3742
unsafe {
3843
bb::clear(Self::Bus::lpenr(rcc), $bit);
3944
}
4045
}
46+
#[inline(always)]
47+
fn is_enabled_in_low_power() -> bool {
48+
let rcc = pac::RCC::ptr();
49+
(Self::Bus::lpenr(unsafe { &*rcc }).read().bits() >> $bit) & 0x1 != 0
50+
}
4151
}
4252
};
4353
}

0 commit comments

Comments
 (0)