can_test for my case

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
hirokimineshita
Date:
Mon Apr 04 04:16:56 2016 +0000
Commit message:
can_test;

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 24cfc59b5220 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Apr 04 04:16:56 2016 +0000
@@ -0,0 +1,48 @@
+#include "mbed.h"
+ 
+Ticker ticker;
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+//BusOut led(LED1,LED2,LED3,LED4);
+CAN can2(p9, p10);
+CAN can1(p30, p29);
+char counter[8] = {0,0,0,0,0,0,0,0};
+int sub=0,j=1,count=0;
+ 
+void send() {
+    //printf("send()\n\r");
+    //led=counter[0];
+    if(j>40)j=1;
+    if(can2.write(CANMessage(j, counter, 8))) {
+        //printf("wloop()\n\r");
+        //printf("Message sent    :%3d: %3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d\n\r",j, counter[0],counter[1],counter[2],counter[3],counter[4],counter[5],counter[6],counter[7]);
+        sub++;
+        if(count==2){
+            j++;
+            count=0;
+        }
+        count++;
+        for(int i=0;i<8;i++)counter[i]=(sub>>(i*8))&255;
+        counter[7]=(4*3-j)/(4*3-j);
+    }
+    led1 = !led1;
+}
+ 
+int main() {
+    //led=0;
+    can2.frequency(1000000);
+    printf("main()\n\r");
+    //ticker.attach(&send, 0.1);
+    CANMessage msg;
+    while(1) {
+        //printf("loop()\n\r");
+        if(can2.read(msg)){
+            printf("%3d:%3d,%3d,%3d,%3d,%3d,%3d,%3d,%3d\n\r",msg.id,msg.data[0],msg.data[1],msg.data[2],msg.data[3],msg.data[4],msg.data[5],msg.data[6],msg.data[7]);
+            if(msg.id==4)led2 = !led2;
+        }
+            //led=msg.data[0];
+        
+        //wait(0.2);
+        
+    }
+}
diff -r 000000000000 -r 24cfc59b5220 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Apr 04 04:16:56 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/ba1f97679dad
\ No newline at end of file