feat(comm): LAN9252增加csrRead验证分级并实现PDO差分写功能
为提升EtherCAT通信性能,实现以下两项优化:
1. 对EscLan9252::csrRead方法增加verify参数,支持分级验证:
- verify=true(默认):保持原有的双读比对+重试机制,用于SM/AL/邮箱等
关键路径防止EXMC毛刺
- verify=false:单读模式,用于诊断回读/MII busy轮询/init轮询等低风
险场景,节省一半CSR间接访问时间
2. 实现PDO输入差分写ESC功能:
- 将输入PDO分为三区:段1桥状态(0-31)、段2电机密排(32-543)、段3+5
快照诊断(544-599)
- 采用3-buffer冲刷协议:变化后连续写3拍确保3个缓冲区全部更新
- 对内容稳定的段跳过写操作,显著减少PRAM字节搬运时间
- 全段跳过时强制写末2字节完成SM事件应答
同时更新配置版本至1.6.25,添加相关配置选项和文档说明。
This commit is contained in:
@@ -82,6 +82,21 @@ public:
|
||||
static bool sparseEscWritePlan(uint16_t *off0, uint16_t *len0,
|
||||
uint16_t *off1, uint16_t *len1);
|
||||
|
||||
/**
|
||||
* @brief 输入 PDO 写 ESC 的多段计划(1.6.25 差分写;未启用时回退稀疏/整包)。
|
||||
* @param[out] offs 段偏移数组,至少 kEscPlanMaxSegs 项
|
||||
* @param[out] lens 段长度数组,至少 kEscPlanMaxSegs 项
|
||||
* @return 段数 1..kEscPlanMaxSegs;调用方逐段 HW_EscWriteIsr。
|
||||
* @note 必须在 writeInputs()/s_in 发布之后、每拍一次调用。按三区差分:
|
||||
* 段1(0..31 桥状态)、段2(32..543 电机密排,写时用稀疏有效长)、
|
||||
* 段3+5(544..599)。变化后连续写 3 拍冲完 3-buffer 才允许跳过。
|
||||
* 全段跳过时返回「末 2 字节」一段以完成 SM 事件。有副作用。
|
||||
*/
|
||||
static uint8_t escWritePlan(uint16_t *offs, uint16_t *lens);
|
||||
|
||||
/** escWritePlan 最多段数。 */
|
||||
static constexpr uint8_t kEscPlanMaxSegs = 4U;
|
||||
|
||||
/** @brief 累计取走输出的周期数(主站在发过程数据的证据)。 */
|
||||
static uint32_t outputCycles() { return s_outputCycles; }
|
||||
|
||||
@@ -121,6 +136,16 @@ private:
|
||||
* ECAT_Application() 会在 PDI_Isr / Sync0_Isr / Sync1_Isr / MainLoop 四个
|
||||
* 上下文被调用并互相抢占,直接写 s_in 会让读侧取到跨轮次的半成品。 */
|
||||
alignas(4) static uint8_t s_build[kPdoInBytes];
|
||||
/** @brief 写 ESC 差分影子(1.6.25):段1 / 段2 / 段3+5 三区。 */
|
||||
alignas(4) static uint8_t s_escSh1[32];
|
||||
alignas(4) static uint8_t s_escSh2[ECAT_XRX_OFF_CH - 32U];
|
||||
alignas(4) static uint8_t s_escSh3[kEcatPdoInBytes - ECAT_XRX_OFF_CH];
|
||||
static uint8_t s_escFlush1;
|
||||
static uint8_t s_escFlush2;
|
||||
static uint8_t s_escFlush3;
|
||||
static bool s_escSh1Valid;
|
||||
static bool s_escSh2Valid;
|
||||
static bool s_escSh3Valid;
|
||||
/** @brief process() 被重入拦下的次数(诊断用,见 reentryCount())。 */
|
||||
static volatile uint32_t s_reentryCount;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user