HTS221
Arduino library for the HTS221 humidity and temperature sensor
Loading...
Searching...
No Matches
HTS221_Driver.h File Reference

HTS221 driver header file. More...

#include <stdint.h>
Include dependency graph for HTS221_Driver.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  HTS221_DriverVersion_st
 Driver Version Info structure definition. More...
 
struct  HTS221_Init_st
 HTS221 Init structure definition. More...
 

Macros

#define USE_FULL_ASSERT_HTS221
 
#define HTS221_assert_param(expr)   ((expr) ? (void)0 : HTS221_assert_failed((uint8_t *)__FILE__, __LINE__))
 The assert_param macro is used for function's parameters check.
 
#define IS_HTS221_State(MODE)   ((MODE == HTS221_ENABLE) || (MODE == HTS221_DISABLE))
 
#define IS_HTS221_BitStatus(MODE)   ((MODE == HTS221_RESET) || (MODE == HTS221_SET))
 
#define IS_HTS221_AVGH(AVGH)
 
#define IS_HTS221_AVGT(AVGT)
 
#define IS_HTS221_ODR(ODR)
 
#define IS_HTS221_OutputType(MODE)   ((MODE == HTS221_PUSHPULL) || (MODE == HTS221_OPENDRAIN))
 
#define IS_HTS221_DrdyLevelType(MODE)   ((MODE == HTS221_HIGH_LVL) || (MODE == HTS221_LOW_LVL))
 
#define HTS221_BIT(x)   ((uint8_t)x)
 Bitfield positioning.
 
#define HTS221_I2C_ADDRESS   (uint8_t)0xBE
 I2C address.
 
#define HTS221_DRIVER_VERSION_MAJOR   (uint8_t)1
 Driver version.
 
#define HTS221_DRIVER_VERSION_MINOR   (uint8_t)1
 
#define HTS221_DRIVER_VERSION_POINT   (uint8_t)0
 
#define HTS221_WHO_AM_I_REG   (uint8_t)0x0F
 Device Identification register.
 
#define HTS221_WHO_AM_I_VAL   (uint8_t)0xBC
 Device Identification value.
 
#define HTS221_AV_CONF_REG   (uint8_t)0x10
 Humidity and temperature average mode register.
 
#define HTS221_AVGT_BIT   HTS221_BIT(3)
 
#define HTS221_AVGH_BIT   HTS221_BIT(0)
 
#define HTS221_AVGH_MASK   (uint8_t)0x07
 
#define HTS221_AVGT_MASK   (uint8_t)0x38
 
#define HTS221_CTRL_REG1   (uint8_t)0x20
 Control register 1.
 
#define HTS221_PD_BIT   HTS221_BIT(7)
 
#define HTS221_BDU_BIT   HTS221_BIT(2)
 
#define HTS221_ODR_BIT   HTS221_BIT(0)
 
#define HTS221_PD_MASK   (uint8_t)0x80
 
#define HTS221_BDU_MASK   (uint8_t)0x04
 
#define HTS221_ODR_MASK   (uint8_t)0x03
 
#define HTS221_CTRL_REG2   (uint8_t)0x21
 Control register 2.
 
#define HTS221_BOOT_BIT   HTS221_BIT(7)
 
#define HTS221_HEATER_BIT   HTS221_BIT(1)
 
#define HTS221_ONESHOT_BIT   HTS221_BIT(0)
 
#define HTS221_BOOT_MASK   (uint8_t)0x80
 
#define HTS221_HEATER_MASK   (uint8_t)0x02
 
#define HTS221_ONE_SHOT_MASK   (uint8_t)0x01
 
#define HTS221_CTRL_REG3   (uint8_t)0x22
 Control register 3.
 
#define HTS221_DRDY_H_L_BIT   HTS221_BIT(7)
 
#define HTS221_PP_OD_BIT   HTS221_BIT(6)
 
#define HTS221_DRDY_BIT   HTS221_BIT(2)
 
#define HTS221_DRDY_H_L_MASK   (uint8_t)0x80
 
#define HTS221_PP_OD_MASK   (uint8_t)0x40
 
#define HTS221_DRDY_MASK   (uint8_t)0x04
 
#define HTS221_STATUS_REG   (uint8_t)0x27
 Status register.
 
#define HTS221_H_DA_BIT   HTS221_BIT(1)
 
#define HTS221_T_DA_BIT   HTS221_BIT(0)
 
#define HTS221_HDA_MASK   (uint8_t)0x02
 
#define HTS221_TDA_MASK   (uint8_t)0x01
 
#define HTS221_HR_OUT_L_REG   (uint8_t)0x28
 Humidity data (LSB).
 
#define HTS221_HR_OUT_H_REG   (uint8_t)0x29
 Humidity data (MSB).
 
#define HTS221_TEMP_OUT_L_REG   (uint8_t)0x2A
 Temperature data (LSB).
 
#define HTS221_TEMP_OUT_H_REG   (uint8_t)0x2B
 Temperature data (MSB).
 
#define HTS221_H0_RH_X2   (uint8_t)0x30
 Calibration registers.
 
#define HTS221_H1_RH_X2   (uint8_t)0x31
 
#define HTS221_T0_DEGC_X8   (uint8_t)0x32
 
#define HTS221_T1_DEGC_X8   (uint8_t)0x33
 
#define HTS221_T0_T1_DEGC_H2   (uint8_t)0x35
 
#define HTS221_H0_T0_OUT_L   (uint8_t)0x36
 
#define HTS221_H0_T0_OUT_H   (uint8_t)0x37
 
#define HTS221_H1_T0_OUT_L   (uint8_t)0x3A
 
#define HTS221_H1_T0_OUT_H   (uint8_t)0x3B
 
#define HTS221_T0_OUT_L   (uint8_t)0x3C
 
#define HTS221_T0_OUT_H   (uint8_t)0x3D
 
#define HTS221_T1_OUT_L   (uint8_t)0x3E
 
#define HTS221_T1_OUT_H   (uint8_t)0x3F
 

Enumerations

enum  HTS221_Error_et { HTS221_OK = (uint8_t)0 , HTS221_ERROR = !HTS221_OK }
 Error code type. More...
 
enum  HTS221_State_et { HTS221_DISABLE = (uint8_t)0 , HTS221_ENABLE = !HTS221_DISABLE }
 State type. More...
 
enum  HTS221_BitStatus_et { HTS221_RESET = (uint8_t)0 , HTS221_SET = !HTS221_RESET }
 Bit status type. More...
 
enum  HTS221_Avgh_et {
  HTS221_AVGH_4 = (uint8_t)0x00 , HTS221_AVGH_8 = (uint8_t)0x01 , HTS221_AVGH_16 = (uint8_t)0x02 , HTS221_AVGH_32 = (uint8_t)0x03 ,
  HTS221_AVGH_64 = (uint8_t)0x04 , HTS221_AVGH_128 = (uint8_t)0x05 , HTS221_AVGH_256 = (uint8_t)0x06 , HTS221_AVGH_512 = (uint8_t)0x07
}
 Humidity average. More...
 
enum  HTS221_Avgt_et {
  HTS221_AVGT_2 = (uint8_t)0x00 , HTS221_AVGT_4 = (uint8_t)0x08 , HTS221_AVGT_8 = (uint8_t)0x10 , HTS221_AVGT_16 = (uint8_t)0x18 ,
  HTS221_AVGT_32 = (uint8_t)0x20 , HTS221_AVGT_64 = (uint8_t)0x28 , HTS221_AVGT_128 = (uint8_t)0x30 , HTS221_AVGT_256 = (uint8_t)0x38
}
 Temperature average. More...
 
enum  HTS221_Odr_et { HTS221_ODR_ONE_SHOT = (uint8_t)0x00 , HTS221_ODR_1HZ = (uint8_t)0x01 , HTS221_ODR_7HZ = (uint8_t)0x02 , HTS221_ODR_12_5HZ = (uint8_t)0x03 }
 Output data rate configuration. More...
 
enum  HTS221_OutputType_et { HTS221_PUSHPULL = (uint8_t)0x00 , HTS221_OPENDRAIN = (uint8_t)0x40 }
 Push-pull/Open Drain selection on DRDY pin. More...
 
enum  HTS221_DrdyLevel_et { HTS221_HIGH_LVL = (uint8_t)0x00 , HTS221_LOW_LVL = (uint8_t)0x80 }
 Active level of DRDY pin. More...
 

Functions

void HTS221_assert_failed (uint8_t *file, uint32_t line)
 Reports the name of the source file and the source line number where the assert_param error has occurred.
 
HTS221_Error_et HTS221_ReadReg (void *handle, uint8_t RegAddr, uint16_t NumByteToRead, uint8_t *Data)
 
HTS221_Error_et HTS221_WriteReg (void *handle, uint8_t RegAddr, uint16_t NumByteToWrite, uint8_t *Data)
 
HTS221_Error_et HTS221_Get_DriverVersion (HTS221_DriverVersion_st *version)
 Get the version of this driver.
 
HTS221_Error_et HTS221_Get_DeviceID (void *handle, uint8_t *deviceid)
 Get device type ID.
 
HTS221_Error_et HTS221_Set_InitConfig (void *handle, HTS221_Init_st *pxInit)
 Initializes the HTS221 with the specified parameters in HTS221_Init_st struct.
 
HTS221_Error_et HTS221_Get_InitConfig (void *handle, HTS221_Init_st *pxInit)
 Returns a HTS221_Init_st struct with the actual configuration.
 
HTS221_Error_et HTS221_DeInit (void *handle)
 De initialization function for HTS221. This function put the HTS221 in power down, make a memory boot and clear the data output flags.
 
HTS221_Error_et HTS221_IsMeasurementCompleted (void *handle, HTS221_BitStatus_et *Is_Measurement_Completed)
 Check if the single measurement has completed.
 
HTS221_Error_et HTS221_Get_Measurement (void *handle, uint16_t *humidity, int16_t *temperature)
 Read HTS221 output registers, and calculate humidity and temperature.
 
HTS221_Error_et HTS221_Get_RawMeasurement (void *handle, int16_t *humidity, int16_t *temperature)
 Read HTS221 output registers. Humidity and temperature.
 
HTS221_Error_et HTS221_Get_Humidity (void *handle, uint16_t *value)
 Read the humidity output and convert it using the factory calibration.
 
HTS221_Error_et HTS221_Get_HumidityRaw (void *handle, int16_t *value)
 Read HTS221 humidity output registers.
 
HTS221_Error_et HTS221_Get_TemperatureRaw (void *handle, int16_t *value)
 Read HTS221 temperature output registers.
 
HTS221_Error_et HTS221_Get_Temperature (void *handle, int16_t *value)
 Read the temperature output and convert it using the factory calibration.
 
HTS221_Error_et HTS221_Get_DataStatus (void *handle, HTS221_BitStatus_et *humidity, HTS221_BitStatus_et *temperature)
 Get the availability of new data for humidity and temperature.
 
HTS221_Error_et HTS221_Activate (void *handle)
 Exit from power down mode.
 
HTS221_Error_et HTS221_DeActivate (void *handle)
 Put the sensor in power down mode.
 
HTS221_Error_et HTS221_Set_AvgHT (void *handle, HTS221_Avgh_et avgh, HTS221_Avgt_et avgt)
 Set_ humidity and temperature average mode.
 
HTS221_Error_et HTS221_Set_AvgH (void *handle, HTS221_Avgh_et avgh)
 Set humidity average mode.
 
HTS221_Error_et HTS221_Set_AvgT (void *handle, HTS221_Avgt_et avgt)
 Set temperature average mode.
 
HTS221_Error_et HTS221_Get_AvgHT (void *handle, HTS221_Avgh_et *avgh, HTS221_Avgt_et *avgt)
 Get humidity and temperature average mode.
 
HTS221_Error_et HTS221_Set_BduMode (void *handle, HTS221_State_et status)
 Set block data update mode.
 
HTS221_Error_et HTS221_Get_BduMode (void *handle, HTS221_State_et *status)
 Get block data update mode.
 
HTS221_Error_et HTS221_Set_PowerDownMode (void *handle, HTS221_BitStatus_et status)
 Enter or exit from power down mode.
 
HTS221_Error_et HTS221_Get_PowerDownMode (void *handle, HTS221_BitStatus_et *status)
 Get if HTS221 is in active mode or in power down mode.
 
HTS221_Error_et HTS221_Set_Odr (void *handle, HTS221_Odr_et odr)
 Set the output data rate mode.
 
HTS221_Error_et HTS221_Get_Odr (void *handle, HTS221_Odr_et *odr)
 Get the output data rate mode.
 
HTS221_Error_et HTS221_MemoryBoot (void *handle)
 Reboot Memory Content.
 
HTS221_Error_et HTS221_Set_HeaterState (void *handle, HTS221_State_et status)
 Configure the internal heater.
 
HTS221_Error_et HTS221_Get_HeaterState (void *handle, HTS221_State_et *status)
 Get the internal heater.
 
HTS221_Error_et HTS221_StartOneShotMeasurement (void *handle)
 Set ONE_SHOT bit to start a new conversion (ODR mode has to be 00). Once the measurement is done, ONE_SHOT bit is self-cleared.
 
HTS221_Error_et HTS221_Set_IrqActiveLevel (void *handle, HTS221_DrdyLevel_et status)
 Set level configuration of the interrupt pin DRDY.
 
HTS221_Error_et HTS221_Get_IrqActiveLevel (void *handle, HTS221_DrdyLevel_et *status)
 Get level configuration of the interrupt pin DRDY.
 
HTS221_Error_et HTS221_Set_IrqOutputType (void *handle, HTS221_OutputType_et value)
 Set Push-pull/open drain configuration for the interrupt pin DRDY.
 
HTS221_Error_et HTS221_Get_IrqOutputType (void *handle, HTS221_OutputType_et *value)
 Get the configuration for the interrupt pin DRDY.
 
HTS221_Error_et HTS221_Set_IrqEnable (void *handle, HTS221_State_et status)
 Enable/disable the interrupt mode.
 
HTS221_Error_et HTS221_Get_IrqEnable (void *handle, HTS221_State_et *status)
 Get the interrupt mode.
 

Detailed Description

HTS221 driver header file.

Author
HESA Application Team
Version
V1.1
Date
10-August-2016
Attention

© COPYRIGHT(c) 2017 STMicroelectronics

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Macro Definition Documentation

◆ HTS221_assert_param

#define HTS221_assert_param (   expr)    ((expr) ? (void)0 : HTS221_assert_failed((uint8_t *)__FILE__, __LINE__))

The assert_param macro is used for function's parameters check.

Parameters
exprIf expr is false, it calls assert_failed function which reports the name of the source file and the source line number of the call that failed. If expr is true, it returns no value.
Return values
None

◆ USE_FULL_ASSERT_HTS221

#define USE_FULL_ASSERT_HTS221