Enable clock by default for stm32l0
Modify init function to return a Clock instance defined by a per-chip SystemClock type and use this in macro setup A proof of concept implementation for STM32 L0 chips. This allows using embassy::main macros for STM32 devices that have the clock setup logic.
This commit is contained in:
@ -36,6 +36,7 @@ pub mod time;
|
||||
|
||||
pub use embassy_macros::interrupt;
|
||||
pub use pac::{interrupt, peripherals, Peripherals};
|
||||
pub use rcc::SystemClock;
|
||||
|
||||
// workaround for svd2rust-generated code using `use crate::generic::*;`
|
||||
pub(crate) use pac::regs::generic;
|
||||
@ -45,6 +46,12 @@ pub struct Config {
|
||||
rcc: rcc::Config,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn new(rcc: rcc::Config) -> Self {
|
||||
Self { rcc }
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
@ -54,14 +61,12 @@ impl Default for Config {
|
||||
}
|
||||
|
||||
/// Initialize embassy.
|
||||
pub fn init(config: Config) -> Peripherals {
|
||||
pub fn init(config: Config) -> (Peripherals, SystemClock) {
|
||||
let p = Peripherals::take();
|
||||
|
||||
unsafe {
|
||||
dma::init();
|
||||
pac::init_exti();
|
||||
rcc::init(config.rcc);
|
||||
(p, rcc::init(config.rcc))
|
||||
}
|
||||
|
||||
p
|
||||
}
|
||||
|
Reference in New Issue
Block a user