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 #include <stddef.h> |
|
24 |
|
25 #include <applicfg.h> |
|
26 #include "def.h" |
|
27 #include "can.h" |
|
28 #include "objdictdef.h" |
|
29 #include "pdo.h" |
|
30 #include "sdo.h" |
|
31 #include "sync.h" |
|
32 #include "lifegrd.h" |
|
33 #include "nmtSlave.h" |
|
34 |
|
35 /**************************************************************************/ |
|
36 /* Declaration of the mapped variables */ |
|
37 /**************************************************************************/ |
|
38 |
|
39 |
|
40 |
|
41 /*// Copy and uncomment this code to your main file |
|
42 extern UNS32 canopenErrNB_node5; // Mapped at index 0x6000, subindex 0x00 |
|
43 extern UNS32 canopenErrVAL_node5; // Mapped at index 0x6001, subindex 0x00 |
|
44 extern UNS8 second; // Mapped at index 0x6002, subindex 0x01 |
|
45 extern UNS8 minutes; // Mapped at index 0x6002, subindex 0x02 |
|
46 extern UNS8 hour; // Mapped at index 0x6002, subindex 0x03 |
|
47 extern UNS8 day; // Mapped at index 0x6002, subindex 0x04 |
|
48 extern UNS32 canopenErrNB; // Mapped at index 0x6003, subindex 0x01 |
|
49 extern UNS32 canopenErrVAL; // Mapped at index 0x6003, subindex 0x02 |
|
50 |
|
51 // END copy to main file |
|
52 */ |
|
53 |
|
54 UNS32 canopenErrNB_node5; // Mapped at index 0x6000, subindex 0x00 |
|
55 UNS32 canopenErrVAL_node5; // Mapped at index 0x6001, subindex 0x00 |
|
56 UNS8 second; // Mapped at index 0x6002, subindex 0x01 |
|
57 UNS8 minutes; // Mapped at index 0x6002, subindex 0x02 |
|
58 UNS8 hour; // Mapped at index 0x6002, subindex 0x03 |
|
59 UNS8 day; // Mapped at index 0x6002, subindex 0x04 |
|
60 UNS32 canopenErrNB; // Mapped at index 0x6003, subindex 0x01 |
|
61 UNS32 canopenErrVAL; // Mapped at index 0x6003, subindex 0x02 |
|
62 |
|
63 /**************************************************************************/ |
|
64 /* Declaration of the value range types */ |
|
65 /**************************************************************************/ |
|
66 |
|
67 |
|
68 |
|
69 UNS32 valueRangeTest (UNS8 typeValue, UNS32 unsValue, REAL32 realValue) |
|
70 { |
|
71 return 0; |
|
72 } |
|
73 |
|
74 |
|
75 /**************************************************************************/ |
|
76 /* The node id */ |
|
77 /**************************************************************************/ |
|
78 /* Computed by strNode */ |
|
79 /* node_id default value. |
|
80 This default value is deprecated. |
|
81 You should always overwrite this by using the function setNodeId(UNS8 nodeId) in your C code. |
|
82 */ |
|
83 #define NODE_ID 0x01 |
|
84 UNS8 bDeviceNodeId = NODE_ID; |
|
85 |
|
86 |
|
87 //*****************************************************************************/ |
|
88 /* Computed by strStartDico */ |
|
89 |
|
90 /* Array of message processing information */ |
|
91 /* Should not be modified */ |
|
92 volatile const proceed_info proceed_infos[] = { |
|
93 {NMT, "NMT", NULL}, |
|
94 {SYNC, "SYNC", proceedSYNC}, |
|
95 {TIME_STAMP, "TStmp", NULL}, |
|
96 {PDO1tx, "PDO1t", proceedPDO}, |
|
97 {PDO1rx, "PDO1r", proceedPDO}, |
|
98 {PDO2tx, "PDO2t", proceedPDO}, |
|
99 {PDO2rx, "PDO2r", proceedPDO}, |
|
100 {PDO3tx, "PDO3t", proceedPDO}, |
|
101 {PDO3rx, "PDO3r", proceedPDO}, |
|
102 {PDO4tx, "PDO4t", proceedPDO}, |
|
103 {PDO4rx, "PDO4r", proceedPDO}, |
|
104 {SDOtx, "SDOt", proceedSDO}, |
|
105 {SDOrx, "SDOr", proceedSDO}, |
|
106 {0xD, "Unkw", NULL}, |
|
107 {NODE_GUARD, "NGrd", proceedNMTerror}, |
|
108 {0xF, "Unkw", NULL} |
|
109 }; |
|
110 |
|
111 // Macros definition |
|
112 |
|
113 /* Beware : |
|
114 index *must* be writen 4 numbers in hexa |
|
115 sub_index *must* be writen 2 numbers in hexa |
|
116 size_variable_in_UNS8 *must* be writen 2 numbers in hexa |
|
117 */ |
|
118 #define PDO_MAP(index, sub_index, size_variable_in_bits)\ |
|
119 0x ## index ## sub_index ## size_variable_in_bits |
|
120 |
|
121 //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ |
|
122 // |
|
123 // OBJECT DICTIONARY |
|
124 // |
|
125 //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ |
|
126 // Make your change, depending of your application |
|
127 |
|
128 |
|
129 /* index 0x1000 : Device type. |
|
130 You have to change the value below, so |
|
131 it fits your canopen-slave-module */ |
|
132 |
|
133 /* Not used, so, should not be modified */ |
|
134 |
|
135 UNS32 obj1000 = 0; |
|
136 subindex Index1000[] = |
|
137 { |
|
138 { RO, uint32, sizeof(UNS32), (void*)&obj1000 } |
|
139 }; |
|
140 |
|
141 /* index 0x1001 : Error register. |
|
142 Change the entries to fit your application |
|
143 Not used, so, should not be modified */ |
|
144 /*const*/ UNS8 obj1001 = 0x0; |
|
145 /*const*/ subindex Index1001[] = |
|
146 { |
|
147 { RO, uint8, sizeof(UNS8), (void*)&obj1001 } |
|
148 }; |
|
149 |
|
150 /* index 0x1005 : COB_ID SYNC */ |
|
151 /* Should not be modified */ |
|
152 UNS32 obj1005 = 0x00000080; // bit 30 = 1 : device can generate a SYNC message |
|
153 // Beware, it is over written when the node |
|
154 // enters in reset mode |
|
155 // See initResetMode() in init.c |
|
156 /*const*/ subindex Index1005[] = |
|
157 { |
|
158 { RW, uint32, sizeof(UNS32), (void*)&obj1005 } |
|
159 }; |
|
160 |
|
161 /* index 0x1006 : SYNC period */ |
|
162 // For producing the SYNC signal every n micro-seconds. |
|
163 // Put O to not producing SYNC |
|
164 /*const*/ UNS32 obj1006 = 0x0; |
|
165 // Default 0 to not produce SYNC // |
|
166 // Beware, it is over written when the |
|
167 // node enters in reset mode. |
|
168 // See initResetMode() in init.c |
|
169 /*const*/ subindex Index1006[] = |
|
170 { |
|
171 { RW, uint32, sizeof(UNS32), (void*)&obj1006 } |
|
172 }; |
|
173 |
|
174 /* index 0x1007 : Synchronous Window Length |
|
175 Seems to be needed by DS401 to generate the SYNC signal ! */ |
|
176 /*const*/ UNS32 obj1007 = 0x0; /* Default 0 */ |
|
177 /*const*/ subindex Index1007[] = |
|
178 { |
|
179 { RW, uint32, sizeof(UNS32), (void*)&obj1007 } |
|
180 }; |
|
181 |
|
182 /* index 0x1008 : Manufacturer device name */ |
|
183 UNS8 obj1008[] = "Appli_Master_Linux"; /* Default 0 */ |
|
184 subindex Index1008[] = |
|
185 { |
|
186 { RO, uint32, sizeof(obj1008), (void*)&obj1008 } |
|
187 }; |
|
188 |
|
189 /* index 0x1009 : Manufacturer hardware version */ |
|
190 UNS8 obj1009[] = __DATE__; /* Default 0 */ |
|
191 subindex Index1009[] = |
|
192 { |
|
193 { RO, uint32, sizeof(obj1009), (void*)&obj1009 } |
|
194 }; |
|
195 |
|
196 /* index 0x100A : Manufacturer software version */ |
|
197 UNS8 obj100A[] = __TIME__; /* Default 0 */ |
|
198 subindex Index100A[] = |
|
199 { |
|
200 { RO, uint32, sizeof(obj100A), (void*)&obj100A} |
|
201 }; |
|
202 |
|
203 /* index 0x1016 : HeartBeat consumers |
|
204 The nodes which can send a heartbeat */ |
|
205 static UNS32 obj1016[] = {// Consumer time for each node |
|
206 0x00000000}; // Format 0x00NNTTTT (N=Node T=time in ms) |
|
207 |
|
208 static UNS8 obj1016_cnt = 1; // 1 nodes could send me |
|
209 // their heartbeat. |
|
210 subindex Index1016[] = |
|
211 { |
|
212 { RO, uint8, sizeof(UNS8), (void*)&obj1016_cnt }, |
|
213 { RW, uint32, sizeof(UNS32), (void*)&obj1016[0] } |
|
214 }; |
|
215 |
|
216 /* index 0x1017 : Heartbeat producer |
|
217 Every HBProducerTime, the node sends its heartbeat */ |
|
218 static UNS16 obj1017 = 0; //HBProducerTime in ms. If 0 : not activated |
|
219 // Beware, it is over written when the |
|
220 // node enters in reset mode. |
|
221 // See initResetMode() in init.c |
|
222 subindex Index1017[] = |
|
223 { |
|
224 { RW, uint16, sizeof(UNS16), &obj1017 } |
|
225 }; |
|
226 |
|
227 /* index 0x1018 : Identity object */ |
|
228 /** index 1018: identify object. Adjust the entries for your node/company |
|
229 */ |
|
230 /* Values can be modified */ |
|
231 |
|
232 s_identity obj1018 = |
|
233 { |
|
234 4, // number of supported entries |
|
235 0, // Vendor-ID (given by the can-cia) |
|
236 0, // Product Code |
|
237 0, // Revision number |
|
238 0 // serial number |
|
239 }; |
|
240 |
|
241 subindex Index1018[] = |
|
242 { |
|
243 { RO, uint8, sizeof(UNS8), (void*)&obj1018.count }, |
|
244 { RO, uint32, sizeof(UNS32), (void*)&obj1018.vendor_id}, |
|
245 { RO, uint32, sizeof(UNS32), (void*)&obj1018.product_code}, |
|
246 { RO, uint32, sizeof(UNS32), (void*)&obj1018.revision_number}, |
|
247 { RO, uint32, sizeof(UNS32), (void*)&obj1018.serial_number} |
|
248 }; |
|
249 |
|
250 /* index 0x1200 : The SDO Server parameters */ |
|
251 /* BEWARE You cannot define more than one SDO server */ |
|
252 /* The values should not be modified here, |
|
253 but can be changed at runtime */ |
|
254 // Beware that the default values that you could put here |
|
255 // will be over written at the initialisation of the node. |
|
256 // See setNodeId() in init.c |
|
257 static s_sdo_parameter obj1200 = |
|
258 { 3, // Number of entries. Always 3 for the SDO |
|
259 0x600 + NODE_ID, // The cob_id transmited in CAN msg to the server |
|
260 0x580 + NODE_ID, // The cob_id received in CAN msg from the server |
|
261 NODE_ID // The node id of the client. Should not be modified |
|
262 }; |
|
263 static subindex Index1200[] = |
|
264 { |
|
265 { RO, uint8, sizeof( UNS8 ), (void*)&obj1200.count }, |
|
266 { RO, uint32, sizeof( UNS32), (void*)&obj1200.cob_id_client }, |
|
267 { RO, uint32, sizeof( UNS32), (void*)&obj1200.cob_id_server }, |
|
268 { RW, uint8, sizeof( UNS8), (void*)&obj1200.node_id } |
|
269 }; |
|
270 |
|
271 /* index 0x1280 : SDO client parameter */ |
|
272 static s_sdo_parameter obj1280 = |
|
273 { 3, // Nb of entries |
|
274 0x600, // cobid transmited to the server. The good value should be 0x600 + server nodeId |
|
275 0x580, // cobid received from the server. The good value should be 0x580 + server nodeId |
|
276 0x0 // server NodeId |
|
277 }; |
|
278 static subindex Index1280[] = |
|
279 { |
|
280 { RO, uint8, sizeof( UNS8 ), (void*)&obj1280.count }, |
|
281 { RW, uint8, sizeof( UNS32 ), (void*)&obj1280.cob_id_client }, |
|
282 { RW, uint8, sizeof( UNS32 ), (void*)&obj1280.cob_id_server }, |
|
283 { RW, uint8, sizeof( UNS8 ), (void*)&obj1280.node_id } |
|
284 }; |
|
285 |
|
286 /* index 0x1281 : SDO client parameter */ |
|
287 static s_sdo_parameter obj1281 = |
|
288 { 3, // Nb of entries |
|
289 0x600, // cobid transmited to the server. The good value should be 0x600 + server nodeId |
|
290 0x580, // cobid received from the server. The good value should be 0x580 + server nodeId |
|
291 0x0 // server NodeId |
|
292 }; |
|
293 static subindex Index1281[] = |
|
294 { |
|
295 { RO, uint8, sizeof( UNS8 ), (void*)&obj1281.count }, |
|
296 { RW, uint8, sizeof( UNS32 ), (void*)&obj1281.cob_id_client }, |
|
297 { RW, uint8, sizeof( UNS32 ), (void*)&obj1281.cob_id_server }, |
|
298 { RW, uint8, sizeof( UNS8 ), (void*)&obj1281.node_id } |
|
299 }; |
|
300 |
|
301 /* index 0x1282 : SDO client parameter */ |
|
302 static s_sdo_parameter obj1282 = |
|
303 { 3, // Nb of entries |
|
304 0x600, // cobid transmited to the server. The good value should be 0x600 + server nodeId |
|
305 0x580, // cobid received from the server. The good value should be 0x580 + server nodeId |
|
306 0x0 // server NodeId |
|
307 }; |
|
308 static subindex Index1282[] = |
|
309 { |
|
310 { RO, uint8, sizeof( UNS8 ), (void*)&obj1282.count }, |
|
311 { RW, uint8, sizeof( UNS32 ), (void*)&obj1282.cob_id_client }, |
|
312 { RW, uint8, sizeof( UNS32 ), (void*)&obj1282.cob_id_server }, |
|
313 { RW, uint8, sizeof( UNS8 ), (void*)&obj1282.node_id } |
|
314 }; |
|
315 |
|
316 /* index 0x1283 : SDO client parameter */ |
|
317 static s_sdo_parameter obj1283 = |
|
318 { 3, // Nb of entries |
|
319 0x600, // cobid transmited to the server. The good value should be 0x600 + server nodeId |
|
320 0x580, // cobid received from the server. The good value should be 0x580 + server nodeId |
|
321 0x0 // server NodeId |
|
322 }; |
|
323 static subindex Index1283[] = |
|
324 { |
|
325 { RO, uint8, sizeof( UNS8 ), (void*)&obj1283.count }, |
|
326 { RW, uint8, sizeof( UNS32 ), (void*)&obj1283.cob_id_client }, |
|
327 { RW, uint8, sizeof( UNS32 ), (void*)&obj1283.cob_id_server }, |
|
328 { RW, uint8, sizeof( UNS8 ), (void*)&obj1283.node_id } |
|
329 }; |
|
330 |
|
331 /* index 0x1284 : SDO client parameter */ |
|
332 static s_sdo_parameter obj1284 = |
|
333 { 3, // Nb of entries |
|
334 0x600, // cobid transmited to the server. The good value should be 0x600 + server nodeId |
|
335 0x580, // cobid received from the server. The good value should be 0x580 + server nodeId |
|
336 0x0 // server NodeId |
|
337 }; |
|
338 static subindex Index1284[] = |
|
339 { |
|
340 { RO, uint8, sizeof( UNS8 ), (void*)&obj1284.count }, |
|
341 { RW, uint8, sizeof( UNS32 ), (void*)&obj1284.cob_id_client }, |
|
342 { RW, uint8, sizeof( UNS32 ), (void*)&obj1284.cob_id_server }, |
|
343 { RW, uint8, sizeof( UNS8 ), (void*)&obj1284.node_id } |
|
344 }; |
|
345 |
|
346 /* index 0x1285 : SDO client parameter */ |
|
347 static s_sdo_parameter obj1285 = |
|
348 { 3, // Nb of entries |
|
349 0x600, // cobid transmited to the server. The good value should be 0x600 + server nodeId |
|
350 0x580, // cobid received from the server. The good value should be 0x580 + server nodeId |
|
351 0x0 // server NodeId |
|
352 }; |
|
353 static subindex Index1285[] = |
|
354 { |
|
355 { RO, uint8, sizeof( UNS8 ), (void*)&obj1285.count }, |
|
356 { RW, uint8, sizeof( UNS32 ), (void*)&obj1285.cob_id_client }, |
|
357 { RW, uint8, sizeof( UNS32 ), (void*)&obj1285.cob_id_server }, |
|
358 { RW, uint8, sizeof( UNS8 ), (void*)&obj1285.node_id } |
|
359 }; |
|
360 |
|
361 /* index 0x1286 : SDO client parameter */ |
|
362 static s_sdo_parameter obj1286 = |
|
363 { 3, // Nb of entries |
|
364 0x600, // cobid transmited to the server. The good value should be 0x600 + server nodeId |
|
365 0x580, // cobid received from the server. The good value should be 0x580 + server nodeId |
|
366 0x0 // server NodeId |
|
367 }; |
|
368 static subindex Index1286[] = |
|
369 { |
|
370 { RO, uint8, sizeof( UNS8 ), (void*)&obj1286.count }, |
|
371 { RW, uint8, sizeof( UNS32 ), (void*)&obj1286.cob_id_client }, |
|
372 { RW, uint8, sizeof( UNS32 ), (void*)&obj1286.cob_id_server }, |
|
373 { RW, uint8, sizeof( UNS8 ), (void*)&obj1286.node_id } |
|
374 }; |
|
375 |
|
376 /* index 0x1287 : SDO client parameter */ |
|
377 static s_sdo_parameter obj1287 = |
|
378 { 3, // Nb of entries |
|
379 0x600, // cobid transmited to the server. The good value should be 0x600 + server nodeId |
|
380 0x580, // cobid received from the server. The good value should be 0x580 + server nodeId |
|
381 0x0 // server NodeId |
|
382 }; |
|
383 static subindex Index1287[] = |
|
384 { |
|
385 { RO, uint8, sizeof( UNS8 ), (void*)&obj1287.count }, |
|
386 { RW, uint8, sizeof( UNS32 ), (void*)&obj1287.cob_id_client }, |
|
387 { RW, uint8, sizeof( UNS32 ), (void*)&obj1287.cob_id_server }, |
|
388 { RW, uint8, sizeof( UNS8 ), (void*)&obj1287.node_id } |
|
389 }; |
|
390 |
|
391 /* index 0x1288 : SDO client parameter */ |
|
392 static s_sdo_parameter obj1288 = |
|
393 { 3, // Nb of entries |
|
394 0x600, // cobid transmited to the server. The good value should be 0x600 + server nodeId |
|
395 0x580, // cobid received from the server. The good value should be 0x580 + server nodeId |
|
396 0x0 // server NodeId |
|
397 }; |
|
398 static subindex Index1288[] = |
|
399 { |
|
400 { RO, uint8, sizeof( UNS8 ), (void*)&obj1288.count }, |
|
401 { RW, uint8, sizeof( UNS32 ), (void*)&obj1288.cob_id_client }, |
|
402 { RW, uint8, sizeof( UNS32 ), (void*)&obj1288.cob_id_server }, |
|
403 { RW, uint8, sizeof( UNS8 ), (void*)&obj1288.node_id } |
|
404 }; |
|
405 |
|
406 /* index 0x1289 : SDO client parameter */ |
|
407 static s_sdo_parameter obj1289 = |
|
408 { 3, // Nb of entries |
|
409 0x600, // cobid transmited to the server. The good value should be 0x600 + server nodeId |
|
410 0x580, // cobid received from the server. The good value should be 0x580 + server nodeId |
|
411 0x0 // server NodeId |
|
412 }; |
|
413 static subindex Index1289[] = |
|
414 { |
|
415 { RO, uint8, sizeof( UNS8 ), (void*)&obj1289.count }, |
|
416 { RW, uint8, sizeof( UNS32 ), (void*)&obj1289.cob_id_client }, |
|
417 { RW, uint8, sizeof( UNS32 ), (void*)&obj1289.cob_id_server }, |
|
418 { RW, uint8, sizeof( UNS8 ), (void*)&obj1289.node_id } |
|
419 }; |
|
420 |
|
421 /* index 0x1400 : PDO receive communication parameter */ |
|
422 static s_pdo_communication_parameter obj1400 = |
|
423 { 2, // Largest subindex supported |
|
424 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) |
|
425 253 // Transmission type. See objdictdef.h |
|
426 }; |
|
427 static subindex Index1400[] = |
|
428 { |
|
429 { RO, uint8, sizeof( UNS8 ), (void*)&obj1400.count }, |
|
430 { RW, uint8, sizeof( UNS32 ), (void*)&obj1400.cob_id }, |
|
431 { RW, uint8, sizeof( UNS8 ), (void*)&obj1400.type }, |
|
432 }; |
|
433 |
|
434 /* index 0x1401 : PDO receive communication parameter */ |
|
435 static s_pdo_communication_parameter obj1401 = |
|
436 { 2, // Largest subindex supported |
|
437 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) |
|
438 253 // Transmission type. See objdictdef.h |
|
439 }; |
|
440 static subindex Index1401[] = |
|
441 { |
|
442 { RO, uint8, sizeof( UNS8 ), (void*)&obj1401.count }, |
|
443 { RW, uint8, sizeof( UNS32 ), (void*)&obj1401.cob_id }, |
|
444 { RW, uint8, sizeof( UNS8 ), (void*)&obj1401.type }, |
|
445 }; |
|
446 |
|
447 /* index 0x1402 : PDO receive communication parameter */ |
|
448 static s_pdo_communication_parameter obj1402 = |
|
449 { 2, // Largest subindex supported |
|
450 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) |
|
451 253 // Transmission type. See objdictdef.h |
|
452 }; |
|
453 static subindex Index1402[] = |
|
454 { |
|
455 { RO, uint8, sizeof( UNS8 ), (void*)&obj1402.count }, |
|
456 { RW, uint8, sizeof( UNS32 ), (void*)&obj1402.cob_id }, |
|
457 { RW, uint8, sizeof( UNS8 ), (void*)&obj1402.type }, |
|
458 }; |
|
459 |
|
460 /* index 0x1600 : PDO receive mapping parameter of PDO communication index 0x1400 */ |
|
461 static UNS8 obj1600_cnt = 0; // Number of mapped variables |
|
462 static UNS32 obj1600_mappedVar[] = { |
|
463 // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : |
|
464 // PDO_MAP(6035,12,16) |
|
465 PDO_MAP(0000, 00, 00), |
|
466 PDO_MAP(0000, 00, 00), |
|
467 PDO_MAP(0000, 00, 00), |
|
468 PDO_MAP(0000, 00, 00), |
|
469 PDO_MAP(0000, 00, 00), |
|
470 PDO_MAP(0000, 00, 00), |
|
471 PDO_MAP(0000, 00, 00), |
|
472 PDO_MAP(0000, 00, 00) |
|
473 }; |
|
474 subindex Index1600[] = |
|
475 { |
|
476 { RW, uint8, sizeof( UNS8 ), (void*)&obj1600_cnt }, |
|
477 { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[0]}, |
|
478 { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[1]}, |
|
479 { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[2]}, |
|
480 { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[3]}, |
|
481 { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[4]}, |
|
482 { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[5]}, |
|
483 { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[6]}, |
|
484 { RW, uint32, sizeof( UNS32 ), (void*)&obj1600_mappedVar[7]} |
|
485 }; |
|
486 |
|
487 /* index 0x1601 : PDO receive mapping parameter of PDO communication index 0x1401 */ |
|
488 static UNS8 obj1601_cnt = 0; // Number of mapped variables |
|
489 static UNS32 obj1601_mappedVar[] = { |
|
490 // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : |
|
491 // PDO_MAP(6035,12,16) |
|
492 PDO_MAP(0000, 00, 00), |
|
493 PDO_MAP(0000, 00, 00), |
|
494 PDO_MAP(0000, 00, 00), |
|
495 PDO_MAP(0000, 00, 00), |
|
496 PDO_MAP(0000, 00, 00), |
|
497 PDO_MAP(0000, 00, 00), |
|
498 PDO_MAP(0000, 00, 00), |
|
499 PDO_MAP(0000, 00, 00) |
|
500 }; |
|
501 subindex Index1601[] = |
|
502 { |
|
503 { RW, uint8, sizeof( UNS8 ), (void*)&obj1601_cnt }, |
|
504 { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[0]}, |
|
505 { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[1]}, |
|
506 { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[2]}, |
|
507 { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[3]}, |
|
508 { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[4]}, |
|
509 { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[5]}, |
|
510 { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[6]}, |
|
511 { RW, uint32, sizeof( UNS32 ), (void*)&obj1601_mappedVar[7]} |
|
512 }; |
|
513 |
|
514 /* index 0x1602 : PDO receive mapping parameter of PDO communication index 0x1402 */ |
|
515 static UNS8 obj1602_cnt = 0; // Number of mapped variables |
|
516 static UNS32 obj1602_mappedVar[] = { |
|
517 // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : |
|
518 // PDO_MAP(6035,12,16) |
|
519 PDO_MAP(0000, 00, 00), |
|
520 PDO_MAP(0000, 00, 00), |
|
521 PDO_MAP(0000, 00, 00), |
|
522 PDO_MAP(0000, 00, 00), |
|
523 PDO_MAP(0000, 00, 00), |
|
524 PDO_MAP(0000, 00, 00), |
|
525 PDO_MAP(0000, 00, 00), |
|
526 PDO_MAP(0000, 00, 00) |
|
527 }; |
|
528 subindex Index1602[] = |
|
529 { |
|
530 { RW, uint8, sizeof( UNS8 ), (void*)&obj1602_cnt }, |
|
531 { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[0]}, |
|
532 { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[1]}, |
|
533 { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[2]}, |
|
534 { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[3]}, |
|
535 { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[4]}, |
|
536 { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[5]}, |
|
537 { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[6]}, |
|
538 { RW, uint32, sizeof( UNS32 ), (void*)&obj1602_mappedVar[7]} |
|
539 }; |
|
540 |
|
541 /* index 0x1800 : PDO transmit communication parameter */ |
|
542 static s_pdo_communication_parameter obj1800 = |
|
543 { 2, // Largest subindex supported |
|
544 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) |
|
545 253 // Transmission type. See objdictdef.h |
|
546 }; |
|
547 static subindex Index1800[] = |
|
548 { |
|
549 { RO, uint8, sizeof( UNS8 ), (void*)&obj1800.count }, |
|
550 { RW, uint8, sizeof( UNS32 ), (void*)&obj1800.cob_id }, |
|
551 { RW, uint8, sizeof( UNS8 ), (void*)&obj1800.type }, |
|
552 }; |
|
553 |
|
554 /* index 0x1801 : PDO transmit communication parameter */ |
|
555 static s_pdo_communication_parameter obj1801 = |
|
556 { 2, // Largest subindex supported |
|
557 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) |
|
558 253 // Transmission type. See objdictdef.h |
|
559 }; |
|
560 static subindex Index1801[] = |
|
561 { |
|
562 { RO, uint8, sizeof( UNS8 ), (void*)&obj1801.count }, |
|
563 { RW, uint8, sizeof( UNS32 ), (void*)&obj1801.cob_id }, |
|
564 { RW, uint8, sizeof( UNS8 ), (void*)&obj1801.type }, |
|
565 }; |
|
566 |
|
567 /* index 0x1802 : PDO transmit communication parameter */ |
|
568 static s_pdo_communication_parameter obj1802 = |
|
569 { 2, // Largest subindex supported |
|
570 0x0, // Default COBID (overwritten at init for index 0x1400 to 0x1403) |
|
571 253 // Transmission type. See objdictdef.h |
|
572 }; |
|
573 static subindex Index1802[] = |
|
574 { |
|
575 { RO, uint8, sizeof( UNS8 ), (void*)&obj1802.count }, |
|
576 { RW, uint8, sizeof( UNS32 ), (void*)&obj1802.cob_id }, |
|
577 { RW, uint8, sizeof( UNS8 ), (void*)&obj1802.type }, |
|
578 }; |
|
579 |
|
580 /* index 0x1A00 : PDO transmit mapping parameter of PDO communication index 0x1800 */ |
|
581 static UNS8 obj1A00_cnt = 0; // Number of mapped variables |
|
582 static UNS32 obj1A00_mappedVar[] = { |
|
583 // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : |
|
584 // PDO_MAP(6035,12,16) |
|
585 PDO_MAP(0000, 00, 00), |
|
586 PDO_MAP(0000, 00, 00), |
|
587 PDO_MAP(0000, 00, 00), |
|
588 PDO_MAP(0000, 00, 00), |
|
589 PDO_MAP(0000, 00, 00), |
|
590 PDO_MAP(0000, 00, 00), |
|
591 PDO_MAP(0000, 00, 00), |
|
592 PDO_MAP(0000, 00, 00) |
|
593 }; |
|
594 subindex Index1A00[] = |
|
595 { |
|
596 { RW, uint8, sizeof( UNS8 ), (void*)&obj1A00_cnt }, |
|
597 { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[0]}, |
|
598 { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[1]}, |
|
599 { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[2]}, |
|
600 { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[3]}, |
|
601 { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[4]}, |
|
602 { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[5]}, |
|
603 { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[6]}, |
|
604 { RW, uint32, sizeof( UNS32 ), (void*)&obj1A00_mappedVar[7]} |
|
605 }; |
|
606 |
|
607 /* index 0x1A01 : PDO transmit mapping parameter of PDO communication index 0x1801 */ |
|
608 static UNS8 obj1A01_cnt = 0; // Number of mapped variables |
|
609 static UNS32 obj1A01_mappedVar[] = { |
|
610 // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : |
|
611 // PDO_MAP(6035,12,16) |
|
612 PDO_MAP(0000, 00, 00), |
|
613 PDO_MAP(0000, 00, 00), |
|
614 PDO_MAP(0000, 00, 00), |
|
615 PDO_MAP(0000, 00, 00), |
|
616 PDO_MAP(0000, 00, 00), |
|
617 PDO_MAP(0000, 00, 00), |
|
618 PDO_MAP(0000, 00, 00), |
|
619 PDO_MAP(0000, 00, 00) |
|
620 }; |
|
621 subindex Index1A01[] = |
|
622 { |
|
623 { RW, uint8, sizeof( UNS8 ), (void*)&obj1A01_cnt }, |
|
624 { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[0]}, |
|
625 { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[1]}, |
|
626 { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[2]}, |
|
627 { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[3]}, |
|
628 { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[4]}, |
|
629 { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[5]}, |
|
630 { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[6]}, |
|
631 { RW, uint32, sizeof( UNS32 ), (void*)&obj1A01_mappedVar[7]} |
|
632 }; |
|
633 |
|
634 /* index 0x1A02 : PDO transmit mapping parameter of PDO communication index 0x1802 */ |
|
635 static UNS8 obj1A02_cnt = 0; // Number of mapped variables |
|
636 static UNS32 obj1A02_mappedVar[] = { |
|
637 // Example to map a variable of 16 bits defined at index 0x6035, subindex 0x12 : |
|
638 // PDO_MAP(6035,12,16) |
|
639 PDO_MAP(0000, 00, 00), |
|
640 PDO_MAP(0000, 00, 00), |
|
641 PDO_MAP(0000, 00, 00), |
|
642 PDO_MAP(0000, 00, 00), |
|
643 PDO_MAP(0000, 00, 00), |
|
644 PDO_MAP(0000, 00, 00), |
|
645 PDO_MAP(0000, 00, 00), |
|
646 PDO_MAP(0000, 00, 00) |
|
647 }; |
|
648 subindex Index1A02[] = |
|
649 { |
|
650 { RW, uint8, sizeof( UNS8 ), (void*)&obj1A02_cnt }, |
|
651 { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[0]}, |
|
652 { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[1]}, |
|
653 { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[2]}, |
|
654 { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[3]}, |
|
655 { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[4]}, |
|
656 { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[5]}, |
|
657 { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[6]}, |
|
658 { RW, uint32, sizeof( UNS32 ), (void*)&obj1A02_mappedVar[7]} |
|
659 }; |
|
660 |
|
661 |
|
662 /* index 0x6000 : Mapped variable */ |
|
663 subindex Index6000[] = |
|
664 { |
|
665 { RW, uint32, sizeof (UNS32), (void*)&canopenErrNB_node5 } |
|
666 }; |
|
667 |
|
668 /* index 0x6001 : Mapped variable */ |
|
669 subindex Index6001[] = |
|
670 { |
|
671 { RW, uint32, sizeof (UNS32), (void*)&canopenErrVAL_node5 } |
|
672 }; |
|
673 |
|
674 /* index 0x6002 : Mapped variable */ |
|
675 static UNS8 highestSubIndex_6002 = 4; // number of subindex - 1 |
|
676 subindex Index6002[] = |
|
677 { |
|
678 { RO, uint8, sizeof (UNS8), (void*)&highestSubIndex_6002 }, |
|
679 { RW, uint8, sizeof (UNS8), (void*)&second }, |
|
680 { RW, uint8, sizeof (UNS8), (void*)&minutes }, |
|
681 { RW, uint8, sizeof (UNS8), (void*)&hour }, |
|
682 { RW, uint8, sizeof (UNS8), (void*)&day } |
|
683 }; |
|
684 |
|
685 /* index 0x6003 : Mapped variable */ |
|
686 static UNS8 highestSubIndex_6003 = 2; // number of subindex - 1 |
|
687 subindex Index6003[] = |
|
688 { |
|
689 { RO, uint8, sizeof (UNS8), (void*)&highestSubIndex_6003 }, |
|
690 { RW, uint32, sizeof (UNS32), (void*)&canopenErrNB }, |
|
691 { RW, uint32, sizeof (UNS32), (void*)&canopenErrVAL } |
|
692 }; |
|
693 |
|
694 const indextable objdict[] = |
|
695 { |
|
696 DeclareIndexTableEntry(Index1000, 0x1000), |
|
697 DeclareIndexTableEntry(Index1001, 0x1001), |
|
698 DeclareIndexTableEntry(Index1005, 0x1005), |
|
699 DeclareIndexTableEntry(Index1006, 0x1006), |
|
700 DeclareIndexTableEntry(Index1007, 0x1007), |
|
701 DeclareIndexTableEntry(Index1008, 0x1008), |
|
702 DeclareIndexTableEntry(Index1009, 0x1009), |
|
703 DeclareIndexTableEntry(Index100A, 0x100A), |
|
704 DeclareIndexTableEntry(Index1016, 0x1016), |
|
705 DeclareIndexTableEntry(Index1017, 0x1017), |
|
706 DeclareIndexTableEntry(Index1018, 0x1018), |
|
707 DeclareIndexTableEntry(Index1200, 0x1200), |
|
708 DeclareIndexTableEntry(Index1280, 0x1280), |
|
709 DeclareIndexTableEntry(Index1281, 0x1281), |
|
710 DeclareIndexTableEntry(Index1282, 0x1282), |
|
711 DeclareIndexTableEntry(Index1283, 0x1283), |
|
712 DeclareIndexTableEntry(Index1284, 0x1284), |
|
713 DeclareIndexTableEntry(Index1285, 0x1285), |
|
714 DeclareIndexTableEntry(Index1286, 0x1286), |
|
715 DeclareIndexTableEntry(Index1287, 0x1287), |
|
716 DeclareIndexTableEntry(Index1288, 0x1288), |
|
717 DeclareIndexTableEntry(Index1289, 0x1289), |
|
718 DeclareIndexTableEntry(Index1400, 0x1400), |
|
719 DeclareIndexTableEntry(Index1401, 0x1401), |
|
720 DeclareIndexTableEntry(Index1402, 0x1402), |
|
721 DeclareIndexTableEntry(Index1600, 0x1600), |
|
722 DeclareIndexTableEntry(Index1601, 0x1601), |
|
723 DeclareIndexTableEntry(Index1602, 0x1602), |
|
724 DeclareIndexTableEntry(Index1800, 0x1800), |
|
725 DeclareIndexTableEntry(Index1801, 0x1801), |
|
726 DeclareIndexTableEntry(Index1802, 0x1802), |
|
727 DeclareIndexTableEntry(Index1A00, 0x1A00), |
|
728 DeclareIndexTableEntry(Index1A01, 0x1A01), |
|
729 DeclareIndexTableEntry(Index1A02, 0x1A02), |
|
730 DeclareIndexTableEntry(Index6000, 0x6000), |
|
731 DeclareIndexTableEntry(Index6001, 0x6001), |
|
732 DeclareIndexTableEntry(Index6002, 0x6002), |
|
733 DeclareIndexTableEntry(Index6003, 0x6003), |
|
734 }; |
|
735 |
|
736 // To count at which received SYNC a PDO must be sent. |
|
737 // Even if no pdoTransmit are defined, at least one entry is computed |
|
738 // for compilations issues. |
|
739 UNS8 count_sync[1] = {0, }; |
|
740 |
|
741 UNS16 firstIndex (enum e_first_object object, UNS16 *lastIndex) |
|
742 { |
|
743 switch (object) { |
|
744 case FIRST_SDO_SERVER : |
|
745 *lastIndex = 11; |
|
746 return 11; |
|
747 case FIRST_SDO_CLIENT : |
|
748 *lastIndex = 21; |
|
749 return 12; |
|
750 case FIRST_PDO_RCV : |
|
751 *lastIndex = 24; |
|
752 return 22; |
|
753 case FIRST_PDO_RCV_MAP : |
|
754 *lastIndex = 27; |
|
755 return 25; |
|
756 case FIRST_PDO_TRS : |
|
757 *lastIndex = 30; |
|
758 return 28; |
|
759 case FIRST_PDO_TRS_MAP : |
|
760 *lastIndex = 33; |
|
761 return 31; |
|
762 } |
|
763 *lastIndex = 0; |
|
764 return 0; |
|
765 } |
|
766 |
|
767 UNS16 getObjdictSize (void) |
|
768 { |
|
769 return sizeof(objdict)/sizeof(objdict[0]); |
|
770 } |
|