NNP STM Generic Remote Module git-main
Loading...
Searching...
No Matches
data.h
Go to the documentation of this file.
1
8#ifndef INC_DATA_H_
9#define INC_DATA_H_
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15
16/* declaration of CO_Data type lets us include all necessary headers
17 struct struct_CO_Data can then be defined later
18 */
19typedef struct struct_CO_Data CO_Data;
20
21#include "stm32l4xx.h"
22#include "applicfg.h"
23#include "def.h"
24#include "can.h"
25#include "objdictdef.h"
26#include "objacces.h"
27#include "boot.h"
28#include "sdo.h"
29#include "pdo.h"
30#include "states.h"
31#include "lifegrd.h"
32#include "sync.h"
33#include "nmtSlave.h"
34#include "nmtMaster.h"
35#include "emcy.h"
36#ifdef CO_ENABLE_LSS
37#include "lss.h"
38#endif
39
45 /* Object dictionary */
46 UNS8 *bDeviceNodeId;
47 const indextable *objdict;
48 s_PDO_status *PDO_status;
49 const quick_index *firstIndex;
50 const quick_index *lastIndex;
51 const UNS16 *ObjdictSize;
52 const UNS8 *iam_a_slave;
53 valueRangeTest_t valueRangeTest;
54
55 /* SDO */
56 s_transfer transfers[SDO_MAX_SIMULTANEOUS_TRANSFERTS];
57 /* s_sdo_parameter *sdo_parameters; */
58
59 /* State machine */
60 e_nodeState nodeState;
61 s_state_communication CurrentCommunicationState;
62 mode_X_Manual_t mode_X_Manual;
63 mode_Y_Manual_t mode_Y_Manual;
64 waiting_t waiting;
65 stopped_t stopped;
66 void (*NMT_Slave_Node_Reset_Callback)(CO_Data*);
67 void (*NMT_Slave_Communications_Reset_Callback)(CO_Data*);
68
69 /* NMT-heartbeat */
70 UNS8 *ConsumerHeartbeatCount;
71 UNS32 *ConsumerHeartbeatEntries;
72 TIMER_HANDLE *ConsumerHeartBeatTimers;
73 UNS16 *ProducerHeartBeatTime;
74 TIMER_HANDLE ProducerHeartBeatTimer;
75 heartbeatError_t heartbeatError;
76 e_nodeState NMTable[NMT_MAX_NODE_ID];
77
78 /* SYNC */
79 TIMER_HANDLE syncTimer;
80 UNS32 *COB_ID_Sync;
81 UNS32 *Sync_Cycle_Period;
82
83 post_sync_t post_sync;
84 post_TPDO_t post_TPDO;
85 post_SlaveBootup_t post_SlaveBootup;
86
87 /* General */
88 UNS8 toggle;
89 CAN_HandleTypeDef *canHandle;
90 scanIndexOD_t scanIndexOD;
91 storeODSubIndex_t storeODSubIndex;
92
93 /* DCF concise */
94 const indextable* dcf_odentry;
95 UNS8* dcf_cursor;
96 UNS32 dcf_entries_count;
97 UNS8 dcf_request;
98
99 /* EMCY */
100 e_errorState error_state;
101 UNS8 error_history_size;
102 UNS8* error_number;
103 UNS32* error_first_element;
104 UNS8* error_register;
105 UNS32* error_cobid;
106 s_errors error_data[EMCY_MAX_ERRORS];
107 post_emcy_t post_emcy;
108
109#ifdef CO_ENABLE_LSS
110 /* LSS */
111 lss_transfer_t lss_transfer;
112 lss_StoreConfiguration_t lss_StoreConfiguration;
113#endif
114};
115
116#define NMTable_Initializer Unknown_state,
117
118#define s_transfer_Initializer {\
119 0, /* nodeId */\
120 0, /* wohami */\
121 SDO_RESET, /* state */\
122 0, /* toggle */\
123 0, /* abortCode */\
124 0, /* index */\
125 0, /* subIndex */\
126 0, /* count */\
127 0, /* offset */\
128 {0}, /* data (static use, so that all the table is initialize at 0)*/\
129 0, /* dataType */\
130 -1, /* timer */\
131 NULL /* Callback */\
132 },
133
134#define ERROR_DATA_INITIALIZER { \
135 0, /* errCode */\
136 0, /* errRegMask */\
137 0 /* active */\
138 },
139
140#ifdef CO_ENABLE_LSS
141
142#ifdef CO_ENABLE_LSS_FS
143#define lss_fs_Initializer \
144 ,0, /* IDNumber */\
145 128, /* BitChecked */\
146 0, /* LSSSub */\
147 0, /* LSSNext */\
148 0, /* LSSPos */\
149 LSS_FS_RESET, /* FastScan_SM */\
150 -1, /* timerFS */\
151 {{0,0,0,0},{0,0,0,0}} /* lss_fs_transfer */
152#else
153#define lss_fs_Initializer
154#endif
155
156#define lss_Initializer {\
157 LSS_RESET, /* state */\
158 0, /* command */\
159 LSS_WAITING_MODE, /* mode */\
160 0, /* dat1 */\
161 0, /* dat2 */\
162 0, /* NodeID */\
163 0, /* addr_sel_match */\
164 0, /* addr_ident_match */\
165 "none", /* BaudRate */\
166 0, /* SwitchDelay */\
167 SDELAY_OFF, /* SwitchDelayState */\
168 NULL, /* canHandle_t */\
169 -1, /* TimerMSG */\
170 -1, /* TimerSDELAY */\
171 NULL, /* Callback */\
172 0 /* LSSanswer */\
173 lss_fs_Initializer /*FastScan service initialization */\
174 },\
175 NULL /* _lss_StoreConfiguration*/
176#else
177#define lss_Initializer
178#endif
179
180/* A macro to initialize the data in client app.*/
181/* CO_Data structure */
182
183#define CANOPEN_NODE_DATA_INITIALIZER(NODE_PREFIX){\
184 /* Object dictionary*/\
185 & NODE_PREFIX ## _bDeviceNodeId, /* bDeviceNodeId */\
186 NODE_PREFIX ## _objdict, /* objdict */\
187 NODE_PREFIX ## _PDO_status, /* PDO_status */\
188 & NODE_PREFIX ## _firstIndex, /* firstIndex */\
189 & NODE_PREFIX ## _lastIndex, /* lastIndex */\
190 & NODE_PREFIX ## _ObjdictSize, /* ObjdictSize */\
191 & NODE_PREFIX ## _iam_a_slave, /* iam_a_slave */\
192 NODE_PREFIX ## _valueRangeTest, /* valueRangeTest */\
193 \
194 /* SDO, structure s_transfer */\
195 {\
196 REPEAT_SDO_MAX_SIMULTANEOUS_TRANSFERTS_TIMES(s_transfer_Initializer)\
197 },\
198 \
199 /* State machine*/\
200 Unknown_state, /* default nodeState */\
201 /* structure s_state_communication */\
202 {\
203 0, /* csBoot_Up */\
204 0, /* csSDO */\
205 0, /* csEmergency */\
206 0, /* csSYNC */\
207 0, /* csHeartbeat */\
208 0, /* csPDO */\
209 0 /* csLSS */\
210 },\
211 _mode_Y_Manual, /* initialisation */\
212 _mode_X_Manual, /* preOperational */\
213 _waiting, /* operational */\
214 _stopped, /* stopped */\
215 NULL, /* NMT node reset callback */\
216 NULL, /* NMT communications reset callback */\
217 \
218 /* NMT-heartbeat */\
219 & NODE_PREFIX ## _highestSubIndex_obj1016, /* ConsumerHeartbeatCount */\
220 NODE_PREFIX ## _obj1016, /* ConsumerHeartbeatEntries */\
221 NODE_PREFIX ## _heartBeatTimers, /* ConsumerHeartBeatTimers */\
222 & NODE_PREFIX ## _obj1017, /* ProducerHeartBeatTime */\
223 TIMER_NONE, /* ProducerHeartBeatTimer */\
224 _heartbeatError, /* heartbeatError */\
225 \
226 {\
227 REPEAT_NMT_MAX_NODE_ID_TIMES(NMTable_Initializer)\
228 },\
229 /* is well initialized at "Unknown_state". Is it ok ? (FD)*/\
230 \
231 /* SYNC */\
232 TIMER_NONE, /* syncTimer */\
233 & NODE_PREFIX ## _obj1005, /* COB_ID_Sync */\
234 & NODE_PREFIX ## _obj1006, /* Sync_Cycle_Period */\
235 /*& NODE_PREFIX ## _obj1007, */ /* Sync_window_length */\
236 _post_sync, /* post_sync */\
237 _post_TPDO, /* post_TPDO */\
238 _post_SlaveBootup, /* post_SlaveBootup */\
239 \
240 /* General */\
241 0, /* toggle */\
242 NULL, /* canHandle */\
243 NODE_PREFIX ## _scanIndexOD, /* scanIndexOD */\
244 _storeODSubIndex, /* storeODSubIndex */\
245 /* DCF concise */\
246 NULL, /*dcf_odentry*/\
247 NULL, /*dcf_cursor*/\
248 1, /*dcf_entries_count*/\
249 0, /* dcf_request*/\
250 \
251 /* EMCY */\
252 Error_free, /* error_state */\
253 sizeof(NODE_PREFIX ## _obj1003) / sizeof(NODE_PREFIX ## _obj1003[0]), /* error_history_size */\
254 & NODE_PREFIX ## _highestSubIndex_obj1003, /* error_number */\
255 & NODE_PREFIX ## _obj1003[0], /* error_first_element */\
256 & NODE_PREFIX ## _obj1001, /* error_register */\
257 & NODE_PREFIX ## _obj1014, /* error_cobid */\
258 /* error_data: structure s_errors */\
259 {\
260 REPEAT_EMCY_MAX_ERRORS_TIMES(ERROR_DATA_INITIALIZER)\
261 },\
262 _post_emcy, /* post_emcy */\
263 /* LSS */\
264 lss_Initializer\
265}
266
267#ifdef __cplusplus
268};
269#endif
270
271#endif /* INC_DATA_H_ */
#define UNS8
Unsigned int8 representation in CANFest.
Definition applicfg.h:25
#define UNS16
Unsigned int16 representation in CANFest.
Definition applicfg.h:26
#define UNS32
Unsigned int32 representation in CANFest.
Definition applicfg.h:27
This structure contains all necessary informations to define a CANOpen node.
Definition data.h:44