CAN receive using interrupt

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
tknara
Date:
Mon Nov 12 13:23:15 2018 +0000
Commit message:
ok ;

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 6a28949eda55 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Nov 12 13:23:15 2018 +0000
@@ -0,0 +1,19 @@
+#include "mbed.h"
+Serial serial(PA_9,PA_10);
+DigitalOut myled(PB_3);
+CAN can(PA_11,PA_12);
+char counter = 0;
+CANMessage msg;
+void callback(){
+    if(can.read(msg)){
+        serial.printf("Message received: ID:%d,data0:%d,data1:%d\n",msg.id,msg.data[0],msg.data[1]);
+    }
+}
+int main() {
+    can.attach(&callback, CAN::RxIrq);
+    while(1) 
+    {
+        serial.printf("loop()\n");
+        wait(0.5);
+    }
+}
diff -r 000000000000 -r 6a28949eda55 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Nov 12 13:23:15 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187
\ No newline at end of file