42#define CHIP_NAME "Texas Instruments HDC302X"
43#define MANUFACTURER_NAME "Texas Instruments"
44#define SUPPLY_VOLTAGE_MIN 1.62f
45#define SUPPLY_VOLTAGE_MAX 5.5f
46#define MAX_CURRENT 0.17f
47#define TEMPERATURE_MIN -40.0f
48#define TEMPERATURE_MAX 125.0f
49#define DRIVER_VERSION 1000
54#define HDC302X_COMMAND_SINGLE_MEASUREMENT_LPM0 0x2400U
55#define HDC302X_COMMAND_SINGLE_MEASUREMENT_LPM1 0x240BU
56#define HDC302X_COMMAND_SINGLE_MEASUREMENT_LPM2 0x2416U
57#define HDC302X_COMMAND_SINGLE_MEASUREMENT_LPM3 0x24FFU
58#define HDC302X_COMMAND_AUTO_MEASUREMENT_0P5_SECOND_LPM0 0x2032U
59#define HDC302X_COMMAND_AUTO_MEASUREMENT_0P5_SECOND_LPM1 0x2024U
60#define HDC302X_COMMAND_AUTO_MEASUREMENT_0P5_SECOND_LPM2 0x202FU
61#define HDC302X_COMMAND_AUTO_MEASUREMENT_0P5_SECOND_LPM3 0x20FFU
62#define HDC302X_COMMAND_AUTO_MEASUREMENT_1_SECOND_LPM0 0x2130U
63#define HDC302X_COMMAND_AUTO_MEASUREMENT_1_SECOND_LPM1 0x2126U
64#define HDC302X_COMMAND_AUTO_MEASUREMENT_1_SECOND_LPM2 0x212DU
65#define HDC302X_COMMAND_AUTO_MEASUREMENT_1_SECOND_LPM3 0x21FFU
66#define HDC302X_COMMAND_AUTO_MEASUREMENT_2_SECOND_LPM0 0x2236U
67#define HDC302X_COMMAND_AUTO_MEASUREMENT_2_SECOND_LPM1 0x2220U
68#define HDC302X_COMMAND_AUTO_MEASUREMENT_2_SECOND_LPM2 0x222BU
69#define HDC302X_COMMAND_AUTO_MEASUREMENT_2_SECOND_LPM3 0x22FFU
70#define HDC302X_COMMAND_AUTO_MEASUREMENT_4_SECOND_LPM0 0x2334U
71#define HDC302X_COMMAND_AUTO_MEASUREMENT_4_SECOND_LPM1 0x2322U
72#define HDC302X_COMMAND_AUTO_MEASUREMENT_4_SECOND_LPM2 0x2329U
73#define HDC302X_COMMAND_AUTO_MEASUREMENT_4_SECOND_LPM3 0x23FFU
74#define HDC302X_COMMAND_AUTO_MEASUREMENT_10_SECOND_LPM0 0x2737U
75#define HDC302X_COMMAND_AUTO_MEASUREMENT_10_SECOND_LPM1 0x2721U
76#define HDC302X_COMMAND_AUTO_MEASUREMENT_10_SECOND_LPM2 0x272AU
77#define HDC302X_COMMAND_AUTO_MEASUREMENT_10_SECOND_LPM3 0x27FFU
78#define HDC302X_COMMAND_EXIT 0x3093U
79#define HDC302X_COMMAND_AUTO_MEASUREMENT_READ_T_RH 0xE000U
80#define HDC302X_COMMAND_AUTO_MEASUREMENT_READ_RH 0xE001U
81#define HDC302X_COMMAND_AUTO_MEASUREMENT_READ_MIN_T 0xE002U
82#define HDC302X_COMMAND_AUTO_MEASUREMENT_READ_MAX_T 0xE003U
83#define HDC302X_COMMAND_AUTO_MEASUREMENT_READ_MIN_RH 0xE004U
84#define HDC302X_COMMAND_AUTO_MEASUREMENT_READ_MAX_RH 0xE005U
85#define HDC302X_COMMAND_WRITE_SET_LOW_ALERT 0x6100U
86#define HDC302X_COMMAND_WRITE_SET_HIGH_ALERT 0x611DU
87#define HDC302X_COMMAND_WRITE_CLEAR_LOW_ALERT 0x610BU
88#define HDC302X_COMMAND_WRITE_CLEAR_HIGH_ALERT 0x6116U
89#define HDC302X_COMMAND_READ_SET_LOW_ALERT 0xE102U
90#define HDC302X_COMMAND_READ_SET_HIGH_ALERT 0xE11FU
91#define HDC302X_COMMAND_READ_CLEAR_LOW_ALERT 0xE109U
92#define HDC302X_COMMAND_READ_CLEAR_HIGH_ALERT 0xE114U
93#define HDC302X_COMMAND_HEATER_ENABLE 0x306DU
94#define HDC302X_COMMAND_HEATER_DISABLE 0x3066U
95#define HDC302X_COMMAND_HEATER_CONFIG 0x306EU
96#define HDC302X_COMMAND_READ_STATUS 0xF32DU
97#define HDC302X_COMMAND_CLEAR_STATUS 0x3041U
98#define HDC302X_COMMAND_SOFT_RESET 0x30A2U
99#define HDC302X_COMMAND_READ_NIST_ID_BYTE5_BYTE4 0x3683U
100#define HDC302X_COMMAND_READ_NIST_ID_BYTE3_BYTE2 0x3684U
101#define HDC302X_COMMAND_READ_NIST_ID_BYTE1_BYTE0 0x3685U
102#define HDC302X_COMMAND_READ_ID 0x3781U
103#define HDC302X_COMMAND_PROGRAM_ALERT_THRESHOLD 0x6155U
104#define HDC302X_COMMAND_PROGRAM_READ_OFFSET 0xA004U
105#define HDC302X_COMMAND_PROGRAM_READ_EEPROM_CONFIG 0x61BBU
118static uint8_t a_hdc302x_iic_read(
hdc302x_handle_t *handle, uint16_t command, uint8_t *buf, uint16_t len)
139static uint8_t a_hdc302x_iic_write(
hdc302x_handle_t *handle, uint16_t command, uint8_t *buf, uint16_t len)
156static uint8_t a_hdc302x_crc(uint8_t *data, uint16_t len)
158 const uint8_t POLYNOMIAL = 0x31;
163 for (j = len; j != 0; --j)
166 for (i = 8; i != 0; --i)
168 crc = (crc & 0x80) ? (crc << 1) ^ POLYNOMIAL : (crc<<1);
305 handle->
debug_print(
"hdc302x: soft reset failed.\n");
346 handle->
debug_print(
"hdc302x: start continuous read failed.\n");
356 handle->
debug_print(
"hdc302x: start continuous read failed.\n");
366 handle->
debug_print(
"hdc302x: start continuous read failed.\n");
376 handle->
debug_print(
"hdc302x: start continuous read failed.\n");
383 handle->
debug_print(
"hdc302x: low power mode is invalid.\n");
398 handle->
debug_print(
"hdc302x: start continuous read failed.\n");
408 handle->
debug_print(
"hdc302x: start continuous read failed.\n");
418 handle->
debug_print(
"hdc302x: start continuous read failed.\n");
428 handle->
debug_print(
"hdc302x: start continuous read failed.\n");
435 handle->
debug_print(
"hdc302x: low power mode is invalid.\n");
450 handle->
debug_print(
"hdc302x: start continuous read failed.\n");
460 handle->
debug_print(
"hdc302x: start continuous read failed.\n");
470 handle->
debug_print(
"hdc302x: start continuous read failed.\n");
480 handle->
debug_print(
"hdc302x: start continuous read failed.\n");
487 handle->
debug_print(
"hdc302x: low power mode is invalid.\n");
502 handle->
debug_print(
"hdc302x: start continuous read failed.\n");
512 handle->
debug_print(
"hdc302x: start continuous read failed.\n");
522 handle->
debug_print(
"hdc302x: start continuous read failed.\n");
532 handle->
debug_print(
"hdc302x: start continuous read failed.\n");
539 handle->
debug_print(
"hdc302x: low power mode is invalid.\n");
554 handle->
debug_print(
"hdc302x: start continuous read failed.\n");
564 handle->
debug_print(
"hdc302x: start continuous read failed.\n");
574 handle->
debug_print(
"hdc302x: start continuous read failed.\n");
584 handle->
debug_print(
"hdc302x: start continuous read failed.\n");
591 handle->
debug_print(
"hdc302x: low power mode is invalid.\n");
601 handle->
debug_print(
"hdc302x: auto mode is invalid.\n");
659 uint16_t *humidity_raw,
float *humidity_s)
672 if (handle->
mode == 0)
674 handle->
debug_print(
"hdc302x: current is not continuous mode.\n");
686 if (a_hdc302x_crc(buf + 0, 2) != buf[2])
688 handle->
debug_print(
"hdc302x: crc check error.\n");
692 if (a_hdc302x_crc(buf + 3, 2) != buf[5])
694 handle->
debug_print(
"hdc302x: crc check error.\n");
698 *temperature_raw = (uint16_t)(((uint16_t)buf[0]) << 8) | buf[1];
699 *humidity_raw = (uint16_t)(((uint16_t)buf[3]) << 8) | buf[4];
700 *temperature_s = (float)(*temperature_raw) / 65535.0f * 175.0f - 45.0f;
701 *humidity_s = (float)(*humidity_raw) / 65535.0f * 100.0f;
724 uint16_t *humidity_raw,
float *humidity_s)
738 if (handle->
mode != 0)
740 handle->
debug_print(
"hdc302x: continuous mode can't use this function.\n");
763 handle->
debug_print(
"hdc302x: low power mode is invalid.\n");
767 res = a_hdc302x_iic_read(handle, command, buf, 6);
770 handle->
debug_print(
"hdc302x: single read failed.\n");
774 if (a_hdc302x_crc(buf + 0, 2) != buf[2])
776 handle->
debug_print(
"hdc302x: crc check error.\n");
780 if (a_hdc302x_crc(buf + 3, 2) != buf[5])
782 handle->
debug_print(
"hdc302x: crc check error.\n");
786 *temperature_raw = (uint16_t)(((uint16_t)buf[0]) << 8) | buf[1];
787 *humidity_raw = (uint16_t)(((uint16_t)buf[3]) << 8) | buf[4];
788 *temperature_s = (float)(*temperature_raw) / 65535.0f * 175.0f - 45.0f;
789 *humidity_s = (float)(*humidity_raw) / 65535.0f * 100.0f;
821 if (handle->
mode == 0)
823 handle->
debug_print(
"hdc302x: current is not continuous mode.\n");
835 if (a_hdc302x_crc(buf + 0, 2) != buf[2])
837 handle->
debug_print(
"hdc302x: crc check error.\n");
841 *humidity_raw = (uint16_t)(((uint16_t)buf[0]) << 8) | buf[1];
842 *humidity_s = (float)(*humidity_raw) / 65535.0f * 100.0f;
874 if (handle->
mode == 0)
876 handle->
debug_print(
"hdc302x: current is not continuous mode.\n");
888 if (a_hdc302x_crc(buf + 0, 2) != buf[2])
890 handle->
debug_print(
"hdc302x: crc check error.\n");
894 *temperature_raw = (uint16_t)(((uint16_t)buf[0]) << 8) | buf[1];
895 *temperature_s = (float)(*temperature_raw) / 65535.0f * 175.0f - 45.0f;
927 if (handle->
mode == 0)
929 handle->
debug_print(
"hdc302x: current is not continuous mode.\n");
941 if (a_hdc302x_crc(buf + 0, 2) != buf[2])
943 handle->
debug_print(
"hdc302x: crc check error.\n");
947 *temperature_raw = (uint16_t)(((uint16_t)buf[0]) << 8) | buf[1];
948 *temperature_s = (float)(*temperature_raw) / 65535.0f * 175.0f - 45.0f;
980 if (handle->
mode == 0)
982 handle->
debug_print(
"hdc302x: current is not continuous mode.\n");
994 if (a_hdc302x_crc(buf + 0, 2) != buf[2])
996 handle->
debug_print(
"hdc302x: crc check error.\n");
1000 *humidity_raw = (uint16_t)(((uint16_t)buf[0]) << 8) | buf[1];
1001 *humidity_s = (float)(*humidity_raw) / 65535.0f * 100.0f;
1033 if (handle->
mode == 0)
1035 handle->
debug_print(
"hdc302x: current is not continuous mode.\n");
1047 if (a_hdc302x_crc(buf + 0, 2) != buf[2])
1049 handle->
debug_print(
"hdc302x: crc check error.\n");
1053 *humidity_raw = (uint16_t)(((uint16_t)buf[0]) << 8) | buf[1];
1054 *humidity_s = (float)(*humidity_raw) / 65535.0f * 100.0f;
1084 buf[0] = (threshold >> 8) & 0xFF;
1085 buf[1] = (threshold >> 0) & 0xFF;
1086 buf[2] = a_hdc302x_crc(buf, 2);
1090 handle->
debug_print(
"hdc302x: write set low alert failed.\n");
1123 buf[0] = (threshold >> 8) & 0xFF;
1124 buf[1] = (threshold >> 0) & 0xFF;
1125 buf[2] = a_hdc302x_crc(buf, 2);
1129 handle->
debug_print(
"hdc302x: write clear low alert failed.\n");
1162 buf[0] = (threshold >> 8) & 0xFF;
1163 buf[1] = (threshold >> 0) & 0xFF;
1164 buf[2] = a_hdc302x_crc(buf, 2);
1168 handle->
debug_print(
"hdc302x: write set high alert failed.\n");
1201 buf[0] = (threshold >> 8) & 0xFF;
1202 buf[1] = (threshold >> 0) & 0xFF;
1203 buf[2] = a_hdc302x_crc(buf, 2);
1207 handle->
debug_print(
"hdc302x: write clear high alert failed.\n");
1244 handle->
debug_print(
"hdc302x: read set low alert failed.\n");
1248 if (a_hdc302x_crc(buf, 2) != buf[2])
1250 handle->
debug_print(
"hdc302x: crc check error.\n");
1254 *threshold = (uint16_t)(((uint16_t)buf[0]) << 8) | buf[1];
1288 handle->
debug_print(
"hdc302x: read set high alert failed.\n");
1292 if (a_hdc302x_crc(buf, 2) != buf[2])
1294 handle->
debug_print(
"hdc302x: crc check error.\n");
1298 *threshold = (uint16_t)(((uint16_t)buf[0]) << 8) | buf[1];
1332 handle->
debug_print(
"hdc302x: read clear low alert failed.\n");
1336 if (a_hdc302x_crc(buf, 2) != buf[2])
1338 handle->
debug_print(
"hdc302x: crc check error.\n");
1342 *threshold = (uint16_t)(((uint16_t)buf[0]) << 8) | buf[1];
1376 handle->
debug_print(
"hdc302x: read clear high alert failed.\n");
1380 if (a_hdc302x_crc(buf, 2) != buf[2])
1382 handle->
debug_print(
"hdc302x: crc check error.\n");
1386 *threshold = (uint16_t)(((uint16_t)buf[0]) << 8) | buf[1];
1417 handle->
debug_print(
"hdc302x: nvm program alert threshold failed.\n");
1451 buf[0] = (offset >> 8) & 0xFF;
1452 buf[1] = (offset >> 0) & 0xFF;
1453 buf[2] = a_hdc302x_crc(buf, 2);
1457 handle->
debug_print(
"hdc302x: nvm program offset failed.\n");
1495 handle->
debug_print(
"hdc302x: nvm read offset failed.\n");
1499 if (a_hdc302x_crc(buf, 2) != buf[2])
1501 handle->
debug_print(
"hdc302x: crc check error.\n");
1505 *offset = (uint16_t)(((uint16_t)buf[0]) << 8) | buf[1];
1535 buf[0] = (config >> 8) & 0xFF;
1536 buf[1] = (config >> 0) & 0xFF;
1537 buf[2] = a_hdc302x_crc(buf, 2);
1541 handle->
debug_print(
"hdc302x: nvm program config failed.\n");
1579 handle->
debug_print(
"hdc302x: nvm read config failed.\n");
1583 if (a_hdc302x_crc(buf, 2) != buf[2])
1585 handle->
debug_print(
"hdc302x: crc check error.\n");
1589 *config = (uint16_t)(((uint16_t)buf[0]) << 8) | buf[1];
1620 handle->
debug_print(
"hdc302x: enable heater failed.\n");
1654 handle->
debug_print(
"hdc302x: disable heater failed.\n");
1707 handle->
debug_print(
"hdc302x: power > 0x3FFF.\n");
1712 buf[0] = (power >> 8) & 0xFF;
1713 buf[1] = (power >> 0) & 0xFF;
1714 buf[2] = a_hdc302x_crc(buf, 2);
1718 handle->
debug_print(
"hdc302x: set heater power failed.\n");
1755 handle->
debug_print(
"hdc302x: get heater power failed.\n");
1759 if (a_hdc302x_crc(buf, 2) != buf[2])
1761 handle->
debug_print(
"hdc302x: crc check error.\n");
1765 *power = (uint16_t)(((uint16_t)buf[0]) << 8) | buf[1];
1799 handle->
debug_print(
"hdc302x: read nist id failed.\n");
1803 if (a_hdc302x_crc(buf, 2) != buf[2])
1805 handle->
debug_print(
"hdc302x: crc check error.\n");
1814 handle->
debug_print(
"hdc302x: read nist id failed.\n");
1818 if (a_hdc302x_crc(buf, 2) != buf[2])
1820 handle->
debug_print(
"hdc302x: crc check error.\n");
1829 handle->
debug_print(
"hdc302x: read nist id failed.\n");
1833 if (a_hdc302x_crc(buf, 2) != buf[2])
1835 handle->
debug_print(
"hdc302x: crc check error.\n");
1874 handle->
debug_print(
"hdc302x: get status failed.\n");
1878 if (a_hdc302x_crc(buf, 2) != buf[2])
1880 handle->
debug_print(
"hdc302x: crc check error.\n");
1884 *status = (uint16_t)(((uint16_t)buf[0]) << 8) | buf[1];
1915 handle->
debug_print(
"hdc302x: clear status failed.\n");
1951 handle->
debug_print(
"hdc302x: iic_init is null.\n");
1957 handle->
debug_print(
"hdc302x: iic_deinit is null.\n");
1963 handle->
debug_print(
"hdc302x: iic_read_address16 is null.\n");
1969 handle->
debug_print(
"hdc302x: iic_write_address16 is null.\n");
1975 handle->
debug_print(
"hdc302x: delay_ms is null.\n");
1982 handle->
debug_print(
"hdc302x: iic init failed.\n");
1993 if (a_hdc302x_crc(buf, 2) != buf[2])
1995 handle->
debug_print(
"hdc302x: crc check error.\n");
1999 id = (uint16_t)(((uint16_t)buf[0]) << 8) | buf[1];
2009 handle->
debug_print(
"hdc302x: soft reset failed.\n");
2049 handle->
debug_print(
"hdc302x: soft reset failed.\n");
2055 handle->
debug_print(
"hdc302x: iic deinit failed.\n");
2137 handle->
debug_print(
"hdc302x: get status failed.\n");
2141 if (a_hdc302x_crc(buf, 2) != buf[2])
2143 handle->
debug_print(
"hdc302x: crc check error.\n");
2147 prev = (uint16_t)(((uint16_t)buf[0]) << 8) | buf[1];
2151 handle->
debug_print(
"hdc302x: clear status failed.\n");
2246 float humidity_percentage, uint16_t *reg)
2248 uint16_t temperature;
2260 humidity = (uint16_t)(humidity_percentage / 100.0f * 65535.0f);
2261 temperature = (uint16_t)((temperature_deg + 45.0f) / 175.0f * 65535.0f);
2262 *reg = (humidity >> 9) << 9 | (temperature >> 7);
2280 float *temperature_deg,
float *humidity_percentage)
2282 uint16_t temperature;
2294 humidity = reg >> 9;
2295 humidity = humidity << 9;
2296 temperature = reg << 7;
2297 *temperature_deg = (float)(temperature) / 65535.0f * 175.0f - 45.0f;
2298 *humidity_percentage = (float)(humidity) / 65535.0f * 100.0f;
2318 uint8_t humidity_symbol,
float humidity_percentage, uint16_t *reg)
2320 uint16_t temperature;
2322 uint8_t temperature_reg8;
2323 uint8_t humidity_reg8;
2334 humidity = (uint16_t)(humidity_percentage / 100.0f * 65535.0f);
2335 temperature = (uint16_t)((temperature_deg + 45.0f) / 175.0f * 65535.0f);
2336 temperature_reg8 = (temperature >> 6) & 0x7F;
2337 if (temperature_symbol != 0)
2339 temperature_reg8 |= 1 << 7;
2341 humidity_reg8 = (humidity >> 7) & 0x7F;
2342 if (humidity_symbol != 0)
2344 humidity_reg8 |= 1 << 7;
2346 *reg = ((uint16_t)humidity_reg8) << 8 | temperature_reg8;
2366 uint8_t *temperature_symbol,
float *temperature_deg,
2367 uint8_t *humidity_symbol,
float *humidity_percentage)
2369 uint8_t temperature_reg8;
2370 uint8_t humidity_reg8;
2371 uint16_t temperature;
2383 temperature_reg8 = reg & 0xFF;
2384 if ((temperature_reg8 >> 7) != 0)
2386 *temperature_symbol = 1;
2390 *temperature_symbol = 0;
2392 temperature_reg8 &= ~(1 << 7);
2393 humidity_reg8 = (reg >> 8) & 0xFF;
2394 if ((humidity_reg8 >> 7) != 0)
2396 *humidity_symbol = 1;
2400 *humidity_symbol = 0;
2402 humidity_reg8 &= ~(1 << 7);
2403 temperature = temperature_reg8 << 6;
2404 temperature |= 1 << 14;
2405 humidity = humidity_reg8 << 7;
2406 *temperature_deg = (float)(temperature) / 65535.0f * 175.0f - 45.0f;
2407 *humidity_percentage = (float)(humidity) / 65535.0f * 100.0f;
2436 if (a_hdc302x_iic_write(handle, command, buf, len) != 0)
2468 if (a_hdc302x_iic_read(handle, command, buf, len) != 0)
#define HDC302X_COMMAND_SOFT_RESET
#define HDC302X_COMMAND_AUTO_MEASUREMENT_1_SECOND_LPM2
#define HDC302X_COMMAND_READ_SET_HIGH_ALERT
#define HDC302X_COMMAND_AUTO_MEASUREMENT_10_SECOND_LPM3
#define HDC302X_COMMAND_PROGRAM_ALERT_THRESHOLD
#define HDC302X_COMMAND_HEATER_CONFIG
#define HDC302X_COMMAND_READ_NIST_ID_BYTE1_BYTE0
#define HDC302X_COMMAND_SINGLE_MEASUREMENT_LPM3
#define HDC302X_COMMAND_AUTO_MEASUREMENT_READ_MIN_RH
#define HDC302X_COMMAND_SINGLE_MEASUREMENT_LPM1
#define HDC302X_COMMAND_HEATER_ENABLE
#define HDC302X_COMMAND_READ_NIST_ID_BYTE5_BYTE4
#define HDC302X_COMMAND_WRITE_SET_HIGH_ALERT
#define HDC302X_COMMAND_AUTO_MEASUREMENT_1_SECOND_LPM0
#define HDC302X_COMMAND_READ_NIST_ID_BYTE3_BYTE2
#define HDC302X_COMMAND_READ_STATUS
#define HDC302X_COMMAND_AUTO_MEASUREMENT_READ_MIN_T
#define SUPPLY_VOLTAGE_MAX
#define HDC302X_COMMAND_AUTO_MEASUREMENT_2_SECOND_LPM2
#define HDC302X_COMMAND_AUTO_MEASUREMENT_1_SECOND_LPM3
#define HDC302X_COMMAND_AUTO_MEASUREMENT_0P5_SECOND_LPM2
#define HDC302X_COMMAND_AUTO_MEASUREMENT_READ_MAX_RH
#define HDC302X_COMMAND_AUTO_MEASUREMENT_0P5_SECOND_LPM0
#define HDC302X_COMMAND_PROGRAM_READ_EEPROM_CONFIG
#define HDC302X_COMMAND_CLEAR_STATUS
#define HDC302X_COMMAND_READ_CLEAR_HIGH_ALERT
#define HDC302X_COMMAND_AUTO_MEASUREMENT_READ_RH
#define HDC302X_COMMAND_SINGLE_MEASUREMENT_LPM2
#define HDC302X_COMMAND_AUTO_MEASUREMENT_10_SECOND_LPM0
#define HDC302X_COMMAND_EXIT
#define HDC302X_COMMAND_AUTO_MEASUREMENT_2_SECOND_LPM3
#define HDC302X_COMMAND_SINGLE_MEASUREMENT_LPM0
chip command definition
#define HDC302X_COMMAND_AUTO_MEASUREMENT_0P5_SECOND_LPM1
#define MANUFACTURER_NAME
#define HDC302X_COMMAND_READ_SET_LOW_ALERT
#define SUPPLY_VOLTAGE_MIN
#define HDC302X_COMMAND_AUTO_MEASUREMENT_10_SECOND_LPM1
#define HDC302X_COMMAND_AUTO_MEASUREMENT_1_SECOND_LPM1
#define HDC302X_COMMAND_WRITE_CLEAR_LOW_ALERT
#define HDC302X_COMMAND_AUTO_MEASUREMENT_4_SECOND_LPM2
#define HDC302X_COMMAND_AUTO_MEASUREMENT_2_SECOND_LPM1
#define HDC302X_COMMAND_AUTO_MEASUREMENT_4_SECOND_LPM3
#define HDC302X_COMMAND_READ_CLEAR_LOW_ALERT
#define HDC302X_COMMAND_HEATER_DISABLE
#define HDC302X_COMMAND_AUTO_MEASUREMENT_4_SECOND_LPM0
#define HDC302X_COMMAND_AUTO_MEASUREMENT_2_SECOND_LPM0
#define HDC302X_COMMAND_AUTO_MEASUREMENT_10_SECOND_LPM2
#define HDC302X_COMMAND_PROGRAM_READ_OFFSET
#define HDC302X_COMMAND_AUTO_MEASUREMENT_READ_MAX_T
#define HDC302X_COMMAND_WRITE_SET_LOW_ALERT
#define CHIP_NAME
chip information definition
#define HDC302X_COMMAND_AUTO_MEASUREMENT_0P5_SECOND_LPM3
#define HDC302X_COMMAND_WRITE_CLEAR_HIGH_ALERT
#define HDC302X_COMMAND_AUTO_MEASUREMENT_4_SECOND_LPM1
#define HDC302X_COMMAND_AUTO_MEASUREMENT_READ_T_RH
#define HDC302X_COMMAND_READ_ID
driver hdc302x header file
uint8_t hdc302x_alert_threshold_convert_to_data(hdc302x_handle_t *handle, uint16_t reg, float *temperature_deg, float *humidity_percentage)
convert the alert threshold to the real data
uint8_t hdc302x_get_addr(hdc302x_handle_t *handle, hdc302x_address_t *addr)
get the iic address
uint8_t hdc302x_continuous_read(hdc302x_handle_t *handle, uint16_t *temperature_raw, float *temperature_s, uint16_t *humidity_raw, float *humidity_s)
continuous read
uint8_t hdc302x_read_clear_high_alert(hdc302x_handle_t *handle, uint16_t *threshold)
read clear high alert
uint8_t hdc302x_read_set_low_alert(hdc302x_handle_t *handle, uint16_t *threshold)
read set low alert
uint8_t hdc302x_nvm_program_temperature_humidity_offset(hdc302x_handle_t *handle, uint16_t offset)
nvm program temperature humidity offset
uint8_t hdc302x_disable_heater(hdc302x_handle_t *handle)
disable heater
uint8_t hdc302x_set_heater_power(hdc302x_handle_t *handle, uint16_t power)
set heater power
uint8_t hdc302x_continuous_read_humidity(hdc302x_handle_t *handle, uint16_t *humidity_raw, float *humidity_s)
continuous read humidity
uint8_t hdc302x_nvm_read_temperature_humidity_offset(hdc302x_handle_t *handle, uint16_t *offset)
nvm read temperature humidity offset
uint8_t hdc302x_offset_convert_to_data(hdc302x_handle_t *handle, uint16_t reg, uint8_t *temperature_symbol, float *temperature_deg, uint8_t *humidity_symbol, float *humidity_percentage)
convert the offset to the real data
struct hdc302x_info_s hdc302x_info_t
hdc302x information structure definition
uint8_t hdc302x_enable_heater(hdc302x_handle_t *handle)
enable heater
uint8_t hdc302x_set_addr(hdc302x_handle_t *handle, hdc302x_address_t addr)
set the iic address
uint8_t hdc302x_deinit(hdc302x_handle_t *handle)
close the chip
hdc302x_address_t
hdc302x address enumeration definition
uint8_t hdc302x_irq_handler(hdc302x_handle_t *handle)
irq handler
uint8_t hdc302x_offset_convert_to_register(hdc302x_handle_t *handle, uint8_t temperature_symbol, float temperature_deg, uint8_t humidity_symbol, float humidity_percentage, uint16_t *reg)
convert the offset to the register raw data
uint8_t hdc302x_single_read(hdc302x_handle_t *handle, uint16_t *temperature_raw, float *temperature_s, uint16_t *humidity_raw, float *humidity_s)
single read
uint8_t hdc302x_set_low_power_mode(hdc302x_handle_t *handle, hdc302x_low_power_mode_t mode)
set low power mode
uint8_t hdc302x_get_nist_id(hdc302x_handle_t *handle, uint8_t id[6])
get nist id
uint8_t hdc302x_read_temperature_min(hdc302x_handle_t *handle, uint16_t *temperature_raw, float *temperature_s)
read temperature min
hdc302x_auto_mode_t
hdc302x auto mode enumeration definition
uint8_t hdc302x_set_auto_mode(hdc302x_handle_t *handle, hdc302x_auto_mode_t mode)
set auto mode
uint8_t hdc302x_alert_threshold_convert_to_register(hdc302x_handle_t *handle, float temperature_deg, float humidity_percentage, uint16_t *reg)
convert the alert threshold to the register raw data
uint8_t hdc302x_get_low_power_mode(hdc302x_handle_t *handle, hdc302x_low_power_mode_t *mode)
get low power mode
uint8_t hdc302x_read_humidity_min(hdc302x_handle_t *handle, uint16_t *humidity_raw, float *humidity_s)
read humidity min
uint8_t hdc302x_read_set_high_alert(hdc302x_handle_t *handle, uint16_t *threshold)
read set high alert
uint8_t hdc302x_nvm_read_config(hdc302x_handle_t *handle, uint16_t *config)
nvm read config
uint8_t hdc302x_init(hdc302x_handle_t *handle)
initialize the chip
uint8_t hdc302x_write_clear_low_alert(hdc302x_handle_t *handle, uint16_t threshold)
write clear low alert
uint8_t hdc302x_get_auto_mode(hdc302x_handle_t *handle, hdc302x_auto_mode_t *mode)
get auto mode
hdc302x_low_power_mode_t
hdc302x low power mode enumeration definition
uint8_t hdc302x_clear_status(hdc302x_handle_t *handle)
clear status
uint8_t hdc302x_write_set_low_alert(hdc302x_handle_t *handle, uint16_t threshold)
write set low alert
uint8_t hdc302x_read_temperature_max(hdc302x_handle_t *handle, uint16_t *temperature_raw, float *temperature_s)
read temperature max
uint8_t hdc302x_stop_continuous_read(hdc302x_handle_t *handle)
stop continuous read
struct hdc302x_handle_s hdc302x_handle_t
hdc302x handle structure definition
uint8_t hdc302x_read_clear_low_alert(hdc302x_handle_t *handle, uint16_t *threshold)
read clear low alert
uint8_t hdc302x_soft_reset(hdc302x_handle_t *handle)
soft reset
uint8_t hdc302x_nvm_program_alert_threshold(hdc302x_handle_t *handle)
nvm program alert threshold
uint8_t hdc302x_get_status(hdc302x_handle_t *handle, uint16_t *status)
get status
uint8_t hdc302x_read_humidity_max(hdc302x_handle_t *handle, uint16_t *humidity_raw, float *humidity_s)
read humidity max
uint8_t hdc302x_get_heater_power(hdc302x_handle_t *handle, uint16_t *power)
get heater power
uint8_t hdc302x_info(hdc302x_info_t *info)
get chip's information
uint8_t hdc302x_start_continuous_read(hdc302x_handle_t *handle)
start continuous read
uint8_t hdc302x_write_clear_high_alert(hdc302x_handle_t *handle, uint16_t threshold)
write clear high alert
uint8_t hdc302x_nvm_program_config(hdc302x_handle_t *handle, uint16_t config)
nvm program config
uint8_t hdc302x_write_set_high_alert(hdc302x_handle_t *handle, uint16_t threshold)
write set high alert
@ HDC302X_STATUS_OVERALL_ALERT
@ HDC302X_STATUS_T_HIGH_TRACKING_ALERT
@ HDC302X_STATUS_RH_LOW_TRACKING_ALERT
@ HDC302X_STATUS_T_LOW_TRACKING_ALERT
@ HDC302X_STATUS_CHECKSUM_VERY
@ HDC302X_STATUS_RH_HIGH_TRACKING_ALERT
@ HDC302X_STATUS_DEVICE_RESET_DETECTED
@ HDC302X_STATUS_T_TRACKING_ALERT
@ HDC302X_STATUS_RH_TRACKING_ALERT
@ HDC302X_AUTO_MODE_10_HZ
@ HDC302X_AUTO_MODE_0P5_HZ
@ HDC302X_LOW_POWER_MODE_3
@ HDC302X_LOW_POWER_MODE_2
@ HDC302X_LOW_POWER_MODE_0
@ HDC302X_LOW_POWER_MODE_1
uint8_t hdc302x_get_reg(hdc302x_handle_t *handle, uint16_t command, uint8_t *buf, uint16_t len)
get the chip register
uint8_t hdc302x_set_reg(hdc302x_handle_t *handle, uint16_t command, uint8_t *buf, uint16_t len)
set the chip register
void(* delay_ms)(uint32_t ms)
uint8_t(* iic_read_address16)(uint8_t addr, uint16_t reg, uint8_t *buf, uint16_t len)
void(* debug_print)(const char *const fmt,...)
void(* receive_callback)(uint16_t type)
uint8_t(* iic_init)(void)
uint8_t(* iic_write_address16)(uint8_t addr, uint16_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