debug(rf): revert to polling EV1527_Decode, ISR does pure edge counting

Diagnostic experiment: restore the commit d8df5d4 polling decode
algorithm/thresholds unchanged, while P3.6 ISR now only increments an
edge counter (no decode state machine). Successful decodes print the
edge-count delta over the decode window to compare against the
EV1527 theoretical 50-edges-per-frame, to validate/refute the
edge-interrupt glitch-noise hypothesis.
This commit is contained in:
edisondeng
2026-07-31 15:53:15 +08:00
parent 18d272aac9
commit 29194a4f5d
4 changed files with 208 additions and 176 deletions

View File

@@ -40,20 +40,20 @@ void EV1527_TxFrame(u32 addr, u8 dat);
void EV1527_Transmit(u32 addr, u8 dat);
/**
* @brief P3.6 (RF_RX_DATA) 边沿中断增量解码处理,由 main.c 的 Port3_Isr 在每次电平跳变时调用
* @details 内部维护一个三态状态机 (空闲搜索 -> 同步头确认 -> 逐位收集),用相邻两次跳变的时间差
* 还原刚结束的电平宽度,增量推进 EV1527 解码,凑齐 24 位后把结果写入内部标志供
* EV1527_Decode() 非阻塞取用。全程不做任何阻塞等待,适合在中断上下文中调用
* @brief DEBUG 对照实验:P3.6 (RF_RX_DATA) 边沿中断处理,由 main.c 的 Port3_Isr 在每次电平跳变时调用
* @details 本实验阶段只做纯边沿计数 (dbg_isr_edge_count++),不参与任何解码逻辑;真正的解码
* 已改回 EV1527_Decode() 内的阻塞轮询实现。用于验证:一次成功轮询解码期间,
* 真实硬件触发的边沿中断次数是否稳定、是否符合 EV1527 协议理论值 (50)
*/
void RF_HandleEdgeInterrupt(void);
/**
* @brief 阻塞地检查一次 EV1527 射频信号是否已解码完成
* @brief 阻塞式检测并解码一个合法的 EV1527 射频信号数据帧 (DEBUG 对照实验:恢复自 commit d8df5d4 的轮询实现)
* @param out_addr 输出参数指针:若解码成功,将写入解析得到的 20 位发送地址 (即 24 位帧除去 4 位数据位后的剩余高 20 位)
* @param out_data 输出参数指针:若解码成功,将写入解析出的 4 位命令状态数据码 (例如报警/SOS等)
* @return bit 1-本次调用取到了一帧新解码出有效数据0-当前尚无新结果
* @note 真正的解码工作已经在 P3.6 边沿中断 (RF_HandleEdgeInterrupt) 中增量完成,
* 本函数只是原子地检查并取出中断解码结果,可在主循环中高频调用而不会造成任何阻塞
* @return bit 1-本次调用解码出一帧有效数据0-未检测到合法数据帧 (含超时/校验失败)
* @note 解码成功时会额外通过串口打印本次解码期间 RF_HandleEdgeInterrupt 的边沿计数快照
* (解码前/解码后/差值),用于对照验证
*/
bit EV1527_Decode(u32 *out_addr, u8 *out_data);
@@ -67,4 +67,10 @@ void RF_DiagnosticMode(char choice);
*/
void Loopback_Test(void);
/**
* @brief DEBUG: 打印 P3.6 边沿中断纯计数快照 (本实验阶段唯一保留的排查计数器)
* @note 排查用,定位问题完成后可以连同 rf.c 里的计数器一起删除
*/
void RF_PrintDebugCounters(void);
#endif // __RF_H__