Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:c4747ebbe0b4, committed 2018-05-26
- 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