From 6f597653afff99e3da1b442354258565f06005f6 Mon Sep 17 00:00:00 2001 From: xoviat Date: Fri, 26 Mar 2021 19:34:52 -0500 Subject: [PATCH] stm32: consolidate modules --- embassy-stm32/Cargo.toml | 4 +- {embassy-stm32f4 => embassy-stm32}/src/can.rs | 19 +++++++++ embassy-stm32/src/lib.rs | 39 +++++++++++++++++++ {embassy-stm32f4 => embassy-stm32}/src/rtc.rs | 0 embassy-stm32f4/src/lib.rs | 6 +-- 5 files changed, 64 insertions(+), 4 deletions(-) rename {embassy-stm32f4 => embassy-stm32}/src/can.rs (85%) rename {embassy-stm32f4 => embassy-stm32}/src/rtc.rs (100%) diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index 6701ff8f3..3fae66e9e 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -42,5 +42,7 @@ cortex-m-rt = "0.6.13" cortex-m = "0.7.1" embedded-hal = { version = "0.2.4" } embedded-dma = { version = "0.1.2" } +bxcan = "0.5.0" +nb = "*" stm32f4xx-hal = { version = "0.8.3", features = ["rt", "can"], git = "https://github.com/stm32-rs/stm32f4xx-hal.git", optional = true } -stm32l0xx-hal = { version = "0.7.0", features = ["rt"], git = "https://github.com/stm32-rs/stm32l0xx-hal.git", optional = true } \ No newline at end of file +stm32l0xx-hal = { version = "0.7.0", features = ["rt"], optional = true } \ No newline at end of file diff --git a/embassy-stm32f4/src/can.rs b/embassy-stm32/src/can.rs similarity index 85% rename from embassy-stm32f4/src/can.rs rename to embassy-stm32/src/can.rs index 526d002c0..f97e900ea 100644 --- a/embassy-stm32f4/src/can.rs +++ b/embassy-stm32/src/can.rs @@ -95,6 +95,25 @@ macro_rules! can { } } +#[cfg(any( + feature = "stm32f401", + feature = "stm32f405", + feature = "stm32f407", + feature = "stm32f410", + feature = "stm32f411", + feature = "stm32f412", + feature = "stm32f413", + feature = "stm32f415", + feature = "stm32f417", + feature = "stm32f423", + feature = "stm32f427", + feature = "stm32f429", + feature = "stm32f437", + feature = "stm32f439", + feature = "stm32f446", + feature = "stm32f469", + feature = "stm32f479", +))] can! { CAN1 => (CAN1_TX, CAN1_RX0), CAN2 => (CAN2_TX, CAN2_RX0), diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index 954067f32..8a1fe5a36 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs @@ -34,3 +34,42 @@ pub mod fmt; pub mod exti; pub mod interrupt; + +#[cfg(any( + feature = "stm32f405", + feature = "stm32f407", + feature = "stm32f412", + feature = "stm32f413", + feature = "stm32f415", + feature = "stm32f417", + feature = "stm32f423", + feature = "stm32f427", + feature = "stm32f429", + feature = "stm32f437", + feature = "stm32f439", + feature = "stm32f446", + feature = "stm32f469", + feature = "stm32f479", +))] +pub mod can; + +#[cfg(any( + feature = "stm32f401", + feature = "stm32f405", + feature = "stm32f407", + feature = "stm32f410", + feature = "stm32f411", + feature = "stm32f412", + feature = "stm32f413", + feature = "stm32f415", + feature = "stm32f417", + feature = "stm32f423", + feature = "stm32f427", + feature = "stm32f429", + feature = "stm32f437", + feature = "stm32f439", + feature = "stm32f446", + feature = "stm32f469", + feature = "stm32f479", +))] +pub mod rtc; diff --git a/embassy-stm32f4/src/rtc.rs b/embassy-stm32/src/rtc.rs similarity index 100% rename from embassy-stm32f4/src/rtc.rs rename to embassy-stm32/src/rtc.rs diff --git a/embassy-stm32f4/src/lib.rs b/embassy-stm32f4/src/lib.rs index bdd4d0fda..eb6f04f88 100644 --- a/embassy-stm32f4/src/lib.rs +++ b/embassy-stm32f4/src/lib.rs @@ -307,11 +307,11 @@ compile_error!( "Multile chip features activated. You must activate exactly one of the following features: " ); -pub use embassy_stm32::{exti, fmt, hal, interrupt, pac}; +pub use embassy_stm32::{exti, fmt, hal, interrupt, pac, rtc}; #[cfg(not(any(feature = "stm32f401", feature = "stm32f410", feature = "stm32f411",)))] -pub mod can; +pub use embassy_stm32::can; + #[cfg(not(feature = "stm32f410"))] pub mod qei; -pub mod rtc; pub mod serial;