fix(opt): 光耦复位改为上升沿触发 + 使能 PB10 数字输入

1. 逻辑改为上升沿触发:
   干接点接通(PB10=0) ≥500ms → 断开(上升沿) → SYS_ResetExecute()
   中途断开 <500ms → 计时清零, 不触发

2. 使能 PB10 数字输入:
   R32_PIN_CONFIG2 &= ~(1UL<<26)
   RB_PIN_PB10_15_DIS 默认置位关闭数字输入以省电,
   DLD110SV4 未用 PB10 作输入因此未配置
This commit is contained in:
wangfq
2026-07-24 16:43:04 +08:00
parent 71366fe1a7
commit af364cea65
@@ -395,7 +395,7 @@ void gpio_uart_init(void)
rs485_init(); /* 初始化 UART0 + GPIO + 中断 */ rs485_init(); /* 初始化 UART0 + GPIO + 中断 */
/*--- 光耦输入 (PB10=IN_1) ---*/ /*--- 光耦输入 (PB10=IN_1) ---*/
/* 逻辑待定, 仅初始化引脚为输入上拉 */ R32_PIN_CONFIG2 &= ~(1UL << 26); // 使能 PB10 数字输入 (默认关闭省电)
GPIOB_ModeCfg(GPIO_Pin_10, GPIO_ModeIN_PU); GPIOB_ModeCfg(GPIO_Pin_10, GPIO_ModeIN_PU);
/*--- 线圈调频 (PA12=FLEVEL, 一级) ---*/ /*--- 线圈调频 (PA12=FLEVEL, 一级) ---*/
@@ -848,33 +848,35 @@ void cjq_srv(void){
} }
/*=========================================================================== /*===========================================================================
* opt_input_poll - 光耦输入处理 * opt_input_poll 光耦输入处理
* *
* g_fm_radar_input_disable == 0: 雷达输入模式 (暂未实现) * g_fm_radar_input_disable == 0: 雷达输入模式 (暂未实现)
* g_fm_radar_input_disable == 1: 光耦复位模式 * g_fm_radar_input_disable == 1: 光耦复位模式
* PB10 低电平 >=500ms -> 触发 INIT_VD() 复位检测器 * 外部干接点接通 → PB10=0 → 计时; 保持 ≥500ms 后断开 → 上升沿 → 芯片复位
*===========================================================================*/ *===========================================================================*/
static void opt_input_poll(void) static void opt_input_poll(void)
{ {
static uint32_t _opt_low_since = 0; // PB10 变低的时刻 static uint32_t _opt_low_since = 0; // PB10 变低的时刻
static uint8_t _opt_fired = 0; // 本次已触发, 等待释放 static uint8_t _opt_armed = 0; // 低电平已保持 ≥500ms, 等待上升沿
if (g_fm_radar_input_disable == 0) { if (g_fm_radar_input_disable == 0) {
_opt_low_since = 0; _opt_low_since = 0;
_opt_fired = 0; _opt_armed = 0;
return; return;
} }
if (OPT_IN1 == 0) { // 光耦导通 -> 低电平 if (OPT_IN1 == 0) { // 干接点接通 → 低电平
if (_opt_low_since == 0) { if (_opt_low_since == 0) {
_opt_low_since = mstick(); _opt_low_since = mstick();
} else if (!_opt_fired && (mstick() - _opt_low_since >= 500)) { } else if (!_opt_armed && (mstick() - _opt_low_since >= 500)) {
_opt_fired = 1; _opt_armed = 1; // 满足 500ms, 等待上升沿
SYS_ResetExecute(); // 芯片全复位 }
} else { // 干接点断开 → 高电平
if (_opt_armed) {
SYS_ResetExecute(); // 上升沿触发芯片复位
} }
} else {
_opt_low_since = 0; _opt_low_since = 0;
_opt_fired = 0; _opt_armed = 0;
} }
} }