From af364cea6556733d653b313e244337a0b2a18269 Mon Sep 17 00:00:00 2001 From: wangfq Date: Fri, 24 Jul 2026 16:43:04 +0800 Subject: [PATCH] =?UTF-8?q?fix(opt):=20=E5=85=89=E8=80=A6=E5=A4=8D?= =?UTF-8?q?=E4=BD=8D=E6=94=B9=E4=B8=BA=E4=B8=8A=E5=8D=87=E6=B2=BF=E8=A7=A6?= =?UTF-8?q?=E5=8F=91=20+=20=E4=BD=BF=E8=83=BD=20PB10=20=E6=95=B0=E5=AD=97?= =?UTF-8?q?=E8=BE=93=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 逻辑改为上升沿触发: 干接点接通(PB10=0) ≥500ms → 断开(上升沿) → SYS_ResetExecute() 中途断开 <500ms → 计时清零, 不触发 2. 使能 PB10 数字输入: R32_PIN_CONFIG2 &= ~(1UL<<26) RB_PIN_PB10_15_DIS 默认置位关闭数字输入以省电, DLD110SV4 未用 PB10 作输入因此未配置 --- .../APP/peripheral_main.c | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/BLE/DLD154Pro_Peripheral_28K/APP/peripheral_main.c b/BLE/DLD154Pro_Peripheral_28K/APP/peripheral_main.c index 617190b..1c8582d 100644 --- a/BLE/DLD154Pro_Peripheral_28K/APP/peripheral_main.c +++ b/BLE/DLD154Pro_Peripheral_28K/APP/peripheral_main.c @@ -395,7 +395,7 @@ void gpio_uart_init(void) rs485_init(); /* 初始化 UART0 + GPIO + 中断 */ /*--- 光耦输入 (PB10=IN_1) ---*/ - /* 逻辑待定, 仅初始化引脚为输入上拉 */ + R32_PIN_CONFIG2 &= ~(1UL << 26); // 使能 PB10 数字输入 (默认关闭省电) GPIOB_ModeCfg(GPIO_Pin_10, GPIO_ModeIN_PU); /*--- 线圈调频 (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 == 1: 光耦复位模式 - * PB10 低电平 >=500ms -> 触发 INIT_VD() 复位检测器 + * 外部干接点接通 → PB10=0 → 计时; 保持 ≥500ms 后断开 → 上升沿 → 芯片复位 *===========================================================================*/ static void opt_input_poll(void) { 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) { _opt_low_since = 0; - _opt_fired = 0; + _opt_armed = 0; return; } - if (OPT_IN1 == 0) { // 光耦导通 -> 低电平 + 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; - SYS_ResetExecute(); // 芯片全复位 + } else if (!_opt_armed && (mstick() - _opt_low_since >= 500)) { + _opt_armed = 1; // 满足 500ms, 等待上升沿 + } + } else { // 干接点断开 → 高电平 + if (_opt_armed) { + SYS_ResetExecute(); // 上升沿触发芯片复位 } - } else { _opt_low_since = 0; - _opt_fired = 0; + _opt_armed = 0; } }