Can sample

Dependencies:   mbed-dev

Fork of CAN_Hello by Zoltan Hudak

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 Ticker ticker;
00003 CAN can1(PA_11,PA_12);
00004 //CAN can2(PB_12,PB_13);
00005 Serial pc(USBTX,USBRX);
00006 char counter = 0;
00007 #define ID 7
00008 void send() {
00009     printf("send()\n");
00010     if(can1.write(CANMessage(ID, &counter, 1))) {
00011         printf("Message sent: %d\n", counter);
00012         counter++;
00013     } 
00014 }
00015  
00016 int main() {
00017     printf("main()\n");
00018     ticker.attach(&send,0.001);
00019     CANMessage msg;
00020     while(1) {
00021     }
00022 }