ethercattype.h
Go to the documentation of this file.
1 /*
2  * Simple Open EtherCAT Master Library
3  *
4  * File : ethercattype.h
5  * Version : 1.3.0
6  * Date : 24-02-2013
7  * Copyright (C) 2005-2013 Speciaal Machinefabriek Ketels v.o.f.
8  * Copyright (C) 2005-2013 Arthur Ketels
9  * Copyright (C) 2008-2009 TU/e Technische Universiteit Eindhoven
10  *
11  * SOEM is free software; you can redistribute it and/or modify it under
12  * the terms of the GNU General Public License version 2 as published by the Free
13  * Software Foundation.
14  *
15  * SOEM is distributed in the hope that it will be useful, but WITHOUT ANY
16  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
17  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18  * for more details.
19  *
20  * As a special exception, if other files instantiate templates or use macros
21  * or inline functions from this file, or you compile this file and link it
22  * with other works to produce a work based on this file, this file does not
23  * by itself cause the resulting work to be covered by the GNU General Public
24  * License. However the source code for this file must still be made available
25  * in accordance with section (3) of the GNU General Public License.
26  *
27  * This exception does not invalidate any other reasons why a work based on
28  * this file might be covered by the GNU General Public License.
29  *
30  * The EtherCAT Technology, the trade name and logo EtherCAT are the intellectual
31  * property of, and protected by Beckhoff Automation GmbH. You can use SOEM for
32  * the sole purpose of creating, using and/or selling or otherwise distributing
33  * an EtherCAT network master provided that an EtherCAT Master License is obtained
34  * from Beckhoff Automation GmbH.
35  *
36  * In case you did not receive a copy of the EtherCAT Master License along with
37  * SOEM write to Beckhoff Automation GmbH, Eiserstra├če 5, D-33415 Verl, Germany
38  * (www.beckhoff.com).
39  */
40 
53 #ifndef _EC_TYPE_H
54 #define _EC_TYPE_H
55 
56 #ifdef __cplusplus
57 extern "C"
58 {
59 #endif
60 
62 #define EC_LITTLE_ENDIAN
63 
66 #define EC_VER1
67 
68 #include <osal.h>
69 
71 #define EC_ERROR -3
72 
73 #define EC_NOFRAME -1
74 
75 #define EC_OTHERFRAME -2
76 
77 #define EC_MAXECATFRAME 1518
78 
79 /* MTU - Ethernet header - length - datagram header - WCK - FCS */
80 #define EC_MAXLRWDATA (EC_MAXECATFRAME - 14 - 2 - 10 - 2 - 4)
81 
82 #define EC_FIRSTDCDATAGRAM 20
83 
84 #define EC_BUFSIZE EC_MAXECATFRAME
85 
86 #define EC_ECATTYPE 0x1000
87 
88 #define EC_MAXBUF 16
89 
90 #define EC_TIMEOUTRET 2000
91 
92 #define EC_TIMEOUTRET3 (EC_TIMEOUTRET * 3)
93 
94 #define EC_TIMEOUTSAFE 20000
95 
96 #define EC_TIMEOUTEEP 20000
97 
98 #define EC_TIMEOUTTXM 20000
99 
100 #define EC_TIMEOUTRXM 700000
101 
102 #define EC_TIMEOUTSTATE 2000000
103 
104 #define EC_MAXEEPBITMAP 128
105 
106 #define EC_MAXEEPBUF EC_MAXEEPBITMAP << 5
107 
108 #define EC_DEFAULTRETRIES 3
109 
112 
114 PACKED_BEGIN
115 typedef struct PACKED
116 {
124 PACKED_END
125 
127 #define ETH_HEADERSIZE sizeof(ec_etherheadert)
128 
130 PACKED_BEGIN
131 typedef struct PACKED
132 {
147 } ec_comt;
148 PACKED_END
149 
151 #define EC_HEADERSIZE sizeof(ec_comt)
152 
153 #define EC_ELENGTHSIZE sizeof(uint16)
154 
155 #define EC_CMDOFFSET EC_ELENGTHSIZE
156 
157 #define EC_WKCSIZE sizeof(uint16)
158 
159 #define EC_DATAGRAMFOLLOWS (1 << 15)
160 
162 typedef enum
163 {
176 } ec_err;
177 
179 typedef enum
180 {
192  EC_STATE_ACK = 0x10,
194 } ec_state;
195 
197 typedef enum
198 {
200  EC_BUF_EMPTY = 0x00,
202  EC_BUF_ALLOC = 0x01,
204  EC_BUF_TX = 0x02,
206  EC_BUF_RCVD = 0x03,
209 } ec_bufstate;
210 
212 typedef enum
213 {
214  ECT_BOOLEAN = 0x0001,
215  ECT_INTEGER8 = 0x0002,
216  ECT_INTEGER16 = 0x0003,
217  ECT_INTEGER32 = 0x0004,
218  ECT_UNSIGNED8 = 0x0005,
219  ECT_UNSIGNED16 = 0x0006,
220  ECT_UNSIGNED32 = 0x0007,
221  ECT_REAL32 = 0x0008,
225  ECT_TIME_OF_DAY = 0x000C,
227  ECT_DOMAIN = 0x000F,
228  ECT_INTEGER24 = 0x0010,
229  ECT_REAL64 = 0x0011,
230  ECT_INTEGER64 = 0x0015,
231  ECT_UNSIGNED24 = 0x0016,
232  ECT_UNSIGNED64 = 0x001B,
233  ECT_BIT1 = 0x0030,
234  ECT_BIT2 = 0x0031,
235  ECT_BIT3 = 0x0032,
236  ECT_BIT4 = 0x0033,
237  ECT_BIT5 = 0x0034,
238  ECT_BIT6 = 0x0035,
239  ECT_BIT7 = 0x0036,
240  ECT_BIT8 = 0x0037
241 } ec_datatype;
242 
244 typedef enum
245 {
247  EC_CMD_NOP = 0x00,
277 } ec_cmdtype;
278 
280 typedef enum
281 {
283  EC_ECMD_NOP = 0x0000,
285  EC_ECMD_READ = 0x0100,
287  EC_ECMD_WRITE = 0x0201,
289  EC_ECMD_RELOAD = 0x0300
290 } ec_ecmdtype;
291 
293 #define EC_ESTAT_R64 0x0040
294 
295 #define EC_ESTAT_BUSY 0x8000
296 
297 #define EC_ESTAT_EMASK 0x7800
298 
299 #define EC_ESTAT_NACK 0x2000
300 
301 /* Ethercat SSI (Slave Information Interface) */
302 
304 #define ECT_SII_START 0x0040
305 
306 enum
307 {
318 };
319 
321 enum
322 {
323  ECT_SII_MANUF = 0x0008,
324  ECT_SII_ID = 0x000a,
325  ECT_SII_REV = 0x000c,
328  ECT_SII_MBXSIZE = 0x0019,
332 };
333 
335 enum
336 {
338  ECT_MBXT_ERR = 0x00,
351 };
352 
354 enum
355 {
364 };
365 
367 enum
368 {
376 };
377 
379 enum
380 {
388 };
389 
391 enum
392 {
393  ECT_FOE_READ = 0x01,
399 };
400 
402 enum
403 {
410 };
411 
413 enum
414 {
415  ECT_REG_TYPE = 0x0000,
416  ECT_REG_PORTDES = 0x0007,
417  ECT_REG_ESCSUP = 0x0008,
418  ECT_REG_STADR = 0x0010,
419  ECT_REG_ALIAS = 0x0012,
420  ECT_REG_DLCTL = 0x0100,
421  ECT_REG_DLPORT = 0x0101,
422  ECT_REG_DLALIAS = 0x0103,
423  ECT_REG_DLSTAT = 0x0110,
424  ECT_REG_ALCTL = 0x0120,
425  ECT_REG_ALSTAT = 0x0130,
427  ECT_REG_PDICTL = 0x0140,
428  ECT_REG_IRQMASK = 0x0200,
429  ECT_REG_RXERR = 0x0300,
430  ECT_REG_EEPCFG = 0x0500,
431  ECT_REG_EEPCTL = 0x0502,
432  ECT_REG_EEPSTAT = 0x0502,
433  ECT_REG_EEPADR = 0x0504,
434  ECT_REG_EEPDAT = 0x0508,
435  ECT_REG_FMMU0 = 0x0600,
439  ECT_REG_SM0 = 0x0800,
447  ECT_REG_DCTIME0 = 0x0900,
448  ECT_REG_DCTIME1 = 0x0904,
449  ECT_REG_DCTIME2 = 0x0908,
450  ECT_REG_DCTIME3 = 0x090C,
452  ECT_REG_DCSOF = 0x0918,
458  ECT_REG_DCCUC = 0x0980,
463 };
464 
466 #define ECT_SDO_SMCOMMTYPE 0x1c00
467 
468 #define ECT_SDO_PDOASSIGN 0x1c10
469 
470 #define ECT_SDO_RXPDOASSIGN 0x1c12
471 
472 #define ECT_SDO_TXPDOASSIGN 0x1c13
473 
475 #define ETH_P_ECAT 0x88A4
476 
478 typedef enum
479 {
489 } ec_err_type;
490 
492 typedef struct
493 {
497  boolean Signal;
506  union
507  {
511  struct
512  {
518  };
519  };
520 } ec_errort;
521 
524 #define MK_WORD(msb, lsb) ((((uint16)(msb))<<8) | (lsb))
525 
526 #define HI_BYTE(w) ((w) >> 8)
527 
528 #define LO_BYTE(w) ((w) & 0x00ff)
529 
530 #define SWAP(w) ((((w)& 0xff00) >> 8) | (((w) & 0x00ff) << 8))
531 
532 #define LO_WORD(l) ((l) & 0xffff)
533 
534 #define HI_WORD(l) ((l) >> 16)
535 
536 #define get_unaligned(ptr) \
537  ({ __typeof__(*(ptr)) __tmp; memcpy(&__tmp, (ptr), sizeof(*(ptr))); __tmp; })
538 
539 #define put_unaligned32(val, ptr) \
540  (memcpy((ptr), &(val), 4))
541 
542 #define put_unaligned64(val, ptr) \
543  (memcpy((ptr), &(val), 8))
544 
545 #if !defined(EC_BIG_ENDIAN) && defined(EC_LITTLE_ENDIAN)
546 
547  #define htoes(A) (A)
548  #define htoel(A) (A)
549  #define htoell(A) (A)
550  #define etohs(A) (A)
551  #define etohl(A) (A)
552  #define etohll(A) (A)
553 
554 #elif !defined(EC_LITTLE_ENDIAN) && defined(EC_BIG_ENDIAN)
555 
556  #define htoes(A) ((((uint16)(A) & 0xff00) >> 8) | \
557  (((uint16)(A) & 0x00ff) << 8))
558  #define htoel(A) ((((uint32)(A) & 0xff000000) >> 24) | \
559  (((uint32)(A) & 0x00ff0000) >> 8) | \
560  (((uint32)(A) & 0x0000ff00) << 8) | \
561  (((uint32)(A) & 0x000000ff) << 24))
562  #define htoell(A) ((((uint64)(A) & (uint64)0xff00000000000000ULL) >> 56) | \
563  (((uint64)(A) & (uint64)0x00ff000000000000ULL) >> 40) | \
564  (((uint64)(A) & (uint64)0x0000ff0000000000ULL) >> 24) | \
565  (((uint64)(A) & (uint64)0x000000ff00000000ULL) >> 8) | \
566  (((uint64)(A) & (uint64)0x00000000ff000000ULL) << 8) | \
567  (((uint64)(A) & (uint64)0x0000000000ff0000ULL) << 24) | \
568  (((uint64)(A) & (uint64)0x000000000000ff00ULL) << 40) | \
569  (((uint64)(A) & (uint64)0x00000000000000ffULL) << 56))
570 
571  #define etohs htoes
572  #define etohl htoel
573  #define etohll htoell
574 
575 #else
576 
577  #error "Must define one of EC_BIG_ENDIAN or EC_LITTLE_ENDIAN"
578 
579 #endif
580 
581 #ifdef __cplusplus
582 }
583 #endif
584 
585 #endif /* _EC_TYPE_H */
uint16 sa1
Definition: ethercattype.h:120
uint8 index
Definition: ethercattype.h:138
uint16 da0
Definition: ethercattype.h:118
uint8_t uint8
Definition: osal.h:33
PACKED_BEGIN struct PACKED ec_etherheadert
uint8 SubIdx
Definition: ethercattype.h:503
uint16 w2
Definition: ethercattype.h:517
ec_state
Definition: ethercattype.h:179
uint16_t uint16
Definition: osal.h:34
uint16 sa2
Definition: ethercattype.h:120
uint8 command
Definition: ethercattype.h:136
uint16 ADO
Definition: ethercattype.h:142
ec_err_type Etype
Definition: ethercattype.h:505
uint16 irpt
Definition: ethercattype.h:146
Definition: osal.h:53
ec_cmdtype
Definition: ethercattype.h:244
uint16 da1
Definition: ethercattype.h:118
ec_datatype
Definition: ethercattype.h:212
uint16 elength
Definition: ethercattype.h:134
uint16 Slave
Definition: ethercattype.h:499
int32_t int32
Definition: osal.h:32
PACKED_BEGIN struct PACKED ec_comt
uint16 dlength
Definition: ethercattype.h:144
uint16 ADP
Definition: ethercattype.h:140
boolean Signal
Definition: ethercattype.h:497
ec_bufstate
Definition: ethercattype.h:197
int32 AbortCode
Definition: ethercattype.h:509
ec_timet Time
Definition: ethercattype.h:495
uint16 etype
Definition: ethercattype.h:122
uint16 ErrorCode
Definition: ethercattype.h:513
uint16 Index
Definition: ethercattype.h:501
ec_ecmdtype
Definition: ethercattype.h:280
uint8 ec_bufT[EC_BUFSIZE]
Definition: ethercattype.h:111
uint16 sa0
Definition: ethercattype.h:120
uint16 da2
Definition: ethercattype.h:118
ec_err
Definition: ethercattype.h:162
ec_err_type
Definition: ethercattype.h:478
#define EC_BUFSIZE
Definition: ethercattype.h:84
uint16 w1
Definition: ethercattype.h:516
uint8 ErrorReg
Definition: ethercattype.h:514


youbot_driver
Author(s): Jan Paulus
autogenerated on Mon Jun 10 2019 15:46:24