HTS221 Part Drivers API Documentation - Core

This page documents the API of the Core component of the HTS221 Part Drivers.

An overview of the driver is also available here: main_doc .

Functions

Functions

hts221_drv_status_t hts221_drv_init ( hts221_object_t * p_obj , uint32_t id )

initialize the HTS221 sensor.

Parameters :
  • p_obj – the device object

  • id – the device instance id

Return values :

0 – in case of success, an error code otherwise

hts221_drv_status_t hts221_drv_deinit ( hts221_object_t * p_obj )

deinitialize the HTS221 sensor.

Parameters :

p_obj – the device object

Return values :

0 – in case of success, an error code otherwise

hts221_drv_status_t hts221_drv_read_id ( hts221_object_t * p_obj , uint8_t * id )

get who_am_i value.

Parameters :
  • p_obj – the device object

  • id – the who_am_i value

Return values :

0 – in case of success, an error code otherwise

hts221_drv_status_t hts221_drv_get_init_status ( hts221_object_t * p_obj , uint8_t * status )

get the hts221 initialization status.

Parameters :
  • p_obj – the device object

  • status – 1 if initialized, 0 otherwise

Return values :

0 – in case of success, an error code otherwise

hts221_drv_status_t hts221_drv_enable ( hts221_object_t * p_obj )

enable the hts221 sensor.

Parameters :

p_obj – the device object

Return values :

0 – in case of success, an error code otherwise

hts221_drv_status_t hts221_drv_disable ( hts221_object_t * p_obj )

disable the hts221 humidity sensor.

Parameters :

p_obj – the device object

Return values :

0 – in case of success, an error code otherwise

hts221_drv_status_t hts221_drv_get_outputdatarate ( hts221_object_t * p_obj , float_t * odr )

get output data rate.

Parameters :
  • p_obj – the device object

  • odr – the output data rate value

Return values :

0 – in case of success, an error code otherwise

hts221_drv_status_t hts221_drv_set_outputdatarate ( hts221_object_t * p_obj , float_t odr )

set output data rate.

Parameters :
  • p_obj – the device p_obj

  • odr – the output data rate value to be set

Return values :

0 – in case of success, an error code otherwise

hts221_drv_status_t hts221_drv_get_humidity ( hts221_object_t * p_obj , float_t * value )

get the HTS221 humidity value.

Parameters :
  • p_obj – the device object

  • value – pointer where the humidity value is written

Return values :

0 – in case of success, an error code otherwise

hts221_drv_status_t hts221_drv_hum_get_drdy_status ( hts221_object_t * p_obj , uint8_t * status )

get the HTS221 humidity data-ready bit value.

Parameters :
  • p_obj – the device p_obj

  • status – the status of the data-ready bit

Return values :

0 – in case of success, an error code otherwise

hts221_drv_status_t hts221_drv_get_temperature ( hts221_object_t * p_obj , float_t * value )

get the HTS221 temperature value.

Parameters :
  • p_obj – the device p_obj

  • value – pointer where the temperature value is written

Return values :

0 – in case of success, an error code otherwise

hts221_drv_status_t hts221_drv_temp_get_drdy_status ( hts221_object_t * p_obj , uint8_t * status )

get the hts221 temperature data-ready bit value.

Parameters :
  • p_obj – the device p_obj

  • status – the status of the data-ready bit

Return values :

0 – in case of success, an error code otherwise

hts221_drv_status_t hts221_drv_read_reg ( hts221_object_t * p_obj , uint8_t reg , uint8_t * data )

get the hts221 register value.

Parameters :
  • p_obj – the device object

  • reg – address to be read

  • data – pointer where the value is written

Return values :

0 – in case of success, an error code otherwise

hts221_drv_status_t hts221_drv_write_reg ( hts221_object_t * p_obj , uint8_t reg , uint8_t data )

set the hts221 register value.

Parameters :
  • p_obj – the device object

  • reg – address to be written

  • data – value to be written

Return values :

0 – in case of success, an error code otherwise

hts221_drv_status_t hts221_drv_set_one_shot ( hts221_object_t * p_obj )

set the hts221 one-shot mode.

Parameters :

p_obj – the device p_obj

Return values :

0 – in case of success, an error code otherwise

hts221_drv_status_t hts221_drv_get_one_shot_status ( hts221_object_t * p_obj , uint8_t * status )

get the hts221 one shot status.

Parameters :
  • p_obj – the device p_obj

  • status – pointer to the one shot status

Return values :

0 – in case of success, an error code otherwise

hts221_drv_status_t hts221_drv_enable_drdy_interrupt ( hts221_object_t * p_obj )

enable hts221 drdy interrupt mode.

Parameters :

p_obj – the device object

Return values :

0 – in case of success, an error code otherwise

hts221_drv_status_t hts221_drv_enable_irq ( hts221_object_t * p_obj )

Enable the interrupt.

Parameters :

p_obj – the device instance object

Return values :

0 – in case of success, an error code otherwise

hts221_drv_status_t hts221_drv_disable_irq ( hts221_object_t * p_obj )

disable the interrupt.

Parameters :

p_obj – the device instance object

Return values :

0 – in case of success, an error code otherwise

hts221_drv_status_t hts221_drv_register_callback ( hts221_object_t * pobj , hts221_callback_t cb , void * arg )

Register the callback function for interrupt events.

Parameters :
  • p_obj – the device instance object

  • cb – the callback function

  • arg – the optional argument given to the callback

Return values :

0 – in case of success, an error code otherwise

Types

Enums

enum hts221_drv_status_t

HTS221 driver status enum.

Values:

enumerator HTS221_OK

Status OK

enumerator HTS221_ERROR

Status error

Typedefs

typedef struct hts221_object_s hts221_object_t

HTS221 object structure type callback function pointer definition

typedef void ( * hts221_callback_t ) ( hts221_object_t * pobj , void * arg )
struct hts221_object_s

HTS221 object structure.

Public Members

hts221_io_t io_ctx

HTS221 IO context

stmdev_ctx_t ctx

HTS221 context

uint8_t is_initialized

Is HTS221 initialized

uint8_t is_enabled

Is humidity enabled

hts221_odr_t last_odr

Last output data rate

hts221_cb_ctx_t cb_ctx_irq

callback context for IRQ events

struct hts221_cb_ctx_t

Callback context structure.

Public Members

hts221_callback_t callback

Callback function to register

void * arg

Optional argument given to the callback

struct lin_t

HTS221 output value linearized structure.

Public Members

float_t x0

x0 value

float_t y0

y0 value

float_t x1

x1 value

float_t y1

y1 value

union hts221_axis3bit16_t
#include <hts221.h>

HTS221 3 axis 16 bit union.

Public Members

int16_t i16bit [ 3 ]

axis value 16 bit

uint8_t u8bit [ 6 ]

axis value 8 bit

union hts221_axis1bit16_t
#include <hts221.h>

HTS221 1 axis 16 bit union.

Public Members

int16_t i16bit

axis value 16 bit

uint8_t u8bit [ 2 ]

axis value 8 bit

union hts221_axis3bit32_t
#include <hts221.h>

HTS221 3 axis 32 bit union.

Public Members

int32_t i32bit [ 3 ]

axis value 32 bit

uint8_t u8bit [ 12 ]

axis value 8 bit

union hts221_axis1bit32_t
#include <hts221.h>

HTS221 1 axis 32 bit union.

Public Members

int32_t i32bit

axis value 32 bit

uint8_t u8bit [ 4 ]

axis value 8 bit

Constants and macros

Defines

HTS221_I2C_BUS 0U

HTS221_I2C_BUS

HTS221_SPI_3WIRES_BUS 1U

HTS221_SPI_3WIRES_BUS

HTS221_ODR_0_HZ_FP 0.0f

0 Hz output data rate

HTS221_ODR_1_HZ_FP 1.0f

1 Hz output data rate

HTS221_ODR_7_HZ_FP 7.0f

7 Hz output data rate

HTS221_ODR_12_HZ_5_FP 12.5f

12.5 Hz output data rate

HTS221_MAX_ODR 12.5f

temperature maximum output data rate

HTS221_MAX_HUM_VALUE 100.0f

humidity maximum value

HTS221_MIN_HUM_VALUE 0.0f

humidity minimum value