From 3c75d5db9c9e7cd8460ceb23e95789a0ffc91fe0 Mon Sep 17 00:00:00 2001 From: hua buduo <1398587039@qq.com> Date: Sun, 22 Sep 2024 16:40:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B8=A9=E6=B9=BF=E5=BA=A6?= =?UTF-8?q?=E4=BC=A0=E6=84=9F=E5=99=A8=E6=95=85=E9=9A=9C=E4=B9=8B=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E7=B3=BB=E7=BB=9F=E5=8F=8D=E5=A4=8D=E9=87=8D=E5=90=AF?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Drivers/Sht3x/sht30.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Drivers/Sht3x/sht30.c b/Drivers/Sht3x/sht30.c index bd5b686..48d3345 100644 --- a/Drivers/Sht3x/sht30.c +++ b/Drivers/Sht3x/sht30.c @@ -71,6 +71,7 @@ u_int8_t CheckCrc8(u_int8_t* message, u_int8_t initial_value) u_int8_t sht30_init() { float temp,humi; + uint8_t ret; // soft reset // i2c_write_cmd(0x30a2); // HAL_Delay(25); @@ -78,8 +79,11 @@ u_int8_t sht30_init() HAL_Delay(1); //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" ); - term_printf("Sensor Sht30 Check OK.\r\n Temp:%.2f,Humi:%.2f\r\n", temp,humi); + 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); + else + term_printf("Sensor Sht30 Check Err.\r\n"); return 0; } @@ -129,7 +133,9 @@ BOOL get_temp_humi_data(float* temdata, float* humidata) for(int i=0; i