从站配置方法较多,仅摘取在PDO配置方面的函数以供参考。
/**01 Configure a sync manager.
*配置同步管理器
* Sets the direction of a sync manager. This overrides the direction bits
* from the default control register from SII.
* 设置同步管理器的方向。这将覆盖来自sIl的默认控制寄存器的方向位。
* This method has to be called in non-realtime context before
* ecrt_master_activate().
*这个方法必须在非实时环境中在ecrt master activate()之前被调用。,
* \return zero on success, else non-zero
*/
int ecrt_slave_config_sync_manager(
ec_slave_config_t *sc, /**< Slave configuration. */
uint8_t sync_index, /**< Sync manager index. Must be less
than #EC_MAX_SYNC_MANAGERS. */
ec_direction_t direction, /**< Input/Output. */
ec_watchdog_mode_t watchdog_mode /** Watchdog mode. */
);
/**08 Registers a PDO entry for process data exchange in a domain.
*"为域中的进程数据交换注册一个PDo条目。
* Searches the assigned PDOs for the given PDO entry. An error is raised, if
* the given entry is not mapped. Otherwise, the corresponding sync manager
* and FMMU configurations are provided for slave configuration and the
* respective sync manager's assigned PDOs are appended to the given domain,
* if not already done. The offset of the requested PDO entry's data inside
* the domain's process data is returned. Optionally, the PDO entry bit
* position (0-7) can be retrieved via the \a bit_position output parameter.
* This pointer may be \a NULL, in this case an error is raised if the PDO
* entry does not byte-align.
*
* This method has to be called in non-realtime context before
* ecrt_master_activate().
*
* \retval >=0 Success: Offset of the PDO entry's process data.
* \retval <0 Error code.
*/
int ecrt_slave_config_reg_pdo_entry(
ec_slave_config_t *sc, /**< Slave configuration. */
uint16_t entry_index, /**< Index of the PDO entry to register. */
uint8_t entry_subindex, /**< Subindex of the PDO entry to register. */
ec_domain_t *domain, /**< Domain. */
unsigned int *bit_position /**< Optional address if bit addressing
is desired */
);
/**10 Configure distributed clocks.
*配置分布式时钟
* Sets the AssignActivate word and the cycle and shift times for the sync
* signals.
*为同义词信号设置AssignActivate单词和周期和移位时间。
* The AssignActivate word is vendor-specific and can be taken from the XML
* device description file (Device -> Dc -> AssignActivate). Set this to zero,
* if the slave shall be operated without distributed clocks (default).
*
* This method has to be called in non-realtime context before
* ecrt_master_activate().
*
* \attention The \a sync1_shift time is ignored.
*/
void ecrt_slave_config_dc(
ec_slave_config_t *sc, /**< Slave configuration. */
uint16_t assign_activate, /**< AssignActivate word.分配激活字词 */
uint32_t sync0_cycle, /**< SYNC0 cycle time [ns]. */
int32_t sync0_shift, /**< SYNC0 shift time [ns]. */
uint32_t sync1_cycle, /**< SYNC1 cycle time [ns]. */
int32_t sync1_shift /**< SYNC1 shift time [ns]. */
);