/******************************************************************************
*03 Data types数据类型
*****************************************************************************/
struct ec_master;
typedef struct ec_master ec_master_t; /**< \see ec_master */
struct ec_slave_config;
typedef struct ec_slave_config ec_slave_config_t; /**< \see ec_slave_config */
struct ec_domain;
typedef struct ec_domain ec_domain_t; /**< \see ec_domain */
struct ec_sdo_request;
typedef struct ec_sdo_request ec_sdo_request_t; /**< \see ec_sdo_request. */
struct ec_voe_handler;
typedef struct ec_voe_handler ec_voe_handler_t; /**< \see ec_voe_handler. */
struct ec_reg_request;
typedef struct ec_reg_request ec_reg_request_t; /**< \see ec_sdo_request. */
/*****************************************************************************/
/**01 Master state.
*主站状态
* This is used for the output parameter of ecrt_master_state().
*函数ecrt_master_state()的输出参数
* \see ecrt_master_state().
*/
typedef struct {
unsigned int slaves_responding; /**< Sum of responding slaves on all
Ethernet devices.所有以太网设备上响应slave的总数。 */
unsigned int al_states : 4; /**< Application-layer states of all slaves.所有从站应用层状态
The states are coded in the lower 4 bits.被用低四位进行编码
If a bit is set, it means that at least one如果一位被设置,意味着至少一个
slave in the bus is in the corresponding从站在总线上有响应
state:
- Bit 0: \a INIT
- Bit 1: \a PREOP
- Bit 2: \a SAFEOP
- Bit 3: \a OP */
unsigned int link_up : 1; /**< \a true, if at least one Ethernet link is为真,至少有一个连接连上
up. */
} ec_master_state_t;
/*****************************************************************************/
/**02 Redundant link state.
*冗余链路状态。
* This is used for the output parameter of ecrt_master_link_state().
*这用于ecrt主链接状态()的输出参数。
* \see ecrt_master_link_state().
*/
typedef struct {
unsigned int slaves_responding; /**< Sum of responding slaves on the given
link. */
unsigned int al_states : 4; /**< Application-layer states of the slaves on
the given link. The states are coded in the
lower 4 bits. If a bit is set, it means
that at least one slave in the bus is in the
corresponding state:
- Bit 0: \a INIT
- Bit 1: \a PREOP
- Bit 2: \a SAFEOP
- Bit 3: \a OP */
unsigned int link_up : 1; /**< \a true, if the given Ethernet link is up.
*/
} ec_master_link_state_t;
/*****************************************************************************/
/**03 Slave configuration state.
*从站配置状态
* This is used as an output parameter of ecrt_slave_config_state().
用于函数ecrt_slave_config_state()输出参数
* \see ecrt_slave_config_state().
*/
typedef struct {
unsigned int online : 1; /**< The slave is online. 从站在线*/
unsigned int operational : 1; /**< The slave was brought into \a OP state从站被带入操作状态
using the specified configuration. 使用指定配置*/
unsigned int al_state : 4; /**< The application-layer state of the slave.从站应用层状态
- 1: \a INIT
- 2: \a PREOP
- 4: \a SAFEOP
- 8: \a OP
Note that each state is coded in a different
bit! 注意不同的状态使用不同的位*/
} ec_slave_config_state_t;
/*****************************************************************************/
/**04 Master information.
*主站信息
* This is used as an output parameter of ecrt_master().
*用于函数ecrt_master()输出参数
* \see ecrt_master().
*/
typedef struct {
unsigned int slave_count; /**< Number of slaves in the bus. 总线上从站数*/
unsigned int link_up : 1; /**< \a true, if the network link is up. 为真,一个网络连接上*/
uint8_t scan_busy; /**< \a true, while the master is scanning the bus 为真,主站正在扫描总线*/
uint64_t app_time; /**< Application time. 应用时间*/
} ec_master_info_t;
/*****************************************************************************/
/**05 EtherCAT slave port descriptor.
EherCAT 从站端口描述
*/
typedef enum {
EC_PORT_NOT_IMPLEMENTED, /**< Port is not implemented.端口没有实现 */
EC_PORT_NOT_CONFIGURED, /**< Port is not configured. 端口没有配置*/
EC_PORT_EBUS, /**< Port is an E-Bus.端口是E-Bus */
EC_PORT_MII /**< Port is a MII.端口是 MII */
} ec_slave_port_desc_t;
/*****************************************************************************/
/**06 EtherCAT slave port information.
从站端口信息
*/
typedef struct {
uint8_t link_up; /**< Link detected.检测到连接 */
uint8_t loop_closed; /**< Loop closed.循环关闭 */
uint8_t signal_detected; /**< Detected signal on RX port.在RX端口检测到信号 */
} ec_slave_port_link_t;
/*****************************************************************************/
/**07 Slave information.
*从站信息
* This is used as an output parameter of ecrt_master_get_slave().
*用于函数ecrt_master_get_slave()的输出参数
* \see ecrt_master_get_slave().
*/
typedef struct {
uint16_t position; /**< Offset of the slave in the ring.从站在位置环中的偏移 */
uint32_t vendor_id; /**< Vendor-ID stored on the slave. 存储在从站中的供应商ID*/
uint32_t product_code; /**< Product-Code stored on the slave.存储在从站中的产品代码 */
uint32_t revision_number; /**< Revision-Number stored on the slave. */
uint32_t serial_number; /**< Serial-Number stored on the slave. */
uint16_t alias; /**< The slaves alias if not equal to 0.不等于0时候从站假名 */
int16_t current_on_ebus; /**< Used current in mA. */
struct {
ec_slave_port_desc_t desc; /**< Physical port type. */
ec_slave_port_link_t link; /**< Port link state. */
uint32_t receive_time; /**< Receive time on DC transmission delay
measurement. */
uint16_t next_slave; /**< Ring position of next DC slave on that
port. */
uint32_t delay_to_next_dc; /**< Delay [ns] to next DC slave. */
} ports[EC_MAX_PORTS]; /**< Port information. 端口信息*/
uint8_t al_state; /**< Current state of the slave.从站当前状态 */
uint8_t error_flag; /**< Error flag for that slave.从站错误标志 */
uint8_t sync_count; /**< Number of sync managers.同步管理器数量 */
uint16_t sdo_count; /**< Number of SDOs.SDO数量 */
char name[EC_MAX_STRING_LENGTH]; /**< Name of the slave. 从站名字*/
} ec_slave_info_t;
/*****************************************************************************/
/**08 Domain working counter interpretation.
*域工作计数解释
* This is used in ec_domain_state_t.
*/
typedef enum {
EC_WC_ZERO = 0, /**< No registered process data were exchanged. 没有交换注册的过程数据。*/
EC_WC_INCOMPLETE, /**< Some of the registered process data were一些注册的进程数据被交换
exchanged. */
EC_WC_COMPLETE /**< All registered process data were exchanged. 交换了所有注册的过程数据*/
} ec_wc_state_t;
/*****************************************************************************/
/**09 Domain state.
*域状态
* This is used for the output parameter of ecrt_domain_state().
*/
typedef struct {
unsigned int working_counter; /**< Value of the last working counter. 最后一个工作计数器的值*/
ec_wc_state_t wc_state; /**< Working counter interpretation. 工作计数器的状态*/
unsigned int redundancy_active; /**< Redundant link is in use. 冗余链接正在使用中。*/
} ec_domain_state_t;
/*****************************************************************************/
/**10 Direction type for PDO assignment functions.PDO分配函数的方向类型。
*/
typedef enum {
EC_DIR_INVALID, /**< Invalid direction. Do not use this value.无效的方向。不要使用这个值。”*/
EC_DIR_OUTPUT, /**< Values written by the master. 主站写的值*/
EC_DIR_INPUT, /**< Values read by the master. 主站读的值*/
EC_DIR_COUNT /**< Number of directions. For internal use only. 数量的方向。只供内部使用*/
} ec_direction_t;
/*****************************************************************************/
/**11 Watchdog mode for sync manager configuration.
*同步管理器配置看门狗模式
* Used to specify, if a sync manager's watchdog is to be enabled.
*/
typedef enum {
EC_WD_DEFAULT, /**< Use the default setting of the sync manager.使用默认同步管理器设置 */
EC_WD_ENABLE, /**< Enable the watchdog.使能看门狗 */
EC_WD_DISABLE, /**< Disable the watchdog. 不使能看门狗*/
} ec_watchdog_mode_t;
/*****************************************************************************/
/**12 PDO entry configuration information.
*PDo表项配置信息。
* This is the data type of the \a entries field in ec_pdo_info_t.
*
* \see ecrt_slave_config_pdos().
*/
typedef struct {
uint16_t index; /**< PDO entry index. PDO条目索引*/
uint8_t subindex; /**< PDO entry subindex. PDO条目子索引*/
uint8_t bit_length; /**< Size of the PDO entry in bit. PDO条目按位计算的大小*/
} ec_pdo_entry_info_t;
/*****************************************************************************/
/**13 PDO configuration information.
*PDo配置信息。
* This is the data type of the \a pdos field in ec_sync_info_t.
*
* \see ecrt_slave_config_pdos().
*/
typedef struct {
uint16_t index; /**< PDO index. */
unsigned int n_entries; /**< Number of PDO entries in \a entries to map.
Zero means, that the default mapping shall be
used (this can only be done if the slave is
present at bus configuration time). */
ec_pdo_entry_info_t *entries; /**< Array of PDO entries to map. Can either
be \a NULL, or must contain at
least \a n_entries values. */
} ec_pdo_info_t;
/*****************************************************************************/
/**14 Sync manager configuration information.
*同步管理器配置信息
* This can be use to configure multiple sync managers including the PDO
* assignment and PDO mapping. It is used as an input parameter type in
* ecrt_slave_config_pdos().
这可以用来配置多个同步管理器,包括PDO分配和PDO mappinq。
它被用作输入参数类型ecrt_salve_config pdos()。
*/
typedef struct {
uint8_t index; /**< Sync manager index. Must be less同步管理器索引,必须小于
than #EC_MAX_SYNC_MANAGERS for a valid sync manager作为一个合法的同步管理器,
but can also be \a 0xff to mark the end of the list. 也可以用0xff作为结束的标志*/
ec_direction_t dir; /**< Sync manager direction. 同步管理器的方向*/
unsigned int n_pdos; /**< Number of PDOs in \a pdos. PDO的数量*/
ec_pdo_info_t *pdos; /**< Array with PDOs to assign. This must contain被分配的PDO的数组,必须包含N条PDOS
at least \a n_pdos PDOs. */
ec_watchdog_mode_t watchdog_mode; /**< Watchdog mode.看门狗模式 */
} ec_sync_info_t;
/*****************************************************************************/
/**15 List record type for PDO entry mass-registration.
*列出PDO输入批量注册的记录类型。
* This type is used for the array parameter of the
* ecrt_domain_reg_pdo_entry_list()
*/
typedef struct {
uint16_t alias; /**< Slave alias address. 从站假名地址*/
uint16_t position; /**< Slave position. 从站位置*/
uint32_t vendor_id; /**< Slave vendor ID. 从站供应商ID*/
uint32_t product_code; /**< Slave product code. 从站产品编码*/
uint16_t index; /**< PDO entry index.PDO条目索引 */
uint8_t subindex; /**< PDO entry subindex. PDO条目子索引*/
unsigned int *offset; /**< Pointer to a variable to store the PDO entry's用于存储PDO表项的变量指针
(byte-)offset in the process data. 在过程数据中的偏移*/
unsigned int *bit_position; /**< Pointer to a variable to store a bit
position (0-7) within the \a offset. Can be
NULL, in which case an error is raised if the
PDO entry does not byte-align. /**<指向一个变量的指针,
用于在\a偏移量中存储位(0-7)。可以为NULL,在这种情况下,
如果PDO条目没有按字节对齐,将引发错误。*/u*/
} ec_pdo_entry_reg_t;
/*****************************************************************************/
/**16 Request state.
*请求状态
* This is used as return type for ecrt_sdo_request_state() and
* ecrt_voe_handler_state().
*/
typedef enum {
EC_REQUEST_UNUSED, /**< Not requested. 没有请求*/
EC_REQUEST_BUSY, /**< Request is being processed. 请求正在处理*/
EC_REQUEST_SUCCESS, /**< Request was processed successfully. 请求处理成功*/
EC_REQUEST_ERROR, /**< Request processing failed. 请求处理失败*/
} ec_request_state_t;
/*****************************************************************************/
/**17 Application-layer state.应用层状态
*/
typedef enum {
EC_AL_STATE_INIT = 1, /**< Init. 初始化*/
EC_AL_STATE_PREOP = 2, /**< Pre-operational.预操作 */
EC_AL_STATE_SAFEOP = 4, /**< Safe-operational. 安全操作*/
EC_AL_STATE_OP = 8, /**< Operational. 操作*/
} ec_al_state_t;
03 ethercat(IGH)主要的数据类型
最新推荐文章于 2025-05-06 15:44:00 发布