This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit aa02b358915d3e869f2d2e30ab167c8d06223e0c
Author: raiden00pl <[email protected]>
AuthorDate: Wed Nov 25 20:36:37 2026 +0100

    arch/arm/stm32u3: Add FDCAN support.
    
    Use the common FDCAN v1 driver for FDCAN1 and FDCAN2.  The U3 resets
    FDCAN in RCC_APB1RSTR2.  The board selects the FDCAN kernel clock with
    STM32_RCC_CCIPR1_FDCANSEL.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: raiden00pl <[email protected]>
---
 Documentation/guides/chip-specific/stm32_ports.rst   | 2 +-
 Documentation/platforms/arm/stm32u3/index.rst        | 2 +-
 arch/arm/src/common/stm32/stm32_fdcan_mcan_v1.c      | 3 +++
 arch/arm/src/common/stm32/stm32_fdcan_mcan_v1_sock.c | 3 +++
 arch/arm/src/stm32u3/Kconfig                         | 3 +++
 arch/arm/src/stm32u3/stm32u3xx_rcc.c                 | 8 ++++++++
 6 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/Documentation/guides/chip-specific/stm32_ports.rst 
b/Documentation/guides/chip-specific/stm32_ports.rst
index 1dbca1a96ac..e33785b922e 100644
--- a/Documentation/guides/chip-specific/stm32_ports.rst
+++ b/Documentation/guides/chip-specific/stm32_ports.rst
@@ -880,7 +880,7 @@ DAC           M33 v1        
arch/arm/src/common/stm32/stm32_dac_m33_v1.c
 DBGMCU        v5            not supported
 DLYB          to be done    not supported
 EXTI          M33M55 v1     
arch/arm/src/common/stm32/stm32_exti_gpio_m33m55_v1.c
-FDCAN         to be done    not supported
+FDCAN         FDCAN         arch/arm/src/common/stm32/stm32_fdcan_mcan_v1.c
 FLASH         to be done    not supported
 GPDMA         GPDMA         arch/arm/src/common/stm32/stm32_dma_gpdma.c
 GPIO          M33M55 v1     arch/arm/src/common/stm32/stm32_gpio_m33m55_v1.c
diff --git a/Documentation/platforms/arm/stm32u3/index.rst 
b/Documentation/platforms/arm/stm32u3/index.rst
index aa5868a3ad6..285b81411f6 100644
--- a/Documentation/platforms/arm/stm32u3/index.rst
+++ b/Documentation/platforms/arm/stm32u3/index.rst
@@ -39,7 +39,7 @@ CRC         No
 CRS         No
 DBGMCU      No
 DLYB        No
-FDCAN       No
+FDCAN       Yes
 FLASH       No
 GPDMA       No
 GTZC        No
diff --git a/arch/arm/src/common/stm32/stm32_fdcan_mcan_v1.c 
b/arch/arm/src/common/stm32/stm32_fdcan_mcan_v1.c
index 5bd25e2db6e..5fcc7647ffd 100644
--- a/arch/arm/src/common/stm32/stm32_fdcan_mcan_v1.c
+++ b/arch/arm/src/common/stm32/stm32_fdcan_mcan_v1.c
@@ -121,6 +121,9 @@
 #elif defined(RCC_APB1RSTR1_FDCANRST)
 #  define FDCAN_RSTR                 STM32_RCC_APB1RSTR1
 #  define FDCAN_RST                  RCC_APB1RSTR1_FDCANRST
+#elif defined(RCC_APB1RSTR2_FDCANRST)
+#  define FDCAN_RSTR                 STM32_RCC_APB1RSTR2
+#  define FDCAN_RST                  RCC_APB1RSTR2_FDCANRST
 #else
 #  define FDCAN_RSTR                 STM32_RCC_APB1RSTR
 #  define FDCAN_RST                  RCC_APB1RSTR_FDCANRST
diff --git a/arch/arm/src/common/stm32/stm32_fdcan_mcan_v1_sock.c 
b/arch/arm/src/common/stm32/stm32_fdcan_mcan_v1_sock.c
index 96ea1823d06..e2e96f368fa 100644
--- a/arch/arm/src/common/stm32/stm32_fdcan_mcan_v1_sock.c
+++ b/arch/arm/src/common/stm32/stm32_fdcan_mcan_v1_sock.c
@@ -135,6 +135,9 @@
 #elif defined(RCC_APB1RSTR1_FDCANRST)
 #  define FDCAN_RSTR                 STM32_RCC_APB1RSTR1
 #  define FDCAN_RST                  RCC_APB1RSTR1_FDCANRST
+#elif defined(RCC_APB1RSTR2_FDCANRST)
+#  define FDCAN_RSTR                 STM32_RCC_APB1RSTR2
+#  define FDCAN_RST                  RCC_APB1RSTR2_FDCANRST
 #else
 #  define FDCAN_RSTR                 STM32_RCC_APB1RSTR
 #  define FDCAN_RST                  RCC_APB1RSTR_FDCANRST
diff --git a/arch/arm/src/stm32u3/Kconfig b/arch/arm/src/stm32u3/Kconfig
index 8c310e52ec2..16c5c63403d 100644
--- a/arch/arm/src/stm32u3/Kconfig
+++ b/arch/arm/src/stm32u3/Kconfig
@@ -32,8 +32,11 @@ config STM32_U3_PERIPHERALS
        bool
        default y
        select STM32_HAVE_DMA1
+       select STM32_HAVE_FDCAN1
+       select STM32_HAVE_FDCAN2
        select STM32_HAVE_IP_DMA_GPDMA
        select STM32_HAVE_IP_EXTI_M33M55_V1
+       select STM32_HAVE_IP_FDCAN_MCAN_V1
        select STM32_HAVE_IP_GPIO_M33M55_V1
        select STM32_HAVE_IP_TIMERS_V3
        select STM32_HAVE_IP_DBGMCU_V5
diff --git a/arch/arm/src/stm32u3/stm32u3xx_rcc.c 
b/arch/arm/src/stm32u3/stm32u3xx_rcc.c
index 2820c90fe34..a7ecfbae44f 100644
--- a/arch/arm/src/stm32u3/stm32u3xx_rcc.c
+++ b/arch/arm/src/stm32u3/stm32u3xx_rcc.c
@@ -237,6 +237,14 @@ void stm32_rcc_enableperipherals(void)
 #endif
   modifyreg32(STM32_RCC_APB1ENR1, 0, regval);
 
+#ifdef CONFIG_STM32_FDCAN
+#  ifdef STM32_RCC_CCIPR1_FDCANSEL
+  modifyreg32(STM32_RCC_CCIPR1, RCC_CCIPR1_FDCANSEL,
+              STM32_RCC_CCIPR1_FDCANSEL);
+#  endif
+  modifyreg32(STM32_RCC_APB1ENR2, 0, RCC_APB1ENR2_FDCANEN);
+#endif
+
   regval = 0;
 #ifdef CONFIG_STM32_SYSCFG
   regval |= RCC_APB3ENR_SYSCFGEN;

Reply via email to