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 66084dafb77d8da8aae3064ad58fdc879d6433f4
Author: Eren Terzioglu <[email protected]>
AuthorDate: Fri Jun 19 17:49:49 2026 +0200

    boards/risc-v/esp32p4: Add TWAI2 support for esp32p4
    
    Add TWAI2 support for esp32p4
    
    Signed-off-by: Eren Terzioglu <[email protected]>
---
 boards/risc-v/esp32p4/common/src/esp_board_twai.c             | 11 +++++++++++
 .../esp32p4/esp32p4-function-ev-board/src/esp32p4_bringup.c   | 11 +++++++++++
 2 files changed, 22 insertions(+)

diff --git a/boards/risc-v/esp32p4/common/src/esp_board_twai.c 
b/boards/risc-v/esp32p4/common/src/esp_board_twai.c
index 936c2f9e454..a3cab7e2f1f 100644
--- a/boards/risc-v/esp32p4/common/src/esp_board_twai.c
+++ b/boards/risc-v/esp32p4/common/src/esp_board_twai.c
@@ -98,6 +98,17 @@ int board_twai_setup(int port)
     }
 #endif /* CONFIG_ESPRESSIF_TWAI1 */
 
+#ifdef CONFIG_ESPRESSIF_TWAI2
+  /* Register the TWAI driver at "/dev/can2" */
+
+  ret = can_register("/dev/can2", twai);
+  if (ret < 0)
+    {
+      canerr("ERROR: TWAI2 register failed: %d\n", ret);
+      return ret;
+    }
+#endif /* CONFIG_ESPRESSIF_TWAI2 */
+
   return OK;
 #else
   return -ENODEV;
diff --git 
a/boards/risc-v/esp32p4/esp32p4-function-ev-board/src/esp32p4_bringup.c 
b/boards/risc-v/esp32p4/esp32p4-function-ev-board/src/esp32p4_bringup.c
index d4cc36bd60b..44322a8222e 100644
--- a/boards/risc-v/esp32p4/esp32p4-function-ev-board/src/esp32p4_bringup.c
+++ b/boards/risc-v/esp32p4/esp32p4-function-ev-board/src/esp32p4_bringup.c
@@ -401,6 +401,17 @@ int esp_bringup(void)
     }
 #endif
 
+#ifdef CONFIG_ESPRESSIF_TWAI2
+
+  /* Initialize TWAI and register the TWAI driver. */
+
+  ret = board_twai_setup(2);
+  if (ret < 0)
+    {
+      syslog(LOG_ERR, "ERROR: TWAI2 board_twai_setup failed: %d\n", ret);
+    }
+#endif
+
 #ifdef CONFIG_DEV_GPIO
   ret = esp_gpio_init();
   if (ret < 0)

Reply via email to