From f26fb37c68df1c6edf26b29b3776a387b35345eb Mon Sep 17 00:00:00 2001 From: Andelf Date: Sun, 29 Dec 2024 23:46:54 +0800 Subject: [PATCH] fix(can): add support for ch32l1, w/o canfd --- src/can/can.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/can/can.rs b/src/can/can.rs index 5b7a565..2a327d0 100644 --- a/src/can/can.rs +++ b/src/can/can.rs @@ -148,8 +148,12 @@ pin_trait!(TxPin, Instance); foreach_peripheral!( (can, $inst:ident) => { impl SealedInstance for peripherals::$inst { + // FIXME: CH32L1 supports CANFD, and is compatible with the CAN peripheral. fn regs() -> crate::pac::can::Can { - crate::pac::$inst + #[cfg(ch32l1)] + return unsafe { crate::pac::can::Can::from_ptr(crate::pac::$inst.as_ptr()) }; + #[cfg(not(ch32l1))] + return crate::pac::$inst; } }