SHENG-HEN HSIEH / Mbed 2 deprecated VDU_2021

Dependencies:   mbed imu_driver

Files at this revision

API Documentation at this revision

Comitter:
open4416
Date:
Sat May 26 16:03:33 2018 +0000
Child:
1:8a9ac822aab7
Commit message:
j

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat May 26 16:03:33 2018 +0000
@@ -0,0 +1,47 @@
+#include "mbed.h"
+
+Ticker ticker;
+CAN can1(PB_5, PB_13, 1000000);
+CAN can2(PA_11, PA_12, 1000000);
+
+CANMessage can_msg_1;
+CANMessage can_msg_2;
+
+uint8_t CAN_flag_1 = 0;
+uint8_t CAN_flag_2 = 0;
+
+void CAN1_RX(void);
+void CAN2_RX(void);
+
+int main()
+{
+    CAN_flag_1 = 0;
+    CAN_flag_2 = 0;
+    
+    can1.attach(&CAN1_RX, CAN::RxIrq);               //CAN1 Recieve Irq
+    can2.attach(&CAN2_RX, CAN::RxIrq);               //CAN2 Recieve Irq
+
+    while(1) {
+        while(CAN_flag_1 == 1) {
+            can2.write(can_msg_1);
+            CAN_flag_1 = 0;
+        }
+        while(CAN_flag_2 == 1) {
+            can1.write(can_msg_2);
+            CAN_flag_2 = 0;
+        }
+    }
+}
+
+void CAN1_RX(void)
+{
+    if(can1.read(can_msg_1)) {
+        CAN_flag_1 = 1;
+    }
+}
+void CAN2_RX(void)
+{
+    if(can2.read(can_msg_2)) {
+        CAN_flag_2 = 1;
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat May 26 16:03:33 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/5aab5a7997ee
\ No newline at end of file