Capacitive digital sensor for relative humidity and temperature.
Dependencies: X_NUCLEO_COMMON ST_INTERFACES
Dependents: HelloWorld_ST_Sensors MOTENV_Mbed mbed-os-mqtt-client HTS221_JS ... more
Revision 5:ccf7f36492ae, committed 2019-07-24
- Comitter:
- cparata
- Date:
- Wed Jul 24 14:17:21 2019 +0000
- Parent:
- 4:9f317607860e
- Commit message:
- Format with Astyle
Changed in this revision
diff -r 9f317607860e -r ccf7f36492ae HTS221Sensor.cpp --- a/HTS221Sensor.cpp Mon Mar 04 13:50:28 2019 +0000 +++ b/HTS221Sensor.cpp Wed Jul 24 14:17:21 2019 +0000 @@ -44,10 +44,10 @@ /* Class Implementation ------------------------------------------------------*/ -HTS221Sensor::HTS221Sensor(SPI *spi, PinName cs_pin, PinName drdy_pin) : - _dev_spi(spi), _cs_pin(cs_pin), _drdy_pin(drdy_pin) // SPI3W ONLY -{ - assert(spi); +HTS221Sensor::HTS221Sensor(SPI *spi, PinName cs_pin, PinName drdy_pin) : + _dev_spi(spi), _cs_pin(cs_pin), _drdy_pin(drdy_pin) // SPI3W ONLY +{ + assert(spi); _dev_i2c = NULL; }; @@ -56,7 +56,7 @@ * @param address the address of the component's instance */ HTS221Sensor::HTS221Sensor(DevI2C *i2c, uint8_t address, PinName drdy_pin) : - _dev_i2c(i2c), _address(address), _cs_pin(NC), _drdy_pin(drdy_pin) + _dev_i2c(i2c), _address(address), _cs_pin(NC), _drdy_pin(drdy_pin) { assert(i2c); _dev_spi = NULL; @@ -69,24 +69,21 @@ */ int HTS221Sensor::init(void *init) { - /* Power down the device */ - if ( HTS221_DeActivate( (void *)this ) == HTS221_ERROR ) - { - return 1; - } + /* Power down the device */ + if (HTS221_DeActivate((void *)this) == HTS221_ERROR) { + return 1; + } - /* Enable BDU */ - if ( HTS221_Set_BduMode( (void *)this, HTS221_ENABLE ) == HTS221_ERROR ) - { - return 1; - } - - if(set_odr(1.0f) == 1) - { - return 1; - } - - return 0; + /* Enable BDU */ + if (HTS221_Set_BduMode((void *)this, HTS221_ENABLE) == HTS221_ERROR) { + return 1; + } + + if (set_odr(1.0f) == 1) { + return 1; + } + + return 0; } /** @@ -95,13 +92,12 @@ */ int HTS221Sensor::enable(void) { - /* Power up the device */ - if ( HTS221_Activate( (void *)this ) == HTS221_ERROR ) - { - return 1; - } + /* Power up the device */ + if (HTS221_Activate((void *)this) == HTS221_ERROR) { + return 1; + } - return 0; + return 0; } /** @@ -110,13 +106,12 @@ */ int HTS221Sensor::disable(void) { - /* Power up the device */ - if ( HTS221_DeActivate( (void *)this ) == HTS221_ERROR ) - { - return 1; - } + /* Power up the device */ + if (HTS221_DeActivate((void *)this) == HTS221_ERROR) { + return 1; + } - return 0; + return 0; } /** @@ -126,18 +121,16 @@ */ int HTS221Sensor::read_id(uint8_t *id) { - if(!id) - { - return 1; - } - - /* Read WHO AM I register */ - if ( HTS221_Get_DeviceID( (void *)this, id ) == HTS221_ERROR ) - { - return 1; - } + if (!id) { + return 1; + } - return 0; + /* Read WHO AM I register */ + if (HTS221_Get_DeviceID((void *)this, id) == HTS221_ERROR) { + return 1; + } + + return 0; } /** @@ -150,20 +143,18 @@ uint8_t tmpreg; /* Read CTRL_REG2 register */ - if (read_reg(HTS221_CTRL_REG2, &tmpreg) != 0) - { - return 1; + if (read_reg(HTS221_CTRL_REG2, &tmpreg) != 0) { + return 1; } /* Enable or Disable the reboot memory */ tmpreg |= (0x01 << HTS221_BOOT_BIT); /* Write value to MEMS CTRL_REG2 regsister */ - if (write_reg(HTS221_CTRL_REG2, tmpreg) != 0) - { - return 1; + if (write_reg(HTS221_CTRL_REG2, tmpreg) != 0) { + return 1; } - + return 0; } @@ -172,19 +163,18 @@ * @param pfData the pointer to data output * @retval 0 in case of success, an error code otherwise */ -int HTS221Sensor::get_humidity(float* pfData) +int HTS221Sensor::get_humidity(float *pfData) { - uint16_t uint16data = 0; + uint16_t uint16data = 0; - /* Read data from HTS221. */ - if ( HTS221_Get_Humidity( (void *)this, &uint16data ) == HTS221_ERROR ) - { - return 1; - } + /* Read data from HTS221. */ + if (HTS221_Get_Humidity((void *)this, &uint16data) == HTS221_ERROR) { + return 1; + } - *pfData = ( float )uint16data / 10.0f; + *pfData = (float)uint16data / 10.0f; - return 0; + return 0; } /** @@ -192,19 +182,18 @@ * @param pfData the pointer to data output * @retval 0 in case of success, an error code otherwise */ -int HTS221Sensor::get_temperature(float* pfData) +int HTS221Sensor::get_temperature(float *pfData) { - int16_t int16data = 0; + int16_t int16data = 0; - /* Read data from HTS221. */ - if ( HTS221_Get_Temperature( (void *)this, &int16data ) == HTS221_ERROR ) - { - return 1; - } + /* Read data from HTS221. */ + if (HTS221_Get_Temperature((void *)this, &int16data) == HTS221_ERROR) { + return 1; + } - *pfData = ( float )int16data / 10.0f; + *pfData = (float)int16data / 10.0f; - return 0; + return 0; } /** @@ -212,35 +201,33 @@ * @param odr the pointer to the output data rate * @retval 0 in case of success, an error code otherwise */ -int HTS221Sensor::get_odr(float* odr) +int HTS221Sensor::get_odr(float *odr) { - HTS221_Odr_et odr_low_level; + HTS221_Odr_et odr_low_level; - if ( HTS221_Get_Odr( (void *)this, &odr_low_level ) == HTS221_ERROR ) - { - return 1; - } + if (HTS221_Get_Odr((void *)this, &odr_low_level) == HTS221_ERROR) { + return 1; + } - switch( odr_low_level ) - { - case HTS221_ODR_ONE_SHOT: - *odr = 0.0f; - break; - case HTS221_ODR_1HZ : - *odr = 1.0f; - break; - case HTS221_ODR_7HZ : - *odr = 7.0f; - break; - case HTS221_ODR_12_5HZ : - *odr = 12.5f; - break; - default : - *odr = -1.0f; - return 1; - } + switch (odr_low_level) { + case HTS221_ODR_ONE_SHOT: + *odr = 0.0f; + break; + case HTS221_ODR_1HZ : + *odr = 1.0f; + break; + case HTS221_ODR_7HZ : + *odr = 7.0f; + break; + case HTS221_ODR_12_5HZ : + *odr = 12.5f; + break; + default : + *odr = -1.0f; + return 1; + } - return 0; + return 0; } /** @@ -250,18 +237,17 @@ */ int HTS221Sensor::set_odr(float odr) { - HTS221_Odr_et new_odr; + HTS221_Odr_et new_odr; - new_odr = ( odr <= 1.0f ) ? HTS221_ODR_1HZ - : ( odr <= 7.0f ) ? HTS221_ODR_7HZ - : HTS221_ODR_12_5HZ; + new_odr = (odr <= 1.0f) ? HTS221_ODR_1HZ + : (odr <= 7.0f) ? HTS221_ODR_7HZ + : HTS221_ODR_12_5HZ; - if ( HTS221_Set_Odr( (void *)this, new_odr ) == HTS221_ERROR ) - { - return 1; - } + if (HTS221_Set_Odr((void *)this, new_odr) == HTS221_ERROR) { + return 1; + } - return 0; + return 0; } @@ -272,15 +258,14 @@ * @retval 0 in case of success * @retval 1 in case of failure */ -int HTS221Sensor::read_reg( uint8_t reg, uint8_t *data ) +int HTS221Sensor::read_reg(uint8_t reg, uint8_t *data) { - if ( HTS221_read_reg( (void *)this, reg, 1, data ) == HTS221_ERROR ) - { - return 1; - } + if (HTS221_read_reg((void *)this, reg, 1, data) == HTS221_ERROR) { + return 1; + } - return 0; + return 0; } /** @@ -290,23 +275,22 @@ * @retval 0 in case of success * @retval 1 in case of failure */ -int HTS221Sensor::write_reg( uint8_t reg, uint8_t data ) +int HTS221Sensor::write_reg(uint8_t reg, uint8_t data) { - if ( HTS221_write_reg( (void *)this, reg, 1, &data ) == HTS221_ERROR ) - { - return 1; - } + if (HTS221_write_reg((void *)this, reg, 1, &data) == HTS221_ERROR) { + return 1; + } - return 0; + return 0; } -uint8_t HTS221_io_write( void *handle, uint8_t WriteAddr, uint8_t *pBuffer, uint16_t nBytesToWrite ) +uint8_t HTS221_io_write(void *handle, uint8_t WriteAddr, uint8_t *pBuffer, uint16_t nBytesToWrite) { - return ((HTS221Sensor *)handle)->io_write(pBuffer, WriteAddr, nBytesToWrite); + return ((HTS221Sensor *)handle)->io_write(pBuffer, WriteAddr, nBytesToWrite); } -uint8_t HTS221_io_read( void *handle, uint8_t ReadAddr, uint8_t *pBuffer, uint16_t nBytesToRead ) +uint8_t HTS221_io_read(void *handle, uint8_t ReadAddr, uint8_t *pBuffer, uint16_t nBytesToRead) { - return ((HTS221Sensor *)handle)->io_read(pBuffer, ReadAddr, nBytesToRead); + return ((HTS221Sensor *)handle)->io_read(pBuffer, ReadAddr, nBytesToRead); }
diff -r 9f317607860e -r ccf7f36492ae HTS221Sensor.h --- a/HTS221Sensor.h Mon Mar 04 13:50:28 2019 +0000 +++ b/HTS221Sensor.h Wed Jul 24 14:17:21 2019 +0000 @@ -56,11 +56,10 @@ /** * Abstract class of an HTS221 Humidity and Temperature sensor. */ -class HTS221Sensor : public HumiditySensor, public TempSensor -{ - public: - HTS221Sensor(SPI *spi, PinName cs_pin=NC, PinName drdy_pin=NC); // SPI3W ONLY - HTS221Sensor(DevI2C *i2c, uint8_t address=HTS221_I2C_ADDRESS, PinName drdy_pin=NC); +class HTS221Sensor : public HumiditySensor, public TempSensor { +public: + HTS221Sensor(SPI *spi, PinName cs_pin = NC, PinName drdy_pin = NC); // SPI3W ONLY + HTS221Sensor(DevI2C *i2c, uint8_t address = HTS221_I2C_ADDRESS, PinName drdy_pin = NC); virtual int init(void *init); virtual int read_id(uint8_t *id); virtual int get_humidity(float *pfData); @@ -79,10 +78,10 @@ * @param NumByteToRead: number of bytes to be read. * @retval 0 if ok, an error code otherwise. */ - uint8_t io_read(uint8_t* pBuffer, uint8_t RegisterAddr, uint16_t NumByteToRead) + uint8_t io_read(uint8_t *pBuffer, uint8_t RegisterAddr, uint16_t NumByteToRead) { if (_dev_spi) { - /* Write Reg Address */ + /* Write Reg Address */ _dev_spi->lock(); _cs_pin = 0; /* Write RD Reg Address with RD bit*/ @@ -91,11 +90,13 @@ _cs_pin = 1; _dev_spi->unlock(); return 0; - } - if (_dev_i2c) return (uint8_t) _dev_i2c->i2c_read(pBuffer, _address, RegisterAddr, NumByteToRead); + } + if (_dev_i2c) { + return (uint8_t) _dev_i2c->i2c_read(pBuffer, _address, RegisterAddr, NumByteToRead); + } return 1; } - + /** * @brief Utility function to write data. * @param pBuffer: pointer to data to be written. @@ -103,40 +104,42 @@ * @param NumByteToWrite: number of bytes to write. * @retval 0 if ok, an error code otherwise. */ - uint8_t io_write(uint8_t* pBuffer, uint8_t RegisterAddr, uint16_t NumByteToWrite) + uint8_t io_write(uint8_t *pBuffer, uint8_t RegisterAddr, uint16_t NumByteToWrite) { - if (_dev_spi) { + if (_dev_spi) { _dev_spi->lock(); _cs_pin = 0; - _dev_spi->write(RegisterAddr); - _dev_spi->write((char *)pBuffer, (int) NumByteToWrite, NULL, 0); - _cs_pin = 1; + _dev_spi->write(RegisterAddr); + _dev_spi->write((char *)pBuffer, (int) NumByteToWrite, NULL, 0); + _cs_pin = 1; _dev_spi->unlock(); - return 0; - } - if (_dev_i2c) return (uint8_t) _dev_i2c->i2c_write(pBuffer, _address, RegisterAddr, NumByteToWrite); + return 0; + } + if (_dev_i2c) { + return (uint8_t) _dev_i2c->i2c_write(pBuffer, _address, RegisterAddr, NumByteToWrite); + } return 1; } - private: +private: /* Helper classes. */ DevI2C *_dev_i2c; SPI *_dev_spi; - + /* Configuration */ uint8_t _address; - DigitalOut _cs_pin; - InterruptIn _drdy_pin; + DigitalOut _cs_pin; + InterruptIn _drdy_pin; }; #ifdef __cplusplus - extern "C" { +extern "C" { #endif -uint8_t HTS221_io_write( void *handle, uint8_t WriteAddr, uint8_t *pBuffer, uint16_t nBytesToWrite ); -uint8_t HTS221_io_read( void *handle, uint8_t ReadAddr, uint8_t *pBuffer, uint16_t nBytesToRead ); +uint8_t HTS221_io_write(void *handle, uint8_t WriteAddr, uint8_t *pBuffer, uint16_t nBytesToWrite); +uint8_t HTS221_io_read(void *handle, uint8_t ReadAddr, uint8_t *pBuffer, uint16_t nBytesToRead); #ifdef __cplusplus - } +} #endif #endif
diff -r 9f317607860e -r ccf7f36492ae HTS221_driver.c --- a/HTS221_driver.c Mon Mar 04 13:50:28 2019 +0000 +++ b/HTS221_driver.c Wed Jul 24 14:17:21 2019 +0000 @@ -39,7 +39,7 @@ #include "HTS221_driver.h" #ifdef __cplusplus - extern "C" { +extern "C" { #endif #ifdef USE_FULL_ASSERT_HTS221 @@ -60,8 +60,8 @@ * @{ */ -extern uint8_t HTS221_io_write( void *handle, uint8_t WriteAddr, uint8_t *pBuffer, uint16_t nBytesToWrite ); -extern uint8_t HTS221_io_read( void *handle, uint8_t ReadAddr, uint8_t *pBuffer, uint16_t nBytesToRead ); +extern uint8_t HTS221_io_write(void *handle, uint8_t WriteAddr, uint8_t *pBuffer, uint16_t nBytesToWrite); +extern uint8_t HTS221_io_read(void *handle, uint8_t ReadAddr, uint8_t *pBuffer, uint16_t nBytesToRead); /** * @} @@ -95,15 +95,18 @@ * Output : Data Read * Return : None *******************************************************************************/ -HTS221_Error_et HTS221_read_reg( void *handle, uint8_t RegAddr, uint16_t NumByteToRead, uint8_t *Data ) +HTS221_Error_et HTS221_read_reg(void *handle, uint8_t RegAddr, uint16_t NumByteToRead, uint8_t *Data) { - if ( NumByteToRead > 1 ) RegAddr |= 0x80; + if (NumByteToRead > 1) { + RegAddr |= 0x80; + } - if ( HTS221_io_read( handle, RegAddr, Data, NumByteToRead ) ) - return HTS221_ERROR; - else - return HTS221_OK; + if (HTS221_io_read(handle, RegAddr, Data, NumByteToRead)) { + return HTS221_ERROR; + } else { + return HTS221_OK; + } } /******************************************************************************* @@ -114,15 +117,18 @@ * Output : None * Return : None *******************************************************************************/ -HTS221_Error_et HTS221_write_reg( void *handle, uint8_t RegAddr, uint16_t NumByteToWrite, uint8_t *Data ) +HTS221_Error_et HTS221_write_reg(void *handle, uint8_t RegAddr, uint16_t NumByteToWrite, uint8_t *Data) { - if ( NumByteToWrite > 1 ) RegAddr |= 0x80; + if (NumByteToWrite > 1) { + RegAddr |= 0x80; + } - if ( HTS221_io_write( handle, RegAddr, Data, NumByteToWrite ) ) - return HTS221_ERROR; - else - return HTS221_OK; + if (HTS221_io_write(handle, RegAddr, Data, NumByteToWrite)) { + return HTS221_ERROR; + } else { + return HTS221_OK; + } } /** @@ -131,13 +137,13 @@ * This parameter is a pointer to @ref HTS221_DriverVersion_st. * @retval Error code [HTS221_OK, HTS221_ERROR]. */ -HTS221_Error_et HTS221_Get_DriverVersion(HTS221_DriverVersion_st* version) +HTS221_Error_et HTS221_Get_DriverVersion(HTS221_DriverVersion_st *version) { - version->Major = HTS221_DRIVER_VERSION_MAJOR; - version->Minor = HTS221_DRIVER_VERSION_MINOR; - version->Point = HTS221_DRIVER_VERSION_POINT; + version->Major = HTS221_DRIVER_VERSION_MAJOR; + version->Minor = HTS221_DRIVER_VERSION_MINOR; + version->Point = HTS221_DRIVER_VERSION_POINT; - return HTS221_OK; + return HTS221_OK; } /** @@ -146,12 +152,13 @@ * @param deviceid pointer to the returned device type ID. * @retval Error code [HTS221_OK, HTS221_ERROR]. */ -HTS221_Error_et HTS221_Get_DeviceID(void *handle, uint8_t* deviceid) +HTS221_Error_et HTS221_Get_DeviceID(void *handle, uint8_t *deviceid) { - if(HTS221_read_reg(handle, HTS221_WHO_AM_I_REG, 1, deviceid)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_WHO_AM_I_REG, 1, deviceid)) { + return HTS221_ERROR; + } - return HTS221_OK; + return HTS221_OK; } /** @@ -161,49 +168,53 @@ * This parameter is a pointer to @ref HTS221_Init_st. * @retval Error code [HTS221_OK, HTS221_ERROR]. */ -HTS221_Error_et HTS221_Set_InitConfig(void *handle, HTS221_Init_st* pxInit) +HTS221_Error_et HTS221_Set_InitConfig(void *handle, HTS221_Init_st *pxInit) { - uint8_t buffer[3]; + uint8_t buffer[3]; - HTS221_assert_param(IS_HTS221_AVGH(pxInit->avg_h)); - HTS221_assert_param(IS_HTS221_AVGT(pxInit->avg_t)); - HTS221_assert_param(IS_HTS221_ODR(pxInit->odr)); - HTS221_assert_param(IS_HTS221_State(pxInit->bdu_status)); - HTS221_assert_param(IS_HTS221_State(pxInit->heater_status)); + HTS221_assert_param(IS_HTS221_AVGH(pxInit->avg_h)); + HTS221_assert_param(IS_HTS221_AVGT(pxInit->avg_t)); + HTS221_assert_param(IS_HTS221_ODR(pxInit->odr)); + HTS221_assert_param(IS_HTS221_State(pxInit->bdu_status)); + HTS221_assert_param(IS_HTS221_State(pxInit->heater_status)); - HTS221_assert_param(IS_HTS221_DrdyLevelType(pxInit->irq_level)); - HTS221_assert_param(IS_HTS221_OutputType(pxInit->irq_output_type)); - HTS221_assert_param(IS_HTS221_State(pxInit->irq_enable)); + HTS221_assert_param(IS_HTS221_DrdyLevelType(pxInit->irq_level)); + HTS221_assert_param(IS_HTS221_OutputType(pxInit->irq_output_type)); + HTS221_assert_param(IS_HTS221_State(pxInit->irq_enable)); - if(HTS221_read_reg(handle, HTS221_AV_CONF_REG, 1, buffer)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_AV_CONF_REG, 1, buffer)) { + return HTS221_ERROR; + } - buffer[0] &= ~(HTS221_AVGH_MASK | HTS221_AVGT_MASK); - buffer[0] |= (uint8_t)pxInit->avg_h; - buffer[0] |= (uint8_t)pxInit->avg_t; + buffer[0] &= ~(HTS221_AVGH_MASK | HTS221_AVGT_MASK); + buffer[0] |= (uint8_t)pxInit->avg_h; + buffer[0] |= (uint8_t)pxInit->avg_t; - if(HTS221_write_reg(handle, HTS221_AV_CONF_REG, 1, buffer)) - return HTS221_ERROR; + if (HTS221_write_reg(handle, HTS221_AV_CONF_REG, 1, buffer)) { + return HTS221_ERROR; + } - if(HTS221_read_reg(handle, HTS221_CTRL_REG1, 3, buffer)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_CTRL_REG1, 3, buffer)) { + return HTS221_ERROR; + } - buffer[0] &= ~(HTS221_BDU_MASK | HTS221_ODR_MASK); - buffer[0] |= (uint8_t)pxInit->odr; - buffer[0] |= ((uint8_t)pxInit->bdu_status) << HTS221_BDU_BIT; + buffer[0] &= ~(HTS221_BDU_MASK | HTS221_ODR_MASK); + buffer[0] |= (uint8_t)pxInit->odr; + buffer[0] |= ((uint8_t)pxInit->bdu_status) << HTS221_BDU_BIT; - buffer[1] &= ~HTS221_HEATHER_BIT; - buffer[1] |= ((uint8_t)pxInit->heater_status) << HTS221_HEATHER_BIT; + buffer[1] &= ~HTS221_HEATHER_BIT; + buffer[1] |= ((uint8_t)pxInit->heater_status) << HTS221_HEATHER_BIT; - buffer[2] &= ~(HTS221_DRDY_H_L_MASK | HTS221_PP_OD_MASK | HTS221_DRDY_MASK); - buffer[2] |= ((uint8_t)pxInit->irq_level) << HTS221_DRDY_H_L_BIT; - buffer[2] |= (uint8_t)pxInit->irq_output_type; - buffer[2] |= ((uint8_t)pxInit->irq_enable) << HTS221_DRDY_BIT; + buffer[2] &= ~(HTS221_DRDY_H_L_MASK | HTS221_PP_OD_MASK | HTS221_DRDY_MASK); + buffer[2] |= ((uint8_t)pxInit->irq_level) << HTS221_DRDY_H_L_BIT; + buffer[2] |= (uint8_t)pxInit->irq_output_type; + buffer[2] |= ((uint8_t)pxInit->irq_enable) << HTS221_DRDY_BIT; - if(HTS221_write_reg(handle, HTS221_CTRL_REG1, 3, buffer)) - return HTS221_ERROR; + if (HTS221_write_reg(handle, HTS221_CTRL_REG1, 3, buffer)) { + return HTS221_ERROR; + } - return HTS221_OK; + return HTS221_OK; } /** @@ -213,28 +224,30 @@ * This parameter is a pointer to @ref HTS221_Init_st. * @retval Error code [HTS221_OK, HTS221_ERROR]. */ -HTS221_Error_et HTS221_Get_InitConfig(void *handle, HTS221_Init_st* pxInit) +HTS221_Error_et HTS221_Get_InitConfig(void *handle, HTS221_Init_st *pxInit) { - uint8_t buffer[3]; + uint8_t buffer[3]; - if(HTS221_read_reg(handle, HTS221_AV_CONF_REG, 1, buffer)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_AV_CONF_REG, 1, buffer)) { + return HTS221_ERROR; + } - pxInit->avg_h = (HTS221_Avgh_et)(buffer[0] & HTS221_AVGH_MASK); - pxInit->avg_t = (HTS221_Avgt_et)(buffer[0] & HTS221_AVGT_MASK); + pxInit->avg_h = (HTS221_Avgh_et)(buffer[0] & HTS221_AVGH_MASK); + pxInit->avg_t = (HTS221_Avgt_et)(buffer[0] & HTS221_AVGT_MASK); - if(HTS221_read_reg(handle, HTS221_CTRL_REG1, 3, buffer)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_CTRL_REG1, 3, buffer)) { + return HTS221_ERROR; + } - pxInit->odr = (HTS221_Odr_et)(buffer[0] & HTS221_ODR_MASK); - pxInit->bdu_status = (HTS221_State_et)((buffer[0] & HTS221_BDU_MASK) >> HTS221_BDU_BIT); - pxInit->heater_status = (HTS221_State_et)((buffer[1] & HTS221_HEATHER_MASK) >> HTS221_HEATHER_BIT); + pxInit->odr = (HTS221_Odr_et)(buffer[0] & HTS221_ODR_MASK); + pxInit->bdu_status = (HTS221_State_et)((buffer[0] & HTS221_BDU_MASK) >> HTS221_BDU_BIT); + pxInit->heater_status = (HTS221_State_et)((buffer[1] & HTS221_HEATHER_MASK) >> HTS221_HEATHER_BIT); - pxInit->irq_level = (HTS221_DrdyLevel_et)(buffer[2] & HTS221_DRDY_H_L_MASK); - pxInit->irq_output_type = (HTS221_OutputType_et)(buffer[2] & HTS221_PP_OD_MASK); - pxInit->irq_enable = (HTS221_State_et)((buffer[2] & HTS221_DRDY_MASK) >> HTS221_DRDY_BIT); + pxInit->irq_level = (HTS221_DrdyLevel_et)(buffer[2] & HTS221_DRDY_H_L_MASK); + pxInit->irq_output_type = (HTS221_OutputType_et)(buffer[2] & HTS221_PP_OD_MASK); + pxInit->irq_enable = (HTS221_State_et)((buffer[2] & HTS221_DRDY_MASK) >> HTS221_DRDY_BIT); - return HTS221_OK; + return HTS221_OK; } /** @@ -245,25 +258,28 @@ */ HTS221_Error_et HTS221_DeInit(void *handle) { - uint8_t buffer[4]; + uint8_t buffer[4]; - if(HTS221_read_reg(handle, HTS221_CTRL_REG1, 2, buffer)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_CTRL_REG1, 2, buffer)) { + return HTS221_ERROR; + } - /* HTS221 in power down */ - buffer[0] |= 0x01 << HTS221_PD_BIT; + /* HTS221 in power down */ + buffer[0] |= 0x01 << HTS221_PD_BIT; - /* Make HTS221 boot */ - buffer[1] |= 0x01 << HTS221_BOOT_BIT; + /* Make HTS221 boot */ + buffer[1] |= 0x01 << HTS221_BOOT_BIT; - if(HTS221_write_reg(handle, HTS221_CTRL_REG1, 2, buffer)) - return HTS221_ERROR; + if (HTS221_write_reg(handle, HTS221_CTRL_REG1, 2, buffer)) { + return HTS221_ERROR; + } - /* Dump of data output */ - if(HTS221_read_reg(handle, HTS221_HR_OUT_L_REG, 4, buffer)) - return HTS221_ERROR; + /* Dump of data output */ + if (HTS221_read_reg(handle, HTS221_HR_OUT_L_REG, 4, buffer)) { + return HTS221_ERROR; + } - return HTS221_OK; + return HTS221_OK; } /** @@ -273,12 +289,16 @@ * @param temperature pointer to the returned temperature value that must be divided by 10 to get the value in ['C]. * @retval Error code [HTS221_OK, HTS221_ERROR]. */ -HTS221_Error_et HTS221_Get_Measurement(void *handle, uint16_t* humidity, int16_t* temperature) +HTS221_Error_et HTS221_Get_Measurement(void *handle, uint16_t *humidity, int16_t *temperature) { - if ( HTS221_Get_Temperature( handle, temperature ) == HTS221_ERROR ) return HTS221_ERROR; - if ( HTS221_Get_Humidity( handle, humidity ) == HTS221_ERROR ) return HTS221_ERROR; + if (HTS221_Get_Temperature(handle, temperature) == HTS221_ERROR) { + return HTS221_ERROR; + } + if (HTS221_Get_Humidity(handle, humidity) == HTS221_ERROR) { + return HTS221_ERROR; + } - return HTS221_OK; + return HTS221_OK; } /** @@ -288,17 +308,18 @@ * @param temperature pointer to the returned temperature raw value. * @retval Error code [HTS221_OK, HTS221_ERROR]. */ -HTS221_Error_et HTS221_Get_RawMeasurement(void *handle, int16_t* humidity, int16_t* temperature) +HTS221_Error_et HTS221_Get_RawMeasurement(void *handle, int16_t *humidity, int16_t *temperature) { - uint8_t buffer[4]; + uint8_t buffer[4]; - if(HTS221_read_reg(handle, HTS221_HR_OUT_L_REG, 4, buffer)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_HR_OUT_L_REG, 4, buffer)) { + return HTS221_ERROR; + } - *humidity = (int16_t)((((uint16_t)buffer[1]) << 8) | (uint16_t)buffer[0]); - *temperature = (int16_t)((((uint16_t)buffer[3]) << 8) | (uint16_t)buffer[2]); + *humidity = (int16_t)((((uint16_t)buffer[1]) << 8) | (uint16_t)buffer[0]); + *temperature = (int16_t)((((uint16_t)buffer[3]) << 8) | (uint16_t)buffer[2]); - return HTS221_OK; + return HTS221_OK; } /** @@ -307,38 +328,42 @@ * @param Pointer to the returned humidity value that must be divided by 10 to get the value in [%]. * @retval Error code [HTS221_OK, HTS221_ERROR]. */ -HTS221_Error_et HTS221_Get_Humidity(void *handle, uint16_t* value) +HTS221_Error_et HTS221_Get_Humidity(void *handle, uint16_t *value) { - int16_t H0_T0_out, H1_T0_out, H_T_out; - int16_t H0_rh, H1_rh; - uint8_t buffer[2]; - float tmp_f; + int16_t H0_T0_out, H1_T0_out, H_T_out; + int16_t H0_rh, H1_rh; + uint8_t buffer[2]; + float tmp_f; - if(HTS221_read_reg(handle, HTS221_H0_RH_X2, 2, buffer)) - return HTS221_ERROR; - H0_rh = buffer[0] >> 1; - H1_rh = buffer[1] >> 1; + if (HTS221_read_reg(handle, HTS221_H0_RH_X2, 2, buffer)) { + return HTS221_ERROR; + } + H0_rh = buffer[0] >> 1; + H1_rh = buffer[1] >> 1; - if(HTS221_read_reg(handle, HTS221_H0_T0_OUT_L, 2, buffer)) - return HTS221_ERROR; - H0_T0_out = (((uint16_t)buffer[1]) << 8) | (uint16_t)buffer[0]; + if (HTS221_read_reg(handle, HTS221_H0_T0_OUT_L, 2, buffer)) { + return HTS221_ERROR; + } + H0_T0_out = (((uint16_t)buffer[1]) << 8) | (uint16_t)buffer[0]; - if(HTS221_read_reg(handle, HTS221_H1_T0_OUT_L, 2, buffer)) - return HTS221_ERROR; - H1_T0_out = (((uint16_t)buffer[1]) << 8) | (uint16_t)buffer[0]; - - if(HTS221_read_reg(handle, HTS221_HR_OUT_L_REG, 2, buffer)) - return HTS221_ERROR; - H_T_out = (((uint16_t)buffer[1]) << 8) | (uint16_t)buffer[0]; + if (HTS221_read_reg(handle, HTS221_H1_T0_OUT_L, 2, buffer)) { + return HTS221_ERROR; + } + H1_T0_out = (((uint16_t)buffer[1]) << 8) | (uint16_t)buffer[0]; - tmp_f = (float)(H_T_out - H0_T0_out) * (float)(H1_rh - H0_rh) / (float)(H1_T0_out - H0_T0_out) + H0_rh; - tmp_f *= 10.0f; + if (HTS221_read_reg(handle, HTS221_HR_OUT_L_REG, 2, buffer)) { + return HTS221_ERROR; + } + H_T_out = (((uint16_t)buffer[1]) << 8) | (uint16_t)buffer[0]; - *value = ( tmp_f > 1000.0f ) ? 1000 - : ( tmp_f < 0.0f ) ? 0 - : ( uint16_t )tmp_f; + tmp_f = (float)(H_T_out - H0_T0_out) * (float)(H1_rh - H0_rh) / (float)(H1_T0_out - H0_T0_out) + H0_rh; + tmp_f *= 10.0f; - return HTS221_OK; + *value = (tmp_f > 1000.0f) ? 1000 + : (tmp_f < 0.0f) ? 0 + : (uint16_t)tmp_f; + + return HTS221_OK; } /** @@ -347,16 +372,17 @@ * @param Pointer to the returned humidity raw value. * @retval Error code [HTS221_OK, HTS221_ERROR]. */ -HTS221_Error_et HTS221_Get_HumidityRaw(void *handle, int16_t* value) +HTS221_Error_et HTS221_Get_HumidityRaw(void *handle, int16_t *value) { - uint8_t buffer[2]; + uint8_t buffer[2]; - if(HTS221_read_reg(handle, HTS221_HR_OUT_L_REG, 2, buffer)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_HR_OUT_L_REG, 2, buffer)) { + return HTS221_ERROR; + } - *value = (int16_t)((((uint16_t)buffer[1]) << 8) | (uint16_t)buffer[0]); + *value = (int16_t)((((uint16_t)buffer[1]) << 8) | (uint16_t)buffer[0]); - return HTS221_OK; + return HTS221_OK; } /** @@ -367,38 +393,42 @@ */ HTS221_Error_et HTS221_Get_Temperature(void *handle, int16_t *value) { - int16_t T0_out, T1_out, T_out, T0_degC_x8_u16, T1_degC_x8_u16; - int16_t T0_degC, T1_degC; - uint8_t buffer[4], tmp; - float tmp_f; + int16_t T0_out, T1_out, T_out, T0_degC_x8_u16, T1_degC_x8_u16; + int16_t T0_degC, T1_degC; + uint8_t buffer[4], tmp; + float tmp_f; - if(HTS221_read_reg(handle, HTS221_T0_DEGC_X8, 2, buffer)) - return HTS221_ERROR; - if(HTS221_read_reg(handle, HTS221_T0_T1_DEGC_H2, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_T0_DEGC_X8, 2, buffer)) { + return HTS221_ERROR; + } + if (HTS221_read_reg(handle, HTS221_T0_T1_DEGC_H2, 1, &tmp)) { + return HTS221_ERROR; + } - T0_degC_x8_u16 = (((uint16_t)(tmp & 0x03)) << 8) | ((uint16_t)buffer[0]); - T1_degC_x8_u16 = (((uint16_t)(tmp & 0x0C)) << 6) | ((uint16_t)buffer[1]); - T0_degC = T0_degC_x8_u16 >> 3; - T1_degC = T1_degC_x8_u16 >> 3; + T0_degC_x8_u16 = (((uint16_t)(tmp & 0x03)) << 8) | ((uint16_t)buffer[0]); + T1_degC_x8_u16 = (((uint16_t)(tmp & 0x0C)) << 6) | ((uint16_t)buffer[1]); + T0_degC = T0_degC_x8_u16 >> 3; + T1_degC = T1_degC_x8_u16 >> 3; - if(HTS221_read_reg(handle, HTS221_T0_OUT_L, 4, buffer)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_T0_OUT_L, 4, buffer)) { + return HTS221_ERROR; + } - T0_out = (((uint16_t)buffer[1]) << 8) | (uint16_t)buffer[0]; - T1_out = (((uint16_t)buffer[3]) << 8) | (uint16_t)buffer[2]; - - if(HTS221_read_reg(handle, HTS221_TEMP_OUT_L_REG, 2, buffer)) - return HTS221_ERROR; + T0_out = (((uint16_t)buffer[1]) << 8) | (uint16_t)buffer[0]; + T1_out = (((uint16_t)buffer[3]) << 8) | (uint16_t)buffer[2]; - T_out = (((uint16_t)buffer[1]) << 8) | (uint16_t)buffer[0]; + if (HTS221_read_reg(handle, HTS221_TEMP_OUT_L_REG, 2, buffer)) { + return HTS221_ERROR; + } + + T_out = (((uint16_t)buffer[1]) << 8) | (uint16_t)buffer[0]; - tmp_f = (float)(T_out - T0_out) * (float)(T1_degC - T0_degC) / (float)(T1_out - T0_out) + T0_degC; - tmp_f *= 10.0f; + tmp_f = (float)(T_out - T0_out) * (float)(T1_degC - T0_degC) / (float)(T1_out - T0_out) + T0_degC; + tmp_f *= 10.0f; - *value = ( int16_t )tmp_f; + *value = (int16_t)tmp_f; - return HTS221_OK; + return HTS221_OK; } /** @@ -407,16 +437,17 @@ * @param Pointer to the returned temperature raw value. * @retval Error code [HTS221_OK, HTS221_ERROR]. */ -HTS221_Error_et HTS221_Get_TemperatureRaw(void *handle, int16_t* value) +HTS221_Error_et HTS221_Get_TemperatureRaw(void *handle, int16_t *value) { - uint8_t buffer[2]; + uint8_t buffer[2]; - if(HTS221_read_reg(handle, HTS221_TEMP_OUT_L_REG, 2, buffer)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_TEMP_OUT_L_REG, 2, buffer)) { + return HTS221_ERROR; + } - *value = (int16_t)((((uint16_t)buffer[1]) << 8) | (uint16_t)buffer[0]); + *value = (int16_t)((((uint16_t)buffer[1]) << 8) | (uint16_t)buffer[0]); - return HTS221_OK; + return HTS221_OK; } /** @@ -427,17 +458,18 @@ * This parameter is a pointer to @ref HTS221_BitStatus_et. * @retval Error code [HTS221_OK, HTS221_ERROR]. */ -HTS221_Error_et HTS221_Get_DataStatus(void *handle, HTS221_BitStatus_et* humidity, HTS221_BitStatus_et* temperature) +HTS221_Error_et HTS221_Get_DataStatus(void *handle, HTS221_BitStatus_et *humidity, HTS221_BitStatus_et *temperature) { - uint8_t tmp; + uint8_t tmp; - if(HTS221_read_reg(handle, HTS221_STATUS_REG, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_STATUS_REG, 1, &tmp)) { + return HTS221_ERROR; + } - *humidity = (HTS221_BitStatus_et)((tmp & HTS221_HDA_MASK) >> HTS221_H_DA_BIT); - *temperature = (HTS221_BitStatus_et)(tmp & HTS221_TDA_MASK); + *humidity = (HTS221_BitStatus_et)((tmp & HTS221_HDA_MASK) >> HTS221_H_DA_BIT); + *temperature = (HTS221_BitStatus_et)(tmp & HTS221_TDA_MASK); - return HTS221_OK; + return HTS221_OK; } /** @@ -448,17 +480,19 @@ */ HTS221_Error_et HTS221_Activate(void *handle) { - uint8_t tmp; + uint8_t tmp; - if(HTS221_read_reg(handle, HTS221_CTRL_REG1, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_CTRL_REG1, 1, &tmp)) { + return HTS221_ERROR; + } - tmp |= HTS221_PD_MASK; + tmp |= HTS221_PD_MASK; - if(HTS221_write_reg(handle, HTS221_CTRL_REG1, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_write_reg(handle, HTS221_CTRL_REG1, 1, &tmp)) { + return HTS221_ERROR; + } - return HTS221_OK; + return HTS221_OK; } /** @@ -468,17 +502,19 @@ */ HTS221_Error_et HTS221_DeActivate(void *handle) { - uint8_t tmp; + uint8_t tmp; - if(HTS221_read_reg(handle, HTS221_CTRL_REG1, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_CTRL_REG1, 1, &tmp)) { + return HTS221_ERROR; + } - tmp &= ~HTS221_PD_MASK; + tmp &= ~HTS221_PD_MASK; - if(HTS221_write_reg(handle, HTS221_CTRL_REG1, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_write_reg(handle, HTS221_CTRL_REG1, 1, &tmp)) { + return HTS221_ERROR; + } - return HTS221_OK; + return HTS221_OK; } @@ -489,19 +525,21 @@ * @param tmp is set to 1, when the measure is completed * @retval Status [HTS221_ERROR, HTS221_OK] */ -HTS221_Error_et HTS221_IsMeasurementCompleted(void *handle, HTS221_BitStatus_et* Is_Measurement_Completed) +HTS221_Error_et HTS221_IsMeasurementCompleted(void *handle, HTS221_BitStatus_et *Is_Measurement_Completed) { - uint8_t tmp; + uint8_t tmp; - if(HTS221_read_reg(handle, HTS221_STATUS_REG, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_STATUS_REG, 1, &tmp)) { + return HTS221_ERROR; + } - if((tmp & (uint8_t)(HTS221_HDA_MASK | HTS221_TDA_MASK)) == (uint8_t)(HTS221_HDA_MASK | HTS221_TDA_MASK)) - *Is_Measurement_Completed = HTS221_SET; - else - *Is_Measurement_Completed = HTS221_RESET; + if ((tmp & (uint8_t)(HTS221_HDA_MASK | HTS221_TDA_MASK)) == (uint8_t)(HTS221_HDA_MASK | HTS221_TDA_MASK)) { + *Is_Measurement_Completed = HTS221_SET; + } else { + *Is_Measurement_Completed = HTS221_RESET; + } - return HTS221_OK; + return HTS221_OK; } @@ -514,22 +552,24 @@ */ HTS221_Error_et HTS221_Set_AvgHT(void *handle, HTS221_Avgh_et avgh, HTS221_Avgt_et avgt) { - uint8_t tmp; + uint8_t tmp; - HTS221_assert_param(IS_HTS221_AVGH(avgh)); - HTS221_assert_param(IS_HTS221_AVGT(avgt)); + HTS221_assert_param(IS_HTS221_AVGH(avgh)); + HTS221_assert_param(IS_HTS221_AVGT(avgt)); - if(HTS221_read_reg(handle, HTS221_AV_CONF_REG, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_AV_CONF_REG, 1, &tmp)) { + return HTS221_ERROR; + } - tmp &= ~(HTS221_AVGH_MASK | HTS221_AVGT_MASK); - tmp |= (uint8_t)avgh; - tmp |= (uint8_t)avgt; + tmp &= ~(HTS221_AVGH_MASK | HTS221_AVGT_MASK); + tmp |= (uint8_t)avgh; + tmp |= (uint8_t)avgt; - if(HTS221_write_reg(handle, HTS221_AV_CONF_REG, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_write_reg(handle, HTS221_AV_CONF_REG, 1, &tmp)) { + return HTS221_ERROR; + } - return HTS221_OK; + return HTS221_OK; } /** @@ -540,20 +580,22 @@ */ HTS221_Error_et HTS221_Set_AvgH(void *handle, HTS221_Avgh_et avgh) { - uint8_t tmp; + uint8_t tmp; + + HTS221_assert_param(IS_HTS221_AVGH(avgh)); - HTS221_assert_param(IS_HTS221_AVGH(avgh)); - - if(HTS221_read_reg(handle, HTS221_AV_CONF_REG, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_AV_CONF_REG, 1, &tmp)) { + return HTS221_ERROR; + } - tmp &= ~HTS221_AVGH_MASK; - tmp |= (uint8_t)avgh; + tmp &= ~HTS221_AVGH_MASK; + tmp |= (uint8_t)avgh; - if(HTS221_write_reg(handle, HTS221_AV_CONF_REG, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_write_reg(handle, HTS221_AV_CONF_REG, 1, &tmp)) { + return HTS221_ERROR; + } - return HTS221_OK; + return HTS221_OK; } /** @@ -564,20 +606,22 @@ */ HTS221_Error_et HTS221_Set_AvgT(void *handle, HTS221_Avgt_et avgt) { - uint8_t tmp; + uint8_t tmp; + + HTS221_assert_param(IS_HTS221_AVGT(avgt)); - HTS221_assert_param(IS_HTS221_AVGT(avgt)); - - if(HTS221_read_reg(handle, HTS221_AV_CONF_REG, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_AV_CONF_REG, 1, &tmp)) { + return HTS221_ERROR; + } - tmp &= ~HTS221_AVGT_MASK; - tmp |= (uint8_t)avgt; + tmp &= ~HTS221_AVGT_MASK; + tmp |= (uint8_t)avgt; - if(HTS221_write_reg(handle, HTS221_AV_CONF_REG, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_write_reg(handle, HTS221_AV_CONF_REG, 1, &tmp)) { + return HTS221_ERROR; + } - return HTS221_OK; + return HTS221_OK; } /** @@ -587,17 +631,18 @@ * @param avgt pointer to the returned value with the temperature average mode. * @retval Error code [HTS221_OK, HTS221_ERROR]. */ -HTS221_Error_et HTS221_Get_AvgHT(void *handle, HTS221_Avgh_et* avgh, HTS221_Avgt_et* avgt) +HTS221_Error_et HTS221_Get_AvgHT(void *handle, HTS221_Avgh_et *avgh, HTS221_Avgt_et *avgt) { - uint8_t tmp; + uint8_t tmp; - if(HTS221_read_reg(handle, HTS221_AV_CONF_REG, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_AV_CONF_REG, 1, &tmp)) { + return HTS221_ERROR; + } - *avgh = (HTS221_Avgh_et)(tmp & HTS221_AVGH_MASK); - *avgt = (HTS221_Avgt_et)(tmp & HTS221_AVGT_MASK); + *avgh = (HTS221_Avgh_et)(tmp & HTS221_AVGH_MASK); + *avgt = (HTS221_Avgt_et)(tmp & HTS221_AVGT_MASK); - return HTS221_OK; + return HTS221_OK; } /** @@ -610,20 +655,22 @@ */ HTS221_Error_et HTS221_Set_BduMode(void *handle, HTS221_State_et status) { - uint8_t tmp; + uint8_t tmp; + + HTS221_assert_param(IS_HTS221_State(status)); - HTS221_assert_param(IS_HTS221_State(status)); - - if(HTS221_read_reg(handle, HTS221_CTRL_REG1, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_CTRL_REG1, 1, &tmp)) { + return HTS221_ERROR; + } - tmp &= ~HTS221_BDU_MASK; - tmp |= ((uint8_t)status) << HTS221_BDU_BIT; + tmp &= ~HTS221_BDU_MASK; + tmp |= ((uint8_t)status) << HTS221_BDU_BIT; - if(HTS221_write_reg(handle, HTS221_CTRL_REG1, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_write_reg(handle, HTS221_CTRL_REG1, 1, &tmp)) { + return HTS221_ERROR; + } - return HTS221_OK; + return HTS221_OK; } /** @@ -632,16 +679,17 @@ * @param Pointer to the returned value with block data update mode status. * @retval Error code [HTS221_OK, HTS221_ERROR]. */ -HTS221_Error_et HTS221_Get_BduMode(void *handle, HTS221_State_et* status) +HTS221_Error_et HTS221_Get_BduMode(void *handle, HTS221_State_et *status) { - uint8_t tmp; + uint8_t tmp; - if(HTS221_read_reg(handle, HTS221_CTRL_REG1, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_CTRL_REG1, 1, &tmp)) { + return HTS221_ERROR; + } - *status = (HTS221_State_et)((tmp & HTS221_BDU_MASK) >> HTS221_BDU_BIT); + *status = (HTS221_State_et)((tmp & HTS221_BDU_MASK) >> HTS221_BDU_BIT); - return HTS221_OK; + return HTS221_OK; } /** @@ -654,20 +702,22 @@ */ HTS221_Error_et HTS221_Set_PowerDownMode(void *handle, HTS221_BitStatus_et status) { - uint8_t tmp; + uint8_t tmp; + + HTS221_assert_param(IS_HTS221_BitStatus(status)); - HTS221_assert_param(IS_HTS221_BitStatus(status)); - - if(HTS221_read_reg(handle, HTS221_CTRL_REG1, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_CTRL_REG1, 1, &tmp)) { + return HTS221_ERROR; + } - tmp &= ~HTS221_PD_MASK; - tmp |= ((uint8_t)status) << HTS221_PD_BIT; + tmp &= ~HTS221_PD_MASK; + tmp |= ((uint8_t)status) << HTS221_PD_BIT; - if(HTS221_write_reg(handle, HTS221_CTRL_REG1, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_write_reg(handle, HTS221_CTRL_REG1, 1, &tmp)) { + return HTS221_ERROR; + } - return HTS221_OK; + return HTS221_OK; } /** @@ -676,16 +726,17 @@ * @param Pointer to the returned value with HTS221 status. * @retval Error code [HTS221_OK, HTS221_ERROR]. */ -HTS221_Error_et HTS221_Get_PowerDownMode(void *handle, HTS221_BitStatus_et* status) +HTS221_Error_et HTS221_Get_PowerDownMode(void *handle, HTS221_BitStatus_et *status) { - uint8_t tmp; + uint8_t tmp; - if(HTS221_read_reg(handle, HTS221_CTRL_REG1, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_CTRL_REG1, 1, &tmp)) { + return HTS221_ERROR; + } - *status = (HTS221_BitStatus_et)((tmp & HTS221_PD_MASK) >> HTS221_PD_BIT); + *status = (HTS221_BitStatus_et)((tmp & HTS221_PD_MASK) >> HTS221_PD_BIT); - return HTS221_OK; + return HTS221_OK; } /** @@ -697,20 +748,22 @@ */ HTS221_Error_et HTS221_Set_Odr(void *handle, HTS221_Odr_et odr) { - uint8_t tmp; + uint8_t tmp; + + HTS221_assert_param(IS_HTS221_ODR(odr)); - HTS221_assert_param(IS_HTS221_ODR(odr)); - - if(HTS221_read_reg(handle, HTS221_CTRL_REG1, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_CTRL_REG1, 1, &tmp)) { + return HTS221_ERROR; + } - tmp &= ~HTS221_ODR_MASK; - tmp |= (uint8_t)odr; + tmp &= ~HTS221_ODR_MASK; + tmp |= (uint8_t)odr; - if(HTS221_write_reg(handle, HTS221_CTRL_REG1, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_write_reg(handle, HTS221_CTRL_REG1, 1, &tmp)) { + return HTS221_ERROR; + } - return HTS221_OK; + return HTS221_OK; } /** @@ -719,17 +772,18 @@ * @param Pointer to the returned value with output data rate mode. * @retval Error code [HTS221_OK, HTS221_ERROR]. */ -HTS221_Error_et HTS221_Get_Odr(void *handle, HTS221_Odr_et* odr) +HTS221_Error_et HTS221_Get_Odr(void *handle, HTS221_Odr_et *odr) { - uint8_t tmp; + uint8_t tmp; - if(HTS221_read_reg(handle, HTS221_CTRL_REG1, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_CTRL_REG1, 1, &tmp)) { + return HTS221_ERROR; + } - tmp &= HTS221_ODR_MASK; - *odr = (HTS221_Odr_et)tmp; + tmp &= HTS221_ODR_MASK; + *odr = (HTS221_Odr_et)tmp; - return HTS221_OK; + return HTS221_OK; } /** @@ -739,17 +793,19 @@ */ HTS221_Error_et HTS221_MemoryBoot(void *handle) { - uint8_t tmp; + uint8_t tmp; - if(HTS221_read_reg(handle, HTS221_CTRL_REG2, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_CTRL_REG2, 1, &tmp)) { + return HTS221_ERROR; + } - tmp |= HTS221_BOOT_MASK; + tmp |= HTS221_BOOT_MASK; - if(HTS221_write_reg(handle, HTS221_CTRL_REG2, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_write_reg(handle, HTS221_CTRL_REG2, 1, &tmp)) { + return HTS221_ERROR; + } - return HTS221_OK; + return HTS221_OK; } /** @@ -761,20 +817,22 @@ */ HTS221_Error_et HTS221_Set_HeaterState(void *handle, HTS221_State_et status) { - uint8_t tmp; + uint8_t tmp; + + HTS221_assert_param(IS_HTS221_State(status)); - HTS221_assert_param(IS_HTS221_State(status)); - - if(HTS221_read_reg(handle, HTS221_CTRL_REG2, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_CTRL_REG2, 1, &tmp)) { + return HTS221_ERROR; + } - tmp &= ~HTS221_HEATHER_MASK; - tmp |= ((uint8_t)status) << HTS221_HEATHER_BIT; + tmp &= ~HTS221_HEATHER_MASK; + tmp |= ((uint8_t)status) << HTS221_HEATHER_BIT; - if(HTS221_write_reg(handle, HTS221_CTRL_REG2, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_write_reg(handle, HTS221_CTRL_REG2, 1, &tmp)) { + return HTS221_ERROR; + } - return HTS221_OK; + return HTS221_OK; } /** @@ -783,16 +841,17 @@ * @param Pointer to the returned status of the internal heater [HTS221_ENABLE/HTS221_DISABLE]. * @retval Error code [HTS221_OK, HTS221_ERROR]. */ -HTS221_Error_et HTS221_Get_HeaterState(void *handle, HTS221_State_et* status) +HTS221_Error_et HTS221_Get_HeaterState(void *handle, HTS221_State_et *status) { - uint8_t tmp; + uint8_t tmp; - if(HTS221_read_reg(handle, HTS221_CTRL_REG2, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_CTRL_REG2, 1, &tmp)) { + return HTS221_ERROR; + } - *status = (HTS221_State_et)((tmp & HTS221_HEATHER_MASK) >> HTS221_HEATHER_BIT); + *status = (HTS221_State_et)((tmp & HTS221_HEATHER_MASK) >> HTS221_HEATHER_BIT); - return HTS221_OK; + return HTS221_OK; } /** @@ -803,17 +862,19 @@ */ HTS221_Error_et HTS221_StartOneShotMeasurement(void *handle) { - uint8_t tmp; + uint8_t tmp; - if(HTS221_read_reg(handle, HTS221_CTRL_REG2, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_CTRL_REG2, 1, &tmp)) { + return HTS221_ERROR; + } - tmp |= HTS221_ONE_SHOT_MASK; + tmp |= HTS221_ONE_SHOT_MASK; - if(HTS221_write_reg(handle, HTS221_CTRL_REG2, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_write_reg(handle, HTS221_CTRL_REG2, 1, &tmp)) { + return HTS221_ERROR; + } - return HTS221_OK; + return HTS221_OK; } @@ -827,20 +888,22 @@ */ HTS221_Error_et HTS221_Set_IrqActiveLevel(void *handle, HTS221_DrdyLevel_et value) { - uint8_t tmp; + uint8_t tmp; + + HTS221_assert_param(IS_HTS221_DrdyLevelType(value)); - HTS221_assert_param(IS_HTS221_DrdyLevelType(value)); - - if(HTS221_read_reg(handle, HTS221_CTRL_REG3, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_CTRL_REG3, 1, &tmp)) { + return HTS221_ERROR; + } - tmp &= ~HTS221_DRDY_H_L_MASK; - tmp |= (uint8_t)value; + tmp &= ~HTS221_DRDY_H_L_MASK; + tmp |= (uint8_t)value; - if(HTS221_write_reg(handle, HTS221_CTRL_REG3, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_write_reg(handle, HTS221_CTRL_REG3, 1, &tmp)) { + return HTS221_ERROR; + } - return HTS221_OK; + return HTS221_OK; } /** @@ -849,16 +912,17 @@ * @param Pointer to the returned status of the level configuration [HTS221_ENABLE/HTS221_DISABLE]. * @retval Error code [HTS221_OK, HTS221_ERROR]. */ -HTS221_Error_et HTS221_Get_IrqActiveLevel(void *handle, HTS221_DrdyLevel_et* value) +HTS221_Error_et HTS221_Get_IrqActiveLevel(void *handle, HTS221_DrdyLevel_et *value) { - uint8_t tmp; + uint8_t tmp; - if(HTS221_read_reg(handle, HTS221_CTRL_REG3, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_CTRL_REG3, 1, &tmp)) { + return HTS221_ERROR; + } - *value = (HTS221_DrdyLevel_et)(tmp & HTS221_DRDY_H_L_MASK); + *value = (HTS221_DrdyLevel_et)(tmp & HTS221_DRDY_H_L_MASK); - return HTS221_OK; + return HTS221_OK; } /** @@ -870,20 +934,22 @@ */ HTS221_Error_et HTS221_Set_IrqOutputType(void *handle, HTS221_OutputType_et value) { - uint8_t tmp; + uint8_t tmp; + + HTS221_assert_param(IS_HTS221_OutputType(value)); - HTS221_assert_param(IS_HTS221_OutputType(value)); - - if(HTS221_read_reg(handle, HTS221_CTRL_REG3, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_CTRL_REG3, 1, &tmp)) { + return HTS221_ERROR; + } - tmp &= ~HTS221_PP_OD_MASK; - tmp |= (uint8_t)value; + tmp &= ~HTS221_PP_OD_MASK; + tmp |= (uint8_t)value; - if(HTS221_write_reg(handle, HTS221_CTRL_REG3, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_write_reg(handle, HTS221_CTRL_REG3, 1, &tmp)) { + return HTS221_ERROR; + } - return HTS221_OK; + return HTS221_OK; } /** @@ -892,16 +958,17 @@ * @param Pointer to the returned value with output type configuration. * @retval Error code [HTS221_OK, HTS221_ERROR]. */ -HTS221_Error_et HTS221_Get_IrqOutputType(void *handle, HTS221_OutputType_et* value) +HTS221_Error_et HTS221_Get_IrqOutputType(void *handle, HTS221_OutputType_et *value) { - uint8_t tmp; + uint8_t tmp; - if(HTS221_read_reg(handle, HTS221_CTRL_REG3, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_CTRL_REG3, 1, &tmp)) { + return HTS221_ERROR; + } - *value = (HTS221_OutputType_et)(tmp & HTS221_PP_OD_MASK); + *value = (HTS221_OutputType_et)(tmp & HTS221_PP_OD_MASK); - return HTS221_OK; + return HTS221_OK; } /** @@ -913,20 +980,22 @@ */ HTS221_Error_et HTS221_Set_IrqEnable(void *handle, HTS221_State_et status) { - uint8_t tmp; + uint8_t tmp; + + HTS221_assert_param(IS_HTS221_State(status)); - HTS221_assert_param(IS_HTS221_State(status)); - - if(HTS221_read_reg(handle, HTS221_CTRL_REG3, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_CTRL_REG3, 1, &tmp)) { + return HTS221_ERROR; + } - tmp &= ~HTS221_DRDY_MASK; - tmp |= ((uint8_t)status) << HTS221_DRDY_BIT; + tmp &= ~HTS221_DRDY_MASK; + tmp |= ((uint8_t)status) << HTS221_DRDY_BIT; - if(HTS221_write_reg(handle, HTS221_CTRL_REG3, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_write_reg(handle, HTS221_CTRL_REG3, 1, &tmp)) { + return HTS221_ERROR; + } - return HTS221_OK; + return HTS221_OK; } /** @@ -935,16 +1004,17 @@ * @param Pointer to the returned status of the interrupt mode configuration [HTS221_ENABLE/HTS221_DISABLE]. * @retval Error code [HTS221_OK, HTS221_ERROR]. */ -HTS221_Error_et HTS221_Get_IrqEnable(void *handle, HTS221_State_et* status) +HTS221_Error_et HTS221_Get_IrqEnable(void *handle, HTS221_State_et *status) { - uint8_t tmp; + uint8_t tmp; - if(HTS221_read_reg(handle, HTS221_CTRL_REG3, 1, &tmp)) - return HTS221_ERROR; + if (HTS221_read_reg(handle, HTS221_CTRL_REG3, 1, &tmp)) { + return HTS221_ERROR; + } - *status = (HTS221_State_et)((tmp & HTS221_DRDY_MASK) >> HTS221_DRDY_BIT); + *status = (HTS221_State_et)((tmp & HTS221_DRDY_MASK) >> HTS221_DRDY_BIT); - return HTS221_OK; + return HTS221_OK; } @@ -956,20 +1026,19 @@ * @param line: assert_param error line source number * @retval : None */ -void HTS221_assert_failed(uint8_t* file, uint32_t line) +void HTS221_assert_failed(uint8_t *file, uint32_t line) { - /* User can add his own implementation to report the file name and line number */ - printf("Wrong parameters value: file %s on line %d\r\n", file, (int)line); + /* User can add his own implementation to report the file name and line number */ + printf("Wrong parameters value: file %s on line %d\r\n", file, (int)line); - /* Infinite loop */ - while (1) - { - } + /* Infinite loop */ + while (1) { + } } #endif #ifdef __cplusplus - } +} #endif /**
diff -r 9f317607860e -r ccf7f36492ae HTS221_driver.h --- a/HTS221_driver.h Mon Mar 04 13:50:28 2019 +0000 +++ b/HTS221_driver.h Wed Jul 24 14:17:21 2019 +0000 @@ -60,7 +60,7 @@ */ #define HTS221_assert_param(expr) ((expr) ? (void)0 : HTS221_assert_failed((uint8_t *)__FILE__, __LINE__)) /* Exported functions ------------------------------------------------------- */ -void HTS221_assert_failed(uint8_t* file, uint32_t line); +void HTS221_assert_failed(uint8_t *file, uint32_t line); #else #define HTS221_assert_param(expr) ((void)0) #endif /* USE_FULL_ASSERT_HTS221 */ @@ -99,16 +99,15 @@ /** * @brief Humidity average. */ -typedef enum -{ - HTS221_AVGH_4 = (uint8_t)0x00, /*!< Internal average on 4 samples */ - HTS221_AVGH_8 = (uint8_t)0x01, /*!< Internal average on 8 samples */ - HTS221_AVGH_16 = (uint8_t)0x02, /*!< Internal average on 16 samples */ - HTS221_AVGH_32 = (uint8_t)0x03, /*!< Internal average on 32 samples */ - HTS221_AVGH_64 = (uint8_t)0x04, /*!< Internal average on 64 samples */ - HTS221_AVGH_128 = (uint8_t)0x05, /*!< Internal average on 128 samples */ - HTS221_AVGH_256 = (uint8_t)0x06, /*!< Internal average on 256 samples */ - HTS221_AVGH_512 = (uint8_t)0x07 /*!< Internal average on 512 samples */ +typedef enum { + HTS221_AVGH_4 = (uint8_t)0x00, /*!< Internal average on 4 samples */ + HTS221_AVGH_8 = (uint8_t)0x01, /*!< Internal average on 8 samples */ + HTS221_AVGH_16 = (uint8_t)0x02, /*!< Internal average on 16 samples */ + HTS221_AVGH_32 = (uint8_t)0x03, /*!< Internal average on 32 samples */ + HTS221_AVGH_64 = (uint8_t)0x04, /*!< Internal average on 64 samples */ + HTS221_AVGH_128 = (uint8_t)0x05, /*!< Internal average on 128 samples */ + HTS221_AVGH_256 = (uint8_t)0x06, /*!< Internal average on 256 samples */ + HTS221_AVGH_512 = (uint8_t)0x07 /*!< Internal average on 512 samples */ } HTS221_Avgh_et; #define IS_HTS221_AVGH(AVGH) ((AVGH == HTS221_AVGH_4) || (AVGH == HTS221_AVGH_8) || \ (AVGH == HTS221_AVGH_16) || (AVGH == HTS221_AVGH_32) || \ @@ -118,16 +117,15 @@ /** * @brief Temperature average. */ -typedef enum -{ - HTS221_AVGT_2 = (uint8_t)0x00, /*!< Internal average on 2 samples */ - HTS221_AVGT_4 = (uint8_t)0x08, /*!< Internal average on 4 samples */ - HTS221_AVGT_8 = (uint8_t)0x10, /*!< Internal average on 8 samples */ - HTS221_AVGT_16 = (uint8_t)0x18, /*!< Internal average on 16 samples */ - HTS221_AVGT_32 = (uint8_t)0x20, /*!< Internal average on 32 samples */ - HTS221_AVGT_64 = (uint8_t)0x28, /*!< Internal average on 64 samples */ - HTS221_AVGT_128 = (uint8_t)0x30, /*!< Internal average on 128 samples */ - HTS221_AVGT_256 = (uint8_t)0x38 /*!< Internal average on 256 samples */ +typedef enum { + HTS221_AVGT_2 = (uint8_t)0x00, /*!< Internal average on 2 samples */ + HTS221_AVGT_4 = (uint8_t)0x08, /*!< Internal average on 4 samples */ + HTS221_AVGT_8 = (uint8_t)0x10, /*!< Internal average on 8 samples */ + HTS221_AVGT_16 = (uint8_t)0x18, /*!< Internal average on 16 samples */ + HTS221_AVGT_32 = (uint8_t)0x20, /*!< Internal average on 32 samples */ + HTS221_AVGT_64 = (uint8_t)0x28, /*!< Internal average on 64 samples */ + HTS221_AVGT_128 = (uint8_t)0x30, /*!< Internal average on 128 samples */ + HTS221_AVGT_256 = (uint8_t)0x38 /*!< Internal average on 256 samples */ } HTS221_Avgt_et; #define IS_HTS221_AVGT(AVGT) ((AVGT == HTS221_AVGT_2) || (AVGT == HTS221_AVGT_4) || \ (AVGT == HTS221_AVGT_8) || (AVGT == HTS221_AVGT_16) || \ @@ -137,12 +135,11 @@ /** * @brief Output data rate configuration. */ -typedef enum -{ - HTS221_ODR_ONE_SHOT = (uint8_t)0x00, /*!< Output Data Rate: one shot */ - HTS221_ODR_1HZ = (uint8_t)0x01, /*!< Output Data Rate: 1Hz */ - HTS221_ODR_7HZ = (uint8_t)0x02, /*!< Output Data Rate: 7Hz */ - HTS221_ODR_12_5HZ = (uint8_t)0x03, /*!< Output Data Rate: 12.5Hz */ +typedef enum { + HTS221_ODR_ONE_SHOT = (uint8_t)0x00, /*!< Output Data Rate: one shot */ + HTS221_ODR_1HZ = (uint8_t)0x01, /*!< Output Data Rate: 1Hz */ + HTS221_ODR_7HZ = (uint8_t)0x02, /*!< Output Data Rate: 7Hz */ + HTS221_ODR_12_5HZ = (uint8_t)0x03, /*!< Output Data Rate: 12.5Hz */ } HTS221_Odr_et; #define IS_HTS221_ODR(ODR) ((ODR == HTS221_ODR_ONE_SHOT) || (ODR == HTS221_ODR_1HZ) || \ (ODR == HTS221_ODR_7HZ) || (ODR == HTS221_ODR_12_5HZ)) @@ -151,48 +148,44 @@ /** * @brief Push-pull/Open Drain selection on DRDY pin. */ -typedef enum -{ - HTS221_PUSHPULL = (uint8_t)0x00, /*!< DRDY pin in push pull */ - HTS221_OPENDRAIN = (uint8_t)0x40 /*!< DRDY pin in open drain */ +typedef enum { + HTS221_PUSHPULL = (uint8_t)0x00, /*!< DRDY pin in push pull */ + HTS221_OPENDRAIN = (uint8_t)0x40 /*!< DRDY pin in open drain */ } HTS221_OutputType_et; #define IS_HTS221_OutputType(MODE) ((MODE == HTS221_PUSHPULL) || (MODE == HTS221_OPENDRAIN)) /** * @brief Active level of DRDY pin. */ -typedef enum -{ - HTS221_HIGH_LVL = (uint8_t)0x00, /*!< HIGH state level for DRDY pin */ - HTS221_LOW_LVL = (uint8_t)0x80 /*!< LOW state level for DRDY pin */ +typedef enum { + HTS221_HIGH_LVL = (uint8_t)0x00, /*!< HIGH state level for DRDY pin */ + HTS221_LOW_LVL = (uint8_t)0x80 /*!< LOW state level for DRDY pin */ } HTS221_DrdyLevel_et; #define IS_HTS221_DrdyLevelType(MODE) ((MODE == HTS221_HIGH_LVL) || (MODE == HTS221_LOW_LVL)) /** * @brief Driver Version Info structure definition. */ -typedef struct -{ - uint8_t Major; - uint8_t Minor; - uint8_t Point; +typedef struct { + uint8_t Major; + uint8_t Minor; + uint8_t Point; } HTS221_DriverVersion_st; /** * @brief HTS221 Init structure definition. */ -typedef struct -{ - HTS221_Avgh_et avg_h; /*!< Humidity average */ - HTS221_Avgt_et avg_t; /*!< Temperature average */ - HTS221_Odr_et odr; /*!< Output data rate */ - HTS221_State_et bdu_status; /*!< HTS221_ENABLE/HTS221_DISABLE the block data update */ - HTS221_State_et heater_status; /*!< HTS221_ENABLE/HTS221_DISABLE the internal heater */ +typedef struct { + HTS221_Avgh_et avg_h; /*!< Humidity average */ + HTS221_Avgt_et avg_t; /*!< Temperature average */ + HTS221_Odr_et odr; /*!< Output data rate */ + HTS221_State_et bdu_status; /*!< HTS221_ENABLE/HTS221_DISABLE the block data update */ + HTS221_State_et heater_status; /*!< HTS221_ENABLE/HTS221_DISABLE the internal heater */ - HTS221_DrdyLevel_et irq_level; /*!< HTS221_HIGH_LVL/HTS221_LOW_LVL the level for DRDY pin */ - HTS221_OutputType_et irq_output_type; /*!< Output configuration for DRDY pin */ - HTS221_State_et irq_enable; /*!< HTS221_ENABLE/HTS221_DISABLE interrupt on DRDY pin */ + HTS221_DrdyLevel_et irq_level; /*!< HTS221_HIGH_LVL/HTS221_LOW_LVL the level for DRDY pin */ + HTS221_OutputType_et irq_output_type; /*!< Output configuration for DRDY pin */ + HTS221_State_et irq_enable; /*!< HTS221_ENABLE/HTS221_DISABLE interrupt on DRDY pin */ } HTS221_Init_st; /** @@ -451,47 +444,47 @@ * @{ */ -HTS221_Error_et HTS221_read_reg( void *handle, uint8_t RegAddr, uint16_t NumByteToRead, uint8_t *Data ); -HTS221_Error_et HTS221_write_reg( void *handle, uint8_t RegAddr, uint16_t NumByteToWrite, uint8_t *Data ); +HTS221_Error_et HTS221_read_reg(void *handle, uint8_t RegAddr, uint16_t NumByteToRead, uint8_t *Data); +HTS221_Error_et HTS221_write_reg(void *handle, uint8_t RegAddr, uint16_t NumByteToWrite, uint8_t *Data); -HTS221_Error_et HTS221_Get_DriverVersion(HTS221_DriverVersion_st* version); -HTS221_Error_et HTS221_Get_DeviceID(void *handle, uint8_t* deviceid); +HTS221_Error_et HTS221_Get_DriverVersion(HTS221_DriverVersion_st *version); +HTS221_Error_et HTS221_Get_DeviceID(void *handle, uint8_t *deviceid); -HTS221_Error_et HTS221_Set_InitConfig(void *handle, HTS221_Init_st* pxInit); -HTS221_Error_et HTS221_Get_InitConfig(void *handle, HTS221_Init_st* pxInit); +HTS221_Error_et HTS221_Set_InitConfig(void *handle, HTS221_Init_st *pxInit); +HTS221_Error_et HTS221_Get_InitConfig(void *handle, HTS221_Init_st *pxInit); HTS221_Error_et HTS221_DeInit(void *handle); -HTS221_Error_et HTS221_IsMeasurementCompleted(void *handle, HTS221_BitStatus_et* Is_Measurement_Completed); +HTS221_Error_et HTS221_IsMeasurementCompleted(void *handle, HTS221_BitStatus_et *Is_Measurement_Completed); -HTS221_Error_et HTS221_Get_Measurement(void *handle, uint16_t* humidity, int16_t* temperature); -HTS221_Error_et HTS221_Get_RawMeasurement(void *handle, int16_t* humidity, int16_t* temperature); -HTS221_Error_et HTS221_Get_Humidity(void *handle, uint16_t* value); -HTS221_Error_et HTS221_Get_HumidityRaw(void *handle, int16_t* value); -HTS221_Error_et HTS221_Get_TemperatureRaw(void *handle, int16_t* value); -HTS221_Error_et HTS221_Get_Temperature(void *handle, int16_t* value); -HTS221_Error_et HTS221_Get_DataStatus(void *handle, HTS221_BitStatus_et* humidity, HTS221_BitStatus_et* temperature); +HTS221_Error_et HTS221_Get_Measurement(void *handle, uint16_t *humidity, int16_t *temperature); +HTS221_Error_et HTS221_Get_RawMeasurement(void *handle, int16_t *humidity, int16_t *temperature); +HTS221_Error_et HTS221_Get_Humidity(void *handle, uint16_t *value); +HTS221_Error_et HTS221_Get_HumidityRaw(void *handle, int16_t *value); +HTS221_Error_et HTS221_Get_TemperatureRaw(void *handle, int16_t *value); +HTS221_Error_et HTS221_Get_Temperature(void *handle, int16_t *value); +HTS221_Error_et HTS221_Get_DataStatus(void *handle, HTS221_BitStatus_et *humidity, HTS221_BitStatus_et *temperature); HTS221_Error_et HTS221_Activate(void *handle); HTS221_Error_et HTS221_DeActivate(void *handle); HTS221_Error_et HTS221_Set_AvgHT(void *handle, HTS221_Avgh_et avgh, HTS221_Avgt_et avgt); HTS221_Error_et HTS221_Set_AvgH(void *handle, HTS221_Avgh_et avgh); HTS221_Error_et HTS221_Set_AvgT(void *handle, HTS221_Avgt_et avgt); -HTS221_Error_et HTS221_Get_AvgHT(void *handle, HTS221_Avgh_et* avgh, HTS221_Avgt_et* avgt); +HTS221_Error_et HTS221_Get_AvgHT(void *handle, HTS221_Avgh_et *avgh, HTS221_Avgt_et *avgt); HTS221_Error_et HTS221_Set_BduMode(void *handle, HTS221_State_et status); -HTS221_Error_et HTS221_Get_BduMode(void *handle, HTS221_State_et* status); +HTS221_Error_et HTS221_Get_BduMode(void *handle, HTS221_State_et *status); HTS221_Error_et HTS221_Set_PowerDownMode(void *handle, HTS221_BitStatus_et status); -HTS221_Error_et HTS221_Get_PowerDownMode(void *handle, HTS221_BitStatus_et* status); +HTS221_Error_et HTS221_Get_PowerDownMode(void *handle, HTS221_BitStatus_et *status); HTS221_Error_et HTS221_Set_Odr(void *handle, HTS221_Odr_et odr); -HTS221_Error_et HTS221_Get_Odr(void *handle, HTS221_Odr_et* odr); +HTS221_Error_et HTS221_Get_Odr(void *handle, HTS221_Odr_et *odr); HTS221_Error_et HTS221_MemoryBoot(void *handle); HTS221_Error_et HTS221_Set_HeaterState(void *handle, HTS221_State_et status); -HTS221_Error_et HTS221_Get_HeaterState(void *handle, HTS221_State_et* status); +HTS221_Error_et HTS221_Get_HeaterState(void *handle, HTS221_State_et *status); HTS221_Error_et HTS221_StartOneShotMeasurement(void *handle); HTS221_Error_et HTS221_Set_IrqActiveLevel(void *handle, HTS221_DrdyLevel_et status); -HTS221_Error_et HTS221_Get_IrqActiveLevel(void *handle, HTS221_DrdyLevel_et* status); +HTS221_Error_et HTS221_Get_IrqActiveLevel(void *handle, HTS221_DrdyLevel_et *status); HTS221_Error_et HTS221_Set_IrqOutputType(void *handle, HTS221_OutputType_et value); -HTS221_Error_et HTS221_Get_IrqOutputType(void *handle, HTS221_OutputType_et* value); +HTS221_Error_et HTS221_Get_IrqOutputType(void *handle, HTS221_OutputType_et *value); HTS221_Error_et HTS221_Set_IrqEnable(void *handle, HTS221_State_et status); -HTS221_Error_et HTS221_Get_IrqEnable(void *handle, HTS221_State_et* status); +HTS221_Error_et HTS221_Get_IrqEnable(void *handle, HTS221_State_et *status); /** * @}