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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

Go to the documentation of this file.
00001 
00002 /** @file
00003  *  @brief main program entry
00004  */
00005 
00006 #include "mbed.h"
00007 #include "CAN.h"
00008 
00009 #include "ppCANOpen.h"
00010 #include "Node_pin0808.h"
00011 
00012 DigitalOut boardLed (LED1);
00013 
00014 void InputScan ()
00015 {
00016     boardLed = !boardLed;
00017 }
00018 
00019 
00020 int main()
00021 {
00022 
00023     printf ("\r\n----- MAIN -----\r\n");
00024 
00025     /* blinker task*/
00026     boardLed = 0;
00027 
00028 //#define MASTER
00029 #ifdef MASTER
00030 
00031     /* CanOpen start */
00032     ServiceProvider service;
00033     printf ("----- READY -----\r\n");
00034 
00035     Node_pin0808 node1(2, &service);
00036     //Node_pin0808 node2(&service);
00037 
00038     service.PostNmtControl(1, NMT_CS_RESET_NODE);
00039     service.Run();
00040     service.PostNmtControl(2, NMT_CS_START);
00041     service.Run();
00042     service.PostNmtControl(3, NMT_CS_START);
00043     service.Run();
00044     service.PostNmtControl(4, NMT_CS_START);
00045     service.Run();
00046     service.PostNmtControl(5, NMT_CS_START);
00047     service.Run();
00048     service.PostNmtControl(6, NMT_CS_START);
00049     service.Run();
00050 
00051     while (1) {
00052         service.Run();
00053     }
00054 
00055 #else
00056 
00057     /* CanOpen start */
00058     ServiceProvider service;
00059     printf ("----- READY -----\r\n");
00060 
00061     Node_pin0808 node1(3, &service);
00062 
00063     while (1) {
00064         service.Run();
00065     }
00066 
00067 #endif
00068 
00069     printf ("----- END -------\r\n\n");
00070 
00071 }