aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Kröger <[email protected]>2022-03-03 20:51:34 +0100
committerTimo Kröger <[email protected]>2022-03-05 09:46:06 +0100
commitd6d25e6470b533dbdcc0fe1f521dd8311fa0adc3 (patch)
tree9477741baf3c129ba138d8579f854395d2d7a5ea
parent6929350552fcf3cc7cc830555ce09b16bb86746f (diff)
[can] `cfgs` for naming inconsistencies
Approach is similar to USB OTG. STM32L49x and STML4Ax have CAN1 and CAN2. All others STM32L4xx do only have CAN1. STM32F72x and STM32F73x are the only F7 devices with only CAN1.
-rw-r--r--embassy-stm32/src/can/bxcan.rs19
1 files changed, 16 insertions, 3 deletions
diff --git a/embassy-stm32/src/can/bxcan.rs b/embassy-stm32/src/can/bxcan.rs
index cb667695a..4887ee143 100644
--- a/embassy-stm32/src/can/bxcan.rs
+++ b/embassy-stm32/src/can/bxcan.rs
@@ -96,10 +96,23 @@ foreach_peripheral!(
96 // CAN1 owns the filter bank and needs to be enabled in order 96 // CAN1 owns the filter bank and needs to be enabled in order
97 // for CAN2 to receive messages. 97 // for CAN2 to receive messages.
98 (can, CAN1) => { 98 (can, CAN1) => {
99 unsafe impl bxcan::FilterOwner for peripherals::CAN1 { 99 cfg_if::cfg_if! {
100 const NUM_FILTER_BANKS: u8 = 28; 100 if #[cfg(all(
101 any(stm32l4, stm32l72, stm32l73),
102 not(any(stm32l49, stm32l4a))
103 ))] {
104 // Most L4 devices and some F7 devices use the name "CAN1"
105 // even if there is no "CAN2" peripheral.
106 unsafe impl bxcan::FilterOwner for peripherals::CAN1 {
107 const NUM_FILTER_BANKS: u8 = 14;
108 }
109 } else {
110 unsafe impl bxcan::FilterOwner for peripherals::CAN1 {
111 const NUM_FILTER_BANKS: u8 = 28;
112 }
113 unsafe impl bxcan::MasterInstance for peripherals::CAN1 {}
114 }
101 } 115 }
102 unsafe impl bxcan::MasterInstance for peripherals::CAN1 {}
103 }; 116 };
104 (can, CAN3) => { 117 (can, CAN3) => {
105 unsafe impl bxcan::FilterOwner for peripherals::CAN3 { 118 unsafe impl bxcan::FilterOwner for peripherals::CAN3 {