From 6c735b637d057b92ee2e8654dafea3e61cc4a25e 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: Fri, 17 Jan 2025 10:52:36 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=8D=E4=BD=8E=E4=BA=86=E6=8A=A5=E8=AD=A6?= =?UTF-8?q?=E7=9A=84=E6=95=8F=E6=84=9F=E5=BA=A6=EF=BC=8C=E9=98=B2=E6=AD=A2?= =?UTF-8?q?=E8=AF=AF=E6=8A=A5=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/inc/bsp_h308.h | 2 +- bsp/src/bsp_h308.c | 20 +++++++++++--------- bsp/src/bsp_led.c | 21 +-------------------- 3 files changed, 13 insertions(+), 30 deletions(-) diff --git a/bsp/inc/bsp_h308.h b/bsp/inc/bsp_h308.h index 5c4016a..e0d266d 100644 --- a/bsp/inc/bsp_h308.h +++ b/bsp/inc/bsp_h308.h @@ -17,7 +17,7 @@ #define TSET_BSP_H308 -#define H308_SAMPLING_TIMS (6U) +#define H308_SAMPLING_TIMS (8U) /*浓度异常采样周期*/ #define H308_SAMPLING_ABNORMAL (60U) #define H308_PWR_PIN GET_PIN(B, 9) diff --git a/bsp/src/bsp_h308.c b/bsp/src/bsp_h308.c index 0da00be..74a7a74 100644 --- a/bsp/src/bsp_h308.c +++ b/bsp/src/bsp_h308.c @@ -2,7 +2,7 @@ * @Author: mbw * @Date: 2024-11-14 10:21:04 * @LastEditors: mbw && 1600520629@qq.com - * @LastEditTime: 2025-01-15 10:15:25 + * @LastEditTime: 2025-01-17 10:46:51 * @FilePath: \JT-DT-YD4N02A_RTT_MRS-NT26K\bsp\src\bsp_h308.c * @Description: * @@ -165,7 +165,7 @@ static uint8_t H308_Count(const rt_uint8_t *buffer, uint8_t value, uint8_t size) static void H308_HandleAlarm(uint8_t count, uint8_t *flag, uint8_t threshold) { - if (count > threshold && *flag == 0) + if (count >= threshold && *flag == 0) { H308.detection_flag = kH308Alarm; Send_Laser_Alarm_Event(kAlarmEvent); @@ -181,7 +181,7 @@ static void H308_HandleAlarm(uint8_t count, uint8_t *flag, uint8_t threshold) static void H308_HandleFault(uint8_t count, uint8_t *flag, uint8_t threshold) { - if (count > threshold && *flag != 1) + if (count >= threshold && *flag != 1) { *flag = 1; H308.detection_flag = kH308Fault; @@ -213,8 +213,8 @@ static uint8_t H308_CheckData(void) alarm_count = H308_Count(alarm_status_buffer, kH308Alarm, H308_SAMPLING_TIMS); fault_count = H308_Count(fault_buf, kH308Fault, H308_SAMPLING_TIMS); - H308_HandleAlarm(alarm_count, &alarm_flag, H308_SAMPLING_TIMS / 2); - H308_HandleFault(fault_count, &fault_flag, H308_SAMPLING_TIMS / 2); + H308_HandleAlarm(alarm_count, &alarm_flag, H308_SAMPLING_TIMS); + H308_HandleFault(fault_count, &fault_flag, H308_SAMPLING_TIMS); return RT_EOK; } @@ -222,15 +222,17 @@ static uint8_t H308_CheckData(void) // TODO: 寿命检测 uint8_t IS_H308_EndOfLife(void) { - if (RTC_GetCounter() >= H308.expiration_seconds) + RTC_GetTime(); + if (RtcDateTime.year > 2035)//至少大于2035年再检测 { - H308.end_of_life = 1; + if (RTC_GetCounter() >= H308.expiration_seconds) + { + H308.end_of_life = 1; + } } return H308.end_of_life; } - - void UART4_Init(void) { GPIO_InitTypeDef GPIO_InitStructure = {0}; diff --git a/bsp/src/bsp_led.c b/bsp/src/bsp_led.c index d65b13c..ba6492d 100644 --- a/bsp/src/bsp_led.c +++ b/bsp/src/bsp_led.c @@ -23,27 +23,8 @@ static struct rt_thread user_led_thread; static void BSP_Led_thread_entry(void *param) { - // static rt_bool_t led_state_flag = RT_FALSE; while (1) { -#if 0 - if (nt26k_conncet_tcp_flag) - { - if ((SysControl.status == kNormalDetectionEvents) && (led_state_flag != RT_TRUE)) - { - LED_G_INTERNET; - led_state_flag = RT_TRUE; - } - } - else - { - if ((SysControl.status == kNormalDetectionEvents) && (led_state_flag != RT_FALSE)) - { - LED_G_NORMAL; - led_state_flag = RT_FALSE; - } - } -#endif if (SysControl.status == kNormalDetectionEvents) { if ((nt26k_conncet_tcp_flag)) @@ -69,7 +50,7 @@ static void BSP_Led_thread_entry(void *param) } } } - rt_thread_mdelay(1000); + rt_thread_mdelay(1500); } }