LibDriver AOX4000
Loading...
Searching...
No Matches
driver_aox4000_read_test.c
Go to the documentation of this file.
1
36
38
39static aox4000_handle_t gs_handle;
40
49uint8_t aox4000_read_test(uint32_t times)
50{
51 uint8_t res;
52 uint32_t i;
53 aox4000_info_t info;
54
55 /* link interface function */
64
65 /* get aox4000 information */
66 res = aox4000_info(&info);
67 if (res != 0)
68 {
69 aox4000_interface_debug_print("aox4000: get info failed.\n");
70
71 return 1;
72 }
73 else
74 {
75 /* print chip information */
76 aox4000_interface_debug_print("aox4000: chip is %s.\n", info.chip_name);
77 aox4000_interface_debug_print("aox4000: manufacturer is %s.\n", info.manufacturer_name);
78 aox4000_interface_debug_print("aox4000: interface is %s.\n", info.interface);
79 aox4000_interface_debug_print("aox4000: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
80 aox4000_interface_debug_print("aox4000: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
81 aox4000_interface_debug_print("aox4000: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
82 aox4000_interface_debug_print("aox4000: max current is %0.2fmA.\n", info.max_current_ma);
83 aox4000_interface_debug_print("aox4000: max temperature is %0.1fC.\n", info.temperature_max);
84 aox4000_interface_debug_print("aox4000: min temperature is %0.1fC.\n", info.temperature_min);
85 }
86
87 /* aox4000 init */
88 res = aox4000_init(&gs_handle);
89 if (res != 0)
90 {
91 aox4000_interface_debug_print("aox4000: init failed.\n");
92
93 return 1;
94 }
95
96 /* start read test */
97 aox4000_interface_debug_print("aox4000: start read test.\n");
98
99 /* auto mode read test */
100 aox4000_interface_debug_print("aox4000: auto mode read test.\n");
101
102 /* set auto mode */
103 res = aox4000_set_mode(&gs_handle, AOX4000_MODE_AUTO);
104 if (res != 0)
105 {
106 aox4000_interface_debug_print("aox4000: set mode failed.\n");
107 (void)aox4000_deinit(&gs_handle);
108
109 return 1;
110 }
111
112 /* read test */
113 aox4000_interface_debug_print("aox4000: read test.\n");
114
115 for (i = 0; i < times; i++)
116 {
117 float oxygen_ppo2_mbar;
118 float oxygen_density_percentage;
119 float temperature_degree;
120 float pressure_mbar;
121
122 /* delay 1000ms */
124
125 /* read */
126 res = aox4000_read(&gs_handle,
127 &oxygen_ppo2_mbar,
128 &oxygen_density_percentage,
129 &temperature_degree,
130 &pressure_mbar);
131 if (res != 0)
132 {
133 aox4000_interface_debug_print("aox4000: read failed.\n");
134 (void)aox4000_deinit(&gs_handle);
135
136 return 1;
137 }
138
139 /* output */
140 aox4000_interface_debug_print("aox4000: oxygen ppo2 is %0.2fmbar.\n", oxygen_ppo2_mbar);
141 aox4000_interface_debug_print("aox4000: oxygen density is %0.2f%%.\n", oxygen_density_percentage);
142 aox4000_interface_debug_print("aox4000: temperature is %0.2fC.\n", temperature_degree);
143 aox4000_interface_debug_print("aox4000: pressure is %0.2fmbar.\n", pressure_mbar);
144 }
145
146 /* read oxygen ppo2 test */
147 aox4000_interface_debug_print("aox4000: read oxygen ppo2 test.\n");
148
149 for (i = 0; i < times; i++)
150 {
151 float oxygen_ppo2_mbar;
152
153 /* delay 1000ms */
155
156 /* read */
157 res = aox4000_read_oxygen_ppo2(&gs_handle, &oxygen_ppo2_mbar);
158 if (res != 0)
159 {
160 aox4000_interface_debug_print("aox4000: read failed.\n");
161 (void)aox4000_deinit(&gs_handle);
162
163 return 1;
164 }
165
166 /* output */
167 aox4000_interface_debug_print("aox4000: oxygen ppo2 is %0.2fmbar.\n", oxygen_ppo2_mbar);
168 }
169
170 /* read oxygen density test */
171 aox4000_interface_debug_print("aox4000: read oxygen density test.\n");
172
173 for (i = 0; i < times; i++)
174 {
175 float oxygen_density_percentage;
176
177 /* delay 1000ms */
179
180 /* read */
181 res = aox4000_read_oxygen_density(&gs_handle, &oxygen_density_percentage);
182 if (res != 0)
183 {
184 aox4000_interface_debug_print("aox4000: read failed.\n");
185 (void)aox4000_deinit(&gs_handle);
186
187 return 1;
188 }
189
190 /* output */
191 aox4000_interface_debug_print("aox4000: oxygen density is %0.2f%%.\n", oxygen_density_percentage);
192 }
193
194 /* read temperature test */
195 aox4000_interface_debug_print("aox4000: read temperature test.\n");
196
197 for (i = 0; i < times; i++)
198 {
199 float temperature_degree;
200
201 /* delay 1000ms */
203
204 /* read */
205 res = aox4000_read_temperature(&gs_handle, &temperature_degree);
206 if (res != 0)
207 {
208 aox4000_interface_debug_print("aox4000: read failed.\n");
209 (void)aox4000_deinit(&gs_handle);
210
211 return 1;
212 }
213
214 /* output */
215 aox4000_interface_debug_print("aox4000: temperature is %0.2fC.\n", temperature_degree);
216 }
217
218 /* read pressure test */
219 aox4000_interface_debug_print("aox4000: read pressure test.\n");
220
221 for (i = 0; i < times; i++)
222 {
223 float pressure_mbar;
224
225 /* delay 1000ms */
227
228 /* read */
229 res = aox4000_read_pressure(&gs_handle, &pressure_mbar);
230 if (res != 0)
231 {
232 aox4000_interface_debug_print("aox4000: read failed.\n");
233 (void)aox4000_deinit(&gs_handle);
234
235 return 1;
236 }
237
238 /* output */
239 aox4000_interface_debug_print("aox4000: pressure is %0.2fmbar.\n", pressure_mbar);
240 }
241
242 /* request mode read test */
243 aox4000_interface_debug_print("aox4000: request mode read test.\n");
244
245 /* set request mode */
246 res = aox4000_set_mode(&gs_handle, AOX4000_MODE_REQUEST);
247 if (res != 0)
248 {
249 aox4000_interface_debug_print("aox4000: set mode failed.\n");
250 (void)aox4000_deinit(&gs_handle);
251
252 return 1;
253 }
254
255 /* read test */
256 aox4000_interface_debug_print("aox4000: read test.\n");
257
258 for (i = 0; i < times; i++)
259 {
260 float oxygen_ppo2_mbar;
261 float oxygen_density_percentage;
262 float temperature_degree;
263 float pressure_mbar;
264
265 /* delay 1000ms */
267
268 /* read */
269 res = aox4000_read(&gs_handle,
270 &oxygen_ppo2_mbar,
271 &oxygen_density_percentage,
272 &temperature_degree,
273 &pressure_mbar);
274 if (res != 0)
275 {
276 aox4000_interface_debug_print("aox4000: read failed.\n");
277 (void)aox4000_deinit(&gs_handle);
278
279 return 1;
280 }
281
282 /* output */
283 aox4000_interface_debug_print("aox4000: oxygen ppo2 is %0.2fmbar.\n", oxygen_ppo2_mbar);
284 aox4000_interface_debug_print("aox4000: oxygen density is %0.2f%%.\n", oxygen_density_percentage);
285 aox4000_interface_debug_print("aox4000: temperature is %0.2fC.\n", temperature_degree);
286 aox4000_interface_debug_print("aox4000: pressure is %0.2fmbar.\n", pressure_mbar);
287 }
288
289 /* read oxygen ppo2 test */
290 aox4000_interface_debug_print("aox4000: read oxygen ppo2 test.\n");
291
292 for (i = 0; i < times; i++)
293 {
294 float oxygen_ppo2_mbar;
295
296 /* delay 1000ms */
298
299 /* read */
300 res = aox4000_read_oxygen_ppo2(&gs_handle, &oxygen_ppo2_mbar);
301 if (res != 0)
302 {
303 aox4000_interface_debug_print("aox4000: read failed.\n");
304 (void)aox4000_deinit(&gs_handle);
305
306 return 1;
307 }
308
309 /* output */
310 aox4000_interface_debug_print("aox4000: oxygen ppo2 is %0.2fmbar.\n", oxygen_ppo2_mbar);
311 }
312
313 /* read oxygen density test */
314 aox4000_interface_debug_print("aox4000: read oxygen density test.\n");
315
316 for (i = 0; i < times; i++)
317 {
318 float oxygen_density_percentage;
319
320 /* delay 1000ms */
322
323 /* read */
324 res = aox4000_read_oxygen_density(&gs_handle, &oxygen_density_percentage);
325 if (res != 0)
326 {
327 aox4000_interface_debug_print("aox4000: read failed.\n");
328 (void)aox4000_deinit(&gs_handle);
329
330 return 1;
331 }
332
333 /* output */
334 aox4000_interface_debug_print("aox4000: oxygen density is %0.2f%%.\n", oxygen_density_percentage);
335 }
336
337 /* read temperature test */
338 aox4000_interface_debug_print("aox4000: read temperature test.\n");
339
340 for (i = 0; i < times; i++)
341 {
342 float temperature_degree;
343
344 /* delay 1000ms */
346
347 /* read */
348 res = aox4000_read_temperature(&gs_handle, &temperature_degree);
349 if (res != 0)
350 {
351 aox4000_interface_debug_print("aox4000: read failed.\n");
352 (void)aox4000_deinit(&gs_handle);
353
354 return 1;
355 }
356
357 /* output */
358 aox4000_interface_debug_print("aox4000: temperature is %0.2fC.\n", temperature_degree);
359 }
360
361 /* read pressure test */
362 aox4000_interface_debug_print("aox4000: read pressure test.\n");
363
364 for (i = 0; i < times; i++)
365 {
366 float pressure_mbar;
367
368 /* delay 1000ms */
370
371 /* read */
372 res = aox4000_read_pressure(&gs_handle, &pressure_mbar);
373 if (res != 0)
374 {
375 aox4000_interface_debug_print("aox4000: read failed.\n");
376 (void)aox4000_deinit(&gs_handle);
377
378 return 1;
379 }
380
381 /* output */
382 aox4000_interface_debug_print("aox4000: pressure is %0.2fmbar.\n", pressure_mbar);
383 }
384
385 /* finish read test */
386 aox4000_interface_debug_print("aox4000: finish read test.\n");
387 (void)aox4000_deinit(&gs_handle);
388
389 return 0;
390}
driver aox4000 read test header file
uint8_t aox4000_read(aox4000_handle_t *handle, float *oxygen_ppo2_mbar, float *oxygen_density_percentage, float *temperature_degree, float *pressure_mbar)
read data
uint8_t aox4000_read_oxygen_density(aox4000_handle_t *handle, float *percentage)
read oxygen density
uint8_t aox4000_info(aox4000_info_t *info)
get chip's information
struct aox4000_handle_s aox4000_handle_t
aox4000 handle structure definition
uint8_t aox4000_read_temperature(aox4000_handle_t *handle, float *degree)
read temperature
uint8_t aox4000_deinit(aox4000_handle_t *handle)
close the chip
uint8_t aox4000_init(aox4000_handle_t *handle)
initialize the chip
struct aox4000_info_s aox4000_info_t
aox4000 information structure definition
uint8_t aox4000_read_oxygen_ppo2(aox4000_handle_t *handle, float *mbar)
read oxygen ppo2
uint8_t aox4000_read_pressure(aox4000_handle_t *handle, float *mbar)
read pressure
uint8_t aox4000_set_mode(aox4000_handle_t *handle, aox4000_mode_t mode)
set mode
@ AOX4000_MODE_AUTO
@ AOX4000_MODE_REQUEST
void aox4000_interface_delay_ms(uint32_t ms)
interface delay ms
uint16_t aox4000_interface_uart_read(uint8_t *buf, uint16_t len)
interface uart read
uint8_t aox4000_interface_uart_init(void)
interface uart init
void aox4000_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t aox4000_interface_uart_flush(void)
interface uart flush
uint8_t aox4000_interface_uart_write(uint8_t *buf, uint16_t len)
interface uart write
uint8_t aox4000_interface_uart_deinit(void)
interface uart deinit
uint8_t aox4000_read_test(uint32_t times)
read test
uint32_t driver_version
char manufacturer_name[32]