Nuvoton / Mbed OS NuMaker-mbed-can

Files at this revision

API Documentation at this revision

Comitter:
ccli8
Date:
Wed Apr 17 17:41:40 2024 +0800
Parent:
9:bb7099cd4943
Child:
11:36d172d475fa
Commit message:
Disable filter #0

Reconfigure filter #0 to accept message ID 0 only.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Apr 17 17:33:23 2024 +0800
+++ b/main.cpp	Wed Apr 17 17:41:40 2024 +0800
@@ -93,7 +93,15 @@
     /* Attach irq function */
     canObj.attach(irq_callback, CAN::RxIrq);
 #endif
-    
+
+    /* According to link below, filter #0 will accept any message, and
+     * no other filters can accept messages without re-configuring filter #0.
+     * https://os.mbed.com/questions/85183/How-to-use-CAN-filter-function
+     *
+     * Re-configure filter #0 to accept message ID 0 only.
+     */
+    canObj.filter(0, 0xFFFFFFFF);
+
     canObj.filter(CAN_DEV_ID, 0, CANStandard, MSG_NUM_INDEX);
     
 #endif