From dfc64ef786b075f08dc4526d5aaaeff700582a68 Mon Sep 17 00:00:00 2001 From: 95384 <664090429@qq.com> Date: Fri, 7 Mar 2025 17:17:19 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=96=B0=E8=AE=BE=E7=BD=AE=E6=B8=A9?= =?UTF-8?q?=E6=B9=BF=E5=BA=A6=E5=A4=A7=E6=B0=94=E5=8E=8B=E4=BC=A0=E6=84=9F?= =?UTF-8?q?=E5=99=A8=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Src/anemometer_dev.c | 87 +++++++++++++--------------------------- 1 file changed, 27 insertions(+), 60 deletions(-) diff --git a/App/Src/anemometer_dev.c b/App/Src/anemometer_dev.c index e298739..97059a8 100644 --- a/App/Src/anemometer_dev.c +++ b/App/Src/anemometer_dev.c @@ -1068,67 +1068,9 @@ void my_update_mcs_param(float new_wind_speed, float new_wind_dirction) //采集温度,湿度,大气压 static void getTempHumiPress(void) { - //采集备用温度与大气压 float backupTemperature1; - float backupTemperature2; -// uint8_t hp203_ret = get_HP203_data(&backupTemperature1, &g_stMcs_Para.pressure); - uint8_t hp203_ret = MS56XX_GetPressureTemp(&backupTemperature1, &g_stMcs_Para.pressure); - uint8_t sht30_ret = get_temp_humi_data(&backupTemperature2, &g_stMcs_Para.humidity); -#if TEMP_SENSOR == SHT30_SENSOR - g_stMcs_Para.temperature = backupTemperature2; -#endif /*TEMP_SENSOR == SHT30_SENSOR*/ - -#if TEMP_SENSOR == TMP117_SENSOR - TMP117_Init(); - osDelay(20); - uint8_t tmp117_ret = TMP117_Get_Temp(&g_stMcs_Para.temperature); - -// TMP117出问题 - if(tmp117_ret != HAL_OK) - { - //置错误标志位 - g_error_log.temp_error_TMP117 = 1; - //使用备用温度 - g_stMcs_Para.temperature = backupTemperature2; - } - else - { - //恢复错误标志位 - g_error_log.temp_error_TMP117 = 0; - } -#endif /*TEMP_SENSOR == TMP117_SENSOR*/ - - // SHT30出问题 - if(sht30_ret == FALSE) - { - //错误处理 - //关电重启,第一次进入错误判断,此时此时错误标志位为0,关电并置位错误标志位; - //再进入错误标志位检测到错误标志位后开电 - //下一次监测如果SHT30恢复,则正常运行,如果没有恢复,电继续开着,保证温度传感器正常运行 -// if(g_error_log.temp_error_SHT30 == 0) -// { -// HAL_GPIO_WritePin(GPIOB, GPIO_SHT_PWR_EN_Pin, GPIO_PIN_RESET); -// HAL_I2C_DeInit(&hi2c1); -// }else -// { -// HAL_GPIO_WritePin(GPIOB, GPIO_SHT_PWR_EN_Pin, GPIO_PIN_SET); -// MX_I2C1_Init(); -// sht30_init(); -// } - //置错误标志位 - g_error_log.temp_error_SHT30 = 1; -#if TEMP_SENSOR == SHT30_SENSOR - g_stMcs_Para.temperature = 0; -#endif /*TEMP_SENSOR == SHT30_SENSOR*/ - } - else - { - //恢复错误标志位 - g_error_log.temp_error_SHT30 = 0; - } - - //HP203B出问题 - if(hp203_ret == FALSE) + //采集MS5607并判错 + if(MS56XX_GetPressure(&g_stMcs_Para.pressure) != HAL_OK) { //置错误标志位 g_error_log.temp_error_HP203B = 1; @@ -1139,6 +1081,31 @@ static void getTempHumiPress(void) //恢复错误标志位 g_error_log.temp_error_HP203B = 0; } + //采集SHT45并判错 + if(get_temp_humi_data(&backupTemperature1, &g_stMcs_Para.humidity) != HAL_OK) + { + //错误处理 + //置错误标志位 + g_error_log.temp_error_SHT30 = 1; + } + else + { + //恢复错误标志位 + g_error_log.temp_error_SHT30 = 0; + } + //采集TMP117并判错 + if(TMP117_Get_Temp(&g_stMcs_Para.temperature) != HAL_OK) + { + //置错误标志位 + g_error_log.temp_error_TMP117 = 1; + //使用备用温度 + g_stMcs_Para.temperature = backupTemperature1; + } + else + { + //恢复错误标志位 + g_error_log.temp_error_TMP117 = 0; + } } void tem_hum_update_task(void const * argument)