add stm32l4 hsi48 and usb example

This commit is contained in:
Philip A Reimer
2022-04-09 14:25:29 -06:00
parent cd6250986a
commit d8860c0b80
4 changed files with 129 additions and 2 deletions

View File

@ -275,6 +275,7 @@ pub struct Config {
Option<PLLSAI1QDiv>,
Option<PLLSAI1PDiv>,
)>,
pub hsi48: bool,
}
impl Default for Config {
@ -286,6 +287,7 @@ impl Default for Config {
apb1_pre: APBPrescaler::NotDivided,
apb2_pre: APBPrescaler::NotDivided,
pllsai1: None,
hsi48: false,
}
}
}
@ -406,6 +408,14 @@ pub(crate) unsafe fn init(config: Config) {
}
};
if config.hsi48 {
RCC.crrcr().modify(|w| w.set_hsi48on(true));
while !RCC.crrcr().read().hsi48rdy() {}
// Enable as clock source for USB, RNG and SDMMC
RCC.ccipr().modify(|w| w.set_clk48sel(0));
}
// Set flash wait states
FLASH.acr().modify(|w| {
w.set_latency(if sys_clk <= 16_000_000 {