Demonstration example for CanPipe Library.
Revision 0:5abca479f387, committed 2016-11-04
- Comitter:
- ptpaterson
- Date:
- Fri Nov 04 13:54:35 2016 +0000
- Child:
- 1:7cf308c1484d
- Commit message:
- documentation
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CanPipe.lib Fri Nov 04 13:54:35 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/ptpaterson/code/CanPipe/#07d73bfb6bea
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Nov 04 13:54:35 2016 +0000
@@ -0,0 +1,37 @@
+#include "mbed.h"
+#include "CanPipe.h"
+
+Ticker ticker;
+DigitalOut led1(LED1);
+
+CAN m_can(P0_11, P0_31);
+CanPipe m_can_pipe(&m_can);
+
+char counter = 0;
+
+void send() {
+ led1 = !led1;
+ m_can_pipe.PostMessage(CANMessage(1337, &counter, 1));
+}
+
+int callback1(CANMessage &msg) { return CanPipe::kOkay; }
+int callback2(CANMessage &msg) { return CanPipe::kOkay; }
+int callback3(CANMessage &msg) { return CanPipe::kOkay; }
+
+int main() {
+ int handle;
+
+ handle = m_can_pipe.RegisterFilter(0x200, 0x780);
+ m_can_pipe.RegisterCallback(callback1, handle);
+
+ handle = m_can_pipe.RegisterFilter(0x281, 0x780);
+ m_can_pipe.RegisterCallback(callback2, handle);
+ m_can_pipe.RegisterCallback(callback3, handle);
+
+ ticker.attach(send, 1);
+
+ while (1) {
+ __WFI(); //sleep();
+ m_can_pipe.HandleMessages();
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Nov 04 13:54:35 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9bcdf88f62b0 \ No newline at end of file