From 0ffa78aca1783332cc2804dce8c6e8f28d5d5dc4 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Mon, 7 Jun 2021 05:12:10 +0200 Subject: [PATCH] Use macrotables from build.rs --- embassy-stm32/Cargo.toml | 1 + embassy-stm32/build.rs | 11 +++++++---- embassy-stm32/src/clock.rs | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index ee0ec1abf..a93fce41e 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -27,6 +27,7 @@ stm32-metapac = { version = "0.1.0", path = "../stm32-metapac", features = ["rt" cfg-if = "1.0.0" [build-dependencies] +stm32-metapac = { version = "0.1.0", path = "../stm32-metapac", default-features = false } serde = { version = "1.0.123", features = [ "derive" ]} serde_yaml = "0.8.15" diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index ef60a855a..df8af660b 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs @@ -23,10 +23,13 @@ fn main() { panic!("gen.py exited with {:?}", exit_code) } - for s in env::var("DEP_STM32_METAPAC_V0.1_CFGS").unwrap().split(",") { - println!("cargo:rustc-cfg={}", s); - } - println!("cargo:rerun-if-env-changed=DEP_STM32_METAPAC_V0.1_CFGS"); + stm32_metapac::peripheral_versions!( + ($peri:ident, $version:ident) => { + println!("cargo:rustc-cfg={}", stringify!($peri)); + println!("cargo:rustc-cfg={}_{}", stringify!($peri), stringify!($version)); + }; + ); + println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=gen.py"); } diff --git a/embassy-stm32/src/clock.rs b/embassy-stm32/src/clock.rs index 694ca666d..075b80118 100644 --- a/embassy-stm32/src/clock.rs +++ b/embassy-stm32/src/clock.rs @@ -79,7 +79,7 @@ impl Clock { // TODO: Temporary until clock code generation is in place pub fn start_tim2(&'static self) { cfg_if::cfg_if! { - if #[cfg(stm32l0)] { + if #[cfg(rcc_l0)] { unsafe { let rcc = crate::pac::RCC; rcc.apb1enr()