ethercattype.h
Go to the documentation of this file.
1 /*
2  * Licensed under the GNU General Public License version 2 with exceptions. See
3  * LICENSE file in the project root for full license information
4  */
5 
18 #ifndef _EC_TYPE_H
19 #define _EC_TYPE_H
20 
21 #ifdef __cplusplus
22 extern "C"
23 {
24 #endif
25 
26 #include "osal.h"
27 
30 #if !defined(EC_VER1) && !defined(EC_VER2)
31 # define EC_VER1
32 #endif
33 
34 
36 #if !defined(EC_LITTLE_ENDIAN) && !defined(EC_BIG_ENDIAN)
37 # define EC_LITTLE_ENDIAN
38 #endif
39 
41 #define EC_NOFRAME -1
42 
43 #define EC_OTHERFRAME -2
44 
45 #define EC_ERROR -3
46 
47 #define EC_SLAVECOUNTEXCEEDED -4
48 
49 #define EC_TIMEOUT -5
50 
51 #define EC_MAXECATFRAME 1518
52 
53 /* MTU - Ethernet header - length - datagram header - WCK - FCS */
54 #define EC_MAXLRWDATA (EC_MAXECATFRAME - 14 - 2 - 10 - 2 - 4)
55 
56 #define EC_FIRSTDCDATAGRAM 20
57 
58 #define EC_BUFSIZE EC_MAXECATFRAME
59 
60 #define EC_ECATTYPE 0x1000
61 
62 #define EC_MAXBUF 16
63 
64 #define EC_TIMEOUTRET 2000
65 
66 #define EC_TIMEOUTRET3 (EC_TIMEOUTRET * 3)
67 
68 #define EC_TIMEOUTSAFE 20000
69 
70 #define EC_TIMEOUTEEP 20000
71 
72 #define EC_TIMEOUTTXM 20000
73 
74 #define EC_TIMEOUTRXM 700000
75 
76 #define EC_TIMEOUTSTATE 2000000
77 
78 #define EC_MAXEEPBITMAP 128
79 
80 #define EC_MAXEEPBUF EC_MAXEEPBITMAP << 5
81 
82 #define EC_DEFAULTRETRIES 3
83 
84 #define EC_LOGGROUPOFFSET 16
85 
88 
91 typedef struct PACKED
92 {
101 
103 #define ETH_HEADERSIZE sizeof(ec_etherheadert)
104 
107 typedef struct PACKED
108 {
123 } ec_comt;
125 
127 #define EC_HEADERSIZE sizeof(ec_comt)
128 
129 #define EC_ELENGTHSIZE sizeof(uint16)
130 
131 #define EC_CMDOFFSET EC_ELENGTHSIZE
132 
133 #define EC_WKCSIZE sizeof(uint16)
134 
135 #define EC_DATAGRAMFOLLOWS (1 << 15)
136 
138 typedef enum
139 {
152 } ec_err;
153 
155 typedef enum
156 {
170  EC_STATE_ACK = 0x10,
172 } ec_state;
173 
175 typedef enum
176 {
178  EC_BUF_EMPTY = 0x00,
180  EC_BUF_ALLOC = 0x01,
182  EC_BUF_TX = 0x02,
184  EC_BUF_RCVD = 0x03,
187 } ec_bufstate;
188 
190 typedef enum
191 {
192  ECT_BOOLEAN = 0x0001,
193  ECT_INTEGER8 = 0x0002,
194  ECT_INTEGER16 = 0x0003,
195  ECT_INTEGER32 = 0x0004,
196  ECT_UNSIGNED8 = 0x0005,
197  ECT_UNSIGNED16 = 0x0006,
198  ECT_UNSIGNED32 = 0x0007,
199  ECT_REAL32 = 0x0008,
203  ECT_TIME_OF_DAY = 0x000C,
205  ECT_DOMAIN = 0x000F,
206  ECT_INTEGER24 = 0x0010,
207  ECT_REAL64 = 0x0011,
208  ECT_INTEGER64 = 0x0015,
209  ECT_UNSIGNED24 = 0x0016,
210  ECT_UNSIGNED64 = 0x001B,
211  ECT_BIT1 = 0x0030,
212  ECT_BIT2 = 0x0031,
213  ECT_BIT3 = 0x0032,
214  ECT_BIT4 = 0x0033,
215  ECT_BIT5 = 0x0034,
216  ECT_BIT6 = 0x0035,
217  ECT_BIT7 = 0x0036,
218  ECT_BIT8 = 0x0037
219 } ec_datatype;
220 
222 typedef enum
223 {
225  EC_CMD_NOP = 0x00,
255 } ec_cmdtype;
256 
258 typedef enum
259 {
261  EC_ECMD_NOP = 0x0000,
263  EC_ECMD_READ = 0x0100,
265  EC_ECMD_WRITE = 0x0201,
267  EC_ECMD_RELOAD = 0x0300
268 } ec_ecmdtype;
269 
271 #define EC_ESTAT_R64 0x0040
272 
273 #define EC_ESTAT_BUSY 0x8000
274 
275 #define EC_ESTAT_EMASK 0x7800
276 
277 #define EC_ESTAT_NACK 0x2000
278 
279 /* Ethercat SSI (Slave Information Interface) */
280 
282 #define ECT_SII_START 0x0040
283 
284 enum
285 {
296 };
297 
299 enum
300 {
301  ECT_SII_MANUF = 0x0008,
302  ECT_SII_ID = 0x000a,
303  ECT_SII_REV = 0x000c,
306  ECT_SII_MBXSIZE = 0x0019,
310 };
311 
313 enum
314 {
316  ECT_MBXT_ERR = 0x00,
329 };
330 
332 enum
333 {
342 };
343 
345 enum
346 {
354 };
355 
357 enum
358 {
366 };
367 
369 enum
370 {
371  ECT_FOE_READ = 0x01,
377 };
378 
380 enum
381 {
388 };
389 
391 enum
392 {
393  ECT_REG_TYPE = 0x0000,
394  ECT_REG_PORTDES = 0x0007,
395  ECT_REG_ESCSUP = 0x0008,
396  ECT_REG_STADR = 0x0010,
397  ECT_REG_ALIAS = 0x0012,
398  ECT_REG_DLCTL = 0x0100,
399  ECT_REG_DLPORT = 0x0101,
400  ECT_REG_DLALIAS = 0x0103,
401  ECT_REG_DLSTAT = 0x0110,
402  ECT_REG_ALCTL = 0x0120,
403  ECT_REG_ALSTAT = 0x0130,
405  ECT_REG_PDICTL = 0x0140,
406  ECT_REG_IRQMASK = 0x0200,
407  ECT_REG_RXERR = 0x0300,
408  ECT_REG_FRXERR = 0x0308,
409  ECT_REG_EPUECNT = 0x030C,
410  ECT_REG_PECNT = 0x030D,
411  ECT_REG_PECODE = 0x030E,
412  ECT_REG_LLCNT = 0x0310,
413  ECT_REG_WDCNT = 0x0442,
414  ECT_REG_EEPCFG = 0x0500,
415  ECT_REG_EEPCTL = 0x0502,
416  ECT_REG_EEPSTAT = 0x0502,
417  ECT_REG_EEPADR = 0x0504,
418  ECT_REG_EEPDAT = 0x0508,
419  ECT_REG_FMMU0 = 0x0600,
423  ECT_REG_SM0 = 0x0800,
431  ECT_REG_DCTIME0 = 0x0900,
432  ECT_REG_DCTIME1 = 0x0904,
433  ECT_REG_DCTIME2 = 0x0908,
434  ECT_REG_DCTIME3 = 0x090C,
436  ECT_REG_DCSOF = 0x0918,
442  ECT_REG_DCCUC = 0x0980,
447 };
448 
450 #define ECT_SDO_SMCOMMTYPE 0x1c00
451 
452 #define ECT_SDO_PDOASSIGN 0x1c10
453 
454 #define ECT_SDO_RXPDOASSIGN 0x1c12
455 
456 #define ECT_SDO_TXPDOASSIGN 0x1c13
457 
459 #define ETH_P_ECAT 0x88A4
460 
462 typedef enum
463 {
475 } ec_err_type;
476 
478 typedef struct
479 {
483  boolean Signal;
492  union
493  {
497  struct
498  {
504  };
505  };
506 } ec_errort;
507 
510 #define MK_WORD(msb, lsb) ((((uint16)(msb))<<8) | (lsb))
511 
512 #define HI_BYTE(w) ((w) >> 8)
513 
514 #define LO_BYTE(w) ((w) & 0x00ff)
515 
516 #define SWAP(w) ((((w)& 0xff00) >> 8) | (((w) & 0x00ff) << 8))
517 
518 #define LO_WORD(l) ((l) & 0xffff)
519 
520 #define HI_WORD(l) ((l) >> 16)
521 
522 #define get_unaligned(ptr) \
523  ({ __typeof__(*(ptr)) __tmp; memcpy(&__tmp, (ptr), sizeof(*(ptr))); __tmp; })
524 
525 #define put_unaligned32(val, ptr) \
526  (memcpy((ptr), &(val), 4))
527 
528 #define put_unaligned64(val, ptr) \
529  (memcpy((ptr), &(val), 8))
530 
531 #if !defined(EC_BIG_ENDIAN) && defined(EC_LITTLE_ENDIAN)
532 
533  #define htoes(A) (A)
534  #define htoel(A) (A)
535  #define htoell(A) (A)
536  #define etohs(A) (A)
537  #define etohl(A) (A)
538  #define etohll(A) (A)
539 
540 #elif !defined(EC_LITTLE_ENDIAN) && defined(EC_BIG_ENDIAN)
541 
542  #define htoes(A) ((((uint16)(A) & 0xff00) >> 8) | \
543  (((uint16)(A) & 0x00ff) << 8))
544  #define htoel(A) ((((uint32)(A) & 0xff000000) >> 24) | \
545  (((uint32)(A) & 0x00ff0000) >> 8) | \
546  (((uint32)(A) & 0x0000ff00) << 8) | \
547  (((uint32)(A) & 0x000000ff) << 24))
548  #define htoell(A) ((((uint64)(A) & (uint64)0xff00000000000000ULL) >> 56) | \
549  (((uint64)(A) & (uint64)0x00ff000000000000ULL) >> 40) | \
550  (((uint64)(A) & (uint64)0x0000ff0000000000ULL) >> 24) | \
551  (((uint64)(A) & (uint64)0x000000ff00000000ULL) >> 8) | \
552  (((uint64)(A) & (uint64)0x00000000ff000000ULL) << 8) | \
553  (((uint64)(A) & (uint64)0x0000000000ff0000ULL) << 24) | \
554  (((uint64)(A) & (uint64)0x000000000000ff00ULL) << 40) | \
555  (((uint64)(A) & (uint64)0x00000000000000ffULL) << 56))
556 
557  #define etohs htoes
558  #define etohl htoel
559  #define etohll htoell
560 
561 #else
562 
563  #error "Must define one of EC_BIG_ENDIAN or EC_LITTLE_ENDIAN"
564 
565 #endif
566 
567 #ifdef __cplusplus
568 }
569 #endif
570 
571 #endif /* _EC_TYPE_H */
uint16 sa1
Definition: ethercattype.h:96
uint8 index
Definition: ethercattype.h:114
uint16 da0
Definition: ethercattype.h:94
uint8_t uint8
Definition: osal.h:28
PACKED_BEGIN struct PACKED ec_etherheadert
uint8 SubIdx
Definition: ethercattype.h:489
uint16 w2
Definition: ethercattype.h:503
ec_state
Definition: ethercattype.h:155
uint16_t uint16
Definition: osal.h:29
uint16 sa2
Definition: ethercattype.h:96
uint8 command
Definition: ethercattype.h:112
uint16 ADO
Definition: ethercattype.h:118
ec_err_type Etype
Definition: ethercattype.h:491
uint16 irpt
Definition: ethercattype.h:122
Definition: osal.h:36
ec_cmdtype
Definition: ethercattype.h:222
uint16 da1
Definition: ethercattype.h:94
ec_datatype
Definition: ethercattype.h:190
uint16 elength
Definition: ethercattype.h:110
uint16 Slave
Definition: ethercattype.h:485
#define PACKED_END
int32_t int32
Definition: osal.h:27
PACKED_BEGIN struct PACKED ec_comt
uint16 dlength
Definition: ethercattype.h:120
uint16 ADP
Definition: ethercattype.h:116
boolean Signal
Definition: ethercattype.h:483
ec_bufstate
Definition: ethercattype.h:175
int32 AbortCode
Definition: ethercattype.h:495
ec_timet Time
Definition: ethercattype.h:481
uint16 etype
Definition: ethercattype.h:98
uint16 ErrorCode
Definition: ethercattype.h:499
uint16 Index
Definition: ethercattype.h:487
ec_ecmdtype
Definition: ethercattype.h:258
uint8 ec_bufT[EC_BUFSIZE]
Definition: ethercattype.h:87
uint16 sa0
Definition: ethercattype.h:96
uint16 da2
Definition: ethercattype.h:94
ec_err
Definition: ethercattype.h:138
ec_err_type
Definition: ethercattype.h:462
#define EC_BUFSIZE
Definition: ethercattype.h:58
uint16 w1
Definition: ethercattype.h:502
uint8 ErrorReg
Definition: ethercattype.h:500
#define PACKED_BEGIN


soem
Author(s): Arthur Ketels and M.J.G. van den Molengraft
autogenerated on Mon Feb 28 2022 23:46:57