LibDriver AMG8833
Loading...
Searching...
No Matches
driver_amg8833_read_test.c
Go to the documentation of this file.
1
36
38
39static amg8833_handle_t gs_handle;
40static int16_t gs_raw[8][8];
41static float gs_temp[8][8];
42
52uint8_t amg8833_read_test(amg8833_address_t addr_pin, uint32_t times)
53{
54 uint32_t i, j, k;
55 uint8_t res;
56 amg8833_info_t info;
57
58 /* link interface function */
67
68 /* get information */
69 res = amg8833_info(&info);
70 if (res != 0)
71 {
72 amg8833_interface_debug_print("amg8833: get info failed.\n");
73
74 return 1;
75 }
76 else
77 {
78 /* print chip info */
79 amg8833_interface_debug_print("amg8833: chip is %s.\n", info.chip_name);
80 amg8833_interface_debug_print("amg8833: manufacturer is %s.\n", info.manufacturer_name);
81 amg8833_interface_debug_print("amg8833: interface is %s.\n", info.interface);
82 amg8833_interface_debug_print("amg8833: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000 ) / 100);
83 amg8833_interface_debug_print("amg8833: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
84 amg8833_interface_debug_print("amg8833: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
85 amg8833_interface_debug_print("amg8833: max current is %0.2fmA.\n", info.max_current_ma);
86 amg8833_interface_debug_print("amg8833: max temperature is %0.1fC.\n", info.temperature_max);
87 amg8833_interface_debug_print("amg8833: min temperature is %0.1fC.\n", info.temperature_min);
88 }
89
90 /* start read test */
91 amg8833_interface_debug_print("amg8833: start read test.\n");
92
93 /* set the address */
94 res = amg8833_set_addr_pin(&gs_handle, addr_pin);
95 if (res != 0)
96 {
97 amg8833_interface_debug_print("amg8833: set addr pin failed.\n");
98
99 return 1;
100 }
101
102 /* init */
103 res = amg8833_init(&gs_handle);
104 if (res != 0)
105 {
106 amg8833_interface_debug_print("amg8833: init failed.\n");
107
108 return 1;
109 }
110
111 /* set normal mode */
112 res = amg8833_set_mode(&gs_handle, AMG8833_MODE_NORMAL);
113 if (res != 0)
114 {
115 amg8833_interface_debug_print("amg8833: set mode failed.\n");
116 (void)amg8833_deinit(&gs_handle);
117
118 return 1;
119 }
120
121 /* 10 fps */
123 if (res != 0)
124 {
125 amg8833_interface_debug_print("amg8833: set frame rate failed.\n");
126 (void)amg8833_deinit(&gs_handle);
127
128 return 1;
129 }
130
131 /* disable */
132 res = amg8833_set_interrupt(&gs_handle, AMG8833_BOOL_FALSE);
133 if (res != 0)
134 {
135 amg8833_interface_debug_print("amg8833: set interrupt failed.\n");
136 (void)amg8833_deinit(&gs_handle);
137
138 return 1;
139 }
140
141 /* twice mode */
143 if (res != 0)
144 {
145 amg8833_interface_debug_print("amg8833: set average mode failed.\n");
146 (void)amg8833_deinit(&gs_handle);
147
148 return 1;
149 }
150
151 /* delay 1000 ms */
153
154 for (i = 0; i < times; i++)
155 {
156 int16_t raw;
157 float temp;
158
159 /* read temperature array */
160 res = amg8833_read_temperature_array(&gs_handle, gs_raw, gs_temp);
161 if (res != 0)
162 {
163 amg8833_interface_debug_print("amg8833: read temperature array failed.\n");
164 (void)amg8833_deinit(&gs_handle);
165
166 return 1;
167 }
168 else
169 {
170 for (j = 0; j < 8; j++)
171 {
172 for (k = 0; k < 8; k++)
173 {
174 amg8833_interface_debug_print("%0.2f ", gs_temp[j][k]);
175 }
177 }
178 }
179
180 /* read temperature */
181 res = amg8833_read_temperature(&gs_handle, (int16_t *)&raw, (float *)&temp);
182 if (res != 0)
183 {
184 amg8833_interface_debug_print("amg8833: read temperature failed.\n");
185 (void)amg8833_deinit(&gs_handle);
186
187 return 1;
188 }
189 else
190 {
191 amg8833_interface_debug_print("amg8833: temperature is %0.3fC.\n", temp);
192 }
193
194 /* delay 1000 ms */
196 }
197
198 /* finish read test */
199 amg8833_interface_debug_print("amg8833: finish read test.\n");
200 (void)amg8833_deinit(&gs_handle);
201
202 return 0;
203}
driver amg8833 read test header file
amg8833_address_t
amg8833 address 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
uint8_t amg8833_set_addr_pin(amg8833_handle_t *handle, amg8833_address_t addr_pin)
set the iic address pin
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_info(amg8833_info_t *info)
get chip's information
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_set_average_mode(amg8833_handle_t *handle, amg8833_average_mode_t mode)
set the average_mode
uint8_t amg8833_read_temperature(amg8833_handle_t *handle, int16_t *raw, float *temp)
read the temperature
uint8_t amg8833_set_frame_rate(amg8833_handle_t *handle, amg8833_frame_rate_t rate)
set the frame rate
uint8_t amg8833_init(amg8833_handle_t *handle)
initialize the chip
@ AMG8833_FRAME_RATE_10_FPS
@ AMG8833_BOOL_FALSE
@ AMG8833_AVERAGE_MODE_TWICE
@ AMG8833_MODE_NORMAL
uint8_t amg8833_interface_iic_deinit(void)
interface iic bus deinit
void amg8833_interface_receive_callback(uint8_t type)
interface receive callback
void amg8833_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t amg8833_interface_iic_write(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus write
void amg8833_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t amg8833_interface_iic_init(void)
interface iic bus init
uint8_t amg8833_interface_iic_read(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus read
uint8_t amg8833_read_test(amg8833_address_t addr_pin, uint32_t times)
read test
uint32_t driver_version
char manufacturer_name[32]