Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: USB2CAN.cpp
- Revision:
- 2:b0d87ab33e13
- Parent:
- 1:4097ba8d8a3c
--- 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()