From 3d1d04b8099ac1144f25b823f25112d849a1627c Mon Sep 17 00:00:00 2001 From: 95384 <664090429@qq.com> Date: Mon, 10 Mar 2025 10:35:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B9=BF=E5=BA=A6=E4=BC=A0=E6=84=9F=E5=99=A8?= =?UTF-8?q?=E5=A4=B1=E6=95=88=E5=90=8E=E9=87=8D=E6=96=B0=E4=B8=8A=E7=94=B5?= =?UTF-8?q?=EF=BC=8C=E9=87=8D=E6=96=B0=E5=88=9D=E5=A7=8B=E5=8C=96IIC?= =?UTF-8?q?=EF=BC=8C=E5=8F=AA=E6=89=A7=E8=A1=8C=E4=B8=80=E6=AC=A1=EF=BC=8C?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E6=B8=A9=E5=BA=A6=E4=BC=A0=E6=84=9F=E5=99=A8?= =?UTF-8?q?=E5=8F=97=E5=BD=B1=E5=93=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Src/anemometer_dev.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/App/Src/anemometer_dev.c b/App/Src/anemometer_dev.c index ae96bb5..fec93d5 100644 --- a/App/Src/anemometer_dev.c +++ b/App/Src/anemometer_dev.c @@ -1065,6 +1065,8 @@ void my_update_mcs_param(float new_wind_speed, float new_wind_dirction) win_10min.index = (win_10min.index + 1) % g_usrConfigInfo.speed_average_time;//更新索引 } + +uint8_t SHT45_ERR_NUM = 0; //采集温度,湿度,大气压 static void getTempHumiPress(void) { @@ -1085,6 +1087,24 @@ static void getTempHumiPress(void) if(get_temp_humi_data(&backupTemperature1, &g_stMcs_Para.humidity) != HAL_OK) { //错误处理 + //断电重启,本次关电,下次上电,下下次返回正常数据 + if(g_error_log.temp_error_SHT30 == 0) + { + HAL_GPIO_WritePin(GPIOB, GPIO_SHT_PWR_EN_Pin, GPIO_PIN_RESET); + HAL_I2C_DeInit(&hi2c1); + SHT45_ERR_NUM = 1; + }else + { + //确保只执行一次重新初始化程序 + if(SHT45_ERR_NUM == 1) + { + HAL_GPIO_WritePin(GPIOB, GPIO_SHT_PWR_EN_Pin, GPIO_PIN_SET); + osDelay(1); + MX_I2C1_Init(); + TMP117_Init();//TMP117是同一个电源,重新上电需要初始化 + SHT45_ERR_NUM = 0; + } + } //置错误标志位 g_error_log.temp_error_SHT30 = 1; }