修复温湿度传感器故障之后,系统反复重启的问题
This commit is contained in:
parent
8901aadc19
commit
3c75d5db9c
|
@ -71,6 +71,7 @@ u_int8_t CheckCrc8(u_int8_t* message, u_int8_t initial_value)
|
||||||
u_int8_t sht30_init()
|
u_int8_t sht30_init()
|
||||||
{
|
{
|
||||||
float temp,humi;
|
float temp,humi;
|
||||||
|
uint8_t ret;
|
||||||
// soft reset
|
// soft reset
|
||||||
// i2c_write_cmd(0x30a2);
|
// i2c_write_cmd(0x30a2);
|
||||||
// HAL_Delay(25);
|
// HAL_Delay(25);
|
||||||
|
@ -78,8 +79,11 @@ u_int8_t sht30_init()
|
||||||
HAL_Delay(1);
|
HAL_Delay(1);
|
||||||
//u_int8_t ret = i2c_write_cmd(g_stTempHumiSensor.i2c_reg_addr, g_stTempHumiSensor.cmd_init_mode);
|
//u_int8_t ret = i2c_write_cmd(g_stTempHumiSensor.i2c_reg_addr, g_stTempHumiSensor.cmd_init_mode);
|
||||||
|
|
||||||
AssertError(get_temp_humi_data(&temp, &humi),return 0,"!!!Sensor Sht30 Check Failed" );
|
ret = get_temp_humi_data(&temp, &humi);
|
||||||
|
if(ret == TRUE)
|
||||||
term_printf("Sensor Sht30 Check OK.\r\n Temp:%.2f,Humi:%.2f\r\n", temp,humi);
|
term_printf("Sensor Sht30 Check OK.\r\n Temp:%.2f,Humi:%.2f\r\n", temp,humi);
|
||||||
|
else
|
||||||
|
term_printf("Sensor Sht30 Check Err.\r\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +133,9 @@ BOOL get_temp_humi_data(float* temdata, float* humidata)
|
||||||
|
|
||||||
for(int i=0; i<COLLECT_DATA_NUM; i++){
|
for(int i=0; i<COLLECT_DATA_NUM; i++){
|
||||||
int ret = sht30_collect_data(g_stTempHumiSensor,&collect_temdata[i].fValue, &collect_humidata[i].fValue);
|
int ret = sht30_collect_data(g_stTempHumiSensor,&collect_temdata[i].fValue, &collect_humidata[i].fValue);
|
||||||
AssertError(ret == HAL_OK, return FALSE, "sht30²ÉÑùʧ°Ü");
|
// AssertError(ret == HAL_OK, return FALSE, "sht30²ÉÑùʧ°Ü");
|
||||||
|
if(ret == HAL_ERROR)
|
||||||
|
return FALSE;
|
||||||
osDelay(1);
|
osDelay(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue