IgH EtherCAT Master  1.6.2
fsm_slave_config.c File Reference

EtherCAT slave configuration state machine. More...

Go to the source code of this file.

Macros

#define EC_DC_MAX_SYNC_DIFF_NS   10000
 Maximum clock difference (in ns) before going to SAFEOP. More...
 
#define EC_DC_SYNC_WAIT_MS   5000
 Maximum time (in ms) to wait for clock discipline.
 
#define EC_DC_START_OFFSET   100000000ULL
 Time offset (in ns), that is added to cyclic start time.
 

Functions

int ec_fsm_slave_config_running (const ec_fsm_slave_config_t *fsm)
 
void ec_fsm_slave_config_state_start (ec_fsm_slave_config_t *fsm)
 Slave configuration state: START. More...
 
void ec_fsm_slave_config_state_init (ec_fsm_slave_config_t *fsm)
 Slave configuration state: INIT. More...
 
void ec_fsm_slave_config_state_clear_fmmus (ec_fsm_slave_config_t *fsm)
 Slave configuration state: CLEAR FMMU. More...
 
void ec_fsm_slave_config_state_clear_sync (ec_fsm_slave_config_t *fsm)
 Slave configuration state: CLEAR SYNC. More...
 
void ec_fsm_slave_config_state_dc_clear_assign (ec_fsm_slave_config_t *fsm)
 Slave configuration state: CLEAR DC ASSIGN. More...
 
void ec_fsm_slave_config_state_mbox_sync (ec_fsm_slave_config_t *fsm)
 Slave configuration state: SYNC. More...
 
void ec_fsm_slave_config_state_assign_pdi (ec_fsm_slave_config_t *fsm)
 Slave configuration state: ASSIGN_PDI. More...
 
void ec_fsm_slave_config_state_boot_preop (ec_fsm_slave_config_t *fsm)
 Slave configuration state: BOOT/PREOP. More...
 
void ec_fsm_slave_config_state_assign_ethercat (ec_fsm_slave_config_t *fsm)
 Slave configuration state: ASSIGN_ETHERCAT. More...
 
void ec_fsm_slave_config_state_sdo_conf (ec_fsm_slave_config_t *fsm)
 Slave configuration state: SDO_CONF. More...
 
void ec_fsm_slave_config_state_soe_conf_preop (ec_fsm_slave_config_t *fsm)
 Slave configuration state: SOE_CONF. More...
 
void ec_fsm_slave_config_state_eoe_ip_param (ec_fsm_slave_config_t *fsm)
 Slave configuration state: EOE_IP_PARAM. More...
 
void ec_fsm_slave_config_state_watchdog_divider (ec_fsm_slave_config_t *fsm)
 Slave configuration state: WATCHDOG_DIVIDER. More...
 
void ec_fsm_slave_config_state_watchdog (ec_fsm_slave_config_t *fsm)
 Slave configuration state: WATCHDOG. More...
 
void ec_fsm_slave_config_state_pdo_sync (ec_fsm_slave_config_t *fsm)
 Configure PDO sync managers. More...
 
void ec_fsm_slave_config_state_pdo_conf (ec_fsm_slave_config_t *fsm)
 Slave configuration state: PDO_CONF. More...
 
void ec_fsm_slave_config_state_fmmu (ec_fsm_slave_config_t *fsm)
 Slave configuration state: FMMU. More...
 
void ec_fsm_slave_config_state_dc_cycle (ec_fsm_slave_config_t *fsm)
 Slave configuration state: DC CYCLE. More...
 
void ec_fsm_slave_config_state_dc_sync_check (ec_fsm_slave_config_t *fsm)
 Slave configuration state: DC SYNC CHECK. More...
 
void ec_fsm_slave_config_state_dc_start (ec_fsm_slave_config_t *fsm)
 Slave configuration state: DC START. More...
 
void ec_fsm_slave_config_state_dc_assign (ec_fsm_slave_config_t *fsm)
 Slave configuration state: DC ASSIGN. More...
 
void ec_fsm_slave_config_state_wait_safeop (ec_fsm_slave_config_t *fsm)
 Slave configuration state: WAIT SAFEOP. More...
 
void ec_fsm_slave_config_state_safeop (ec_fsm_slave_config_t *fsm)
 Slave configuration state: SAFEOP. More...
 
void ec_fsm_slave_config_state_soe_conf_safeop (ec_fsm_slave_config_t *fsm)
 Slave configuration state: SOE_CONF. More...
 
void ec_fsm_slave_config_state_op (ec_fsm_slave_config_t *fsm)
 Slave configuration state: OP. More...
 
void ec_fsm_slave_config_enter_init (ec_fsm_slave_config_t *fsm)
 Start state change to INIT. More...
 
void ec_fsm_slave_config_enter_clear_sync (ec_fsm_slave_config_t *fsm)
 Clear the sync manager configurations. More...
 
void ec_fsm_slave_config_enter_dc_clear_assign (ec_fsm_slave_config_t *fsm)
 Clear the DC assignment. More...
 
void ec_fsm_slave_config_enter_mbox_sync (ec_fsm_slave_config_t *fsm)
 Check for mailbox sync managers to be configured. More...
 
void ec_fsm_slave_config_enter_assign_pdi (ec_fsm_slave_config_t *fsm)
 Assign SII to PDI. More...
 
void ec_fsm_slave_config_enter_boot_preop (ec_fsm_slave_config_t *fsm)
 Request PREOP state. More...
 
void ec_fsm_slave_config_enter_sdo_conf (ec_fsm_slave_config_t *fsm)
 Check for SDO configurations to be applied. More...
 
void ec_fsm_slave_config_enter_soe_conf_preop (ec_fsm_slave_config_t *fsm)
 Check for SoE configurations to be applied. More...
 
void ec_fsm_slave_config_enter_eoe_ip_param (ec_fsm_slave_config_t *fsm)
 EOE_IP_PARAM entry function. More...
 
void ec_fsm_slave_config_enter_pdo_conf (ec_fsm_slave_config_t *fsm)
 PDO_CONF entry function. More...
 
void ec_fsm_slave_config_enter_watchdog_divider (ec_fsm_slave_config_t *fsm)
 WATCHDOG_DIVIDER entry function. More...
 
void ec_fsm_slave_config_enter_watchdog (ec_fsm_slave_config_t *fsm)
 WATCHDOG entry function. More...
 
void ec_fsm_slave_config_enter_pdo_sync (ec_fsm_slave_config_t *fsm)
 Check for PDO sync managers to be configured. More...
 
void ec_fsm_slave_config_enter_fmmu (ec_fsm_slave_config_t *fsm)
 Check for FMMUs to be configured. More...
 
void ec_fsm_slave_config_enter_dc_cycle (ec_fsm_slave_config_t *fsm)
 Check for DC to be configured. More...
 
void ec_fsm_slave_config_enter_wait_safeop (ec_fsm_slave_config_t *fsm)
 Wait before SAFEOP transition. More...
 
void ec_fsm_slave_config_enter_safeop (ec_fsm_slave_config_t *fsm)
 Request SAFEOP state. More...
 
void ec_fsm_slave_config_enter_soe_conf_safeop (ec_fsm_slave_config_t *fsm)
 Check for SoE configurations to be applied in SAFEOP. More...
 
void ec_fsm_slave_config_enter_op (ec_fsm_slave_config_t *fsm)
 Bring slave to OP. More...
 
void ec_fsm_slave_config_state_end (ec_fsm_slave_config_t *fsm)
 State: END. More...
 
void ec_fsm_slave_config_state_error (ec_fsm_slave_config_t *fsm)
 State: ERROR. More...
 
void ec_fsm_slave_config_reconfigure (ec_fsm_slave_config_t *fsm)
 Reconfigure the slave starting at INIT. More...
 
void ec_fsm_slave_config_init (ec_fsm_slave_config_t *fsm, ec_datagram_t *datagram, ec_fsm_change_t *fsm_change, ec_fsm_coe_t *fsm_coe, ec_fsm_soe_t *fsm_soe, ec_fsm_pdo_t *fsm_pdo, ec_fsm_eoe_t *fsm_eoe)
 Constructor. More...
 
void ec_fsm_slave_config_clear (ec_fsm_slave_config_t *fsm)
 Destructor. More...
 
void ec_fsm_slave_config_start (ec_fsm_slave_config_t *fsm, ec_slave_t *slave)
 Start slave configuration state machine. More...
 
int ec_fsm_slave_config_exec (ec_fsm_slave_config_t *fsm)
 Executes the current state of the state machine. More...
 
int ec_fsm_slave_config_success (const ec_fsm_slave_config_t *fsm)
 

Detailed Description

EtherCAT slave configuration state machine.

Definition in file fsm_slave_config.c.

Macro Definition Documentation

◆ EC_DC_MAX_SYNC_DIFF_NS

#define EC_DC_MAX_SYNC_DIFF_NS   10000

Maximum clock difference (in ns) before going to SAFEOP.

Wait for DC time difference to drop under this absolute value before requesting SAFEOP.

Definition at line 43 of file fsm_slave_config.c.

Function Documentation

◆ ec_fsm_slave_config_running()

int ec_fsm_slave_config_running ( const ec_fsm_slave_config_t fsm)
Returns
false, if state machine has terminated
Parameters
fsmslave state machine

Definition at line 174 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_state_start()

void ec_fsm_slave_config_state_start ( ec_fsm_slave_config_t fsm)

Slave configuration state: START.

Parameters
fsmslave state machine

Definition at line 223 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_state_init()

void ec_fsm_slave_config_state_init ( ec_fsm_slave_config_t fsm)

Slave configuration state: INIT.

Parameters
fsmslave state machine

Definition at line 248 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_state_clear_fmmus()

void ec_fsm_slave_config_state_clear_fmmus ( ec_fsm_slave_config_t fsm)

Slave configuration state: CLEAR FMMU.

Parameters
fsmslave state machine

Definition at line 285 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_state_clear_sync()

void ec_fsm_slave_config_state_clear_sync ( ec_fsm_slave_config_t fsm)

Slave configuration state: CLEAR SYNC.

Parameters
fsmslave state machine

Definition at line 344 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_state_dc_clear_assign()

void ec_fsm_slave_config_state_dc_clear_assign ( ec_fsm_slave_config_t fsm)

Slave configuration state: CLEAR DC ASSIGN.

Parameters
fsmslave state machine

Definition at line 400 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_state_mbox_sync()

void ec_fsm_slave_config_state_mbox_sync ( ec_fsm_slave_config_t fsm)

Slave configuration state: SYNC.

Todo:
Timeout for response.
Parameters
fsmslave state machine

Definition at line 561 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_state_assign_pdi()

void ec_fsm_slave_config_state_assign_pdi ( ec_fsm_slave_config_t fsm)

Slave configuration state: ASSIGN_PDI.

Parameters
fsmslave state machine

Definition at line 652 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_state_boot_preop()

void ec_fsm_slave_config_state_boot_preop ( ec_fsm_slave_config_t fsm)

Slave configuration state: BOOT/PREOP.

Parameters
fsmslave state machine

Definition at line 705 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_state_assign_ethercat()

void ec_fsm_slave_config_state_assign_ethercat ( ec_fsm_slave_config_t fsm)

Slave configuration state: ASSIGN_ETHERCAT.

Parameters
fsmslave state machine

Definition at line 778 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_state_sdo_conf()

void ec_fsm_slave_config_state_sdo_conf ( ec_fsm_slave_config_t fsm)

Slave configuration state: SDO_CONF.

Parameters
fsmslave state machine

Definition at line 847 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_state_soe_conf_preop()

void ec_fsm_slave_config_state_soe_conf_preop ( ec_fsm_slave_config_t fsm)

Slave configuration state: SOE_CONF.

Parameters
fsmslave state machine

Definition at line 920 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_state_eoe_ip_param()

void ec_fsm_slave_config_state_eoe_ip_param ( ec_fsm_slave_config_t fsm)

Slave configuration state: EOE_IP_PARAM.

Parameters
fsmslave state machine

Definition at line 990 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_state_watchdog_divider()

void ec_fsm_slave_config_state_watchdog_divider ( ec_fsm_slave_config_t fsm)

Slave configuration state: WATCHDOG_DIVIDER.

Parameters
fsmslave state machine

Definition at line 1080 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_state_watchdog()

void ec_fsm_slave_config_state_watchdog ( ec_fsm_slave_config_t fsm)

Slave configuration state: WATCHDOG.

Parameters
fsmslave state machine

Definition at line 1139 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_state_pdo_sync()

void ec_fsm_slave_config_state_pdo_sync ( ec_fsm_slave_config_t fsm)

Configure PDO sync managers.

Parameters
fsmslave state machine

Definition at line 1238 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_state_pdo_conf()

void ec_fsm_slave_config_state_pdo_conf ( ec_fsm_slave_config_t fsm)

Slave configuration state: PDO_CONF.

Parameters
fsmslave state machine

Definition at line 1029 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_state_fmmu()

void ec_fsm_slave_config_state_fmmu ( ec_fsm_slave_config_t fsm)

Slave configuration state: FMMU.

Parameters
fsmslave state machine

Definition at line 1325 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_state_dc_cycle()

void ec_fsm_slave_config_state_dc_cycle ( ec_fsm_slave_config_t fsm)

Slave configuration state: DC CYCLE.

Parameters
fsmslave state machine

Definition at line 1395 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_state_dc_sync_check()

void ec_fsm_slave_config_state_dc_sync_check ( ec_fsm_slave_config_t fsm)

Slave configuration state: DC SYNC CHECK.

Parameters
fsmslave state machine

Definition at line 1438 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_state_dc_start()

void ec_fsm_slave_config_state_dc_start ( ec_fsm_slave_config_t fsm)

Slave configuration state: DC START.

Parameters
fsmslave state machine

Definition at line 1539 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_state_dc_assign()

void ec_fsm_slave_config_state_dc_assign ( ec_fsm_slave_config_t fsm)

Slave configuration state: DC ASSIGN.

Parameters
fsmslave state machine

Definition at line 1584 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_state_wait_safeop()

void ec_fsm_slave_config_state_wait_safeop ( ec_fsm_slave_config_t fsm)

Slave configuration state: WAIT SAFEOP.

Parameters
fsmslave state machine

Definition at line 1652 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_state_safeop()

void ec_fsm_slave_config_state_safeop ( ec_fsm_slave_config_t fsm)

Slave configuration state: SAFEOP.

Parameters
fsmslave state machine

Definition at line 1682 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_state_soe_conf_safeop()

void ec_fsm_slave_config_state_soe_conf_safeop ( ec_fsm_slave_config_t fsm)

Slave configuration state: SOE_CONF.

Parameters
fsmslave state machine

Definition at line 1748 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_state_op()

void ec_fsm_slave_config_state_op ( ec_fsm_slave_config_t fsm)

Slave configuration state: OP.

Parameters
fsmslave state machine

Definition at line 1806 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_enter_init()

void ec_fsm_slave_config_enter_init ( ec_fsm_slave_config_t fsm)

Start state change to INIT.

Parameters
fsmslave state machine

Definition at line 235 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_enter_clear_sync()

void ec_fsm_slave_config_enter_clear_sync ( ec_fsm_slave_config_t fsm)

Clear the sync manager configurations.

Parameters
fsmslave state machine

Definition at line 315 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_enter_dc_clear_assign()

void ec_fsm_slave_config_enter_dc_clear_assign ( ec_fsm_slave_config_t fsm)

Clear the DC assignment.

Parameters
fsmslave state machine

Definition at line 376 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_enter_mbox_sync()

void ec_fsm_slave_config_enter_mbox_sync ( ec_fsm_slave_config_t fsm)

Check for mailbox sync managers to be configured.

Parameters
fsmslave state machine

Definition at line 429 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_enter_assign_pdi()

void ec_fsm_slave_config_enter_assign_pdi ( ec_fsm_slave_config_t fsm)

Assign SII to PDI.

Parameters
fsmslave state machine

Definition at line 628 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_enter_boot_preop()

void ec_fsm_slave_config_enter_boot_preop ( ec_fsm_slave_config_t fsm)

Request PREOP state.

Parameters
fsmslave state machine

Definition at line 684 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_enter_sdo_conf()

void ec_fsm_slave_config_enter_sdo_conf ( ec_fsm_slave_config_t fsm)

Check for SDO configurations to be applied.

Parameters
fsmslave state machine

Definition at line 816 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_enter_soe_conf_preop()

void ec_fsm_slave_config_enter_soe_conf_preop ( ec_fsm_slave_config_t fsm)

Check for SoE configurations to be applied.

Parameters
fsmslave state machine

Definition at line 886 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_enter_eoe_ip_param()

void ec_fsm_slave_config_enter_eoe_ip_param ( ec_fsm_slave_config_t fsm)

EOE_IP_PARAM entry function.

Parameters
fsmslave state machine

Definition at line 964 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_enter_pdo_conf()

void ec_fsm_slave_config_enter_pdo_conf ( ec_fsm_slave_config_t fsm)

PDO_CONF entry function.

Parameters
fsmslave state machine

Definition at line 1015 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_enter_watchdog_divider()

void ec_fsm_slave_config_enter_watchdog_divider ( ec_fsm_slave_config_t fsm)

WATCHDOG_DIVIDER entry function.

Parameters
fsmslave state machine

Definition at line 1055 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_enter_watchdog()

void ec_fsm_slave_config_enter_watchdog ( ec_fsm_slave_config_t fsm)

WATCHDOG entry function.

Parameters
fsmslave state machine

Definition at line 1112 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_enter_pdo_sync()

void ec_fsm_slave_config_enter_pdo_sync ( ec_fsm_slave_config_t fsm)

Check for PDO sync managers to be configured.

Parameters
fsmslave state machine

Definition at line 1170 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_enter_fmmu()

void ec_fsm_slave_config_enter_fmmu ( ec_fsm_slave_config_t fsm)

Check for FMMUs to be configured.

Parameters
fsmslave state machine

Definition at line 1271 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_enter_dc_cycle()

void ec_fsm_slave_config_enter_dc_cycle ( ec_fsm_slave_config_t fsm)

Check for DC to be configured.

Parameters
fsmslave state machine

Definition at line 1357 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_enter_wait_safeop()

void ec_fsm_slave_config_enter_wait_safeop ( ec_fsm_slave_config_t fsm)

Wait before SAFEOP transition.

The feature flag WaitBeforeSAFEOPms can be used to add a wait time before going to SAFEOP. This can be used as a workaround for slaves that need some extra time for initialisation.

Parameters
fsmslave state machine

Definition at line 1620 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_enter_safeop()

void ec_fsm_slave_config_enter_safeop ( ec_fsm_slave_config_t fsm)

Request SAFEOP state.

Parameters
fsmslave state machine

Definition at line 1669 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_enter_soe_conf_safeop()

void ec_fsm_slave_config_enter_soe_conf_safeop ( ec_fsm_slave_config_t fsm)

Check for SoE configurations to be applied in SAFEOP.

Parameters
fsmslave state machine

Definition at line 1714 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_enter_op()

void ec_fsm_slave_config_enter_op ( ec_fsm_slave_config_t fsm)

Bring slave to OP.

Parameters
fsmslave state machine

Definition at line 1792 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_state_end()

void ec_fsm_slave_config_state_end ( ec_fsm_slave_config_t fsm)

State: END.

Parameters
fsmslave state machine

Definition at line 1858 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_state_error()

void ec_fsm_slave_config_state_error ( ec_fsm_slave_config_t fsm)

State: ERROR.

Parameters
fsmslave state machine

Definition at line 1848 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_reconfigure()

void ec_fsm_slave_config_reconfigure ( ec_fsm_slave_config_t fsm)

Reconfigure the slave starting at INIT.

Parameters
fsmslave state machine

Definition at line 1832 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_init()

void ec_fsm_slave_config_init ( ec_fsm_slave_config_t fsm,
ec_datagram_t datagram,
ec_fsm_change_t fsm_change,
ec_fsm_coe_t fsm_coe,
ec_fsm_soe_t fsm_soe,
ec_fsm_pdo_t fsm_pdo,
ec_fsm_eoe_t fsm_eoe 
)

Constructor.

Parameters
fsmslave state machine
datagramdatagram structure to use
fsm_changeState change state machine to use.
fsm_coeCoE state machine to use.
fsm_soeSoE state machine to use.
fsm_pdoPDO configuration state machine to use.
fsm_eoeEoE state machine to use.

Definition at line 121 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_clear()

void ec_fsm_slave_config_clear ( ec_fsm_slave_config_t fsm)

Destructor.

Parameters
fsmslave state machine

Definition at line 148 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_start()

void ec_fsm_slave_config_start ( ec_fsm_slave_config_t fsm,
ec_slave_t slave 
)

Start slave configuration state machine.

Parameters
fsmslave state machine
slaveslave to configure

Definition at line 160 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_exec()

int ec_fsm_slave_config_exec ( ec_fsm_slave_config_t fsm)

Executes the current state of the state machine.

If the state machine's datagram is not sent or received yet, the execution of the state machine is delayed to the next cycle.

Returns
false, if state machine has terminated
Parameters
fsmslave state machine

Definition at line 191 of file fsm_slave_config.c.

◆ ec_fsm_slave_config_success()

int ec_fsm_slave_config_success ( const ec_fsm_slave_config_t fsm)
Returns
true, if the state machine terminated gracefully
Parameters
fsmslave state machine

Definition at line 210 of file fsm_slave_config.c.