Canbus with interrupt
Dependencies: mbed
Revision 0:8cad60da149a, committed 2016-01-19
- Comitter:
- cagriakalin
- Date:
- Tue Jan 19 15:02:11 2016 +0000
- Commit message:
- Canbus with interrupt
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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Jan 19 15:02:11 2016 +0000 @@ -0,0 +1,41 @@ +#include "mbed.h" + +CAN canObject(p30,p29); +DigitalOut led1(LED1); +DigitalOut led2(LED2); +Serial pc(USBTX, USBRX); + +void test(void) { + led1= !led1; + return; +} + +bool speed() { + char can_msg[3]; + can_msg[0] = 0x3D; + can_msg[1] = 0x30; + can_msg[2] = 0x00; + + bool success = canObject.write(CANMessage(0x211, can_msg, 3)); + led2 = !led2; + return success; +} + +int main() +{ + pc.baud(115200); + wait(0.2); + canObject.frequency(250000); + wait(0.2); + + canObject.attach(&test, CAN::RxIrq); + + wait(1); + if(speed()); + wait(1); + if(speed()); + + while(1) { + + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Jan 19 15:02:11 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9296ab0bfc11 \ No newline at end of file