Silvan Geissmann
/
canSender
sends on both can busses
Diff: main.cpp
- Revision:
- 0:777a6becd0b5
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Apr 30 05:47:18 2013 +0000 @@ -0,0 +1,46 @@ +#include "mbed.h" + + Ticker ticker; + DigitalOut led1(LED1); // senden1 OK + DigitalOut led2(LED2); // senden2 OK + DigitalOut led3(LED3); + DigitalOut led4(LED4); // alive + CAN can1(p9, p10); + CAN can2(p30, p29); + Serial pc(USBTX, USBRX); // tx, rx + + char counter = 0; + + void send() { + if(can1.write(CANMessage(1337, &counter, 1))) { + led1=1; + pc.printf("S: Message sent: %d Errors:%d \n\r", counter,can1.tderror()); + counter++; + } + else{ + led1 = 0; + } + if(can2.write(CANMessage(1337, &counter, 1))) { + led2=1; + pc.printf("S: Message sent: %d Errors:%d \n\r", counter,can2.tderror()); + counter++; + } + else{ + led2 = 0; + } + } + + + int main() { + ticker.attach(&send, 2.0); + pc.printf("S: Hi!"); + can1.frequency(125000); + can2.frequency(125000); + + while(1) { + //canIN.reset(); + + wait(0.2); + led4 =!led4; + } + } \ No newline at end of file