Richard Adams
/
cantest2
CAN transmit test
Revision 1:f93dfec45007, committed 2010-06-24
- Comitter:
- richarda
- Date:
- Thu Jun 24 00:58:38 2010 +0000
- Parent:
- 0:fc2ffe77c811
- Commit message:
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Jun 23 19:40:24 2010 +0000 +++ b/main.cpp Thu Jun 24 00:58:38 2010 +0000 @@ -1,35 +1,26 @@ #include "mbed.h" Ticker ticker; -Ticker t2; DigitalOut led1(LED1); -DigitalOut led2(LED2); -//CAN can2(p9, p10); -CAN can2(p30, p29); +CAN can1(p30, p29); Serial pc(USBTX, USBRX); // tx, rx char counter = 0; void send() { static char counter = 0; - if (can2.write(CANMessage(1337, &counter, 1))) { + if (can1.write(CANMessage(0x200, &counter, 1))) { printf("CanTx--> id: 0x200 dlc: 1 data: %x\n\r", counter); - led2 = !led2; + led1 = !led1; counter++; - } else - led2 = 0; -} - -void blink() { - led1 = !led1; + } } int main() { pc.printf("\nCAN Test\n"); //250kbit/s - can2.frequency(250000); + can1.frequency(250000); // every 500ms ticker.attach(&send, 0.5); - t2.attach(&blink, 1.5); while (1); } \ No newline at end of file