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){