HDC3020 HAL API
Module: Board Components / TIDA-010997
HDC3020 Temperature/Humidity sensor driver. More…
Structures
Name |
|
|---|---|
struct |
Hdc3020_Hal_InitParamsType |
struct |
Hdc3020_Hal_DataType |
Types
Name |
|
|---|---|
enum |
Hdc3020_Hal_LowPowerModeType { HDC3020_HAL_LPM_0 = 0U, HDC3020_HAL_LPM_1, HDC3020_HAL_LPM_2, HDC3020_HAL_LPM_3, HDC3020_HAL_LPM_MAX} |
enum |
Hdc3020_Hal_MeasurementRateType { HDC3020_HAL_RATE_0_5HZ = 0U, HDC3020_HAL_RATE_1HZ, HDC3020_HAL_RATE_2HZ, HDC3020_HAL_RATE_4HZ, HDC3020_HAL_RATE_10HZ, HDC3020_HAL_RATE_MAX} |
enum |
Hdc3020_Hal_MeasurementModeType { HDC3020_HAL_MODE_TRIGGER_ON_DEMAND = 0U, HDC3020_HAL_MODE_AUTO_MEASUREMENT} |
enum |
Hdc3020_Hal_SensorType { HDC3020_HAL_SENSOR_BOTH = 0U, HDC3020_HAL_SENSOR_TEMPERATURE, HDC3020_HAL_SENSOR_HUMIDITY} |
Functions
Name |
|
|---|---|
Hdc3020_Hal_Init(const Hdc3020_Hal_InitParamsType * paramsPtr) |
|
Hdc3020_Hal_Reset(void ) |
|
Hdc3020_Hal_GetData(Hdc3020_Hal_DataType * dataPtr, Hdc3020_Hal_SensorType sensorType) |
|
Hdc3020_Hal_TriggerMeasurement(Hdc3020_Hal_LowPowerModeType lowPowerMode) |
|
Hdc3020_Hal_AwaitDataReady(void ) |
|
Hdc3020_Hal_SetMode(Hdc3020_Hal_MeasurementModeType mode, Hdc3020_Hal_LowPowerModeType lowPowerMode, Hdc3020_Hal_MeasurementRateType rate) |
|
Hdc3020_Hal_CalculateCrc(const uint8 * dataPtr, uint8 length) |
|
Hdc3020_Hal_WaitForTransferComplete(uint32 timeoutMs) |
|
void |
Hdc3020_Hal_SignalTransferComplete(uint32 errorMask) |
void |
Hdc3020_Hal_DelayMs(uint32 delayMs) |
Defines
Name |
|
|---|---|
HDC3020_HAL_ERROR_NONE |
|
HDC3020_HAL_ERROR_I2C |
|
HDC3020_HAL_ERROR_CRC |
|
HDC3020_HAL_ERROR_INVALID_DATA |
|
HDC3020_HAL_ERROR_INVALID_PARAMS |
Detailed Description
HDC3020 Temperature/Humidity sensor driver.
This module provides drivers for the HDC3020 sensor, connected via I2C.
Types Documentation
enum Hdc3020_Hal_LowPowerModeType
Enumerator |
Value |
Description |
|---|---|---|
HDC3020_HAL_LPM_0 |
0U |
Lowest noise, ~12.5ms conversion |
HDC3020_HAL_LPM_1 |
~7.5ms conversion |
|
HDC3020_HAL_LPM_2 |
~5.0ms conversion |
|
HDC3020_HAL_LPM_3 |
Lowest power, ~3.7ms conversion |
|
HDC3020_HAL_LPM_MAX |
HDC3020 low power modes.
Lower power modes reduce accuracy but decrease conversion time.
enum Hdc3020_Hal_MeasurementRateType
Enumerator |
Value |
Description |
|---|---|---|
HDC3020_HAL_RATE_0_5HZ |
0U |
0.5 measurements per second |
HDC3020_HAL_RATE_1HZ |
1 measurement per second |
|
HDC3020_HAL_RATE_2HZ |
2 measurements per second |
|
HDC3020_HAL_RATE_4HZ |
4 measurements per second |
|
HDC3020_HAL_RATE_10HZ |
10 measurements per second |
|
HDC3020_HAL_RATE_MAX |
HDC3020 measurement rates for auto measurement mode.
enum Hdc3020_Hal_MeasurementModeType
Enumerator |
Value |
Description |
|---|---|---|
HDC3020_HAL_MODE_TRIGGER_ON_DEMAND |
0U |
Single measurement on command |
HDC3020_HAL_MODE_AUTO_MEASUREMENT |
Continuous measurements at specified rate |
HDC3020 measurement modes.
enum Hdc3020_Hal_SensorType
Enumerator |
Value |
Description |
|---|---|---|
HDC3020_HAL_SENSOR_BOTH |
0U |
Both temperature and humidity sensors |
HDC3020_HAL_SENSOR_TEMPERATURE |
Temperature sensor only |
|
HDC3020_HAL_SENSOR_HUMIDITY |
Humidity sensor only |
HDC3020 sensor type selection.
Specifies which sensor(s) to read data from.
Functions Documentation
function Hdc3020_Hal_Init
sint32 Hdc3020_Hal_Init(
const Hdc3020_Hal_InitParamsType * paramsPtr
)
Initialize the HDC3020 sensor.
Parameters:
paramsPtr Pointer to initialization parameters
Return: HDC3020_HAL_ERROR_NONE on success, non-zero error code on failure
Stores the configuration, performs a soft reset, and sets the measurement mode.
function Hdc3020_Hal_Reset
sint32 Hdc3020_Hal_Reset(
void
)
Perform a soft reset of the HDC3020 sensor.
Return: HDC3020_HAL_ERROR_NONE on success, non-zero error code on failure
function Hdc3020_Hal_GetData
sint32 Hdc3020_Hal_GetData(
Hdc3020_Hal_DataType * dataPtr,
Hdc3020_Hal_SensorType sensorType
)
Get data from the selected sensor(s)
Parameters:
dataPtr Pointer to data structure to store the readings
sensorType Which sensor to read (temperature, humidity, or both)
Return: HDC3020_HAL_ERROR_NONE on success, non-zero error code on failure
In trigger-on-demand mode, this function will trigger a measurement and wait for conversion before reading data. In auto measurement mode, it reads the latest available measurement.
function Hdc3020_Hal_TriggerMeasurement
sint32 Hdc3020_Hal_TriggerMeasurement(
Hdc3020_Hal_LowPowerModeType lowPowerMode
)
Trigger a single measurement.
Parameters:
lowPowerMode Low power mode to use for the measurement
Return: HDC3020_HAL_ERROR_NONE on success, non-zero error code on failure
If in auto measurement mode, this function will exit auto mode first. After triggering, the caller should wait for conversion to complete before reading data.
function Hdc3020_Hal_AwaitDataReady
sint32 Hdc3020_Hal_AwaitDataReady(
void
)
Wait for measurement conversion to complete.
Return: HDC3020_HAL_ERROR_NONE on success
Delays for the conversion time corresponding to the currently configured low power mode.
function Hdc3020_Hal_SetMode
sint32 Hdc3020_Hal_SetMode(
Hdc3020_Hal_MeasurementModeType mode,
Hdc3020_Hal_LowPowerModeType lowPowerMode,
Hdc3020_Hal_MeasurementRateType rate
)
Set measurement mode for HDC3020.
Parameters:
mode Measurement mode (trigger-on-demand or auto)
lowPowerMode Low power mode setting
rate Measurement rate (only used in auto mode)
Return: HDC3020_HAL_ERROR_NONE on success, non-zero error code on failure
function Hdc3020_Hal_CalculateCrc
uint8 Hdc3020_Hal_CalculateCrc(
const uint8 * dataPtr,
uint8 length
)
Calculate CRC-8 checksum for HDC3020 communication.
Parameters:
dataPtr Pointer to data bytes
length Number of bytes
Return: Calculated CRC value
function Hdc3020_Hal_WaitForTransferComplete
sint32 Hdc3020_Hal_WaitForTransferComplete(
uint32 timeoutMs
)
Wait for I2C transfer to complete.
Parameters:
timeoutMs Timeout in milliseconds
Return: HDC3020_HAL_ERROR_NONE on success, non-zero error code on failure
Weak function that can be overridden for RTOS integration. Default implementation busy-waits with 1ms polling interval.
function Hdc3020_Hal_SignalTransferComplete
void Hdc3020_Hal_SignalTransferComplete(
uint32 errorMask
)
Signal that an I2C transfer has completed.
Parameters:
errorMask Error bit mask (0 = no error)
Weak function that can be overridden for RTOS integration. Called from the I2C transfer complete or error callback.
function Hdc3020_Hal_DelayMs
void Hdc3020_Hal_DelayMs(
uint32 delayMs
)
Millisecond delay.
Parameters:
delayMs Delay duration in milliseconds
Weak function that can be overridden for RTOS integration. Default implementation uses TIDA010997_HAL_CFG_DELAY_MS().
Macros Documentation
define HDC3020_HAL_ERROR_NONE
#define HDC3020_HAL_ERROR_NONE (0)
No error - operation successful.
define HDC3020_HAL_ERROR_I2C
#define HDC3020_HAL_ERROR_I2C (1)
I2C communication error.
define HDC3020_HAL_ERROR_CRC
#define HDC3020_HAL_ERROR_CRC (2)
CRC verification failed.
define HDC3020_HAL_ERROR_INVALID_DATA
#define HDC3020_HAL_ERROR_INVALID_DATA (3)
Invalid measurement data.
define HDC3020_HAL_ERROR_INVALID_PARAMS
#define HDC3020_HAL_ERROR_INVALID_PARAMS (4)
Invalid parameters passed to function.