feat: 光耦输入复位功能 (PB10 ≥500ms 低电平触发 INIT_VD)

opt_input_poll():
- g_fm_radar_input_disable=0: 雷达模式 (暂未实现)
- g_fm_radar_input_disable=1: 光耦复位模式
  PB10 低电平 ≥500ms → INIT_VD() + rs485_reset_heartbeat()
  <500ms 脉冲被消抖忽略 (上升沿清零计时)
This commit is contained in:
wangfq
2026-07-24 12:09:53 +08:00
parent a1c617facb
commit b98c931baa
@@ -847,7 +847,38 @@ void cjq_srv(void){
}
}
/*===========================================================================
* opt_input_poll - 光耦输入处理
*
* g_fm_radar_input_disable == 0: 雷达输入模式 (暂未实现)
* g_fm_radar_input_disable == 1: 光耦复位模式
* PB10 低电平 >=500ms -> 触发 INIT_VD() 复位检测器
*===========================================================================*/
static void opt_input_poll(void)
{
static uint32_t _opt_low_since = 0; // PB10 变低的时刻
static uint8_t _opt_fired = 0; // 本次已触发, 等待释放
if (g_fm_radar_input_disable == 0) {
_opt_low_since = 0;
_opt_fired = 0;
return;
}
if (OPT_IN1 == 0) { // 光耦导通 -> 低电平
if (_opt_low_since == 0) {
_opt_low_since = mstick();
} else if (!_opt_fired && (mstick() - _opt_low_since >= 500)) {
_opt_fired = 1;
INIT_VD();
rs485_reset_heartbeat();
PRINT("OPT: reset triggered\n");
}
} else {
_opt_low_since = 0;
_opt_fired = 0;
}
}
/*********************************************************************
@@ -869,6 +900,8 @@ void Main_Circulation()
cjq_srv();
opt_input_poll(); // 光耦输入处理 (复位 / 雷达)
rs485_poll(); // RS485 700BS 协议: 命令处理 + 心跳上报
if(g_flag_bt_state == 0){