LibDriver HDC2080
Loading...
Searching...
No Matches
driver_hdc2080.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_HDC2080_H
38#define DRIVER_HDC2080_H
39
40#include <stdio.h>
41#include <stdint.h>
42#include <string.h>
43
44#ifdef __cplusplus
45extern "C"{
46#endif
47
53
58
62typedef enum
63{
64 HDC2080_ADDRESS_0 = (0x40 << 1),
65 HDC2080_ADDRESS_1 = (0x41 << 1),
67
71typedef enum
72{
76
86
95
110
119
131
140
144typedef struct hdc2080_handle_s
145{
146 uint8_t (*iic_init)(void);
147 uint8_t (*iic_deinit)(void);
148 uint8_t (*iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
149 uint8_t (*iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
150 void (*delay_ms)(uint32_t ms);
151 void (*debug_print)(const char *const fmt, ...);
152 uint8_t inited;
153 uint8_t iic_addr;
155
171
175
182
189#define DRIVER_HDC2080_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
190
197#define DRIVER_HDC2080_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
198
205#define DRIVER_HDC2080_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
206
213#define DRIVER_HDC2080_LINK_IIC_READ(HANDLE, FUC) (HANDLE)->iic_read = FUC
214
221#define DRIVER_HDC2080_LINK_IIC_WRITE(HANDLE, FUC) (HANDLE)->iic_write = FUC
222
229#define DRIVER_HDC2080_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
230
237#define DRIVER_HDC2080_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
238
242
249
258uint8_t hdc2080_info(hdc2080_info_t *info);
259
270
281
295uint8_t hdc2080_init(hdc2080_handle_t *handle);
296
307uint8_t hdc2080_deinit(hdc2080_handle_t *handle);
308
323uint8_t hdc2080_read_temperature_humidity(hdc2080_handle_t *handle, uint16_t *temperature_raw, float *temperature_s,
324 uint16_t *humidity_raw, float *humidity_s);
325
338uint8_t hdc2080_read_temperature(hdc2080_handle_t *handle, uint16_t *temperature_raw, float *temperature_s);
339
352uint8_t hdc2080_read_humidity(hdc2080_handle_t *handle, uint16_t *humidity_raw, float *humidity_s);
353
365uint8_t hdc2080_read_poll(hdc2080_handle_t *handle);
366
379
392
405
418
431
443uint8_t hdc2080_get_mode(hdc2080_handle_t *handle, hdc2080_mode_t *mode);
444
457
470
481uint8_t hdc2080_soft_reset(hdc2080_handle_t *handle);
482
495
508
520uint8_t hdc2080_set_heater(hdc2080_handle_t *handle, hdc2080_bool_t enable);
521
533uint8_t hdc2080_get_heater(hdc2080_handle_t *handle, hdc2080_bool_t *enable);
534
547
560
573
586
599
612
624uint8_t hdc2080_set_humidity_high_threshold(hdc2080_handle_t *handle, uint8_t threshold);
625
637uint8_t hdc2080_get_humidity_high_threshold(hdc2080_handle_t *handle, uint8_t *threshold);
638
650uint8_t hdc2080_set_humidity_low_threshold(hdc2080_handle_t *handle, uint8_t threshold);
651
663uint8_t hdc2080_get_humidity_low_threshold(hdc2080_handle_t *handle, uint8_t *threshold);
664
676uint8_t hdc2080_set_temperature_high_threshold(hdc2080_handle_t *handle, uint8_t threshold);
677
689uint8_t hdc2080_get_temperature_high_threshold(hdc2080_handle_t *handle, uint8_t *threshold);
690
702uint8_t hdc2080_set_temperature_low_threshold(hdc2080_handle_t *handle, uint8_t threshold);
703
715uint8_t hdc2080_get_temperature_low_threshold(hdc2080_handle_t *handle, uint8_t *threshold);
716
728uint8_t hdc2080_set_humidity_offset_adjustment(hdc2080_handle_t *handle, int8_t offset);
729
741uint8_t hdc2080_get_humidity_offset_adjustment(hdc2080_handle_t *handle, int8_t *offset);
742
754uint8_t hdc2080_set_temperature_offset_adjustment(hdc2080_handle_t *handle, int8_t offset);
755
767uint8_t hdc2080_get_temperature_offset_adjustment(hdc2080_handle_t *handle, int8_t *offset);
768
782
796
808uint8_t hdc2080_set_humidity_max(hdc2080_handle_t *handle, uint8_t max);
809
821uint8_t hdc2080_get_humidity_max(hdc2080_handle_t *handle, uint8_t *max);
822
834uint8_t hdc2080_set_temperature_max(hdc2080_handle_t *handle, uint8_t max);
835
847uint8_t hdc2080_get_temperature_max(hdc2080_handle_t *handle, uint8_t *max);
848
860uint8_t hdc2080_get_interrupt_status(hdc2080_handle_t *handle, uint8_t *status);
861
873uint8_t hdc2080_humidity_convert_to_register(hdc2080_handle_t *handle, float percent, uint8_t *reg);
874
886uint8_t hdc2080_humidity_convert_to_data(hdc2080_handle_t *handle, uint8_t reg, float *percent);
887
899uint8_t hdc2080_temperature_convert_to_register(hdc2080_handle_t *handle, float deg, uint8_t *reg);
900
912uint8_t hdc2080_temperature_convert_to_data(hdc2080_handle_t *handle, uint8_t reg, float *deg);
913
925uint8_t hdc2080_humidity_offset_convert_to_register(hdc2080_handle_t *handle, float percent, int8_t *reg);
926
938uint8_t hdc2080_humidity_offset_convert_to_data(hdc2080_handle_t *handle, int8_t reg, float *percent);
939
951uint8_t hdc2080_temperature_offset_convert_to_register(hdc2080_handle_t *handle, float deg, int8_t *reg);
952
964uint8_t hdc2080_temperature_offset_convert_to_data(hdc2080_handle_t *handle, int8_t reg, float *deg);
965
969
976
990uint8_t hdc2080_set_reg(hdc2080_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
991
1005uint8_t hdc2080_get_reg(hdc2080_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
1006
1010
1014
1015#ifdef __cplusplus
1016}
1017#endif
1018
1019#endif
uint8_t hdc2080_set_measurement(hdc2080_handle_t *handle, hdc2080_bool_t enable)
enable or disable measurement
uint8_t hdc2080_init(hdc2080_handle_t *handle)
initialize the chip
uint8_t hdc2080_set_temperature_offset_adjustment(hdc2080_handle_t *handle, int8_t offset)
set temperature offset adjustment
uint8_t hdc2080_set_temperature_low_threshold(hdc2080_handle_t *handle, uint8_t threshold)
set temperature low threshold
uint8_t hdc2080_get_addr_pin(hdc2080_handle_t *handle, hdc2080_address_t *addr_pin)
get the iic address pin
uint8_t hdc2080_set_auto_measurement_mode(hdc2080_handle_t *handle, hdc2080_auto_measurement_mode_t mode)
set auto measurement mode
uint8_t hdc2080_get_temperature_low_threshold(hdc2080_handle_t *handle, uint8_t *threshold)
get temperature low threshold
struct hdc2080_handle_s hdc2080_handle_t
hdc2080 handle structure definition
uint8_t hdc2080_set_humidity_resolution(hdc2080_handle_t *handle, hdc2080_resolution_t resolution)
set humidity resolution
uint8_t hdc2080_read_temperature_humidity(hdc2080_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 hdc2080_get_humidity_low_threshold(hdc2080_handle_t *handle, uint8_t *threshold)
get humidity low threshold
uint8_t hdc2080_soft_reset(hdc2080_handle_t *handle)
soft reset
uint8_t hdc2080_deinit(hdc2080_handle_t *handle)
close the chip
uint8_t hdc2080_humidity_offset_convert_to_register(hdc2080_handle_t *handle, float percent, int8_t *reg)
convert the humidity offset to the register raw data
uint8_t hdc2080_set_temperature_resolution(hdc2080_handle_t *handle, hdc2080_resolution_t resolution)
set temperature resolution
uint8_t hdc2080_temperature_offset_convert_to_register(hdc2080_handle_t *handle, float deg, int8_t *reg)
convert the temperature offset to the register raw data
uint8_t hdc2080_temperature_convert_to_data(hdc2080_handle_t *handle, uint8_t reg, float *deg)
convert the register raw data to the temperature
uint8_t hdc2080_humidity_convert_to_data(hdc2080_handle_t *handle, uint8_t reg, float *percent)
convert the register raw data to the humidity
uint8_t hdc2080_set_interrupt_pin(hdc2080_handle_t *handle, hdc2080_bool_t enable)
enable or disable interrupt pin
uint8_t hdc2080_temperature_offset_convert_to_data(hdc2080_handle_t *handle, int8_t reg, float *deg)
convert the register raw data to the temperature offset
uint8_t hdc2080_get_interrupt_pin(hdc2080_handle_t *handle, hdc2080_bool_t *enable)
get interrupt pin status
uint8_t hdc2080_get_heater(hdc2080_handle_t *handle, hdc2080_bool_t *enable)
get heater status
uint8_t hdc2080_set_humidity_low_threshold(hdc2080_handle_t *handle, uint8_t threshold)
set humidity low threshold
uint8_t hdc2080_get_temperature_offset_adjustment(hdc2080_handle_t *handle, int8_t *offset)
get temperature offset adjustment
uint8_t hdc2080_get_humidity_max(hdc2080_handle_t *handle, uint8_t *max)
get humidity max
uint8_t hdc2080_set_addr_pin(hdc2080_handle_t *handle, hdc2080_address_t addr_pin)
set the iic address pin
hdc2080_bool_t
hdc2080 bool enumeration definition
uint8_t hdc2080_get_mode(hdc2080_handle_t *handle, hdc2080_mode_t *mode)
get the chip mode
uint8_t hdc2080_get_measurement(hdc2080_handle_t *handle, hdc2080_bool_t *enable)
get measurement status
hdc2080_resolution_t
hdc2080 resolution enumeration definition
uint8_t hdc2080_get_interrupt_polarity(hdc2080_handle_t *handle, hdc2080_interrupt_polarity_t *polarity)
get interrupt polarity
uint8_t hdc2080_set_mode(hdc2080_handle_t *handle, hdc2080_mode_t mode)
set the chip mode
uint8_t hdc2080_set_humidity_high_threshold(hdc2080_handle_t *handle, uint8_t threshold)
set humidity high threshold
hdc2080_auto_measurement_mode_t
hdc2080 auto measurement mode enumeration definition
hdc2080_interrupt_polarity_t
hdc2080 interrupt polarity enumeration definition
hdc2080_interrupt_mode_t
hdc2080 interrupt mode enumeration definition
uint8_t hdc2080_set_humidity_max(hdc2080_handle_t *handle, uint8_t max)
set humidity max
uint8_t hdc2080_get_humidity_offset_adjustment(hdc2080_handle_t *handle, int8_t *offset)
get humidity offset adjustment
hdc2080_interrupt_t
hdc2080 interrupt enumeration definition
uint8_t hdc2080_get_temperature_high_threshold(hdc2080_handle_t *handle, uint8_t *threshold)
get temperature high threshold
hdc2080_mode_t
hdc2080 mode enumeration definition
uint8_t hdc2080_get_auto_measurement_mode(hdc2080_handle_t *handle, hdc2080_auto_measurement_mode_t *mode)
get auto measurement mode
uint8_t hdc2080_set_interrupt_polarity(hdc2080_handle_t *handle, hdc2080_interrupt_polarity_t polarity)
set interrupt polarity
uint8_t hdc2080_get_interrupt_mode(hdc2080_handle_t *handle, hdc2080_interrupt_mode_t *mode)
get interrupt mode
uint8_t hdc2080_set_interrupt_mode(hdc2080_handle_t *handle, hdc2080_interrupt_mode_t mode)
set interrupt mode
struct hdc2080_info_s hdc2080_info_t
hdc2080 information structure definition
uint8_t hdc2080_set_humidity_offset_adjustment(hdc2080_handle_t *handle, int8_t offset)
set humidity offset adjustment
uint8_t hdc2080_set_heater(hdc2080_handle_t *handle, hdc2080_bool_t enable)
enable or disable heater
uint8_t hdc2080_humidity_convert_to_register(hdc2080_handle_t *handle, float percent, uint8_t *reg)
convert the humidity to the register raw data
uint8_t hdc2080_info(hdc2080_info_t *info)
get chip's information
uint8_t hdc2080_get_temperature_max(hdc2080_handle_t *handle, uint8_t *max)
get temperature max
uint8_t hdc2080_set_interrupt(hdc2080_handle_t *handle, hdc2080_interrupt_t interrupt, hdc2080_bool_t enable)
enable or disable interrupt
uint8_t hdc2080_set_temperature_max(hdc2080_handle_t *handle, uint8_t max)
set temperature max
uint8_t hdc2080_get_humidity_resolution(hdc2080_handle_t *handle, hdc2080_resolution_t *resolution)
get humidity resolution
uint8_t hdc2080_temperature_convert_to_register(hdc2080_handle_t *handle, float deg, uint8_t *reg)
convert the temperature to the register raw data
uint8_t hdc2080_get_interrupt_status(hdc2080_handle_t *handle, uint8_t *status)
get interrupt status
uint8_t hdc2080_read_humidity(hdc2080_handle_t *handle, uint16_t *humidity_raw, float *humidity_s)
read the humidity data
uint8_t hdc2080_set_temperature_high_threshold(hdc2080_handle_t *handle, uint8_t threshold)
set temperature high threshold
uint8_t hdc2080_get_humidity_high_threshold(hdc2080_handle_t *handle, uint8_t *threshold)
get humidity high threshold
uint8_t hdc2080_humidity_offset_convert_to_data(hdc2080_handle_t *handle, int8_t reg, float *percent)
convert the register raw data to the humidity offset
uint8_t hdc2080_read_poll(hdc2080_handle_t *handle)
read poll
uint8_t hdc2080_get_temperature_resolution(hdc2080_handle_t *handle, hdc2080_resolution_t *resolution)
get temperature resolution
uint8_t hdc2080_get_interrupt(hdc2080_handle_t *handle, hdc2080_interrupt_t interrupt, hdc2080_bool_t *enable)
get interrupt status
uint8_t hdc2080_read_temperature(hdc2080_handle_t *handle, uint16_t *temperature_raw, float *temperature_s)
read the temperature
hdc2080_address_t
hdc2080 address enumeration definition
@ HDC2080_BOOL_TRUE
@ HDC2080_BOOL_FALSE
@ HDC2080_RESOLUTION_9_BIT
@ HDC2080_RESOLUTION_11_BIT
@ HDC2080_RESOLUTION_14_BIT
@ HDC2080_AUTO_MEASUREMENT_MODE_1_HZ
@ HDC2080_AUTO_MEASUREMENT_MODE_1_DIV_120_HZ
@ HDC2080_AUTO_MEASUREMENT_MODE_1_DIV_60_HZ
@ HDC2080_AUTO_MEASUREMENT_MODE_1_DIV_5_HZ
@ HDC2080_AUTO_MEASUREMENT_MODE_2_HZ
@ HDC2080_AUTO_MEASUREMENT_MODE_5_HZ
@ HDC2080_AUTO_MEASUREMENT_MODE_DISABLED
@ HDC2080_AUTO_MEASUREMENT_MODE_1_DIV_10_HZ
@ HDC2080_INTERRUPT_POLARITY_LOW
@ HDC2080_INTERRUPT_POLARITY_HIGH
@ HDC2080_INTERRUPT_MODE_LEVEL
@ HDC2080_INTERRUPT_MODE_COMPARATOR
@ HDC2080_INTERRUPT_DRDY
@ HDC2080_INTERRUPT_HUMIDITY_HIGH_THRESHOLD
@ HDC2080_INTERRUPT_HUMIDITY_LOW_THRESHOLD
@ HDC2080_INTERRUPT_TEMPERATURE_LOW_THRESHOLD
@ HDC2080_INTERRUPT_TEMPERATURE_HIGH_THRESHOLD
@ HDC2080_MODE_TEMPERATURE
@ HDC2080_MODE_HUMIDITY_TEMPERATURE
@ HDC2080_ADDRESS_0
@ HDC2080_ADDRESS_1
uint8_t hdc2080_get_reg(hdc2080_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get chip register
uint8_t hdc2080_set_reg(hdc2080_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set chip register
hdc2080 handle structure definition
void(* delay_ms)(uint32_t ms)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
hdc2080 information structure definition
uint32_t driver_version
char manufacturer_name[32]