IgH EtherCAT Master  1.6.9
slave.h
Go to the documentation of this file.
1/*****************************************************************************
2 *
3 * Copyright (C) 2006-2012 Florian Pose, Ingenieurgemeinschaft IgH
4 *
5 * This file is part of the IgH EtherCAT Master.
6 *
7 * The IgH EtherCAT Master is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version 2, as
9 * published by the Free Software Foundation.
10 *
11 * The IgH EtherCAT Master is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
14 * Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with the IgH EtherCAT Master; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 ****************************************************************************/
21
26
27/****************************************************************************/
28
29#ifndef __EC_SLAVE_H__
30#define __EC_SLAVE_H__
31
32#include <linux/list.h>
33#include <linux/kobject.h>
34
35#include "globals.h"
36#include "datagram.h"
37#include "pdo.h"
38#include "sync.h"
39#include "sdo.h"
40#include "fsm_slave.h"
41
42/****************************************************************************/
43
54#define EC_SLAVE_INFO(slave, fmt, args...) \
55 printk(KERN_INFO "EtherCAT %u-%u: " fmt, slave->master->index, \
56 slave->ring_position, ##args)
57
68#define EC_SLAVE_ERR(slave, fmt, args...) \
69 printk(KERN_ERR "EtherCAT ERROR %u-%u: " fmt, slave->master->index, \
70 slave->ring_position, ##args)
71
82#define EC_SLAVE_WARN(slave, fmt, args...) \
83 printk(KERN_WARNING "EtherCAT WARNING %u-%u: " fmt, \
84 slave->master->index, slave->ring_position, ##args)
85
98#define EC_SLAVE_DBG(slave, level, fmt, args...) \
99 do { \
100 if (slave->master->debug_level >= level) { \
101 printk(KERN_DEBUG "EtherCAT DEBUG %u-%u: " fmt, \
102 slave->master->index, slave->ring_position, ##args); \
103 } \
104 } while (0)
105
106/****************************************************************************/
107
119
120/****************************************************************************/
121
124typedef struct {
125 // Non-category data
126 uint16_t alias;
127 uint32_t vendor_id;
128 uint32_t product_code;
130 uint32_t serial_number;
140
141 // Strings
142 char **strings;
143 unsigned int string_count;
144
145 // General
146 unsigned int has_general;
147 char *group;
148 char *image;
149 char *order;
150 char *name;
155
156 // SyncM
158 unsigned int sync_count;
159
160 // [RT]XPDO
161 struct list_head pdos;
162} ec_sii_t;
163
164/****************************************************************************/
165
169{
173
174 // addresses
175 uint16_t ring_position;
178
180
181 // configuration
185 unsigned int error_flag;
186 unsigned int force_config;
194
195 // base data
196 uint8_t base_type;
198 uint16_t base_build;
209
210 // SII
211 uint16_t *sii_words;
212 size_t sii_nwords;
213
214 // Slave information interface
216
217 struct list_head sdo_dictionary;
219 unsigned long jiffies_preop;
220
221 struct list_head sdo_requests;
222 struct list_head reg_requests;
223 struct list_head foe_requests;
224 struct list_head soe_requests;
225 struct list_head eoe_requests;
226
228};
229
230/****************************************************************************/
231
232// slave construction/destruction
234 uint16_t, uint16_t);
236
238
241
242// SII categories
243int ec_slave_fetch_sii_strings(ec_slave_t *, const uint8_t *, size_t);
244int ec_slave_fetch_sii_general(ec_slave_t *, const uint8_t *, size_t);
245int ec_slave_fetch_sii_syncs(ec_slave_t *, const uint8_t *, size_t);
246int ec_slave_fetch_sii_pdos(ec_slave_t *, const uint8_t *, size_t,
248
249// misc.
251
253 unsigned int *, unsigned int *);
255const ec_sdo_t *ec_slave_get_sdo_const(const ec_slave_t *, uint16_t);
256const ec_sdo_t *ec_slave_get_sdo_by_pos_const(const ec_slave_t *, uint16_t);
257uint16_t ec_slave_sdo_count(const ec_slave_t *);
258const ec_pdo_t *ec_slave_find_pdo(const ec_slave_t *, uint16_t);
260
263
264/****************************************************************************/
265
266#endif
EtherCAT datagram structure.
EtherCAT slave request state machine.
struct ec_fsm_slave ec_fsm_slave_t
Definition fsm_slave.h:48
Global definitions and macros.
ec_slave_state_t
State of an EtherCAT slave.
Definition globals.h:121
ec_slave_dc_range_t
EtherCAT slave distributed clocks range.
Definition globals.h:172
struct ec_slave ec_slave_t
Definition globals.h:310
ec_device_index_t
Master devices.
Definition globals.h:198
ec_slave_port_desc_t
EtherCAT slave port descriptor.
Definition ecrt.h:426
#define EC_MAX_PORTS
Maximum number of slave ports.
Definition ecrt.h:276
struct ec_master ec_master_t
Definition ecrt.h:300
ec_direction_t
Direction type for PDO assignment functions.
Definition ecrt.h:504
struct ec_slave_config ec_slave_config_t
Definition ecrt.h:303
EtherCAT Process data object structure.
EtherCAT CANopen SDO structure.
struct ec_sdo ec_sdo_t
Definition sdo_entry.h:40
int ec_slave_fetch_sii_pdos(ec_slave_t *, const uint8_t *, size_t, ec_direction_t)
Fetches data from a [RT]xPDO category.
Definition slave.c:495
void ec_slave_attach_pdo_names(ec_slave_t *)
Attach PDO names.
Definition slave.c:791
uint16_t ec_slave_sdo_count(const ec_slave_t *)
Get the number of SDOs in the dictionary.
Definition slave.c:716
int ec_slave_fetch_sii_syncs(ec_slave_t *, const uint8_t *, size_t)
Fetches data from a SYNC MANAGER category.
Definition slave.c:429
const ec_pdo_t * ec_slave_find_pdo(const ec_slave_t *, uint16_t)
Finds a mapped PDO.
Definition slave.c:735
const ec_sdo_t * ec_slave_get_sdo_const(const ec_slave_t *, uint16_t)
Get an SDO from the dictionary.
Definition slave.c:672
ec_sdo_t * ec_slave_get_sdo(ec_slave_t *, uint16_t)
Get an SDO from the dictionary.
Definition slave.c:646
void ec_slave_init(ec_slave_t *, ec_master_t *, ec_device_index_t, uint16_t, uint16_t)
Slave constructor.
Definition slave.c:60
void ec_slave_sdo_dict_info(const ec_slave_t *, unsigned int *, unsigned int *)
Counts the total number of SDOs and entries in the dictionary.
Definition slave.c:618
void ec_slave_clear_sync_managers(ec_slave_t *)
Clear the sync manager array.
Definition slave.c:265
void ec_slave_request_state(ec_slave_t *, ec_slave_state_t)
Request a slave state and resets the error flag.
Definition slave.c:306
int ec_slave_fetch_sii_strings(ec_slave_t *, const uint8_t *, size_t)
Fetches data from a STRING category.
Definition slave.c:322
void ec_slave_calc_transmission_delays_rec(ec_slave_t *, uint32_t *)
Recursively calculates transmission delays.
Definition slave.c:978
void ec_slave_set_state(ec_slave_t *, ec_slave_state_t)
Sets the application state of a slave.
Definition slave.c:284
int ec_slave_fetch_sii_general(ec_slave_t *, const uint8_t *, size_t)
Fetches data from a GENERAL category.
Definition slave.c:378
void ec_slave_calc_port_delays(ec_slave_t *)
Calculates the port transmission delays.
Definition slave.c:932
void ec_slave_clear(ec_slave_t *)
Slave destructor.
Definition slave.c:169
const ec_sdo_t * ec_slave_get_sdo_by_pos_const(const ec_slave_t *, uint16_t)
Get an SDO from the dictionary, given its position in the list.
Definition slave.c:694
ec_sync_t * ec_slave_get_sync(ec_slave_t *, uint8_t)
Get the sync manager given an index.
Definition slave.c:600
PDO description.
Definition pdo.h:41
Slave information interface CANopen over EtherCAT details flags.
Definition globals.h:154
Slave information interface general flags.
Definition globals.h:165
Slave information interface data.
Definition slave.h:124
uint16_t std_rx_mailbox_offset
Standard receive mailbox address.
Definition slave.h:135
char * group
Group name.
Definition slave.h:147
ec_sync_t * syncs
SYNC MANAGER categories.
Definition slave.h:157
uint16_t alias
Configured station alias.
Definition slave.h:126
char * order
Order number.
Definition slave.h:149
uint32_t serial_number
Serial number.
Definition slave.h:130
uint16_t std_tx_mailbox_size
Standard transmit mailbox size.
Definition slave.h:138
unsigned int string_count
Number of SII strings.
Definition slave.h:143
char * image
Image name.
Definition slave.h:148
uint16_t boot_tx_mailbox_size
Bootstrap transmit mailbox size.
Definition slave.h:134
int16_t current_on_ebus
Power consumption in mA.
Definition slave.h:154
uint32_t product_code
Vendor-specific product code.
Definition slave.h:128
char ** strings
Strings in SII categories.
Definition slave.h:142
struct list_head pdos
SII [RT]XPDO categories.
Definition slave.h:161
uint16_t mailbox_protocols
Supported mailbox protocols.
Definition slave.h:139
ec_sii_coe_details_t coe_details
CoE detail flags.
Definition slave.h:152
ec_sii_general_flags_t general_flags
General flags.
Definition slave.h:153
uint16_t boot_tx_mailbox_offset
Bootstrap transmit mailbox address.
Definition slave.h:133
uint16_t std_tx_mailbox_offset
Standard transmit mailbox address.
Definition slave.h:137
uint16_t boot_rx_mailbox_size
Bootstrap receive mailbox size.
Definition slave.h:132
uint32_t revision_number
Revision number.
Definition slave.h:129
uint16_t std_rx_mailbox_size
Standard receive mailbox size.
Definition slave.h:136
uint16_t boot_rx_mailbox_offset
Bootstrap receive mailbox address.
Definition slave.h:131
unsigned int has_general
General category present.
Definition slave.h:146
uint32_t vendor_id
Vendor ID.
Definition slave.h:127
unsigned int sync_count
Number of sync managers.
Definition slave.h:158
char * name
Slave name.
Definition slave.h:150
uint8_t physical_layer[EC_MAX_PORTS]
Port media.
Definition slave.h:151
Slave port.
Definition slave.h:110
uint32_t receive_time
Port receive times for delay measurement.
Definition slave.h:114
ec_slave_t * next_slave
Connected slaves.
Definition slave.h:113
ec_slave_port_link_t link
Port link status.
Definition slave.h:112
uint32_t delay_to_next_dc
Delay to next slave with DC support behind this port [ns].
Definition slave.h:116
ec_slave_port_desc_t desc
Port descriptors.
Definition slave.h:111
EtherCAT slave.
Definition slave.h:169
uint16_t configured_rx_mailbox_size
Configured receive mailbox size.
Definition slave.h:189
ec_sii_t sii
Extracted SII data.
Definition slave.h:215
unsigned int force_config
Force (re-)configuration.
Definition slave.h:186
ec_slave_port_t ports[EC_MAX_PORTS]
Ports.
Definition slave.h:179
uint32_t transmission_delay
DC system time transmission delay (offset from reference clock).
Definition slave.h:207
struct list_head sdo_dictionary
SDO dictionary list.
Definition slave.h:217
uint8_t base_dc_supported
Distributed clocks are supported.
Definition slave.h:202
uint16_t ring_position
Ring position.
Definition slave.h:175
ec_slave_config_t * config
Current configuration.
Definition slave.h:182
uint16_t configured_tx_mailbox_offset
Configured send mailbox offset.
Definition slave.h:191
struct list_head foe_requests
FoE requests.
Definition slave.h:223
uint16_t * sii_words
Complete SII image.
Definition slave.h:211
uint8_t base_fmmu_bit_operation
FMMU bit operation is supported.
Definition slave.h:201
uint8_t base_fmmu_count
Number of supported FMMUs.
Definition slave.h:199
uint8_t base_revision
Revision.
Definition slave.h:197
struct list_head reg_requests
Register access requests.
Definition slave.h:222
ec_slave_state_t current_state
Current application state.
Definition slave.h:184
uint8_t has_dc_system_time
The slave supports the DC system time register.
Definition slave.h:204
struct list_head eoe_requests
EoE set IP parameter requests.
Definition slave.h:225
struct list_head sdo_requests
SDO access requests.
Definition slave.h:221
uint16_t configured_tx_mailbox_size
Configured send mailbox size.
Definition slave.h:193
struct list_head soe_requests
SoE requests.
Definition slave.h:224
uint16_t configured_rx_mailbox_offset
Configured receive mailbox offset.
Definition slave.h:187
ec_slave_dc_range_t base_dc_range
DC range.
Definition slave.h:203
uint8_t base_type
Slave type.
Definition slave.h:196
uint8_t sdo_dictionary_fetched
Dictionary has been fetched.
Definition slave.h:218
uint16_t effective_alias
Effective alias address.
Definition slave.h:177
size_t sii_nwords
Size of the SII contents in words.
Definition slave.h:212
uint8_t base_sync_count
Number of supported sync managers.
Definition slave.h:200
ec_device_index_t device_index
Index of device the slave responds on.
Definition slave.h:171
ec_master_t * master
Master owning the slave.
Definition slave.h:170
uint16_t station_address
Configured station address.
Definition slave.h:176
ec_fsm_slave_t fsm
Slave state machine.
Definition slave.h:227
unsigned int error_flag
Stop processing after an error.
Definition slave.h:185
unsigned long jiffies_preop
Time, the slave went to PREOP.
Definition slave.h:219
ec_slave_state_t requested_state
Requested application state.
Definition slave.h:183
uint16_t base_build
Build number.
Definition slave.h:198
Sync manager.
Definition sync.h:39
EtherCAT sync manager.