libethercat - an embeddable realtime EtherCAT-master library
Communicate with EtherCAT slaves attached to a Network interface.
|
Data Structures | |
struct | ec_slave_sm |
slave sync manager settings More... | |
struct | ec_slave_fmmu |
slave fielbus memory management unit (fmmu) settings More... | |
struct | ec_slave_subdev |
EtherCAT sub device. More... | |
struct | ec_init_cmd |
slave mailbox init commands More... | |
struct | worker_arg |
struct | ec_slave |
Macros | |
#define | BOOT_2_BOOT 0x0303u |
EtherCAT slave state transitions. | |
#define | BOOT_2_INIT 0x0301u |
BOOT to INIT state transition. | |
#define | BOOT_2_PREOP 0x0302u |
BOOT to PREOP state transition,. | |
#define | BOOT_2_SAFEOP 0x0304u |
BOOT to SAFEOP state transition,. | |
#define | BOOT_2_OP 0x0308u |
BOOT to OP state transition,. | |
#define | UNKNOWN_2_BOOT 0x0003u |
UNKNOWN to BOOT state transition. | |
#define | UNKNOWN_2_INIT 0x0001u |
UNKNOWN to INIT state transition,. | |
#define | UNKNOWN_2_PREOP 0x0002u |
UNKNOWN to PREOP state transition,. | |
#define | UNKNOWN_2_SAFEOP 0x0004u |
UNKNOWN to SAFEOP state transition,. | |
#define | UNKNOWN_2_OP 0x0008u |
UNKNOWN to OP state transition,. | |
#define | INIT_2_BOOT 0x0103u |
INIT to BOOT state transition. | |
#define | INIT_2_INIT 0x0101u |
INIT to INIT state transition,. | |
#define | INIT_2_PREOP 0x0102u |
INIT to PREOP state transition,. | |
#define | INIT_2_SAFEOP 0x0104u |
INIT to SAFEOP state transition,. | |
#define | INIT_2_OP 0x0108u |
INIT to OP state transition,. | |
#define | PREOP_2_BOOT 0x0203u |
PREOP to BOOT state transition,. | |
#define | PREOP_2_INIT 0x0201u |
PREOP to INIT state transition,. | |
#define | PREOP_2_PREOP 0x0202u |
PREOP to PREOP state transition,. | |
#define | PREOP_2_SAFEOP 0x0204u |
PREOP to SAFEOP state transition,. | |
#define | PREOP_2_OP 0x0208u |
PREOP to OP state transition,. | |
#define | SAFEOP_2_BOOT 0x0403u |
SAFEOP to BOOT state transition,. | |
#define | SAFEOP_2_INIT 0x0401u |
SAFEOP to INIT state transition,. | |
#define | SAFEOP_2_PREOP 0x0402u |
SAFEOP to PREOP state transition,. | |
#define | SAFEOP_2_SAFEOP 0x0404u |
SAFEOP to SAFEOP state transition,. | |
#define | SAFEOP_2_OP 0x0408u |
SAFEOP to OP state transition,. | |
#define | OP_2_BOOT 0x0803u |
OP to BOOT state transition,. | |
#define | OP_2_INIT 0x0801u |
OP to INIT state transition,. | |
#define | OP_2_PREOP 0x0802u |
OP to PREOP state transition,. | |
#define | OP_2_SAFEOP 0x0804u |
OP to SAFEOP state transition,. | |
#define | OP_2_OP 0x0808u |
OP to OP state transition,. | |
#define | INIT_CMD_SIZE (sizeof(ec_init_cmd_t)) |
#define | ec_slave_ptr(ptr, pec, slave) |
Typedefs | |
typedef osal_uint16_t | ec_state_transition_t |
typedef struct PACKED ec_slave_sm | ec_slave_sm_t |
slave sync manager settings | |
typedef struct PACKED ec_slave_fmmu | ec_slave_fmmu_t |
slave fielbus memory management unit (fmmu) settings | |
typedef struct ec_slave_subdev | ec_slave_subdev_t |
EtherCAT sub device. | |
typedef struct ec_init_cmd | ec_init_cmd_t |
slave mailbox init commands | |
typedef struct worker_arg | worker_arg_t |
Worker thread argument structure. | |
typedef struct ec_slave | ec_slave_t |
Functions | |
LIST_HEAD (ec_init_cmds, ec_init_cmd) | |
void | ec_slave_init (struct ec *pec, osal_uint16_t slave) |
void | ec_slave_free (struct ec *pec, osal_uint16_t slave) |
void | ec_slave_reset (ec_t *pec, osal_uint16_t slave) |
issue hardware reset of slave | |
int | ec_slave_set_state (struct ec *pec, osal_uint16_t slave, ec_state_t state) |
Set EtherCAT state on slave. | |
int | ec_slave_get_state (struct ec *pec, osal_uint16_t slave, ec_state_t *state, osal_uint16_t *alstatcode) |
Get EtherCAT state from slave. | |
int | ec_slave_generate_mapping (struct ec *pec, osal_uint16_t slave) |
Generate process data mapping. | |
int | ec_slave_prepare_state_transition (struct ec *pec, osal_uint16_t slave, ec_state_t state) |
Prepare state transition on EtherCAT slave. | |
int | ec_slave_state_transition (struct ec *pec, osal_uint16_t slave, ec_state_t state) |
Execute state transition on EtherCAT slave. | |
void | ec_slave_mailbox_coe_init_cmd_init (ec_init_cmd_t *cmd, int transition, int id, int si_el, int ca_atn, osal_char_t *data, osal_size_t datalen) |
Initialize CoE init command. | |
void | ec_slave_add_init_cmd (ec_t *pec, osal_uint16_t slave, ec_init_cmd_t *cmd) |
Add master init command. | |
void | ec_slave_set_dc_config (struct ec *pec, osal_uint16_t slave, int use_dc, int type, osal_uint32_t cycle_time_0, osal_uint32_t cycle_time_1, osal_int32_t cycle_shift) |
Set Distributed Clocks config to slave. | |
const osal_char_t * | al_status_code_2_string (int code) |
This modules contains main EtherCAT slave functions.
#define BOOT_2_BOOT 0x0303u |
EtherCAT slave state transitions.
BOOT to BOOT state transition
#define ec_slave_ptr | ( | ptr, | |
pec, | |||
slave | |||
) |
void ec_slave_add_init_cmd | ( | ec_t * | pec, |
osal_uint16_t | slave, | ||
ec_init_cmd_t * | cmd | ||
) |
Add master init command.
This adds an EtherCAT slave init command.
[in] | pec | Pointer to ethercat master structure, which you got from ec_open. |
[in] | slave | Number of ethercat slave. this depends on the physical order of the ethercat slaves (usually the n'th slave attached). |
[in] | cmd | Init command to add. |
void ec_slave_free | ( | struct ec * | pec, |
osal_uint16_t | slave | ||
) |
[in] | pec | Pointer to ethercat master structure, which you got from ec_open. |
[in] | slave | Number of ethercat slave. this depends on the physical order of the ethercat slaves (usually the n'th slave attached). |
int ec_slave_generate_mapping | ( | struct ec * | pec, |
osal_uint16_t | slave | ||
) |
Generate process data mapping.
This tries to generate a mapping for the process data and figures out the settings for the sync managers. Therefor it either tries to use an available mailbox protocol or the information stored in the EEPROM.
[in] | pec | Pointer to ethercat master structure, which you got from ec_open. |
[in] | slave | Number of ethercat slave. this depends on the physical order of the ethercat slaves (usually the n'th slave attached). |
int ec_slave_get_state | ( | struct ec * | pec, |
osal_uint16_t | slave, | ||
ec_state_t * | state, | ||
osal_uint16_t * | alstatcode | ||
) |
Get EtherCAT state from slave.
This call tries to read the EtherCAT slave state. If successfull a working counter of 1 will be returned.
[in] | pec | Pointer to ethercat master structure, which you got from ec_open. |
[in] | slave | Number of ethercat slave. this depends on the physical order of the ethercat slaves (usually the n'th slave attached). |
[out] | state | Returns current EtherCAT state. |
[out] | alstatcode | Return current AL StatusCode of specified EtherCAT slave. (maybe NULL if you are not interested in) |
void ec_slave_init | ( | struct ec * | pec, |
osal_uint16_t | slave | ||
) |
[in] | pec | Pointer to ethercat master structure, which you got from ec_open. |
[in] | slave | Number of ethercat slave. this depends on the physical order of the ethercat slaves (usually the n'th slave attached). |
void ec_slave_mailbox_coe_init_cmd_init | ( | ec_init_cmd_t * | cmd, |
int | transition, | ||
int | id, | ||
int | si_el, | ||
int | ca_atn, | ||
osal_char_t * | data, | ||
osal_size_t | datalen | ||
) |
Initialize CoE init command.
This adds an EtherCAT slave init command.
[in] | cmd | Init command to add. |
[in] | transition | EtherCAT state transition in form 0xab, where 'a' is the state we are coming from and 'b' is the state we want to get. |
[in] | id | Either CoE Index number or the ServoDrive IDN. |
[in] | si_el | Either CoE SubIndex or ServoDrive element number. |
[in] | ca_atn | Either CoE complete access or ServoDrive ATN. |
[in] | data | Pointer to memory buffer with data which should be transfered. |
[in] | datalen | Length of data |
int ec_slave_prepare_state_transition | ( | struct ec * | pec, |
osal_uint16_t | slave, | ||
ec_state_t | state | ||
) |
Prepare state transition on EtherCAT slave.
While prepare a state transition the master sends the init commands to the slaves. These are usually settings for the process data mapping (e.g. PDOs, ...) or some slave specific settings.
[in] | pec | Pointer to ethercat master structure, which you got from ec_open. |
[in] | slave | Number of ethercat slave. this depends on the physical order of the ethercat slaves (usually the n'th slave attached). |
[in] | state | Prepare the EtherCAT slave for a switch to the specified EtherCAT state. |
void ec_slave_reset | ( | ec_t * | pec, |
osal_uint16_t | slave | ||
) |
issue hardware reset of slave
[in] | pec | Pointer to ethercat master structure, which you got from ec_open. |
[in] | slave | Number of ethercat slave. this depends on the physical order of the ethercat slaves (usually the n'th slave attached). |
void ec_slave_set_dc_config | ( | struct ec * | pec, |
osal_uint16_t | slave, | ||
int | use_dc, | ||
int | type, | ||
osal_uint32_t | cycle_time_0, | ||
osal_uint32_t | cycle_time_1, | ||
osal_int32_t | cycle_shift | ||
) |
Set Distributed Clocks config to slave.
[in] | pec | Pointer to ethercat master structure, which you got from ec_open. |
[in] | slave | Number of ethercat slave. this depends on the physical order of the ethercat slaves (usually the n'th slave attached). |
[in] | use_dc | Whether to en-/disable dc on slave. |
[in] | activation_reg | DC Sync Activation Register (0x981). Sets the type of DC sync:
|
[in] | cycle_time_0 | Cycle time of sync 0 [ns]. |
[in] | cycle_time_1 | Cycle time of sync 1 [ns]. |
[in] | cycle_shift | Cycle shift time [ns]. |
int ec_slave_set_state | ( | struct ec * | pec, |
osal_uint16_t | slave, | ||
ec_state_t | state | ||
) |
Set EtherCAT state on slave.
This call tries to set the EtherCAT slave to the requested state. If successfull a working counter of 1 will be returned.
[in] | pec | Pointer to ethercat master structure, which you got from ec_open. |
[in] | slave | Number of ethercat slave. this depends on the physical order of the ethercat slaves (usually the n'th slave attached). |
[in] | state | New EtherCAT state which will be set on specified slave. |
int ec_slave_state_transition | ( | struct ec * | pec, |
osal_uint16_t | slave, | ||
ec_state_t | state | ||
) |
Execute state transition on EtherCAT slave.
This actually performs the state transition.
[in] | pec | Pointer to ethercat master structure, which you got from ec_open. |
[in] | slave | Number of ethercat slave. this depends on the physical order of the ethercat slaves (usually the n'th slave attached). |
[in] | state | Switch the EtherCAT slave to the specified EtherCAT state. |