|
1 /* |
|
2 This file is part of CanFestival, a library implementing CanOpen Stack. |
|
3 |
|
4 Copyright (C): Edouard TISSERANT and Francis DUPIN |
|
5 |
|
6 See COPYING file for copyrights details. |
|
7 |
|
8 This library is free software; you can redistribute it and/or |
|
9 modify it under the terms of the GNU Lesser General Public |
|
10 License as published by the Free Software Foundation; either |
|
11 version 2.1 of the License, or (at your option) any later version. |
|
12 |
|
13 This library is distributed in the hope that it will be useful, |
|
14 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16 Lesser General Public License for more details. |
|
17 |
|
18 You should have received a copy of the GNU Lesser General Public |
|
19 License along with this library; if not, write to the Free Software |
|
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
21 */ |
|
22 |
|
23 |
|
24 #ifndef __data_h__ |
|
25 #define __data_h__ |
|
26 |
|
27 // declaration of CO_Data type let us include all necessary headers |
|
28 // struct struct_CO_Data can then be defined later |
|
29 typedef struct struct_CO_Data CO_Data; |
|
30 |
|
31 #include <applicfg.h> |
|
32 #include "def.h" |
|
33 #include "can.h" |
|
34 #include "objdictdef.h" |
|
35 #include "objacces.h" |
|
36 #include "sdo.h" |
|
37 #include "pdo.h" |
|
38 #include "states.h" |
|
39 #include "lifegrd.h" |
|
40 #include "sync.h" |
|
41 #include "nmtMaster.h" |
|
42 |
|
43 // This structurs contains all necessary information for a CanOpen node |
|
44 struct struct_CO_Data { |
|
45 // Object dictionary |
|
46 UNS8 *bDeviceNodeId; |
|
47 const indextable *objdict; |
|
48 UNS8 *count_sync; |
|
49 quick_index *firstIndex; |
|
50 quick_index *lastIndex; |
|
51 UNS16 *ObjdictSize; |
|
52 const UNS8 *iam_a_slave; |
|
53 valueRangeTest_t valueRangeTest; |
|
54 |
|
55 // SDO |
|
56 s_transfer transfers[SDO_MAX_SIMULTANEOUS_TRANSFERTS]; |
|
57 SDOtimeoutError_t SDOtimeoutError; |
|
58 //s_sdo_parameter *sdo_parameters; |
|
59 |
|
60 // State machine |
|
61 e_nodeState nodeState; |
|
62 s_state_communication CurrentCommunicationState; |
|
63 initialisation_t initialisation; |
|
64 preOperational_t preOperational; |
|
65 operational_t operational; |
|
66 stopped_t stopped; |
|
67 |
|
68 // NMT-heartbeat |
|
69 UNS8 *ConsumerHeartbeatCount; |
|
70 UNS32 *ConsumerHeartbeatEntries; |
|
71 TIMER_HANDLE *ConsumerHeartBeatTimers; |
|
72 UNS16 *ProducerHeartBeatTime; |
|
73 TIMER_HANDLE ProducerHeartBeatTimer; |
|
74 heartbeatError_t heartbeatError; |
|
75 e_nodeState NMTable[NMT_MAX_NODE_ID]; |
|
76 |
|
77 // SYNC |
|
78 TIMER_HANDLE syncTimer; |
|
79 UNS32 *COB_ID_Sync; |
|
80 UNS32 *Sync_Cycle_Period; |
|
81 /*UNS32 *Sync_window_length*/; |
|
82 post_sync_t post_sync; |
|
83 post_TPDO_t post_TPDO; |
|
84 |
|
85 // PDO |
|
86 s_process_var process_var; |
|
87 |
|
88 // General |
|
89 UNS8 toggle; |
|
90 canSend_t canSend; |
|
91 scanIndexOD_t scanIndexOD; |
|
92 }; |
|
93 |
|
94 // A macro to initialize the data in client app. |
|
95 #define CANOPEN_NODE_DATA_INITIALIZER(NODE_PREFIX) {\ |
|
96 /* Object dictionary*/\ |
|
97 bDeviceNodeId:& NODE_PREFIX ## _bDeviceNodeId,\ |
|
98 objdict: NODE_PREFIX ## _objdict,\ |
|
99 count_sync: NODE_PREFIX ## _count_sync,\ |
|
100 firstIndex: & NODE_PREFIX ## _firstIndex,\ |
|
101 lastIndex: & NODE_PREFIX ## _lastIndex,\ |
|
102 ObjdictSize: & NODE_PREFIX ## _ObjdictSize,\ |
|
103 iam_a_slave: & NODE_PREFIX ## _iam_a_slave,\ |
|
104 valueRangeTest: NODE_PREFIX ## _valueRangeTest,\ |
|
105 \ |
|
106 /* SDO */\ |
|
107 transfers:{{\ |
|
108 nodeId: 0,\ |
|
109 index: 0,\ |
|
110 subIndex: 0,\ |
|
111 state: SDO_RESET,\ |
|
112 toggle: 0,\ |
|
113 count: 0,\ |
|
114 offset: 0,\ |
|
115 data: {0,},\ |
|
116 dataType: 0,\ |
|
117 timer: -1},},\ |
|
118 SDOtimeoutError: &NODE_PREFIX ## _SDOtimeoutError,\ |
|
119 \ |
|
120 /* State machine */\ |
|
121 nodeState:Unknown_state,\ |
|
122 CurrentCommunicationState:{\ |
|
123 csBoot_Up: 0,\ |
|
124 csSDO: 0,\ |
|
125 csEmergency: 0,\ |
|
126 csSYNC: 0,\ |
|
127 csHeartbeat: 0,\ |
|
128 csPDO: 0},\ |
|
129 initialisation: &NODE_PREFIX ## _initialisation,\ |
|
130 preOperational: &NODE_PREFIX ## _preOperational,\ |
|
131 operational: &NODE_PREFIX ## _operational,\ |
|
132 stopped: &NODE_PREFIX ## _stopped,\ |
|
133 \ |
|
134 /* NMT-heartbeat */\ |
|
135 ConsumerHeartbeatCount: & NODE_PREFIX ## _highestSubIndex_obj1016,\ |
|
136 ConsumerHeartbeatEntries: NODE_PREFIX ## _obj1016,\ |
|
137 ConsumerHeartBeatTimers: NODE_PREFIX ## _heartBeatTimers,\ |
|
138 ProducerHeartBeatTime: & NODE_PREFIX ## _obj1017,\ |
|
139 ProducerHeartBeatTimer: TIMER_NONE,\ |
|
140 heartbeatError: NODE_PREFIX ## _heartbeatError,\ |
|
141 NMTable:{Unknown_state,},\ |
|
142 \ |
|
143 /* SYNC */\ |
|
144 syncTimer: TIMER_NONE,\ |
|
145 COB_ID_Sync: & NODE_PREFIX ## _obj1005,\ |
|
146 Sync_Cycle_Period: & NODE_PREFIX ## _obj1006,\ |
|
147 /*Sync_window_length: & NODE_PREFIX ## _obj1007,*/\ |
|
148 post_sync: NODE_PREFIX ## _post_sync,\ |
|
149 post_TPDO: NODE_PREFIX ## _post_TPDO,\ |
|
150 \ |
|
151 /* PDO */\ |
|
152 process_var: {\ |
|
153 count: 0,\ |
|
154 data: {0,}},\ |
|
155 \ |
|
156 /* General */\ |
|
157 toggle: 0,\ |
|
158 canSend: NODE_PREFIX ## _canSend,\ |
|
159 scanIndexOD: NODE_PREFIX ## _scanIndexOD\ |
|
160 } |
|
161 |
|
162 #endif // __data_h__ |
|
163 |
|
164 |