采集10次气压,超过范围算报错,不报错平均值返回气压数据,气压传感器D1,D2每次开始转换到获取延时改为10MS

This commit is contained in:
95384 2025-03-08 14:08:12 +08:00
parent dfc64ef786
commit aaac4bb443
2 changed files with 9 additions and 5 deletions

View File

@ -1118,7 +1118,7 @@ void tem_hum_update_task(void const * argument)
if(tem_hun_check_flag) if(tem_hun_check_flag)
{ {
//采集温湿度与大气压 //采集温湿度与大气压
osDelay(10);//等待传感器初始化 // osDelay(10);//等待传感器初始化
getTempHumiPress(); getTempHumiPress();
} }

View File

@ -42,7 +42,7 @@ static HAL_StatusTypeDef MS56XX_ReadD1_Press(uint32_t *D1_Value)
{ {
return HAL_ERROR; return HAL_ERROR;
} }
osDelay(20); osDelay(10);
if(HAL_I2C_Master_Transmit(&hi2c3, MS5607_ADDRESS, _addr, 1, 0xff) != HAL_OK) if(HAL_I2C_Master_Transmit(&hi2c3, MS5607_ADDRESS, _addr, 1, 0xff) != HAL_OK)
{ {
return HAL_ERROR; return HAL_ERROR;
@ -71,7 +71,7 @@ static HAL_StatusTypeDef MS56XX_ReadD2_Temp(uint32_t *D2_Value_)
{ {
return HAL_ERROR; return HAL_ERROR;
} }
osDelay(20); osDelay(10);
if(HAL_I2C_Master_Transmit(&hi2c3, MS5607_ADDRESS, _addr, 1, 0xff) != HAL_OK) if(HAL_I2C_Master_Transmit(&hi2c3, MS5607_ADDRESS, _addr, 1, 0xff) != HAL_OK)
{ {
return HAL_ERROR; return HAL_ERROR;
@ -183,11 +183,15 @@ static HAL_StatusTypeDef MS56XX_GetPressureTemp(float *Temp, float *Press) //
} }
if(Tmp_Pressure<1000) if(Tmp_Pressure<1000)
{ {
Tmp_Pressure=1000; // Tmp_Pressure=1000;
*Press = 0;
return HAL_ERROR;
} }
if(Tmp_Pressure>120000) if(Tmp_Pressure>120000)
{ {
Tmp_Pressure=120000; // Tmp_Pressure=120000;
*Press = 0;
return HAL_ERROR;
} }
*Temp = ((float)MS56XX_Temperature)/100; *Temp = ((float)MS56XX_Temperature)/100;
*Press = ((float)Tmp_Pressure)/100; *Press = ((float)Tmp_Pressure)/100;