From b98c931baa9ab47813666c791e5e211d1b9c49ba Mon Sep 17 00:00:00 2001 From: wangfq Date: Fri, 24 Jul 2026 12:09:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=85=89=E8=80=A6=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E5=A4=8D=E4=BD=8D=E5=8A=9F=E8=83=BD=20(PB10=20=E2=89=A5500ms?= =?UTF-8?q?=20=E4=BD=8E=E7=94=B5=E5=B9=B3=E8=A7=A6=E5=8F=91=20INIT=5FVD)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit opt_input_poll(): - g_fm_radar_input_disable=0: 雷达模式 (暂未实现) - g_fm_radar_input_disable=1: 光耦复位模式 PB10 低电平 ≥500ms → INIT_VD() + rs485_reset_heartbeat() <500ms 脉冲被消抖忽略 (上升沿清零计时) --- .../APP/peripheral_main.c | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/BLE/DLD154Pro_Peripheral_28K/APP/peripheral_main.c b/BLE/DLD154Pro_Peripheral_28K/APP/peripheral_main.c index 059293e..c1607e3 100644 --- a/BLE/DLD154Pro_Peripheral_28K/APP/peripheral_main.c +++ b/BLE/DLD154Pro_Peripheral_28K/APP/peripheral_main.c @@ -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){