From 8887dbbde2e35d3ed21a8b5cee9be2a68bfe900c Mon Sep 17 00:00:00 2001 From: Rocco Marco Guglielmi Date: Fri, 9 Mar 2018 23:45:17 +0000 Subject: Updated HTS221 Driver and related demo git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11678 110e8d01-0319-4d1e-a829-52ad28d1bb01 --- os/ex/ST/hts221.c | 693 +++++++++++++++++++++++++++++++++++------------------- os/ex/ST/hts221.h | 398 ++++++++++++++++++++++++------- 2 files changed, 769 insertions(+), 322 deletions(-) (limited to 'os/ex') diff --git a/os/ex/ST/hts221.c b/os/ex/ST/hts221.c index 570726248..a426b2c9a 100644 --- a/os/ex/ST/hts221.c +++ b/os/ex/ST/hts221.c @@ -1,5 +1,5 @@ /* - ChibiOS - Copyright (C) 2016 Rocco Marco Guglielmi + ChibiOS - Copyright (C) 2016-2018 Rocco Marco Guglielmi This file is part of ChibiOS. @@ -53,7 +53,6 @@ /* Driver local functions. */ /*===========================================================================*/ -#if (HTS221_USE_I2C) || defined(__DOXYGEN__) /** * @brief Reads registers value using I2C. * @pre The I2C interface must be initialized and the driver started. @@ -63,9 +62,10 @@ * @param[out] rxbuf pointer to an output buffer * @param[in] n number of consecutive register to read * @return the operation status. + * * @notapi */ -msg_t hts221I2CReadRegister(I2CDriver *i2cp, uint8_t reg, uint8_t* rxbuf, +static msg_t hts221I2CReadRegister(I2CDriver *i2cp, uint8_t reg, uint8_t* rxbuf, size_t n) { uint8_t txbuf = reg; if (n > 1) @@ -85,31 +85,32 @@ msg_t hts221I2CReadRegister(I2CDriver *i2cp, uint8_t reg, uint8_t* rxbuf, * @param[in] n size of txbuf less one (not considering the first * element) * @return the operation status. + * * @notapi */ -msg_t hts221I2CWriteRegister(I2CDriver *i2cp, uint8_t* txbuf, size_t n) { +static msg_t hts221I2CWriteRegister(I2CDriver *i2cp, uint8_t* txbuf, size_t n) { if (n > 1) (*txbuf) |= HTS221_SUB_MS; return i2cMasterTransmitTimeout(i2cp, HTS221_SAD, txbuf, n + 1, NULL, 0, TIME_INFINITE); } -#endif /* HTS221_USE_I2C */ /** - * @brief Compute biases and sensitivities starting from data stored in + * @brief Computes biases and sensitivities starting from data stored in * calibration registers. - * @notapi + * @note Factory bias and sensitivity values are stored into the driver + * structure. * * @param[in] devp pointer to the HTS221 interface - * @param[in] flag flag to select parameters * @return the operation status. + * + * @notapi */ -msg_t hts221Calibrate(HTS221Driver *devp, uint8_t flag) { +static msg_t hts221Calibrate(HTS221Driver *devp) { msg_t msg; uint8_t calib[16], H0_rH_x2, H1_rH_x2, msb; int16_t H0_T0_OUT, H1_T0_OUT, T0_degC_x8, T1_degC_x8, T0_OUT, T1_OUT; - float sens; #if HTS221_SHARED_I2C i2cAcquireBus(devp->config->i2cp); @@ -132,6 +133,7 @@ msg_t hts221Calibrate(HTS221Driver *devp, uint8_t flag) { H1_T0_OUT += calib[11] << 8; T0_degC_x8 = calib[2]; + /* Completing T0_degC_x8 value */ msb = (calib[5] & HTS221_SEL(0x03, 0)); if (msb & HTS221_SEL(0x01, 1)) { @@ -152,277 +154,465 @@ msg_t hts221Calibrate(HTS221Driver *devp, uint8_t flag) { T1_OUT = calib[14]; T1_OUT += calib[15] << 8; - sens = ((float)H1_rH_x2 - (float)H0_rH_x2) / - (2.0f * ((float)H1_T0_OUT - (float)H0_T0_OUT)); - - if (flag & HTS221_FLAG_HYGRO_SENS) - devp->sensitivity[0] = sens; - - if (flag & HTS221_FLAG_HYGRO_BIAS) - devp->bias[0] = (sens * (float)H0_T0_OUT) - - ((float)H0_rH_x2 / 2.0f); - - sens = ((float)T1_degC_x8 - (float)T0_degC_x8) / - (8.0f * ((float)T1_OUT - (float)T0_OUT)); - - if (flag & HTS221_FLAG_THERMO_SENS) - devp->sensitivity[1] = sens; - - if (flag & HTS221_FLAG_THERMO_BIAS) - devp->bias[1] = (sens * (float)T0_OUT) - - ((float)T0_degC_x8 / 8.0f); + devp->hygrofactorysensitivity = ((float)H1_rH_x2 - (float)H0_rH_x2) / + (((float)H1_T0_OUT - (float)H0_T0_OUT) * 2.0f); + + + devp->hygrofactorybias = (devp->hygrofactorysensitivity * (float)H0_T0_OUT) - + ((float)H0_rH_x2 / 2.0f); + + devp->thermofactorysensitivity = ((float)T1_degC_x8 - (float)T0_degC_x8) / + (((float)T1_OUT - (float)T0_OUT) * 8.0f); + + devp->thermofactorybias = (devp->thermofactorysensitivity * (float)T0_OUT) - + ((float)T0_degC_x8 / 8.0f); return msg; } -/* - * Interface implementation. +/** + * @brief Return the number of axes of the BaseHygrometer. + * + * @param[in] ip pointer to @p BaseHygrometer interface. + * + * @return the number of axes. */ static size_t hygro_get_axes_number(void *ip) { - - osalDbgCheck(ip != NULL); + (void)ip; + return HTS221_HYGRO_NUMBER_OF_AXES; } -static size_t thermo_get_axes_number(void *ip) { - - osalDbgCheck(ip != NULL); - return HTS221_THERMO_NUMBER_OF_AXES; -} - -static size_t sens_get_axes_number(void *ip) { - - osalDbgCheck(ip != NULL); - return (thermo_get_axes_number(ip) + hygro_get_axes_number(ip)); -} - -static msg_t hygro_read_raw(void *ip, int32_t* axis) { +/** + * @brief Retrieves raw data from the BaseHygrometer. + * @note This data is retrieved from MEMS register without any algebraical + * manipulation. + * @note The axes array must be at least the same size of the + * BaseHygrometer axes number. + * + * @param[in] ip pointer to @p BaseHygrometer interface. + * @param[out] axes a buffer which would be filled with raw data. + * + * @return The operation status. + * @retval MSG_OK if the function succeeded. + * @retval MSG_RESET if one or more I2C errors occurred, the errors can + * be retrieved using @p i2cGetErrors(). + * @retval MSG_TIMEOUT if a timeout occurred before operation end. + */ +static msg_t hygro_read_raw(void *ip, int32_t axes[]) { + HTS221Driver* devp; + uint8_t buff[2]; int16_t tmp; - uint8_t buff[2]; - msg_t msg = MSG_OK; + msg_t msg; + + osalDbgCheck((ip != NULL) && (axes != NULL)); - *axis = 0; + /* Getting parent instance pointer.*/ + devp = objGetInstance(HTS221Driver*, (BaseHygrometer*)ip); - osalDbgCheck((ip != NULL) && (axis != NULL)); - osalDbgAssert((((HTS221Driver *)ip)->state == HTS221_READY), + osalDbgAssert((devp->state == HTS221_READY), "hygro_read_raw(), invalid state"); -#if HTS221_USE_I2C - osalDbgAssert((((HTS221Driver *)ip)->config->i2cp->state == I2C_READY), + + osalDbgAssert((devp->config->i2cp->state == I2C_READY), "hygro_read_raw(), channel not ready"); #if HTS221_SHARED_I2C - i2cAcquireBus(((HTS221Driver *)ip)->config->i2cp); - i2cStart(((HTS221Driver *)ip)->config->i2cp, - ((HTS221Driver *)ip)->config->i2ccfg); + i2cAcquireBus(devp->config->i2cp); + i2cStart(devp->config->i2cp, + devp->config->i2ccfg); #endif /* HTS221_SHARED_I2C */ - msg = hts221I2CReadRegister(((HTS221Driver *)ip)->config->i2cp, - HTS221_AD_HUMIDITY_OUT_L, buff, 2); + msg = hts221I2CReadRegister(devp->config->i2cp, HTS221_AD_HUMIDITY_OUT_L, + buff, 2); #if HTS221_SHARED_I2C - i2cReleaseBus(((HTS221Driver *)ip)->config->i2cp); + i2cReleaseBus(devp->config->i2cp); #endif /* HTS221_SHARED_I2C */ -#endif /* HTS221_USE_I2C */ if (msg == MSG_OK) { tmp = buff[0] + (buff[1] << 8); - *axis = (int32_t)tmp; + *axes = (int32_t)tmp; } return msg; } -static msg_t thermo_read_raw(void *ip, int32_t axis[]) { - int16_t tmp; - uint8_t buff[2]; - msg_t msg = MSG_OK; +/** + * @brief Retrieves cooked data from the BaseHygrometer. + * @note This data is manipulated according to the formula + * cooked = (raw * sensitivity) - bias. + * @note Final data is expressed as %rH. + * @note The axes array must be at least the same size of the + * BaseHygrometer axes number. + * + * @param[in] ip pointer to @p BaseHygrometer interface. + * @param[out] axes a buffer which would be filled with cooked data. + * + * @return The operation status. + * @retval MSG_OK if the function succeeded. + * @retval MSG_RESET if one or more I2C errors occurred, the errors can + * be retrieved using @p i2cGetErrors(). + * @retval MSG_TIMEOUT if a timeout occurred before operation end. + */ +static msg_t hygro_read_cooked(void *ip, float axes[]) { + HTS221Driver* devp; + int32_t raw; + msg_t msg; - *axis = 0.0f; + osalDbgCheck((ip != NULL) && (axes != NULL)); - osalDbgCheck((ip != NULL) && (axis != NULL)); - osalDbgAssert((((HTS221Driver *)ip)->state == HTS221_READY), - "thermo_read_raw(), invalid state"); + /* Getting parent instance pointer.*/ + devp = objGetInstance(HTS221Driver*, (BaseHygrometer*)ip); -#if HTS221_USE_I2C - osalDbgAssert((((HTS221Driver *)ip)->config->i2cp->state == I2C_READY), - "thermo_read_raw(), channel not ready"); - -#if HTS221_SHARED_I2C - i2cAcquireBus(((HTS221Driver *)ip)->config->i2cp); - i2cStart(((HTS221Driver *)ip)->config->i2cp, - ((HTS221Driver *)ip)->config->i2ccfg); -#endif /* HTS221_SHARED_I2C */ + osalDbgAssert((devp->state == HTS221_READY), + "hygro_read_cooked(), invalid state"); - msg = hts221I2CReadRegister(((HTS221Driver *)ip)->config->i2cp, - HTS221_AD_TEMP_OUT_L, buff, 2); - -#if HTS221_SHARED_I2C - i2cReleaseBus(((HTS221Driver *)ip)->config->i2cp); -#endif /* HTS221_SHARED_I2C */ -#endif /* HTS221_USE_I2C */ + msg = hygro_read_raw(ip, &raw); - if (msg == MSG_OK) { - tmp = buff[0] + (buff[1] << 8); - *axis = (int32_t)tmp; - } + *axes = (raw * devp->hygrosensitivity) - devp->hygrobias; + return msg; } -static msg_t sens_read_raw(void *ip, int32_t axes[]) { - int32_t* bp = axes; - msg_t msg; - msg = hygro_read_raw(ip, bp); - if (msg != MSG_OK){ - return msg; - } - bp += HTS221_HYGRO_NUMBER_OF_AXES; - return thermo_read_raw(ip, bp); -} +/** + * @brief Set bias values for the BaseHygrometer. + * @note Bias must be expressed as %rH. + * @note The bias buffer must be at least the same size of the + * BaseHygrometer axes number. + * + * @param[in] ip pointer to @p BaseHygrometer interface. + * @param[in] bp a buffer which contains biases. + * + * @return The operation status. + * @retval MSG_OK if the function succeeded. + * @retval MSG_RESET if one or more I2C errors occurred, the errors can + * be retrieved using @p i2cGetErrors(). + * @retval MSG_TIMEOUT if a timeout occurred before operation end. + */ +static msg_t hygro_set_bias(void *ip, float *bp) { + HTS221Driver* devp; + msg_t msg = MSG_OK; + + osalDbgCheck((ip != NULL) && (bp != NULL)); -static msg_t hygro_read_cooked(void *ip, float* axis) { - int32_t raw; - msg_t msg; + /* Getting parent instance pointer.*/ + devp = objGetInstance(HTS221Driver*, (BaseHygrometer*)ip); + + osalDbgAssert((devp->state == HTS221_READY), + "hygro_set_bias(), invalid state"); - osalDbgCheck((ip != NULL) && (axis != NULL)); - osalDbgAssert((((HTS221Driver *)ip)->state == HTS221_READY), - "hygro_read_cooked(), invalid state"); + devp->hygrobias = *bp; + return msg; +} - msg = hygro_read_raw(ip, &raw); +/** + * @brief Reset bias values for the BaseHygrometer. + * @note Default biases value are obtained from device datasheet when + * available otherwise they are considered zero. + * + * @param[in] ip pointer to @p BaseHygrometer interface. + * + * @return The operation status. + * @retval MSG_OK if the function succeeded. + */ +static msg_t hygro_reset_bias(void *ip) { + HTS221Driver* devp; + msg_t msg = MSG_OK; + + osalDbgCheck(ip != NULL); - *axis = raw * ((HTS221Driver *)ip)->sensitivity[0]; - *axis -= ((HTS221Driver *)ip)->bias[0]; + /* Getting parent instance pointer.*/ + devp = objGetInstance(HTS221Driver*, (BaseHygrometer*)ip); + + osalDbgAssert((devp->state == HTS221_READY), + "hygro_reset_bias(), invalid state"); + + devp->hygrobias = devp->hygrofactorybias; return msg; } -static msg_t thermo_read_cooked(void *ip, float* axis) { - int32_t raw; - msg_t msg; +/** + * @brief Set sensitivity values for the BaseHygrometer. + * @note Sensitivity must be expressed as %rH/LSB. + * @note The sensitivity buffer must be at least the same size of the + * BaseHygrometer axes number. + * + * @param[in] ip pointer to @p BaseHygrometer interface. + * @param[in] sp a buffer which contains sensitivities. + * + * @return The operation status. + * @retval MSG_OK if the function succeeded. + */ +static msg_t hygro_set_sensitivity(void *ip, float *sp) { + HTS221Driver* devp; + msg_t msg = MSG_OK; + + osalDbgCheck((ip != NULL) && (sp != NULL)); - osalDbgCheck((ip != NULL) && (axis != NULL)); + /* Getting parent instance pointer.*/ + devp = objGetInstance(HTS221Driver*, (BaseHygrometer*)ip); + + osalDbgAssert((devp->state == HTS221_READY), + "hygro_set_sensitivity(), invalid state"); - osalDbgAssert((((HTS221Driver *)ip)->state == HTS221_READY), - "thermo_read_cooked(), invalid state"); + devp->hygrosensitivity = *sp; + return msg; +} - msg = thermo_read_raw(ip, &raw); +/** + * @brief Reset sensitivity values for the BaseHygrometer. + * @note Default sensitivities value are obtained from device datasheet. + * + * @param[in] ip pointer to @p BaseHygrometer interface. + * + * @return The operation status. + * @retval MSG_OK if the function succeeded. + */ +static msg_t hygro_reset_sensitivity(void *ip) { + HTS221Driver* devp; + msg_t msg = MSG_OK; + + osalDbgCheck(ip != NULL); - *axis = raw * ((HTS221Driver *)ip)->sensitivity[1]; - *axis -= ((HTS221Driver *)ip)->bias[1]; + /* Getting parent instance pointer.*/ + devp = objGetInstance(HTS221Driver*, (BaseHygrometer*)ip); + + osalDbgAssert((devp->state == HTS221_READY), + "hygro_reset_sensitivity(), invalid state"); + + devp->hygrosensitivity = devp->hygrofactorysensitivity; return msg; } -static msg_t sens_read_cooked(void *ip, float axes[]) { - float *dp = axes; - msg_t msg; +/** + * @brief Return the number of axes of the BaseThermometer. + * + * @param[in] ip pointer to @p BaseThermometer interface. + * + * @return the number of axes. + */ +static size_t thermo_get_axes_number(void *ip) { + (void)ip; + + return HTS221_THERMO_NUMBER_OF_AXES; +} +/** + * @brief Retrieves raw data from the BaseThermometer. + * @note This data is retrieved from MEMS register without any algebraical + * manipulation. + * @note The axes array must be at least the same size of the + * BaseThermometer axes number. + * + * @param[in] ip pointer to @p BaseThermometer interface. + * @param[out] axes a buffer which would be filled with raw data. + * + * @return The operation status. + * @retval MSG_OK if the function succeeded. + * @retval MSG_RESET if one or more I2C errors occurred, the errors can + * be retrieved using @p i2cGetErrors(). + * @retval MSG_TIMEOUT if a timeout occurred before operation end. + */ +static msg_t thermo_read_raw(void *ip, int32_t axes[]) { + HTS221Driver* devp; + int16_t tmp; + uint8_t buff[2]; + msg_t msg; + osalDbgCheck((ip != NULL) && (axes != NULL)); - osalDbgAssert((((HTS221Driver *)ip)->state == HTS221_READY), - "sens_read_cooked(), invalid state"); + /* Getting parent instance pointer.*/ + devp = objGetInstance(HTS221Driver*, (BaseThermometer*)ip); + + osalDbgAssert((devp->state == HTS221_READY), + "thermo_read_raw(), invalid state"); + + osalDbgAssert((devp->config->i2cp->state == I2C_READY), + "thermo_read_raw(), channel not ready"); + +#if HTS221_SHARED_I2C + i2cAcquireBus(devp->config->i2cp); + i2cStart(devp->config->i2cp, + devp->config->i2ccfg); +#endif /* HTS221_SHARED_I2C */ - msg = hygro_read_cooked(ip, dp); - if (msg != MSG_OK) - return msg; - dp += HTS221_THERMO_NUMBER_OF_AXES; - return thermo_read_cooked(ip, dp); + msg = hts221I2CReadRegister(devp->config->i2cp, HTS221_AD_TEMP_OUT_L, + buff, 2); + +#if HTS221_SHARED_I2C + i2cReleaseBus(devp->config->i2cp); +#endif /* HTS221_SHARED_I2C */ + + if (msg == MSG_OK) { + tmp = buff[0] + (buff[1] << 8); + *axes = (int32_t)tmp; + } + return msg; } -static msg_t hygro_set_bias(void *ip, float *bp) { - osalDbgCheck((ip != NULL) && (bp != NULL)); +/** + * @brief Retrieves cooked data from the BaseThermometer. + * @note This data is manipulated according to the formula + * cooked = (raw * sensitivity) - bias. + * @note Final data is expressed as °C. + * @note The axes array must be at least the same size of the + * BaseThermometer axes number. + * + * @param[in] ip pointer to @p BaseThermometer interface. + * @param[out] axes a buffer which would be filled with cooked data. + * + * @return The operation status. + * @retval MSG_OK if the function succeeded. + * @retval MSG_RESET if one or more I2C errors occurred, the errors can + * be retrieved using @p i2cGetErrors(). + * @retval MSG_TIMEOUT if a timeout occurred before operation end. + */ +static msg_t thermo_read_cooked(void *ip, float* axis) { + HTS221Driver* devp; + int32_t raw; + msg_t msg; - osalDbgAssert((((HTS221Driver *)ip)->state == HTS221_READY) || - (((HTS221Driver *)ip)->state == HTS221_STOP), - "hygro_set_bias(), invalid state"); + osalDbgCheck((ip != NULL) && (axis != NULL)); - ((HTS221Driver *)ip)->bias[0] = *bp; - return MSG_OK; -} + /* Getting parent instance pointer.*/ + devp = objGetInstance(HTS221Driver*, (BaseThermometer*)ip); + + osalDbgAssert((devp->state == HTS221_READY), + "thermo_read_cooked(), invalid state"); -static msg_t thermo_set_bias(void *ip, float *bp) { - osalDbgCheck((ip != NULL) && (bp != NULL)); + msg = thermo_read_raw(devp, &raw); - osalDbgAssert((((HTS221Driver *)ip)->state == HTS221_READY) || - (((HTS221Driver *)ip)->state == HTS221_STOP), - "thermo_set_bias(), invalid state"); + *axis = (raw * devp->thermosensitivity) - devp->thermobias; - ((HTS221Driver *)ip)->bias[1] = *bp; - return MSG_OK; + return msg; } -static msg_t hygro_reset_bias(void *ip) { - osalDbgCheck(ip != NULL); - - osalDbgAssert((((HTS221Driver *)ip)->state == HTS221_READY) || - (((HTS221Driver *)ip)->state == HTS221_STOP), - "hygro_reset_bias(), invalid state"); +/** + * @brief Set bias values for the BaseThermometer. + * @note Bias must be expressed as °C. + * @note The bias buffer must be at least the same size of the + * BaseThermometer axes number. + * + * @param[in] ip pointer to @p BaseThermometer interface. + * @param[in] bp a buffer which contains biases. + * + * @return The operation status. + * @retval MSG_OK if the function succeeded. + */ +static msg_t thermo_set_bias(void *ip, float *bp) { + HTS221Driver* devp; + msg_t msg = MSG_OK; + + osalDbgCheck((ip != NULL) && (bp != NULL)); - return hts221Calibrate(ip, HTS221_FLAG_HYGRO_BIAS); + /* Getting parent instance pointer.*/ + devp = objGetInstance(HTS221Driver*, (BaseThermometer*)ip); + + osalDbgAssert((devp->state == HTS221_READY), + "thermo_set_bias(), invalid state"); + + devp->thermobias = *bp; + + return msg; } +/** + * @brief Reset bias values for the BaseThermometer. + * @note Default biases value are obtained from device datasheet when + * available otherwise they are considered zero. + * + * @param[in] ip pointer to @p BaseThermometer interface. + * + * @return The operation status. + * @retval MSG_OK if the function succeeded. + */ static msg_t thermo_reset_bias(void *ip) { + HTS221Driver* devp; + msg_t msg = MSG_OK; + osalDbgCheck(ip != NULL); - osalDbgAssert((((HTS221Driver *)ip)->state == HTS221_READY) || - (((HTS221Driver *)ip)->state == HTS221_STOP), + /* Getting parent instance pointer.*/ + devp = objGetInstance(HTS221Driver*, (BaseThermometer*)ip); + + osalDbgAssert((devp->state == HTS221_READY), "thermo_reset_bias(), invalid state"); - return hts221Calibrate(ip, HTS221_FLAG_THERMO_BIAS); -} - -static msg_t hygro_set_sensitivity(void *ip, float *sp) { - osalDbgCheck((ip != NULL) && (sp != NULL)); - - osalDbgAssert((((HTS221Driver *)ip)->state == HTS221_READY) || - (((HTS221Driver *)ip)->state == HTS221_STOP), - "hygro_set_sensitivity(), invalid state"); - - ((HTS221Driver *)ip)->sensitivity[0] = *sp; - return MSG_OK; + devp->thermobias = devp->thermofactorybias; + + return msg; } +/** + * @brief Set sensitivity values for the BaseThermometer. + * @note Sensitivity must be expressed as °C/LSB. + * @note The sensitivity buffer must be at least the same size of the + * BaseThermometer axes number. + * + * @param[in] ip pointer to @p BaseThermometer interface. + * @param[in] sp a buffer which contains sensitivities. + * + * @return The operation status. + * @retval MSG_OK if the function succeeded. + */ static msg_t thermo_set_sensitivity(void *ip, float *sp) { + HTS221Driver* devp; + msg_t msg = MSG_OK; + osalDbgCheck((ip != NULL) && (sp != NULL)); - osalDbgAssert((((HTS221Driver *)ip)->state == HTS221_READY) || - (((HTS221Driver *)ip)->state == HTS221_STOP), + /* Getting parent instance pointer.*/ + devp = objGetInstance(HTS221Driver*, (BaseThermometer*)ip); + + osalDbgAssert((devp->state == HTS221_READY), "thermo_set_sensitivity(), invalid state"); - - return hts221Calibrate(ip, HTS221_FLAG_THERMO_SENS); -} - -static msg_t hygro_reset_sensitivity(void *ip) { - osalDbgCheck(ip != NULL); - - osalDbgAssert((((HTS221Driver *)ip)->state == HTS221_READY) || - (((HTS221Driver *)ip)->state == HTS221_STOP), - "hygro_reset_sensitivity(), invalid state"); - - return hts221Calibrate(ip, HTS221_FLAG_HYGRO_SENS); + + devp->thermosensitivity = *sp; + + return msg; } +/** + * @brief Reset sensitivity values for the BaseThermometer. + * @note Default sensitivities value are obtained from device datasheet. + * + * @param[in] ip pointer to @p BaseThermometer interface. + * + * @return The operation status. + * @retval MSG_OK if the function succeeded. + */ static msg_t thermo_reset_sensitivity(void *ip) { + HTS221Driver* devp; + msg_t msg = MSG_OK; + osalDbgCheck(ip != NULL); - osalDbgAssert((((HTS221Driver *)ip)->state == HTS221_READY) || - (((HTS221Driver *)ip)->state == HTS221_STOP), + /* Getting parent instance pointer.*/ + devp = objGetInstance(HTS221Driver*, (BaseThermometer*)ip); + + osalDbgAssert((devp->state == HTS221_READY), "thermo_reset_sensitivity(), invalid state"); - ((HTS221Driver *)ip)->sensitivity[1] = HTS221_THERMO_SENS; - return MSG_OK; + devp->thermosensitivity = devp->thermofactorysensitivity; + + return msg; } -static const struct BaseSensorVMT vmt_sensor = { - sens_get_axes_number, sens_read_raw, sens_read_cooked +static const struct HTS221VMT vmt_device = { + (size_t)0 }; -static const struct HTS221HygrometerVMT vmt_hygrometer = { +static const struct BaseHygrometerVMT vmt_hygrometer = { + sizeof(struct HTS221VMT*), hygro_get_axes_number, hygro_read_raw, hygro_read_cooked, - hygro_set_bias, hygro_reset_bias, - hygro_set_sensitivity, hygro_reset_sensitivity + hygro_set_bias, hygro_reset_bias, hygro_set_sensitivity, + hygro_reset_sensitivity }; -static const struct HTS221ThermometerVMT vmt_thermometer = { +static const struct BaseThermometerVMT vmt_thermometer = { + sizeof(struct HTS221VMT*) + sizeof(BaseHygrometer), thermo_get_axes_number, thermo_read_raw, thermo_read_cooked, - thermo_set_bias, thermo_reset_bias, - thermo_set_sensitivity, thermo_reset_sensitivity + thermo_set_bias, thermo_reset_bias, thermo_set_sensitivity, + thermo_reset_sensitivity }; /*===========================================================================*/ @@ -438,15 +628,19 @@ static const struct HTS221ThermometerVMT vmt_thermometer = { */ void hts221ObjectInit(HTS221Driver *devp) { - devp->vmt_sensor = &vmt_sensor; - devp->vmt_hygrometer = &vmt_hygrometer; - devp->vmt_thermometer = &vmt_thermometer; + devp->vmt = &vmt_device; + devp->hygro_if.vmt = &vmt_hygrometer; + devp->thermo_if.vmt = &vmt_thermometer; + devp->config = NULL; - devp->state = HTS221_STOP; - devp->bias[0] = 0.0; - devp->bias[1] = 0.0; - devp->sensitivity[0] = 0.0; - devp->sensitivity[1] = 0.0; + + devp->hygroaxes = HTS221_HYGRO_NUMBER_OF_AXES; + devp->thermoaxes = HTS221_THERMO_NUMBER_OF_AXES; + + devp->hygrobias = 0.0f; + devp->thermobias = 0.0f; + + devp->state = HTS221_STOP; } /** @@ -462,11 +656,53 @@ void hts221Start(HTS221Driver *devp, const HTS221Config *config) { osalDbgCheck((devp != NULL) && (config != NULL)); osalDbgAssert((devp->state == HTS221_STOP) || (devp->state == HTS221_READY), - "hts221Start(), invalid state"); + "hts221Start(), invalid state"); + devp->config = config; + +#if HTS221_SHARED_I2C + i2cAcquireBus(devp->config->i2cp); +#endif /* HTS221_SHARED_I2C */ + + i2cStart(devp->config->i2cp, devp->config->i2ccfg); + hts221Calibrate(devp); + +#if HTS221_SHARED_I2C + i2cReleaseBus(devp->config->i2cp); +#endif /* HTS221_SHARED_I2C */ + + if(devp->config->hygrosensitivity == NULL) { + devp->hygrosensitivity = devp->hygrofactorysensitivity; + } + else{ + /* Taking hygrometer sensitivity from user configurations */ + devp->hygrosensitivity = *(devp->config->hygrosensitivity); + } + + if(devp->config->hygrobias == NULL) { + devp->hygrobias = devp->hygrofactorybias; + } + else{ + /* Taking hygrometer bias from user configurations */ + devp->hygrobias = *(devp->config->hygrobias); + } -#if HTS221_USE_I2C + if(devp->config->thermosensitivity == NULL) { + devp->thermosensitivity = devp->thermofactorysensitivity; + } + else{ + /* Taking thermometer sensitivity from user configurations */ + devp->thermosensitivity = *(devp->config->thermosensitivity); + } + if(devp->config->thermobias == NULL) { + devp->thermobias = devp->thermofactorybias; + } + else{ + /* Taking thermometer bias from user configurations */ + devp->thermobias = *(devp->config->thermobias); + } + /* Control register 1 configuration block.*/ { cr[0] = HTS221_AD_CTRL_REG1; @@ -475,16 +711,15 @@ void hts221Start(HTS221Driver *devp, const HTS221Config *config) { cr[1] |= devp->config->blockdataupdate; #endif -#if HTS221_SHARED_I2C - i2cAcquireBus((devp)->config->i2cp); +#if HTS221_SHARED_I2C + i2cAcquireBus(devp->config->i2cp); + i2cStart(devp->config->i2cp, devp->config->i2ccfg); #endif /* HTS221_SHARED_I2C */ - i2cStart((devp)->config->i2cp, - (devp)->config->i2ccfg); hts221I2CWriteRegister(devp->config->i2cp, cr, 1); -#if HTS221_SHARED_I2C - i2cReleaseBus((devp)->config->i2cp); +#if HTS221_SHARED_I2C + i2cReleaseBus(devp->config->i2cp); #endif /* HTS221_SHARED_I2C */ } @@ -493,39 +728,20 @@ void hts221Start(HTS221Driver *devp, const HTS221Config *config) { cr[0] = HTS221_AD_AV_CONF; cr[1] = 0x05; #if HTS221_USE_ADVANCED || defined(__DOXYGEN__) - cr[1] = devp->config->reshumidity | devp->config->restemperature; + cr[1] = devp->config->hygroresolution | devp->config->thermoresolution; #endif -#if HTS221_SHARED_I2C - i2cAcquireBus((devp)->config->i2cp); - i2cStart((devp)->config->i2cp, - (devp)->config->i2ccfg); + +#if HTS221_SHARED_I2C + i2cAcquireBus(devp->config->i2cp); + i2cStart(devp->config->i2cp, devp->config->i2ccfg); #endif /* HTS221_SHARED_I2C */ hts221I2CWriteRegister(devp->config->i2cp, cr, 1); -#if HTS221_SHARED_I2C - i2cReleaseBus((devp)->config->i2cp); +#if HTS221_SHARED_I2C + i2cReleaseBus(devp->config->i2cp); #endif /* HTS221_SHARED_I2C */ } -#endif /* HTS221_USE_I2C */ - - if (devp->config->sensitivity == NULL) { - hts221Calibrate(devp, HTS221_FLAG_HYGRO_SENS | HTS221_FLAG_THERMO_SENS); - } - else{ - /* Taking Sensitivity from user configurations */ - devp->sensitivity[0] = devp->config->sensitivity[0]; - devp->sensitivity[1] = devp->config->sensitivity[1]; - } - - if (devp->config->bias == NULL) { - hts221Calibrate(devp, HTS221_FLAG_HYGRO_BIAS | HTS221_FLAG_THERMO_BIAS); - } - else { - /* Taking Bias from user configurations */ - devp->bias[0] = devp->config->bias[0]; - devp->bias[1] = devp->config->bias[1]; - } /* This is the MEMS transient recovery time */ osalThreadSleepMilliseconds(5); @@ -549,21 +765,20 @@ void hts221Stop(HTS221Driver *devp) { "hts221Stop(), invalid state"); if (devp->state == HTS221_READY) { -#if (HTS221_USE_I2C) -#if HTS221_SHARED_I2C - i2cAcquireBus((devp)->config->i2cp); - i2cStart((devp)->config->i2cp, (devp)->config->i2ccfg); + +#if HTS221_SHARED_I2C + i2cAcquireBus(devp->config->i2cp); + i2cStart(devp->config->i2cp, devp->config->i2ccfg); #endif /* HTS221_SHARED_I2C */ cr[0] = HTS221_AD_CTRL_REG1; cr[1] = 0; hts221I2CWriteRegister(devp->config->i2cp, cr, 1); - i2cStop((devp)->config->i2cp); -#if HTS221_SHARED_I2C - i2cReleaseBus((devp)->config->i2cp); + i2cStop(devp->config->i2cp); +#if HTS221_SHARED_I2C + i2cReleaseBus(devp->config->i2cp); #endif /* HTS221_SHARED_I2C */ -#endif /* HTS221_USE_I2C */ } devp->state = HTS221_STOP; } diff --git a/os/ex/ST/hts221.h b/os/ex/ST/hts221.h index 9f47aaea4..c6e595fb7 100644 --- a/os/ex/ST/hts221.h +++ b/os/ex/ST/hts221.h @@ -1,5 +1,5 @@ /* - ChibiOS - Copyright (C) 2016 Rocco Marco Guglielmi + ChibiOS - Copyright (C) 2016-2018 Rocco Marco Guglielmi This file is part of ChibiOS. @@ -44,7 +44,7 @@ /** * @brief HTS221 driver version string. */ -#define EX_HTS221_VERSION "1.0.1" +#define EX_HTS221_VERSION "1.0.2" /** * @brief HTS221 driver version major number. @@ -59,21 +59,32 @@ /** * @brief HTS221 driver version patch number. */ -#define EX_HTS221_PATCH 1 +#define EX_HTS221_PATCH 2 /** @} */ /** - * @brief HTS221 characteristics. + * @brief HTS221 hygrometer subsystem characteristics. + * @note Sensitivity is expressed as %rH/LSB whereas %rH stand for percentage + * of relative humidity. * * @{ */ #define HTS221_HYGRO_NUMBER_OF_AXES 1U -#define HTS221_THERMO_NUMBER_OF_AXES 1U -#define HTS221_HYGRO_SENS 256.0f /**< LSB/%rH */ -#define HTS221_THERMO_SENS 64.0f /**< LSB/°C */ +#define HTS221_HYGRO_SENS 0.00390625f /** @} */ +/** + * @brief HTS221 thermometer subsystem characteristics. + * @note Sensitivity is expressed as °C/LSB whereas. + * + * @{ + */ +#define HTS221_THERMO_NUMBER_OF_AXES 1U + +#define HTS221_THERMO_SENS 00015625f +/** @} */ + /** * @name HTS221 communication interfaces related bit masks * @{ @@ -154,7 +165,7 @@ /** @} */ /*===========================================================================*/ -/* Driver pre-compile time settings. */ +/* Driver pre-thermoile time settings. */ /*===========================================================================*/ /** @@ -194,7 +205,7 @@ * on each transaction. * @note The default is @p FALSE. Requires I2C_USE_MUTUAL_EXCLUSION */ -#if !defined(HTS221_SHARED_SPI) || defined(__DOXYGEN__) +#if !defined(HTS221_SHARED_I2C) || defined(__DOXYGEN__) #define HTS221_SHARED_I2C FALSE #endif /** @} */ @@ -223,10 +234,6 @@ #error "HTS221_SHARED_I2C requires I2C_USE_MUTUAL_EXCLUSION" #endif -/* - * TODO: Add SPI support. - */ - /*===========================================================================*/ /* Driver data structures and types. */ /*===========================================================================*/ @@ -235,6 +242,11 @@ * @name HTS221 data structures and types. * @{ */ +/** + * @brief Structure representing a HTS221 driver. + */ +typedef struct HTS221Driver HTS221Driver; + /** * @brief HTS221 output data rate and bandwidth. */ @@ -316,17 +328,21 @@ typedef struct { const I2CConfig *i2ccfg; #endif /* HTS221_USE_I2C */ /** - * @brief HTS221 initial sensitivity. - * @note Value are respectively related to hygrometer - * and thermometer. + * @brief HTS221 hygrometer subsystem initial sensitivity. + */ + float *hygrosensitivity; + /** + * @brief HTS221 hygrometer subsystem initial bias. + */ + float *hygrobias; + /** + * @brief HTS221 thermometer subsystem initial sensitivity. */ - float* sensitivity; + float *thermosensitivity; /** - * @brief HTS221 initial bias. - * @note Value are respectively related to hygrometer - * and thermometer. + * @brief HTS221 thermometer subsystem initial bias. */ - float* bias; + float *thermobias; /** * @brief HTS221 output data rate selection. */ @@ -337,104 +353,320 @@ typedef struct { */ hts221_bdu_t blockdataupdate; /** - * @brief HTS221 humidity resolution. + * @brief HTS221 hygrometer subsystem resolution. */ - hts221_avgh_t reshumidity; + hts221_avgh_t hygroresolution; /** - * @brief HTS221 temperature resolution. + * @brief HTS221 thermometer subsystem resolution. */ - hts221_avgt_t restemperature; + hts221_avgt_t thermoresolution; #endif } HTS221Config; /** - * @brief @p HTS221 hygrometer subsystem specific methods. + * @brief @p HTS221 specific methods. * @note No methods so far, just a common ancestor interface. */ -#define _hts221_hygrometer_methods_alone +#define _hts221_methods_alone /** - * @brief @p HTS221 hygrometer subsystem specific methods with inherited ones. + * @brief @p HTS221 specific methods with inherited ones. */ -#define _hts221_hygrometer_methods \ - _base_hygrometer_methods \ - _hts221_hygrometer_methods_alone +#define _hts221_methods \ + _base_object_methods \ + _hts221_methods_alone /** - * @brief @p HTS221 thermometer subsystem specific methods. - * @note No methods so far, just a common ancestor interface. + * @extends BaseObjectVMT + * + * @brief @p HTS221 virtual methods table. */ -#define _hts221_thermometer_methods_alone - +struct HTS221VMT { + _hts221_methods +}; + /** - * @brief @p HTS221 compass subsystem specific methods with inherited ones. + * @brief @p HTS221Driver specific data. + */ +#define _hts221_data \ + /* Driver state.*/ \ + hts221_state_t state; \ + /* Current configuration data.*/ \ + const HTS221Config *config; \ + /* Hygrometer subsystem axes number.*/ \ + size_t hygroaxes; \ + /* Hygrometer subsystem current sensitivity.*/ \ + float hygrosensitivity; \ + /* Hygrometer subsystem current bias .*/ \ + float hygrobias; \ + /* Hygrometer subsystem factory sensitivity.*/ \ + float hygrofactorysensitivity; \ + /* Hygrometer subsystem factory bias .*/ \ + float hygrofactorybias; \ + /* Thermometer subsystem axes number.*/ \ + size_t thermoaxes; \ + /* Thermometer subsystem current sensitivity.*/ \ + float thermosensitivity; \ + /* Thermometer subsystem current bias.*/ \ + float thermobias; \ + /* Thermometer subsystem factory sensitivity.*/ \ + float thermofactorysensitivity; \ + /* Thermometer subsystem factory bias.*/ \ + float thermofactorybias; + +/** + * @brief HTS221 2-axis hygrometer/thermometer class. */ -#define _hts221_thermometer_methods \ - _base_thermometer_methods \ - _hts221_thermometer_methods_alone +struct HTS221Driver { + /** @brief Virtual Methods Table.*/ + const struct HTS221VMT *vmt; + /** @brief Base hygrometer interface.*/ + BaseHygrometer hygro_if; + /** @brief Base thermometer interface.*/ + BaseThermometer thermo_if; + _hts221_data +}; +/** @} */ + +/*===========================================================================*/ +/* Driver macros. */ +/*===========================================================================*/ /** - * @extends BaseHygrometerVMT + * @brief Return the number of axes of the BaseHygrometer. + * + * @param[in] devp pointer to @p HTS221Driver. + * + * @return the number of axes. * - * @brief @p HTS221 hygrometer virtual methods table. + * @api */ -struct HTS221HygrometerVMT { - _hts221_hygrometer_methods -}; +#define hts221HygrometerGetAxesNumber(devp) \ + hygrometerGetAxesNumber(&((devp)->hygro_if)) /** - * @extends BaseThermometerVMT + * @brief Retrieves raw data from the BaseHygrometer. + * @note This data is retrieved from MEMS register without any algebraical + * manipulation. + * @note The axes array must be at least the same size of the + * BaseHygrometer axes number. + * + * @param[in] devp pointer to @p HTS221Driver. + * @param[out] axes a buffer which would be filled with raw data. * - * @brief @p HTS221 thermometer virtual methods table. + * @return The operation status. + * @retval MSG_OK if the function succeeded. + * @retval MSG_RESET if one or more I2C errors occurred, the errors can + * be retrieved using @p i2cGetErrors(). + * @retval MSG_TIMEOUT if a timeout occurred before operation end. + * + * @api */ -struct HTS221ThermometerVMT { - _hts221_thermometer_methods -}; +#define hts221HygrometerReadRaw(devp, axes) \ + hygrometerReadRaw(&((devp)->hygro_if), axes) /** - * @brief @p HTS221Driver specific data. + * @brief Retrieves cooked data from the BaseHygrometer. + * @note This data is manipulated according to the formula + * cooked = (raw * sensitivity) - bias. + * @note Final data is expressed as %rH. + * @note The axes array must be at least the same size of the + * BaseHygrometer axes number. + * + * @param[in] devp pointer to @p HTS221Driver. + * @param[out] axes a buffer which would be filled with cooked data. + * + * @return The operation status. + * @retval MSG_OK if the function succeeded. + * @retval MSG_RESET if one or more I2C errors occurred, the errors can + * be retrieved using @p i2cGetErrors(). + * @retval MSG_TIMEOUT if a timeout occurred before operation end. + * + * @api */ -#define _hts221_data \ - /* Driver state.*/ \ - hts221_state_t state; \ - /* Current configuration data.*/ \ - const HTS221Config *config; \ - /* Current sensitivity data.*/ \ - float sensitivity[HTS221_HYGRO_NUMBER_OF_AXES + \ - HTS221_THERMO_NUMBER_OF_AXES]; \ - /* Current Bias data.*/ \ - float bias[HTS221_HYGRO_NUMBER_OF_AXES + \ - HTS221_THERMO_NUMBER_OF_AXES]; +#define hts221HygrometerReadCooked(devp, axes) \ + hygrometerReadCooked(&((devp)->hygro_if), axes) /** - * @extends BaseHygrometer + * @brief Set bias values for the BaseHygrometer. + * @note Bias must be expressed as %rH. + * @note The bias buffer must be at least the same size of the + * BaseHygrometer axes number. + * + * @param[in] devp pointer to @p HTS221Driver. + * @param[in] bp a buffer which contains biases. * - * @brief HTS221 3-axis barometer class. - * @details This class extends @p BaseHygrometer by adding physical - * driver implementation. + * @return The operation status. + * @retval MSG_OK if the function succeeded. + * + * @api */ -struct HTS221Driver { - /** @brief BaseSensor Virtual Methods Table. */ - const struct BaseSensorVMT *vmt_sensor; - _base_sensor_data - /** @brief HTS221 Hygrometer Virtual Methods Table. */ - const struct HTS221HygrometerVMT *vmt_hygrometer; - _base_hygrometer_data - /** @brief HTS221 Thermometer Virtual Methods Table. */ - const struct HTS221ThermometerVMT *vmt_thermometer; - _base_thermometer_data - _hts221_data -}; +#define hts221HygrometerSetBias(devp, bp) \ + hygrometerSetBias(&((devp)->hygro_if), bp) /** - * @brief Structure representing a HTS221 driver. + * @brief Reset bias values for the BaseHygrometer. + * @note Default biases value are obtained from device datasheet when + * available otherwise they are considered zero. + * + * @param[in] devp pointer to @p HTS221Driver. + * + * @return The operation status. + * @retval MSG_OK if the function succeeded. + * + * @api */ -typedef struct HTS221Driver HTS221Driver; -/** @} */ +#define hts221HygrometerResetBias(devp) \ + hygrometerResetBias(&((devp)->hygro_if)) -/*===========================================================================*/ -/* Driver macros. */ -/*===========================================================================*/ +/** + * @brief Set sensitivity values for the BaseHygrometer. + * @note Sensitivity must be expressed as %rH/LSB. + * @note The sensitivity buffer must be at least the same size of the + * BaseHygrometer axes number. + * + * @param[in] devp pointer to @p HTS221Driver. + * @param[in] sp a buffer which contains sensitivities. + * + * @return The operation status. + * @retval MSG_OK if the function succeeded. + * + * @api + */ +#define hts221HygrometerSetSensitivity(devp, sp) \ + hygrometerSetSensitivity(&((devp)->hygro_if), sp) + +/** + * @brief Reset sensitivity values for the BaseHygrometer. + * @note Default sensitivities value are obtained from device datasheet. + * + * @param[in] devp pointer to @p HTS221Driver. + * + * @return The operation status. + * @retval MSG_OK if the function succeeded. + * + * @api + */ +#define hts221HygrometerResetSensitivity(devp) \ + hygrometerResetSensitivity(&((devp)->hygro_if)) + +/** + * @brief Return the number of axes of the BaseThermometer. + * + * @param[in] devp pointer to @p HTS221Driver. + * + * @return the number of axes. + * + * @api + */ +#define hts221ThermometerGetAxesNumber(devp) \ + thermometerGetAxesNumber(&((devp)->thermo_if)) + +/** + * @brief Retrieves raw data from the BaseThermometer. + * @note This data is retrieved from MEMS register without any algebraical + * manipulation. + * @note The axes array must be at least the same size of the + * BaseThermometer axes number. + * + * @param[in] devp pointer to @p HTS221Driver. + * @param[out] axes a buffer which would be filled with raw data. + * + * @return The operation status. + * @retval MSG_OK if the function succeeded. + * @retval MSG_RESET if one or more I2C errors occurred, the errors can + * be retrieved using @p i2cGetErrors(). + * @retval MSG_TIMEOUT if a timeout occurred before operation end. + * + * @api + */ +#define hts221ThermometerReadRaw(devp, axes) \ + thermometerReadRaw(&((devp)->thermo_if), axes) + +/** + * @brief Retrieves cooked data from the BaseThermometer. + * @note This data is manipulated according to the formula + * cooked = (raw * sensitivity) - bias. + * @note Final data is expressed as °C. + * @note The axes array must be at least the same size of the + * BaseThermometer axes number. + * + * @param[in] devp pointer to @p HTS221Driver. + * @param[out] axes a buffer which would be filled with cooked data. + * + * @return The operation status. + * @retval MSG_OK if the function succeeded. + * @retval MSG_RESET if one or more I2C errors occurred, the errors can + * be retrieved using @p i2cGetErrors(). + * @retval MSG_TIMEOUT if a timeout occurred before operation end. + * + * @api + */ +#define hts221ThermometerReadCooked(devp, axes) \ + thermometerReadCooked(&((devp)->thermo_if), axes) + +/** + * @brief Set bias values for the BaseThermometer. + * @note Bias must be expressed as °C. + * @note The bias buffer must be at least the same size of the + * BaseThermometer axes number. + * + * @param[in] devp pointer to @p HTS221Driver. + * @param[in] bp a buffer which contains biases. + * + * @return The operation status. + * @retval MSG_OK if the function succeeded. + * + * @api + */ +#define hts221ThermometerSetBias(devp, bp) \ + thermometerSetBias(&((devp)->thermo_if), bp) + +/** + * @brief Reset bias values for the BaseThermometer. + * @note Default biases value are obtained from device datasheet when + * available otherwise they are considered zero. + * + * @param[in] devp pointer to @p HTS221Driver. + * + * @return The operation status. + * @retval MSG_OK if the function succeeded. + * + * @api + */ +#define hts221ThermometerResetBias(devp) \ + thermometerResetBias(&((devp)->thermo_if)) + +/** + * @brief Set sensitivity values for the BaseThermometer. + * @note Sensitivity must be expressed as °C/LSB. + * @note The sensitivity buffer must be at least the same size of the + * BaseThermometer axes number. + * + * @param[in] devp pointer to @p HTS221Driver. + * @param[in] sp a buffer which contains sensitivities. + * + * @return The operation status. + * @retval MSG_OK if the function succeeded. + * + * @api + */ +#define hts221ThermometerSetSensitivity(devp, sp) \ + thermometerSetSensitivity(&((devp)->thermo_if), sp) + +/** + * @brief Reset sensitivity values for the BaseThermometer. + * @note Default sensitivities value are obtained from device datasheet. + * + * @param[in] devp pointer to @p HTS221Driver. + * + * @return The operation status. + * @retval MSG_OK if the function succeeded. + * + * @api + */ +#define hts221ThermometerResetSensitivity(devp) \ + thermometerResetSensitivity(&((devp)->thermo_if)) /*===========================================================================*/ /* External declarations. */ -- cgit v1.2.3