stm32g0: Add support for low-power run
This commit is contained in:
parent
794798e225
commit
573e6ec373
@ -49,7 +49,6 @@ impl Into<u8> for HSI16Prescaler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl Into<u8> for APBPrescaler {
|
impl Into<u8> for APBPrescaler {
|
||||||
fn into(self) -> u8 {
|
fn into(self) -> u8 {
|
||||||
match self {
|
match self {
|
||||||
@ -83,6 +82,7 @@ pub struct Config {
|
|||||||
mux: ClockSrc,
|
mux: ClockSrc,
|
||||||
ahb_pre: AHBPrescaler,
|
ahb_pre: AHBPrescaler,
|
||||||
apb_pre: APBPrescaler,
|
apb_pre: APBPrescaler,
|
||||||
|
low_power_run: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Config {
|
impl Default for Config {
|
||||||
@ -92,6 +92,7 @@ impl Default for Config {
|
|||||||
mux: ClockSrc::HSI16(HSI16Prescaler::NotDivided),
|
mux: ClockSrc::HSI16(HSI16Prescaler::NotDivided),
|
||||||
ahb_pre: AHBPrescaler::NotDivided,
|
ahb_pre: AHBPrescaler::NotDivided,
|
||||||
apb_pre: APBPrescaler::NotDivided,
|
apb_pre: APBPrescaler::NotDivided,
|
||||||
|
low_power_run: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -114,6 +115,12 @@ impl Config {
|
|||||||
self.apb_pre = pre;
|
self.apb_pre = pre;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn low_power_run(mut self, on: bool) -> Self {
|
||||||
|
self.low_power_run = on;
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// RCC peripheral
|
/// RCC peripheral
|
||||||
@ -206,6 +213,14 @@ impl RccExt for RCC {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let pwr = pac::PWR;
|
||||||
|
if cfgr.low_power_run {
|
||||||
|
assert!(sys_clk.hz() <= 2_000_000.hz());
|
||||||
|
unsafe {
|
||||||
|
pwr.cr1().modify(|w| w.set_lpr(true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Clocks {
|
Clocks {
|
||||||
sys: sys_clk.hz(),
|
sys: sys_clk.hz(),
|
||||||
ahb: ahb_freq.hz(),
|
ahb: ahb_freq.hz(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user