8 #define BMP280_DEFAULT_ADDR 0x76 10 #define BMP280_DEFAULT_CHIP_ID 0x58 12 #define BMP280_CHIP_ID_REG 0xD0 13 #define BMP280_RST_REG 0xE0 14 #define BMP280_STAT_REG 0xF3 15 #define BMP280_CTRL_MEAS_REG 0xF4 16 #define BMP280_CONFIG_REG 0xF5 17 #define BMP280_PRESSURE_MSB_REG 0xF7 18 #define BMP280_PRESSURE_LSB_REG 0xF8 19 #define BMP280_PRESSURE_XLSB_REG 0xF9 20 #define BMP280_TEMPERATURE_MSB_REG 0xFA 21 #define BMP280_TEMPERATURE_LSB_REG 0xFB 22 #define BMP280_TEMPERATURE_XLSB_REG 0xFC 23 #define BMP280_FORCED_MODE 0x01 24 #define BMP280_NORMAL_MODE 0x03 26 #define BMP280_TEMPERATURE_CALIB_DIG_T1_LSB_REG 0x88 27 #define BMP280_PRESSURE_TEMPERATURE_CALIB_DATA_LENGTH 24 28 #define BMP280_DATA_FRAME_SIZE 6 30 #define BMP280_OVERSAMP_SKIPPED 0x00 31 #define BMP280_OVERSAMP_1X 0x01 32 #define BMP280_OVERSAMP_2X 0x02 33 #define BMP280_OVERSAMP_4X 0x03 34 #define BMP280_OVERSAMP_8X 0x04 35 #define BMP280_OVERSAMP_16X 0x05 93 int32_t var1, var2, T;
95 var1 = ((((adc_T >> 3) - ((int32_t)bmp280_cal.
dig_T1 << 1))) * ((int32_t)bmp280_cal.
dig_T2)) >> 11;
96 var2 = (((((adc_T >> 4) - ((int32_t)bmp280_cal.
dig_T1)) * ((adc_T >> 4) - ((int32_t)bmp280_cal.
dig_T1))) >> 12) * ((int32_t)bmp280_cal.
dig_T3)) >> 14;
97 bmp280_cal.
t_fine = var1 + var2;
98 T = (bmp280_cal.
t_fine * 5 + 128) >> 8;
107 int64_t var1, var2, p;
108 var1 = ((int64_t)bmp280_cal.
t_fine) - 128000;
109 var2 = var1 * var1 * (int64_t)bmp280_cal.
dig_P6;
110 var2 = var2 + ((var1*(int64_t)bmp280_cal.
dig_P5) << 17);
111 var2 = var2 + (((int64_t)bmp280_cal.
dig_P4) << 35);
112 var1 = ((var1 * var1 * (int64_t)bmp280_cal.
dig_P3) >> 8) + ((var1 * (int64_t)bmp280_cal.
dig_P2) << 12);
113 var1 = (((((int64_t)1) << 47) + var1)) * ((int64_t)bmp280_cal.
dig_P1) >> 33;
117 p = (((p << 31) - var2) * 3125) / var1;
118 var1 = (((int64_t)bmp280_cal.
dig_P9) * (p >> 13) * (p >> 13)) >> 25;
119 var2 = (((int64_t)bmp280_cal.
dig_P8) * p) >> 19;
120 p = ((p + var1 + var2) >> 8) + (((int64_t)bmp280_cal.
dig_P7) << 4);
165 static uint32_t next_update_ms = 0;
166 uint32_t now_ms =
millis();
167 if (now_ms > next_update_ms)
176 next_update_ms += 20;
static uint32_t pressure_raw
bool i2cRead(uint8_t addr_, uint8_t reg_, uint8_t len, uint8_t *buf)
static uint32_t temperature_raw
#define BMP280_PRESSURE_MSB_REG
volatile uint32_t millis(void)
static bool sensor_present
#define BMP280_CTRL_MEAS_REG
static uint8_t buffer[BMP280_DATA_FRAME_SIZE]
#define BMP280_NORMAL_MODE
#define BMP280_CHIP_ID_REG
bool i2cWrite(uint8_t addr_, uint8_t reg_, uint8_t data)
static volatile int16_t temp
#define BMP280_OVERSAMP_8X
void bmp280_async_read(float *pres, float *temp)
static volatile uint8_t async_read_status
ASYNC Methods.
#define BMP280_DATA_FRAME_SIZE
void i2c_queue_job(i2cJobType_t type, uint8_t addr_, uint8_t reg_, uint8_t *data, uint8_t length, volatile uint8_t *status_, void(*CB)(uint8_t))
static int32_t bmp280_compensate_T(int32_t adc_T)
static bmp280_calib_param_t bmp280_cal
static uint32_t bmp280_compensate_P(int32_t adc_P)
#define BMP280_OVERSAMP_1X
#define BMP280_TEMPERATURE_CALIB_DIG_T1_LSB_REG
void bmp280_async_update()
struct bmp280_calib_param_s bmp280_calib_param_t
void bmp280_calculate(void)
#define BMP280_DEFAULT_ADDR
static void bmp280_async_read_cb(uint8_t result)
void bmp280_read(float *pres, float *temp)