CAN support for STM32U3 Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
Post Reply
wild-boar
Posts: 17
Joined: Thu May 08, 2014 11:58 pm
Been thanked: 9 times

CAN support for STM32U3

Post by wild-boar »

Here is a quick patch to enable FDCAN support in STM32U3.

Code: Select all

diff --git a/os/hal/ports/STM32/STM32U3xx/platform.mk b/os/hal/ports/STM32/STM32U3xx/platform.mk
index 249aa94ed..71b596f10 100644
--- a/os/hal/ports/STM32/STM32U3xx/platform.mk
+++ b/os/hal/ports/STM32/STM32U3xx/platform.mk
@@ -29,7 +29,7 @@ include $(CHIBIOS)/os/hal/ports/STM32/LLD/ADCv7/driver.mk
 include $(CHIBIOS)/os/hal/ports/STM32/LLD/DACv2/driver.mk
 include $(CHIBIOS)/os/hal/ports/STM32/LLD/DMA3v1/driver.mk
 include $(CHIBIOS)/os/hal/ports/STM32/LLD/EXTIv1/driver.mk
-#include $(CHIBIOS)/os/hal/ports/STM32/LLD/FDCANv1/driver.mk
+include $(CHIBIOS)/os/hal/ports/STM32/LLD/FDCANv1/driver.mk
 include $(CHIBIOS)/os/hal/ports/STM32/LLD/GPIOv2/driver.mk
 include $(CHIBIOS)/os/hal/ports/STM32/LLD/I2Cv4/driver.mk
 include $(CHIBIOS)/os/hal/ports/STM32/LLD/ICACHEv1/driver.mk
diff --git a/os/hal/ports/STM32/STM32U3xx/stm32_isr.c b/os/hal/ports/STM32/STM32U3xx/stm32_isr.c
index fc2b3bcd7..d3dbbfcac 100644
--- a/os/hal/ports/STM32/STM32U3xx/stm32_isr.c
+++ b/os/hal/ports/STM32/STM32U3xx/stm32_isr.c
@@ -70,6 +70,8 @@
 #include "stm32_exti14.inc"
 #include "stm32_exti15.inc"
 
+#include "stm32_fdcan1.inc"
+
 #include "stm32_i2c1.inc"
 #include "stm32_i2c2.inc"
 #include "stm32_i2c3.inc"
@@ -126,6 +128,8 @@ void irqInit(void) {
   exti14_irq_init();
   exti15_irq_init();
 
+  fdcan1_irq_init();
+
   i2c1_irq_init();
   i2c2_irq_init();
   i2c3_irq_init();
@@ -179,6 +183,8 @@ void irqDeinit(void) {
   exti14_irq_deinit();
   exti15_irq_deinit();
 
+  fdcan1_irq_deinit();
+
   i2c1_irq_deinit();
   i2c2_irq_deinit();
   i2c3_irq_deinit();
   diff --git a/os/hal/ports/STM32/STM32U3xx/stm32_isr.h b/os/hal/ports/STM32/STM32U3xx/stm32_isr.h
index 86cc0b75b..a53130c4a 100644
--- a/os/hal/ports/STM32/STM32U3xx/stm32_isr.h
+++ b/os/hal/ports/STM32/STM32U3xx/stm32_isr.h
@@ -136,6 +136,15 @@
 #define STM32_EXTI14_NUMBER                 25
 #define STM32_EXTI15_NUMBER                 26
 
+/*
+ * FDCAN units.
+ */
+#define STM32_FDCAN1_IT0_HANDLER            VectorDC
+#define STM32_FDCAN1_IT1_HANDLER            VectorE0
+
+#define STM32_FDCAN1_IT0_NUMBER             39
+#define STM32_FDCAN1_IT1_NUMBER             40
+
 /*
  * I2C units.
  */


Thanks!
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: CAN support for STM32U3

Post by Giovanni »

Hi,

FDCAN is enabled now.

Giovanni
Post Reply