43#include <linux/module.h>
44#include <linux/slab.h>
59 struct list_head list;
62 unsigned int timeout_ms;
113 INIT_LIST_HEAD(&sc->
flags);
148 list_for_each_entry_safe(req, next_req, &sc->
sdo_configs, list) {
149 list_del(&req->
list);
155 list_for_each_entry_safe(req, next_req, &sc->
sdo_requests, list) {
156 list_del(&req->
list);
162 list_for_each_entry_safe(soe, next_soe, &sc->
soe_requests, list) {
163 list_del(&soe->
list);
169 list_for_each_entry_safe(reg, next_reg, &sc->
reg_requests, list) {
170 list_del(®->
list);
176 list_for_each_entry_safe(voe, next_voe, &sc->
voe_handlers, list) {
177 list_del(&voe->
list);
183 list_for_each_entry_safe(soe, next_soe, &sc->
soe_configs, list) {
184 list_del(&soe->
list);
190 list_for_each_entry_safe(flag, next_flag, &sc->
flags, list) {
191 list_del(&flag->
list);
197 list_for_each_entry_safe(timeout, next_timeout, &sc->
al_timeouts, list) {
198 list_del(&timeout->list);
268 EC_CONFIG_DBG(sc, 1,
"Failed to find slave for configuration.\n");
273 EC_CONFIG_DBG(sc, 1,
"Failed to attach configuration. Slave %u"
279#ifdef EC_IDENT_WILDCARDS
284 EC_CONFIG_DBG(sc, 1,
"Slave %u has no matching vendor ID (0x%08X)"
285 " for configuration (0x%08X).\n",
291#ifdef EC_IDENT_WILDCARDS
296 EC_CONFIG_DBG(sc, 1,
"Slave %u has no matching product code (0x%08X)"
297 " for configuration (0x%08X).\n",
361 "SM%u has an invalid direction field!\n", sync_index);
383 EC_CONFIG_DBG(sc, 1,
"Loading default mapping for PDO 0x%04X.\n",
390 list_for_each_entry(default_pdo, &sync->
pdos.
list, list) {
394 if (default_pdo->
name) {
408 list_for_each_entry(entry, &pdo->
entries, list) {
432 unsigned int count = 0;
476 unsigned int count = 0;
520 unsigned int count = 0;
522 list_for_each_entry(flag, &sc->
flags, list) {
544 list_for_each_entry(flag, &sc->
flags, list) {
654 list_for_each_entry(flag, &sc->
flags, list) {
655 if (!strcmp(flag->
key, key)) {
675 list_for_each_entry(timeout, &sc->
al_timeouts, list) {
676 if (timeout->from == from && timeout->to == to) {
677 return timeout->timeout_ms;
693 EC_CONFIG_DBG(sc, 1,
"%s(sc = 0x%p, sync_index = %u, dir = %i,"
694 " watchdog_mode = %i)\n", __func__, sc, sync_index, dir,
698 EC_CONFIG_ERR(sc,
"Invalid sync manager index %u!\n", sync_index);
703 EC_CONFIG_ERR(sc,
"Invalid direction %u!\n", (
unsigned int) dir);
708 sync_config->
dir = dir;
716 uint16_t divider, uint16_t intervals)
718 EC_CONFIG_DBG(sc, 1,
"%s(sc = 0x%p, divider = %u, intervals = %u)\n",
719 __func__, sc, divider, intervals);
732 " config_mode = %u)\n", __func__, sc, assign_mode, config_mode);
735 EC_CONFIG_ERR(sc,
"Invalid PDO assignment mode %u!\n", assign_mode);
753 uint8_t sync_index, uint16_t pdo_index)
758 "pdo_index = 0x%04X)\n", __func__, sc, sync_index, pdo_index);
761 EC_CONFIG_ERR(sc,
"Invalid sync manager index %u!\n", sync_index);
786 __func__, sc, sync_index);
789 EC_CONFIG_ERR(sc,
"Invalid sync manager index %u!\n", sync_index);
802 uint16_t pdo_index, uint16_t entry_index, uint8_t entry_subindex,
803 uint8_t entry_bit_length)
811 "pdo_index = 0x%04X, entry_index = 0x%04X, "
812 "entry_subindex = 0x%02X, entry_bit_length = %u)\n",
813 __func__, sc, pdo_index, entry_index, entry_subindex,
827 retval = PTR_ERR(entry);
829 EC_CONFIG_ERR(sc,
"PDO 0x%04X is not assigned.\n", pdo_index);
845 __func__, sc, pdo_index);
868 unsigned int i, j, k;
873 EC_CONFIG_DBG(sc, 1,
"%s(sc = 0x%p, n_syncs = %u, syncs = 0x%p)\n",
874 __func__, sc, n_syncs, syncs);
879 for (i = 0; i < n_syncs; i++) {
880 sync_info = &syncs[i];
899 for (j = 0; j < sync_info->
n_pdos; j++) {
900 pdo_info = &sync_info->
pdos[j];
910 for (k = 0; k < pdo_info->
n_entries; k++) {
911 entry_info = &pdo_info->
entries[k];
935 unsigned int *bit_position
940 unsigned int bit_offset, bit_pos;
946 "subindex = 0x%02X, domain = 0x%p, bit_position = 0x%p)\n",
947 __func__, sc, index, subindex, domain, bit_position);
953 list_for_each_entry(pdo, &sync_config->
pdos.
list, list) {
954 list_for_each_entry(entry, &pdo->
entries, list) {
958 bit_pos = bit_offset % 8;
960 *bit_position = bit_pos;
961 }
else if (bit_pos) {
963 " not byte-align.\n", index, subindex);
968 sc, domain, sync_index, sync_config->
dir);
972 return sync_offset + bit_offset / 8;
988 unsigned int pdo_pos,
989 unsigned int entry_pos,
991 unsigned int *bit_position
995 unsigned int bit_offset, pp, ep;
999 EC_CONFIG_DBG(sc, 1,
"%s(sc = 0x%p, sync_index = %u, pdo_pos = %u,"
1000 " entry_pos = %u, domain = 0x%p, bit_position = 0x%p)\n",
1001 __func__, sc, sync_index, pdo_pos, entry_pos,
1002 domain, bit_position);
1005 EC_CONFIG_ERR(sc,
"Invalid syncmanager position %u.\n", sync_index);
1013 list_for_each_entry(pdo, &sync_config->
pdos.
list, list) {
1015 list_for_each_entry(entry, &pdo->
entries, list) {
1016 if (pp != pdo_pos || ep != entry_pos) {
1019 unsigned int bit_pos = bit_offset % 8;
1023 *bit_position = bit_pos;
1024 }
else if (bit_pos) {
1026 " not byte-align.\n",
1032 sc, domain, sync_index, sync_config->
dir);
1033 if (sync_offset < 0)
1036 return sync_offset + bit_offset / 8;
1043 EC_CONFIG_ERR(sc,
"PDO entry specification %u/%u/%u out of range.\n",
1044 sync_index, pdo_pos, entry_pos);
1051 uint32_t sync0_cycle_time, int32_t sync0_shift_time,
1052 uint32_t sync1_cycle_time, int32_t sync1_shift_time)
1054 EC_CONFIG_DBG(sc, 1,
"%s(sc = 0x%p, assign_activate = 0x%04X,"
1055 " sync0_cycle = %u, sync0_shift = %i,"
1056 " sync1_cycle = %u, sync1_shift = %i\n",
1057 __func__, sc, assign_activate, sync0_cycle_time, sync0_shift_time,
1058 sync1_cycle_time, sync1_shift_time);
1071 uint8_t subindex,
const uint8_t *data,
size_t size)
1078 "subindex = 0x%02X, data = 0x%p, size = %zu)\n",
1079 __func__, sc, index, subindex, data, size);
1088 " SDO configuration!\n");
1111 uint8_t subindex, uint8_t value)
1116 "subindex = 0x%02X, value = %u)\n",
1117 __func__, sc, index, subindex, (
unsigned int) value);
1126 uint8_t subindex, uint16_t value)
1131 "subindex = 0x%02X, value = %u)\n",
1132 __func__, sc, index, subindex, value);
1141 uint8_t subindex, uint32_t value)
1146 "subindex = 0x%02X, value = %u)\n",
1147 __func__, sc, index, subindex, value);
1156 const uint8_t *data,
size_t size)
1163 "data = 0x%p, size = %zu)\n", __func__, sc, index, data, size);
1172 " SDO configuration!\n");
1233 "index = 0x%04X, subindex = 0x%02X, size = %zu)\n",
1234 __func__, sc, index, subindex, size);
1238 EC_CONFIG_ERR(sc,
"Failed to allocate SDO request memory!\n");
1239 return ERR_PTR(-ENOMEM);
1249 return ERR_PTR(ret);
1253 memset(req->
data, 0x00, size);
1270 return IS_ERR(s) ? NULL : s;
1285 "drive_no = 0x%02X, idn = 0x%04X, size = %zu)\n",
1286 __func__, sc, drive_no, idn, size);
1290 EC_CONFIG_ERR(sc,
"Failed to allocate IDN request memory!\n");
1291 return ERR_PTR(-ENOMEM);
1301 return ERR_PTR(ret);
1305 memset(req->
data, 0x00, size);
1321 drive_no, idn, size);
1322 return IS_ERR(req) ? NULL : req;
1337 __func__, sc, size);
1341 EC_CONFIG_ERR(sc,
"Failed to allocate register request memory!\n");
1342 return ERR_PTR(-ENOMEM);
1348 return ERR_PTR(ret);
1365 return IS_ERR(reg) ? NULL : reg;
1379 EC_CONFIG_DBG(sc, 1,
"%s(sc = 0x%p, size = %zu)\n", __func__, sc, size);
1383 EC_CONFIG_ERR(sc,
"Failed to allocate VoE request memory!\n");
1384 return ERR_PTR(-ENOMEM);
1390 return ERR_PTR(ret);
1407 return IS_ERR(voe) ? NULL : voe;
1417 state->
online = slave ? 1 : 0;
1439 EC_CONFIG_DBG(sc, 1,
"%s(sc = 0x%p, drive_no = %u, idn = 0x%04X, "
1440 "state = %u, data = 0x%p, size = %zu)\n",
1441 __func__, sc, drive_no, idn, state, data, size);
1445 (
unsigned int) drive_no);
1451 " must be PREOP or SAFEOP!\n");
1462 " IDN configuration!\n");
1491 EC_CONFIG_DBG(sc, 1,
"%s(sc = 0x%p, key = %s, value = %i)\n",
1492 __func__, sc, key, value);
1497 flag->
value = value;
1525 const unsigned char *mac_address)
1535 struct in_addr ip_address)
1545 struct in_addr subnet_mask)
1555 struct in_addr gateway_address)
1565 struct in_addr dns_address)
1607 list_for_each_entry(timeout, &sc->
al_timeouts, list) {
1608 if (timeout->from == from_state && timeout->to == to_state) {
1609 if (timeout_ms == 0) {
1611 list_del(&timeout->list);
1615 timeout->timeout_ms = timeout_ms;
1620 if (timeout_ms == 0) {
1628 " AL timeout configuration!\n");
1632 timeout->from = from_state;
1633 timeout->to = to_state;
1634 timeout->timeout_ms = timeout_ms;
int ec_coe_emerg_ring_overruns(const ec_coe_emerg_ring_t *ring)
Read the number of overruns.
void ec_coe_emerg_ring_init(ec_coe_emerg_ring_t *ring, ec_slave_config_t *sc)
Emergency ring buffer constructor.
int ec_coe_emerg_ring_pop(ec_coe_emerg_ring_t *ring, u8 *msg)
Remove an emergency message from the ring.
int ec_coe_emerg_ring_clear_ring(ec_coe_emerg_ring_t *ring)
Clear the ring.
int ec_coe_emerg_ring_size(ec_coe_emerg_ring_t *ring, size_t size)
Set the ring size.
void ec_coe_emerg_ring_clear(ec_coe_emerg_ring_t *ring)
Emergency ring buffer destructor.
void ec_eoe_request_init(ec_eoe_request_t *req)
EoE request constructor.
EtherCAT EoE request structure.
int ec_flag_init(ec_flag_t *flag, const char *key, int32_t value)
SDO request constructor.
void ec_flag_clear(ec_flag_t *flag)
SDO request destructor.
EtherCAT Slave Configuration Feature Flag.
void ec_fmmu_config_init(ec_fmmu_config_t *fmmu, ec_slave_config_t *sc, ec_domain_t *domain, uint8_t sync_index, ec_direction_t dir)
FMMU configuration constructor.
Global definitions and macros.
ec_slave_state_t
State of an EtherCAT slave.
@ EC_SLAVE_STATE_OP
OP (mailbox communication and input/output update).
@ EC_SLAVE_STATE_UNKNOWN
unknown state
@ EC_MBOX_COE
CANopen over EtherCAT.
@ EC_MBOX_SOE
Servo-Profile over EtherCAT.
#define EC_MAX_FMMUS
Maximum number of FMMUs per slave.
struct ec_slave ec_slave_t
#define EC_MAX_HOSTNAME_SIZE
Maximum hostname size.
int ecrt_slave_config_pdos(ec_slave_config_t *sc, unsigned int n_syncs, const ec_sync_info_t syncs[])
Specify a complete PDO configuration.
struct ec_soe_request ec_soe_request_t
int ecrt_slave_config_emerg_clear(ec_slave_config_t *sc)
Clears CoE emergency ring buffer and the overrun counter.
int ecrt_slave_config_sync_manager(ec_slave_config_t *sc, uint8_t sync_index, ec_direction_t dir, ec_watchdog_mode_t watchdog_mode)
Configure a sync manager.
int ecrt_soe_request_idn(ec_soe_request_t *req, uint8_t drive_no, uint16_t idn)
Set the request's drive and Sercos ID numbers.
ec_al_state_t
Application-layer state.
ec_sdo_request_t * ecrt_slave_config_create_sdo_request(ec_slave_config_t *sc, uint16_t index, uint8_t subindex, size_t size)
Create an SDO request to exchange SDOs during realtime operation.
int ecrt_slave_config_reg_pdo_entry_pos(ec_slave_config_t *sc, uint8_t sync_index, unsigned int pdo_pos, unsigned int entry_pos, ec_domain_t *domain, unsigned int *bit_position)
Registers a PDO entry using its position.
int ecrt_slave_config_watchdog(ec_slave_config_t *sc, uint16_t divider, uint16_t intervals)
Configure a slave's watchdog times.
ec_soe_request_t * ecrt_slave_config_create_soe_request(ec_slave_config_t *sc, uint8_t drive_no, uint16_t idn, size_t size)
Create an SoE request to exchange SoE IDNs during realtime operation.
int ecrt_slave_config_idn(ec_slave_config_t *sc, uint8_t drive_no, uint16_t idn, ec_al_state_t state, const uint8_t *data, size_t size)
Add an SoE IDN configuration.
int ecrt_slave_config_pdo_mode(ec_slave_config_t *sc, ec_pdo_mode_t assign_mode, ec_pdo_mode_t config_mode)
Selects how a slave's PDO assignment and PDO configuration are read from resp.
int ecrt_slave_config_eoe_subnet_mask(ec_slave_config_t *sc, struct in_addr subnet_mask)
Sets the subnet mask for Ethernet-over-EtherCAT (EoE) operation.
int ecrt_slave_config_sdo32(ec_slave_config_t *sc, uint16_t index, uint8_t subindex, uint32_t value)
Add a configuration value for a 32-bit SDO.
int ecrt_slave_config_emerg_overruns(const ec_slave_config_t *sc)
Read the number of CoE emergency overruns.
#define EC_WRITE_U8(DATA, VAL)
Write an 8-bit unsigned value to EtherCAT data.
struct ec_voe_handler ec_voe_handler_t
int ecrt_slave_config_state(const ec_slave_config_t *sc, ec_slave_config_state_t *state)
Outputs the state of the slave configuration.
ec_voe_handler_t * ecrt_slave_config_create_voe_handler(ec_slave_config_t *sc, size_t size)
Create an VoE handler to exchange vendor-specific data during realtime operation.
int ecrt_slave_config_pdo_assign_clear(ec_slave_config_t *sc, uint8_t sync_index)
Clear a sync manager's PDO assignment.
struct ec_sdo_request ec_sdo_request_t
int ecrt_slave_config_dc(ec_slave_config_t *sc, uint16_t assign_activate, uint32_t sync0_cycle_time, int32_t sync0_shift_time, uint32_t sync1_cycle_time, int32_t sync1_shift_time)
Configure distributed clocks.
int ecrt_slave_config_flag(ec_slave_config_t *sc, const char *key, int32_t value)
Adds a feature flag to a slave configuration.
struct ec_master ec_master_t
int ecrt_slave_config_eoe_default_gateway(ec_slave_config_t *sc, struct in_addr gateway_address)
Sets the gateway address for Ethernet-over-EtherCAT (EoE) operation.
int ecrt_slave_config_pdo_mapping_add(ec_slave_config_t *sc, uint16_t pdo_index, uint16_t entry_index, uint8_t entry_subindex, uint8_t entry_bit_length)
Add a PDO entry to the given PDO's mapping.
ec_pdo_mode_t
PDO handling mode.
ec_direction_t
Direction type for PDO assignment functions.
int ecrt_slave_config_sdo(ec_slave_config_t *sc, uint16_t index, uint8_t subindex, const uint8_t *data, size_t size)
Add an SDO configuration.
struct ec_domain ec_domain_t
struct ec_slave_config ec_slave_config_t
struct ec_reg_request ec_reg_request_t
int ecrt_slave_config_reg_pdo_entry(ec_slave_config_t *sc, uint16_t index, uint8_t subindex, ec_domain_t *domain, unsigned int *bit_position)
Registers a PDO entry for process data exchange in a domain.
#define EC_WRITE_U32(DATA, VAL)
Write a 32-bit unsigned value to EtherCAT data.
int ecrt_slave_config_eoe_mac_address(ec_slave_config_t *sc, const unsigned char *mac_address)
Sets the link/MAC address for Ethernet-over-EtherCAT (EoE) operation.
int ecrt_slave_config_complete_sdo(ec_slave_config_t *sc, uint16_t index, const uint8_t *data, size_t size)
Add configuration data for a complete SDO.
ec_watchdog_mode_t
Watchdog mode for sync manager configuration.
int ecrt_slave_config_eoe_ip_address(ec_slave_config_t *sc, struct in_addr ip_address)
Sets the IP address for Ethernet-over-EtherCAT (EoE) operation.
int ecrt_slave_config_eoe_dns_address(ec_slave_config_t *sc, struct in_addr dns_address)
Sets the IPv4 address of the DNS server for Ethernet-over-EtherCAT (EoE) operation.
int ecrt_slave_config_eoe_hostname(ec_slave_config_t *sc, const char *name)
Sets the host name for Ethernet-over-EtherCAT (EoE) operation.
#define EC_END
End of list marker.
int ecrt_slave_config_pdo_mapping_clear(ec_slave_config_t *sc, uint16_t pdo_index)
Clear the mapping of a given PDO.
int ecrt_slave_config_sdo8(ec_slave_config_t *sc, uint16_t index, uint8_t subindex, uint8_t value)
Add a configuration value for an 8-bit SDO.
#define EC_MAX_SYNC_MANAGERS
Maximum number of sync managers per slave.
ec_reg_request_t * ecrt_slave_config_create_reg_request(ec_slave_config_t *sc, size_t size)
Create a register request to exchange EtherCAT register contents during realtime operation.
int ecrt_slave_config_sdo16(ec_slave_config_t *sc, uint16_t index, uint8_t subindex, uint16_t value)
Add a configuration value for a 16-bit SDO.
#define EC_WRITE_U16(DATA, VAL)
Write a 16-bit unsigned value to EtherCAT data.
int ecrt_slave_config_pdo_assign_add(ec_slave_config_t *sc, uint8_t sync_index, uint16_t pdo_index)
Add a PDO to a sync manager's PDO assignment.
#define EC_PDO_MODE_DEFAULT
Default PDO handling mode: read via CoE while scanning, and unconditionally (re-)write via CoE every ...
int ecrt_sdo_request_index(ec_sdo_request_t *req, uint16_t index, uint8_t subindex)
Set the SDO index and subindex.
int ecrt_slave_config_state_timeout(ec_slave_config_t *sc, ec_al_state_t from, ec_al_state_t to, unsigned int timeout_ms)
Sets the application-layer state transition timeout in ms.
int ecrt_slave_config_emerg_pop(ec_slave_config_t *sc, uint8_t *target)
Read and remove one record from the CoE emergency ring buffer.
int ecrt_slave_config_emerg_size(ec_slave_config_t *sc, size_t elements)
Set the size of the CoE emergency ring buffer.
@ EC_AL_STATE_OP
Operational.
@ EC_AL_STATE_PREOP
Pre-operational.
@ EC_AL_STATE_SAFEOP
Safe-operational.
@ EC_PDO_MODE_WRITE_IF_DIFFERENT
Read the current state via CoE while scanning the slave, and write it back only if it differs from th...
@ EC_DIR_INVALID
Invalid direction.
@ EC_DIR_INPUT
Values read by the master.
@ EC_DIR_OUTPUT
Values written by the master.
EtherCAT master character device IOCTL commands.
ec_slave_t * ec_master_find_slave(ec_master_t *master, uint16_t alias, uint16_t position)
Finds a slave in the bus, given the alias and position.
EtherCAT master structure.
int ec_pdo_copy_entries(ec_pdo_t *pdo, const ec_pdo_t *other)
Copy PDO entries from another PDO.
void ec_pdo_clear_entries(ec_pdo_t *pdo)
Clear PDO entry list.
ec_pdo_entry_t * ec_pdo_add_entry(ec_pdo_t *pdo, uint16_t index, uint8_t subindex, uint8_t bit_length)
Add a new PDO entry to the configuration.
int ec_pdo_set_name(ec_pdo_t *pdo, const char *name)
Set PDO name.
ec_pdo_t * ec_pdo_list_add_pdo(ec_pdo_list_t *pl, uint16_t index)
Add a new PDO to the list.
ec_pdo_t * ec_pdo_list_find_pdo(const ec_pdo_list_t *pl, uint16_t index)
Finds a PDO with the given index.
int ec_pdo_list_copy(ec_pdo_list_t *pl, const ec_pdo_list_t *other)
Makes a deep copy of another PDO list.
void ec_pdo_list_clear_pdos(ec_pdo_list_t *pl)
Clears the list of mapped PDOs.
void ec_reg_request_clear(ec_reg_request_t *reg)
Register request destructor.
int ec_reg_request_init(ec_reg_request_t *reg, size_t size)
Register request constructor.
void ec_sdo_request_init(ec_sdo_request_t *req)
SDO request constructor.
int ec_sdo_request_alloc(ec_sdo_request_t *req, size_t size)
Pre-allocates the data memory.
void ec_sdo_request_clear(ec_sdo_request_t *req)
SDO request destructor.
int ec_sdo_request_copy_data(ec_sdo_request_t *req, const uint8_t *source, size_t size)
Copies SDO data from an external source.
ec_sync_t * ec_slave_get_sync(ec_slave_t *slave, uint8_t sync_index)
Get the sync manager given an index.
#define EC_SLAVE_WARN(slave, fmt, args...)
Convenience macro for printing slave-specific warnings to syslog.
ec_voe_handler_t * ec_slave_config_find_voe_handler(ec_slave_config_t *sc, unsigned int pos)
Finds a VoE handler via its position in the list.
ec_sdo_request_t * ecrt_slave_config_create_sdo_request_err(ec_slave_config_t *sc, uint16_t index, uint8_t subindex, size_t size)
Same as ecrt_slave_config_create_sdo_request(), but with ERR_PTR() return value.
ec_soe_request_t * ec_slave_config_find_soe_request(ec_slave_config_t *sc, unsigned int pos)
Finds a SoE request via its position in the list.
void ec_slave_config_load_default_sync_config(ec_slave_config_t *sc)
Loads the default PDO assignment from the slave object.
const ec_sdo_request_t * ec_slave_config_get_sdo_by_pos_const(const ec_slave_config_t *sc, unsigned int pos)
Finds an SDO configuration via its position in the list.
ec_voe_handler_t * ecrt_slave_config_create_voe_handler_err(ec_slave_config_t *sc, size_t size)
Same as ecrt_slave_config_create_voe_handler(), but with ERR_PTR() return value.
int ec_slave_config_prepare_fmmu(ec_slave_config_t *, ec_domain_t *, uint8_t, ec_direction_t)
Prepares an FMMU configuration.
void ec_slave_config_clear(ec_slave_config_t *sc)
Slave configuration destructor.
unsigned int ec_slave_config_idn_count(const ec_slave_config_t *sc)
Get the number of IDN configurations.
const ec_flag_t * ec_slave_config_get_flag_by_pos_const(const ec_slave_config_t *sc, unsigned int pos)
Finds a flag via its position in the list.
void ec_slave_config_init(ec_slave_config_t *sc, ec_master_t *master, uint16_t alias, uint16_t position, uint32_t vendor_id, uint32_t product_code)
Slave configuration constructor.
ec_reg_request_t * ec_slave_config_find_reg_request(ec_slave_config_t *sc, unsigned int pos)
Finds a register handler via its position in the list.
ec_soe_request_t * ecrt_slave_config_create_soe_request_err(ec_slave_config_t *sc, uint8_t drive_no, uint16_t idn, size_t size)
Same as ecrt_slave_config_create_soe_request(), but with ERR_PTR() return value.
ec_sdo_request_t * ec_slave_config_find_sdo_request(ec_slave_config_t *sc, unsigned int pos)
Finds a CoE SDO request via its position in the list.
void ec_slave_config_load_default_mapping(const ec_slave_config_t *, ec_pdo_t *)
Loads the default mapping for a PDO from the slave object.
int ec_slave_config_attach(ec_slave_config_t *sc)
Attaches the configuration to the addressed slave object.
unsigned int ec_slave_config_sdo_count(const ec_slave_config_t *sc)
Get the number of SDO configurations.
ec_flag_t * ec_slave_config_find_flag(ec_slave_config_t *sc, const char *key)
Finds a flag.
unsigned int ec_slave_config_flag_count(const ec_slave_config_t *sc)
Get the number of feature flags.
unsigned int ec_slave_config_al_timeout(const ec_slave_config_t *sc, ec_slave_state_t from, ec_slave_state_t to)
Return an AL state timeout.
const ec_soe_request_t * ec_slave_config_get_idn_by_pos_const(const ec_slave_config_t *sc, unsigned int pos)
Finds an IDN configuration via its position in the list.
void ec_slave_config_detach(ec_slave_config_t *sc)
Detaches the configuration from a slave object.
ec_reg_request_t * ecrt_slave_config_create_reg_request_err(ec_slave_config_t *sc, size_t size)
Same as ecrt_slave_config_create_reg_request(), but with ERR_PTR() return value.
EtherCAT slave configuration structure.
#define EC_CONFIG_ERR(sc, fmt, args...)
Convenience macro for printing configuration-specific errors to syslog.
#define EC_CONFIG_WARN(sc, fmt, args...)
Convenience macro for printing configuration-specific warnings to syslog.
#define EC_CONFIG_DBG(sc, level, fmt, args...)
Convenience macro for printing configuration-specific debug messages to syslog.
void ec_soe_request_set_idn(ec_soe_request_t *req, uint16_t idn)
Set IDN.
void ec_soe_request_set_drive_no(ec_soe_request_t *req, uint8_t drive_no)
Set drive number.
int ec_soe_request_copy_data(ec_soe_request_t *req, const uint8_t *source, size_t size)
Copies SoE data from an external source.
void ec_soe_request_init(ec_soe_request_t *req)
SoE request constructor.
int ec_soe_request_alloc(ec_soe_request_t *req, size_t size)
Pre-allocates the data memory.
void ec_soe_request_clear(ec_soe_request_t *req)
SoE request destructor.
EtherCAT application-layer transition timeout.
Slave configutation feature flag.
char * key
Flag key (null-terminated ASCII string.
struct list_head list
List item.
int32_t value
Flag value (meaning depends on key).
uint32_t logical_start_address
Logical start address.
const ec_domain_t * domain
Domain.
uint8_t sync_index
Index of sync manager to use.
ec_reg_request_t * reg_request
Register request to process.
struct semaphore master_sem
Master semaphore.
unsigned int debug_level
Master debug level.
PDO entry configuration information.
uint8_t subindex
PDO entry subindex.
uint8_t bit_length
Size of the PDO entry in bit.
uint16_t index
PDO entry index.
uint8_t bit_length
entry length in bit
uint8_t subindex
PDO entry subindex.
uint16_t index
PDO entry index.
PDO configuration information.
unsigned int n_entries
Number of PDO entries in entries to map.
ec_pdo_entry_info_t const * entries
Array of PDO entries to map.
struct list_head list
List of PDOs.
struct list_head entries
List of PDO entries.
int8_t sync_index
Assigned sync manager.
struct list_head list
List item.
struct list_head list
List item.
uint8_t complete_access
SDO shall be transferred completely.
size_t data_size
Size of SDO data.
uint8_t * data
Pointer to SDO data.
ec_sync_t * syncs
SYNC MANAGER categories.
uint32_t product_code
Vendor-specific product code.
uint16_t mailbox_protocols
Supported mailbox protocols.
uint32_t vendor_id
Vendor ID.
unsigned int sync_count
Number of sync managers.
Slave configuration state.
unsigned int online
The slave is online.
unsigned int operational
The slave was brought into OP state using the specified configuration.
unsigned int al_state
The application-layer state of the slave.
ec_pdo_mode_t pdo_assign_mode
Whether/how to read resp.
uint32_t product_code
Slave product code.
ec_pdo_mode_t pdo_config_mode
Whether/how to read resp.
ec_sync_config_t sync_configs[EC_MAX_SYNC_MANAGERS]
Sync manager configurations.
struct list_head flags
List of feature flags.
struct list_head reg_requests
List of register requests.
uint16_t dc_assign_activate
Vendor-specific AssignActivate word.
struct list_head sdo_requests
List of SDO requests.
uint16_t watchdog_intervals
Process data watchdog intervals (see spec.
uint16_t alias
Slave alias.
ec_fmmu_config_t fmmu_configs[EC_MAX_FMMUS]
FMMU configurations.
ec_coe_emerg_ring_t emerg_ring
CoE emergency ring buffer.
ec_sync_signal_t dc_sync[EC_SYNC_SIGNAL_COUNT]
DC sync signals.
struct list_head soe_requests
List of SoE requests.
struct list_head soe_configs
List of SoE configurations.
struct list_head sdo_configs
List of SDO configurations.
uint16_t watchdog_divider
Watchdog divider as a number of 40ns intervals (see spec.
uint8_t used_fmmus
Number of FMMUs used.
ec_master_t * master
Master owning the slave configuration.
ec_slave_t * slave
Slave pointer.
struct list_head al_timeouts
List of specific AL state timeouts.
uint32_t vendor_id
Slave vendor ID.
uint16_t position
Index after alias.
ec_eoe_request_t eoe_ip_param_request
EoE IP parameters.
struct list_head voe_handlers
List of VoE handlers.
ec_sii_t sii
Extracted SII data.
unsigned int force_config
Force (re-)configuration.
uint16_t ring_position
Ring position.
ec_slave_config_t * config
Current configuration.
ec_slave_state_t current_state
Current application state.
ec_fsm_slave_t fsm
Slave state machine.
ec_al_state_t al_state
AL state (only valid for IDN config).
size_t data_size
Size of SDO data.
uint8_t * data
Pointer to SDO data.
struct list_head list
List item.
Sync manager configuration.
ec_direction_t dir
Sync manager direction.
ec_watchdog_mode_t watchdog_mode
Watchdog mode.
ec_pdo_list_t pdos
Current PDO assignment.
Sync manager configuration information.
unsigned int n_pdos
Number of PDOs in pdos.
ec_direction_t dir
Sync manager direction.
uint8_t index
Sync manager index.
ec_pdo_info_t const * pdos
Array with PDOs to assign.
ec_watchdog_mode_t watchdog_mode
Watchdog mode.
uint32_t cycle_time
Cycle time [ns].
int32_t shift_time
Shift time [ns].
ec_pdo_list_t pdos
Current PDO assignment.
struct list_head list
List item.
ec_direction_t ec_sync_default_direction(const ec_sync_t *sync)
Determines the default direction from the control register.
void ec_sync_config_clear(ec_sync_config_t *sync_config)
Destructor.
void ec_sync_config_init(ec_sync_config_t *sync_config)
Constructor.
void ec_voe_handler_clear(ec_voe_handler_t *voe)
VoE handler destructor.
int ec_voe_handler_init(ec_voe_handler_t *voe, ec_slave_config_t *sc, size_t size)
VoE handler constructor.
void ec_voe_handler_release_mbox_lock(ec_voe_handler_t *voe)
Releases the mailbox read lock, if the handler holds it.
Vendor specific over EtherCAT protocol handler.