add stm32l4 hsi48 and usb example
This commit is contained in:
@ -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 {
|
||||
|
Reference in New Issue
Block a user