lu yonggang / Mbed OS USB2CAN

Files at this revision

API Documentation at this revision

Comitter:
luyongganglyg
Date:
Wed Mar 25 11:37:05 2020 +0000
Parent:
1:4097ba8d8a3c
Commit message:
can1 H743ZI

Changed in this revision

USB2CAN.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show diff for this revision Revisions of this file
--- a/USB2CAN.cpp	Tue May 31 12:04:38 2011 +0000
+++ b/USB2CAN.cpp	Wed Mar 25 11:37:05 2020 +0000
@@ -20,8 +20,7 @@
 DigitalOut read_activity(LED2); // CAN read toggle led
 DigitalOut pc_activity(LED3);   // USB activity toggle led
 DigitalOut live_led(LED4);      // Live toggle led
-CAN can(p30, p29);              // RD, TD
-
+CAN can1(PD_0, PD_1);              // RD, TD
 CANMessage msg;                 // The canmessage
 int pc_ID;                      // Standard 11bit ID
 int pc_IDe;                     // Extended 29bit ID
@@ -51,7 +50,7 @@
 // Reads a CANMessage and prints it's contents via serial
 {
     // Reading the message
-    can.read(msg);
+    can1.read(msg);
     
     // Printing what was read
     pc.printf("Read:    [ ID: %9x", msg.id);
@@ -94,7 +93,7 @@
     { // CANStandard
         if(pc_type==0) 
         { // CANData
-            if(can.write(CANMessage(pc_ID,candata,(char)pc_length,CANData,CANStandard))) 
+            if(can1.write(CANMessage(pc_ID,candata,(char)pc_length,CANData,CANStandard))) 
             {
                 pc.printf("MBED:    [ Message compiled and sent. ]\r\n");
                 write_activity = !write_activity;
@@ -102,7 +101,7 @@
         }
         else if(pc_type==1) 
         { // CANRemote
-            if(can.write(CANMessage(pc_ID,CANStandard))) {
+            if(can1.write(CANMessage(pc_ID,CANStandard))) {
                 pc.printf("MBED:    [ RTR Message compiled and sent. ]\r\n");
                 write_activity = !write_activity;
             }
@@ -112,7 +111,7 @@
     { // CANExtended
         if(pc_type==0) 
         { // CANData
-            if(can.write(CANMessage(pc_ID,candata,(char)pc_length,CANData,CANExtended))) 
+            if(can1.write(CANMessage(pc_ID,candata,(char)pc_length,CANData,CANExtended))) 
             {
                 pc.printf("MBED:    [ Message compiled and sent. ]\r\n");
                 write_activity = !write_activity;
@@ -120,7 +119,7 @@
         }
         else if(pc_type==1) 
         { // CANRemote
-            if(can.write(CANMessage(pc_ID,CANExtended))) {
+            if(can1.write(CANMessage(pc_ID,CANExtended))) {
                 pc.printf("MBED:    [ RTR Message compiled and sent. ]\r\n");
                 write_activity = !write_activity;
             }
@@ -131,9 +130,9 @@
 void initcan() 
 // Initializes MBED's CAN port
 {
-    can.frequency(1000000);             // 1Mbit/s
-    can.reset();
-    can.attach(&canread);               // Run canread on CAN reception interrupt
+    can1.frequency(1000000);             // 1Mbit/s
+    can1.reset();
+    can1.attach(&canread);               // Run canread on CAN reception interrupt
 }
 
 void liveled()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Wed Mar 25 11:37:05 2020 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#532654ebb31c7bf79601042a6fa976b85532ef47
--- a/mbed.bld	Tue May 31 12:04:38 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912