41 const struct list_head *);
108 printk(KERN_CONT
"Currently assigned PDOs: ");
110 printk(KERN_CONT
". PDOs to assign: ");
112 printk(KERN_CONT
"\n");
169 fsm->
state(fsm, datagram);
220 EC_SLAVE_DBG(slave, 1,
"Reading PDO assignment of SM%u.\n",
233 EC_SLAVE_DBG(slave, 1,
"Reading of PDO configuration finished.\n");
318 " assigned PDO %u from SM%u.\n",
333 kmalloc(
sizeof(
ec_pdo_t), GFP_KERNEL))) {
349 fsm->
state(fsm, datagram);
367 " for PDO 0x%04X.\n", fsm->
pdo->
index);
405 const struct list_head *list
411 return list_entry(list,
ec_pdo_t, list);
442 " but slave does not provide the" 443 " sync manager information!\n",
490 fsm->
state(fsm, datagram);
513 "Failed to read PDO entries for PDO 0x%04X.\n",
540 fsm->
state(fsm, datagram);
545 " changing the PDO mapping!\n");
547 printk(KERN_CONT
"Currently mapped PDO entries: ");
549 printk(KERN_CONT
". Entries to map: ");
551 printk(KERN_CONT
"\n");
572 "Failed to configure mapping of PDO 0x%04X.\n",
737 "Setting number of assigned PDOs to %u.\n",
766 " assigned PDOs of SM%u.\n", fsm->
sync_index);
776 " PDO assignment of SM%u.\n", fsm->
sync_index);
void(* state)(ec_fsm_pdo_t *, ec_datagram_t *)
State function.
void ec_fsm_pdo_conf_state_assign_pdo(ec_fsm_pdo_t *, ec_datagram_t *)
Add a PDO to the sync managers PDO assignment.
void ec_fsm_pdo_read_action_next_pdo(ec_fsm_pdo_t *, ec_datagram_t *)
Read next PDO.
ec_sii_t sii
Extracted SII data.
int ec_fsm_pdo_exec(ec_fsm_pdo_t *fsm, ec_datagram_t *datagram)
Executes the current state of the state machine.
ec_sdo_request_t request
SDO request.
int ecrt_sdo_request_write(ec_sdo_request_t *req)
Schedule an SDO write operation.
void ec_fsm_pdo_conf_state_read_mapping(ec_fsm_pdo_t *, ec_datagram_t *)
Execute the PDO entry state machine to read the current PDO's mapping.
void ec_fsm_pdo_conf_action_next_sync(ec_fsm_pdo_t *, ec_datagram_t *)
Get the next sync manager for a pdo configuration.
#define EC_SLAVE_DBG(slave, level, fmt, args...)
Convenience macro for printing slave-specific debug messages to syslog.
void ec_fsm_pdo_start_configuration(ec_fsm_pdo_t *fsm, ec_slave_t *slave)
Start writing the PDO configuration.
void ec_fsm_pdo_read_state_start(ec_fsm_pdo_t *, ec_datagram_t *)
Start reading PDO assignment.
void ec_pdo_list_print(const ec_pdo_list_t *pl)
Outputs the PDOs in the list.
void ec_fsm_pdo_conf_state_set_pdo_count(ec_fsm_pdo_t *, ec_datagram_t *)
Set the number of assigned PDOs.
int ec_pdo_list_copy(ec_pdo_list_t *pl, const ec_pdo_list_t *other)
Makes a deep copy of another PDO list.
ec_slave_t * slave
Slave the FSM runs on.
#define EC_SLAVE_WARN(slave, fmt, args...)
Convenience macro for printing slave-specific warnings to syslog.
int ecrt_sdo_request_read(ec_sdo_request_t *req)
Schedule an SDO read operation.
ec_pdo_t * pdo
Current PDO.
void ec_pdo_list_clear(ec_pdo_list_t *pl)
PDO list destructor.
struct list_head list
List of PDOs.
EtherCAT PDO configuration state machine structures.
ec_sii_coe_details_t coe_details
CoE detail flags.
#define EC_WRITE_U8(DATA, VAL)
Write an 8-bit unsigned value to EtherCAT data.
void ec_pdo_list_clear_pdos(ec_pdo_list_t *pl)
Clears the list of mapped PDOs.
void ec_fsm_pdo_entry_start_reading(ec_fsm_pdo_entry_t *fsm, ec_slave_t *slave, ec_pdo_t *pdo)
Start reading a PDO's entries.
void ec_pdo_clear_entries(ec_pdo_t *pdo)
Clear PDO entry list.
void ec_pdo_init(ec_pdo_t *pdo)
PDO constructor.
const ec_pdo_t * ec_slave_find_pdo(const ec_slave_t *slave, uint16_t index)
Finds a mapped PDO.
uint8_t * data
Pointer to SDO data.
int ec_fsm_coe_success(const ec_fsm_coe_t *fsm)
Returns, if the state machine terminated with success.
void ec_fsm_pdo_conf_state_start(ec_fsm_pdo_t *, ec_datagram_t *)
Start PDO configuration.
ec_fsm_coe_t * fsm_coe
CoE state machine to use.
void ec_fsm_pdo_entry_start_configuration(ec_fsm_pdo_entry_t *fsm, ec_slave_t *slave, const ec_pdo_t *pdo, const ec_pdo_t *cur_pdo)
Start PDO mapping state machine.
int ec_fsm_pdo_running(const ec_fsm_pdo_t *)
Get running state.
Global definitions and macros.
void ec_fsm_pdo_conf_state_mapping(ec_fsm_pdo_t *, ec_datagram_t *)
Let the PDO entry state machine configure the current PDO's mapping.
void ec_fsm_pdo_state_end(ec_fsm_pdo_t *, ec_datagram_t *)
State: END.
void ec_fsm_pdo_clear(ec_fsm_pdo_t *fsm)
Destructor.
EtherCAT master structure.
void ec_fsm_pdo_conf_action_pdo_mapping(ec_fsm_pdo_t *, ec_datagram_t *)
Check if the mapping has to be read, otherwise start to configure it.
void ec_pdo_clear(ec_pdo_t *pdo)
PDO destructor.
int8_t sync_index
Assigned sync manager.
void ec_fsm_pdo_print(const ec_fsm_pdo_t *)
Print the current and desired PDO assignment.
void ec_fsm_pdo_state_error(ec_fsm_pdo_t *, ec_datagram_t *)
State: ERROR.
void ec_sdo_request_clear(ec_sdo_request_t *req)
SDO request destructor.
int ecrt_sdo_request_index(ec_sdo_request_t *req, uint16_t index, uint8_t subindex)
Set the SDO index and subindex.
ec_sync_config_t sync_configs[EC_MAX_SYNC_MANAGERS]
Sync manager configurations.
ec_slave_config_t * config
Current configuration.
uint16_t mailbox_protocols
Supported mailbox protocols.
void ec_fsm_pdo_start_reading(ec_fsm_pdo_t *fsm, ec_slave_t *slave)
Start reading the PDO configuration.
int ec_fsm_pdo_entry_success(const ec_fsm_pdo_entry_t *fsm)
Get execution result.
unsigned int debug_level
Master debug level.
#define EC_SLAVE_ERR(slave, fmt, args...)
Convenience macro for printing slave-specific errors to syslog.
ec_pdo_list_t pdos
Current PDO assignment.
void ec_fsm_pdo_init(ec_fsm_pdo_t *fsm, ec_fsm_coe_t *fsm_coe)
Constructor.
int ec_fsm_pdo_entry_exec(ec_fsm_pdo_entry_t *fsm, ec_datagram_t *datagram)
Executes the current state.
int ec_pdo_equal_entries(const ec_pdo_t *pdo1, const ec_pdo_t *pdo2)
Compares the entries of two PDOs.
#define EC_WRITE_U16(DATA, VAL)
Write a 16-bit unsigned value to EtherCAT data.
struct list_head entries
List of PDO entries.
void ec_fsm_pdo_read_state_pdo_count(ec_fsm_pdo_t *, ec_datagram_t *)
Count assigned PDOs.
ec_pdo_t * ec_fsm_pdo_conf_action_next_pdo(const ec_fsm_pdo_t *, const struct list_head *)
Assign next PDO.
ec_master_t * master
Master owning the slave.
void ec_fsm_pdo_conf_action_next_pdo_mapping(ec_fsm_pdo_t *, ec_datagram_t *)
Check mapping of next PDO, otherwise configure assignment.
uint8_t sync_index
Current sync manager index.
void ec_fsm_pdo_conf_action_check_mapping(ec_fsm_pdo_t *, ec_datagram_t *)
Check if the mapping has to be re-configured.
void ec_fsm_pdo_read_action_next_sync(ec_fsm_pdo_t *, ec_datagram_t *)
Read PDO assignment of next sync manager.
PDO configuration state machine.
uint8_t subindex
SDO subindex.
int ec_fsm_pdo_success(const ec_fsm_pdo_t *fsm)
Get execution result.
int ec_pdo_copy_entries(ec_pdo_t *pdo, const ec_pdo_t *other)
Copy PDO entries from another PDO.
void ec_fsm_pdo_entry_init(ec_fsm_pdo_entry_t *fsm, ec_fsm_coe_t *fsm_coe)
Constructor.
size_t data_size
Size of SDO data.
#define EC_READ_U16(DATA)
Read a 16-bit unsigned value from EtherCAT data.
void ec_sdo_request_init(ec_sdo_request_t *req)
SDO request constructor.
ec_sync_t * sync
Current sync manager.
int ec_fsm_coe_exec(ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
Executes the current state of the state machine.
unsigned int pdo_count
Number of assigned PDOs.
ec_pdo_list_t pdos
Current PDO assignment.
void ec_pdo_list_init(ec_pdo_list_t *pl)
PDO list constructor.
void ec_fsm_pdo_read_state_pdo(ec_fsm_pdo_t *, ec_datagram_t *)
Fetch PDO information.
void ec_pdo_print_entries(const ec_pdo_t *pdo)
Outputs the PDOs in the list.
void ec_fsm_pdo_conf_action_check_assignment(ec_fsm_pdo_t *, ec_datagram_t *)
Check if the PDO assignment of the current SM has to be re-configured.
#define EC_READ_U8(DATA)
Read an 8-bit unsigned value from EtherCAT data.
void ec_fsm_pdo_conf_action_assign_pdo(ec_fsm_pdo_t *, ec_datagram_t *)
Assign a PDO.
EtherCAT slave configuration structure.
void ec_fsm_pdo_entry_clear(ec_fsm_pdo_entry_t *fsm)
Destructor.
void ec_fsm_coe_transfer(ec_fsm_coe_t *fsm, ec_slave_t *slave, ec_sdo_request_t *request)
Starts to transfer an SDO to/from a slave.
int ec_sdo_request_alloc(ec_sdo_request_t *req, size_t size)
Pre-allocates the data memory.
int ec_pdo_list_equal(const ec_pdo_list_t *pl1, const ec_pdo_list_t *pl2)
Compares two PDO lists.
ec_fsm_pdo_entry_t fsm_pdo_entry
PDO entry state machine.
struct list_head list
List item.
uint8_t enable_pdo_configuration
PDO configuration possible.
void ec_fsm_pdo_conf_state_zero_pdo_count(ec_fsm_pdo_t *, ec_datagram_t *)
Set the number of assigned PDOs to zero.
#define EC_MAX_SYNC_MANAGERS
Maximum number of sync managers per slave.
ec_pdo_list_t pdos
PDO configuration.
void ec_fsm_pdo_read_state_pdo_entries(ec_fsm_pdo_t *, ec_datagram_t *)
Fetch PDO information.
unsigned int pdo_pos
Assignment position of current PDOs.
unsigned int has_general
General category present.
ec_pdo_t slave_pdo
PDO actually appearing in a slave.
Finite state machines for the CANopen over EtherCAT protocol.
ec_sync_t * ec_slave_get_sync(ec_slave_t *slave, uint8_t sync_index)
Get the sync manager given an index.
uint8_t enable_pdo_assign
PDO mapping configurable.