Use macrotables from build.rs

This commit is contained in:
Dario Nieuwenhuis 2021-06-07 05:12:10 +02:00
parent 2685dbfcf4
commit 0ffa78aca1
3 changed files with 9 additions and 5 deletions

View File

@ -27,6 +27,7 @@ stm32-metapac = { version = "0.1.0", path = "../stm32-metapac", features = ["rt"
cfg-if = "1.0.0" cfg-if = "1.0.0"
[build-dependencies] [build-dependencies]
stm32-metapac = { version = "0.1.0", path = "../stm32-metapac", default-features = false }
serde = { version = "1.0.123", features = [ "derive" ]} serde = { version = "1.0.123", features = [ "derive" ]}
serde_yaml = "0.8.15" serde_yaml = "0.8.15"

View File

@ -23,10 +23,13 @@ fn main() {
panic!("gen.py exited with {:?}", exit_code) panic!("gen.py exited with {:?}", exit_code)
} }
for s in env::var("DEP_STM32_METAPAC_V0.1_CFGS").unwrap().split(",") { stm32_metapac::peripheral_versions!(
println!("cargo:rustc-cfg={}", s); ($peri:ident, $version:ident) => {
} println!("cargo:rustc-cfg={}", stringify!($peri));
println!("cargo:rerun-if-env-changed=DEP_STM32_METAPAC_V0.1_CFGS"); println!("cargo:rustc-cfg={}_{}", stringify!($peri), stringify!($version));
};
);
println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=gen.py"); println!("cargo:rerun-if-changed=gen.py");
} }

View File

@ -79,7 +79,7 @@ impl<T: Instance> Clock<T> {
// TODO: Temporary until clock code generation is in place // TODO: Temporary until clock code generation is in place
pub fn start_tim2(&'static self) { pub fn start_tim2(&'static self) {
cfg_if::cfg_if! { cfg_if::cfg_if! {
if #[cfg(stm32l0)] { if #[cfg(rcc_l0)] {
unsafe { unsafe {
let rcc = crate::pac::RCC; let rcc = crate::pac::RCC;
rcc.apb1enr() rcc.apb1enr()