aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-stm32/src/can/bxcan.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/embassy-stm32/src/can/bxcan.rs b/embassy-stm32/src/can/bxcan.rs
index 33f3cebff..906978e8b 100644
--- a/embassy-stm32/src/can/bxcan.rs
+++ b/embassy-stm32/src/can/bxcan.rs
@@ -17,7 +17,6 @@ pub struct Can<'d, T: Instance + bxcan::Instance> {
17impl<'d, T: Instance + bxcan::Instance> Can<'d, T> { 17impl<'d, T: Instance + bxcan::Instance> Can<'d, T> {
18 pub fn new( 18 pub fn new(
19 peri: impl Unborrow<Target = T> + 'd, 19 peri: impl Unborrow<Target = T> + 'd,
20 // irq: impl Unborrow<Target = T::Interrupt> + 'd,
21 rx: impl Unborrow<Target = impl RxPin<T>> + 'd, 20 rx: impl Unborrow<Target = impl RxPin<T>> + 'd,
22 tx: impl Unborrow<Target = impl TxPin<T>> + 'd, 21 tx: impl Unborrow<Target = impl TxPin<T>> + 'd,
23 ) -> Self { 22 ) -> Self {
@@ -30,7 +29,6 @@ impl<'d, T: Instance + bxcan::Instance> Can<'d, T> {
30 29
31 T::enable(); 30 T::enable();
32 T::reset(); 31 T::reset();
33 // TODO: CAN2 also required CAN1 clock
34 32
35 Self { 33 Self {
36 phantom: PhantomData, 34 phantom: PhantomData,
@@ -101,21 +99,27 @@ crate::pac::peripherals!(
101); 99);
102 100
103crate::pac::peripherals!( 101crate::pac::peripherals!(
104 // TODO: rename CAN to CAN1 on yaml level??
105 (can, CAN) => { 102 (can, CAN) => {
106 unsafe impl bxcan::FilterOwner for peripherals::CAN { 103 unsafe impl bxcan::FilterOwner for peripherals::$inst {
107 const NUM_FILTER_BANKS: u8 = 14; 104 const NUM_FILTER_BANKS: u8 = 14;
108 } 105 }
109 }; 106 };
107 // Only correct when CAN2 also exists… Fix on yaml level?
108 // There are only 14 filter banks when CAN2 is not available.
110 (can, CAN1) => { 109 (can, CAN1) => {
111 unsafe impl bxcan::FilterOwner for peripherals::CAN1 { 110 unsafe impl bxcan::FilterOwner for peripherals::CAN1 {
112 const NUM_FILTER_BANKS: u8 = 14; 111 const NUM_FILTER_BANKS: u8 = 28;
113 } 112 }
114 }; 113 };
115 (can, CAN2) => { 114 (can, CAN2) => {
116 // TODO: when CAN2 existis, we have 28 filter banks 115 // CAN2 is always a slave instance where CAN1 is the master instance
117 unsafe impl bxcan::MasterInstance for peripherals::CAN1 {} 116 unsafe impl bxcan::MasterInstance for peripherals::CAN1 {}
118 }; 117 };
118 (can, CAN3) => {
119 unsafe impl bxcan::FilterOwner for peripherals::$inst {
120 const NUM_FILTER_BANKS: u8 = 14;
121 }
122 };
119); 123);
120 124
121macro_rules! impl_pin { 125macro_rules! impl_pin {