2 This file is part of CanFestival, a library implementing CanOpen Stack.
4 Copyright (C): Edouard TISSERANT and Francis DUPIN
6 See COPYING file for copyrights details.
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.
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.
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
30 /* declaration of CO_Data type let us include all necessary headers
31 struct struct_CO_Data can then be defined later
33 typedef struct struct_CO_Data CO_Data;
38 #include "objdictdef.h"
45 #include "nmtMaster.h"
48 /* This structurs contains all necessary information for a CanOpen node */
49 struct struct_CO_Data {
50 /* Object dictionary */
52 const indextable *objdict;
53 s_PDO_status *PDO_status;
54 quick_index *firstIndex;
55 quick_index *lastIndex;
57 const UNS8 *iam_a_slave;
58 valueRangeTest_t valueRangeTest;
61 s_transfer transfers[SDO_MAX_SIMULTANEOUS_TRANSFERTS];
62 /* s_sdo_parameter *sdo_parameters; */
65 e_nodeState nodeState;
66 s_state_communication CurrentCommunicationState;
67 initialisation_t initialisation;
68 preOperational_t preOperational;
69 operational_t operational;
73 UNS8 *ConsumerHeartbeatCount;
74 UNS32 *ConsumerHeartbeatEntries;
75 TIMER_HANDLE *ConsumerHeartBeatTimers;
76 UNS16 *ProducerHeartBeatTime;
77 TIMER_HANDLE ProducerHeartBeatTimer;
78 heartbeatError_t heartbeatError;
79 e_nodeState NMTable[NMT_MAX_NODE_ID];
82 TIMER_HANDLE syncTimer;
84 UNS32 *Sync_Cycle_Period;
85 /*UNS32 *Sync_window_length;;*/
86 post_sync_t post_sync;
87 post_TPDO_t post_TPDO;
92 scanIndexOD_t scanIndexOD;
93 storeODSubIndex_t storeODSubIndex;
97 UNS32 dcf_count_targets;
100 e_errorState error_state;
101 UNS8 error_history_size;
103 UNS32* error_first_element;
104 UNS8* error_register;
105 s_errors error_data[EMCY_MAX_ERRORS];
106 post_emcy_t post_emcy;
110 #define NMTable_Initializer Unknown_state,
112 #define s_transfer_Initializer {\
115 SDO_RESET, /* state */\
122 {0}, /* data (static use, so that all the table is initialize at 0)*/\
128 #define ERROR_DATA_INITIALIZER \
135 /* A macro to initialize the data in client app.*/
136 /* CO_Data structure */
137 #define CANOPEN_NODE_DATA_INITIALIZER(NODE_PREFIX) {\
138 /* Object dictionary*/\
139 & NODE_PREFIX ## _bDeviceNodeId, /* bDeviceNodeId */\
140 NODE_PREFIX ## _objdict, /* objdict */\
141 NODE_PREFIX ## _PDO_status, /* PDO_status */\
142 & NODE_PREFIX ## _firstIndex, /* firstIndex */\
143 & NODE_PREFIX ## _lastIndex, /* lastIndex */\
144 & NODE_PREFIX ## _ObjdictSize, /* ObjdictSize */\
145 & NODE_PREFIX ## _iam_a_slave, /* iam_a_slave */\
146 NODE_PREFIX ## _valueRangeTest, /* valueRangeTest */\
148 /* SDO, structure s_transfer */\
150 REPEAT_SDO_MAX_SIMULTANEOUS_TRANSFERTS_TIMES(s_transfer_Initializer)\
154 Unknown_state, /* nodeState */\
155 /* structure s_state_communication */\
159 0, /* csEmergency */\
161 0, /* csHeartbeat */\
164 _initialisation, /* initialisation */\
165 _preOperational, /* preOperational */\
166 _operational, /* operational */\
167 _stopped, /* stopped */\
170 & NODE_PREFIX ## _highestSubIndex_obj1016, /* ConsumerHeartbeatCount */\
171 NODE_PREFIX ## _obj1016, /* ConsumerHeartbeatEntries */\
172 NODE_PREFIX ## _heartBeatTimers, /* ConsumerHeartBeatTimers */\
173 & NODE_PREFIX ## _obj1017, /* ProducerHeartBeatTime */\
174 TIMER_NONE, /* ProducerHeartBeatTimer */\
175 _heartbeatError, /* heartbeatError */\
177 {REPEAT_NMT_MAX_NODE_ID_TIMES(NMTable_Initializer)},\
178 /* is well initialized at "Unknown_state". Is it ok ? (FD)*/\
181 TIMER_NONE, /* syncTimer */\
182 & NODE_PREFIX ## _obj1005, /* COB_ID_Sync */\
183 & NODE_PREFIX ## _obj1006, /* Sync_Cycle_Period */\
184 /*& NODE_PREFIX ## _obj1007, */ /* Sync_window_length */\
185 _post_sync, /* post_sync */\
186 _post_TPDO, /* post_TPDO */\
191 NODE_PREFIX ## _scanIndexOD, /* scanIndexOD */\
192 _storeODSubIndex, /* storeODSubIndex */\
193 NULL, /*dcf_cursor*/\
194 1, /*dcf_count_targets*/\
197 Error_free, /* error_state */\
198 sizeof(NODE_PREFIX ## _obj1003) / sizeof(NODE_PREFIX ## _obj1003[0]), /* error_history_size */\
199 & NODE_PREFIX ## _highestSubIndex_obj1003, /* error_number */\
200 & NODE_PREFIX ## _obj1003[0], /* error_first_element */\
201 & NODE_PREFIX ## _obj1001, /* error_register */\
202 /* error_data: structure s_errors */\
204 REPEAT_EMCY_MAX_ERRORS_TIMES(ERROR_DATA_INITIALIZER)\
206 _post_emcy /* post_emcy */\
213 #endif /* __data_h__ */