From ceaa0578c69e8ffacbd4b6d93968624509457563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=A9=AC=5F666?= <13089258+pony-six-hundred-and-sixty-six@user.noreply.gitee.com> Date: Thu, 5 Jun 2025 14:38:33 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=8D=E4=BD=8E=E4=BA=86=E6=8E=89=E7=94=B5?= =?UTF-8?q?=E9=98=88=E5=80=BC=EF=BC=8C=E4=BB=A5=E5=8F=8A=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BA=86=E8=81=94=E7=BD=91=E6=9C=BA=E5=88=B6=EF=BC=8C=E5=8F=AA?= =?UTF-8?q?=E8=A6=81=E4=BA=8B=E4=BB=B6=E8=A7=A6=E5=8F=91=EF=BC=8C=E5=88=99?= =?UTF-8?q?=E6=96=AD=E7=BD=91=E9=87=8D=E8=BF=9E=E6=A0=87=E5=BF=97=E6=B8=85?= =?UTF-8?q?=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .mrs/launch.json | 6 +++--- applications/main.c | 6 +++--- bsp/inc/bsp_vin_detection.h | 2 +- bsp/src/bsp_ml307.c | 10 ++++++---- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.mrs/launch.json b/.mrs/launch.json index 0ad7452..e17263f 100644 --- a/.mrs/launch.json +++ b/.mrs/launch.json @@ -5,7 +5,7 @@ "type": "mrs-debugger", "request": "launch", "name": "ble_bjq_ch303rct6_ml307", - "cwd": "c:\\Users\\16586\\Desktop\\ble_-tyq_-bjq_-ch32-v303", + "cwd": "d:\\SXDT\\Project\\CH32\\ble_bjq_ch303rct6_ml307", "openOCDCfg": { "useLocalOpenOCD": true, "executable": "c:/MounRiver/MounRiver_Studio2/resources/app/resources/win32/components/WCH/OpenOCD/OpenOCD/bin/openocd.exe", @@ -39,8 +39,8 @@ "additionalCommands": [] }, "loadedFiles": { - "executableFile": "c:\\Users\\16586\\Desktop\\ble_-tyq_-bjq_-ch32-v303\\obj\\ble_bjq_ch303rct6_ml307.elf", - "symbolFile": "c:\\Users\\16586\\Desktop\\ble_-tyq_-bjq_-ch32-v303\\obj\\ble_bjq_ch303rct6_ml307.elf", + "executableFile": "d:\\SXDT\\Project\\CH32\\ble_bjq_ch303rct6_ml307\\obj\\ble_bjq_ch303rct6_ml307.elf", + "symbolFile": "d:\\SXDT\\Project\\CH32\\ble_bjq_ch303rct6_ml307\\obj\\ble_bjq_ch303rct6_ml307.elf", "executableFileOffset": 0, "symbolFileOffset": 0 }, diff --git a/applications/main.c b/applications/main.c index 6e80ec8..6a7a9df 100644 --- a/applications/main.c +++ b/applications/main.c @@ -2,7 +2,7 @@ * @Author: mbw * @Date: 2024-10-23 17:14:16 * @LastEditors: mbw && 1600520629@qq.com - * @LastEditTime: 2025-06-04 08:54:13 + * @LastEditTime: 2025-06-05 09:58:33 * @FilePath: \ble_bjq_ch303rct6_ml307\applications\main.c * @Descrt_thread_ * @@ -198,7 +198,7 @@ uint16_t Get_Stable_Reading(uint8_t cnt, uint32_t timeout_ms) /*标定函数*/ int APP_Calibration_Handle(void) { - uint32_t gas_calibration_voltage = 0; + uint16_t gas_calibration_voltage = 0; // if (Get_Gas_VoltageAdcInt1000x() > 400 && Get_Gas_VoltageAdcInt1000x() < 900) // { @@ -240,7 +240,7 @@ int APP_Calibration_Handle(void) gas_calibration_voltage += gas_buf[i]; rt_thread_mdelay(500); } - if (i == 10) + if (i == 10) { gas_calibration_voltage = (uint16_t)(gas_calibration_voltage / 10); diff --git a/bsp/inc/bsp_vin_detection.h b/bsp/inc/bsp_vin_detection.h index 1c7d54c..ef3bb59 100644 --- a/bsp/inc/bsp_vin_detection.h +++ b/bsp/inc/bsp_vin_detection.h @@ -25,7 +25,7 @@ // (4.7/19.7) * 13V = 3.1V, 3.1/3.3*4096 = 3723 #define VIN_ADC_HIGH_THRESHOLD (uint16_t)3847 // 13V // (4.7/19.7) * 10V = 2.39V, 2.39/3.3*4096 = 2966 -#define VIN_ADC_LOW_THRESHOLD (uint16_t)2966 // 10V +#define VIN_ADC_LOW_THRESHOLD (uint16_t)2665 // 9V float Get_VIN_Voltage(void); diff --git a/bsp/src/bsp_ml307.c b/bsp/src/bsp_ml307.c index 2fdfd74..f6d110a 100644 --- a/bsp/src/bsp_ml307.c +++ b/bsp/src/bsp_ml307.c @@ -975,6 +975,7 @@ int Ml307_Process_Events (Ml307Event ml307_recv_event, struct at_device *device, if (event) // 处理该事件 { // 打印事件的名称 + ml307_disconnect_retry_flag = 0;//有事件,则断连重试标志清空 ml307_current_evnet = event->event_flag; for (size_t i = 0; i < max_retry_count; i++) { @@ -2181,11 +2182,12 @@ __exit: rt_thread_mdelay (retry_delay); retry_delay = MIN (retry_delay * 2, 1800000); // 最大延迟30min delay_n++; - if (delay_n >= 21) // 连续重连大于1小时都不行,则重启设备 + if (delay_n >= 10) // 连续重连大于10都不行,则复位重连时间 { - Flash_Set_WorkDuration (work_duration); - rt_thread_mdelay (100); - reboot(); + // Flash_Set_WorkDuration (work_duration); + // rt_thread_mdelay (100); + // reboot(); + retry_delay = 8000; } ml307_conncet_tcp_flag = 0; rt_sem_release (ml307_disconnect_sem);