feat(comm): 1.6.22 稀疏写 ESC + 1.6.23~24 pmDrive 电源管理; LAN9252 性能审计报告

This commit is contained in:
cbb
2026-09-12 01:59:42 +08:00
parent 1742d9a759
commit 9ca3db26f8
8 changed files with 434 additions and 5 deletions
@@ -1,12 +1,15 @@
/**
* @file app_spi_cmd_exmc_diag.cpp
* @brief SPI 0xA2 EXMC/HBI 诊断命令处理器:驱动 LAN9252 通断测试 pattern / NRST 手动诊断。
* @brief SPI 0xA2 EXMC/HBI 诊断命令处理器:驱动 LAN9252 通断测试 pattern / NRST 手动诊断 / 电源管理。
*
* 网页按钮 → ESP32 /spi/send → SPI 0xA2 → 本 handler → 分流:
* action 0~10 → EscExmcBus::continuityDrive() (EXMC 数据/控制线 pattern)
* action 20~24 → EscLan9252::nrstDrive() (ECAT_NRST/PB10 拉低/拉高/浮空/回读)
* action 30~34 → EscLan9252::pmDrive() (电源管理:读状态/进D1/D2/D3/手动唤醒)
* 立即返回 ACK,不阻塞 SPI 总线。电平保持到下次调用或 action=0(stop)。
* NRST action 返回的 status 字节 = 实际引脚电平(0/1),非 OK 码。
* PM action 返回的 status 字节 = bit0=READY bit1=PM_SLEEP_EN bit3:2=PM_MODE;
* 唤醒(34)另有 1=成功 0=超时;0xEE=无效 action,0xE1=HBI 未就绪。
*/
#include "device/spi/spi_command_handler.h"
#include "device/spi/app_spi_command.h"
@@ -29,7 +32,9 @@ public:
uint8_t status = 0xEE;
if (ctx.payload_len >= 1) {
const uint8_t action = ctx.payload[0];
if (action >= 20U) {
if (action >= 30U) {
status = EscLan9252::pmDrive(action - 30U);
} else if (action >= 20U) {
status = EscLan9252::nrstDrive(action - 20U);
} else {
status = EscExmcBus::continuityDrive(action);