LibDriver HTU31D
Loading...
Searching...
No Matches
htu31d base driver function

htu31d base driver modules More...

Collaboration diagram for htu31d base driver function:

Data Structures

struct  htu31d_handle_s
 htu31d handle structure definition More...
struct  htu31d_info_s
 htu31d information structure definition More...

Typedefs

typedef struct htu31d_handle_s htu31d_handle_t
 htu31d handle structure definition
typedef struct htu31d_info_s htu31d_info_t
 htu31d information structure definition

Enumerations

enum  htu31d_addr_pin_t { HTU31D_ADDR_PIN_LOW = (0x40 << 1) , HTU31D_ADDR_PIN_HIGH = (0x41 << 1) }
 htu31d addr pin enumeration definition More...
enum  htu31d_humidity_osr_t { HTU31D_HUMIDITY_OSR_VERY_HIGH = 3 , HTU31D_HUMIDITY_OSR_HIGH = 2 , HTU31D_HUMIDITY_OSR_MIDDLE = 1 , HTU31D_HUMIDITY_OSR_LOW = 0 }
 htu31d humidity osr enumeration definition More...
enum  htu31d_temperature_osr_t { HTU31D_TEMPERATURE_OSR_VERY_HIGH = 3 , HTU31D_TEMPERATURE_OSR_HIGH = 2 , HTU31D_TEMPERATURE_OSR_MIDDLE = 1 , HTU31D_TEMPERATURE_OSR_LOW = 0 }
 htu31d temperature osr enumeration definition More...
enum  htu31d_diagnostic_t {
  HTU31D_DIAGNOSTIC_NVM_ERROR = (1 << 7) , HTU31D_DIAGNOSTIC_HUMIDITY_UNDER_OVERRUN = (1 << 6) , HTU31D_DIAGNOSTIC_HUMIDITY_HIGH_ERROR = (1 << 5) , HTU31D_DIAGNOSTIC_HUMIDITY_LOW_ERROR = (1 << 4) ,
  HTU31D_DIAGNOSTIC_TEMPERATURE_UNDER_OVERRUN = (1 << 3) , HTU31D_DIAGNOSTIC_TEMPERATURE_HIGH_ERROR = (1 << 2) , HTU31D_DIAGNOSTIC_TEMPERATURE_LOW_ERROR = (1 << 1) , HTU31D_DIAGNOSTIC_HEATER_ON = (1 << 0)
}
 htu31d diagnostic enumeration definition More...

Functions

uint8_t htu31d_info (htu31d_info_t *info)
 get chip's information
uint8_t htu31d_set_addr_pin (htu31d_handle_t *handle, htu31d_addr_pin_t addr_pin)
 set the address pin
uint8_t htu31d_get_addr_pin (htu31d_handle_t *handle, htu31d_addr_pin_t *addr_pin)
 get the address pin
uint8_t htu31d_init (htu31d_handle_t *handle)
 initialize the chip
uint8_t htu31d_deinit (htu31d_handle_t *handle)
 close the chip
uint8_t htu31d_set_humidity_osr (htu31d_handle_t *handle, htu31d_humidity_osr_t osr)
 set humidity osr
uint8_t htu31d_get_humidity_osr (htu31d_handle_t *handle, htu31d_humidity_osr_t *osr)
 get humidity osr
uint8_t htu31d_set_temperature_osr (htu31d_handle_t *handle, htu31d_temperature_osr_t osr)
 set temperature osr
uint8_t htu31d_get_temperature_osr (htu31d_handle_t *handle, htu31d_temperature_osr_t *osr)
 get temperature osr
uint8_t htu31d_read_temperature_humidity (htu31d_handle_t *handle, uint16_t *temperature_raw, float *temperature_s, uint16_t *humidity_raw, float *humidity_s)
 read the temperature and humidity data
uint8_t htu31d_read_humidity (htu31d_handle_t *handle, uint16_t *humidity_raw, float *humidity_s)
 read the humidity data
uint8_t htu31d_soft_reset (htu31d_handle_t *handle)
 soft reset
uint8_t htu31d_set_heater_on (htu31d_handle_t *handle)
 enable heater
uint8_t htu31d_set_heater_off (htu31d_handle_t *handle)
 disable heater
uint8_t htu31d_get_serial_number (htu31d_handle_t *handle, uint8_t number[3])
 get the serial number
uint8_t htu31d_get_diagnostic (htu31d_handle_t *handle, uint8_t *diagnostic)
 get the diagnostic

Detailed Description

htu31d base driver modules

Typedef Documentation

◆ htu31d_handle_t

htu31d handle structure definition

◆ htu31d_info_t

typedef struct htu31d_info_s htu31d_info_t

htu31d information structure definition

Enumeration Type Documentation

◆ htu31d_addr_pin_t

htu31d addr pin enumeration definition

Enumerator
HTU31D_ADDR_PIN_LOW 

pin to gnd

HTU31D_ADDR_PIN_HIGH 

pin to vcc

Definition at line 62 of file driver_htu31d.h.

◆ htu31d_diagnostic_t

htu31d diagnostic enumeration definition

Enumerator
HTU31D_DIAGNOSTIC_NVM_ERROR 

nvm error

HTU31D_DIAGNOSTIC_HUMIDITY_UNDER_OVERRUN 

humidity under/overrun

HTU31D_DIAGNOSTIC_HUMIDITY_HIGH_ERROR 

humidity high error

HTU31D_DIAGNOSTIC_HUMIDITY_LOW_ERROR 

humidity low error

HTU31D_DIAGNOSTIC_TEMPERATURE_UNDER_OVERRUN 

temperature under/overrun

HTU31D_DIAGNOSTIC_TEMPERATURE_HIGH_ERROR 

temperature high error

HTU31D_DIAGNOSTIC_TEMPERATURE_LOW_ERROR 

temperature low error

HTU31D_DIAGNOSTIC_HEATER_ON 

heater on

Definition at line 93 of file driver_htu31d.h.

◆ htu31d_humidity_osr_t

htu31d humidity osr enumeration definition

Enumerator
HTU31D_HUMIDITY_OSR_VERY_HIGH 

0.007rh

HTU31D_HUMIDITY_OSR_HIGH 

0.010rh

HTU31D_HUMIDITY_OSR_MIDDLE 

0.014rh

HTU31D_HUMIDITY_OSR_LOW 

0.020rh

Definition at line 71 of file driver_htu31d.h.

◆ htu31d_temperature_osr_t

htu31d temperature osr enumeration definition

Enumerator
HTU31D_TEMPERATURE_OSR_VERY_HIGH 

0.012°C

HTU31D_TEMPERATURE_OSR_HIGH 

0.016°C

HTU31D_TEMPERATURE_OSR_MIDDLE 

0.025°C

HTU31D_TEMPERATURE_OSR_LOW 

0.040°C

Definition at line 82 of file driver_htu31d.h.

Function Documentation

◆ htu31d_deinit()

uint8_t htu31d_deinit ( htu31d_handle_t * handle)

close the chip

Parameters
[in]*handlepointer to an htu31d handle structure
Returns
status code
  • 0 success
  • 1 iic deinit failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 reset failed
Note
none

Definition at line 702 of file driver_htu31d.c.

◆ htu31d_get_addr_pin()

uint8_t htu31d_get_addr_pin ( htu31d_handle_t * handle,
htu31d_addr_pin_t * addr_pin )

get the address pin

Parameters
[in]*handlepointer to an htu31d handle structure
[out]*addr_pinpointer to an addr pin buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 194 of file driver_htu31d.c.

◆ htu31d_get_diagnostic()

uint8_t htu31d_get_diagnostic ( htu31d_handle_t * handle,
uint8_t * diagnostic )

get the diagnostic

Parameters
[in]*handlepointer to an htu31d handle structure
[out]*diagnosticpointer to a diagnostic buffer
Returns
status code
  • 0 success
  • 1 get diagnostic failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 crc checked error
Note
none

Definition at line 365 of file driver_htu31d.c.

◆ htu31d_get_humidity_osr()

uint8_t htu31d_get_humidity_osr ( htu31d_handle_t * handle,
htu31d_humidity_osr_t * osr )

get humidity osr

Parameters
[in]*handlepointer to an htu31d handle structure
[out]*osrpointer to a humidity osr buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 770 of file driver_htu31d.c.

◆ htu31d_get_serial_number()

uint8_t htu31d_get_serial_number ( htu31d_handle_t * handle,
uint8_t number[3] )

get the serial number

Parameters
[in]*handlepointer to an htu31d handle structure
[out]*numberpointer to a number buffer
Returns
status code
  • 0 success
  • 1 get serial number failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 crc checked error
Note
none

Definition at line 321 of file driver_htu31d.c.

◆ htu31d_get_temperature_osr()

uint8_t htu31d_get_temperature_osr ( htu31d_handle_t * handle,
htu31d_temperature_osr_t * osr )

get temperature osr

Parameters
[in]*handlepointer to an htu31d handle structure
[out]*osrpointer to a temperature osr buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 822 of file driver_htu31d.c.

◆ htu31d_info()

uint8_t htu31d_info ( htu31d_info_t * info)

get chip's information

Parameters
[out]*infopointer to an htu31d info structure
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 900 of file driver_htu31d.c.

◆ htu31d_init()

uint8_t htu31d_init ( htu31d_handle_t * handle)

initialize the chip

Parameters
[in]*handlepointer to an htu31d handle structure
Returns
status code
  • 0 success
  • 1 iic initialization failed
  • 2 handle is NULL
  • 3 linked functions is NULL
  • 4 reset failed
Note
none

Definition at line 628 of file driver_htu31d.c.

◆ htu31d_read_humidity()

uint8_t htu31d_read_humidity ( htu31d_handle_t * handle,
uint16_t * humidity_raw,
float * humidity_s )

read the humidity data

Parameters
[in]*handlepointer to an htu31d handle structure
[out]*humidity_rawpointer to a raw humidity buffer
[out]*humidity_spointer to a converted humidity buffer
Returns
status code
  • 0 success
  • 1 read humidity failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 crc is error
  • 5 param is error
Note
none

Definition at line 528 of file driver_htu31d.c.

◆ htu31d_read_temperature_humidity()

uint8_t htu31d_read_temperature_humidity ( htu31d_handle_t * handle,
uint16_t * temperature_raw,
float * temperature_s,
uint16_t * humidity_raw,
float * humidity_s )

read the temperature and humidity data

Parameters
[in]*handlepointer to an htu31d handle structure
[out]*temperature_rawpointer to a raw temperature buffer
[out]*temperature_spointer to a converted temperature buffer
[out]*humidity_rawpointer to a raw humidity buffer
[out]*humidity_spointer to a converted humidity buffer
Returns
status code
  • 0 success
  • 1 read temperature humidity failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 crc is error
  • 5 param is error
Note
none

Definition at line 413 of file driver_htu31d.c.

◆ htu31d_set_addr_pin()

uint8_t htu31d_set_addr_pin ( htu31d_handle_t * handle,
htu31d_addr_pin_t addr_pin )

set the address pin

Parameters
[in]*handlepointer to an htu31d handle structure
[in]addr_pinaddr pin
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 173 of file driver_htu31d.c.

◆ htu31d_set_heater_off()

uint8_t htu31d_set_heater_off ( htu31d_handle_t * handle)

disable heater

Parameters
[in]*handlepointer to an htu31d handle structure
Returns
status code
  • 0 success
  • 1 heater off failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 285 of file driver_htu31d.c.

◆ htu31d_set_heater_on()

uint8_t htu31d_set_heater_on ( htu31d_handle_t * handle)

enable heater

Parameters
[in]*handlepointer to an htu31d handle structure
Returns
status code
  • 0 success
  • 1 heater on failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 251 of file driver_htu31d.c.

◆ htu31d_set_humidity_osr()

uint8_t htu31d_set_humidity_osr ( htu31d_handle_t * handle,
htu31d_humidity_osr_t osr )

set humidity osr

Parameters
[in]*handlepointer to an htu31d handle structure
[in]osrhumidity osr
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 744 of file driver_htu31d.c.

◆ htu31d_set_temperature_osr()

uint8_t htu31d_set_temperature_osr ( htu31d_handle_t * handle,
htu31d_temperature_osr_t osr )

set temperature osr

Parameters
[in]*handlepointer to an htu31d handle structure
[in]osrtemperature osr
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 796 of file driver_htu31d.c.

◆ htu31d_soft_reset()

uint8_t htu31d_soft_reset ( htu31d_handle_t * handle)

soft reset

Parameters
[in]*handlepointer to an htu31d handle structure
Returns
status code
  • 0 success
  • 1 soft reset failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 216 of file driver_htu31d.c.