Skip to content

Commit

Permalink
feat: Support the configuration of slaves to use only dc sync1
Browse files Browse the repository at this point in the history
  • Loading branch information
marcfir committed Sep 13, 2024
1 parent 9108db1 commit d972a9e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/libethercat/slave.h
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ void ec_slave_add_init_cmd(ec_t *pec, osal_uint16_t slave, ec_init_cmd_t *cmd);
* the physical order of the ethercat slaves
* (usually the n'th slave attached).
* \param[in] use_dc Whether to en-/disable dc on slave.
* \param[in] type DC type, 0 = sync0, 1 = sync01.
* \param[in] type DC type, 0 = sync0, 1 = sync01, 2 = sync1.
* \param[in] cycle_time_0 Cycle time of sync 0 [ns].
* \param[in] cycle_time_1 Cycle time of sync 1 [ns].
* \param[in] cycle_shift Cycle shift time [ns].
Expand Down
10 changes: 9 additions & 1 deletion src/slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -1051,8 +1051,16 @@ int ec_slave_state_transition(ec_t *pec, osal_uint16_t slave, ec_state_t state)
if (slv->dc.cycle_time_0 == 0u) {
slv->dc.cycle_time_0 = pec->main_cycle_interval;
}
if (slv->dc.type == 2) {
ec_log(10, get_transition_string(transition),
"slave %2d: configuring dc sync 1, "
"cycle_times %d/%d, cycle_shift %d\n",
slave, slv->dc.cycle_time_0,
slv->dc.cycle_time_1, slv->dc.cycle_shift);

if (slv->dc.type == 1) {
ec_dc_sync(pec, slave, 5, slv->dc.cycle_time_0,
slv->dc.cycle_time_1, slv->dc.cycle_shift);
} else if (slv->dc.type == 1) {
if (slv->dc.cycle_time_1 == 0u) {
slv->dc.cycle_time_1 = pec->main_cycle_interval;
}
Expand Down

0 comments on commit d972a9e

Please sign in to comment.