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. Master unit.

Dependencies:   mbed

Committer:
ggudgel
Date:
Fri Oct 31 22:13:47 2014 +0000
Revision:
0:855b6e84e744
First working revision. Test functionality of one mbed system controlling another through SPI, while utilizing CAN bus lines.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ggudgel 0:855b6e84e744 1 #include "mbed.h"
ggudgel 0:855b6e84e744 2 #include "spiMasterProtocol.h"
ggudgel 0:855b6e84e744 3
ggudgel 0:855b6e84e744 4 // https://developer.mbed.org/forum/helloworld/topic/2541/
ggudgel 0:855b6e84e744 5
ggudgel 0:855b6e84e744 6 Serial pc(USBTX, USBRX); // tx, rx
ggudgel 0:855b6e84e744 7
ggudgel 0:855b6e84e744 8 int main() {
ggudgel 0:855b6e84e744 9 spiMasterProtocol* canDevice = new spiMasterProtocol();
ggudgel 0:855b6e84e744 10
ggudgel 0:855b6e84e744 11 pc.printf("======================================================\r\n");
ggudgel 0:855b6e84e744 12 pc.printf("Press any key to start...\r\n");
ggudgel 0:855b6e84e744 13 pc.getc(); // wait for keyboard
ggudgel 0:855b6e84e744 14
ggudgel 0:855b6e84e744 15 while (1) {
ggudgel 0:855b6e84e744 16
ggudgel 0:855b6e84e744 17 canDevice->get42();
ggudgel 0:855b6e84e744 18
ggudgel 0:855b6e84e744 19 wait(0.5); // Wait for 5 seconds for readability only
ggudgel 0:855b6e84e744 20
ggudgel 0:855b6e84e744 21 canDevice->get84();
ggudgel 0:855b6e84e744 22
ggudgel 0:855b6e84e744 23 wait(0.5);
ggudgel 0:855b6e84e744 24
ggudgel 0:855b6e84e744 25 }
ggudgel 0:855b6e84e744 26 }