42#define CHIP_NAME "Texas Instruments HDC1080"
43#define MANUFACTURER_NAME "Texas Instruments"
44#define SUPPLY_VOLTAGE_MIN 2.7f
45#define SUPPLY_VOLTAGE_MAX 5.5f
46#define MAX_CURRENT 7.2f
47#define TEMPERATURE_MIN -40.0f
48#define TEMPERATURE_MAX 125.0f
49#define DRIVER_VERSION 1000
54#define HDC1080_ADDRESS 0x80
59#define HDC1080_REG_TEMPERATURE 0x00
60#define HDC1080_REG_HUMIDITY 0x01
61#define HDC1080_REG_CONFIG 0x02
62#define HDC1080_REG_SERIAL_ID_0 0xFB
63#define HDC1080_REG_SERIAL_ID_1 0xFC
64#define HDC1080_REG_SERIAL_ID_2 0xFD
65#define HDC1080_REG_MANUFACTURER_ID 0xFE
66#define HDC1080_REG_DEVICE_ID 0xFF
78static uint8_t a_hdc1080_iic_read_with_wait(
hdc1080_handle_t *handle, uint8_t reg, uint16_t *data)
88 *data = (uint16_t)((uint16_t)buf[0] << 8 | buf[1]);
104static uint8_t a_hdc1080_iic_read(
hdc1080_handle_t *handle, uint8_t reg, uint16_t *data)
114 *data = (uint16_t)((uint16_t)buf[0] << 8 | buf[1]);
130static uint8_t a_hdc1080_iic_write(
hdc1080_handle_t *handle, uint8_t reg, uint16_t data)
134 buf[0] = (data >> 8) & 0xFF;
135 buf[1] = (data >> 0) & 0xFF;
175 handle->
debug_print(
"hdc1080: iic_init is null.\n");
181 handle->
debug_print(
"hdc1080: iic_deinit is null.\n");
187 handle->
debug_print(
"hdc1080: iic_read is null.\n");
193 handle->
debug_print(
"hdc1080: iic_read_with_wait is null.\n");
199 handle->
debug_print(
"hdc1080: iic_write is null.\n");
205 handle->
debug_print(
"hdc1080: delay_ms is null.\n");
212 handle->
debug_print(
"hdc1080: iic init failed.\n");
219 handle->
debug_print(
"hdc1080: read manufacturer id failed.\n");
226 handle->
debug_print(
"hdc1080: manufacturer id is invalid.\n");
234 handle->
debug_print(
"hdc1080: read device id failed.\n");
241 handle->
debug_print(
"hdc1080: device id is invalid.\n");
250 handle->
debug_print(
"hdc1080: read config failed.\n");
260 handle->
debug_print(
"hdc1080: write config failed.\n");
294 handle->
debug_print(
"hdc1080: iic deinit failed.\n");
318 uint16_t *humidity_raw,
float *humidity_s)
335 handle->
debug_print(
"hdc1080: read temperature failed.\n");
339 *temperature_s = (float)(*temperature_raw) / 65536.0f * 165.0f - 40.0f;
343 handle->
debug_print(
"hdc1080: read humidity failed.\n");
347 *humidity_s = (float)(*humidity_raw) / 65536.0f * 100.0f;
380 handle->
debug_print(
"hdc1080: read temperature failed.\n");
384 *temperature_s = (float)(*temperature_raw) / 65536.0f * 165.0f - 40.0f;
417 handle->
debug_print(
"hdc1080: read humidity failed.\n");
421 *humidity_s = (float)(*humidity_raw) / 65536.0f * 100.0f;
453 handle->
debug_print(
"hdc1080: read config failed.\n");
462 handle->
debug_print(
"hdc1080: write config failed.\n");
499 handle->
debug_print(
"hdc1080: read config failed.\n");
504 data |= enable << 13;
508 handle->
debug_print(
"hdc1080: write config failed.\n");
544 handle->
debug_print(
"hdc1080: read config failed.\n");
581 handle->
debug_print(
"hdc1080: read config failed.\n");
590 handle->
debug_print(
"hdc1080: write config failed.\n");
626 handle->
debug_print(
"hdc1080: read config failed.\n");
663 handle->
debug_print(
"hdc1080: read config failed.\n");
700 handle->
debug_print(
"hdc1080: read config failed.\n");
705 data |= resolution << 10;
709 handle->
debug_print(
"hdc1080: write config failed.\n");
745 handle->
debug_print(
"hdc1080: read config failed.\n");
782 handle->
debug_print(
"hdc1080: read config failed.\n");
787 data |= resolution << 8;
791 handle->
debug_print(
"hdc1080: write config failed.\n");
827 handle->
debug_print(
"hdc1080: read config failed.\n");
864 handle->
debug_print(
"hdc1080: read serial id 0 failed.\n");
868 id[0] = (data >> 8) & 0xFF;
869 id[1] = (data >> 0) & 0xFF;
873 handle->
debug_print(
"hdc1080: read serial id 1 failed.\n");
877 id[2] = (data >> 8) & 0xFF;
878 id[3] = (data >> 0) & 0xFF;
882 handle->
debug_print(
"hdc1080: read serial id 2 failed.\n");
886 id[4] = (data >> 8) & 0xFF;
887 id[5] = (data >> 0) & 0xFF;
915 if (a_hdc1080_iic_write(handle, reg, data) != 0)
948 if (a_hdc1080_iic_read(handle, reg, data) != 0)
#define HDC1080_REG_HUMIDITY
#define HDC1080_REG_SERIAL_ID_0
#define HDC1080_REG_TEMPERATURE
chip register definition
#define HDC1080_ADDRESS
chip address definition
#define SUPPLY_VOLTAGE_MAX
#define HDC1080_REG_DEVICE_ID
#define HDC1080_REG_SERIAL_ID_1
#define MANUFACTURER_NAME
#define SUPPLY_VOLTAGE_MIN
#define HDC1080_REG_SERIAL_ID_2
#define CHIP_NAME
chip information definition
#define HDC1080_REG_MANUFACTURER_ID
#define HDC1080_REG_CONFIG
driver hdc1080 header file
uint8_t hdc1080_get_serial_id(hdc1080_handle_t *handle, uint8_t id[6])
get serial id
uint8_t hdc1080_info(hdc1080_info_t *info)
get chip's information
struct hdc1080_info_s hdc1080_info_t
hdc1080 information structure definition
uint8_t hdc1080_get_temperature_resolution(hdc1080_handle_t *handle, hdc1080_temperature_resolution_t *resolution)
get temperature resolution
uint8_t hdc1080_read_humidity(hdc1080_handle_t *handle, uint16_t *humidity_raw, float *humidity_s)
read the humidity data
uint8_t hdc1080_get_battery_status(hdc1080_handle_t *handle, hdc1080_battery_status_t *status)
get battery status
struct hdc1080_handle_s hdc1080_handle_t
hdc1080 handle structure definition
hdc1080_humidity_resolution_t
hdc1080 humidity resolution enumeration definition
hdc1080_mode_t
hdc1080 mode enumeration definition
hdc1080_temperature_resolution_t
hdc1080 temperature resolution enumeration definition
uint8_t hdc1080_read_temperature_humidity(hdc1080_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 hdc1080_deinit(hdc1080_handle_t *handle)
close the chip
uint8_t hdc1080_set_heater(hdc1080_handle_t *handle, hdc1080_bool_t enable)
enable or disable heater
uint8_t hdc1080_set_mode(hdc1080_handle_t *handle, hdc1080_mode_t mode)
set the chip mode
uint8_t hdc1080_get_humidity_resolution(hdc1080_handle_t *handle, hdc1080_humidity_resolution_t *resolution)
get humidity resolution
uint8_t hdc1080_set_humidity_resolution(hdc1080_handle_t *handle, hdc1080_humidity_resolution_t resolution)
set humidity resolution
uint8_t hdc1080_init(hdc1080_handle_t *handle)
initialize the chip
hdc1080_battery_status_t
hdc1080 battery status enumeration definition
uint8_t hdc1080_get_heater(hdc1080_handle_t *handle, hdc1080_bool_t *enable)
get the heater status
uint8_t hdc1080_software_reset(hdc1080_handle_t *handle)
software reset
uint8_t hdc1080_read_temperature(hdc1080_handle_t *handle, uint16_t *temperature_raw, float *temperature_s)
read the temperature
uint8_t hdc1080_get_mode(hdc1080_handle_t *handle, hdc1080_mode_t *mode)
get the chip mode
uint8_t hdc1080_set_temperature_resolution(hdc1080_handle_t *handle, hdc1080_temperature_resolution_t resolution)
set temperature resolution
hdc1080_bool_t
hdc1080 bool enumeration definition
uint8_t hdc1080_get_reg(hdc1080_handle_t *handle, uint8_t reg, uint16_t *data)
get chip register
uint8_t hdc1080_set_reg(hdc1080_handle_t *handle, uint8_t reg, uint16_t data)
set chip register
void(* delay_ms)(uint32_t ms)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* iic_read_with_wait)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
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)
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v