IgH EtherCAT Master  1.5.3
fsm_master.c File Reference

EtherCAT master state machine. More...

Go to the source code of this file.

Macros

#define EC_SYSTEM_TIME_TOLERANCE_NS   1000000
 Time difference [ns] to tolerate without setting a new system time offset.
 

Functions

void ec_fsm_master_state_start (ec_fsm_master_t *fsm)
 Master state: START. More...
 
void ec_fsm_master_state_broadcast (ec_fsm_master_t *fsm)
 Master state: BROADCAST. More...
 
void ec_fsm_master_state_read_state (ec_fsm_master_t *fsm)
 Master state: READ STATE. More...
 
void ec_fsm_master_state_acknowledge (ec_fsm_master_t *fsm)
 Master state: ACKNOWLEDGE. More...
 
void ec_fsm_master_state_configure_slave (ec_fsm_master_t *fsm)
 Master state: CONFIGURE SLAVE. More...
 
void ec_fsm_master_state_clear_addresses (ec_fsm_master_t *fsm)
 Master state: CLEAR ADDRESSES. More...
 
void ec_fsm_master_state_dc_measure_delays (ec_fsm_master_t *fsm)
 Master state: DC MEASURE DELAYS. More...
 
void ec_fsm_master_state_scan_slave (ec_fsm_master_t *fsm)
 Master state: SCAN SLAVE. More...
 
void ec_fsm_master_state_dc_read_offset (ec_fsm_master_t *fsm)
 Master state: DC READ OFFSET. More...
 
void ec_fsm_master_state_dc_write_offset (ec_fsm_master_t *fsm)
 Master state: DC WRITE OFFSET. More...
 
void ec_fsm_master_state_assign_sii (ec_fsm_master_t *fsm)
 Master state: ASSIGN SII. More...
 
void ec_fsm_master_state_write_sii (ec_fsm_master_t *fsm)
 Master state: WRITE SII. More...
 
void ec_fsm_master_state_sdo_dictionary (ec_fsm_master_t *fsm)
 Master state: SDO DICTIONARY. More...
 
void ec_fsm_master_state_sdo_request (ec_fsm_master_t *fsm)
 Master state: SDO REQUEST. More...
 
void ec_fsm_master_state_soe_request (ec_fsm_master_t *fsm)
 Master state: SoE REQUEST. More...
 
void ec_fsm_master_enter_clear_addresses (ec_fsm_master_t *fsm)
 Start clearing slave addresses. More...
 
void ec_fsm_master_enter_write_system_times (ec_fsm_master_t *fsm)
 Start writing DC system times. More...
 
void ec_fsm_master_init (ec_fsm_master_t *fsm, ec_master_t *master, ec_datagram_t *datagram)
 Constructor. More...
 
void ec_fsm_master_clear (ec_fsm_master_t *fsm)
 Destructor. More...
 
void ec_fsm_master_reset (ec_fsm_master_t *fsm)
 Reset state machine. More...
 
int ec_fsm_master_exec (ec_fsm_master_t *fsm)
 Executes the current state of the state machine. More...
 
int ec_fsm_master_idle (const ec_fsm_master_t *fsm)
 
void ec_fsm_master_restart (ec_fsm_master_t *fsm)
 Restarts the master state machine. More...
 
int ec_fsm_master_action_process_sii (ec_fsm_master_t *fsm)
 Check for pending SII write requests and process one. More...
 
int ec_fsm_master_action_process_int_request (ec_fsm_master_t *fsm)
 Check for pending internal SDO/SoE requests and process one. More...
 
void ec_fsm_master_action_idle (ec_fsm_master_t *fsm)
 Master action: IDLE. More...
 
void ec_fsm_master_action_next_slave_state (ec_fsm_master_t *fsm)
 Master action: Get state of next slave. More...
 
void ec_fsm_master_action_configure (ec_fsm_master_t *fsm)
 Master action: Configure. More...
 
u64 ec_fsm_master_dc_offset32 (ec_fsm_master_t *fsm, u64 system_time, u64 old_offset, unsigned long jiffies_since_read)
 Configure 32 bit time offset. More...
 
u64 ec_fsm_master_dc_offset64 (ec_fsm_master_t *fsm, u64 system_time, u64 old_offset, unsigned long jiffies_since_read)
 Configure 64 bit time offset. More...
 

Detailed Description

EtherCAT master state machine.

Definition in file fsm_master.c.

Function Documentation

◆ ec_fsm_master_state_start()

void ec_fsm_master_state_start ( ec_fsm_master_t fsm)

Master state: START.

Starts with getting slave count and slave states.

Parameters
fsmMaster state machine.

Definition at line 207 of file fsm_master.c.

◆ ec_fsm_master_state_broadcast()

void ec_fsm_master_state_broadcast ( ec_fsm_master_t fsm)

Master state: BROADCAST.

Processes the broadcast read slave count and slaves states.

Parameters
fsmMaster state machine.

Definition at line 265 of file fsm_master.c.

◆ ec_fsm_master_state_read_state()

void ec_fsm_master_state_read_state ( ec_fsm_master_t fsm)

Master state: READ STATE.

Fetches the AL state of a slave.

Parameters
fsmMaster state machine.

Definition at line 735 of file fsm_master.c.

◆ ec_fsm_master_state_acknowledge()

void ec_fsm_master_state_acknowledge ( ec_fsm_master_t fsm)

Master state: ACKNOWLEDGE.

Parameters
fsmMaster state machine.

Definition at line 790 of file fsm_master.c.

◆ ec_fsm_master_state_configure_slave()

void ec_fsm_master_state_configure_slave ( ec_fsm_master_t fsm)

Master state: CONFIGURE SLAVE.

Starts configuring a slave.

Parameters
fsmMaster state machine.

Definition at line 997 of file fsm_master.c.

◆ ec_fsm_master_state_clear_addresses()

void ec_fsm_master_state_clear_addresses ( ec_fsm_master_t fsm)

Master state: CLEAR ADDRESSES.

Parameters
fsmMaster state machine.

Definition at line 828 of file fsm_master.c.

◆ ec_fsm_master_state_dc_measure_delays()

void ec_fsm_master_state_dc_measure_delays ( ec_fsm_master_t fsm)

Master state: DC MEASURE DELAYS.

Parameters
fsmMaster state machine.

Definition at line 872 of file fsm_master.c.

◆ ec_fsm_master_state_scan_slave()

void ec_fsm_master_state_scan_slave ( ec_fsm_master_t fsm)

Master state: SCAN SLAVE.

Executes the sub-statemachine for the scanning of a slave.

Parameters
fsmMaster state machine.

Definition at line 925 of file fsm_master.c.

◆ ec_fsm_master_state_dc_read_offset()

void ec_fsm_master_state_dc_read_offset ( ec_fsm_master_t fsm)

Master state: DC READ OFFSET.

Parameters
fsmMaster state machine.

Definition at line 1153 of file fsm_master.c.

◆ ec_fsm_master_state_dc_write_offset()

void ec_fsm_master_state_dc_write_offset ( ec_fsm_master_t fsm)

Master state: DC WRITE OFFSET.

Parameters
fsmMaster state machine.

Definition at line 1206 of file fsm_master.c.

◆ ec_fsm_master_state_assign_sii()

void ec_fsm_master_state_assign_sii ( ec_fsm_master_t fsm)

Master state: ASSIGN SII.

Parameters
fsmMaster state machine.

Definition at line 1241 of file fsm_master.c.

◆ ec_fsm_master_state_write_sii()

void ec_fsm_master_state_write_sii ( ec_fsm_master_t fsm)

Master state: WRITE SII.

Parameters
fsmMaster state machine.

Definition at line 1278 of file fsm_master.c.

◆ ec_fsm_master_state_sdo_dictionary()

void ec_fsm_master_state_sdo_dictionary ( ec_fsm_master_t fsm)

Master state: SDO DICTIONARY.

Parameters
fsmMaster state machine.

Definition at line 1332 of file fsm_master.c.

◆ ec_fsm_master_state_sdo_request()

void ec_fsm_master_state_sdo_request ( ec_fsm_master_t fsm)

Master state: SDO REQUEST.

Parameters
fsmMaster state machine.

Definition at line 1367 of file fsm_master.c.

◆ ec_fsm_master_state_soe_request()

void ec_fsm_master_state_soe_request ( ec_fsm_master_t fsm)

Master state: SoE REQUEST.

Parameters
fsmMaster state machine.

Definition at line 1410 of file fsm_master.c.

◆ ec_fsm_master_enter_clear_addresses()

void ec_fsm_master_enter_clear_addresses ( ec_fsm_master_t fsm)

Start clearing slave addresses.

Parameters
fsmMaster state machine.

Definition at line 812 of file fsm_master.c.

◆ ec_fsm_master_enter_write_system_times()

void ec_fsm_master_enter_write_system_times ( ec_fsm_master_t fsm)

Start writing DC system times.

Parameters
fsmMaster state machine.

Definition at line 1025 of file fsm_master.c.

◆ ec_fsm_master_init()

void ec_fsm_master_init ( ec_fsm_master_t fsm,
ec_master_t master,
ec_datagram_t datagram 
)

Constructor.

Parameters
fsmMaster state machine.
masterEtherCAT master.
datagramDatagram object to use.

Definition at line 76 of file fsm_master.c.

◆ ec_fsm_master_clear()

void ec_fsm_master_clear ( ec_fsm_master_t fsm)

Destructor.

Parameters
fsmMaster state machine.

Definition at line 113 of file fsm_master.c.

◆ ec_fsm_master_reset()

void ec_fsm_master_reset ( ec_fsm_master_t fsm)

Reset state machine.

Parameters
fsmMaster state machine.

Definition at line 131 of file fsm_master.c.

◆ ec_fsm_master_exec()

int ec_fsm_master_exec ( ec_fsm_master_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
true, if the state machine was executed
Parameters
fsmMaster state machine.

Definition at line 160 of file fsm_master.c.

◆ ec_fsm_master_idle()

int ec_fsm_master_idle ( const ec_fsm_master_t fsm)
Returns
true, if the state machine is in an idle phase
Parameters
fsmMaster state machine.

Definition at line 179 of file fsm_master.c.

◆ ec_fsm_master_restart()

void ec_fsm_master_restart ( ec_fsm_master_t fsm)

Restarts the master state machine.

Parameters
fsmMaster state machine.

Definition at line 190 of file fsm_master.c.

◆ ec_fsm_master_action_process_sii()

int ec_fsm_master_action_process_sii ( ec_fsm_master_t fsm)

Check for pending SII write requests and process one.

Returns
non-zero, if an SII write request is processed.
Parameters
fsmMaster state machine.

Definition at line 446 of file fsm_master.c.

◆ ec_fsm_master_action_process_int_request()

int ec_fsm_master_action_process_int_request ( ec_fsm_master_t fsm)

Check for pending internal SDO/SoE requests and process one.

Returns
non-zero, if an SDO request is processed.
Parameters
fsmMaster state machine.

Definition at line 508 of file fsm_master.c.

◆ ec_fsm_master_action_idle()

void ec_fsm_master_action_idle ( ec_fsm_master_t fsm)

Master action: IDLE.

Does secondary work.

Parameters
fsmMaster state machine.

Definition at line 591 of file fsm_master.c.

◆ ec_fsm_master_action_next_slave_state()

void ec_fsm_master_action_next_slave_state ( ec_fsm_master_t fsm)

Master action: Get state of next slave.

Parameters
fsmMaster state machine.

Definition at line 649 of file fsm_master.c.

◆ ec_fsm_master_action_configure()

void ec_fsm_master_action_configure ( ec_fsm_master_t fsm)

Master action: Configure.

Parameters
fsmMaster state machine.

Definition at line 677 of file fsm_master.c.

◆ ec_fsm_master_dc_offset32()

u64 ec_fsm_master_dc_offset32 ( ec_fsm_master_t fsm,
u64  system_time,
u64  old_offset,
unsigned long  jiffies_since_read 
)

Configure 32 bit time offset.

Returns
New offset.
Parameters
fsmMaster state machine.
system_timeSystem time register.
old_offsetTime offset register.
jiffies_since_readJiffies for correction.

Definition at line 1073 of file fsm_master.c.

◆ ec_fsm_master_dc_offset64()

u64 ec_fsm_master_dc_offset64 ( ec_fsm_master_t fsm,
u64  system_time,
u64  old_offset,
unsigned long  jiffies_since_read 
)

Configure 64 bit time offset.

Returns
New offset.
Parameters
fsmMaster state machine.
system_timeSystem time register.
old_offsetTime offset register.
jiffies_since_readJiffies for correction.

Definition at line 1115 of file fsm_master.c.