#![no_std]
#![allow(unused_unsafe)]
#[cfg(not(any(
feature = "f301",
feature = "f302",
feature = "f303",
feature = "f373",
feature = "f3x4",
feature = "f401",
feature = "f405",
feature = "f407",
feature = "f410",
feature = "f411",
feature = "f412",
feature = "f413",
feature = "f427",
feature = "f429",
feature = "f446",
feature = "f469",
feature = "l4x1",
feature = "l4x2",
feature = "l412",
feature = "l4x3",
feature = "l4x5",
feature = "l4x6",
feature = "l552",
feature = "l562",
feature = "g030",
feature = "g031",
feature = "g041",
feature = "g070",
feature = "g071",
feature = "g081",
feature = "g431",
feature = "g441",
feature = "g471",
feature = "g473",
feature = "g474",
feature = "g483",
feature = "g484",
feature = "g491",
feature = "g4a1",
feature = "h743",
feature = "h743v",
feature = "h747cm4",
feature = "h747cm7",
feature = "h753",
feature = "h753v",
feature = "h7b3",
feature = "wb55",
feature = "wle5",
)))]
compile_error!("This crate requires an MCU-specifying feature to be enabled. eg `l552`.");
#[cfg(feature = "f301")]
pub use stm32f3::stm32f301 as pac;
#[cfg(feature = "f302")]
pub use stm32f3::stm32f302 as pac;
#[cfg(feature = "f303")]
pub use stm32f3::stm32f303 as pac;
#[cfg(feature = "f373")]
pub use stm32f3::stm32f373 as pac;
#[cfg(feature = "f3x4")]
pub use stm32f3::stm32f3x4 as pac;
#[cfg(feature = "f401")]
pub use stm32f4::stm32f401 as pac;
#[cfg(feature = "f405")]
pub use stm32f4::stm32f405 as pac;
#[cfg(feature = "f407")]
pub use stm32f4::stm32f407 as pac;
#[cfg(feature = "f410")]
pub use stm32f4::stm32f410 as pac;
#[cfg(feature = "f411")]
pub use stm32f4::stm32f411 as pac;
#[cfg(feature = "f412")]
pub use stm32f4::stm32f412 as pac;
#[cfg(feature = "f413")]
pub use stm32f4::stm32f413 as pac;
#[cfg(feature = "f427")]
pub use stm32f4::stm32f427 as pac;
#[cfg(feature = "f429")]
pub use stm32f4::stm32f429 as pac;
#[cfg(feature = "f446")]
pub use stm32f4::stm32f446 as pac;
#[cfg(feature = "f469")]
pub use stm32f4::stm32f469 as pac;
#[cfg(feature = "l4x1")]
pub use stm32l4::stm32l4x1 as pac;
#[cfg(feature = "l4x2")]
pub use stm32l4::stm32l4x2 as pac;
#[cfg(feature = "l412")]
pub use stm32l4::stm32l412 as pac;
#[cfg(feature = "l4x3")]
pub use stm32l4::stm32l4x3 as pac;
#[cfg(feature = "l4x5")]
pub use stm32l4::stm32l4x5 as pac;
#[cfg(feature = "l4x6")]
pub use stm32l4::stm32l4x6 as pac;
#[cfg(feature = "l552")]
pub use stm32l5::stm32l552 as pac;
#[cfg(feature = "l562")]
pub use stm32l5::stm32l562 as pac;
#[cfg(feature = "g030")]
pub use stm32g0::stm32g030 as pac;
#[cfg(feature = "g031")]
pub use stm32g0::stm32g031 as pac;
#[cfg(feature = "g041")]
pub use stm32g0::stm32g041 as pac;
#[cfg(feature = "g070")]
pub use stm32g0::stm32g070 as pac;
#[cfg(feature = "g071")]
pub use stm32g0::stm32g071 as pac;
#[cfg(feature = "g081")]
pub use stm32g0::stm32g081 as pac;
#[cfg(feature = "g431")]
pub use stm32g4::stm32g431 as pac;
#[cfg(feature = "g441")]
pub use stm32g4::stm32g441 as pac;
#[cfg(feature = "g471")]
pub use stm32g4::stm32g471 as pac;
#[cfg(feature = "g473")]
pub use stm32g4::stm32g473 as pac;
#[cfg(feature = "g474")]
pub use stm32g4::stm32g474 as pac;
#[cfg(feature = "g483")]
pub use stm32g4::stm32g483 as pac;
#[cfg(feature = "g484")]
pub use stm32g4::stm32g484 as pac;
#[cfg(feature = "g491")]
pub use stm32g4::stm32g491 as pac;
#[cfg(feature = "g4a1")]
pub use stm32g4::stm32g4a1 as pac;
#[cfg(feature = "h743")]
pub use stm32h7::stm32h743 as pac;
#[cfg(feature = "h743v")]
pub use stm32h7::stm32h743v as pac;
#[cfg(feature = "h747cm4")]
pub use stm32h7::stm32h747cm4 as pac;
#[cfg(feature = "h747cm7")]
pub use stm32h7::stm32h747cm7 as pac;
#[cfg(feature = "h753")]
pub use stm32h7::stm32h753 as pac;
#[cfg(feature = "h753v")]
pub use stm32h7::stm32h753v as pac;
#[cfg(feature = "h7b3")]
pub use stm32h7::stm32h7b3 as pac;
#[cfg(feature = "wb55")]
pub use stm32wb::stm32wb55 as pac;
#[cfg(feature = "wle5")]
pub use stm32wl::stm32wle5 as pac;
#[cfg(not(any(feature = "f301", feature = "f302")))]
pub mod adc;
#[cfg(all(
feature = "can",
any(
all(feature = "f3", not(feature = "f301")),
all(
feature = "f4",
not(any(feature = "f401", feature = "f410", feature = "f411"))
),
feature = "l4"
)
))]
pub mod can;
pub mod clocks;
#[cfg(not(any(
feature = "f4",
feature = "g0",
feature = "g4",
feature = "l5",
feature = "wb",
feature = "wl"
)))]
pub mod crc;
#[cfg(not(any(
feature = "f401",
feature = "f411",
feature = "f412",
feature = "wb",
feature = "g0"
)))]
pub mod dac;
#[cfg(not(any(feature = "h7", feature = "f4", feature = "l5")))]
pub mod dma;
#[cfg(not(feature = "h7"))] pub mod flash;
#[cfg(not(feature = "wl"))] pub mod gpio;
#[cfg(feature = "wb")]
pub mod hsem;
#[cfg(not(feature = "f4"))]
pub mod i2c;
#[cfg(feature = "f4")]
pub mod i2c_f4;
#[cfg(feature = "f4")]
pub use i2c_f4 as i2c;
#[cfg(feature = "wb")]
pub mod ipcc;
pub mod low_power;
#[cfg(not(any(
feature = "f3",
feature = "f4",
feature = "l4x3", // todo: PAC bug?
feature = "l5",
feature = "g0",
feature = "g431",
feature = "g441",
feature = "g471",
feature = "g491",
feature = "g4a1",
feature = "h7b3",
feature = "wl",
)))]
pub mod qspi;
#[cfg(not(feature = "wl"))] pub mod rtc;
pub mod spi;
#[cfg(not(feature = "wl"))] pub mod timer;
#[cfg(not(feature = "wl"))] pub mod usart;
cfg_if::cfg_if! {
if #[cfg(all(
feature = "usb",
any(feature = "f303", feature = "l4x2", feature = "l412", feature = "l4x3", feature = "l5", feature = "g4", feature = "wb")
))] {
pub mod usb;
} else if #[cfg(all(
// todo: I think only H7 has hs (high-speed), while F4 and L4 have FS only.
any(feature = "usbotg_fs", feature = "usbotg_hs"),
any(feature = "f4", feature = "l4x5", feature = "l4x6", feature = "h7")
))] {
pub mod usb_otg;
}
}
mod util;
#[macro_export]
macro_rules! access_global {
($NAME_GLOBAL:ident, $name_local:ident, $cs:expr) => {
let mut part1 = $NAME_GLOBAL.borrow($cs).borrow_mut();
let $name_local = part1.as_mut().unwrap();
};
}
#[macro_export]
macro_rules! make_globals {
($(($NAME:ident, $type:ty)),+) => {
$(
static $NAME: Mutex<RefCell<Option<$type>>> = Mutex::new(RefCell::new(None));
)+
};
}
#[macro_export]
macro_rules! make_simple_globals {
($(($NAME:ident, $type:ty, $val:expr)),+) => {
$(
static $NAME: Mutex<Cell<$type>> = Mutex::new(Cell::new($val));
)+
};
}
use cortex_m::interrupt::free;
#[cfg(not(any(feature = "g0", feature = "h7")))]
pub fn debug_workaround() {
free(|_| {
let dbgmcu = unsafe { &(*pac::DBGMCU::ptr()) };
#[cfg(not(feature = "l5"))]
dbgmcu.cr.modify(|_, w| w.dbg_sleep().set_bit());
dbgmcu.cr.modify(|_, w| w.dbg_stop().set_bit());
dbgmcu.cr.modify(|_, w| w.dbg_standby().set_bit());
});
free(|cs| {
let rcc = unsafe { &(*pac::RCC::ptr()) };
#[cfg(feature = "f3")]
rcc.ahbenr.modify(|_, w| w.dma1en().set_bit());
#[cfg(not(feature = "f3"))]
rcc.ahb1enr.modify(|_, w| w.dma1en().set_bit());
})
}
pub mod prelude {
pub use access_global;
pub use make_globals;
pub use make_simple_globals;
}