IgH EtherCAT Master  1.5.3
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

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_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_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)
 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_running (const ec_fsm_slave_config_t *fsm)
 
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 50 of file fsm_slave_config.c.

Function Documentation

◆ 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 221 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 246 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 283 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 342 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 398 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 559 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 650 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 703 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 776 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 845 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 918 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 1027 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 1086 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 1185 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 976 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 1272 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 1342 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 1385 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 1486 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 1531 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 1599 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 1629 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 1695 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 1753 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 233 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 313 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 374 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 427 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 626 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 682 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 814 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 884 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 962 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 1002 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 1059 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 1117 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 1218 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 1304 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 1567 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 1616 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 1661 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 1739 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 1805 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 1795 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 1779 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 
)

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.

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 146 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 158 of file fsm_slave_config.c.

◆ 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 172 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 189 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 208 of file fsm_slave_config.c.