Each LPC1768 is capable of controlling 2 CAN bus lines. Linking multiple chips together via SPI allows for more bus lines to be monitored simultaneously. Slave unit.

Dependencies:   mbed-rtos mbed

Revision:
0:a46303f3277c
diff -r 000000000000 -r a46303f3277c CAN_thread.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CAN_thread.cpp	Fri Oct 31 22:14:03 2014 +0000
@@ -0,0 +1,31 @@
+#include "mbed.h"
+#include "rtos.h"
+#include "CAN_thread.h"
+
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+CAN can1(p9, p10);
+CAN can2(p30, p29);
+char counter1 = 0;
+
+void sendBUS1(void const *args) {
+    if(can1.write(CANMessage(1337, &counter1, 1))) {
+        counter1++;
+    } 
+    led1 = !led1;
+}
+
+void CAN_thread (void const *args) {
+    can1.frequency(125000);
+    can2.frequency(125000);
+    
+    RtosTimer CAN1send(sendBUS1, osTimerPeriodic);
+    CAN1send.start(1000);
+    CANMessage msg;
+    while(1) {
+        if(can2.read(msg)) {
+            led2 = !led2;
+        } 
+        Thread::wait(10);
+    }
+}
\ No newline at end of file