用的是i2c1,stm32所有型号都可以用。i2c初始化后调用Bmp_Init()函数初始化BMP280,读取数据时建议先读温度再读气压,这样精度更高:
while(BMP280_GetStatus(BMP280_MEASURING) != RESET);
while(BMP280_GetStatus(BMP280_IM_UPDATE) != RESET);
BMP280_Get_Temperature();
BMP_Pressure=BMP280_Get_Pressure_f();
printf("Pressure %f Pa\r\n",BMP_Pressure);
1