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 
63 #define EC_WAIT_SDO_DICT 3
64 
66 #define EC_STATE_STRING_SIZE 32
67 
69 #define EC_MAX_SII_SIZE 4096
70 
72 #define EC_RATE_COUNT 3
73 
74 /******************************************************************************
75  * EtherCAT protocol
76  *****************************************************************************/
77 
79 #define EC_FRAME_HEADER_SIZE 2
80 
82 #define EC_DATAGRAM_HEADER_SIZE 10
83 
85 #define EC_DATAGRAM_FOOTER_SIZE 2
86 
88 #define EC_ADDR_LEN 4
89 
91 #define EC_MAX_DATA_SIZE (ETH_DATA_LEN - EC_FRAME_HEADER_SIZE \
92  - EC_DATAGRAM_HEADER_SIZE - EC_DATAGRAM_FOOTER_SIZE)
93 
95 #define EC_MBOX_HEADER_SIZE 6
96 
98 #define EC_FIRST_SII_CATEGORY_OFFSET 0x40
99 
101 #define EC_SYNC_PAGE_SIZE 8
102 
104 #define EC_MAX_FMMUS 16
105 
107 #define EC_FMMU_PAGE_SIZE 16
108 
110 #define EC_SYNC_SIGNAL_COUNT 2
111 
116 #define EC_DATAGRAM_NAME_SIZE 20
117 
123 #define EC_SLAVE_STATE_MASK 0x0F
124 
127 typedef enum {
143 
146 enum {
147  EC_MBOX_AOE = 0x01,
148  EC_MBOX_EOE = 0x02,
149  EC_MBOX_COE = 0x04,
150  EC_MBOX_FOE = 0x08,
151  EC_MBOX_SOE = 0x10,
152  EC_MBOX_VOE = 0x20
153 };
154 
157 typedef struct {
158  uint8_t enable_sdo : 1;
159  uint8_t enable_sdo_info : 1;
160  uint8_t enable_pdo_assign : 1;
161  uint8_t enable_pdo_configuration : 1;
162  uint8_t enable_upload_at_startup : 1;
163  uint8_t enable_sdo_complete_access : 1;
165 
168 typedef struct {
169  uint8_t enable_safeop : 1;
170  uint8_t enable_not_lrw : 1;
172 
175 typedef enum {
177  EC_DC_64 /*< 64 bit for system time, system time offset and
178  port 0 receive time. */
180 
183 typedef struct {
184  uint32_t cycle_time;
185  int32_t shift_time;
187 
192 enum {
197 };
198 
201 typedef enum {
205 
206 extern const char *ec_device_names[2]; // only main and backup!
207 
208 /*****************************************************************************/
209 
217 #define EC_INFO(fmt, args...) \
218  printk(KERN_INFO "EtherCAT: " fmt, ##args)
219 
227 #define EC_ERR(fmt, args...) \
228  printk(KERN_ERR "EtherCAT ERROR: " fmt, ##args)
229 
237 #define EC_WARN(fmt, args...) \
238  printk(KERN_WARNING "EtherCAT WARNING: " fmt, ##args)
239 
247 #define EC_DBG(fmt, args...) \
248  printk(KERN_DEBUG "EtherCAT DEBUG: " fmt, ##args)
249 
250 /*****************************************************************************/
251 
254 #define EC_ABS(X) ((X) >= 0 ? (X) : -(X))
255 
256 /*****************************************************************************/
257 
258 extern char *ec_master_version_str;
259 
260 /*****************************************************************************/
261 
262 unsigned int ec_master_count(void);
263 void ec_print_data(const uint8_t *, size_t);
264 void ec_print_data_diff(const uint8_t *, const uint8_t *, size_t);
265 size_t ec_state_string(uint8_t, char *, uint8_t);
266 ssize_t ec_mac_print(const uint8_t *, char *);
267 int ec_mac_is_zero(const uint8_t *);
268 
269 ec_master_t *ecrt_request_master_err(unsigned int);
270 
271 /*****************************************************************************/
272 
278 typedef struct {
279  uint32_t code;
280  const char *message;
281 } ec_code_msg_t;
282 
283 /*****************************************************************************/
284 
290 typedef enum {
291  EC_INT_REQUEST_INIT,
292  EC_INT_REQUEST_QUEUED,
293  EC_INT_REQUEST_BUSY,
294  EC_INT_REQUEST_SUCCESS,
295  EC_INT_REQUEST_FAILURE
297 
298 /*****************************************************************************/
299 
301 
302 /*****************************************************************************/
303 
306 typedef enum {
309 } ec_origin_t;
310 
311 /*****************************************************************************/
312 
313 typedef struct ec_slave ec_slave_t;
315 /*****************************************************************************/
316 
317 #endif
Slave information interface general flags.
Definition: globals.h:168
int ec_mac_is_zero(const uint8_t *)
Definition: module.c:263
File-Access over EtherCAT.
Definition: globals.h:150
Ethernet over EtherCAT.
Definition: globals.h:148
CANopen over EtherCAT.
Definition: globals.h:149
void ec_print_data_diff(const uint8_t *, const uint8_t *, size_t)
Outputs frame contents and differences for debugging purposes.
Definition: module.c:369
int32_t shift_time
Shift time [ns].
Definition: globals.h:185
OP (mailbox communication and input/output update)
Definition: globals.h:138
size_t ec_state_string(uint8_t, char *, uint8_t)
Prints slave states in clear text.
Definition: module.c:394
uint32_t code
Code.
Definition: globals.h:279
Access rights in PREOP.
Definition: globals.h:193
Bootstrap state (mailbox communication, firmware update)
Definition: globals.h:134
uint32_t cycle_time
Cycle time [ns].
Definition: globals.h:184
Acknowledge/Error bit (no actual state)
Definition: globals.h:140
ec_master_t * ecrt_request_master_err(unsigned int)
Request a master.
Definition: module.c:530
const char * message
Message belonging to code.
Definition: globals.h:280
const char * ec_device_names[2]
Device names.
Definition: module.c:458
Vendor specific.
Definition: globals.h:152
SAFEOP (mailbox communication and input update)
Definition: globals.h:136
Internal.
Definition: globals.h:307
ec_internal_request_state_t
Generic request state.
Definition: globals.h:290
EtherCAT slave.
Definition: slave.h:176
Access rights in SAFEOP.
Definition: globals.h:194
Code/Message pair.
Definition: globals.h:278
Slave information interface CANopen over EtherCAT details flags.
Definition: globals.h:157
ec_device_index_t
Master devices.
Definition: globals.h:201
External.
Definition: globals.h:308
Main device.
Definition: globals.h:202
ec_slave_dc_range_t
EtherCAT slave distributed clocks range.
Definition: globals.h:175
ec_slave_state_t
State of an EtherCAT slave.
Definition: globals.h:127
32 bit.
Definition: globals.h:176
void ec_print_data(const uint8_t *, size_t)
Outputs frame contents for debugging purposes.
Definition: module.c:341
char * ec_master_version_str
Version string.
Definition: module.c:71
INIT state (no mailbox communication, no IO)
Definition: globals.h:130
ssize_t ec_mac_print(const uint8_t *, char *)
Print a MAC address to a buffer.
Definition: module.c:242
Servo-Profile over EtherCAT.
Definition: globals.h:151
EtherCAT slave sync signal configuration.
Definition: globals.h:183
Access rights in OP.
Definition: globals.h:195
ec_origin_t
Origin type.
Definition: globals.h:306
unsigned int ec_master_count(void)
Get the number of masters.
Definition: module.c:204
ADS over EtherCAT.
Definition: globals.h:147
Number of states.
Definition: globals.h:196
ec_request_state_t
Request state.
Definition: ecrt.h:517
PREOP state (mailbox communication, no IO)
Definition: globals.h:132
Backup device.
Definition: globals.h:203
const ec_request_state_t ec_request_state_translation_table[]
Global request state type translation table.
Definition: module.c:651
EtherCAT master.
Definition: master.h:194
unknown state
Definition: globals.h:128