embassy/embassy-stm32/src/lib.rs
Ulf Lilleengen 1c10e746b6 Re-adds embassy macros for stm32
* Hook RCC config into chip config and use chip-specific RCC init
  function
* RTC/clock setup is ignored for now
2021-05-25 13:30:42 +02:00

68 lines
1.3 KiB
Rust

#![no_std]
#![feature(generic_associated_types)]
#![feature(asm)]
#![feature(min_type_alias_impl_trait)]
#![feature(impl_trait_in_bindings)]
#![feature(type_alias_impl_trait)]
#![allow(incomplete_features)]
// This must go FIRST so that all the other modules see its macros.
pub mod fmt;
#[cfg(feature = "_timer")]
pub mod clock;
#[cfg(feature = "_dma")]
pub mod dma;
pub mod exti;
pub mod gpio;
pub mod pwr;
pub mod rcc;
#[cfg(feature = "_rng")]
pub mod rng;
#[cfg(feature = "_sdmmc")]
pub mod sdmmc;
#[cfg(feature = "_spi")]
pub mod spi;
#[cfg(feature = "_usart")]
pub mod usart;
// This must go LAST so that it sees the `impl_foo!` macros
#[cfg(feature = "pac")]
pub mod pac;
#[cfg(not(feature = "pac"))]
mod pac;
pub mod time;
pub use embassy_macros::interrupt;
pub use pac::{interrupt, peripherals, Peripherals};
// workaround for svd2rust-generated code using `use crate::generic::*;`
pub(crate) use pac::regs::generic;
#[non_exhaustive]
pub struct Config {
rcc: rcc::Config,
}
impl Default for Config {
fn default() -> Self {
Self {
rcc: Default::default(),
}
}
}
/// Initialize embassy.
pub fn init(config: Config) -> Peripherals {
let p = Peripherals::take();
unsafe {
dma::init();
pac::init_exti();
rcc::init(config.rcc);
}
p
}