37 #define BMP085_SAD 0x77 39 #define BMP085_CR_P_VAL0 0x34 40 #define BMP085_CR_P_VAL1 0x74 41 #define BMP085_CR_P_VAL2 0xB4 42 #define BMP085_CR_P_VAL3 0xF4 44 #define BMP085_CR_T_VAL 0x2E 58 #if (BMP085_USE_I2C) || defined(__DOXYGEN__) 112 #if BMP085_SHARED_I2C 118 #if BMP085_SHARED_I2C 123 devp->calibrationdata.ac1 = ((rxbuf[ 0] << 8) | rxbuf[ 1]);
124 devp->calibrationdata.ac2 = ((rxbuf[ 2] << 8) | rxbuf[ 3]);
125 devp->calibrationdata.ac3 = ((rxbuf[ 4] << 8) | rxbuf[ 5]);
126 devp->calibrationdata.ac4 = ((rxbuf[ 6] << 8) | rxbuf[ 7]);
127 devp->calibrationdata.ac5 = ((rxbuf[ 8] << 8) | rxbuf[ 9]);
128 devp->calibrationdata.ac6 = ((rxbuf[10] << 8) | rxbuf[11]);
129 devp->calibrationdata.b1 = ((rxbuf[12] << 8) | rxbuf[13]);
130 devp->calibrationdata.b2 = ((rxbuf[14] << 8) | rxbuf[15]);
131 devp->calibrationdata.mb = ((rxbuf[16] << 8) | rxbuf[17]);
132 devp->calibrationdata.mc = ((rxbuf[18] << 8) | rxbuf[19]);
133 devp->calibrationdata.md = ((rxbuf[20] << 8) | rxbuf[21]);
151 x1 = ((ut - devp->calibrationdata.ac6) * devp->calibrationdata.ac5) >> 15;
152 x2 = (devp->calibrationdata.mc << 11) / (x1 + devp->calibrationdata.md);
153 devp->calibrationdata.b5 = x1 + x2;
154 *ctp = (float)((devp->calibrationdata.b5 + 8) >> 4)*
BMP085_T_RES;
173 b6 = devp->calibrationdata.b5 - 4000;
174 x1 = (devp->calibrationdata.b2 * ((b6 * b6) >> 12)) >> 11;
175 x2 = (devp->calibrationdata.ac2 * b6) >> 11;
177 b3 = ((((int32_t)devp->calibrationdata.ac1 * 4 + x3) << oss) + 2) >> 2;
178 x1 = ((devp->calibrationdata.ac3)*b6) >> 13;
179 x2 = (devp->calibrationdata.b1 * (b6*b6 >> 12)) >> 16;
180 x3 = ((x1 + x2) + 2) >> 2;
181 b4 = devp->calibrationdata.ac4 * (uint32_t)(x3 + 32768) >> 15;
182 b7 = ((uint32_t)up - b3)*(50000 >> oss);
189 x1 = (press >> 8)*(press >> 8);
190 x1 = (x1*3038) >> 16;
191 x2 = (-7357*press) >> 16;
192 *cpp =(float)((press + ((x1 + x2 + 3791) >> 4))*
BMP085_P_RES);
228 oss = devp->config->oss;
233 txbuf[1] = BMP085_CR_P_VAL0 + (oss << 6);
237 txbuf[1] = BMP085_CR_P_VAL1 + (oss << 6);
241 txbuf[1] = BMP085_CR_P_VAL2 + (oss << 6);
245 txbuf[1] = BMP085_CR_P_VAL3 + (oss << 6);
250 #if BMP085_SHARED_I2C 256 #if BMP085_SHARED_I2C 283 #if BMP085_SHARED_I2C 291 #if BMP085_SHARED_I2C 297 *utemp = (int32_t)((rxbuf[0] << 8) | rxbuf[1]);
318 oss = devp->config->oss;
324 #if BMP085_SHARED_I2C 332 #if BMP085_SHARED_I2C 338 *upress = (int32_t)((rxbuf[0] << 16)|(rxbuf[1] << 8)|rxbuf[2]);
339 *upress = *upress >> (8-oss);
403 "baro_read_raw(), invalid state");
407 "baro_read_raw(), channel not ready");
408 #if BMP085_SHARED_I2C 417 #if BMP085_SHARED_I2C 437 "thermo_read_raw(), invalid state");
441 "thermo_read_raw(), channel not ready");
442 #if BMP085_SHARED_I2C 451 #if BMP085_SHARED_I2C 501 "baro_read_cooked(), invalid state");
507 calcul_p(ip, raw[i], oss, &axes[i]);
528 "thermo_read_cooked(), invalid state");
574 "baro_set_bias(), invalid state");
591 "thermo_set_bias(), invalid state");
607 "baro_reset_bias(), invalid state");
624 "thermo_reset_bias(), invalid state");
641 "baro_set_sensivity(), invalid state");
658 "thermo_set_sensivity(), invalid state");
674 "baro_reset_sensivity(), invalid state");
690 "thermo_reset_sensivity(), invalid state");
744 "bmp085cStart(), invalid state");
745 devp->config = config;
747 #if BMP085_SHARED_I2C 753 #if BMP085_SHARED_I2C 773 "bmp085Stop(), invalid state");
776 #if BMP085_SHARED_I2C 778 i2cStart((devp)->config->i2cp, (devp)->config->i2ccfg);
780 #if BMP085_SHARED_I2C
msg_t bmp085I2CReadRegister(I2CDriver *i2cp, uint8_t reg, uint8_t *rxbufp, size_t n)
Reads registers value using I2C.
msg_t i2cMasterTransmitTimeout(I2CDriver *i2cp, i2caddr_t addr, const uint8_t *txbuf, size_t txbytes, uint8_t *rxbuf, size_t rxbytes, sysinterval_t timeout)
Sends data via the I2C bus.
static msg_t thermo_set_sensivity(void *ip, float *sp)
Set the thermometer sensivity.
static void calcul_p(BMP085Driver *devp, int32_t up, uint8_t oss, float *cpp)
Calcul the true pressure.
void i2cStart(I2CDriver *i2cp, const I2CConfig *config)
Configures and activates the I2C peripheral.
#define chThdSleepMilliseconds(msec)
Delays the invoking thread for the specified number of milliseconds.
static msg_t thermo_reset_sensivity(void *ip)
Reset the thermometer sensivity.
static msg_t baro_set_sensivity(void *ip, float *sp)
Set the barometer sensivity.
static msg_t thermo_set_bias(void *ip, float *bp)
Set the thermometer bias.
static msg_t thermo_reset_bias(void *ip)
Reset the thermometer bias.
static void calcul_t(BMP085Driver *devp, int32_t ut, float *ctp)
Calcul the true temperature.
static msg_t baro_read_cooked(void *ip, float axes[])
Read barometer cooked data.
void i2cAcquireBus(I2CDriver *i2cp)
Gains exclusive access to the I2C bus.
static msg_t baro_reset_sensivity(void *ip)
Reset the barometer sensivity.
void i2cReleaseBus(I2CDriver *i2cp)
Releases exclusive access to the I2C bus.
BaseThermometer virtual methods table.
const struct BaseBarometerVMT * vmt_basebarometer
BaseBarometer Virtual Methods Table.
static size_t sens_get_axes_number(void *ip)
Get the sensor number of axes.
BaseBarometer virtual methods table.
static msg_t sens_read_raw(void *ip, int32_t axes[])
Read BMP085 sensor raw data.
static msg_t baro_set_bias(void *ip, float *bp)
Set the barometer bias.
void bmp085Start(BMP085Driver *devp, const BMP085Config *config)
Configures and activates BMP085 Complex Driver peripheral.
BMP085 Digital pressure sensor interface module header.
void bmp085Stop(BMP085Driver *devp)
Deactivates the BMP085 Complex Driver peripheral.
const struct BaseThermometerVMT * vmt_basethermometer
BaseThermometer Virtual Methods Table.
static msg_t sens_read_cooked(void *ip, float axes[])
Read BMP085 sensor cooked data.
void bmp085ObjectInit(BMP085Driver *devp)
Initializes an instance.
static size_t baro_get_axes_number(void *ip)
Get the barometer number of axes.
Structure representing an I2C driver.
#define BMP085_THERMO_NUMBER_OF_AXES
BMP085 thermometer subsystem characteristics.
static msg_t thermo_read_raw(void *ip, int32_t axes[])
Read thermometer raw data.
I2CDriver * i2cp
I2C driver associated to this BMP085.
static msg_t baro_read_raw(void *ip, int32_t axes[])
Read baromether raw data.
#define TIME_INFINITE
Infinite interval specification for all functions with a timeout specification.
static msg_t bmp085ReadCoefficient(BMP085Driver *devp, uint8_t reg)
Read all the calibration data from the BMP085 EEPROM.
#define osalDbgCheck(c)
Function parameters check.
#define BMP085_AD_CC_AC1_MSB
static size_t thermo_get_axes_number(void *ip)
Get the thermometer number of axes.
static msg_t acquire_ut(BMP085Driver *devp, int32_t *utemp)
Read the uncompensated temperature from the BMP085 register.
#define MSG_OK
Normal wakeup message.
static msg_t start_p_measurement(BMP085Driver *devp)
Start the pressure measurment.
#define BMP085_AD_T_DR_MSB
const struct BaseSensorVMT * vmt_basesensor
BaseSensor Virtual Methods Table.
BMP085 configuration structure.
#define BMP085_AD_P_DR_MSB
LSM303DLHC 6-axis accelerometer/compass class.
#define osalDbgAssert(c, remark)
Condition assertion.
const I2CConfig * config
Current configuration data.
static msg_t baro_reset_bias(void *ip)
Reset the barometer bias.
static msg_t thermo_read_cooked(void *ip, float axes[])
Read thermometer cooked data.
static msg_t acquire_up(BMP085Driver *devp, int32_t *upress)
Read the uncompensated pressure from the BMP085 register.
static msg_t start_t_measurement(BMP085Driver *devp)
Start temperature measurement.
BaseSensor virtual methods table.
#define BMP085_BARO_NUMBER_OF_AXES
BMP085 barometer subsystem characteristics.
msg_t bmp085I2CWriteRegister(I2CDriver *i2cp, uint8_t *txbufp, size_t n)
Writes a value into a register using I2C.