46 #define BMP085_DEV_ADDR_R 0xEF
50 #define BMP085_DEV_ADDR_W 0xEE
55 #define BMP085_CTRL_REG_ADDR 0xF4
59 #define BMP085_CTRL_REG_TEMP 0x2E
63 #define BMP085_CTRL_REG_PRESS_0 0x34
67 #define BMP085_CTRL_REG_PRESS_1 0x74
71 #define BMP085_CTRL_REG_PRESS_2 0xB4
75 #define BMP085_CTRL_REG_PRESS_3 0xF4
80 #define BMP085_DATA_REG_N 0xF6
85 #define BMP085_DATA_REG_X 0xF8
90 #define BMP085_AC1_ADDR 0xAA
94 #define BMP085_AC2_ADDR 0xAC
98 #define BMP085_AC3_ADDR 0xAE
102 #define BMP085_AC4_ADDR 0xB0
106 #define BMP085_AC5_ADDR 0xB2
110 #define BMP085_AC6_ADDR 0xB4
114 #define BMP085_B1_ADDR 0xB6
118 #define BMP085_B2_ADDR 0xB8
122 #define BMP085_MB_ADDR 0xBA
126 #define BMP085_MC_ADDR 0xBC
130 #define BMP085_MD_ADDR 0xBE
136 volatile int16_t ac1;
137 volatile int16_t ac2;
138 volatile int16_t ac3;
139 volatile uint16_t ac4;
140 volatile uint16_t ac5;
141 volatile uint16_t ac6;
152 static bmp085_calib_data bmp085_coeff;
154 static uint8_t bmp085_read8bit_data(uint8_t addr);
155 static uint16_t bmp085_read16bit_data(uint8_t addr);
156 static void bmp085_read_calib_data(
void);
157 static int32_t bmp085_read_uncomp_pressure(uint8_t mode);
158 static int32_t bmp085_read_uncomp_temperature(
void);
181 bmp085_read_calib_data();
192 bmp085_read_uncomp_temperature(
void)
203 bmp085_read_uncomp_pressure(uint8_t mode)
232 return (pressure >> (8 - mode));
241 ut = bmp085_read_uncomp_temperature();
243 x1 = ((int32_t) ut - (int32_t) bmp085_coeff.ac6)
244 * (int32_t) bmp085_coeff.ac5 >> 15;
245 x2 = ((int32_t) bmp085_coeff.mc << 11) / (x1 + bmp085_coeff.md);
248 return (int16_t) ((b5 + 8) >> 4);
254 int32_t ut = 0, compt = 0;
255 int32_t up = 0, compp = 0;
257 int32_t x1, x2, b5, b6, x3, b3, p;
260 ut = bmp085_read_uncomp_temperature();
261 up = bmp085_read_uncomp_pressure(mode);
263 x1 = ((int32_t) ut - (int32_t) bmp085_coeff.ac6)
264 * (int32_t) bmp085_coeff.ac5 >> 15;
265 x2 = ((int32_t) bmp085_coeff.mc << 11) / (x1 + bmp085_coeff.md);
267 compt = (b5 + 8) >> 4;
270 x1 = (bmp085_coeff.b2 * ((b6 * b6) >> 12)) >> 11;
271 x2 = (bmp085_coeff.ac2 * b6) >> 11;
273 b3 = (((((int32_t) bmp085_coeff.ac1) * 4 + x3) << mode) + 2) >> 2;
274 x1 = (bmp085_coeff.ac3 * b6) >> 13;
275 x2 = (bmp085_coeff.b1 * ((b6 * b6) >> 12)) >> 16;
276 x3 = ((x1 + x2) + 2) >> 2;
277 b4 = (bmp085_coeff.ac4 * (uint32_t) (x3 + 32768)) >> 15;
278 b7 = ((uint32_t) (up - b3) * (50000 >> mode));
280 if (b7 < 0x80000000) {
286 x1 = (p >> 8) * (p >> 8);
287 x1 = (x1 * 3038) >> 16;
288 x2 = (-7357 * p) >> 16;
289 compp = p + ((x1 + x2 + 3791) >> 4);
294 bmp085_read_calib_data(
void)
310 bmp085_read16bit_data(uint8_t addr)
312 uint8_t msb = 0, lsb = 0;
319 return (uint16_t) ((msb << 8) | lsb);
323 bmp085_read8bit_data(uint8_t addr)