fix(rf): true single-edge P3.6 trigger + pull-down, restore edge decode

Root cause found via datasheet: PxIM0/PxIM1 has no dual-edge mode, only
falling/rising/low-level/high-level. (IM1=1,IM0=1) was actually
high-level interrupt, refiring continuously for the whole high-pulse
duration (confirmed by scope: no real HF noise, and edge_count=0 when
P3.6 grounded). Fix: start in rising-edge mode, software-toggle to the
opposite edge on every trigger (ping-pong) to emulate true dual-edge
triggering, feeding exact edge direction into the incremental decode
state machine (no glitch filter needed). Also switch P3.6 idle bias
from pull-up to pull-down, since floating-high under the old high-level
mode caused the interrupt-storm boot issue; removed the now-conflicting
pull-up restore in Wakeup_Restore().
This commit is contained in:
edisondeng
2026-07-31 16:39:06 +08:00
parent 29194a4f5d
commit 4a89aef71e
5 changed files with 270 additions and 155 deletions

View File

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