10 |
10 |
11 static int init_level=0; |
11 static int init_level=0; |
12 extern int common_ticktime__; |
12 extern int common_ticktime__; |
13 |
13 |
14 |
14 |
15 static void ConfigureSlaveNode(CO_Data* d, UNS8 nodeId) |
15 static void Master_post_SlaveBootup(CO_Data* d, UNS8 nodeId) |
16 { |
16 { |
17 /* Put the master in operational mode */ |
17 /* Put the master in operational mode */ |
18 setState(d, Operational); |
18 setState(d, Operational); |
19 |
19 |
20 /* Ask slave node to go in operational mode */ |
20 /* Ask slave node to go in operational mode */ |
21 masterSendNMTstateChange (d, 0, NMT_Start_Node); |
21 masterSendNMTstateChange (d, 0, NMT_Start_Node); |
22 } |
22 } |
23 |
|
24 #define NODE_DECLARE(nodename, nodeid)\ |
|
25 void nodename##_preOperational()\ |
|
26 {\ |
|
27 ConfigureSlaveNode(&nodename##_Data, nodeid);\ |
|
28 }\ |
|
29 |
|
30 %(nodes_declare)s |
|
31 |
|
32 |
23 |
33 #define NODE_INIT(nodename, nodeid) \ |
24 #define NODE_INIT(nodename, nodeid) \ |
34 /* Artificially force sync state to 1 so that it is not started */\ |
25 /* Artificially force sync state to 1 so that it is not started */\ |
35 nodename##_Data.CurrentCommunicationState.csSYNC = -1;\ |
26 nodename##_Data.CurrentCommunicationState.csSYNC = -1;\ |
36 /* Force sync period to common_ticktime__ so that other node can read it*/\ |
27 /* Force sync period to common_ticktime__ so that other node can read it*/\ |
71 TimerCleanup(); |
63 TimerCleanup(); |
72 #endif |
64 #endif |
73 } |
65 } |
74 |
66 |
75 #define NODE_OPEN(nodename)\ |
67 #define NODE_OPEN(nodename)\ |
76 nodename##_Data.preOperational = nodename##_preOperational;\ |
68 nodename##_Data.post_SlaveBootup = Master_post_SlaveBootup;\ |
77 if(!canOpen(&nodename##Board,&nodename##_Data)){\ |
69 if(!canOpen(&nodename##Board,&nodename##_Data)){\ |
78 printf("Cannot open " #nodename " Board (%%s,%%s)\n",nodename##Board.busname, nodename##Board.baudrate);\ |
70 printf("Cannot open " #nodename " Board (%%s,%%s)\n",nodename##Board.busname, nodename##Board.baudrate);\ |
79 return -1;\ |
71 return -1;\ |
80 }\ |
72 }\ |
81 init_level++; |
73 init_level++; |