stm32: Allow for RccPeripheral without reset field

This fix build on F0, since it doesn't have DMARST. This change makes
RccPeripheral::reset a no-op on peripherals where a reset field couldn't
be found
This commit is contained in:
Thales Fragoso
2021-07-15 13:25:51 -03:00
parent 8a172ac123
commit 2f08c7ced5
3 changed files with 77 additions and 24 deletions

View File

@ -177,7 +177,7 @@ pub(crate) unsafe fn init() {
}
pac::peripherals! {
(bdma, $peri:ident) => {
crate::peripherals::$peri::enable();
<crate::peripherals::$peri as RccPeripheral>::enable();
};
}
}

View File

@ -121,6 +121,35 @@ crate::pac::peripheral_rcc!(
}
}
impl RccPeripheral for peripherals::$inst {}
};
($inst:ident, $clk:ident, $enable:ident, $perien:ident) => {
impl sealed::RccPeripheral for peripherals::$inst {
fn frequency() -> crate::time::Hertz {
critical_section::with(|_| {
unsafe {
let freqs = get_freqs();
freqs.$clk
}
})
}
fn enable() {
critical_section::with(|_| {
unsafe {
crate::pac::RCC.$enable().modify(|w| w.$perien(true));
}
})
}
fn disable() {
critical_section::with(|_| {
unsafe {
crate::pac::RCC.$enable().modify(|w| w.$perien(false));
}
})
}
fn reset() {}
}
impl RccPeripheral for peripherals::$inst {}
};
);