diff --git a/embassy-stm32/src/bxcan.rs b/embassy-stm32/src/can/bxcan.rs similarity index 86% rename from embassy-stm32/src/bxcan.rs rename to embassy-stm32/src/can/bxcan.rs index 8dd7459b..33f3cebf 100644 --- a/embassy-stm32/src/bxcan.rs +++ b/embassy-stm32/src/can/bxcan.rs @@ -68,7 +68,7 @@ pub(crate) mod sealed { use super::*; pub trait Instance { - fn regs() -> &'static crate::pac::bxcan::Can; + fn regs() -> &'static crate::pac::can::Can; } pub trait RxPin: Pin { @@ -85,9 +85,9 @@ pub trait RxPin: sealed::RxPin {} pub trait TxPin: sealed::TxPin {} crate::pac::peripherals!( - (bxcan, $inst:ident) => { + (can, $inst:ident) => { impl sealed::Instance for peripherals::$inst { - fn regs() -> &'static crate::pac::bxcan::Can { + fn regs() -> &'static crate::pac::can::Can { &crate::pac::$inst } } @@ -98,26 +98,21 @@ crate::pac::peripherals!( const REGISTERS: *mut bxcan::RegisterBlock = crate::pac::$inst.0 as *mut _; } }; - // (bxcan, CAN) => { - // unsafe impl bxcan::FilterOwner for Can { - // const NUM_FILTER_BANKS: u8 = 14; - // } - // }; ); crate::pac::peripherals!( // TODO: rename CAN to CAN1 on yaml level?? - (bxcan, CAN) => { + (can, CAN) => { unsafe impl bxcan::FilterOwner for peripherals::CAN { const NUM_FILTER_BANKS: u8 = 14; } }; - (bxcan, CAN1) => { + (can, CAN1) => { unsafe impl bxcan::FilterOwner for peripherals::CAN1 { const NUM_FILTER_BANKS: u8 = 14; } }; - (bxcan, CAN2) => { + (can, CAN2) => { // TODO: when CAN2 existis, we have 28 filter banks unsafe impl bxcan::MasterInstance for peripherals::CAN1 {} }; @@ -136,10 +131,10 @@ macro_rules! impl_pin { } crate::pac::peripheral_pins!( - ($inst:ident, bxcan, CAN, $pin:ident, TX, $af:expr) => { + ($inst:ident, can, CAN, $pin:ident, TX, $af:expr) => { impl_pin!($inst, $pin, TxPin, $af); }; - ($inst:ident, bxcan, CAN, $pin:ident, RX, $af:expr) => { + ($inst:ident, can, CAN, $pin:ident, RX, $af:expr) => { impl_pin!($inst, $pin, RxPin, $af); }; ); diff --git a/embassy-stm32/src/can/mod.rs b/embassy-stm32/src/can/mod.rs new file mode 100644 index 00000000..c7e2e620 --- /dev/null +++ b/embassy-stm32/src/can/mod.rs @@ -0,0 +1,5 @@ +#![macro_use] + +#[cfg_attr(can_bxcan, path = "bxcan.rs")] +mod _version; +pub use _version::*; diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index ca5c4d77..af4ab95f 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs @@ -27,8 +27,8 @@ mod time_driver; #[cfg(adc)] pub mod adc; -#[cfg(bxcan)] -pub mod bxcan; +#[cfg(can)] +pub mod can; #[cfg(dac)] pub mod dac; #[cfg(dbgmcu)] diff --git a/examples/stm32f4/src/bin/can.rs b/examples/stm32f4/src/bin/can.rs index d35a81d1..04f3417c 100644 --- a/examples/stm32f4/src/bin/can.rs +++ b/examples/stm32f4/src/bin/can.rs @@ -8,7 +8,7 @@ mod example_common; use cortex_m_rt::entry; -use embassy_stm32::bxcan::{Can, Frame, StandardId}; +use embassy_stm32::can::{Can, Frame, StandardId}; use embassy_stm32::dbgmcu::Dbgmcu; use example_common::*;