Nuvoton
/
NuMaker-mbed-can
NUMAKER CAN sample
Revision 11:36d172d475fa, committed 7 months ago
- Comitter:
- ccli8
- Date:
- Wed Apr 17 17:47:56 2024 +0800
- Parent:
- 10:33d27c970411
- Commit message:
- Support loopback mode
To enable loopback mode, both TX and RX are required to enable.
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:41:40 2024 +0800 +++ b/main.cpp Wed Apr 17 17:47:56 2024 +0800 @@ -9,6 +9,11 @@ #define CAN_TX_MODE_TEST 0 #define CAN_RX_MODE_TEST 1 +#define CAN_LOOPBACK_MODE_TEST 0 +#if CAN_LOOPBACK_MODE_TEST && (!CAN_TX_MODE_TEST || !CAN_RX_MODE_TEST) +#error "Either TX or RX not enabled for loopback mode" +#endif + /* WARNING: Don't enable interrupt mode on receive side. It is not supported on Nuvoton targets. */ #define CAN_RX_IRQ_EN 0 #define LED_ALL_OFF led1=led2=led3=1 @@ -105,7 +110,14 @@ canObj.filter(CAN_DEV_ID, 0, CANStandard, MSG_NUM_INDEX); #endif - + +#if CAN_LOOPBACK_MODE_TEST + if (!canObj.mode(CAN::SilentTest)) { + printf("CAN: Configure to SilentTest mode failed\n\n"); + return EXIT_FAILURE; + } +#endif + while (true) {