2026-06-26 00:57:59 +08:00
|
|
|
/**
|
|
|
|
|
* @file ethercat_slave.h
|
2026-09-01 03:07:48 +08:00
|
|
|
* @brief EtherCAT 从站 init 探针与运行状态查询接口。
|
|
|
|
|
* @note 1.5.27:原先的 periodicIsr()/三缓冲 PDO 桥是死代码(无任何调用点),
|
|
|
|
|
* 运行期 PDO 交换实际由 SSC 协议栈完成 —— 周期路径为 Sync0_Isr →
|
|
|
|
|
* ECAT_Application → APPL_InputMapping/OutputMapping(comm/ssc/port/dc_app.c),
|
|
|
|
|
* 主循环路径为 MainLoop → ECAT_Main。本类仅保留 init 探针与诊断查询。
|
2026-06-26 00:57:59 +08:00
|
|
|
*/
|
|
|
|
|
#ifndef COMM_ETHERCAT_SLAVE_H
|
|
|
|
|
#define COMM_ETHERCAT_SLAVE_H
|
|
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
#include <cstddef>
|
|
|
|
|
|
2026-06-29 01:51:02 +08:00
|
|
|
/** @brief EtherCAT AL 状态码(EtherCAT 协议定义,ESC AL Status 寄存器低 4 位)。 */
|
|
|
|
|
constexpr uint8_t AL_STATE_SAFEOP = 0x04U; /**< SAFEOP 状态(SYNC0 可触发下限)。 */
|
|
|
|
|
|
2026-06-26 00:57:59 +08:00
|
|
|
/**
|
2026-09-01 03:07:48 +08:00
|
|
|
* @brief EtherCAT 从站 init 探针与状态查询。
|
2026-06-26 00:57:59 +08:00
|
|
|
*/
|
|
|
|
|
class EthercatSlave {
|
|
|
|
|
public:
|
2026-09-01 03:07:48 +08:00
|
|
|
/** @brief 初始化 ESC(HBI 探活 + 芯片 ID + AL 状态),供 init 汇总诊断。 */
|
2026-06-26 00:57:59 +08:00
|
|
|
static void init();
|
|
|
|
|
|
2026-06-29 01:51:02 +08:00
|
|
|
/** @brief ESC 自检是否通过(init 后可查询,用于决定是否使能同步中断)。 */
|
|
|
|
|
static bool isEscReady() { return s_escReady; }
|
|
|
|
|
|
|
|
|
|
/** @brief 读取 ESC 芯片 ID(供诊断打印;未就绪时为上次读到的值)。 */
|
|
|
|
|
static uint32_t getChipId() { return s_chipId; }
|
|
|
|
|
|
2026-09-01 03:07:48 +08:00
|
|
|
/** @brief 读取 ESC AL 状态码(供诊断打印;未就绪时为上次读到的值)。 */
|
2026-06-29 01:51:02 +08:00
|
|
|
static uint8_t getAlState() { return s_alState; }
|
|
|
|
|
|
2026-06-26 00:57:59 +08:00
|
|
|
private:
|
2026-06-29 01:51:02 +08:00
|
|
|
static bool s_escReady; /**< ESC 自检结果(init 后置位)。 */
|
|
|
|
|
static uint32_t s_chipId; /**< ESC 芯片 ID(诊断用)。 */
|
|
|
|
|
static uint8_t s_alState; /**< ESC AL 状态码(init 后可查询,供 isEscReady 守卫)。 */
|
2026-06-26 00:57:59 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif /* COMM_ETHERCAT_SLAVE_H */
|