49 #if (LPS22HB_USE_I2C) || defined(__DOXYGEN__) 64 uint8_t reg, uint8_t* rxbuf,
size_t n) {
84 #define lps22hbI2CWriteRegister(i2cp, sad, txbuf, n) \ 85 i2cMasterTransmitTimeout(i2cp, sad, txbuf, n + 1, NULL, 0, \ 129 "baro_read_raw(), invalid state");
132 "baro_read_raw(), channel not ready");
134 #if LPS22HB_SHARED_I2C 137 devp->config->i2ccfg);
141 LPS22HB_AD_PRESS_OUT_XL, buff, 3);
143 #if LPS22HB_SHARED_I2C 148 *axes = buff[0] + (buff[1] << 8) + (buff[2] << 16);
181 "baro_read_cooked(), invalid state");
185 *axes = (raw * devp->barosensitivity) - devp->barobias;
215 "baro_set_bias(), invalid state");
217 devp->barobias = *bp;
241 "baro_reset_bias(), invalid state");
243 devp->barobias = LPS22HB_BARO_SENS;
269 "baro_set_sensitivity(), invalid state");
271 devp->barosensitivity = *sp;
294 "baro_reset_sensitivity(), invalid state");
296 devp->barosensitivity = LPS22HB_BARO_SENS;
341 "thermo_read_raw(), invalid state");
344 "thermo_read_raw(), channel not ready");
346 #if LPS22HB_SHARED_I2C 349 devp->config->i2ccfg);
353 LPS22HB_AD_TEMP_OUT_L, buff, 2);
355 #if LPS22HB_SHARED_I2C 360 tmp = buff[0] + (buff[1] << 8);
361 *axes = (int32_t)tmp;
394 "thermo_read_cooked(), invalid state");
398 *axis = (raw * devp->thermosensitivity) - devp->thermobias;
425 "thermo_set_bias(), invalid state");
427 devp->thermobias = *bp;
452 "thermo_reset_bias(), invalid state");
454 devp->thermobias = LPS22HB_THERMO_BIAS;
481 "thermo_set_sensitivity(), invalid state");
483 devp->thermosensitivity = *sp;
507 "thermo_reset_sensitivity(), invalid state");
509 devp->thermosensitivity = LPS22HB_THERMO_SENS;
545 devp->
vmt = &vmt_device;
570 "lps22hbStart(), invalid state");
572 devp->config = config;
577 cr[0] = LPS22HB_AD_CTRL_REG2;
578 cr[1] = LPS22HB_CTRL_REG2_IF_ADD_INC;
580 #if LPS22HB_SHARED_I2C 584 i2cStart(devp->config->i2cp, devp->config->i2ccfg);
590 cr[0] = LPS22HB_AD_CTRL_REG1;
591 cr[1] = devp->config->outputdatarate;
592 #if LPS22HB_USE_ADVANCED || defined(__DOXYGEN__) 593 cr[1] |= devp->config->blockdataupdate;
594 cr[1] |= devp->config->lowpass_filter;
598 #if LPS22HB_SHARED_I2C 606 #if LPS22HB_SHARED_I2C 610 if(devp->config->barosensitivity == NULL) {
611 devp->barosensitivity = LPS22HB_BARO_SENS;
615 devp->barosensitivity = *(devp->config->barosensitivity);
618 if(devp->config->barobias == NULL) {
619 devp->barobias = LPS22HB_BARO_BIAS;
623 devp->barobias = *(devp->config->barobias);
626 if(devp->config->thermosensitivity == NULL) {
627 devp->thermosensitivity = LPS22HB_THERMO_SENS;
631 devp->thermosensitivity = *(devp->config->thermosensitivity);
634 if(devp->config->thermobias == NULL) {
635 devp->thermobias = LPS22HB_THERMO_BIAS;
639 devp->thermobias = *(devp->config->thermobias);
661 "lps22hbStop(), invalid state");
664 #if LPS22HB_SHARED_I2C 667 (devp)->config->i2ccfg);
670 cr[0] = LPS22HB_AD_CTRL_REG1;
676 #if LPS22HB_SHARED_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.
void i2cStart(I2CDriver *i2cp, const I2CConfig *config)
Configures and activates the I2C peripheral.
const struct LPS22HBVMT * vmt
Virtual Methods Table.
static msg_t baro_read_cooked(void *ip, float axes[])
Retrieves cooked data from the BaseBarometer.
void i2cAcquireBus(I2CDriver *i2cp)
Gains exclusive access to the I2C bus.
void i2cReleaseBus(I2CDriver *i2cp)
Releases exclusive access to the I2C bus.
BaseThermometer virtual methods table.
BaseBarometer virtual methods table.
#define objGetInstance(type, ip)
Returns the instance pointer starting from an interface pointer.
static msg_t baro_set_bias(void *ip, float *bp)
Set bias values for the BaseBarometer.
I2CDriver * i2cp
I2C driver associated to this LPS22HB.
#define LPS22HB_BARO_NUMBER_OF_AXES
LPS22HB barometer subsystem characteristics.
static msg_t baro_set_sensitivity(void *ip, float *sp)
Set sensitivity values for the BaseBarometer.
static msg_t thermo_reset_sensitivity(void *ip)
Reset sensitivity values for the BaseThermometer.
#define osalThreadSleepMilliseconds(msecs)
Delays the invoking thread for the specified number of milliseconds.
#define LPS22HB_THERMO_NUMBER_OF_AXES
LPS22HB thermometer subsystem characteristics.
void lps22hbStart(LPS22HBDriver *devp, const LPS22HBConfig *config)
Configures and activates LPS22HB Complex Driver peripheral.
void i2cStop(I2CDriver *i2cp)
Deactivates the I2C peripheral.
LPS22HB MEMS interface module header.
LPS22HB configuration structure.
Structure representing an I2C driver.
const struct BaseBarometerVMT * vmt
Virtual Methods Table.
LPS22HB virtual methods table.
static msg_t thermo_set_bias(void *ip, float *bp)
Set bias values for the BaseThermometer.
#define TIME_INFINITE
Infinite interval specification for all functions with a timeout specification.
#define osalDbgCheck(c)
Function parameters check.
static msg_t baro_read_raw(void *ip, int32_t axes[])
Retrieves raw data from the BaseBarometer.
BaseBarometer baro_if
Base barometer interface.
static msg_t baro_reset_sensitivity(void *ip)
Reset sensitivity values for the BaseBarometer.
lps22hb_sad_t
LPS22HB slave address.
#define MSG_OK
Normal wakeup message.
void lps22hbStop(LPS22HBDriver *devp)
Deactivates the LPS22HB Complex Driver peripheral.
static msg_t thermo_set_sensitivity(void *ip, float *sp)
Set sensitivity values for the BaseThermometer.
void lps22hbObjectInit(LPS22HBDriver *devp)
Initializes an instance.
#define lps22hbI2CWriteRegister(i2cp, sad, txbuf, n)
Writes a value into a register using I2C.
LPS22HB 2-axis barometer/thermometer class.
static msg_t baro_reset_bias(void *ip)
Reset bias values for the BaseBarometer.
#define osalDbgAssert(c, remark)
Condition assertion.
const I2CConfig * config
Current configuration data.
static msg_t thermo_reset_bias(void *ip)
Reset bias values for the BaseThermometer.
static msg_t lps22hbI2CReadRegister(I2CDriver *i2cp, lps22hb_sad_t sad, uint8_t reg, uint8_t *rxbuf, size_t n)
Reads registers value using I2C.
static msg_t thermo_read_raw(void *ip, int32_t axes[])
Retrieves raw data from the BaseThermometer.
BaseThermometer thermo_if
Base thermometer interface.
static size_t baro_get_axes_number(void *ip)
Return the number of axes of the BaseBarometer.
static msg_t thermo_read_cooked(void *ip, float *axis)
Retrieves cooked data from the BaseThermometer.
static size_t thermo_get_axes_number(void *ip)
Return the number of axes of the BaseThermometer.
const struct BaseThermometerVMT * vmt
Virtual Methods Table.