
CAN Testing Program for the 'Master' Half of the test
main.cpp@0:70922a074fba, 2013-08-07 (annotated)
- Committer:
- melse
- Date:
- Wed Aug 07 15:30:34 2013 +0000
- Revision:
- 0:70922a074fba
Initial Commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
melse | 0:70922a074fba | 1 | #include "mbed.h" |
melse | 0:70922a074fba | 2 | |
melse | 0:70922a074fba | 3 | Serial pcSerial(USBTX, USBRX); |
melse | 0:70922a074fba | 4 | CAN can(p9, p10); |
melse | 0:70922a074fba | 5 | char charBuffer; |
melse | 0:70922a074fba | 6 | DigitalOut led1(LED2); |
melse | 0:70922a074fba | 7 | DigitalOut led2(LED2); |
melse | 0:70922a074fba | 8 | |
melse | 0:70922a074fba | 9 | int main() { |
melse | 0:70922a074fba | 10 | pcSerial.baud(9600); |
melse | 0:70922a074fba | 11 | while(1) { |
melse | 0:70922a074fba | 12 | if (pcSerial.readable()) { |
melse | 0:70922a074fba | 13 | charBuffer = pcSerial.getc(); |
melse | 0:70922a074fba | 14 | if (can.write(CANMessage(1337, &charBuffer, 1))) { |
melse | 0:70922a074fba | 15 | pcSerial.printf("Writing: %c\n", charBuffer); |
melse | 0:70922a074fba | 16 | led2 = !led2; |
melse | 0:70922a074fba | 17 | } |
melse | 0:70922a074fba | 18 | led1 = !led1; |
melse | 0:70922a074fba | 19 | } |
melse | 0:70922a074fba | 20 | } |
melse | 0:70922a074fba | 21 | } |