This one takes CAN data and spits it out over USB serial

Dependencies:   mbed

Committer:
melse
Date:
Wed Aug 07 15:31:41 2013 +0000
Revision:
0:133e0824c63d
Initial Commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
melse 0:133e0824c63d 1 #include "mbed.h"
melse 0:133e0824c63d 2
melse 0:133e0824c63d 3 CAN can(p9, p10);
melse 0:133e0824c63d 4 Serial pcSerial(USBTX, USBRX);
melse 0:133e0824c63d 5 DigitalOut led(LED1);
melse 0:133e0824c63d 6
melse 0:133e0824c63d 7 int main() {
melse 0:133e0824c63d 8 pcSerial.baud(9600);
melse 0:133e0824c63d 9 CANMessage msg;
melse 0:133e0824c63d 10 while(1) {
melse 0:133e0824c63d 11 if (can.read(msg)) {
melse 0:133e0824c63d 12 // Write the data to serial...
melse 0:133e0824c63d 13 pcSerial.printf("Message received: %d\n", msg.data[0]);
melse 0:133e0824c63d 14 led = !led;
melse 0:133e0824c63d 15 }
melse 0:133e0824c63d 16 }
melse 0:133e0824c63d 17 }