湿度传感器失效后重新上电,重新初始化IIC,只执行一次,避免温度传感器受影响
This commit is contained in:
parent
bb5e52ff52
commit
3d1d04b809
|
@ -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;//更新索引
|
win_10min.index = (win_10min.index + 1) % g_usrConfigInfo.speed_average_time;//更新索引
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t SHT45_ERR_NUM = 0;
|
||||||
//采集温度,湿度,大气压
|
//采集温度,湿度,大气压
|
||||||
static void getTempHumiPress(void)
|
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(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;
|
g_error_log.temp_error_SHT30 = 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue