#ifndef __BMP390_H #define __BMP390_H //#include "myiic.h" //#include "sys.h" //#include "LCD.h" //#include "delay.h" #include "stdio.h" #include "math.h" #include "main.h" #define BMP390_Write 0XEE #define BMP390_Read 0xEF #define BMP390_CMD_SOFT_RESET 0xB6 #define CHIP_ID_Addr 0x00 #define REV_ID_Addr 0x01 #define ERR_REG_Addr 0x02 #define STATUS_Addr 0x03 #define PSR_B2_Addr 0x06 #define PSR_B1_Addr 0x05 #define PSR_B0_Addr 0x04 #define TMP_B2_Addr 0x09 #define TMP_B1_Addr 0x08 #define TMP_B0_Addr 0x07 #define SENSORTIME_0_Addr 0x0C #define SENSORTIME_1_Addr 0x0D #define SENSORTIME_2_Addr 0x0E #define EVENT_Addr 0x10 #define INT_CTRL_Addr 0x19 #define IF_CONF_Addr 0x1A #define PWR_CTRL_Addr 0x1B #define OSR_Addr 0x1C #define ODR_Addr 0x1D #define CONFIG_Addr 0x1F #define CMD_Addr 0x7E #define NVM_PAR_P11_Addr 0x45 #define NVM_PAR_P10_Addr 0x44 #define NVM_PAR_P9_H_Addr 0x43 #define NVM_PAR_P9_L_Addr 0x42 #define NVM_PAR_P8_Addr 0x41 #define NVM_PAR_P7_Addr 0x40 #define NVM_PAR_P6_H_Addr 0x3F #define NVM_PAR_P6_L_Addr 0x3E #define NVM_PAR_P5_H_Addr 0x3D #define NVM_PAR_P5_L_Addr 0x3C #define NVM_PAR_P4_Addr 0x3B #define NVM_PAR_P3_Addr 0x3A #define NVM_PAR_P2_H_Addr 0x39 #define NVM_PAR_P2_L_Addr 0x38 #define NVM_PAR_P1_H_Addr 0x37 #define NVM_PAR_P1_L_Addr 0x36 #define NVM_PAR_T3_Addr 0x35 #define NVM_PAR_T2_H_Addr 0x34 #define NVM_PAR_T2_L_Addr 0x33 #define NVM_PAR_T1_H_Addr 0x32 #define NVM_PAR_T1_L_Addr 0x31 #define Total_Number_32 4294967296.0 #define Total_Number_30 1073741824.0 #define Total_Number_29 536870912.0 #define Total_Number_24 16777216.0 #define Total_Number_20 1048576.0 #define Total_Number_16 65536.0 #define Total_Number_15 32768.0 #define Total_Number_14 16384.0 #define Total_Number_12 4096.0 #define Total_Number_8 256.0 #define Total_Number_6 64.0 #define Total_Number_5 32.0 #define Total_Number_1 2.0 #define Total_Number_Neg_8 0.00390625 #define Total_Number_Neg_3 0.125 /**\name Over sampling macros */ #define BMP3_NO_OVERSAMPLING UINT8_C(0x00) #define BMP3_OVERSAMPLING_2X UINT8_C(0x01) #define BMP3_OVERSAMPLING_4X UINT8_C(0x02) #define BMP3_OVERSAMPLING_8X UINT8_C(0x03) #define BMP3_OVERSAMPLING_16X UINT8_C(0x04) #define BMP3_OVERSAMPLING_32X UINT8_C(0x05) /**\name Filter setting macros */ #define BMP3_IIR_FILTER_DISABLE UINT8_C(0x00) #define BMP3_IIR_FILTER_COEFF_1 UINT8_C(0x01) #define BMP3_IIR_FILTER_COEFF_3 UINT8_C(0x02) #define BMP3_IIR_FILTER_COEFF_7 UINT8_C(0x03) #define BMP3_IIR_FILTER_COEFF_15 UINT8_C(0x04) #define BMP3_IIR_FILTER_COEFF_31 UINT8_C(0x05) #define BMP3_IIR_FILTER_COEFF_63 UINT8_C(0x06) #define BMP3_IIR_FILTER_COEFF_127 UINT8_C(0x07) /**\name Odr setting macros */ #define BMP3_ODR_200_HZ UINT8_C(0x00) #define BMP3_ODR_100_HZ UINT8_C(0x01) #define BMP3_ODR_50_HZ UINT8_C(0x02) #define BMP3_ODR_25_HZ UINT8_C(0x03) #define BMP3_ODR_12_5_HZ UINT8_C(0x04) #define BMP3_ODR_6_25_HZ UINT8_C(0x05) #define BMP3_ODR_3_1_HZ UINT8_C(0x06) #define BMP3_ODR_1_5_HZ UINT8_C(0x07) #define BMP3_ODR_0_78_HZ UINT8_C(0x08) #define BMP3_ODR_0_39_HZ UINT8_C(0x09) #define BMP3_ODR_0_2_HZ UINT8_C(0x0A) #define BMP3_ODR_0_1_HZ UINT8_C(0x0B) #define BMP3_ODR_0_05_HZ UINT8_C(0x0C) #define BMP3_ODR_0_02_HZ UINT8_C(0x0D) #define BMP3_ODR_0_01_HZ UINT8_C(0x0E) #define BMP3_ODR_0_006_HZ UINT8_C(0x0F) #define BMP3_ODR_0_003_HZ UINT8_C(0x10) #define BMP3_ODR_0_001_HZ UINT8_C(0x11) u8 BMP390_Init(void); u8 BMP390_Read_Byte(u8 addr); u32 Temperature_Read(void); u32 Pressure_Read(void); void BMP390_Write_Byte(u8 addr,u8 data); void Parameter_Reading(int *Pressure_Para,int *Temperature_Para); double Correcting_Temperature(u32 Temperature,int *Temperature_Para); double Correcting_Pressure(u32 Pressure,int *Pressure_Para,double Corr_Temperature); ////IO·½ÏòÉèÖà // //#define SDA_IN() {GPIOA->MODER&=0X0FFFFFFF;GPIOB->CRH|=(u32)8<<28;} //#define SDA_OUT() {GPIOB->CRH&=0X0FFFFFFF;GPIOB->CRH|=(u32)3<<28;} // ////IO¿Ú²Ù×÷º¯Êý //#define IIC_SCL PBout(13) //SCL //#define IIC_SDA PBout(15) //Êä³öSDA //#define READ_SDA PBin(15) //ÊäÈëSDA #define BMP390_IIC2_READ_SDA HAL_GPIO_ReadPin(GPIOA, SDA_Pin) #define BMP390_SDA_1 HAL_GPIO_WritePin(GPIOA, SDA_Pin, GPIO_PIN_SET) #define BMP390_SCL_1 HAL_GPIO_WritePin(GPIOA, SCL_Pin, GPIO_PIN_SET) #define BMP390_SDA_0 HAL_GPIO_WritePin(GPIOA, SDA_Pin, GPIO_PIN_RESET) #define BMP390_SCL_0 HAL_GPIO_WritePin(GPIOA, SCL_Pin, GPIO_PIN_RESET) //I2CËùÓвÙ×÷º¯Êý void IIC_Init(void); //³õʼ»¯I2CµÄIO¿Ú void IIC_Start(void); //·¢ËÍIIC¿ªÊ¼ÐźŠvoid IIC_Stop(void); //·¢ËÍIICÍ£Ö¹ÐźŠvoid IIC_Send_Byte(u8 txd); //I2C·¢ËÍÒ»¸ö×Ö½Ú u8 IIC_Read_Byte(unsigned char ack);//I2C¶Áȡһ¸ö×Ö½Ú u8 IIC_Wait_Ack(void); //I2CµÈ´ýACKÐźŠvoid IIC_Ack(void); //I2C·¢ËÍACKÐźŠvoid IIC_NAck(void); //I2C²»·¢ËÍACKÐźŠvoid IIC_Write_One_Byte(u8 daddr,u8 addr,u8 data); u8 IIC_Read_One_Byte(u8 daddr,u8 addr); void GetPressAndHeight(); #endif