by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"
Revision 0:81536a1c322c, committed 2013-06-16
- Comitter:
- robt
- Date:
- Sun Jun 16 15:39:27 2013 +0000
- Commit message:
- by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 81536a1c322c main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Jun 16 15:39:27 2013 +0000 @@ -0,0 +1,23 @@ +/* Program Example 13.4: CAN data write – sends an incrementing count value to the CAN bus every second. + */ +#include "mbed.h" +Serial pc(USBTX, USBRX); // tx, rx for Tera Term output + +DigitalOut led1(LED1); // status LED +CAN can1(p30, p29); // CAN interface +char counter = 0; +int main() { + printf("send... "); + while (1) { + // send value to CAN bus and monitor return value to check if CAN + // message was sent successfully. If so display, increment and toggle + if (can1.write(CANMessage(1, &counter, 1))) { + pc.printf("Message sent: %d\n", counter); // display + counter++; // increment + led1 = !led1; // toggle status LED + }else{ + can1.reset(); + } + wait(1); + } +}
diff -r 000000000000 -r 81536a1c322c mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Jun 16 15:39:27 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/b3110cd2dd17 \ No newline at end of file