RRH46410 Firmware Documentation
HS4xxx Sensor API

HS4xxx Temperature/Humidity Sensor API. More...

Files

file  hs4xxx.h
 HS4xxx sensor declarations.
 

Functions

int HS4xxx_Init (HSxxxx_t *sensor, Interface_t *hal)
 Initialize the sensor object. More...
 
int HS4xxx_ReadID (HSxxxx_t *sensor, uint32_t *id)
 Read the unique sensor ID of the HS4xxx. More...
 
int HS4xxx_Measure (HSxxxx_t *sensor, HSxxxx_Results_t *results)
 Perform a temperature/humidity measurement cycle. More...
 
int HS4xxx_MeasureHold (HSxxxx_t *sensor, HSxxxx_Results_t *results)
 Perform a temperature/humidity measurement cycle using hold mode. More...
 
int HS4xxx_MeasureStart (HSxxxx_t *sensor)
 Start a temperature/humidity measurement cycle in non-hold mode. More...
 
int HS4xxx_MeasureRead (HSxxxx_t *sensor, HSxxxx_Results_t *results)
 Read temperature/humidity results in non-hold mode. More...
 

Enumerations

enum  HS4xxx_ErrorCodes_t { hteHS4xxxCRCError = 1 }
 Error code definitions specific for the HS4xxx API. More...
 

Detailed Description

HS4xxx Temperature/Humidity Sensor API.

HS4xxx is a series of highly accurate, fully calibrated automotive-grade relative humidity and temperature sensors. HS4xxx sensors provide a CRC checksum for communication integrity checking and have different modes of operation.

The HS4xxx API provides convenient access to the sensor's temperature & humidity measurement capabilities.

Enumeration Type Documentation

◆ HS4xxx_ErrorCodes_t

Error code definitions specific for the HS4xxx API.

Enumerator
hteHS4xxxCRCError 

Result CRC error

Function Documentation

◆ HS4xxx_Init()

int HS4xxx_Init ( HSxxxx_t sensor,
Interface_t hal 
)

Initialize the sensor object.

This function tries accessing the HS4xxx I2C address using hal as hardware interface. On success, the sensor object is initialized and can be used afterwards. Otherwise, an error code is returned and the sensor object is not usable.

Note
The HS4xxx API requires that the HAL interface object has the Interface_t::i2cRead and Interface_t::i2cWrite members defined. In addition, HS4xxx_Measure() requires the Interface_t::msSleep member.
Parameters
sensorPointer to sensor object to be initialized
halPointer to HAL object providing physical communication
Returns
int Error code
Return values
0On success
otherOn error

◆ HS4xxx_Measure()

int HS4xxx_Measure ( HSxxxx_t sensor,
HSxxxx_Results_t results 
)

Perform a temperature/humidity measurement cycle.

This function starts a measurement cycle in non-hold mode, waits for the result to be available and reads it. If the checksum computation is correct the result is stored in the results data structure. Otherwise the contents of results is left unmodified and an error code is returned.

Note
Although the HS4xxx is able to perform the requested measurement with a single I2C transaction (refer to HS4xxx_MeasureHold), this function uses the HS4xxx_MeasureStart() and HS4xxx_MeasureRead() functions together with the Interface_t::msSleep function. This is to allow operation on a wider variety of I2C interfaces. HS4xxx_MeasureHold() requires a minimum of 200kHz I2C clock frequency which is not supported by all interfaces.
Parameters
sensorPointer to an initialized sensor object
resultsPointer to a data structure, to store results in
Returns
int Error code
Return values
0On success
otherOn error

◆ HS4xxx_MeasureHold()

int HS4xxx_MeasureHold ( HSxxxx_t sensor,
HSxxxx_Results_t results 
)

Perform a temperature/humidity measurement cycle using hold mode.

This function performs temperature/humidity measurements in hold mode and reads the results form the sensor. If the checksum computation is correct the result is stored in the results data structure. Otherwise the contents of results is left unmodified and an error code is returned.

Note
For hold measurements, the I2C clock frequency must be at least 200kHz. Otherwise the result readout is unreliable.
Parameters
sensorPointer to an initialized sensor object
resultsPointer to a data structure, to store results in
Returns
int Error code
Return values
0On success
otherOn error

◆ HS4xxx_MeasureRead()

int HS4xxx_MeasureRead ( HSxxxx_t sensor,
HSxxxx_Results_t results 
)

Read temperature/humidity results in non-hold mode.

This function reads the temperature/humidity results from a measurement that has been started through HS4xxx_MeasureStart() previously. If the checksum computation is correct the result is stored in the results data structure. Otherwise the contents of results is left unmodified and an error code is returned.

Parameters
sensorPointer to an initialized sensor object
resultsPointer to a data structure, to store results in
Returns
int Error code
Return values
0On success
otherOn error

◆ HS4xxx_MeasureStart()

int HS4xxx_MeasureStart ( HSxxxx_t sensor)

Start a temperature/humidity measurement cycle in non-hold mode.

Parameters
sensorPointer to an initialized sensor object
Returns
int Error code
Return values
0On success
otherOn error

◆ HS4xxx_ReadID()

int HS4xxx_ReadID ( HSxxxx_t sensor,
uint32_t *  id 
)

Read the unique sensor ID of the HS4xxx.

Parameters
sensorPointer to an initialized sensor object
idPointer buffer to store the ID
Returns
int Error code
Return values
0On success
otherOn error