IgH EtherCAT Master  1.5.2
globals.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * $Id$
4  *
5  * Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH
6  *
7  * This file is part of the IgH EtherCAT Master.
8  *
9  * The IgH EtherCAT Master is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License version 2, as
11  * published by the Free Software Foundation.
12  *
13  * The IgH EtherCAT Master 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 General
16  * Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with the IgH EtherCAT Master; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  * ---
23  *
24  * The license mentioned above concerns the source code only. Using the
25  * EtherCAT technology and brand is only permitted in compliance with the
26  * industrial property and similar rights of Beckhoff Automation GmbH.
27  *
28  *****************************************************************************/
29 
34 /*****************************************************************************/
35 
36 #ifndef __EC_MASTER_GLOBALS_H__
37 #define __EC_MASTER_GLOBALS_H__
38 
39 #include "../globals.h"
40 #include "../include/ecrt.h"
41 
42 /******************************************************************************
43  * EtherCAT master
44  *****************************************************************************/
45 
47 #define EC_IO_TIMEOUT 500
48 
50 #define EC_SDO_INJECTION_TIMEOUT 10000
51 
56 #define EC_BYTE_TRANSMISSION_TIME_NS 80
57 
59 #define EC_FSM_RETRIES 3
60 
62 #define EC_SKIP_SDO_DICT 1
63 
65 #define EC_STATE_STRING_SIZE 32
66 
68 #define EC_MAX_SII_SIZE 4096
69 
71 #define EC_RATE_COUNT 3
72 
73 /******************************************************************************
74  * EtherCAT protocol
75  *****************************************************************************/
76 
78 #define EC_FRAME_HEADER_SIZE 2
79 
81 #define EC_DATAGRAM_HEADER_SIZE 10
82 
84 #define EC_DATAGRAM_FOOTER_SIZE 2
85 
87 #define EC_ADDR_LEN 4
88 
90 #ifdef DEBUG_DATAGRAM_OVERFLOW
91 // Define a runt datagram which can be easily overflowed on
92 // available hardware for use when testing ec_domain_finish()
93 #define EC_MAX_DATA_SIZE (128)
94 #else
95 #define EC_MAX_DATA_SIZE (ETH_DATA_LEN - EC_FRAME_HEADER_SIZE \
96  - EC_DATAGRAM_HEADER_SIZE - EC_DATAGRAM_FOOTER_SIZE)
97 #endif // DEBUG_DATAGRAM_OVERFLOW
98 
100 #define EC_MBOX_HEADER_SIZE 6
101 
103 #define EC_COE_HEADER_SIZE 2
104 
106 #define EC_MBG_SLAVE_ADDR_OFFSET 1000
107 
109 #define EC_FIRST_SII_CATEGORY_OFFSET 0x40
110 
112 #define EC_ALIAS_SII_OFFSET 0x04
113 
115 #define EC_VENDOR_SII_OFFSET 0x08
116 
118 #define EC_PRODUCT_SII_OFFSET 0x0A
119 
121 #define EC_REVISION_SII_OFFSET 0x0C
122 
124 #define EC_SERIAL_SII_OFFSET 0x0E
125 
127 #define EC_SYNC_PAGE_SIZE 8
128 
130 #define EC_MAX_FMMUS 16
131 
133 #define EC_FMMU_PAGE_SIZE 16
134 
136 #define EC_SYNC_SIGNAL_COUNT 2
137 
142 #define EC_DATAGRAM_NAME_SIZE 20
143 
148 #define EC_MAX_HOSTNAME_SIZE 32
149 
155 #define EC_SLAVE_STATE_MASK 0x0F
156 
159 typedef enum {
175 
181 enum {
182  EC_MBOX_AOE = 0x01,
183  EC_MBOX_EOE = 0x02,
184  EC_MBOX_COE = 0x04,
185  EC_MBOX_FOE = 0x08,
186  EC_MBOX_SOE = 0x10,
187  EC_MBOX_VOE = 0x20
188 };
189 
192 typedef struct {
193  uint8_t enable_sdo : 1;
194  uint8_t enable_sdo_info : 1;
195  uint8_t enable_pdo_assign : 1;
200 
203 typedef struct {
204  uint8_t enable_safeop : 1;
205  uint8_t enable_not_lrw : 1;
207 
210 typedef enum {
212  EC_DC_64 /*< 64 bit for system time, system time offset and
213  port 0 receive time. */
215 
218 typedef struct {
219  uint32_t cycle_time;
220  int32_t shift_time;
222 
227 enum {
232 };
233 
236 typedef enum {
240 
241 extern const char *ec_device_names[2]; // only main and backup!
242 
243 /*****************************************************************************/
244 
252 #define EC_INFO(fmt, args...) \
253  printk(KERN_INFO "EtherCAT: " fmt, ##args)
254 
262 #define EC_ERR(fmt, args...) \
263  printk(KERN_ERR "EtherCAT ERROR: " fmt, ##args)
264 
272 #define EC_WARN(fmt, args...) \
273  printk(KERN_WARNING "EtherCAT WARNING: " fmt, ##args)
274 
282 #define EC_DBG(fmt, args...) \
283  printk(KERN_DEBUG "EtherCAT DEBUG: " fmt, ##args)
284 
285 /*****************************************************************************/
286 
289 #define EC_ABS(X) ((X) >= 0 ? (X) : -(X))
290 
291 /*****************************************************************************/
292 
293 extern char *ec_master_version_str;
294 
295 /*****************************************************************************/
296 
297 unsigned int ec_master_count(void);
298 void ec_print_data(const uint8_t *, size_t);
299 void ec_print_data_diff(const uint8_t *, const uint8_t *, size_t);
300 size_t ec_state_string(uint8_t, char *, uint8_t);
301 size_t ec_mac_print(const uint8_t *, char *);
302 int ec_mac_is_zero(const uint8_t *);
303 
304 ec_master_t *ecrt_request_master_err(unsigned int);
305 
306 /*****************************************************************************/
307 
313 typedef struct {
314  uint32_t code;
315  const char *message;
316 } ec_code_msg_t;
317 
318 /*****************************************************************************/
319 
325 typedef enum {
326  EC_INT_REQUEST_INIT,
327  EC_INT_REQUEST_QUEUED,
328  EC_INT_REQUEST_BUSY,
329  EC_INT_REQUEST_SUCCESS,
330  EC_INT_REQUEST_FAILURE
332 
333 /*****************************************************************************/
334 
336 
337 /*****************************************************************************/
338 
341 typedef enum {
344 } ec_origin_t;
345 
346 /*****************************************************************************/
347 
348 typedef struct ec_slave ec_slave_t;
350 /*****************************************************************************/
351 
352 #endif
Slave information interface general flags.
Definition: globals.h:203
Vendor specific.
Definition: globals.h:187
int ec_mac_is_zero(const uint8_t *)
Definition: module.c:277
void ec_print_data_diff(const uint8_t *, const uint8_t *, size_t)
Outputs frame contents and differences for debugging purposes.
Definition: module.c:383
uint8_t enable_upload_at_startup
?.
Definition: globals.h:197
Servo-Profile over EtherCAT.
Definition: globals.h:186
int32_t shift_time
Shift time [ns].
Definition: globals.h:220
uint8_t enable_not_lrw
Slave does not support LRW.
Definition: globals.h:205
OP (mailbox communication and input/output update)
Definition: globals.h:170
size_t ec_state_string(uint8_t, char *, uint8_t)
Prints slave states in clear text.
Definition: module.c:408
uint32_t code
Code.
Definition: globals.h:314
uint8_t enable_sdo
Enable SDO access.
Definition: globals.h:193
Bootstrap state (mailbox communication, firmware update)
Definition: globals.h:166
uint32_t cycle_time
Cycle time [ns].
Definition: globals.h:219
Acknowledge/Error bit (no actual state)
Definition: globals.h:172
ec_master_t * ecrt_request_master_err(unsigned int)
Request a master.
Definition: module.c:544
const char * message
Message belonging to code.
Definition: globals.h:315
const char * ec_device_names[2]
Device names.
Definition: module.c:472
size_t ec_mac_print(const uint8_t *, char *)
Print a MAC address to a buffer.
Definition: module.c:256
SAFEOP (mailbox communication and input update)
Definition: globals.h:168
Internal.
Definition: globals.h:342
ec_internal_request_state_t
Generic request state.
Definition: globals.h:325
EtherCAT slave.
Definition: slave.h:214
Code/Message pair.
Definition: globals.h:313
Slave information interface CANopen over EtherCAT details flags.
Definition: globals.h:192
CANopen over EtherCAT.
Definition: globals.h:184
uint8_t enable_safeop
?.
Definition: globals.h:204
uint8_t enable_sdo_info
SDO information service available.
Definition: globals.h:194
uint8_t enable_sdo_complete_access
Complete access possible.
Definition: globals.h:198
Access rights in OP.
Definition: globals.h:230
ec_device_index_t
Master devices.
Definition: globals.h:236
Number of states.
Definition: globals.h:231
External.
Definition: globals.h:343
Main device.
Definition: globals.h:237
Ethernet over EtherCAT.
Definition: globals.h:183
ec_slave_dc_range_t
EtherCAT slave distributed clocks range.
Definition: globals.h:210
ec_slave_state_t
State of an EtherCAT slave.
Definition: globals.h:159
Access rights in SAFEOP.
Definition: globals.h:229
32 bit.
Definition: globals.h:211
void ec_print_data(const uint8_t *, size_t)
Outputs frame contents for debugging purposes.
Definition: module.c:355
char * ec_master_version_str
Version string.
Definition: module.c:77
INIT state (no mailbox communication, no IO)
Definition: globals.h:162
EtherCAT slave sync signal configuration.
Definition: globals.h:218
ec_origin_t
Origin type.
Definition: globals.h:341
unsigned int ec_master_count(void)
Get the number of masters.
Definition: module.c:218
ec_request_state_t
Request state.
Definition: ecrt.h:537
PREOP state (mailbox communication, no IO)
Definition: globals.h:164
Backup device.
Definition: globals.h:238
Access rights in PREOP.
Definition: globals.h:228
const ec_request_state_t ec_request_state_translation_table[]
Global request state type translation table.
Definition: module.c:665
EtherCAT master.
Definition: master.h:202
uint8_t enable_pdo_configuration
PDO configuration possible.
Definition: globals.h:196
ADS over EtherCAT.
Definition: globals.h:182
File-Access over EtherCAT.
Definition: globals.h:185
unknown state
Definition: globals.h:160
uint8_t enable_pdo_assign
PDO mapping configurable.
Definition: globals.h:195