Additional CAN example

Files at this revision

API Documentation at this revision

Comitter:
aashishc1988
Date:
Thu Oct 11 16:02:16 2018 +0000
Parent:
1:5791101761f9
Commit message:
The example was not compiling due to incorrect pinnames. Also, the example should error out properly if the board doesnt support CAN.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed_app.json Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Jan 20 11:39:47 2017 -0600
+++ b/main.cpp	Thu Oct 11 16:02:16 2018 +0000
@@ -1,8 +1,13 @@
 #include "mbed.h"
 
+#if defined (DEVICE_CAN) || defined(DOXYGEN_ONLY)
+
 Ticker ticker;
 DigitalOut led1(LED1);
 DigitalOut led2(LED2);
+/** The constructor takes in RX, and TX pin respectively.
+  * These pins, for this example, are defined in mbed_app.json
+  */
 CAN can1(MBED_CONF_APP_CAN1_RD, MBED_CONF_APP_CAN1_TD);
 CAN can2(MBED_CONF_APP_CAN2_RD, MBED_CONF_APP_CAN2_TD);
 char counter = 0;
@@ -30,3 +35,8 @@
         wait(0.2);
     }
 }
+
+#else
+  #error CAN NOT SUPPORTED
+  
+#endif
--- a/mbed_app.json	Fri Jan 20 11:39:47 2017 -0600
+++ b/mbed_app.json	Thu Oct 11 16:02:16 2018 +0000
@@ -1,18 +1,18 @@
 {
     "config": {
-        "CAN1_rd": {
+        "CAN1_RD": {
             "help": "CAN1 rd pin",
             "value": "NC"
         },
-        "CAN1_td": {
+        "CAN1_TD": {
             "help": "CAN1 td pin",
             "value": "NC"
         },
-        "CAN2_rd": {
+        "CAN2_RD": {
             "help": "CAN2 rd pin",
             "value": "NC"
         },
-        "CAN2_td": {
+        "CAN2_TD": {
             "help": "CAN2 td pin",
             "value": "NC"
         }
@@ -20,10 +20,10 @@
     },
     "target_overrides": {
         "LPC1768": {
-            "CAN1_rd": "p9",
-            "CAN1_td": "p10",
-            "CAN2_rd": "p30",
-            "CAN2_td": "p29"
+            "CAN1_RD": "p9",
+            "CAN1_TD": "p10",
+            "CAN2_RD": "p30",
+            "CAN2_TD": "p29"
         }
     }
 }