37 #ifndef __EC_SLAVE_H__ 38 #define __EC_SLAVE_H__ 40 #include <linux/list.h> 41 #include <linux/kobject.h> 42 #include <linux/rtmutex.h> 63 #define EC_SLAVE_INFO(slave, fmt, args...) \ 64 printk(KERN_INFO "EtherCAT %u-%u: " fmt, slave->master->index, \ 65 slave->ring_position, ##args) 77 #define EC_SLAVE_ERR(slave, fmt, args...) \ 78 printk(KERN_ERR "EtherCAT ERROR %u-%u: " fmt, slave->master->index, \ 79 slave->ring_position, ##args) 91 #define EC_SLAVE_WARN(slave, fmt, args...) \ 92 printk(KERN_WARNING "EtherCAT WARNING %u-%u: " fmt, \ 93 slave->master->index, slave->ring_position, ##args) 107 #define EC_SLAVE_DBG(slave, level, fmt, args...) \ 109 if (slave->master->debug_level >= level) { \ 110 printk(KERN_DEBUG "EtherCAT DEBUG %u-%u: " fmt, \ 111 slave->master->index, slave->ring_position, ##args); \ 117 #ifdef EC_LOOP_CONTROL 125 } ec_slave_port_state_t;
129 #define EC_PORT_WAIT_MS 2000 145 #ifdef EC_LOOP_CONTROL 146 ec_slave_port_state_t state;
147 unsigned long link_detection_jiffies;
192 struct list_head pdos;
248 struct list_head sdo_dictionary;
252 struct list_head sdo_requests;
253 struct list_head reg_requests;
254 struct list_head foe_requests;
255 struct list_head soe_requests;
256 struct list_head eoe_requests;
257 struct list_head dict_requests;
262 struct rt_mutex mbox_sem;
300 unsigned int *,
unsigned int *);
ec_sii_general_flags_t general_flags
General flags.
ec_mbox_data_t mbox_eoe_frag_data
Received mailbox data for EoE, type frame fragment.
Slave information interface general flags.
uint16_t ring_position
Ring position.
uint32_t revision_number
Revision number.
uint16_t boot_rx_mailbox_offset
Bootstrap receive mailbox address.
ec_sii_t sii
Extracted SII data.
int ec_slave_fetch_sii_syncs(ec_slave_t *, const uint8_t *, size_t)
Fetches data from a SYNC MANAGER category.
uint16_t configured_tx_mailbox_size
Configured send mailbox size.
uint16_t base_build
Build number.
ec_slave_port_desc_t
EtherCAT slave port descriptor.
ec_mbox_data_t mbox_eoe_init_data
Received mailbox data for EoE, type eoe init reponse.
void ec_slave_request_state(ec_slave_t *, ec_slave_state_t)
Request a slave state and resets the error flag.
uint16_t configured_tx_mailbox_offset
Configured send mailbox offset.
ec_slave_state_t current_state
Current application state.
ec_mbox_data_t mbox_foe_data
Received mailbox data for FoE.
ec_sync_t * ec_slave_get_sync(ec_slave_t *, uint8_t)
Get the sync manager given an index.
ec_slave_port_link_t link
Port link status.
EtherCAT mailbox response data.
uint32_t serial_number
Serial number.
const ec_pdo_t * ec_slave_find_pdo(const ec_slave_t *, uint16_t)
Finds a mapped PDO.
ec_sii_coe_details_t coe_details
CoE detail flags.
char * order
Order number.
int ec_slave_fetch_sii_general(ec_slave_t *, const uint8_t *, size_t)
Fetches data from a GENERAL category.
Finite state machine of an EtherCAT slave.
ec_fsm_slave_t fsm
Slave state machine.
int16_t current_on_ebus
Power consumption in mA.
uint16_t boot_tx_mailbox_size
Bootstrap transmit mailbox size.
EtherCAT slave port information.
void ec_read_mbox_lock_clear(ec_slave_t *)
Clears the mailbox lock.
int ec_read_mbox_locked(ec_slave_t *)
Return the current mailbox lock status and lock it if not locked.
uint16_t station_address
Configured station address.
unsigned int sync_count
Number of sync managers.
uint16_t std_rx_mailbox_size
Standard receive mailbox size.
uint8_t base_type
Slave type.
const ec_sdo_t * ec_slave_get_sdo_const(const ec_slave_t *, uint16_t)
Get an SDO from the dictionary.
int ec_slave_fetch_sii_pdos(ec_slave_t *, const uint8_t *, size_t, ec_direction_t)
Fetches data from a [RT]xPDO category.
Global definitions and macros.
uint16_t std_tx_mailbox_offset
Standard transmit mailbox address.
uint16_t boot_tx_mailbox_offset
Bootstrap transmit mailbox address.
void ec_slave_init(ec_slave_t *, ec_master_t *, ec_device_index_t, uint16_t, uint16_t)
Slave constructor.
uint16_t ec_slave_sdo_count(const ec_slave_t *)
Get the number of SDOs in the dictionary.
Slave information interface CANopen over EtherCAT details flags.
ec_slave_config_t * config
Current configuration.
uint8_t sdo_dictionary_fetched
Dictionary has been fetched.
uint16_t * sii_words
Complete SII image.
uint16_t mailbox_protocols
Supported mailbox protocols.
ec_slave_dc_range_t base_dc_range
DC range.
uint16_t std_rx_mailbox_offset
Standard receive mailbox address.
uint8_t base_fmmu_bit_operation
FMMU bit operation is supported.
uint32_t transmission_delay
DC system time transmission delay (offset from reference clock).
ec_device_index_t
Master devices.
void ec_slave_calc_port_delays(ec_slave_t *)
Calculates the port transmission delays.
uint16_t alias
Configured station alias.
ec_direction_t
Direction type for PDO assignment functions.
uint8_t base_fmmu_count
Number of supported FMMUs.
uint16_t configured_rx_mailbox_offset
Configured receive mailbox offset.
void ec_slave_clear_sync_managers(ec_slave_t *)
Clear the sync manager array.
ec_slave_dc_range_t
EtherCAT slave distributed clocks range.
ec_slave_port_desc_t desc
Port descriptors.
unsigned int string_count
Number of SII strings.
ec_master_t * master
Master owning the slave.
uint8_t has_dc_system_time
The slave supports the DC system time register.
char ** strings
Strings in SII categories.
ec_slave_state_t
State of an EtherCAT slave.
void ec_slave_clear(ec_slave_t *)
Slave destructor.
void ec_slave_set_dl_status(ec_slave_t *, uint16_t)
Sets the data-link state of a slave.
EtherCAT datagram structure.
void ec_slave_set_al_status(ec_slave_t *, ec_slave_state_t)
Sets the application state of a slave.
void ec_slave_calc_transmission_delays_rec(ec_slave_t *, uint32_t *)
Recursively calculates transmission delays.
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.
uint8_t base_revision
Revision.
uint8_t valid_mbox_data
Received mailbox data is valid.
uint16_t effective_alias
Effective alias address.
uint16_t boot_rx_mailbox_size
Bootstrap receive mailbox size.
#define EC_MAX_PORTS
Maximum number of slave ports.
uint8_t read_mbox_busy
Flag set during a mailbox read request.
EtherCAT slave request state machine.
ec_slave_t * next_slave
Connected slaves.
uint32_t receive_time
Port receive times for delay measurement.
ec_mbox_data_t mbox_voe_data
Received mailbox data for VoE.
unsigned long jiffies_preop
Time, the slave went to PREOP.
uint16_t configured_rx_mailbox_size
Configured receive mailbox size.
uint8_t base_dc_supported
Distributed clocks are supported.
Slave information interface data.
size_t sii_nwords
Size of the SII contents in words.
void ec_slave_attach_pdo_names(ec_slave_t *)
Attach PDO names.
uint8_t base_sync_count
Number of supported sync managers.
EtherCAT slave configuration.
ec_device_index_t device_index
Index of device the slave responds on.
uint32_t product_code
Vendor-specific product code.
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.
unsigned int error_flag
Stop processing after an error.
ec_sync_t * syncs
SYNC MANAGER categories.
uint16_t std_tx_mailbox_size
Standard transmit mailbox size.
ec_slave_state_t requested_state
Requested application state.
int ec_slave_fetch_sii_strings(ec_slave_t *, const uint8_t *, size_t)
Fetches data from a STRING category.
EtherCAT CANopen SDO structure.
ec_mbox_data_t mbox_coe_data
Received mailbox data for CoE.
ec_mbox_data_t mbox_soe_data
Received mailbox data for SoE.
uint32_t vendor_id
Vendor ID.
uint32_t delay_to_next_dc
Delay to next slave with DC support behind this port [ns].
unsigned int force_config
Force (re-)configuration.
unsigned int has_general
General category present.
ec_sdo_t * ec_slave_get_sdo(ec_slave_t *, uint16_t)
Get an SDO from the dictionary.
EtherCAT Process data object structure.