From 23f26e8d4cea6619caff53235b92bd2dd4eed76e Mon Sep 17 00:00:00 2001 From: WXK <287788329@qq.com> Date: 星期四, 03 八月 2023 17:23:29 +0800 Subject: [PATCH] 版本v2.6,修改5v输入检测错误bug --- Src/ExternalDevices/BMP390.c | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Src/ExternalDevices/BMP390.c b/Src/ExternalDevices/BMP390.c index d5f80cc..d11eb43 100644 --- a/Src/ExternalDevices/BMP390.c +++ b/Src/ExternalDevices/BMP390.c @@ -176,8 +176,7 @@ } u8 BMP390_Init(void) { - delay_ms(10); - u8 BMP390_ID; + u8 BMP390_ID,temp; // IIC_Start(); // IIC_Send_Byte(BMP390_Write); // IIC_Send_Byte(0xB6); @@ -189,9 +188,13 @@ BMP390_Write_Byte(PWR_CTRL_Addr,0x33);//Set Working mode and state of sensor // BMP390_Write_Byte(IF_CONF_Addr,0x00);//Serial interface settings BMP390_Write_Byte(INT_CTRL_Addr,0x02);//Set interrupt config - BMP390_Write_Byte(OSR_Addr,0x15);//Set the PM-RATE and PM-PRC,Set the TMPI-RATE and TMP-PRC - BMP390_Write_Byte(ODR_Addr,0x05);//Set the configuration of the output data rates by means of setting the subdivision/subsampling. - BMP390_Write_Byte(CONFIG_Addr,0);//IIR filter coeffcients + + temp = BMP3_OVERSAMPLING_2X<<3|BMP3_OVERSAMPLING_32X; + BMP390_Write_Byte(OSR_Addr,temp);//Set the PM-RATE and PM-PRC,Set the TMPI-RATE and TMP-PRC + temp = BMP3_ODR_6_25_HZ; + BMP390_Write_Byte(ODR_Addr,temp);//Set the configuration of the output data rates by means of setting the subdivision/subsampling. + temp = BMP3_IIR_FILTER_COEFF_3<<1; + BMP390_Write_Byte(CONFIG_Addr,temp);//IIR filter coeffcients return BMP390_ID; } @@ -340,7 +343,7 @@ } float Altitude; double Correcting_Temp,Correcting_Press; -extern int Pressure_Para[11],Temperature_Para[3]; +int Pressure_Para[11],Temperature_Para[3]; void GetPressAndHeight() { float Pressure,Pressure_Temp,Pres_temp; @@ -353,7 +356,7 @@ Correcting_Temp = Correcting_Temperature(Temperature,Temperature_Para); Correcting_Press = Correcting_Pressure(Pressure,Pressure_Para,Correcting_Temp)+Offest_Pressure; Altitude = 44330*(1-pow(Correcting_Press/101325.0,1.0/5.255)); - Correcting_Press = Correcting_Press/100; + // Correcting_Press = Correcting_Press/100; if(Correcting_Press==0) Altitude = 0; -- Gitblit v1.9.3