I am no longer actively working on the ppCANOpen library, however, I want to publish this project so that anyone who wants to pick up any of the pieces can have a good example. This is a a project I was working on using the ppCANOpen library. It has a pretty in deep use of the object dictionary structure. And a number of functions to control high voltage pinball drivers, if you're into that sort of thing.
Dependencies: CANnucleo mbed ppCANOpen
Application/source/main.cpp@10:ec59d628ebdc, 2016-03-19 (annotated)
- Committer:
- ptpaterson
- Date:
- Sat Mar 19 01:44:35 2016 +0000
- Revision:
- 10:ec59d628ebdc
Final Submission (probs)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ptpaterson | 10:ec59d628ebdc | 1 | |
ptpaterson | 10:ec59d628ebdc | 2 | /** @file |
ptpaterson | 10:ec59d628ebdc | 3 | * @brief main program entry |
ptpaterson | 10:ec59d628ebdc | 4 | */ |
ptpaterson | 10:ec59d628ebdc | 5 | |
ptpaterson | 10:ec59d628ebdc | 6 | #include "mbed.h" |
ptpaterson | 10:ec59d628ebdc | 7 | #include "CAN.h" |
ptpaterson | 10:ec59d628ebdc | 8 | |
ptpaterson | 10:ec59d628ebdc | 9 | #include "ppCANOpen.h" |
ptpaterson | 10:ec59d628ebdc | 10 | #include "Node_pin0808.h" |
ptpaterson | 10:ec59d628ebdc | 11 | |
ptpaterson | 10:ec59d628ebdc | 12 | DigitalOut boardLed (LED1); |
ptpaterson | 10:ec59d628ebdc | 13 | |
ptpaterson | 10:ec59d628ebdc | 14 | void InputScan () |
ptpaterson | 10:ec59d628ebdc | 15 | { |
ptpaterson | 10:ec59d628ebdc | 16 | boardLed = !boardLed; |
ptpaterson | 10:ec59d628ebdc | 17 | } |
ptpaterson | 10:ec59d628ebdc | 18 | |
ptpaterson | 10:ec59d628ebdc | 19 | |
ptpaterson | 10:ec59d628ebdc | 20 | int main() |
ptpaterson | 10:ec59d628ebdc | 21 | { |
ptpaterson | 10:ec59d628ebdc | 22 | |
ptpaterson | 10:ec59d628ebdc | 23 | printf ("\r\n----- MAIN -----\r\n"); |
ptpaterson | 10:ec59d628ebdc | 24 | |
ptpaterson | 10:ec59d628ebdc | 25 | /* blinker task*/ |
ptpaterson | 10:ec59d628ebdc | 26 | boardLed = 0; |
ptpaterson | 10:ec59d628ebdc | 27 | |
ptpaterson | 10:ec59d628ebdc | 28 | //#define MASTER |
ptpaterson | 10:ec59d628ebdc | 29 | #ifdef MASTER |
ptpaterson | 10:ec59d628ebdc | 30 | |
ptpaterson | 10:ec59d628ebdc | 31 | /* CanOpen start */ |
ptpaterson | 10:ec59d628ebdc | 32 | ServiceProvider service; |
ptpaterson | 10:ec59d628ebdc | 33 | printf ("----- READY -----\r\n"); |
ptpaterson | 10:ec59d628ebdc | 34 | |
ptpaterson | 10:ec59d628ebdc | 35 | Node_pin0808 node1(2, &service); |
ptpaterson | 10:ec59d628ebdc | 36 | //Node_pin0808 node2(&service); |
ptpaterson | 10:ec59d628ebdc | 37 | |
ptpaterson | 10:ec59d628ebdc | 38 | service.PostNmtControl(1, NMT_CS_RESET_NODE); |
ptpaterson | 10:ec59d628ebdc | 39 | service.Run(); |
ptpaterson | 10:ec59d628ebdc | 40 | service.PostNmtControl(2, NMT_CS_START); |
ptpaterson | 10:ec59d628ebdc | 41 | service.Run(); |
ptpaterson | 10:ec59d628ebdc | 42 | service.PostNmtControl(3, NMT_CS_START); |
ptpaterson | 10:ec59d628ebdc | 43 | service.Run(); |
ptpaterson | 10:ec59d628ebdc | 44 | service.PostNmtControl(4, NMT_CS_START); |
ptpaterson | 10:ec59d628ebdc | 45 | service.Run(); |
ptpaterson | 10:ec59d628ebdc | 46 | service.PostNmtControl(5, NMT_CS_START); |
ptpaterson | 10:ec59d628ebdc | 47 | service.Run(); |
ptpaterson | 10:ec59d628ebdc | 48 | service.PostNmtControl(6, NMT_CS_START); |
ptpaterson | 10:ec59d628ebdc | 49 | service.Run(); |
ptpaterson | 10:ec59d628ebdc | 50 | |
ptpaterson | 10:ec59d628ebdc | 51 | while (1) { |
ptpaterson | 10:ec59d628ebdc | 52 | service.Run(); |
ptpaterson | 10:ec59d628ebdc | 53 | } |
ptpaterson | 10:ec59d628ebdc | 54 | |
ptpaterson | 10:ec59d628ebdc | 55 | #else |
ptpaterson | 10:ec59d628ebdc | 56 | |
ptpaterson | 10:ec59d628ebdc | 57 | /* CanOpen start */ |
ptpaterson | 10:ec59d628ebdc | 58 | ServiceProvider service; |
ptpaterson | 10:ec59d628ebdc | 59 | printf ("----- READY -----\r\n"); |
ptpaterson | 10:ec59d628ebdc | 60 | |
ptpaterson | 10:ec59d628ebdc | 61 | Node_pin0808 node1(3, &service); |
ptpaterson | 10:ec59d628ebdc | 62 | |
ptpaterson | 10:ec59d628ebdc | 63 | while (1) { |
ptpaterson | 10:ec59d628ebdc | 64 | service.Run(); |
ptpaterson | 10:ec59d628ebdc | 65 | } |
ptpaterson | 10:ec59d628ebdc | 66 | |
ptpaterson | 10:ec59d628ebdc | 67 | #endif |
ptpaterson | 10:ec59d628ebdc | 68 | |
ptpaterson | 10:ec59d628ebdc | 69 | printf ("----- END -------\r\n\n"); |
ptpaterson | 10:ec59d628ebdc | 70 | |
ptpaterson | 10:ec59d628ebdc | 71 | } |