49 #if (LPS25H_USE_I2C) || defined(__DOXYGEN__) 64 uint8_t reg, uint8_t* rxbuf,
size_t n) {
67 txbuf |= LPS25H_SUB_MS;
88 uint8_t* txbuf,
size_t n) {
90 (*txbuf) |= LPS25H_SUB_MS;
136 "baro_read_raw(), invalid state");
139 "baro_read_raw(), channel not ready");
141 #if LPS25H_SHARED_I2C 144 devp->config->i2ccfg);
148 LPS25H_AD_PRESS_OUT_XL, buff, 3);
150 #if LPS25H_SHARED_I2C 155 *axes = buff[0] + (buff[1] << 8) + (buff[2] << 16);
188 "baro_read_cooked(), invalid state");
192 *axes = (raw * devp->barosensitivity) - devp->barobias;
222 "baro_set_bias(), invalid state");
224 devp->barobias = *bp;
248 "baro_reset_bias(), invalid state");
250 devp->barobias = LPS25H_BARO_SENS;
276 "baro_set_sensitivity(), invalid state");
278 devp->barosensitivity = *sp;
301 "baro_reset_sensitivity(), invalid state");
303 devp->barosensitivity = LPS25H_BARO_SENS;
348 "thermo_read_raw(), invalid state");
351 "thermo_read_raw(), channel not ready");
353 #if LPS25H_SHARED_I2C 356 devp->config->i2ccfg);
360 LPS25H_AD_TEMP_OUT_L, buff, 2);
362 #if LPS25H_SHARED_I2C 367 tmp = buff[0] + (buff[1] << 8);
368 *axes = (int32_t)tmp;
401 "thermo_read_cooked(), invalid state");
405 *axis = (raw * devp->thermosensitivity) - devp->thermobias;
432 "thermo_set_bias(), invalid state");
434 devp->thermobias = *bp;
459 "thermo_reset_bias(), invalid state");
461 devp->thermobias = LPS25H_THERMO_BIAS;
488 "thermo_set_sensitivity(), invalid state");
490 devp->thermosensitivity = *sp;
514 "thermo_reset_sensitivity(), invalid state");
516 devp->thermosensitivity = LPS25H_THERMO_SENS;
521 static const struct LPS25HVMT vmt_device = {
552 devp->
vmt = &vmt_device;
577 "lps25hStart(), invalid state");
579 devp->config = config;
583 cr[0] = LPS25H_AD_CTRL_REG1;
584 cr[1] = devp->config->outputdatarate | LPS25H_CTRL_REG1_PD;
585 #if LPS25H_USE_ADVANCED || defined(__DOXYGEN__) 586 cr[1] |= devp->config->blockdataupdate;
590 #if LPS25H_SHARED_I2C 598 #if LPS25H_SHARED_I2C 604 cr[0] = LPS25H_AD_RES_CONF;
606 #if LPS25H_USE_ADVANCED || defined(__DOXYGEN__) 607 cr[1] = devp->config->baroresolution | devp->config->thermoresolution;
611 #if LPS25H_SHARED_I2C 620 #if LPS25H_SHARED_I2C 624 if(devp->config->barosensitivity == NULL) {
625 devp->barosensitivity = LPS25H_BARO_SENS;
629 devp->barosensitivity = *(devp->config->barosensitivity);
632 if(devp->config->barobias == NULL) {
633 devp->barobias = LPS25H_BARO_BIAS;
637 devp->barobias = *(devp->config->barobias);
640 if(devp->config->thermosensitivity == NULL) {
641 devp->thermosensitivity = LPS25H_THERMO_SENS;
645 devp->thermosensitivity = *(devp->config->thermosensitivity);
648 if(devp->config->thermobias == NULL) {
649 devp->thermobias = LPS25H_THERMO_BIAS;
653 devp->thermobias = *(devp->config->thermobias);
675 "lps25hStop(), invalid state");
678 #if LPS25H_SHARED_I2C 681 (devp)->config->i2ccfg);
684 cr[0] = LPS25H_AD_CTRL_REG1;
690 #if LPS25H_SHARED_I2C LPS25H MEMS interface module header.
LPS25H 2-axis barometer/thermometer class.
static msg_t baro_set_bias(void *ip, float *bp)
Set bias values for the BaseBarometer.
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.
#define LPS25H_THERMO_NUMBER_OF_AXES
LPS25H thermometer subsystem characteristics.
I2CDriver * i2cp
I2C driver associated to this LPS25H.
void i2cStart(I2CDriver *i2cp, const I2CConfig *config)
Configures and activates the I2C peripheral.
LPS25H configuration structure.
static msg_t thermo_read_raw(void *ip, int32_t axes[])
Retrieves raw data from the BaseThermometer.
void lps25hStart(LPS25HDriver *devp, const LPS25HConfig *config)
Configures and activates LPS25H Complex Driver peripheral.
static msg_t baro_read_cooked(void *ip, float axes[])
Retrieves cooked data from the BaseBarometer.
static size_t thermo_get_axes_number(void *ip)
Return the number of axes of the BaseThermometer.
void i2cAcquireBus(I2CDriver *i2cp)
Gains exclusive access to the I2C bus.
BaseThermometer thermo_if
Base thermometer interface.
void i2cReleaseBus(I2CDriver *i2cp)
Releases exclusive access to the I2C bus.
static msg_t thermo_set_sensitivity(void *ip, float *sp)
Set sensitivity values for the BaseThermometer.
BaseThermometer virtual methods table.
static msg_t baro_reset_bias(void *ip)
Reset bias values for the BaseBarometer.
BaseBarometer virtual methods table.
#define objGetInstance(type, ip)
Returns the instance pointer starting from an interface pointer.
static msg_t thermo_set_bias(void *ip, float *bp)
Set bias values for the BaseThermometer.
#define osalThreadSleepMilliseconds(msecs)
Delays the invoking thread for the specified number of milliseconds.
void i2cStop(I2CDriver *i2cp)
Deactivates the I2C peripheral.
void lps25hObjectInit(LPS25HDriver *devp)
Initializes an instance.
Structure representing an I2C driver.
const struct BaseBarometerVMT * vmt
Virtual Methods Table.
#define TIME_INFINITE
Infinite interval specification for all functions with a timeout specification.
#define osalDbgCheck(c)
Function parameters check.
static msg_t baro_set_sensitivity(void *ip, float *sp)
Set sensitivity values for the BaseBarometer.
static msg_t baro_reset_sensitivity(void *ip)
Reset sensitivity values for the BaseBarometer.
LPS25H virtual methods table.
#define MSG_OK
Normal wakeup message.
static msg_t baro_read_raw(void *ip, int32_t axes[])
Retrieves raw data from the BaseBarometer.
static msg_t thermo_reset_sensitivity(void *ip)
Reset sensitivity values for the BaseThermometer.
static size_t baro_get_axes_number(void *ip)
Return the number of axes of the BaseBarometer.
static msg_t thermo_reset_bias(void *ip)
Reset bias values for the BaseThermometer.
void lps25hStop(LPS25HDriver *devp)
Deactivates the LPS25H Complex Driver peripheral.
lps25h_sad_t
LPS25H slave address.
static msg_t lps25hI2CWriteRegister(I2CDriver *i2cp, lps25h_sad_t sad, uint8_t *txbuf, size_t n)
Writes a value into a register using I2C.
static msg_t lps25hI2CReadRegister(I2CDriver *i2cp, lps25h_sad_t sad, uint8_t reg, uint8_t *rxbuf, size_t n)
Reads registers value using I2C.
#define osalDbgAssert(c, remark)
Condition assertion.
#define LPS25H_BARO_NUMBER_OF_AXES
LPS25H barometer subsystem characteristics.
const I2CConfig * config
Current configuration data.
BaseBarometer baro_if
Base barometer interface.
static msg_t thermo_read_cooked(void *ip, float *axis)
Retrieves cooked data from the BaseThermometer.
const struct LPS25HVMT * vmt
Virtual Methods Table.
const struct BaseThermometerVMT * vmt
Virtual Methods Table.