42#define CHIP_NAME "ASAIR AM2320"
43#define MANUFACTURER_NAME "ASAIR"
44#define SUPPLY_VOLTAGE_MIN 3.1f
45#define SUPPLY_VOLTAGE_MAX 5.5f
46#define MAX_CURRENT 0.95f
47#define TEMPERATURE_MIN -20.0f
48#define TEMPERATURE_MAX 60.0f
49#define DRIVER_VERSION 1000
54#define AM2320_ADDRESS 0xB8
59#define AM2320_MODBUS_ADDRESS_HUMI_MSB 0x00
60#define AM2320_MODBUS_ADDRESS_HUMI_LSB 0x01
61#define AM2320_MODBUS_ADDRESS_TEMP_MSB 0x02
62#define AM2320_MODBUS_ADDRESS_TEMP_LSB 0x03
63#define AM2320_MODBUS_ADDRESS_DEVICE_TYPE_MSB 0x08
64#define AM2320_MODBUS_ADDRESS_DEVICE_TYPE_LSB 0x09
65#define AM2320_MODBUS_ADDRESS_VERSION 0x0A
66#define AM2320_MODBUS_ADDRESS_DEVICE_3 0x0B
67#define AM2320_MODBUS_ADDRESS_DEVICE_2 0x0C
68#define AM2320_MODBUS_ADDRESS_DEVICE_1 0x0D
69#define AM2320_MODBUS_ADDRESS_DEVICE_0 0x0E
70#define AM2320_MODBUS_ADDRESS_STATUS 0x0F
71#define AM2320_MODBUS_ADDRESS_USER_REG1_MSB 0x10
72#define AM2320_MODBUS_ADDRESS_USER_REG1_LSB 0x11
73#define AM2320_MODBUS_ADDRESS_USER_REG2_MSB 0x12
74#define AM2320_MODBUS_ADDRESS_USER_REG2_LSB 0x13
79static const uint8_t gs_crc_table_hi[] =
81 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
82 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40,
83 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1,
84 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
85 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
86 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
87 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1,
88 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
89 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
90 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40,
91 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,
92 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
93 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1,
94 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
95 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
96 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
97 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,
98 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
99 0x00, 0xC1, 0x81, 0x40
105static const uint8_t gs_crc_table_lo[] =
107 0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06, 0x07, 0xC7, 0x05, 0xC5,
108 0xC4, 0x04, 0xCC, 0x0C, 0x0D, 0xCD, 0x0F, 0xCF, 0xCE, 0x0E, 0x0A, 0xCA, 0xCB, 0x0B,
109 0xC9, 0x09, 0x08, 0xC8, 0xD8, 0x18, 0x19, 0xD9, 0x1B, 0xDB, 0xDA, 0x1A, 0x1E, 0xDE,
110 0xDF, 0x1F, 0xDD, 0x1D, 0x1C, 0xDC, 0x14, 0xD4, 0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6,
111 0xD2, 0x12, 0x13, 0xD3, 0x11, 0xD1, 0xD0, 0x10, 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3,
112 0xF2, 0x32, 0x36, 0xF6, 0xF7, 0x37, 0xF5, 0x35, 0x34, 0xF4, 0x3C, 0xFC, 0xFD, 0x3D,
113 0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A, 0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38, 0x28, 0xE8,
114 0xE9, 0x29, 0xEB, 0x2B, 0x2A, 0xEA, 0xEE, 0x2E, 0x2F, 0xEF, 0x2D, 0xED, 0xEC, 0x2C,
115 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26, 0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21,
116 0x20, 0xE0, 0xA0, 0x60, 0x61, 0xA1, 0x63, 0xA3, 0xA2, 0x62, 0x66, 0xA6, 0xA7, 0x67,
117 0xA5, 0x65, 0x64, 0xA4, 0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F, 0x6E, 0xAE, 0xAA, 0x6A,
118 0x6B, 0xAB, 0x69, 0xA9, 0xA8, 0x68, 0x78, 0xB8, 0xB9, 0x79, 0xBB, 0x7B, 0x7A, 0xBA,
119 0xBE, 0x7E, 0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5, 0x77, 0xB7,
120 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71, 0x70, 0xB0, 0x50, 0x90, 0x91, 0x51,
121 0x93, 0x53, 0x52, 0x92, 0x96, 0x56, 0x57, 0x97, 0x55, 0x95, 0x94, 0x54, 0x9C, 0x5C,
122 0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E, 0x5A, 0x9A, 0x9B, 0x5B, 0x99, 0x59, 0x58, 0x98,
123 0x88, 0x48, 0x49, 0x89, 0x4B, 0x8B, 0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D,
124 0x4C, 0x8C, 0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42, 0x43, 0x83,
125 0x41, 0x81, 0x80, 0x40
135static uint16_t a_am2320_generate_crc16(uint8_t *data, uint16_t count)
137 uint8_t crc_hi = 0xFF;
138 uint8_t crc_lo = 0xFF;
143 i = crc_lo ^ *data++;
144 crc_lo = crc_hi ^ gs_crc_table_hi[i];
145 crc_hi = gs_crc_table_lo[i];
148 return ((uint16_t)crc_hi << 8 | crc_lo);
168 handle->
debug_print(
"am2320: bus write 0 failed.\n");
178 handle->
debug_print(
"am2320: bus write 1 failed.\n");
183 res = handle->
bus_read((uint8_t *)&value);
191 while ((value != 0) && (retry < 100))
193 res = handle->
bus_read((uint8_t *)&value);
215 res = handle->
bus_read((uint8_t *)&value);
223 while ((!value) && (retry < 100))
225 res = handle->
bus_read((uint8_t *)&value);
257static uint8_t a_am2320_read_bit(
am2320_handle_t *handle, uint8_t *value)
262 res = handle->
bus_read((uint8_t *)value);
269 while (((*value) != 0) && (retry < 100))
271 res = handle->
bus_read((uint8_t *)value);
282 res = handle->
bus_read((uint8_t *)value);
289 while ((!(*value)) && (retry < 100))
291 res = handle->
bus_read((uint8_t *)value);
302 res = handle->
bus_read((uint8_t *)value);
324static uint8_t a_am2320_read_byte(
am2320_handle_t *handle, uint8_t *
byte)
331 for (i = 0; i < 8; i++)
334 res = a_am2320_read_bit(handle, (uint8_t *)&value);
363 handle->
gpio_iic = (uint8_t)interface;
417 if (a_am2320_reset(handle) == 0)
420 for (i = 0; i < 5; i++)
422 if (a_am2320_read_byte(handle, (uint8_t *)&buf[i]) != 0)
425 handle->
debug_print(
"am2320: read byte failed.\n");
431 if ((buf[0] + buf[1] + buf[2] + buf[3]) == buf[4])
433 *raw = (uint16_t)buf[0] << 8 | buf[1];
434 *s = (float)(*raw) / 10.0f;
440 handle->
debug_print(
"am2320: data check failed.\n");
455 uint8_t input_buf[3];
466 handle->
debug_print(
"am2320: write command failed.\n");
474 handle->
debug_print(
"am2320: read command failed.\n");
478 crc16 = ((uint16_t)out_buf[5] << 8 | (uint16_t)out_buf[4]);
479 if (crc16 != a_am2320_generate_crc16(out_buf, 4))
485 if (out_buf[0] != 0x03)
491 if (out_buf[1] != 0x02)
493 handle->
debug_print(
"am2320: number is invalid.\n");
497 *raw = (uint16_t)out_buf[2] << 8 | out_buf[3];
498 *s = (float)(*raw) / 10.0f;
534 if (a_am2320_reset(handle) == 0)
537 for (i = 0; i < 5; i++)
539 if (a_am2320_read_byte(handle, (uint8_t *)&buf[i]) != 0)
542 handle->
debug_print(
"am2320: read byte failed.\n");
548 if ((buf[0] + buf[1] + buf[2] + buf[3]) == buf[4])
550 if ((buf[2] & (1 << 7)) != 0)
552 *temperature_raw = (uint16_t)buf[2] << 8 | buf[3];
553 *temperature_s= (float)((buf[2] & ~(1 << 7)) * 256 +
554 buf[3]) / 10.0f * (-1.0f);
558 *temperature_raw = (uint16_t)buf[2] << 8 | buf[3];
559 *temperature_s= (float)(buf[2] * 256 + buf[3]) / 10.0f;
561 *humidity_raw = (uint16_t)buf[0] << 8 | buf[1];
562 *humidity_s = (float)(*humidity_raw) / 10.0f;
568 handle->
debug_print(
"am2320: data check failed.\n");
583 uint8_t input_buf[3];
594 handle->
debug_print(
"am2320: write command failed.\n");
602 handle->
debug_print(
"am2320: read command failed.\n");
606 crc16 = ((uint16_t)out_buf[7] << 8 | (uint16_t)out_buf[6]);
607 if (crc16 != a_am2320_generate_crc16(out_buf, 6))
613 if (out_buf[0] != 0x03)
619 if (out_buf[1] != 0x04)
621 handle->
debug_print(
"am2320: number is invalid.\n");
625 if ((out_buf[4] & (1 << 7)) != 0)
627 *temperature_raw = (uint16_t)out_buf[4] << 8 | out_buf[5];
628 *temperature_s= (float)((out_buf[4] & ~(1 << 7)) * 256 +
629 out_buf[5]) / 10.0f * (-1.0f);
633 *temperature_raw = (uint16_t)out_buf[4] << 8 | out_buf[5];
634 *temperature_s= (float)(out_buf[4] * 256 + out_buf[5]) / 10.0f;
636 *humidity_raw = (uint16_t)out_buf[2] << 8 | out_buf[3];
637 *humidity_s = (float)(*humidity_raw) / 10.0f;
671 if (a_am2320_reset(handle) == 0)
674 for (i = 0; i < 5; i++)
676 if (a_am2320_read_byte(handle, (uint8_t *)&buf[i]) != 0)
679 handle->
debug_print(
"am2320: read byte failed.\n");
685 if ((buf[0] + buf[1] + buf[2] + buf[3]) == buf[4])
687 if ((buf[2] & (1 << 7)) != 0)
689 *raw = (uint16_t)buf[2] << 8 | buf[3];
690 *s= (float)((buf[2] & ~(1 << 7)) * 256 +
691 buf[3]) / 10.0f * (-1.0f);
695 *raw = (uint16_t)buf[2] << 8 | buf[3];
696 *s= (float)(buf[2] * 256 + buf[3]) / 10.0f;
703 handle->
debug_print(
"am2320: data check failed.\n");
718 uint8_t input_buf[3];
729 handle->
debug_print(
"am2320: write command failed.\n");
737 handle->
debug_print(
"am2320: read command failed.\n");
741 crc16 = ((uint16_t)out_buf[5] << 8 | (uint16_t)out_buf[4]);
742 if (crc16 != a_am2320_generate_crc16(out_buf, 4))
748 if (out_buf[0] != 0x03)
754 if (out_buf[1] != 0x02)
756 handle->
debug_print(
"am2320: number is invalid.\n");
760 if ((out_buf[2] & (1 << 7)) != 0)
762 *raw = (uint16_t)out_buf[2] << 8 | out_buf[3];
763 *s= (float)((out_buf[2] & ~(1 << 7)) * 256 +
764 out_buf[3]) / 10.0f * (-1.0f);
768 *raw = (uint16_t)out_buf[2] << 8 | out_buf[3];
769 *s= (float)(out_buf[2] * 256 + out_buf[3]) / 10.0f;
791 uint8_t input_buf[3];
806 handle->
debug_print(
"am2320: gpio can't use this function.\n");
818 handle->
debug_print(
"am2320: write command failed.\n");
826 handle->
debug_print(
"am2320: read command failed.\n");
830 crc16 = ((uint16_t)out_buf[5] << 8 | (uint16_t)out_buf[4]);
831 if (crc16 != a_am2320_generate_crc16(out_buf, 4))
837 if (out_buf[0] != 0x03)
843 if (out_buf[1] != 0x02)
845 handle->
debug_print(
"am2320: number is invalid.\n");
849 *type = (uint16_t)out_buf[2] << 8 | out_buf[3];
869 uint8_t input_buf[3];
884 handle->
debug_print(
"am2320: gpio can't use this function.\n");
896 handle->
debug_print(
"am2320: write command failed.\n");
904 handle->
debug_print(
"am2320: read command failed.\n");
908 crc16 = ((uint16_t)out_buf[4] << 8 | (uint16_t)out_buf[3]);
909 if (crc16 != a_am2320_generate_crc16(out_buf, 3))
915 if (out_buf[0] != 0x03)
921 if (out_buf[1] != 0x01)
923 handle->
debug_print(
"am2320: number is invalid.\n");
927 *version = out_buf[2];
947 uint8_t input_buf[3];
962 handle->
debug_print(
"am2320: gpio can't use this function.\n");
974 handle->
debug_print(
"am2320: write command failed.\n");
982 handle->
debug_print(
"am2320: read command failed.\n");
986 crc16 = ((uint16_t)out_buf[4] << 8 | (uint16_t)out_buf[3]);
987 if (crc16 != a_am2320_generate_crc16(out_buf, 3))
993 if (out_buf[0] != 0x03)
999 if (out_buf[1] != 0x01)
1001 handle->
debug_print(
"am2320: number is invalid.\n");
1005 *status = out_buf[2];
1025 uint8_t input_buf[3];
1040 handle->
debug_print(
"am2320: gpio can't use this function.\n");
1046 input_buf[0] = 0x03;
1048 input_buf[2] = 0x04;
1052 handle->
debug_print(
"am2320: write command failed.\n");
1060 handle->
debug_print(
"am2320: read command failed.\n");
1064 crc16 = ((uint16_t)out_buf[7] << 8 | (uint16_t)out_buf[6]);
1065 if (crc16 != a_am2320_generate_crc16(out_buf, 6))
1067 handle->
debug_print(
"am2320: crc check error.\n");
1071 if (out_buf[0] != 0x03)
1073 handle->
debug_print(
"am2320: code is invalid.\n");
1077 if (out_buf[1] != 0x04)
1079 handle->
debug_print(
"am2320: number is invalid.\n");
1083 *
id = (uint32_t)out_buf[2] << 24 | (uint32_t)out_buf[3] << 16 |
1084 (uint32_t)out_buf[4] << 8 | (uint32_t)out_buf[5] << 0;
1104 uint8_t input_buf[7];
1119 handle->
debug_print(
"am2320: gpio can't use this function.\n");
1125 input_buf[0] = 0x10;
1127 input_buf[2] = 0x02;
1128 input_buf[3] = (reg >> 8) & 0xFF;
1129 input_buf[4] = (reg >> 0) & 0xFF;
1130 crc16 = a_am2320_generate_crc16(input_buf, 5);
1131 input_buf[5] = (crc16 >> 0) & 0xFF;
1132 input_buf[6] = (crc16 >> 8) & 0xFF;
1136 handle->
debug_print(
"am2320: write command failed.\n");
1144 handle->
debug_print(
"am2320: read command failed.\n");
1148 crc16 = ((uint16_t)out_buf[4] << 8 | (uint16_t)out_buf[3]);
1149 if (crc16 != a_am2320_generate_crc16(out_buf, 3))
1151 handle->
debug_print(
"am2320: crc check error.\n");
1155 if (out_buf[0] != 0x10)
1157 handle->
debug_print(
"am2320: code is invalid.\n");
1163 handle->
debug_print(
"am2320: addr is invalid.\n");
1167 if (out_buf[2] != 0x02)
1169 handle->
debug_print(
"am2320: number is invalid.\n");
1192 uint8_t input_buf[3];
1207 handle->
debug_print(
"am2320: gpio can't use this function.\n");
1213 input_buf[0] = 0x03;
1215 input_buf[2] = 0x02;
1219 handle->
debug_print(
"am2320: write command failed.\n");
1227 handle->
debug_print(
"am2320: read command failed.\n");
1231 crc16 = ((uint16_t)out_buf[5] << 8 | (uint16_t)out_buf[4]);
1232 if (crc16 != a_am2320_generate_crc16(out_buf, 4))
1234 handle->
debug_print(
"am2320: crc check error.\n");
1238 if (out_buf[0] != 0x03)
1240 handle->
debug_print(
"am2320: code is invalid.\n");
1244 if (out_buf[1] != 0x02)
1246 handle->
debug_print(
"am2320: number is invalid.\n");
1250 *reg = (uint16_t)out_buf[2] << 8 | out_buf[3];
1270 uint8_t input_buf[7];
1285 handle->
debug_print(
"am2320: gpio can't use this function.\n");
1291 input_buf[0] = 0x10;
1293 input_buf[2] = 0x02;
1294 input_buf[3] = (reg >> 8) & 0xFF;
1295 input_buf[4] = (reg >> 0) & 0xFF;
1296 crc16 = a_am2320_generate_crc16(input_buf, 5);
1297 input_buf[5] = (crc16 >> 0) & 0xFF;
1298 input_buf[6] = (crc16 >> 8) & 0xFF;
1302 handle->
debug_print(
"am2320: write command failed.\n");
1310 handle->
debug_print(
"am2320: read command failed.\n");
1314 crc16 = ((uint16_t)out_buf[4] << 8 | (uint16_t)out_buf[3]);
1315 if (crc16 != a_am2320_generate_crc16(out_buf, 3))
1317 handle->
debug_print(
"am2320: crc check error.\n");
1321 if (out_buf[0] != 0x10)
1323 handle->
debug_print(
"am2320: code is invalid.\n");
1329 handle->
debug_print(
"am2320: addr is invalid.\n");
1333 if (out_buf[2] != 0x02)
1335 handle->
debug_print(
"am2320: number is invalid.\n");
1358 uint8_t input_buf[3];
1373 handle->
debug_print(
"am2320: gpio can't use this function.\n");
1379 input_buf[0] = 0x03;
1381 input_buf[2] = 0x02;
1385 handle->
debug_print(
"am2320: write command failed.\n");
1393 handle->
debug_print(
"am2320: read command failed.\n");
1397 crc16 = ((uint16_t)out_buf[5] << 8 | (uint16_t)out_buf[4]);
1398 if (crc16 != a_am2320_generate_crc16(out_buf, 4))
1400 handle->
debug_print(
"am2320: crc check error.\n");
1404 if (out_buf[0] != 0x03)
1406 handle->
debug_print(
"am2320: code is invalid.\n");
1410 if (out_buf[1] != 0x02)
1412 handle->
debug_print(
"am2320: number is invalid.\n");
1416 *reg = (uint16_t)out_buf[2] << 8 | out_buf[3];
1444 handle->
debug_print(
"am2320: iic_init is null.\n");
1450 handle->
debug_print(
"am2320: iic_deinit is null.\n");
1456 handle->
debug_print(
"am2320: iic_read_cmd is null.\n");
1462 handle->
debug_print(
"am2320: iic_write_cmd is null.\n");
1468 handle->
debug_print(
"am2320: bus_init is null.\n");
1474 handle->
debug_print(
"am2320: bus_deinit is null.\n");
1480 handle->
debug_print(
"am2320: bus_read is null.\n");
1486 handle->
debug_print(
"am2320: bus_write is null.\n");
1492 handle->
debug_print(
"am2320: delay_ms is null.\n");
1498 handle->
debug_print(
"am2320: delay_us is null.\n");
1504 handle->
debug_print(
"am2320: enable_irq is null.\n");
1510 handle->
debug_print(
"am2320: disable_irq is null.\n");
1519 handle->
debug_print(
"am2320: bus init failed.\n");
1523 if (a_am2320_reset(handle) != 0)
1535 handle->
debug_print(
"am2320: iic init failed.\n");
1579 handle->
debug_print(
"am2320: iic deinit failed.\n");
1619 handle->
debug_print(
"am2320: gpio can't use this function.\n");
1628 handle->
debug_print(
"am2320: write command failed.\n");
1636 handle->
debug_print(
"am2320: read command failed.\n");
1662 strncpy(info->
interface,
"GPIO IIC", 16);
#define AM2320_MODBUS_ADDRESS_DEVICE_TYPE_MSB
#define AM2320_MODBUS_ADDRESS_HUMI_MSB
modbus address definition
#define AM2320_MODBUS_ADDRESS_USER_REG2_MSB
#define AM2320_MODBUS_ADDRESS_VERSION
#define AM2320_MODBUS_ADDRESS_DEVICE_3
#define AM2320_MODBUS_ADDRESS_STATUS
#define AM2320_ADDRESS
chip address definition
#define SUPPLY_VOLTAGE_MAX
#define MANUFACTURER_NAME
#define AM2320_MODBUS_ADDRESS_TEMP_MSB
#define SUPPLY_VOLTAGE_MIN
#define CHIP_NAME
chip information definition
#define AM2320_MODBUS_ADDRESS_USER_REG1_MSB
driver am2320 header file
uint8_t am2320_set_user_reg1(am2320_handle_t *handle, uint16_t reg)
set user reg1
uint8_t am2320_get_version(am2320_handle_t *handle, uint8_t *version)
get version
uint8_t am2320_get_device_type(am2320_handle_t *handle, uint16_t *type)
get device type
struct am2320_handle_s am2320_handle_t
am2320 handle structure definition
uint8_t am2320_init(am2320_handle_t *handle)
initialize the chip
uint8_t am2320_get_interface(am2320_handle_t *handle, am2320_interface_t *interface)
get the chip interface
uint8_t am2320_read_temperature(am2320_handle_t *handle, uint16_t *raw, float *s)
read the temperature data
uint8_t am2320_read_temperature_humidity(am2320_handle_t *handle, uint16_t *temperature_raw, float *temperature_s, uint16_t *humidity_raw, float *humidity_s)
read the temperature and humidity data
am2320_interface_t
am2320 interface enumeration definition
uint8_t am2320_set_user_reg2(am2320_handle_t *handle, uint16_t reg)
set user reg2
uint8_t am2320_get_device_id(am2320_handle_t *handle, uint32_t *id)
get device id
uint8_t am2320_get_status(am2320_handle_t *handle, uint8_t *status)
get status
uint8_t am2320_get_user_reg1(am2320_handle_t *handle, uint16_t *reg)
get user reg1
uint8_t am2320_read_humidity(am2320_handle_t *handle, uint16_t *raw, float *s)
read the humidity data
uint8_t am2320_deinit(am2320_handle_t *handle)
close the chip
uint8_t am2320_info(am2320_info_t *info)
get chip's information
uint8_t am2320_set_interface(am2320_handle_t *handle, am2320_interface_t interface)
set the chip interface
struct am2320_info_s am2320_info_t
am2320 info structure definition
uint8_t am2320_get_user_reg2(am2320_handle_t *handle, uint16_t *reg)
get user reg2
uint8_t am2320_set_get_reg(am2320_handle_t *handle, uint8_t *input_buf, uint16_t input_len, uint8_t *output_buf, uint16_t output_len)
set and get the register value
uint8_t(* bus_deinit)(void)
void(* delay_ms)(uint32_t ms)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
void(* delay_us)(uint32_t us)
void(* disable_irq)(void)
uint8_t(* bus_read)(uint8_t *value)
uint8_t(* bus_write)(uint8_t value)
uint8_t(* iic_read_cmd)(uint8_t addr, uint8_t *buf, uint16_t len)
uint8_t(* bus_init)(void)
uint8_t(* iic_deinit)(void)
uint8_t(* iic_write_cmd)(uint8_t addr, uint8_t *buf, uint16_t len)
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v