From 69c9ae25c3852a3514d225f67847c59394a9be66 Mon Sep 17 00:00:00 2001 From: stark1898y <1658608470@qq.com> Date: Fri, 20 Jun 2025 19:31:51 +0800 Subject: [PATCH] ZANCUN --- applications/main.c | 10 +++++----- applications/user_sys.h | 2 +- bsp/inc/bsp_mq.h | 4 ++-- bsp/src/bsp_flash.c | 7 ++++--- bsp/src/bsp_mq.c | 6 +++--- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/applications/main.c b/applications/main.c index 446bd7e..0a80464 100644 --- a/applications/main.c +++ b/applications/main.c @@ -229,9 +229,9 @@ int APP_Calibration_Handle(void) uint16_t gas_buf[20] = {0}; // 采集10s的ADC值 - for (i = 0; i < 20; i++) + for (i = 0; i < 10; i++) { - gas_buf[i] = Get_Gas_VoltageAdcInt1000x(); + gas_buf[i] = Get_Gas_VoltageInt1000x(); if ((gas_buf[i] == 0) || (gas_buf[i] >= 0xfff)) { return 0; @@ -259,7 +259,7 @@ int APP_Calibration_Handle(void) { sum += gas_buf[i]; } - gas_calibration_voltage = (uint16_t)(sum / 8); + gas_calibration_voltage = (uint16_t)((sum / 8.0f) - 85); // 写入标定值 calibration_buf[0] = gas_calibration_voltage & 0xFF; // 低字节 @@ -320,7 +320,7 @@ int main(void) { uint16_t dr2 = (BKP_ReadBackupRegister(BKP_DR2) & 0xFFFF); uint8_t calibration_buf[2] = {0}; - + // 写入标定值 calibration_buf[0] = dr2 & 0xFF; // 低字节 calibration_buf[1] = (dr2 >> 8) & 0xFF; // 高字节 @@ -331,7 +331,7 @@ int main(void) BKP_WriteBackupRegister(BKP_DR3, 0);// 清除标志位 } - + rt_thread_mdelay(10); } else diff --git a/applications/user_sys.h b/applications/user_sys.h index 49a11bd..218b242 100644 --- a/applications/user_sys.h +++ b/applications/user_sys.h @@ -19,7 +19,7 @@ #define SYS_HW_VERSION (0X13U) -#define SYS_SW_VERSION (0X17U) +#define SYS_SW_VERSION (0X18U) #define SYS_IOT_UPLOAD_CYCLE_MIN (0X003CU) // 高位在后,低位在前 #define SYS_IOT_RETRY (0X03U) #define SYS_TEMP_ALARM_THRESHOLD (0X32U) diff --git a/bsp/inc/bsp_mq.h b/bsp/inc/bsp_mq.h index 3e2e1c8..a7184cd 100644 --- a/bsp/inc/bsp_mq.h +++ b/bsp/inc/bsp_mq.h @@ -12,7 +12,7 @@ * @Author : stark1898y 1658608470@qq.com * @Date : 2023-08-02 11:49:34 * @LastEditors : stark1898y 1658608470@qq.com - * @LastEditTime : 2024-06-19 09:42:35 + * @LastEditTime : 2025-06-20 17:29:07 * @FilePath : \wuxi_alarm_ch32v303rct6_rtt\bsp\inc\bsp_mq.h * @Description : * @@ -26,7 +26,7 @@ // MQ采样间隔 #define MQ_SAMPLING_INTERVAL_MS (100U) -#define SENSOR_SAMPLING_TIMS (4U) +#define SENSOR_SAMPLING_TIMS (10U) // MQ采样时间窗口 #define MQ_SAMPLING_S (uint8_t)(3U) diff --git a/bsp/src/bsp_flash.c b/bsp/src/bsp_flash.c index 5dfc8a8..82e022d 100644 --- a/bsp/src/bsp_flash.c +++ b/bsp/src/bsp_flash.c @@ -297,7 +297,7 @@ int Flash_Set_WorkDuration(rt_uint16_t value) rt_thread_delay(10); } } - + return RT_ERROR; } @@ -905,7 +905,7 @@ int BSP_Flash_Init (void) Flash_Write (FLASH_INIT_FLAG_ADDR, flash_init_flag, sizeof (flash_init_flag)); Flash_Set_WorkDuration (work_duration); - + LOG_D ("work_duration:%d", Flash_Get_WorkDuration()); Convert_To_Hex (&sever_info, sever_data); @@ -917,7 +917,8 @@ int BSP_Flash_Init (void) Flash_SetProductTimeLimit (2025, 6, 11, 11, 50, 20, kFactoryTimeId); Set_ExpirationTime (MAX_EXPIRATION_DAYS); - Flash_Set_Calibration_State(kSysGasCalibStatus); // 标定状态 + // TODO:标定标志 + Flash_Set_Calibration_State(kNotCalibrated); // 标定状态 Flash_Set_Valve_Num(0); sci.hw_ver = SYS_HW_VERSION; sci.sw_ver = SYS_SW_VERSION; diff --git a/bsp/src/bsp_mq.c b/bsp/src/bsp_mq.c index 8dd7de2..e7c3551 100644 --- a/bsp/src/bsp_mq.c +++ b/bsp/src/bsp_mq.c @@ -12,7 +12,7 @@ * @Author : yzy * @Date : 2023-01-30 15:40:07 * @LastEditors : stark1898y 1658608470@qq.com - * @LastEditTime : 2023-09-19 16:25:03 + * @LastEditTime : 2025-06-20 17:30:09 * @FilePath : \JT-DT-YD1F01_RTT_Nano\bsp\src\bsp_mq.c * @Description : * @@ -116,11 +116,11 @@ static uint8_t Sensor_CheckData(void) static rt_uint8_t index = 0; static rt_uint8_t alarm_status_buffer[SENSOR_SAMPLING_TIMS] = {0}; static rt_uint8_t fault_buf[SENSOR_SAMPLING_TIMS] = {0}; - rt_uint16_t voltage = Get_Gas_VoltageAdcInt1000x(); + rt_uint16_t voltage = Get_Gas_VoltageInt1000x(); if(alarm_flag) { - alarm_status_buffer[index] = ((voltage > (Sensor_device.alarm_value - 15)) && (voltage < MQ_VOLTAGE_HIGH_LIMIT)) ? kSensorAlarm : kSensorNormal; + alarm_status_buffer[index] = ((voltage > (Sensor_device.alarm_value - 30)) && (voltage < MQ_VOLTAGE_HIGH_LIMIT)) ? kSensorAlarm : kSensorNormal; } else {