2/4

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
maxnagazumi
Date:
Wed Mar 04 09:34:52 2020 +0000
Commit message:
2/4

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 f61429c7c6c0 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Mar 04 09:34:52 2020 +0000
@@ -0,0 +1,46 @@
+#include "mbed.h"
+
+CAN can1(p30,p29);
+
+DigitalOut led(LED1);
+DigitalOut led2(LED2);
+
+Ticker ticker;
+
+char can_data1[2]= {0,0};
+int data1;
+float y;
+void can_send()
+{
+    data1=500;
+    can_data1[0]=data1>>8;
+    can_data1[1]=data1&255;
+    if(can1.write(CANMessage(1,can_data1,2))) {
+        led =1;
+        led2=0;
+        printf("send\r\n");
+    } else {
+        led=0;
+        led2=1;
+        printf("no send\r\n");
+    }
+    
+    CANMessage msg1;
+    if(can1.read(msg1)) {
+        if(msg1.id == 2) {
+            y=(short)((msg1.data[0]<<8)|msg1.data[1]);
+            if(y==1000) {
+                led=1;
+                led2=1;
+            } else {
+                led=0;
+                led2=0;
+            }
+        }
+    }
+}
+int main()
+{
+    can1.frequency(1000000);
+    ticker.attach(&can_send,0.01);
+}
diff -r 000000000000 -r f61429c7c6c0 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Mar 04 09:34:52 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file