42#define CHIP_NAME "Panasonic AMG8833"
43#define MANUFACTURER_NAME "Panasonic"
44#define SUPPLY_VOLTAGE_MIN 3.0f
45#define SUPPLY_VOLTAGE_MAX 3.6f
46#define MAX_CURRENT 5.0f
47#define TEMPERATURE_MIN 0.0f
48#define TEMPERATURE_MAX 80.0f
49#define DRIVER_VERSION 1000
54#define AMG8833_REG_PCTL 0x00
55#define AMG8833_REG_RST 0x01
56#define AMG8833_REG_FPSC 0x02
57#define AMG8833_REG_INTC 0x03
58#define AMG8833_REG_STAT 0x04
59#define AMG8833_REG_SCLR 0x05
60#define AMG8833_REG_AVE 0x07
61#define AMG8833_REG_INTHL 0x08
62#define AMG8833_REG_INTHH 0x09
63#define AMG8833_REG_INTLL 0x0A
64#define AMG8833_REG_INTLH 0x0B
65#define AMG8833_REG_IHYSL 0x0C
66#define AMG8833_REG_IHYSH 0x0D
67#define AMG8833_REG_TTHL 0x0E
68#define AMG8833_REG_TTHH 0x0F
69#define AMG8833_REG_INT0 0x10
70#define AMG8833_REG_INT1 0x11
71#define AMG8833_REG_INT2 0x12
72#define AMG8833_REG_INT3 0x13
73#define AMG8833_REG_INT4 0x14
74#define AMG8833_REG_INT5 0x15
75#define AMG8833_REG_INT6 0x16
76#define AMG8833_REG_INT7 0x17
77#define AMG8833_REG_T01L 0x80
78#define AMG8833_REG_T01H 0x81
91static uint8_t a_amg8833_iic_read(
amg8833_handle_t *handle, uint8_t reg, uint8_t *data, uint16_t len)
114static uint8_t a_amg8833_iic_write(
amg8833_handle_t *handle, uint8_t reg, uint8_t *data, uint16_t len)
142 handle->
iic_addr = (uint8_t)addr_pin;
193 handle->
debug_print(
"amg8833: iic_init is null.\n");
199 handle->
debug_print(
"amg8833: iic_deinit is null.\n");
205 handle->
debug_print(
"amg8833: iic_read is null.\n");
211 handle->
debug_print(
"amg8833: iic_write is null.\n");
217 handle->
debug_print(
"amg8833: delay_ms is null.\n");
223 handle->
debug_print(
"amg8833: receive_callback is null.\n");
229 handle->
debug_print(
"amg8833: iic init failed.\n");
237 handle->
debug_print(
"amg8833: write pctl register failed.\n");
244 res = a_amg8833_iic_write(handle,
AMG8833_REG_RST, (uint8_t *)&prev, 1);
247 handle->
debug_print(
"amg8833: write rst register failed.\n");
254 res = a_amg8833_iic_write(handle,
AMG8833_REG_RST, (uint8_t *)&prev, 1);
257 handle->
debug_print(
"amg8833: write rst register failed.\n");
295 handle->
debug_print(
"amg8833: write pctl register failed.\n");
302 handle->
debug_print(
"amg8833: iic deinit failed.\n");
340 handle->
debug_print(
"amg8833: read stat register failed.\n");
347 handle->
debug_print(
"amg8833: write sclr register failed.\n");
405 handle->
debug_print(
"amg8833: write pctl register failed.\n");
441 handle->
debug_print(
"amg8833: read pctl register failed.\n");
476 res = a_amg8833_iic_write(handle,
AMG8833_REG_RST, (uint8_t *)&prev, 1);
479 handle->
debug_print(
"amg8833: write rst register failed.\n");
515 handle->
debug_print(
"amg8833: read fpsc register failed.\n");
524 handle->
debug_print(
"amg8833: write fpsc register failed.\n");
560 handle->
debug_print(
"amg8833: read fpsc register failed.\n");
597 handle->
debug_print(
"amg8833: read intc register failed.\n");
606 handle->
debug_print(
"amg8833: write intc register failed.\n");
642 handle->
debug_print(
"amg8833: read intc register failed.\n");
679 handle->
debug_print(
"amg8833: read intc register failed.\n");
688 handle->
debug_print(
"amg8833: write intc register failed.\n");
724 handle->
debug_print(
"amg8833: read intc register failed.\n");
761 handle->
debug_print(
"amg8833: read stat register failed.\n");
799 handle->
debug_print(
"amg8833: write sclr register failed.\n");
823 uint8_t unlock_seq[] = {0x50, 0x45, 0x57};
834 for (i = 0; i < 3; i++)
836 prev = unlock_seq[i];
837 res = a_amg8833_iic_write(handle, 0x1F, &prev, 1);
840 handle->
debug_print(
"amg8833: write unlock sequence failed.\n");
846 res = a_amg8833_iic_read(handle,
AMG8833_REG_AVE, (uint8_t *)&prev, 1);
849 handle->
debug_print(
"amg8833: read ave register failed.\n");
855 res = a_amg8833_iic_write(handle,
AMG8833_REG_AVE, (uint8_t *)&prev, 1);
858 handle->
debug_print(
"amg8833: write ave register failed.\n");
864 res = a_amg8833_iic_write(handle, 0x1F, &prev, 1);
867 handle->
debug_print(
"amg8833: write lock sequence failed.\n");
900 res = a_amg8833_iic_read(handle,
AMG8833_REG_AVE, (uint8_t *)&prev, 1);
903 handle->
debug_print(
"amg8833: read ave register failed.\n");
937 buf[0] = (level >> 0) & 0xFF;
938 buf[1] = (level >> 8) & 0xF;
942 handle->
debug_print(
"amg8833: write inthl register failed.\n");
949 handle->
debug_print(
"amg8833: write inthh register failed.\n");
985 handle->
debug_print(
"amg8833: read inthl register failed.\n");
992 handle->
debug_print(
"amg8833: read inthh register failed.\n");
996 if ((buf[1] & (1 << 3)) != 0)
998 *level = (int16_t)(((uint16_t)(buf[1]) << 8) |
999 ((uint16_t)(0xF) << 12) | (buf[0] << 0));
1003 *level = (int16_t)(((uint16_t)(buf[1]) << 8) | (buf[0] << 0));
1034 buf[0] = (level >> 0) & 0xFF;
1035 buf[1] = (level >> 8) & 0xF;
1039 handle->
debug_print(
"amg8833: write intll register failed.\n");
1046 handle->
debug_print(
"amg8833: write intlh register failed.\n");
1082 handle->
debug_print(
"amg8833: read intll register failed.\n");
1089 handle->
debug_print(
"amg8833: read intlh register failed.\n");
1093 if ((buf[1] & (1 << 3)) != 0)
1095 *level = (int16_t)(((uint16_t)(buf[1]) << 8) |
1096 ((uint16_t)(0xF) << 12) | (buf[0] << 0));
1100 *level = (int16_t)(((uint16_t)(buf[1]) << 8) | (buf[0] << 0));
1131 buf[0] = (level >> 0) & 0xFF;
1132 buf[1] = (level >> 8) & 0xF;
1136 handle->
debug_print(
"amg8833: write ihysl register failed.\n");
1143 handle->
debug_print(
"amg8833: write ihysh register failed.\n");
1179 handle->
debug_print(
"amg8833: read ihysl register failed.\n");
1186 handle->
debug_print(
"amg8833: read ihysh register failed.\n");
1190 if ((buf[1] & (1 << 3)) != 0)
1192 *level = (int16_t)(((uint16_t)(buf[1]) << 8) |
1193 ((uint16_t)(0xF) << 12) | (buf[0] << 0));
1197 *level = (int16_t)(((uint16_t)(buf[1]) << 8) | (buf[0] << 0));
1225 *reg = (int16_t)(temp / 0.25f);
1252 *temp = (float)(reg) * 0.25f;
1287 handle->
debug_print(
"amg8833: read tthl register failed.\n");
1294 handle->
debug_print(
"amg8833: read tthh register failed.\n");
1298 *raw = (int16_t)(((uint16_t)(buf[1] & 0xF) << 8) | (buf[0] << 0));
1299 data = (int16_t)(((uint16_t)(buf[1] & 0x7) << 8) | (buf[0] << 0));
1300 if ((buf[1] & 0x8) != 0)
1304 *temp = data * 0.0625f;
1346 handle->
debug_print(
"amg8833: read t01l register failed.\n");
1350 for (i = 0; i < 8; i++)
1352 for (j = 0; j < 8; j++)
1354 raw[7 - i][7 - j] = (int16_t)(((uint16_t)buf[i * 16 + j * 2 + 1] << 8) |
1355 buf[i * 16 + j * 2 + 0]);
1356 temp[7 - i][7 - j] = (float)raw[7 - i][7 - j] * 0.25f;
1393 res = a_amg8833_iic_read(handle,
AMG8833_REG_INT0, (uint8_t *)table[7], 1);
1396 handle->
debug_print(
"amg8833: read int0 register failed.\n");
1400 res = a_amg8833_iic_read(handle,
AMG8833_REG_INT1, (uint8_t *)table[6], 1);
1403 handle->
debug_print(
"amg8833: read int1 register failed.\n");
1407 res = a_amg8833_iic_read(handle,
AMG8833_REG_INT2, (uint8_t *)table[5], 1);
1410 handle->
debug_print(
"amg8833: read int2 register failed.\n");
1414 res = a_amg8833_iic_read(handle,
AMG8833_REG_INT3, (uint8_t *)table[4], 1);
1417 handle->
debug_print(
"amg8833: read int3 register failed.\n");
1421 res = a_amg8833_iic_read(handle,
AMG8833_REG_INT4, (uint8_t *)table[3], 1);
1424 handle->
debug_print(
"amg8833: read int4 register failed.\n");
1428 res = a_amg8833_iic_read(handle,
AMG8833_REG_INT5, (uint8_t *)table[2], 1);
1431 handle->
debug_print(
"amg8833: read int5 register failed.\n");
1435 res = a_amg8833_iic_read(handle,
AMG8833_REG_INT6, (uint8_t *)table[1], 1);
1438 handle->
debug_print(
"amg8833: read int6 register failed.\n");
1442 res = a_amg8833_iic_read(handle,
AMG8833_REG_INT7, (uint8_t *)table[0], 1);
1445 handle->
debug_print(
"amg8833: read int7 register failed.\n");
1477 return a_amg8833_iic_write(handle, reg, buf, len);
1504 return a_amg8833_iic_read(handle, reg, buf, len);
#define AMG8833_REG_IHYSH
#define SUPPLY_VOLTAGE_MAX
#define AMG8833_REG_INTHL
#define AMG8833_REG_INTLH
#define AMG8833_REG_INTLL
#define MANUFACTURER_NAME
#define SUPPLY_VOLTAGE_MIN
#define AMG8833_REG_PCTL
chip register definition
#define AMG8833_REG_IHYSL
#define CHIP_NAME
chip information definition
#define AMG8833_REG_INTHH
driver amg8833 header file
amg8833_address_t
amg8833 address enumeration definition
uint8_t amg8833_get_frame_rate(amg8833_handle_t *handle, amg8833_frame_rate_t *rate)
get the frame rate
amg8833_frame_rate_t
amg8833 frame rate enumeration definition
uint8_t amg8833_set_interrupt(amg8833_handle_t *handle, amg8833_bool_t enable)
enable or disable the interrupt
struct amg8833_handle_s amg8833_handle_t
amg8833 handle structure definition
amg8833_bool_t
amg8833 bool enumeration definition
uint8_t amg8833_get_status(amg8833_handle_t *handle, uint8_t *status)
get the status
uint8_t amg8833_clear_status(amg8833_handle_t *handle, amg8833_status_t status)
clear the interrupt status
amg8833_average_mode_t
amg8833 average mode enumeration definition
uint8_t amg8833_set_addr_pin(amg8833_handle_t *handle, amg8833_address_t addr_pin)
set the iic address pin
amg8833_mode_t
amg8833 mode enumeration definition
uint8_t amg8833_get_mode(amg8833_handle_t *handle, amg8833_mode_t *mode)
get the mode
uint8_t amg8833_get_interrupt_table(amg8833_handle_t *handle, uint8_t table[8][1])
get the interrupt table
uint8_t amg8833_deinit(amg8833_handle_t *handle)
close the chip
struct amg8833_info_s amg8833_info_t
amg8833 information structure definition
uint8_t amg8833_get_interrupt_hysteresis_level(amg8833_handle_t *handle, int16_t *level)
get the interrupt hysteresis level
uint8_t amg8833_interrupt_level_convert_to_data(amg8833_handle_t *handle, int16_t reg, float *temp)
convert the register raw data to the interrupt level
uint8_t amg8833_get_average_mode(amg8833_handle_t *handle, amg8833_average_mode_t *mode)
get the average_mode
uint8_t amg8833_reset(amg8833_handle_t *handle, amg8833_reset_type_t type)
reset the chip
uint8_t amg8833_set_interrupt_low_level(amg8833_handle_t *handle, int16_t level)
set the interrupt low level
uint8_t amg8833_get_interrupt_high_level(amg8833_handle_t *handle, int16_t *level)
get the interrupt high level
uint8_t amg8833_info(amg8833_info_t *info)
get chip's information
uint8_t amg8833_set_interrupt_mode(amg8833_handle_t *handle, amg8833_interrupt_mode_t mode)
set the interrupt mode
uint8_t amg8833_get_interrupt_mode(amg8833_handle_t *handle, amg8833_interrupt_mode_t *mode)
get the interrupt mode
uint8_t amg8833_read_temperature_array(amg8833_handle_t *handle, int16_t raw[8][8], float temp[8][8])
read the temperature array
uint8_t amg8833_set_mode(amg8833_handle_t *handle, amg8833_mode_t mode)
set the mode
uint8_t amg8833_get_addr_pin(amg8833_handle_t *handle, amg8833_address_t *addr_pin)
get the iic address pin
amg8833_reset_type_t
amg8833 reset type enumeration definition
amg8833_interrupt_mode_t
amg8833 interrupt mode enumeration definition
uint8_t amg8833_set_average_mode(amg8833_handle_t *handle, amg8833_average_mode_t mode)
set the average_mode
uint8_t amg8833_set_interrupt_high_level(amg8833_handle_t *handle, int16_t level)
set the interrupt high level
uint8_t amg8833_read_temperature(amg8833_handle_t *handle, int16_t *raw, float *temp)
read the temperature
uint8_t amg8833_get_interrupt_low_level(amg8833_handle_t *handle, int16_t *level)
get the interrupt low level
uint8_t amg8833_irq_handler(amg8833_handle_t *handle)
irq handler
uint8_t amg8833_get_interrupt(amg8833_handle_t *handle, amg8833_bool_t *enable)
get the interrupt status
uint8_t amg8833_set_frame_rate(amg8833_handle_t *handle, amg8833_frame_rate_t rate)
set the frame rate
uint8_t amg8833_interrupt_level_convert_to_register(amg8833_handle_t *handle, float temp, int16_t *reg)
convert the interrupt level to the register raw data
amg8833_status_t
amg8833 status enumeration definition
uint8_t amg8833_set_interrupt_hysteresis_level(amg8833_handle_t *handle, int16_t level)
set the interrupt hysteresis level
uint8_t amg8833_init(amg8833_handle_t *handle)
initialize the chip
uint8_t amg8833_set_reg(amg8833_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set the chip register
uint8_t amg8833_get_reg(amg8833_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get the chip register
void(* delay_ms)(uint32_t ms)
void(* receive_callback)(uint8_t type)
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)
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v