feat(opt): 光耦输出模式升级 — DLD_OUTPUT_MODE 枚举 + direction_mode 低四位取值

- 新增 DLD_OUTPUT_MODE 枚举: 7种模式(复位/纯地感/纯雷达/或/与/人车混行/ETC)
- g_fm_radar_input_disable → g_output_radar_mode: 从 function_mode bit1 改为 direction_mode & 0x0F
- 仅模式0(复位)已实现, 1~6 暂为 no-op
- BLE 回读字段改为 direction_mode 完整字节
- rs485_700bs.c: 注释块重排(无功能变更)
- docs: 更新开发日志
This commit is contained in:
wangfq
2026-07-28 09:26:09 +08:00
parent ffaa5cd733
commit f5edab43c2
6 changed files with 391 additions and 325 deletions
@@ -35,7 +35,7 @@
uint8_t g_flag_bt_state = 0; // 0 蓝牙没有连接,1 有蓝牙连接
uint8_t g_function_mode = 0;
uint8_t g_fm_700bs_disable = 0; //0: 700bs protocol; 1 Modbus protocol
uint8_t g_fm_radar_input_disable = 0; //0: radar input enable; 1 reset
uint8_t g_output_radar_mode = 0;
uint32_t g_sys_freq = 0;
uint8_t g_storage_uart_num = 0;
uint32_t g_storage_uart_baud = 19200;//9600;
@@ -340,7 +340,7 @@ void para_store_init(void)
g_freq_level = g_loop_cng_unit.loopFreq_Level - 1;
g_function_mode = g_loop_cng_unit.direction_mode >> 4;
g_fm_700bs_disable = g_function_mode & 0x01;
g_fm_radar_input_disable = (g_function_mode >> 1) & 0x01;
g_output_radar_mode = g_loop_cng_unit.direction_mode & 0x0F;
g_freq_sens = (g_loop_cng_unit.sensitvity > 0) ? (g_loop_cng_unit.sensitvity - 1) : 0;
#ifdef DEBUG
@@ -850,8 +850,8 @@ void cjq_srv(void){
/*===========================================================================
* opt_input_poll — 光耦输入处理
*
* g_fm_radar_input_disable == 0: 雷达输入模式 (暂未实现)
* g_fm_radar_input_disable == 1: 光耦复位模式
* g_output_radar_mode == 0: 光耦复位模式 + 地感模式
* g_output_radar_mode >= 1: 雷达输入模式 (暂未实现)
* 外部干接点接通 → PB10=0 → 计时; 保持 ≥500ms 后断开 → 上升沿 → 芯片复位
*===========================================================================*/
static void opt_input_poll(void)
@@ -859,7 +859,7 @@ static void opt_input_poll(void)
static uint32_t _opt_low_since = 0; // PB10 变低的时刻
static uint8_t _opt_armed = 0; // 低电平已保持 ≥500ms, 等待上升沿
if (g_fm_radar_input_disable == 0) {
if (g_output_radar_mode) {
_opt_low_since = 0;
_opt_armed = 0;
return;
@@ -868,7 +868,7 @@ static void opt_input_poll(void)
if (OPT_IN1 == 0) { // 干接点接通 → 低电平
if (_opt_low_since == 0) {
_opt_low_since = mstick();
} else if (!_opt_armed && (mstick() - _opt_low_since >= 100)) { // 100 tick × 5ms = 500ms
} else if (!_opt_armed && (mstick() - _opt_low_since >= 80)) { // 100 tick × 5ms = 500ms
_opt_armed = 1; // 满足 500ms, 等待上升沿
}
} else { // 干接点断开 → 高电平