LibDriver APDS9960
Loading...
Searching...
No Matches
driver_apds9960_register_test.c
Go to the documentation of this file.
1
36
38#include <stdlib.h>
39
40static apds9960_handle_t gs_handle;
41
50{
51 uint8_t res;
52 uint8_t integration_time, integration_time_check;
53 uint8_t wait_time, wait_time_check;
54 uint16_t threshold, threshold_check;
55 uint8_t reg, reg_check;
56 uint16_t count, count_check;
57 int8_t offset, offset_check;
58 uint8_t mask, mask_check;
59 uint8_t status;
60 uint8_t level;
61 float ms, ms_check;
62 int32_t sensitivity, sensitivity_check;
63 apds9960_info_t info;
64 apds9960_bool_t enable;
69 apds9960_proximity_gain_t proximity_gain;
75 apds9960_gesture_led_current_t gesture_current;
76 apds9960_gesture_wait_time_t gesture_wait_time;
79
80 /* link interface function */
89
90 /* get information */
91 res = apds9960_info(&info);
92 if (res != 0)
93 {
94 apds9960_interface_debug_print("apds9960: get info failed.\n");
95
96 return 1;
97 }
98 else
99 {
100 /* print chip info */
101 apds9960_interface_debug_print("apds9960: chip is %s.\n", info.chip_name);
102 apds9960_interface_debug_print("apds9960: manufacturer is %s.\n", info.manufacturer_name);
103 apds9960_interface_debug_print("apds9960: interface is %s.\n", info.interface);
104 apds9960_interface_debug_print("apds9960: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
105 apds9960_interface_debug_print("apds9960: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
106 apds9960_interface_debug_print("apds9960: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
107 apds9960_interface_debug_print("apds9960: max current is %0.2fmA.\n", info.max_current_ma);
108 apds9960_interface_debug_print("apds9960: max temperature is %0.1fC.\n", info.temperature_max);
109 apds9960_interface_debug_print("apds9960: min temperature is %0.1fC.\n", info.temperature_min);
110 }
111
112 /* start register test */
113 apds9960_interface_debug_print("apds9960: start register test.\n");
114
115 /* init the apds9960 */
116 res = apds9960_init(&gs_handle);
117 if (res != 0)
118 {
119 apds9960_interface_debug_print("apds9960: init failed.\n");
120
121 return 1;
122 }
123
124 /* apds9960_set_conf/apds9960_get_conf test */
125 apds9960_interface_debug_print("apds9960: apds9960_set_conf/apds9960_get_conf test.\n");
126
127 /* disable power on */
129 if (res != 0)
130 {
131 apds9960_interface_debug_print("apds9960: set conf failed.\n");
132 (void)apds9960_deinit(&gs_handle);
133
134 return 1;
135 }
136 apds9960_interface_debug_print("apds9960: disable power on.\n");
137 res = apds9960_get_conf(&gs_handle, APDS9960_CONF_POWER_ON, &enable);
138 if (res != 0)
139 {
140 apds9960_interface_debug_print("apds9960: get conf failed.\n");
141 (void)apds9960_deinit(&gs_handle);
142
143 return 1;
144 }
145 apds9960_interface_debug_print("apds9960: check config %s.\n", enable == APDS9960_BOOL_FALSE ? "ok" : "error");
146
147 /* enable power on */
149 if (res != 0)
150 {
151 apds9960_interface_debug_print("apds9960: set conf failed.\n");
152 (void)apds9960_deinit(&gs_handle);
153
154 return 1;
155 }
156 apds9960_interface_debug_print("apds9960: enable power on.\n");
157 res = apds9960_get_conf(&gs_handle, APDS9960_CONF_POWER_ON, &enable);
158 if (res != 0)
159 {
160 apds9960_interface_debug_print("apds9960: get conf failed.\n");
161 (void)apds9960_deinit(&gs_handle);
162
163 return 1;
164 }
165 apds9960_interface_debug_print("apds9960: check config %s.\n", enable == APDS9960_BOOL_TRUE ? "ok" : "error");
166
167 /* enable gesture */
169 if (res != 0)
170 {
171 apds9960_interface_debug_print("apds9960: set conf failed.\n");
172 (void)apds9960_deinit(&gs_handle);
173
174 return 1;
175 }
176 apds9960_interface_debug_print("apds9960: enable gesture.\n");
177 res = apds9960_get_conf(&gs_handle, APDS9960_CONF_GESTURE_ENABLE, &enable);
178 if (res != 0)
179 {
180 apds9960_interface_debug_print("apds9960: get conf failed.\n");
181 (void)apds9960_deinit(&gs_handle);
182
183 return 1;
184 }
185 apds9960_interface_debug_print("apds9960: check config %s.\n", enable == APDS9960_BOOL_TRUE ? "ok" : "error");
186
187 /* disable gesture */
189 if (res != 0)
190 {
191 apds9960_interface_debug_print("apds9960: set conf failed.\n");
192 (void)apds9960_deinit(&gs_handle);
193
194 return 1;
195 }
196 apds9960_interface_debug_print("apds9960: disable gesture.\n");
197 res = apds9960_get_conf(&gs_handle, APDS9960_CONF_GESTURE_ENABLE, &enable);
198 if (res != 0)
199 {
200 apds9960_interface_debug_print("apds9960: get conf failed.\n");
201 (void)apds9960_deinit(&gs_handle);
202
203 return 1;
204 }
205 apds9960_interface_debug_print("apds9960: check config %s.\n", enable == APDS9960_BOOL_FALSE ? "ok" : "error");
206
207 /* enable proximity interrupt */
209 if (res != 0)
210 {
211 apds9960_interface_debug_print("apds9960: set conf failed.\n");
212 (void)apds9960_deinit(&gs_handle);
213
214 return 1;
215 }
216 apds9960_interface_debug_print("apds9960: enable proximity interrupt.\n");
218 if (res != 0)
219 {
220 apds9960_interface_debug_print("apds9960: get conf failed.\n");
221 (void)apds9960_deinit(&gs_handle);
222
223 return 1;
224 }
225 apds9960_interface_debug_print("apds9960: check config %s.\n", enable == APDS9960_BOOL_TRUE ? "ok" : "error");
226
227 /* disable proximity interrupt */
229 if (res != 0)
230 {
231 apds9960_interface_debug_print("apds9960: set conf failed.\n");
232 (void)apds9960_deinit(&gs_handle);
233
234 return 1;
235 }
236 apds9960_interface_debug_print("apds9960: disable proximity interrupt.\n");
238 if (res != 0)
239 {
240 apds9960_interface_debug_print("apds9960: get conf failed.\n");
241 (void)apds9960_deinit(&gs_handle);
242
243 return 1;
244 }
245 apds9960_interface_debug_print("apds9960: check config %s.\n", enable == APDS9960_BOOL_FALSE ? "ok" : "error");
246
247 /* enable als interrupt */
249 if (res != 0)
250 {
251 apds9960_interface_debug_print("apds9960: set conf failed.\n");
252 (void)apds9960_deinit(&gs_handle);
253
254 return 1;
255 }
256 apds9960_interface_debug_print("apds9960: enable als interrupt.\n");
257 res = apds9960_get_conf(&gs_handle, APDS9960_CONF_ALS_INTERRUPT_ENABLE, &enable);
258 if (res != 0)
259 {
260 apds9960_interface_debug_print("apds9960: get conf failed.\n");
261 (void)apds9960_deinit(&gs_handle);
262
263 return 1;
264 }
265 apds9960_interface_debug_print("apds9960: check config %s.\n", enable == APDS9960_BOOL_TRUE ? "ok" : "error");
266
267 /* disable als interrupt */
269 if (res != 0)
270 {
271 apds9960_interface_debug_print("apds9960: set conf failed.\n");
272 (void)apds9960_deinit(&gs_handle);
273
274 return 1;
275 }
276 apds9960_interface_debug_print("apds9960: disable als interrupt.\n");
277 res = apds9960_get_conf(&gs_handle, APDS9960_CONF_ALS_INTERRUPT_ENABLE, &enable);
278 if (res != 0)
279 {
280 apds9960_interface_debug_print("apds9960: get conf failed.\n");
281 (void)apds9960_deinit(&gs_handle);
282
283 return 1;
284 }
285 apds9960_interface_debug_print("apds9960: check config %s.\n", enable == APDS9960_BOOL_FALSE ? "ok" : "error");
286
287 /* enable wait */
289 if (res != 0)
290 {
291 apds9960_interface_debug_print("apds9960: set conf failed.\n");
292 (void)apds9960_deinit(&gs_handle);
293
294 return 1;
295 }
296 apds9960_interface_debug_print("apds9960: enable wait.\n");
297 res = apds9960_get_conf(&gs_handle, APDS9960_CONF_WAIT_ENABLE, &enable);
298 if (res != 0)
299 {
300 apds9960_interface_debug_print("apds9960: get conf failed.\n");
301 (void)apds9960_deinit(&gs_handle);
302
303 return 1;
304 }
305 apds9960_interface_debug_print("apds9960: check config %s.\n", enable == APDS9960_BOOL_TRUE ? "ok" : "error");
306
307 /* disable wait */
309 if (res != 0)
310 {
311 apds9960_interface_debug_print("apds9960: set conf failed.\n");
312 (void)apds9960_deinit(&gs_handle);
313
314 return 1;
315 }
316 apds9960_interface_debug_print("apds9960: disable wait.\n");
317 res = apds9960_get_conf(&gs_handle, APDS9960_CONF_WAIT_ENABLE, &enable);
318 if (res != 0)
319 {
320 apds9960_interface_debug_print("apds9960: get conf failed.\n");
321 (void)apds9960_deinit(&gs_handle);
322
323 return 1;
324 }
325 apds9960_interface_debug_print("apds9960: check config %s.\n", enable == APDS9960_BOOL_FALSE ? "ok" : "error");
326
327 /* enable proximity detect */
329 if (res != 0)
330 {
331 apds9960_interface_debug_print("apds9960: set conf failed.\n");
332 (void)apds9960_deinit(&gs_handle);
333
334 return 1;
335 }
336 apds9960_interface_debug_print("apds9960: enable proximity detect.\n");
338 if (res != 0)
339 {
340 apds9960_interface_debug_print("apds9960: get conf failed.\n");
341 (void)apds9960_deinit(&gs_handle);
342
343 return 1;
344 }
345 apds9960_interface_debug_print("apds9960: check config %s.\n", enable == APDS9960_BOOL_TRUE ? "ok" : "error");
346
347 /* disable proximity detect */
349 if (res != 0)
350 {
351 apds9960_interface_debug_print("apds9960: set conf failed.\n");
352 (void)apds9960_deinit(&gs_handle);
353
354 return 1;
355 }
356 apds9960_interface_debug_print("apds9960: disable proximity detect.\n");
358 if (res != 0)
359 {
360 apds9960_interface_debug_print("apds9960: get conf failed.\n");
361 (void)apds9960_deinit(&gs_handle);
362
363 return 1;
364 }
365 apds9960_interface_debug_print("apds9960: check config %s.\n", enable == APDS9960_BOOL_FALSE ? "ok" : "error");
366
367 /* enable als */
369 if (res != 0)
370 {
371 apds9960_interface_debug_print("apds9960: set conf failed.\n");
372 (void)apds9960_deinit(&gs_handle);
373
374 return 1;
375 }
376 apds9960_interface_debug_print("apds9960: enable als.\n");
377 res = apds9960_get_conf(&gs_handle, APDS9960_CONF_ALS_ENABLE, &enable);
378 if (res != 0)
379 {
380 apds9960_interface_debug_print("apds9960: get conf failed.\n");
381 (void)apds9960_deinit(&gs_handle);
382
383 return 1;
384 }
385 apds9960_interface_debug_print("apds9960: check config %s.\n", enable == APDS9960_BOOL_TRUE ? "ok" : "error");
386
387 /* disable als */
389 if (res != 0)
390 {
391 apds9960_interface_debug_print("apds9960: set conf failed.\n");
392 (void)apds9960_deinit(&gs_handle);
393
394 return 1;
395 }
396 apds9960_interface_debug_print("apds9960: disable als.\n");
397 res = apds9960_get_conf(&gs_handle, APDS9960_CONF_ALS_ENABLE, &enable);
398 if (res != 0)
399 {
400 apds9960_interface_debug_print("apds9960: get conf failed.\n");
401 (void)apds9960_deinit(&gs_handle);
402
403 return 1;
404 }
405 apds9960_interface_debug_print("apds9960: check config %s.\n", enable == APDS9960_BOOL_FALSE ? "ok" : "error");
406
407 /* apds9960_set_adc_integration_time/apds9960_get_adc_integration_time test */
408 apds9960_interface_debug_print("apds9960: apds9960_set_adc_integration_time/apds9960_get_adc_integration_time test.\n");
409
410 integration_time = rand() % 256;
411 res = apds9960_set_adc_integration_time(&gs_handle, integration_time);
412 if (res != 0)
413 {
414 apds9960_interface_debug_print("apds9960: set adc integration time failed.\n");
415 (void)apds9960_deinit(&gs_handle);
416
417 return 1;
418 }
419 apds9960_interface_debug_print("apds9960: set adc integration time 0x%02X.\n", integration_time);
420 res = apds9960_get_adc_integration_time(&gs_handle, (uint8_t *)&integration_time_check);
421 if (res != 0)
422 {
423 apds9960_interface_debug_print("apds9960: get adc integration time failed.\n");
424 (void)apds9960_deinit(&gs_handle);
425
426 return 1;
427 }
428 apds9960_interface_debug_print("apds9960: check adc integration time %s.\n", integration_time == integration_time_check ? "ok" : "error");
429
430 /* apds9960_set_wait_time/apds9960_get_wait_time test */
431 apds9960_interface_debug_print("apds9960: apds9960_set_wait_time/apds9960_get_wait_time test.\n");
432
433 wait_time = rand() % 256;
434 res = apds9960_set_wait_time(&gs_handle, wait_time);
435 if (res != 0)
436 {
437 apds9960_interface_debug_print("apds9960: set wait time failed.\n");
438 (void)apds9960_deinit(&gs_handle);
439
440 return 1;
441 }
442 apds9960_interface_debug_print("apds9960: set wait time 0x%02X.\n", wait_time);
443 res = apds9960_get_wait_time(&gs_handle, (uint8_t *)&wait_time_check);
444 if (res != 0)
445 {
446 apds9960_interface_debug_print("apds9960: get wait time failed.\n");
447 (void)apds9960_deinit(&gs_handle);
448
449 return 1;
450 }
451 apds9960_interface_debug_print("apds9960: check wait time %s.\n", wait_time == wait_time_check ? "ok" : "error");
452
453 /* apds9960_set_als_interrupt_low_threshold/apds9960_get_als_interrupt_low_threshold test */
454 apds9960_interface_debug_print("apds9960: apds9960_set_als_interrupt_low_threshold/apds9960_get_als_interrupt_low_threshold test.\n");
455
456 threshold = rand() % 65536;
457 res = apds9960_set_als_interrupt_low_threshold(&gs_handle, threshold);
458 if (res != 0)
459 {
460 apds9960_interface_debug_print("apds9960: set als interrupt low threshold failed.\n");
461 (void)apds9960_deinit(&gs_handle);
462
463 return 1;
464 }
465 apds9960_interface_debug_print("apds9960: set als interrupt low threshold 0x%04X.\n", threshold);
466 res = apds9960_get_als_interrupt_low_threshold(&gs_handle, (uint16_t *)&threshold_check);
467 if (res != 0)
468 {
469 apds9960_interface_debug_print("apds9960: get als interrupt low threshold failed.\n");
470 (void)apds9960_deinit(&gs_handle);
471
472 return 1;
473 }
474 apds9960_interface_debug_print("apds9960: check als interrupt low threshold %s.\n", threshold == threshold_check ? "ok" : "error");
475
476 /* apds9960_set_als_interrupt_high_threshold/apds9960_get_als_interrupt_high_threshold test */
477 apds9960_interface_debug_print("apds9960: apds9960_set_als_interrupt_high_threshold/apds9960_get_als_interrupt_high_threshold test.\n");
478
479 threshold = rand() % 65536;
480 res = apds9960_set_als_interrupt_high_threshold(&gs_handle, threshold);
481 if (res != 0)
482 {
483 apds9960_interface_debug_print("apds9960: set als interrupt high threshold failed.\n");
484 (void)apds9960_deinit(&gs_handle);
485
486 return 1;
487 }
488 apds9960_interface_debug_print("apds9960: set als interrupt high threshold 0x%04X.\n", threshold);
489 res = apds9960_get_als_interrupt_high_threshold(&gs_handle, (uint16_t *)&threshold_check);
490 if (res != 0)
491 {
492 apds9960_interface_debug_print("apds9960: get als interrupt high threshold failed.\n");
493 (void)apds9960_deinit(&gs_handle);
494
495 return 1;
496 }
497 apds9960_interface_debug_print("apds9960: check als interrupt high threshold %s.\n", threshold == threshold_check ? "ok" : "error");
498
499 /* apds9960_set_proximity_interrupt_low_threshold/apds9960_get_proximity_interrupt_low_threshold test */
500 apds9960_interface_debug_print("apds9960: apds9960_set_proximity_interrupt_low_threshold/apds9960_get_proximity_interrupt_low_threshold test.\n");
501
502 reg = rand() % 256;
504 if (res != 0)
505 {
506 apds9960_interface_debug_print("apds9960: set proximity interrupt low threshold failed.\n");
507 (void)apds9960_deinit(&gs_handle);
508
509 return 1;
510 }
511 apds9960_interface_debug_print("apds9960: set proximity interrupt low threshold 0x%02X.\n", reg);
512 res = apds9960_get_proximity_interrupt_low_threshold(&gs_handle, (uint8_t *)&reg_check);
513 if (res != 0)
514 {
515 apds9960_interface_debug_print("apds9960: get proximity interrupt low threshold failed.\n");
516 (void)apds9960_deinit(&gs_handle);
517
518 return 1;
519 }
520 apds9960_interface_debug_print("apds9960: check proximity interrupt low threshold %s.\n", reg_check == reg ? "ok" : "error");
521
522 /* apds9960_set_proximity_interrupt_high_threshold/apds9960_get_proximity_interrupt_high_threshold test */
523 apds9960_interface_debug_print("apds9960: apds9960_set_proximity_interrupt_high_threshold/apds9960_get_proximity_interrupt_high_threshold test.\n");
524
525 reg = rand() % 256;
527 if (res != 0)
528 {
529 apds9960_interface_debug_print("apds9960: set proximity interrupt high threshold failed.\n");
530 (void)apds9960_deinit(&gs_handle);
531
532 return 1;
533 }
534 apds9960_interface_debug_print("apds9960: set proximity interrupt high threshold 0x%02X.\n", reg);
535 res = apds9960_get_proximity_interrupt_high_threshold(&gs_handle, (uint8_t *)&reg_check);
536 if (res != 0)
537 {
538 apds9960_interface_debug_print("apds9960: get proximity interrupt high threshold failed.\n");
539 (void)apds9960_deinit(&gs_handle);
540
541 return 1;
542 }
543 apds9960_interface_debug_print("apds9960: check proximity interrupt high threshold %s.\n", reg_check == reg ? "ok" : "error");
544
545 /* apds9960_set_proximity_interrupt_cycle/apds9960_get_proximity_interrupt_cycle test */
546 apds9960_interface_debug_print("apds9960: apds9960_set_proximity_interrupt_cycle/apds9960_get_proximity_interrupt_cycle test.\n");
547
548 /* set proximity interrupt every cycle */
550 if (res != 0)
551 {
552 apds9960_interface_debug_print("apds9960: set proximity interrupt cycle failed.\n");
553 (void)apds9960_deinit(&gs_handle);
554
555 return 1;
556 }
557 apds9960_interface_debug_print("apds9960: set proximity interrupt every cycle.\n");
558 res = apds9960_get_proximity_interrupt_cycle(&gs_handle, &cycle);
559 if (res != 0)
560 {
561 apds9960_interface_debug_print("apds9960: get proximity interrupt cycle failed.\n");
562 (void)apds9960_deinit(&gs_handle);
563
564 return 1;
565 }
566 apds9960_interface_debug_print("apds9960: check proximity interrupt cycle %s.\n", cycle == APDS9960_PROXIMITY_INTERRUPT_CYCLE_EVERY ? "ok" : "error");
567
568 /* set proximity interrupt any cycle */
570 if (res != 0)
571 {
572 apds9960_interface_debug_print("apds9960: set proximity interrupt cycle failed.\n");
573 (void)apds9960_deinit(&gs_handle);
574
575 return 1;
576 }
577 apds9960_interface_debug_print("apds9960: set proximity interrupt any cycle.\n");
578 res = apds9960_get_proximity_interrupt_cycle(&gs_handle, &cycle);
579 if (res != 0)
580 {
581 apds9960_interface_debug_print("apds9960: get proximity interrupt cycle failed.\n");
582 (void)apds9960_deinit(&gs_handle);
583
584 return 1;
585 }
586 apds9960_interface_debug_print("apds9960: check proximity interrupt cycle %s.\n", cycle == APDS9960_PROXIMITY_INTERRUPT_CYCLE_ANY ? "ok" : "error");
587
588 /* set proximity interrupt 2 cycle */
590 if (res != 0)
591 {
592 apds9960_interface_debug_print("apds9960: set proximity interrupt cycle failed.\n");
593 (void)apds9960_deinit(&gs_handle);
594
595 return 1;
596 }
597 apds9960_interface_debug_print("apds9960: set proximity interrupt 2 cycle.\n");
598 res = apds9960_get_proximity_interrupt_cycle(&gs_handle, &cycle);
599 if (res != 0)
600 {
601 apds9960_interface_debug_print("apds9960: get proximity interrupt cycle failed.\n");
602 (void)apds9960_deinit(&gs_handle);
603
604 return 1;
605 }
606 apds9960_interface_debug_print("apds9960: check proximity interrupt cycle %s.\n", cycle == APDS9960_PROXIMITY_INTERRUPT_CYCLE_2 ? "ok" : "error");
607
608 /* set proximity interrupt 3 cycle */
610 if (res != 0)
611 {
612 apds9960_interface_debug_print("apds9960: set proximity interrupt cycle failed.\n");
613 (void)apds9960_deinit(&gs_handle);
614
615 return 1;
616 }
617 apds9960_interface_debug_print("apds9960: set proximity interrupt 3 cycle.\n");
618 res = apds9960_get_proximity_interrupt_cycle(&gs_handle, &cycle);
619 if (res != 0)
620 {
621 apds9960_interface_debug_print("apds9960: get proximity interrupt cycle failed.\n");
622 (void)apds9960_deinit(&gs_handle);
623
624 return 1;
625 }
626 apds9960_interface_debug_print("apds9960: check proximity interrupt cycle %s.\n", cycle == APDS9960_PROXIMITY_INTERRUPT_CYCLE_3 ? "ok" : "error");
627
628 /* set proximity interrupt 4 cycle */
630 if (res != 0)
631 {
632 apds9960_interface_debug_print("apds9960: set proximity interrupt cycle failed.\n");
633 (void)apds9960_deinit(&gs_handle);
634
635 return 1;
636 }
637 apds9960_interface_debug_print("apds9960: set proximity interrupt 4 cycle.\n");
638 res = apds9960_get_proximity_interrupt_cycle(&gs_handle, &cycle);
639 if (res != 0)
640 {
641 apds9960_interface_debug_print("apds9960: get proximity interrupt cycle failed.\n");
642 (void)apds9960_deinit(&gs_handle);
643
644 return 1;
645 }
646 apds9960_interface_debug_print("apds9960: check proximity interrupt cycle %s.\n", cycle == APDS9960_PROXIMITY_INTERRUPT_CYCLE_4 ? "ok" : "error");
647
648 /* set proximity interrupt 5 cycle */
650 if (res != 0)
651 {
652 apds9960_interface_debug_print("apds9960: set proximity interrupt cycle failed.\n");
653 (void)apds9960_deinit(&gs_handle);
654
655 return 1;
656 }
657 apds9960_interface_debug_print("apds9960: set proximity interrupt 5 cycle.\n");
658 res = apds9960_get_proximity_interrupt_cycle(&gs_handle, &cycle);
659 if (res != 0)
660 {
661 apds9960_interface_debug_print("apds9960: get proximity interrupt cycle failed.\n");
662 (void)apds9960_deinit(&gs_handle);
663
664 return 1;
665 }
666 apds9960_interface_debug_print("apds9960: check proximity interrupt cycle %s.\n", cycle == APDS9960_PROXIMITY_INTERRUPT_CYCLE_5 ? "ok" : "error");
667
668 /* set proximity interrupt 6 cycle */
670 if (res != 0)
671 {
672 apds9960_interface_debug_print("apds9960: set proximity interrupt cycle failed.\n");
673 (void)apds9960_deinit(&gs_handle);
674
675 return 1;
676 }
677 apds9960_interface_debug_print("apds9960: set proximity interrupt 6 cycle.\n");
678 res = apds9960_get_proximity_interrupt_cycle(&gs_handle, &cycle);
679 if (res != 0)
680 {
681 apds9960_interface_debug_print("apds9960: get proximity interrupt cycle failed.\n");
682 (void)apds9960_deinit(&gs_handle);
683
684 return 1;
685 }
686 apds9960_interface_debug_print("apds9960: check proximity interrupt cycle %s.\n", cycle == APDS9960_PROXIMITY_INTERRUPT_CYCLE_6 ? "ok" : "error");
687
688 /* set proximity interrupt 7 cycle */
690 if (res != 0)
691 {
692 apds9960_interface_debug_print("apds9960: set proximity interrupt cycle failed.\n");
693 (void)apds9960_deinit(&gs_handle);
694
695 return 1;
696 }
697 apds9960_interface_debug_print("apds9960: set proximity interrupt 7 cycle.\n");
698 res = apds9960_get_proximity_interrupt_cycle(&gs_handle, &cycle);
699 if (res != 0)
700 {
701 apds9960_interface_debug_print("apds9960: get proximity interrupt cycle failed.\n");
702 (void)apds9960_deinit(&gs_handle);
703
704 return 1;
705 }
706 apds9960_interface_debug_print("apds9960: check proximity interrupt cycle %s.\n", cycle == APDS9960_PROXIMITY_INTERRUPT_CYCLE_7 ? "ok" : "error");
707
708 /* set proximity interrupt 8 cycle */
710 if (res != 0)
711 {
712 apds9960_interface_debug_print("apds9960: set proximity interrupt cycle failed.\n");
713 (void)apds9960_deinit(&gs_handle);
714
715 return 1;
716 }
717 apds9960_interface_debug_print("apds9960: set proximity interrupt 8 cycle.\n");
718 res = apds9960_get_proximity_interrupt_cycle(&gs_handle, &cycle);
719 if (res != 0)
720 {
721 apds9960_interface_debug_print("apds9960: get proximity interrupt cycle failed.\n");
722 (void)apds9960_deinit(&gs_handle);
723
724 return 1;
725 }
726 apds9960_interface_debug_print("apds9960: check proximity interrupt cycle %s.\n", cycle == APDS9960_PROXIMITY_INTERRUPT_CYCLE_8 ? "ok" : "error");
727
728 /* set proximity interrupt 9 cycle */
730 if (res != 0)
731 {
732 apds9960_interface_debug_print("apds9960: set proximity interrupt cycle failed.\n");
733 (void)apds9960_deinit(&gs_handle);
734
735 return 1;
736 }
737 apds9960_interface_debug_print("apds9960: set proximity interrupt 9 cycle.\n");
738 res = apds9960_get_proximity_interrupt_cycle(&gs_handle, &cycle);
739 if (res != 0)
740 {
741 apds9960_interface_debug_print("apds9960: get proximity interrupt cycle failed.\n");
742 (void)apds9960_deinit(&gs_handle);
743
744 return 1;
745 }
746 apds9960_interface_debug_print("apds9960: check proximity interrupt cycle %s.\n", cycle == APDS9960_PROXIMITY_INTERRUPT_CYCLE_9 ? "ok" : "error");
747
748 /* set proximity interrupt 10 cycle */
750 if (res != 0)
751 {
752 apds9960_interface_debug_print("apds9960: set proximity interrupt cycle failed.\n");
753 (void)apds9960_deinit(&gs_handle);
754
755 return 1;
756 }
757 apds9960_interface_debug_print("apds9960: set proximity interrupt 10 cycle.\n");
758 res = apds9960_get_proximity_interrupt_cycle(&gs_handle, &cycle);
759 if (res != 0)
760 {
761 apds9960_interface_debug_print("apds9960: get proximity interrupt cycle failed.\n");
762 (void)apds9960_deinit(&gs_handle);
763
764 return 1;
765 }
766 apds9960_interface_debug_print("apds9960: check proximity interrupt cycle %s.\n", cycle == APDS9960_PROXIMITY_INTERRUPT_CYCLE_10 ? "ok" : "error");
767
768 /* set proximity interrupt 11 cycle */
770 if (res != 0)
771 {
772 apds9960_interface_debug_print("apds9960: set proximity interrupt cycle failed.\n");
773 (void)apds9960_deinit(&gs_handle);
774
775 return 1;
776 }
777 apds9960_interface_debug_print("apds9960: set proximity interrupt 11 cycle.\n");
778 res = apds9960_get_proximity_interrupt_cycle(&gs_handle, &cycle);
779 if (res != 0)
780 {
781 apds9960_interface_debug_print("apds9960: get proximity interrupt cycle failed.\n");
782 (void)apds9960_deinit(&gs_handle);
783
784 return 1;
785 }
786 apds9960_interface_debug_print("apds9960: check proximity interrupt cycle %s.\n", cycle == APDS9960_PROXIMITY_INTERRUPT_CYCLE_11 ? "ok" : "error");
787
788 /* set proximity interrupt 12 cycle */
790 if (res != 0)
791 {
792 apds9960_interface_debug_print("apds9960: set proximity interrupt cycle failed.\n");
793 (void)apds9960_deinit(&gs_handle);
794
795 return 1;
796 }
797 apds9960_interface_debug_print("apds9960: set proximity interrupt 12 cycle.\n");
798 res = apds9960_get_proximity_interrupt_cycle(&gs_handle, &cycle);
799 if (res != 0)
800 {
801 apds9960_interface_debug_print("apds9960: get proximity interrupt cycle failed.\n");
802 (void)apds9960_deinit(&gs_handle);
803
804 return 1;
805 }
806 apds9960_interface_debug_print("apds9960: check proximity interrupt cycle %s.\n", cycle == APDS9960_PROXIMITY_INTERRUPT_CYCLE_12 ? "ok" : "error");
807
808 /* set proximity interrupt 13 cycle */
810 if (res != 0)
811 {
812 apds9960_interface_debug_print("apds9960: set proximity interrupt cycle failed.\n");
813 (void)apds9960_deinit(&gs_handle);
814
815 return 1;
816 }
817 apds9960_interface_debug_print("apds9960: set proximity interrupt 13 cycle.\n");
818 res = apds9960_get_proximity_interrupt_cycle(&gs_handle, &cycle);
819 if (res != 0)
820 {
821 apds9960_interface_debug_print("apds9960: get proximity interrupt cycle failed.\n");
822 (void)apds9960_deinit(&gs_handle);
823
824 return 1;
825 }
826 apds9960_interface_debug_print("apds9960: check proximity interrupt cycle %s.\n", cycle == APDS9960_PROXIMITY_INTERRUPT_CYCLE_13 ? "ok" : "error");
827
828 /* set proximity interrupt 14 cycle */
830 if (res != 0)
831 {
832 apds9960_interface_debug_print("apds9960: set proximity interrupt cycle failed.\n");
833 (void)apds9960_deinit(&gs_handle);
834
835 return 1;
836 }
837 apds9960_interface_debug_print("apds9960: set proximity interrupt 14 cycle.\n");
838 res = apds9960_get_proximity_interrupt_cycle(&gs_handle, &cycle);
839 if (res != 0)
840 {
841 apds9960_interface_debug_print("apds9960: get proximity interrupt cycle failed.\n");
842 (void)apds9960_deinit(&gs_handle);
843
844 return 1;
845 }
846 apds9960_interface_debug_print("apds9960: check proximity interrupt cycle %s.\n", cycle == APDS9960_PROXIMITY_INTERRUPT_CYCLE_14 ? "ok" : "error");
847
848 /* set proximity interrupt 15 cycle */
850 if (res != 0)
851 {
852 apds9960_interface_debug_print("apds9960: set proximity interrupt cycle failed.\n");
853 (void)apds9960_deinit(&gs_handle);
854
855 return 1;
856 }
857 apds9960_interface_debug_print("apds9960: set proximity interrupt 15 cycle.\n");
858 res = apds9960_get_proximity_interrupt_cycle(&gs_handle, &cycle);
859 if (res != 0)
860 {
861 apds9960_interface_debug_print("apds9960: get proximity interrupt cycle failed.\n");
862 (void)apds9960_deinit(&gs_handle);
863
864 return 1;
865 }
866 apds9960_interface_debug_print("apds9960: check proximity interrupt cycle %s.\n", cycle == APDS9960_PROXIMITY_INTERRUPT_CYCLE_15 ? "ok" : "error");
867
868 /* apds9960_set_als_interrupt_cycle/apds9960_get_als_interrupt_cycle test */
869 apds9960_interface_debug_print("apds9960: apds9960_set_als_interrupt_cycle/apds9960_get_als_interrupt_cycle test.\n");
870
871 /* every als cycle */
873 if (res != 0)
874 {
875 apds9960_interface_debug_print("apds9960: set als interrupt cycle failed.\n");
876 (void)apds9960_deinit(&gs_handle);
877
878 return 1;
879 }
880 apds9960_interface_debug_print("apds9960: set als interrupt every cycle.\n");
881 res = apds9960_get_als_interrupt_cycle(&gs_handle, &als_cycle);
882 if (res != 0)
883 {
884 apds9960_interface_debug_print("apds9960: get als interrupt cycle failed.\n");
885 (void)apds9960_deinit(&gs_handle);
886
887 return 1;
888 }
889 apds9960_interface_debug_print("apds9960: check als interrupt cycle %s.\n", als_cycle == APDS9960_ALS_INTERRUPT_CYCLE_EVERY ? "ok" : "error");
890
891 /* als any cycle */
893 if (res != 0)
894 {
895 apds9960_interface_debug_print("apds9960: set als interrupt cycle failed.\n");
896 (void)apds9960_deinit(&gs_handle);
897
898 return 1;
899 }
900 apds9960_interface_debug_print("apds9960: set als interrupt any cycle.\n");
901 res = apds9960_get_als_interrupt_cycle(&gs_handle, &als_cycle);
902 if (res != 0)
903 {
904 apds9960_interface_debug_print("apds9960: get als interrupt cycle failed.\n");
905 (void)apds9960_deinit(&gs_handle);
906
907 return 1;
908 }
909 apds9960_interface_debug_print("apds9960: check als interrupt cycle %s.\n", als_cycle == APDS9960_ALS_INTERRUPT_CYCLE_ANY ? "ok" : "error");
910
911 /* als 2 cycle */
913 if (res != 0)
914 {
915 apds9960_interface_debug_print("apds9960: set als interrupt cycle failed.\n");
916 (void)apds9960_deinit(&gs_handle);
917
918 return 1;
919 }
920 apds9960_interface_debug_print("apds9960: set als interrupt 2 cycle.\n");
921 res = apds9960_get_als_interrupt_cycle(&gs_handle, &als_cycle);
922 if (res != 0)
923 {
924 apds9960_interface_debug_print("apds9960: get als interrupt cycle failed.\n");
925 (void)apds9960_deinit(&gs_handle);
926
927 return 1;
928 }
929 apds9960_interface_debug_print("apds9960: check als interrupt cycle %s.\n", als_cycle == APDS9960_ALS_INTERRUPT_CYCLE_2 ? "ok" : "error");
930
931 /* als 3 cycle */
933 if (res != 0)
934 {
935 apds9960_interface_debug_print("apds9960: set als interrupt cycle failed.\n");
936 (void)apds9960_deinit(&gs_handle);
937
938 return 1;
939 }
940 apds9960_interface_debug_print("apds9960: set als interrupt 3 cycle.\n");
941 res = apds9960_get_als_interrupt_cycle(&gs_handle, &als_cycle);
942 if (res != 0)
943 {
944 apds9960_interface_debug_print("apds9960: get als interrupt cycle failed.\n");
945 (void)apds9960_deinit(&gs_handle);
946
947 return 1;
948 }
949 apds9960_interface_debug_print("apds9960: check als interrupt cycle %s.\n", als_cycle == APDS9960_ALS_INTERRUPT_CYCLE_3 ? "ok" : "error");
950
951 /* als 5 cycle */
953 if (res != 0)
954 {
955 apds9960_interface_debug_print("apds9960: set als interrupt cycle failed.\n");
956 (void)apds9960_deinit(&gs_handle);
957
958 return 1;
959 }
960 apds9960_interface_debug_print("apds9960: set als interrupt 5 cycle.\n");
961 res = apds9960_get_als_interrupt_cycle(&gs_handle, &als_cycle);
962 if (res != 0)
963 {
964 apds9960_interface_debug_print("apds9960: get als interrupt cycle failed.\n");
965 (void)apds9960_deinit(&gs_handle);
966
967 return 1;
968 }
969 apds9960_interface_debug_print("apds9960: check als interrupt cycle %s.\n", als_cycle == APDS9960_ALS_INTERRUPT_CYCLE_5 ? "ok" : "error");
970
971 /* als 10 cycle */
973 if (res != 0)
974 {
975 apds9960_interface_debug_print("apds9960: set als interrupt cycle failed.\n");
976 (void)apds9960_deinit(&gs_handle);
977
978 return 1;
979 }
980 apds9960_interface_debug_print("apds9960: set als interrupt 10 cycle.\n");
981 res = apds9960_get_als_interrupt_cycle(&gs_handle, &als_cycle);
982 if (res != 0)
983 {
984 apds9960_interface_debug_print("apds9960: get als interrupt cycle failed.\n");
985 (void)apds9960_deinit(&gs_handle);
986
987 return 1;
988 }
989 apds9960_interface_debug_print("apds9960: check als interrupt cycle %s.\n", als_cycle == APDS9960_ALS_INTERRUPT_CYCLE_10 ? "ok" : "error");
990
991 /* als 15 cycle */
993 if (res != 0)
994 {
995 apds9960_interface_debug_print("apds9960: set als interrupt cycle failed.\n");
996 (void)apds9960_deinit(&gs_handle);
997
998 return 1;
999 }
1000 apds9960_interface_debug_print("apds9960: set als interrupt 15 cycle.\n");
1001 res = apds9960_get_als_interrupt_cycle(&gs_handle, &als_cycle);
1002 if (res != 0)
1003 {
1004 apds9960_interface_debug_print("apds9960: get als interrupt cycle failed.\n");
1005 (void)apds9960_deinit(&gs_handle);
1006
1007 return 1;
1008 }
1009 apds9960_interface_debug_print("apds9960: check als interrupt cycle %s.\n", als_cycle == APDS9960_ALS_INTERRUPT_CYCLE_15 ? "ok" : "error");
1010
1011 /* als 20 cycle */
1013 if (res != 0)
1014 {
1015 apds9960_interface_debug_print("apds9960: set als interrupt cycle failed.\n");
1016 (void)apds9960_deinit(&gs_handle);
1017
1018 return 1;
1019 }
1020 apds9960_interface_debug_print("apds9960: set als interrupt 20 cycle.\n");
1021 res = apds9960_get_als_interrupt_cycle(&gs_handle, &als_cycle);
1022 if (res != 0)
1023 {
1024 apds9960_interface_debug_print("apds9960: get als interrupt cycle failed.\n");
1025 (void)apds9960_deinit(&gs_handle);
1026
1027 return 1;
1028 }
1029 apds9960_interface_debug_print("apds9960: check als interrupt cycle %s.\n", als_cycle == APDS9960_ALS_INTERRUPT_CYCLE_20 ? "ok" : "error");
1030
1031 /* als 25 cycle */
1033 if (res != 0)
1034 {
1035 apds9960_interface_debug_print("apds9960: set als interrupt cycle failed.\n");
1036 (void)apds9960_deinit(&gs_handle);
1037
1038 return 1;
1039 }
1040 apds9960_interface_debug_print("apds9960: set als interrupt 25 cycle.\n");
1041 res = apds9960_get_als_interrupt_cycle(&gs_handle, &als_cycle);
1042 if (res != 0)
1043 {
1044 apds9960_interface_debug_print("apds9960: get als interrupt cycle failed.\n");
1045 (void)apds9960_deinit(&gs_handle);
1046
1047 return 1;
1048 }
1049 apds9960_interface_debug_print("apds9960: check als interrupt cycle %s.\n", als_cycle == APDS9960_ALS_INTERRUPT_CYCLE_25 ? "ok" : "error");
1050
1051 /* als 30 cycle */
1053 if (res != 0)
1054 {
1055 apds9960_interface_debug_print("apds9960: set als interrupt cycle failed.\n");
1056 (void)apds9960_deinit(&gs_handle);
1057
1058 return 1;
1059 }
1060 apds9960_interface_debug_print("apds9960: set als interrupt 30 cycle.\n");
1061 res = apds9960_get_als_interrupt_cycle(&gs_handle, &als_cycle);
1062 if (res != 0)
1063 {
1064 apds9960_interface_debug_print("apds9960: get als interrupt cycle failed.\n");
1065 (void)apds9960_deinit(&gs_handle);
1066
1067 return 1;
1068 }
1069 apds9960_interface_debug_print("apds9960: check als interrupt cycle %s.\n", als_cycle == APDS9960_ALS_INTERRUPT_CYCLE_30 ? "ok" : "error");
1070
1071 /* als 35 cycle */
1073 if (res != 0)
1074 {
1075 apds9960_interface_debug_print("apds9960: set als interrupt cycle failed.\n");
1076 (void)apds9960_deinit(&gs_handle);
1077
1078 return 1;
1079 }
1080 apds9960_interface_debug_print("apds9960: set als interrupt 35 cycle.\n");
1081 res = apds9960_get_als_interrupt_cycle(&gs_handle, &als_cycle);
1082 if (res != 0)
1083 {
1084 apds9960_interface_debug_print("apds9960: get als interrupt cycle failed.\n");
1085 (void)apds9960_deinit(&gs_handle);
1086
1087 return 1;
1088 }
1089 apds9960_interface_debug_print("apds9960: check als interrupt cycle %s.\n", als_cycle == APDS9960_ALS_INTERRUPT_CYCLE_35 ? "ok" : "error");
1090
1091 /* als 40 cycle */
1093 if (res != 0)
1094 {
1095 apds9960_interface_debug_print("apds9960: set als interrupt cycle failed.\n");
1096 (void)apds9960_deinit(&gs_handle);
1097
1098 return 1;
1099 }
1100 apds9960_interface_debug_print("apds9960: set als interrupt 40 cycle.\n");
1101 res = apds9960_get_als_interrupt_cycle(&gs_handle, &als_cycle);
1102 if (res != 0)
1103 {
1104 apds9960_interface_debug_print("apds9960: get als interrupt cycle failed.\n");
1105 (void)apds9960_deinit(&gs_handle);
1106
1107 return 1;
1108 }
1109 apds9960_interface_debug_print("apds9960: check als interrupt cycle %s.\n", als_cycle == APDS9960_ALS_INTERRUPT_CYCLE_40 ? "ok" : "error");
1110
1111 /* als 45 cycle */
1113 if (res != 0)
1114 {
1115 apds9960_interface_debug_print("apds9960: set als interrupt cycle failed.\n");
1116 (void)apds9960_deinit(&gs_handle);
1117
1118 return 1;
1119 }
1120 apds9960_interface_debug_print("apds9960: set als interrupt 45 cycle.\n");
1121 res = apds9960_get_als_interrupt_cycle(&gs_handle, &als_cycle);
1122 if (res != 0)
1123 {
1124 apds9960_interface_debug_print("apds9960: get als interrupt cycle failed.\n");
1125 (void)apds9960_deinit(&gs_handle);
1126
1127 return 1;
1128 }
1129 apds9960_interface_debug_print("apds9960: check als interrupt cycle %s.\n", als_cycle == APDS9960_ALS_INTERRUPT_CYCLE_45 ? "ok" : "error");
1130
1131 /* als 50 cycle */
1133 if (res != 0)
1134 {
1135 apds9960_interface_debug_print("apds9960: set als interrupt cycle failed.\n");
1136 (void)apds9960_deinit(&gs_handle);
1137
1138 return 1;
1139 }
1140 apds9960_interface_debug_print("apds9960: set als interrupt 50 cycle.\n");
1141 res = apds9960_get_als_interrupt_cycle(&gs_handle, &als_cycle);
1142 if (res != 0)
1143 {
1144 apds9960_interface_debug_print("apds9960: get als interrupt cycle failed.\n");
1145 (void)apds9960_deinit(&gs_handle);
1146
1147 return 1;
1148 }
1149 apds9960_interface_debug_print("apds9960: check als interrupt cycle %s.\n", als_cycle == APDS9960_ALS_INTERRUPT_CYCLE_50 ? "ok" : "error");
1150
1151 /* als 55 cycle */
1153 if (res != 0)
1154 {
1155 apds9960_interface_debug_print("apds9960: set als interrupt cycle failed.\n");
1156 (void)apds9960_deinit(&gs_handle);
1157
1158 return 1;
1159 }
1160 apds9960_interface_debug_print("apds9960: set als interrupt 55 cycle.\n");
1161 res = apds9960_get_als_interrupt_cycle(&gs_handle, &als_cycle);
1162 if (res != 0)
1163 {
1164 apds9960_interface_debug_print("apds9960: get als interrupt cycle failed.\n");
1165 (void)apds9960_deinit(&gs_handle);
1166
1167 return 1;
1168 }
1169 apds9960_interface_debug_print("apds9960: check als interrupt cycle %s.\n", als_cycle == APDS9960_ALS_INTERRUPT_CYCLE_55 ? "ok" : "error");
1170
1171 /* als 60 cycle */
1173 if (res != 0)
1174 {
1175 apds9960_interface_debug_print("apds9960: set als interrupt cycle failed.\n");
1176 (void)apds9960_deinit(&gs_handle);
1177
1178 return 1;
1179 }
1180 apds9960_interface_debug_print("apds9960: set als interrupt 60 cycle.\n");
1181 res = apds9960_get_als_interrupt_cycle(&gs_handle, &als_cycle);
1182 if (res != 0)
1183 {
1184 apds9960_interface_debug_print("apds9960: get als interrupt cycle failed.\n");
1185 (void)apds9960_deinit(&gs_handle);
1186
1187 return 1;
1188 }
1189 apds9960_interface_debug_print("apds9960: check als interrupt cycle %s.\n", als_cycle == APDS9960_ALS_INTERRUPT_CYCLE_60 ? "ok" : "error");
1190
1191 /* apds9960_set_wait_long/apds9960_get_wait_long test */
1192 apds9960_interface_debug_print("apds9960: apds9960_set_wait_long/apds9960_get_wait_long test.\n");
1193
1194 /* enable wait long */
1195 res = apds9960_set_wait_long(&gs_handle, APDS9960_BOOL_TRUE);
1196 if (res != 0)
1197 {
1198 apds9960_interface_debug_print("apds9960: set wait long failed.\n");
1199 (void)apds9960_deinit(&gs_handle);
1200
1201 return 1;
1202 }
1203 apds9960_interface_debug_print("apds9960: enable wait long.\n");
1204 res = apds9960_get_wait_long(&gs_handle, &enable);
1205 if (res != 0)
1206 {
1207 apds9960_interface_debug_print("apds9960: get wait long failed.\n");
1208 (void)apds9960_deinit(&gs_handle);
1209
1210 return 1;
1211 }
1212 apds9960_interface_debug_print("apds9960: check wait long %s.\n", enable == APDS9960_BOOL_TRUE ? "ok" : "error");
1213
1214 /* disable wait long */
1216 if (res != 0)
1217 {
1218 apds9960_interface_debug_print("apds9960: set wait long failed.\n");
1219 (void)apds9960_deinit(&gs_handle);
1220
1221 return 1;
1222 }
1223 apds9960_interface_debug_print("apds9960: disable wait long.\n");
1224 res = apds9960_get_wait_long(&gs_handle, &enable);
1225 if (res != 0)
1226 {
1227 apds9960_interface_debug_print("apds9960: get wait long failed.\n");
1228 (void)apds9960_deinit(&gs_handle);
1229
1230 return 1;
1231 }
1232 apds9960_interface_debug_print("apds9960: check wait long %s.\n", enable == APDS9960_BOOL_FALSE ? "ok" : "error");
1233
1234 /* apds9960_set_proximity_pulse_length/apds9960_get_proximity_pulse_length test */
1235 apds9960_interface_debug_print("apds9960: apds9960_set_proximity_pulse_length/apds9960_get_proximity_pulse_length test.\n");
1236
1237 /* proximity pulse length 4 us */
1239 if (res != 0)
1240 {
1241 apds9960_interface_debug_print("apds9960: set proximity pulse length failed.\n");
1242 (void)apds9960_deinit(&gs_handle);
1243
1244 return 1;
1245 }
1246 apds9960_interface_debug_print("apds9960: proximity pulse length 4 us.\n");
1247 res = apds9960_get_proximity_pulse_length(&gs_handle, &len);
1248 if (res != 0)
1249 {
1250 apds9960_interface_debug_print("apds9960: get proximity pulse length failed.\n");
1251 (void)apds9960_deinit(&gs_handle);
1252
1253 return 1;
1254 }
1255 apds9960_interface_debug_print("apds9960: check proximity pulse length %s.\n", len == APDS9960_PROXIMITY_PULSE_LENGTH_4_US ? "ok" : "error");
1256
1257 /* proximity pulse length 8 us */
1259 if (res != 0)
1260 {
1261 apds9960_interface_debug_print("apds9960: set proximity pulse length failed.\n");
1262 (void)apds9960_deinit(&gs_handle);
1263
1264 return 1;
1265 }
1266 apds9960_interface_debug_print("apds9960: proximity pulse length 8 us.\n");
1267 res = apds9960_get_proximity_pulse_length(&gs_handle, &len);
1268 if (res != 0)
1269 {
1270 apds9960_interface_debug_print("apds9960: get proximity pulse length failed.\n");
1271 (void)apds9960_deinit(&gs_handle);
1272
1273 return 1;
1274 }
1275 apds9960_interface_debug_print("apds9960: check proximity pulse length %s.\n", len == APDS9960_PROXIMITY_PULSE_LENGTH_8_US ? "ok" : "error");
1276
1277 /* proximity pulse length 16 us */
1279 if (res != 0)
1280 {
1281 apds9960_interface_debug_print("apds9960: set proximity pulse length failed.\n");
1282 (void)apds9960_deinit(&gs_handle);
1283
1284 return 1;
1285 }
1286 apds9960_interface_debug_print("apds9960: proximity pulse length 16 us.\n");
1287 res = apds9960_get_proximity_pulse_length(&gs_handle, &len);
1288 if (res != 0)
1289 {
1290 apds9960_interface_debug_print("apds9960: get proximity pulse length failed.\n");
1291 (void)apds9960_deinit(&gs_handle);
1292
1293 return 1;
1294 }
1295 apds9960_interface_debug_print("apds9960: check proximity pulse length %s.\n", len == APDS9960_PROXIMITY_PULSE_LENGTH_16_US ? "ok" : "error");
1296
1297 /* proximity pulse length 32 us */
1299 if (res != 0)
1300 {
1301 apds9960_interface_debug_print("apds9960: set proximity pulse length failed.\n");
1302 (void)apds9960_deinit(&gs_handle);
1303
1304 return 1;
1305 }
1306 apds9960_interface_debug_print("apds9960: proximity pulse length 32 us.\n");
1307 res = apds9960_get_proximity_pulse_length(&gs_handle, &len);
1308 if (res != 0)
1309 {
1310 apds9960_interface_debug_print("apds9960: get proximity pulse length failed.\n");
1311 (void)apds9960_deinit(&gs_handle);
1312
1313 return 1;
1314 }
1315 apds9960_interface_debug_print("apds9960: check proximity pulse length %s.\n", len == APDS9960_PROXIMITY_PULSE_LENGTH_32_US ? "ok" : "error");
1316
1317 /* apds9960_set_proximity_pulse_count/apds9960_get_proximity_pulse_count test */
1318 apds9960_interface_debug_print("apds9960: apds9960_set_proximity_pulse_count/apds9960_get_proximity_pulse_count test.\n");
1319
1320 count = rand() % 0x3F;
1321 res = apds9960_set_proximity_pulse_count(&gs_handle, count);
1322 if (res != 0)
1323 {
1324 apds9960_interface_debug_print("apds9960: set proximity pulse count failed.\n");
1325 (void)apds9960_deinit(&gs_handle);
1326
1327 return 1;
1328 }
1329 apds9960_interface_debug_print("apds9960: set proximity pulse count %d.\n", count);
1330 res = apds9960_get_proximity_pulse_count(&gs_handle, (uint16_t *)&count_check);
1331 if (res != 0)
1332 {
1333 apds9960_interface_debug_print("apds9960: get proximity pulse count failed.\n");
1334 (void)apds9960_deinit(&gs_handle);
1335
1336 return 1;
1337 }
1338 apds9960_interface_debug_print("apds9960: check proximity pulse count %s.\n", count_check == count ? "ok" : "error");
1339
1340 /* apds9960_set_led_current/apds9960_get_led_current test */
1341 apds9960_interface_debug_print("apds9960: apds9960_set_led_current/apds9960_get_led_current test.\n");
1342
1343 /* 100 mA */
1345 if (res != 0)
1346 {
1347 apds9960_interface_debug_print("apds9960: set led current failed.\n");
1348 (void)apds9960_deinit(&gs_handle);
1349
1350 return 1;
1351 }
1352 apds9960_interface_debug_print("apds9960: set led current 100 mA.\n");
1353 res = apds9960_get_led_current(&gs_handle, &current);
1354 if (res != 0)
1355 {
1356 apds9960_interface_debug_print("apds9960: get led current failed.\n");
1357 (void)apds9960_deinit(&gs_handle);
1358
1359 return 1;
1360 }
1361 apds9960_interface_debug_print("apds9960: check led current %s.\n", current == APDS9960_LED_CURRENT_100_MA ? "ok" : "error");
1362
1363 /* 50 mA */
1365 if (res != 0)
1366 {
1367 apds9960_interface_debug_print("apds9960: set led current failed.\n");
1368 (void)apds9960_deinit(&gs_handle);
1369
1370 return 1;
1371 }
1372 apds9960_interface_debug_print("apds9960: set led current 50 mA.\n");
1373 res = apds9960_get_led_current(&gs_handle, &current);
1374 if (res != 0)
1375 {
1376 apds9960_interface_debug_print("apds9960: get led current failed.\n");
1377 (void)apds9960_deinit(&gs_handle);
1378
1379 return 1;
1380 }
1381 apds9960_interface_debug_print("apds9960: check led current %s.\n", current == APDS9960_LED_CURRENT_50_MA ? "ok" : "error");
1382
1383 /* 25 mA */
1385 if (res != 0)
1386 {
1387 apds9960_interface_debug_print("apds9960: set led current failed.\n");
1388 (void)apds9960_deinit(&gs_handle);
1389
1390 return 1;
1391 }
1392 apds9960_interface_debug_print("apds9960: set led current 25 mA.\n");
1393 res = apds9960_get_led_current(&gs_handle, &current);
1394 if (res != 0)
1395 {
1396 apds9960_interface_debug_print("apds9960: get led current failed.\n");
1397 (void)apds9960_deinit(&gs_handle);
1398
1399 return 1;
1400 }
1401 apds9960_interface_debug_print("apds9960: check led current %s.\n", current == APDS9960_LED_CURRENT_25_MA ? "ok" : "error");
1402
1403 /* 12.5 mA */
1405 if (res != 0)
1406 {
1407 apds9960_interface_debug_print("apds9960: set led current failed.\n");
1408 (void)apds9960_deinit(&gs_handle);
1409
1410 return 1;
1411 }
1412 apds9960_interface_debug_print("apds9960: set led current 12.5 mA.\n");
1413 res = apds9960_get_led_current(&gs_handle, &current);
1414 if (res != 0)
1415 {
1416 apds9960_interface_debug_print("apds9960: get led current failed.\n");
1417 (void)apds9960_deinit(&gs_handle);
1418
1419 return 1;
1420 }
1421 apds9960_interface_debug_print("apds9960: check led current %s.\n", current == APDS9960_LED_CURRENT_12P5_MA ? "ok" : "error");
1422
1423 /* apds9960_set_proximity_gain/apds9960_get_proximity_gain test */
1424 apds9960_interface_debug_print("apds9960: apds9960_set_proximity_gain/apds9960_get_proximity_gain test.\n");
1425
1426 /* gain 1x */
1428 if (res != 0)
1429 {
1430 apds9960_interface_debug_print("apds9960: set proximity gain failed.\n");
1431 (void)apds9960_deinit(&gs_handle);
1432
1433 return 1;
1434 }
1435 apds9960_interface_debug_print("apds9960: set proximity gain 1x.\n");
1436 res = apds9960_get_proximity_gain(&gs_handle, &proximity_gain);
1437 if (res != 0)
1438 {
1439 apds9960_interface_debug_print("apds9960: get proximity gain failed.\n");
1440 (void)apds9960_deinit(&gs_handle);
1441
1442 return 1;
1443 }
1444 apds9960_interface_debug_print("apds9960: check proximity gain %s.\n", proximity_gain == APDS9960_PROXIMITY_GAIN_1X ? "ok" : "error");
1445
1446 /* gain 2x */
1448 if (res != 0)
1449 {
1450 apds9960_interface_debug_print("apds9960: set proximity gain failed.\n");
1451 (void)apds9960_deinit(&gs_handle);
1452
1453 return 1;
1454 }
1455 apds9960_interface_debug_print("apds9960: set proximity gain 2x.\n");
1456 res = apds9960_get_proximity_gain(&gs_handle, &proximity_gain);
1457 if (res != 0)
1458 {
1459 apds9960_interface_debug_print("apds9960: get proximity gain failed.\n");
1460 (void)apds9960_deinit(&gs_handle);
1461
1462 return 1;
1463 }
1464 apds9960_interface_debug_print("apds9960: check proximity gain %s.\n", proximity_gain == APDS9960_PROXIMITY_GAIN_2X ? "ok" : "error");
1465
1466 /* gain 4x */
1468 if (res != 0)
1469 {
1470 apds9960_interface_debug_print("apds9960: set proximity gain failed.\n");
1471 (void)apds9960_deinit(&gs_handle);
1472
1473 return 1;
1474 }
1475 apds9960_interface_debug_print("apds9960: set proximity gain 4x.\n");
1476 res = apds9960_get_proximity_gain(&gs_handle, &proximity_gain);
1477 if (res != 0)
1478 {
1479 apds9960_interface_debug_print("apds9960: get proximity gain failed.\n");
1480 (void)apds9960_deinit(&gs_handle);
1481
1482 return 1;
1483 }
1484 apds9960_interface_debug_print("apds9960: check proximity gain %s.\n", proximity_gain == APDS9960_PROXIMITY_GAIN_4X ? "ok" : "error");
1485
1486 /* gain 8x */
1488 if (res != 0)
1489 {
1490 apds9960_interface_debug_print("apds9960: set proximity gain failed.\n");
1491 (void)apds9960_deinit(&gs_handle);
1492
1493 return 1;
1494 }
1495 apds9960_interface_debug_print("apds9960: set proximity gain 8x.\n");
1496 res = apds9960_get_proximity_gain(&gs_handle, &proximity_gain);
1497 if (res != 0)
1498 {
1499 apds9960_interface_debug_print("apds9960: get proximity gain failed.\n");
1500 (void)apds9960_deinit(&gs_handle);
1501
1502 return 1;
1503 }
1504 apds9960_interface_debug_print("apds9960: check proximity gain %s.\n", proximity_gain == APDS9960_PROXIMITY_GAIN_8X ? "ok" : "error");
1505
1506 /* apds9960_set_als_color_gain/apds9960_get_als_color_gain test */
1507 apds9960_interface_debug_print("apds9960: apds9960_set_als_color_gain/apds9960_get_als_color_gain test.\n");
1508
1509 /* gain 1x */
1511 if (res != 0)
1512 {
1513 apds9960_interface_debug_print("apds9960: set als color gain failed.\n");
1514 (void)apds9960_deinit(&gs_handle);
1515
1516 return 1;
1517 }
1518 apds9960_interface_debug_print("apds9960: set als color gain 1x.\n");
1519 res = apds9960_get_als_color_gain(&gs_handle, &als_gain);
1520 if (res != 0)
1521 {
1522 apds9960_interface_debug_print("apds9960: get als color gain failed.\n");
1523 (void)apds9960_deinit(&gs_handle);
1524
1525 return 1;
1526 }
1527 apds9960_interface_debug_print("apds9960: check als color gain %s.\n", als_gain == APDS9960_ALS_COLOR_GAIN_1X ? "ok" : "error");
1528
1529 /* gain 4x */
1531 if (res != 0)
1532 {
1533 apds9960_interface_debug_print("apds9960: set als color gain failed.\n");
1534 (void)apds9960_deinit(&gs_handle);
1535
1536 return 1;
1537 }
1538 apds9960_interface_debug_print("apds9960: set als color gain 4x.\n");
1539 res = apds9960_get_als_color_gain(&gs_handle, &als_gain);
1540 if (res != 0)
1541 {
1542 apds9960_interface_debug_print("apds9960: get als color gain failed.\n");
1543 (void)apds9960_deinit(&gs_handle);
1544
1545 return 1;
1546 }
1547 apds9960_interface_debug_print("apds9960: check als color gain %s.\n", als_gain == APDS9960_ALS_COLOR_GAIN_4X ? "ok" : "error");
1548
1549 /* gain 16x */
1551 if (res != 0)
1552 {
1553 apds9960_interface_debug_print("apds9960: set als color gain failed.\n");
1554 (void)apds9960_deinit(&gs_handle);
1555
1556 return 1;
1557 }
1558 apds9960_interface_debug_print("apds9960: set als color gain 16x.\n");
1559 res = apds9960_get_als_color_gain(&gs_handle, &als_gain);
1560 if (res != 0)
1561 {
1562 apds9960_interface_debug_print("apds9960: get als color gain failed.\n");
1563 (void)apds9960_deinit(&gs_handle);
1564
1565 return 1;
1566 }
1567 apds9960_interface_debug_print("apds9960: check als color gain %s.\n", als_gain == APDS9960_ALS_COLOR_GAIN_16X ? "ok" : "error");
1568
1569 /* gain 64x */
1571 if (res != 0)
1572 {
1573 apds9960_interface_debug_print("apds9960: set als color gain failed.\n");
1574 (void)apds9960_deinit(&gs_handle);
1575
1576 return 1;
1577 }
1578 apds9960_interface_debug_print("apds9960: set als color gain 64x.\n");
1579 res = apds9960_get_als_color_gain(&gs_handle, &als_gain);
1580 if (res != 0)
1581 {
1582 apds9960_interface_debug_print("apds9960: get als color gain failed.\n");
1583 (void)apds9960_deinit(&gs_handle);
1584
1585 return 1;
1586 }
1587 apds9960_interface_debug_print("apds9960: check als color gain %s.\n", als_gain == APDS9960_ALS_COLOR_GAIN_64X ? "ok" : "error");
1588
1589 /* apds9960_set_saturation_interrupt/apds9960_get_saturation_interrupt test */
1590 apds9960_interface_debug_print("apds9960: apds9960_set_saturation_interrupt/apds9960_get_saturation_interrupt test.\n");
1591
1592 /* disable proximity saturation interrupt */
1594 if (res != 0)
1595 {
1596 apds9960_interface_debug_print("apds9960: set saturation interrupt failed.\n");
1597 (void)apds9960_deinit(&gs_handle);
1598
1599 return 1;
1600 }
1601 apds9960_interface_debug_print("apds9960: disable proximity saturation interrupt.\n");
1603 if (res != 0)
1604 {
1605 apds9960_interface_debug_print("apds9960: get saturation interrupt failed.\n");
1606 (void)apds9960_deinit(&gs_handle);
1607
1608 return 1;
1609 }
1610 apds9960_interface_debug_print("apds9960: check saturation interrupt %s.\n", enable == APDS9960_BOOL_FALSE ? "ok" : "error");
1611
1612 /* enable proximity saturation interrupt */
1614 if (res != 0)
1615 {
1616 apds9960_interface_debug_print("apds9960: set saturation interrupt failed.\n");
1617 (void)apds9960_deinit(&gs_handle);
1618
1619 return 1;
1620 }
1621 apds9960_interface_debug_print("apds9960: enable proximity saturation interrupt.\n");
1623 if (res != 0)
1624 {
1625 apds9960_interface_debug_print("apds9960: get saturation interrupt failed.\n");
1626 (void)apds9960_deinit(&gs_handle);
1627
1628 return 1;
1629 }
1630 apds9960_interface_debug_print("apds9960: check saturation interrupt %s.\n", enable == APDS9960_BOOL_TRUE ? "ok" : "error");
1631
1632 /* disable clear photo diode saturation interrupt */
1634 if (res != 0)
1635 {
1636 apds9960_interface_debug_print("apds9960: set saturation interrupt failed.\n");
1637 (void)apds9960_deinit(&gs_handle);
1638
1639 return 1;
1640 }
1641 apds9960_interface_debug_print("apds9960: disable clear photo diode saturation interrupt.\n");
1643 if (res != 0)
1644 {
1645 apds9960_interface_debug_print("apds9960: get saturation interrupt failed.\n");
1646 (void)apds9960_deinit(&gs_handle);
1647
1648 return 1;
1649 }
1650 apds9960_interface_debug_print("apds9960: check clear photo diode saturation interrupt %s.\n", enable == APDS9960_BOOL_FALSE ? "ok" : "error");
1651
1652 /* enable clear photo diode saturation interrupt */
1654 if (res != 0)
1655 {
1656 apds9960_interface_debug_print("apds9960: set saturation interrupt failed.\n");
1657 (void)apds9960_deinit(&gs_handle);
1658
1659 return 1;
1660 }
1661 apds9960_interface_debug_print("apds9960: enable clear photo diode saturation interrupt.\n");
1663 if (res != 0)
1664 {
1665 apds9960_interface_debug_print("apds9960: get saturation interrupt failed.\n");
1666 (void)apds9960_deinit(&gs_handle);
1667
1668 return 1;
1669 }
1670 apds9960_interface_debug_print("apds9960: check clear photo diode saturation interrupt %s.\n", enable == APDS9960_BOOL_TRUE ? "ok" : "error");
1671
1672 /* apds9960_set_led_boost/apds9960_get_led_boost test */
1673 apds9960_interface_debug_print("apds9960: apds9960_set_led_boost/apds9960_get_led_boost test.\n");
1674
1675 /* 100% */
1677 if (res != 0)
1678 {
1679 apds9960_interface_debug_print("apds9960: set led boost failed.\n");
1680 (void)apds9960_deinit(&gs_handle);
1681
1682 return 1;
1683 }
1684 apds9960_interface_debug_print("apds9960: set led boost 100%%.\n");
1685 res = apds9960_get_led_boost(&gs_handle, &boost);
1686 if (res != 0)
1687 {
1688 apds9960_interface_debug_print("apds9960: get led boost failed.\n");
1689 (void)apds9960_deinit(&gs_handle);
1690
1691 return 1;
1692 }
1693 apds9960_interface_debug_print("apds9960: check led boost %s.\n", boost == APDS9960_LED_BOOST_100_PERCENTAGE ? "ok" : "error");
1694
1695 /* 150% */
1697 if (res != 0)
1698 {
1699 apds9960_interface_debug_print("apds9960: set led boost failed.\n");
1700 (void)apds9960_deinit(&gs_handle);
1701
1702 return 1;
1703 }
1704 apds9960_interface_debug_print("apds9960: set led boost 150%%.\n");
1705 res = apds9960_get_led_boost(&gs_handle, &boost);
1706 if (res != 0)
1707 {
1708 apds9960_interface_debug_print("apds9960: get led boost failed.\n");
1709 (void)apds9960_deinit(&gs_handle);
1710
1711 return 1;
1712 }
1713 apds9960_interface_debug_print("apds9960: check led boost %s.\n", boost == APDS9960_LED_BOOST_150_PERCENTAGE ? "ok" : "error");
1714
1715 /* 200% */
1717 if (res != 0)
1718 {
1719 apds9960_interface_debug_print("apds9960: set led boost failed.\n");
1720 (void)apds9960_deinit(&gs_handle);
1721
1722 return 1;
1723 }
1724 apds9960_interface_debug_print("apds9960: set led boost 200%%.\n");
1725 res = apds9960_get_led_boost(&gs_handle, &boost);
1726 if (res != 0)
1727 {
1728 apds9960_interface_debug_print("apds9960: get led boost failed.\n");
1729 (void)apds9960_deinit(&gs_handle);
1730
1731 return 1;
1732 }
1733 apds9960_interface_debug_print("apds9960: check led boost %s.\n", boost == APDS9960_LED_BOOST_200_PERCENTAGE ? "ok" : "error");
1734
1735 /* 300% */
1737 if (res != 0)
1738 {
1739 apds9960_interface_debug_print("apds9960: set led boost failed.\n");
1740 (void)apds9960_deinit(&gs_handle);
1741
1742 return 1;
1743 }
1744 apds9960_interface_debug_print("apds9960: set led boost 300%%.\n");
1745 res = apds9960_get_led_boost(&gs_handle, &boost);
1746 if (res != 0)
1747 {
1748 apds9960_interface_debug_print("apds9960: get led boost failed.\n");
1749 (void)apds9960_deinit(&gs_handle);
1750
1751 return 1;
1752 }
1753 apds9960_interface_debug_print("apds9960: check led boost %s.\n", boost == APDS9960_LED_BOOST_300_PERCENTAGE ? "ok" : "error");
1754
1755 /* apds9960_set_proximity_up_right_offset/apds9960_get_proximity_up_right_offset test */
1756 apds9960_interface_debug_print("apds9960: apds9960_set_proximity_up_right_offset/apds9960_get_proximity_up_right_offset test.\n");
1757
1758 offset = rand() % 128;
1759 res = apds9960_set_proximity_up_right_offset(&gs_handle, offset);
1760 if (res != 0)
1761 {
1762 apds9960_interface_debug_print("apds9960: set proximity up right offset failed.\n");
1763 (void)apds9960_deinit(&gs_handle);
1764
1765 return 1;
1766 }
1767 apds9960_interface_debug_print("apds9960: set proximity up right offset %d.\n", offset);
1768 res = apds9960_get_proximity_up_right_offset(&gs_handle, (int8_t *)&offset_check);
1769 if (res != 0)
1770 {
1771 apds9960_interface_debug_print("apds9960: get proximity up right offset failed.\n");
1772 (void)apds9960_deinit(&gs_handle);
1773
1774 return 1;
1775 }
1776 apds9960_interface_debug_print("apds9960: check proximity up right offset %s.\n", offset_check == offset ? "ok" : "error");
1777
1778 /* apds9960_set_proximity_down_left_offset/apds9960_get_proximity_down_left_offset test */
1779 apds9960_interface_debug_print("apds9960: apds9960_set_proximity_down_left_offset/apds9960_get_proximity_down_left_offset test.\n");
1780
1781 offset = -(rand() % 128);
1782 res = apds9960_set_proximity_down_left_offset(&gs_handle, offset);
1783 if (res != 0)
1784 {
1785 apds9960_interface_debug_print("apds9960: set proximity down left offset failed.\n");
1786 (void)apds9960_deinit(&gs_handle);
1787
1788 return 1;
1789 }
1790 apds9960_interface_debug_print("apds9960: set proximity down left offset %d.\n", offset);
1791 res = apds9960_get_proximity_down_left_offset(&gs_handle, (int8_t *)&offset_check);
1792 if (res != 0)
1793 {
1794 apds9960_interface_debug_print("apds9960: get proximity down left offset failed.\n");
1795 (void)apds9960_deinit(&gs_handle);
1796
1797 return 1;
1798 }
1799 apds9960_interface_debug_print("apds9960: check proximity down left offset %s.\n", offset_check == offset ? "ok" : "error");
1800
1801 /* apds9960_set_proximity_gain_compensation/apds9960_get_proximity_gain_compensation test */
1802 apds9960_interface_debug_print("apds9960: apds9960_set_proximity_gain_compensation/apds9960_get_proximity_gain_compensation test.\n");
1803
1804 /* enable */
1806 if (res != 0)
1807 {
1808 apds9960_interface_debug_print("apds9960: set proximity gain compensation failed.\n");
1809 (void)apds9960_deinit(&gs_handle);
1810
1811 return 1;
1812 }
1813 apds9960_interface_debug_print("apds9960: enable proximity gain compensation.\n");
1814 res = apds9960_get_proximity_gain_compensation(&gs_handle, &enable);
1815 if (res != 0)
1816 {
1817 apds9960_interface_debug_print("apds9960: get proximity gain compensation failed.\n");
1818 (void)apds9960_deinit(&gs_handle);
1819
1820 return 1;
1821 }
1822 apds9960_interface_debug_print("apds9960: check proximity gain compensation %s.\n", enable == APDS9960_BOOL_TRUE ? "ok" : "error");
1823
1824 /* disable */
1826 if (res != 0)
1827 {
1828 apds9960_interface_debug_print("apds9960: set proximity gain compensation failed.\n");
1829 (void)apds9960_deinit(&gs_handle);
1830
1831 return 1;
1832 }
1833 apds9960_interface_debug_print("apds9960: disable proximity gain compensation.\n");
1834 res = apds9960_get_proximity_gain_compensation(&gs_handle, &enable);
1835 if (res != 0)
1836 {
1837 apds9960_interface_debug_print("apds9960: get proximity gain compensation failed.\n");
1838 (void)apds9960_deinit(&gs_handle);
1839
1840 return 1;
1841 }
1842 apds9960_interface_debug_print("apds9960: check proximity gain compensation %s.\n", enable == APDS9960_BOOL_FALSE ? "ok" : "error");
1843
1844 /* apds9960_set_sleep_after_interrupt/apds9960_get_sleep_after_interrupt test */
1845 apds9960_interface_debug_print("apds9960: apds9960_set_sleep_after_interrupt/apds9960_get_sleep_after_interrupt test.\n");
1846
1847 /* enable */
1849 if (res != 0)
1850 {
1851 apds9960_interface_debug_print("apds9960: set sleep after interrupt failed.\n");
1852 (void)apds9960_deinit(&gs_handle);
1853
1854 return 1;
1855 }
1856 apds9960_interface_debug_print("apds9960: enable sleep after interrupt.\n");
1857 res = apds9960_get_sleep_after_interrupt(&gs_handle, (apds9960_bool_t *)&enable);
1858 if (res != 0)
1859 {
1860 apds9960_interface_debug_print("apds9960: get sleep after interrupt failed.\n");
1861 (void)apds9960_deinit(&gs_handle);
1862
1863 return 1;
1864 }
1865 apds9960_interface_debug_print("apds9960: check sleep after interrupt %s.\n", enable == APDS9960_BOOL_TRUE ? "ok" : "error");
1866
1867 /* disable */
1869 if (res != 0)
1870 {
1871 apds9960_interface_debug_print("apds9960: set sleep after interrupt failed.\n");
1872 (void)apds9960_deinit(&gs_handle);
1873
1874 return 1;
1875 }
1876 apds9960_interface_debug_print("apds9960: disable sleep after interrupt.\n");
1877 res = apds9960_get_sleep_after_interrupt(&gs_handle, (apds9960_bool_t *)&enable);
1878 if (res != 0)
1879 {
1880 apds9960_interface_debug_print("apds9960: get sleep after interrupt failed.\n");
1881 (void)apds9960_deinit(&gs_handle);
1882
1883 return 1;
1884 }
1885 apds9960_interface_debug_print("apds9960: check sleep after interrupt %s.\n", enable == APDS9960_BOOL_FALSE ? "ok" : "error");
1886
1887 /* apds9960_set_proximity_mask/apds9960_get_proximity_mask test */
1888 apds9960_interface_debug_print("apds9960: apds9960_set_proximity_mask/apds9960_get_proximity_mask test.\n");
1889
1890 /* enable proximity mask up */
1892 if (res != 0)
1893 {
1894 apds9960_interface_debug_print("apds9960: set proximity mask failed.\n");
1895 (void)apds9960_deinit(&gs_handle);
1896
1897 return 1;
1898 }
1899 apds9960_interface_debug_print("apds9960: enable proximity mask up.\n");
1901 if (res != 0)
1902 {
1903 apds9960_interface_debug_print("apds9960: get proximity mask failed.\n");
1904 (void)apds9960_deinit(&gs_handle);
1905
1906 return 1;
1907 }
1908 apds9960_interface_debug_print("apds9960: check proximity mask %s.\n", enable == APDS9960_BOOL_TRUE ? "ok" : "error");
1909
1910 /* disable proximity mask up */
1912 if (res != 0)
1913 {
1914 apds9960_interface_debug_print("apds9960: set proximity mask failed.\n");
1915 (void)apds9960_deinit(&gs_handle);
1916
1917 return 1;
1918 }
1919 apds9960_interface_debug_print("apds9960: disable proximity mask up.\n");
1921 if (res != 0)
1922 {
1923 apds9960_interface_debug_print("apds9960: get proximity mask failed.\n");
1924 (void)apds9960_deinit(&gs_handle);
1925
1926 return 1;
1927 }
1928 apds9960_interface_debug_print("apds9960: check proximity mask %s.\n", enable == APDS9960_BOOL_FALSE ? "ok" : "error");
1929
1930 /* enable proximity mask down */
1932 if (res != 0)
1933 {
1934 apds9960_interface_debug_print("apds9960: set proximity mask failed.\n");
1935 (void)apds9960_deinit(&gs_handle);
1936
1937 return 1;
1938 }
1939 apds9960_interface_debug_print("apds9960: enable proximity mask down.\n");
1941 if (res != 0)
1942 {
1943 apds9960_interface_debug_print("apds9960: get proximity mask failed.\n");
1944 (void)apds9960_deinit(&gs_handle);
1945
1946 return 1;
1947 }
1948 apds9960_interface_debug_print("apds9960: check proximity mask %s.\n", enable == APDS9960_BOOL_TRUE ? "ok" : "error");
1949
1950 /* disable proximity mask down */
1952 if (res != 0)
1953 {
1954 apds9960_interface_debug_print("apds9960: set proximity mask failed.\n");
1955 (void)apds9960_deinit(&gs_handle);
1956
1957 return 1;
1958 }
1959 apds9960_interface_debug_print("apds9960: disable proximity mask down.\n");
1961 if (res != 0)
1962 {
1963 apds9960_interface_debug_print("apds9960: get proximity mask failed.\n");
1964 (void)apds9960_deinit(&gs_handle);
1965
1966 return 1;
1967 }
1968 apds9960_interface_debug_print("apds9960: check proximity mask %s.\n", enable == APDS9960_BOOL_FALSE ? "ok" : "error");
1969
1970 /* enable proximity mask left */
1972 if (res != 0)
1973 {
1974 apds9960_interface_debug_print("apds9960: set proximity mask failed.\n");
1975 (void)apds9960_deinit(&gs_handle);
1976
1977 return 1;
1978 }
1979 apds9960_interface_debug_print("apds9960: enable proximity mask left.\n");
1981 if (res != 0)
1982 {
1983 apds9960_interface_debug_print("apds9960: get proximity mask failed.\n");
1984 (void)apds9960_deinit(&gs_handle);
1985
1986 return 1;
1987 }
1988 apds9960_interface_debug_print("apds9960: check proximity mask %s.\n", enable == APDS9960_BOOL_TRUE ? "ok" : "error");
1989
1990 /* disable proximity mask left */
1992 if (res != 0)
1993 {
1994 apds9960_interface_debug_print("apds9960: set proximity mask failed.\n");
1995 (void)apds9960_deinit(&gs_handle);
1996
1997 return 1;
1998 }
1999 apds9960_interface_debug_print("apds9960: disable proximity mask left.\n");
2001 if (res != 0)
2002 {
2003 apds9960_interface_debug_print("apds9960: get proximity mask failed.\n");
2004 (void)apds9960_deinit(&gs_handle);
2005
2006 return 1;
2007 }
2008 apds9960_interface_debug_print("apds9960: check proximity mask %s.\n", enable == APDS9960_BOOL_FALSE ? "ok" : "error");
2009
2010 /* enable proximity mask right */
2012 if (res != 0)
2013 {
2014 apds9960_interface_debug_print("apds9960: set proximity mask failed.\n");
2015 (void)apds9960_deinit(&gs_handle);
2016
2017 return 1;
2018 }
2019 apds9960_interface_debug_print("apds9960: enable proximity mask right.\n");
2021 if (res != 0)
2022 {
2023 apds9960_interface_debug_print("apds9960: get proximity mask failed.\n");
2024 (void)apds9960_deinit(&gs_handle);
2025
2026 return 1;
2027 }
2028 apds9960_interface_debug_print("apds9960: check proximity mask %s.\n", enable == APDS9960_BOOL_TRUE ? "ok" : "error");
2029
2030 /* disable proximity mask right */
2032 if (res != 0)
2033 {
2034 apds9960_interface_debug_print("apds9960: set proximity mask failed.\n");
2035 (void)apds9960_deinit(&gs_handle);
2036
2037 return 1;
2038 }
2039 apds9960_interface_debug_print("apds9960: disable proximity mask right.\n");
2041 if (res != 0)
2042 {
2043 apds9960_interface_debug_print("apds9960: get proximity mask failed.\n");
2044 (void)apds9960_deinit(&gs_handle);
2045
2046 return 1;
2047 }
2048 apds9960_interface_debug_print("apds9960: check proximity mask %s.\n", enable == APDS9960_BOOL_FALSE ? "ok" : "error");
2049
2050 /* apds9960_set_gesture_proximity_enter_threshold/apds9960_get_gesture_proximity_enter_threshold test */
2051 apds9960_interface_debug_print("apds9960: apds9960_set_gesture_proximity_enter_threshold/apds9960_get_gesture_proximity_enter_threshold test.\n");
2052
2053 reg = rand() % 256;
2055 if (res != 0)
2056 {
2057 apds9960_interface_debug_print("apds9960: set gesture proximity enter threshold failed.\n");
2058 (void)apds9960_deinit(&gs_handle);
2059
2060 return 1;
2061 }
2062 apds9960_interface_debug_print("apds9960: set gesture proximity enter threshold 0x%02X.\n", reg);
2063 res = apds9960_get_gesture_proximity_enter_threshold(&gs_handle, (uint8_t *)&reg_check);
2064 if (res != 0)
2065 {
2066 apds9960_interface_debug_print("apds9960: get gesture proximity enter threshold failed.\n");
2067 (void)apds9960_deinit(&gs_handle);
2068
2069 return 1;
2070 }
2071 apds9960_interface_debug_print("apds9960: check gesture proximity enter threshold %s.\n", reg == reg_check ? "ok" : "error");
2072
2073 /* apds9960_set_gesture_proximity_exit_threshold/apds9960_get_gesture_proximity_exit_threshold test */
2074 apds9960_interface_debug_print("apds9960: apds9960_set_gesture_proximity_exit_threshold/apds9960_get_gesture_proximity_exit_threshold test.\n");
2075
2076 reg = rand() % 256;
2077 res = apds9960_set_gesture_proximity_exit_threshold(&gs_handle, reg);
2078 if (res != 0)
2079 {
2080 apds9960_interface_debug_print("apds9960: set gesture proximity exit threshold failed.\n");
2081 (void)apds9960_deinit(&gs_handle);
2082
2083 return 1;
2084 }
2085 apds9960_interface_debug_print("apds9960: set gesture proximity exit threshold 0x%02X.\n", reg);
2086 res = apds9960_get_gesture_proximity_exit_threshold(&gs_handle, (uint8_t *)&reg_check);
2087 if (res != 0)
2088 {
2089 apds9960_interface_debug_print("apds9960: get gesture proximity exit threshold failed.\n");
2090 (void)apds9960_deinit(&gs_handle);
2091
2092 return 1;
2093 }
2094 apds9960_interface_debug_print("apds9960: check gesture proximity exit threshold %s.\n", reg == reg_check ? "ok" : "error");
2095
2096 /* apds9960_set_gesture_fifo_threshold/apds9960_get_gesture_fifo_threshold test */
2097 apds9960_interface_debug_print("apds9960: apds9960_set_gesture_fifo_threshold/apds9960_get_gesture_fifo_threshold test.\n");
2098
2099 /* set gesture fifo threshold 1 dataset */
2101 if (res != 0)
2102 {
2103 apds9960_interface_debug_print("apds9960: set gesture fifo threshold failed.\n");
2104 (void)apds9960_deinit(&gs_handle);
2105
2106 return 1;
2107 }
2108 apds9960_interface_debug_print("apds9960: set gesture fifo threshold 1 dataset.\n");
2109 res = apds9960_get_gesture_fifo_threshold(&gs_handle, &fifo_threshold);
2110 if (res != 0)
2111 {
2112 apds9960_interface_debug_print("apds9960: get gesture fifo threshold failed.\n");
2113 (void)apds9960_deinit(&gs_handle);
2114
2115 return 1;
2116 }
2117 apds9960_interface_debug_print("apds9960: check gesture fifo threshold %s.\n", fifo_threshold == APDS9960_GESTURE_FIFO_THRESHOLD_1_DATASET ? "ok" : "error");
2118
2119 /* set gesture fifo threshold 4 dataset */
2121 if (res != 0)
2122 {
2123 apds9960_interface_debug_print("apds9960: set gesture fifo threshold failed.\n");
2124 (void)apds9960_deinit(&gs_handle);
2125
2126 return 1;
2127 }
2128 apds9960_interface_debug_print("apds9960: set gesture fifo threshold 4 dataset.\n");
2129 res = apds9960_get_gesture_fifo_threshold(&gs_handle, &fifo_threshold);
2130 if (res != 0)
2131 {
2132 apds9960_interface_debug_print("apds9960: get gesture fifo threshold failed.\n");
2133 (void)apds9960_deinit(&gs_handle);
2134
2135 return 1;
2136 }
2137 apds9960_interface_debug_print("apds9960: check gesture fifo threshold %s.\n", fifo_threshold == APDS9960_GESTURE_FIFO_THRESHOLD_4_DATASET ? "ok" : "error");
2138
2139 /* set gesture fifo threshold 8 dataset */
2141 if (res != 0)
2142 {
2143 apds9960_interface_debug_print("apds9960: set gesture fifo threshold failed.\n");
2144 (void)apds9960_deinit(&gs_handle);
2145
2146 return 1;
2147 }
2148 apds9960_interface_debug_print("apds9960: set gesture fifo threshold 8 dataset.\n");
2149 res = apds9960_get_gesture_fifo_threshold(&gs_handle, &fifo_threshold);
2150 if (res != 0)
2151 {
2152 apds9960_interface_debug_print("apds9960: get gesture fifo threshold failed.\n");
2153 (void)apds9960_deinit(&gs_handle);
2154
2155 return 1;
2156 }
2157 apds9960_interface_debug_print("apds9960: check gesture fifo threshold %s.\n", fifo_threshold == APDS9960_GESTURE_FIFO_THRESHOLD_8_DATASET ? "ok" : "error");
2158
2159 /* set gesture fifo threshold 16 dataset */
2161 if (res != 0)
2162 {
2163 apds9960_interface_debug_print("apds9960: set gesture fifo threshold failed.\n");
2164 (void)apds9960_deinit(&gs_handle);
2165
2166 return 1;
2167 }
2168 apds9960_interface_debug_print("apds9960: set gesture fifo threshold 16 dataset.\n");
2169 res = apds9960_get_gesture_fifo_threshold(&gs_handle, &fifo_threshold);
2170 if (res != 0)
2171 {
2172 apds9960_interface_debug_print("apds9960: get gesture fifo threshold failed.\n");
2173 (void)apds9960_deinit(&gs_handle);
2174
2175 return 1;
2176 }
2177 apds9960_interface_debug_print("apds9960: check gesture fifo threshold %s.\n", fifo_threshold == APDS9960_GESTURE_FIFO_THRESHOLD_16_DATASET ? "ok" : "error");
2178
2179 /* apds9960_set_gesture_exit_persistence/apds9960_get_gesture_exit_persistence test */
2180 apds9960_interface_debug_print("apds9960: apds9960_set_gesture_exit_persistence/apds9960_get_gesture_exit_persistence test.\n");
2181
2182 /* set gesture exit persistence 1st */
2184 if (res != 0)
2185 {
2186 apds9960_interface_debug_print("apds9960: set gesture exit persistence failed.\n");
2187 (void)apds9960_deinit(&gs_handle);
2188
2189 return 1;
2190 }
2191 apds9960_interface_debug_print("apds9960: set gesture exit persistence 1st.\n");
2192 res = apds9960_get_gesture_exit_persistence(&gs_handle, &persistence);
2193 if (res != 0)
2194 {
2195 apds9960_interface_debug_print("apds9960: get gesture exit persistence failed.\n");
2196 (void)apds9960_deinit(&gs_handle);
2197
2198 return 1;
2199 }
2200 apds9960_interface_debug_print("apds9960: check gesture exit persistence %s.\n", persistence == APDS9960_GESTURE_EXIT_PERSISTENCE_1ST ? "ok" : "error");
2201
2202 /* set gesture exit persistence 2nd */
2204 if (res != 0)
2205 {
2206 apds9960_interface_debug_print("apds9960: set gesture exit persistence failed.\n");
2207 (void)apds9960_deinit(&gs_handle);
2208
2209 return 1;
2210 }
2211 apds9960_interface_debug_print("apds9960: set gesture exit persistence 2nd.\n");
2212 res = apds9960_get_gesture_exit_persistence(&gs_handle, &persistence);
2213 if (res != 0)
2214 {
2215 apds9960_interface_debug_print("apds9960: get gesture exit persistence failed.\n");
2216 (void)apds9960_deinit(&gs_handle);
2217
2218 return 1;
2219 }
2220 apds9960_interface_debug_print("apds9960: check gesture exit persistence %s.\n", persistence == APDS9960_GESTURE_EXIT_PERSISTENCE_2ND ? "ok" : "error");
2221
2222 /* set gesture exit persistence 4th */
2224 if (res != 0)
2225 {
2226 apds9960_interface_debug_print("apds9960: set gesture exit persistence failed.\n");
2227 (void)apds9960_deinit(&gs_handle);
2228
2229 return 1;
2230 }
2231 apds9960_interface_debug_print("apds9960: set gesture exit persistence 4th.\n");
2232 res = apds9960_get_gesture_exit_persistence(&gs_handle, &persistence);
2233 if (res != 0)
2234 {
2235 apds9960_interface_debug_print("apds9960: get gesture exit persistence failed.\n");
2236 (void)apds9960_deinit(&gs_handle);
2237
2238 return 1;
2239 }
2240 apds9960_interface_debug_print("apds9960: check gesture exit persistence %s.\n", persistence == APDS9960_GESTURE_EXIT_PERSISTENCE_4TH ? "ok" : "error");
2241
2242 /* set gesture exit persistence 7th */
2244 if (res != 0)
2245 {
2246 apds9960_interface_debug_print("apds9960: set gesture exit persistence failed.\n");
2247 (void)apds9960_deinit(&gs_handle);
2248
2249 return 1;
2250 }
2251 apds9960_interface_debug_print("apds9960: set gesture exit persistence 7th.\n");
2252 res = apds9960_get_gesture_exit_persistence(&gs_handle, &persistence);
2253 if (res != 0)
2254 {
2255 apds9960_interface_debug_print("apds9960: get gesture exit persistence failed.\n");
2256 (void)apds9960_deinit(&gs_handle);
2257
2258 return 1;
2259 }
2260 apds9960_interface_debug_print("apds9960: check gesture exit persistence %s.\n", persistence == APDS9960_GESTURE_EXIT_PERSISTENCE_7TH ? "ok" : "error");
2261
2262 /* apds9960_set_gesture_exit_mask/apds9960_get_gesture_exit_mask test */
2263 apds9960_interface_debug_print("apds9960: apds9960_set_gesture_exit_mask/apds9960_get_gesture_exit_mask test.\n");
2264
2265 mask = rand() % 0xF;
2266 res = apds9960_set_gesture_exit_mask(&gs_handle, mask);
2267 if (res != 0)
2268 {
2269 apds9960_interface_debug_print("apds9960: set gesture exit mask failed.\n");
2270 (void)apds9960_deinit(&gs_handle);
2271
2272 return 1;
2273 }
2274 apds9960_interface_debug_print("apds9960: set gesture exit mask 0x%01X.\n", mask);
2275 res = apds9960_get_gesture_exit_mask(&gs_handle, (uint8_t *)&mask_check);
2276 if (res != 0)
2277 {
2278 apds9960_interface_debug_print("apds9960: get gesture exit mask failed.\n");
2279 (void)apds9960_deinit(&gs_handle);
2280
2281 return 1;
2282 }
2283 apds9960_interface_debug_print("apds9960: check gesture exit mask %s.\n", mask_check == mask ? "ok" : "error");
2284
2285 /* apds9960_set_gesture_gain/apds9960_get_gesture_gain test */
2286 apds9960_interface_debug_print("apds9960: apds9960_set_gesture_gain/apds9960_get_gesture_gain test.\n");
2287
2288 /* set gesture gain 1x */
2290 if (res != 0)
2291 {
2292 apds9960_interface_debug_print("apds9960: set gesture gain failed.\n");
2293 (void)apds9960_deinit(&gs_handle);
2294
2295 return 1;
2296 }
2297 apds9960_interface_debug_print("apds9960: set gesture gain 1x.\n");
2298 res = apds9960_get_gesture_gain(&gs_handle, &gesture_gain);
2299 if (res != 0)
2300 {
2301 apds9960_interface_debug_print("apds9960: get gesture gain failed.\n");
2302 (void)apds9960_deinit(&gs_handle);
2303
2304 return 1;
2305 }
2306 apds9960_interface_debug_print("apds9960: check gesture gain %s.\n", gesture_gain == APDS9960_GESTURE_GAIN_1X ? "ok" : "error");
2307
2308 /* set gesture gain 2x */
2310 if (res != 0)
2311 {
2312 apds9960_interface_debug_print("apds9960: set gesture gain failed.\n");
2313 (void)apds9960_deinit(&gs_handle);
2314
2315 return 1;
2316 }
2317 apds9960_interface_debug_print("apds9960: set gesture gain 2x.\n");
2318 res = apds9960_get_gesture_gain(&gs_handle, &gesture_gain);
2319 if (res != 0)
2320 {
2321 apds9960_interface_debug_print("apds9960: get gesture gain failed.\n");
2322 (void)apds9960_deinit(&gs_handle);
2323
2324 return 1;
2325 }
2326 apds9960_interface_debug_print("apds9960: check gesture gain %s.\n", gesture_gain == APDS9960_GESTURE_GAIN_2X ? "ok" : "error");
2327
2328 /* set gesture gain 4x */
2330 if (res != 0)
2331 {
2332 apds9960_interface_debug_print("apds9960: set gesture gain failed.\n");
2333 (void)apds9960_deinit(&gs_handle);
2334
2335 return 1;
2336 }
2337 apds9960_interface_debug_print("apds9960: set gesture gain 4x.\n");
2338 res = apds9960_get_gesture_gain(&gs_handle, &gesture_gain);
2339 if (res != 0)
2340 {
2341 apds9960_interface_debug_print("apds9960: get gesture gain failed.\n");
2342 (void)apds9960_deinit(&gs_handle);
2343
2344 return 1;
2345 }
2346 apds9960_interface_debug_print("apds9960: check gesture gain %s.\n", gesture_gain == APDS9960_GESTURE_GAIN_4X ? "ok" : "error");
2347
2348 /* set gesture gain 8x */
2350 if (res != 0)
2351 {
2352 apds9960_interface_debug_print("apds9960: set gesture gain failed.\n");
2353 (void)apds9960_deinit(&gs_handle);
2354
2355 return 1;
2356 }
2357 apds9960_interface_debug_print("apds9960: set gesture gain 8x.\n");
2358 res = apds9960_get_gesture_gain(&gs_handle, &gesture_gain);
2359 if (res != 0)
2360 {
2361 apds9960_interface_debug_print("apds9960: get gesture gain failed.\n");
2362 (void)apds9960_deinit(&gs_handle);
2363
2364 return 1;
2365 }
2366 apds9960_interface_debug_print("apds9960: check gesture gain %s.\n", gesture_gain == APDS9960_GESTURE_GAIN_8X ? "ok" : "error");
2367
2368 /* apds9960_set_gesture_led_current/apds9960_get_gesture_led_current test */
2369 apds9960_interface_debug_print("apds9960: apds9960_set_gesture_led_current/apds9960_get_gesture_led_current test.\n");
2370
2371 /* set gesture led current 100 mA */
2373 if (res != 0)
2374 {
2375 apds9960_interface_debug_print("apds9960: set gesture led current failed.\n");
2376 (void)apds9960_deinit(&gs_handle);
2377
2378 return 1;
2379 }
2380 apds9960_interface_debug_print("apds9960: set gesture led current 100 mA.\n");
2381 res = apds9960_get_gesture_led_current(&gs_handle, &gesture_current);
2382 if (res != 0)
2383 {
2384 apds9960_interface_debug_print("apds9960: get gesture led current failed.\n");
2385 (void)apds9960_deinit(&gs_handle);
2386
2387 return 1;
2388 }
2389 apds9960_interface_debug_print("apds9960: check gesture led current %s.\n", gesture_current == APDS9960_GESTURE_LED_CURRENT_100_MA ? "ok" : "error");
2390
2391 /* set gesture led current 50 mA */
2393 if (res != 0)
2394 {
2395 apds9960_interface_debug_print("apds9960: set gesture led current failed.\n");
2396 (void)apds9960_deinit(&gs_handle);
2397
2398 return 1;
2399 }
2400 apds9960_interface_debug_print("apds9960: set gesture led current 50 mA.\n");
2401 res = apds9960_get_gesture_led_current(&gs_handle, &gesture_current);
2402 if (res != 0)
2403 {
2404 apds9960_interface_debug_print("apds9960: get gesture led current failed.\n");
2405 (void)apds9960_deinit(&gs_handle);
2406
2407 return 1;
2408 }
2409 apds9960_interface_debug_print("apds9960: check gesture led current %s.\n", gesture_current == APDS9960_GESTURE_LED_CURRENT_50_MA ? "ok" : "error");
2410
2411 /* set gesture led current 25 mA */
2413 if (res != 0)
2414 {
2415 apds9960_interface_debug_print("apds9960: set gesture led current failed.\n");
2416 (void)apds9960_deinit(&gs_handle);
2417
2418 return 1;
2419 }
2420 apds9960_interface_debug_print("apds9960: set gesture led current 25 mA.\n");
2421 res = apds9960_get_gesture_led_current(&gs_handle, &gesture_current);
2422 if (res != 0)
2423 {
2424 apds9960_interface_debug_print("apds9960: get gesture led current failed.\n");
2425 (void)apds9960_deinit(&gs_handle);
2426
2427 return 1;
2428 }
2429 apds9960_interface_debug_print("apds9960: check gesture led current %s.\n", gesture_current == APDS9960_GESTURE_LED_CURRENT_25_MA ? "ok" : "error");
2430
2431 /* set gesture led current 12.5 mA */
2433 if (res != 0)
2434 {
2435 apds9960_interface_debug_print("apds9960: set gesture led current failed.\n");
2436 (void)apds9960_deinit(&gs_handle);
2437
2438 return 1;
2439 }
2440 apds9960_interface_debug_print("apds9960: set gesture led current 12.5 mA.\n");
2441 res = apds9960_get_gesture_led_current(&gs_handle, &gesture_current);
2442 if (res != 0)
2443 {
2444 apds9960_interface_debug_print("apds9960: get gesture led current failed.\n");
2445 (void)apds9960_deinit(&gs_handle);
2446
2447 return 1;
2448 }
2449 apds9960_interface_debug_print("apds9960: check gesture led current %s.\n", gesture_current == APDS9960_GESTURE_LED_CURRENT_12P5_MA ? "ok" : "error");
2450
2451 /* apds9960_set_gesture_wait_time/apds9960_get_gesture_wait_time test */
2452 apds9960_interface_debug_print("apds9960: apds9960_set_gesture_wait_time/apds9960_get_gesture_wait_time test.\n");
2453
2454 /* set gesture wait time 0 ms */
2456 if (res != 0)
2457 {
2458 apds9960_interface_debug_print("apds9960: set gesture wait time failed.\n");
2459 (void)apds9960_deinit(&gs_handle);
2460
2461 return 1;
2462 }
2463 apds9960_interface_debug_print("apds9960: set gesture wait time 0 ms.\n");
2464 res = apds9960_get_gesture_wait_time(&gs_handle, &gesture_wait_time);
2465 if (res != 0)
2466 {
2467 apds9960_interface_debug_print("apds9960: get gesture wait time failed.\n");
2468 (void)apds9960_deinit(&gs_handle);
2469
2470 return 1;
2471 }
2472 apds9960_interface_debug_print("apds9960: check gesture wait time %s.\n", gesture_wait_time == APDS9960_GESTURE_WAIT_TIME_0_MS ? "ok" : "error");
2473
2474 /* set gesture wait time 2.8 ms */
2476 if (res != 0)
2477 {
2478 apds9960_interface_debug_print("apds9960: set gesture wait time failed.\n");
2479 (void)apds9960_deinit(&gs_handle);
2480
2481 return 1;
2482 }
2483 apds9960_interface_debug_print("apds9960: set gesture wait time 2.8 ms.\n");
2484 res = apds9960_get_gesture_wait_time(&gs_handle, &gesture_wait_time);
2485 if (res != 0)
2486 {
2487 apds9960_interface_debug_print("apds9960: get gesture wait time failed.\n");
2488 (void)apds9960_deinit(&gs_handle);
2489
2490 return 1;
2491 }
2492 apds9960_interface_debug_print("apds9960: check gesture wait time %s.\n", gesture_wait_time == APDS9960_GESTURE_WAIT_TIME_2P8_MS ? "ok" : "error");
2493
2494 /* set gesture wait time 5.6 ms */
2496 if (res != 0)
2497 {
2498 apds9960_interface_debug_print("apds9960: set gesture wait time failed.\n");
2499 (void)apds9960_deinit(&gs_handle);
2500
2501 return 1;
2502 }
2503 apds9960_interface_debug_print("apds9960: set gesture wait time 5.6 ms.\n");
2504 res = apds9960_get_gesture_wait_time(&gs_handle, &gesture_wait_time);
2505 if (res != 0)
2506 {
2507 apds9960_interface_debug_print("apds9960: get gesture wait time failed.\n");
2508 (void)apds9960_deinit(&gs_handle);
2509
2510 return 1;
2511 }
2512 apds9960_interface_debug_print("apds9960: check gesture wait time %s.\n", gesture_wait_time == APDS9960_GESTURE_WAIT_TIME_5P6_MS ? "ok" : "error");
2513
2514 /* set gesture wait time 8.4 ms */
2516 if (res != 0)
2517 {
2518 apds9960_interface_debug_print("apds9960: set gesture wait time failed.\n");
2519 (void)apds9960_deinit(&gs_handle);
2520
2521 return 1;
2522 }
2523 apds9960_interface_debug_print("apds9960: set gesture wait time 8.4 ms.\n");
2524 res = apds9960_get_gesture_wait_time(&gs_handle, &gesture_wait_time);
2525 if (res != 0)
2526 {
2527 apds9960_interface_debug_print("apds9960: get gesture wait time failed.\n");
2528 (void)apds9960_deinit(&gs_handle);
2529
2530 return 1;
2531 }
2532 apds9960_interface_debug_print("apds9960: check gesture wait time %s.\n", gesture_wait_time == APDS9960_GESTURE_WAIT_TIME_8P4_MS ? "ok" : "error");
2533
2534 /* set gesture wait time 14 ms */
2536 if (res != 0)
2537 {
2538 apds9960_interface_debug_print("apds9960: set gesture wait time failed.\n");
2539 (void)apds9960_deinit(&gs_handle);
2540
2541 return 1;
2542 }
2543 apds9960_interface_debug_print("apds9960: set gesture wait time 14 ms.\n");
2544 res = apds9960_get_gesture_wait_time(&gs_handle, &gesture_wait_time);
2545 if (res != 0)
2546 {
2547 apds9960_interface_debug_print("apds9960: get gesture wait time failed.\n");
2548 (void)apds9960_deinit(&gs_handle);
2549
2550 return 1;
2551 }
2552 apds9960_interface_debug_print("apds9960: check gesture wait time %s.\n", gesture_wait_time == APDS9960_GESTURE_WAIT_TIME_14_MS ? "ok" : "error");
2553
2554 /* set gesture wait time 22.4 ms */
2556 if (res != 0)
2557 {
2558 apds9960_interface_debug_print("apds9960: set gesture wait time failed.\n");
2559 (void)apds9960_deinit(&gs_handle);
2560
2561 return 1;
2562 }
2563 apds9960_interface_debug_print("apds9960: set gesture wait time 22.4 ms.\n");
2564 res = apds9960_get_gesture_wait_time(&gs_handle, &gesture_wait_time);
2565 if (res != 0)
2566 {
2567 apds9960_interface_debug_print("apds9960: get gesture wait time failed.\n");
2568 (void)apds9960_deinit(&gs_handle);
2569
2570 return 1;
2571 }
2572 apds9960_interface_debug_print("apds9960: check gesture wait time %s.\n", gesture_wait_time == APDS9960_GESTURE_WAIT_TIME_22P4_MS ? "ok" : "error");
2573
2574 /* set gesture wait time 30.8 ms */
2576 if (res != 0)
2577 {
2578 apds9960_interface_debug_print("apds9960: set gesture wait time failed.\n");
2579 (void)apds9960_deinit(&gs_handle);
2580
2581 return 1;
2582 }
2583 apds9960_interface_debug_print("apds9960: set gesture wait time 30.8 ms.\n");
2584 res = apds9960_get_gesture_wait_time(&gs_handle, &gesture_wait_time);
2585 if (res != 0)
2586 {
2587 apds9960_interface_debug_print("apds9960: get gesture wait time failed.\n");
2588 (void)apds9960_deinit(&gs_handle);
2589
2590 return 1;
2591 }
2592 apds9960_interface_debug_print("apds9960: check gesture wait time %s.\n", gesture_wait_time == APDS9960_GESTURE_WAIT_TIME_30P8_MS ? "ok" : "error");
2593
2594 /* set gesture wait time 39.2 ms */
2596 if (res != 0)
2597 {
2598 apds9960_interface_debug_print("apds9960: set gesture wait time failed.\n");
2599 (void)apds9960_deinit(&gs_handle);
2600
2601 return 1;
2602 }
2603 apds9960_interface_debug_print("apds9960: set gesture wait time 39.2 ms.\n");
2604 res = apds9960_get_gesture_wait_time(&gs_handle, &gesture_wait_time);
2605 if (res != 0)
2606 {
2607 apds9960_interface_debug_print("apds9960: get gesture wait time failed.\n");
2608 (void)apds9960_deinit(&gs_handle);
2609
2610 return 1;
2611 }
2612 apds9960_interface_debug_print("apds9960: check gesture wait time %s.\n", gesture_wait_time == APDS9960_GESTURE_WAIT_TIME_39P2_MS ? "ok" : "error");
2613
2614 /* apds9960_set_gesture_up_offset/apds9960_get_gesture_up_offset test */
2615 apds9960_interface_debug_print("apds9960: apds9960_set_gesture_up_offset/apds9960_get_gesture_up_offset test.\n");
2616
2617 offset = rand() % 128;
2618 res = apds9960_set_gesture_up_offset(&gs_handle, offset);
2619 if (res != 0)
2620 {
2621 apds9960_interface_debug_print("apds9960: set gesture up offset failed.\n");
2622 (void)apds9960_deinit(&gs_handle);
2623
2624 return 1;
2625 }
2626 apds9960_interface_debug_print("apds9960: set gesture up offset %d.\n", offset);
2627 res = apds9960_get_gesture_up_offset(&gs_handle, (int8_t *)&offset_check);
2628 if (res != 0)
2629 {
2630 apds9960_interface_debug_print("apds9960: get gesture up offset failed.\n");
2631 (void)apds9960_deinit(&gs_handle);
2632
2633 return 1;
2634 }
2635 apds9960_interface_debug_print("apds9960: check gesture up offset %s.\n", offset_check == offset ? "ok" : "error");
2636
2637 /* apds9960_set_gesture_down_offset/apds9960_get_gesture_down_offset test */
2638 apds9960_interface_debug_print("apds9960: apds9960_set_gesture_down_offset/apds9960_get_gesture_down_offset test.\n");
2639
2640 offset = -(rand() % 128);
2641 res = apds9960_set_gesture_down_offset(&gs_handle, offset);
2642 if (res != 0)
2643 {
2644 apds9960_interface_debug_print("apds9960: set gesture down offset failed.\n");
2645 (void)apds9960_deinit(&gs_handle);
2646
2647 return 1;
2648 }
2649 apds9960_interface_debug_print("apds9960: set gesture down offset %d.\n", offset);
2650 res = apds9960_get_gesture_down_offset(&gs_handle, (int8_t *)&offset_check);
2651 if (res != 0)
2652 {
2653 apds9960_interface_debug_print("apds9960: get gesture down offset failed.\n");
2654 (void)apds9960_deinit(&gs_handle);
2655
2656 return 1;
2657 }
2658 apds9960_interface_debug_print("apds9960: check gesture down offset %s.\n", offset_check == offset ? "ok" : "error");
2659
2660 /* apds9960_set_gesture_left_offset/apds9960_get_gesture_left_offset test */
2661 apds9960_interface_debug_print("apds9960: apds9960_set_gesture_left_offset/apds9960_get_gesture_left_offset test.\n");
2662
2663 offset = rand() % 128;
2664 res = apds9960_set_gesture_left_offset(&gs_handle, offset);
2665 if (res != 0)
2666 {
2667 apds9960_interface_debug_print("apds9960: set gesture left offset failed.\n");
2668 (void)apds9960_deinit(&gs_handle);
2669
2670 return 1;
2671 }
2672 apds9960_interface_debug_print("apds9960: set gesture left offset %d.\n", offset);
2673 res = apds9960_get_gesture_left_offset(&gs_handle, (int8_t *)&offset_check);
2674 if (res != 0)
2675 {
2676 apds9960_interface_debug_print("apds9960: get gesture left offset failed.\n");
2677 (void)apds9960_deinit(&gs_handle);
2678
2679 return 1;
2680 }
2681 apds9960_interface_debug_print("apds9960: check gesture left offset %s.\n", offset_check == offset ? "ok" : "error");
2682
2683 /* apds9960_set_gesture_right_offset/apds9960_get_gesture_right_offset test */
2684 apds9960_interface_debug_print("apds9960: apds9960_set_gesture_right_offset/apds9960_get_gesture_right_offset test.\n");
2685
2686 offset = -(rand() % 128);
2687 res = apds9960_set_gesture_right_offset(&gs_handle, offset);
2688 if (res != 0)
2689 {
2690 apds9960_interface_debug_print("apds9960: set gesture right offset failed.\n");
2691 (void)apds9960_deinit(&gs_handle);
2692
2693 return 1;
2694 }
2695 apds9960_interface_debug_print("apds9960: set gesture right offset %d.\n", offset);
2696 res = apds9960_get_gesture_right_offset(&gs_handle, (int8_t *)&offset_check);
2697 if (res != 0)
2698 {
2699 apds9960_interface_debug_print("apds9960: get gesture right offset failed.\n");
2700 (void)apds9960_deinit(&gs_handle);
2701
2702 return 1;
2703 }
2704 apds9960_interface_debug_print("apds9960: check gesture right offset %s.\n", offset_check == offset ? "ok" : "error");
2705
2706 /* apds9960_set_gesture_pulse_length/apds9960_get_gesture_pulse_length test */
2707 apds9960_interface_debug_print("apds9960: apds9960_set_gesture_pulse_length/apds9960_get_gesture_pulse_length test.\n");
2708
2709 /* set gesture pulse length 4 us */
2711 if (res != 0)
2712 {
2713 apds9960_interface_debug_print("apds9960: set gesture pulse length failed.\n");
2714 (void)apds9960_deinit(&gs_handle);
2715
2716 return 1;
2717 }
2718 apds9960_interface_debug_print("apds9960: set gesture pulse length 4 us.\n");
2719 res = apds9960_get_gesture_pulse_length(&gs_handle, &gesture_len);
2720 if (res != 0)
2721 {
2722 apds9960_interface_debug_print("apds9960: get gesture pulse length failed.\n");
2723 (void)apds9960_deinit(&gs_handle);
2724
2725 return 1;
2726 }
2727 apds9960_interface_debug_print("apds9960: check gesture pulse length %s.\n", gesture_len == APDS9960_GESTURE_PULSE_LENGTH_4_US ? "ok" : "error");
2728
2729 /* set gesture pulse length 8 us */
2731 if (res != 0)
2732 {
2733 apds9960_interface_debug_print("apds9960: set gesture pulse length failed.\n");
2734 (void)apds9960_deinit(&gs_handle);
2735
2736 return 1;
2737 }
2738 apds9960_interface_debug_print("apds9960: set gesture pulse length 8 us.\n");
2739 res = apds9960_get_gesture_pulse_length(&gs_handle, &gesture_len);
2740 if (res != 0)
2741 {
2742 apds9960_interface_debug_print("apds9960: get gesture pulse length failed.\n");
2743 (void)apds9960_deinit(&gs_handle);
2744
2745 return 1;
2746 }
2747 apds9960_interface_debug_print("apds9960: check gesture pulse length %s.\n", gesture_len == APDS9960_GESTURE_PULSE_LENGTH_8_US ? "ok" : "error");
2748
2749 /* set gesture pulse length 16 us */
2751 if (res != 0)
2752 {
2753 apds9960_interface_debug_print("apds9960: set gesture pulse length failed.\n");
2754 (void)apds9960_deinit(&gs_handle);
2755
2756 return 1;
2757 }
2758 apds9960_interface_debug_print("apds9960: set gesture pulse length 16 us.\n");
2759 res = apds9960_get_gesture_pulse_length(&gs_handle, &gesture_len);
2760 if (res != 0)
2761 {
2762 apds9960_interface_debug_print("apds9960: get gesture pulse length failed.\n");
2763 (void)apds9960_deinit(&gs_handle);
2764
2765 return 1;
2766 }
2767 apds9960_interface_debug_print("apds9960: check gesture pulse length %s.\n", gesture_len == APDS9960_GESTURE_PULSE_LENGTH_16_US ? "ok" : "error");
2768
2769 /* set gesture pulse length 32 us */
2771 if (res != 0)
2772 {
2773 apds9960_interface_debug_print("apds9960: set gesture pulse length failed.\n");
2774 (void)apds9960_deinit(&gs_handle);
2775
2776 return 1;
2777 }
2778 apds9960_interface_debug_print("apds9960: set gesture pulse length 32 us.\n");
2779 res = apds9960_get_gesture_pulse_length(&gs_handle, &gesture_len);
2780 if (res != 0)
2781 {
2782 apds9960_interface_debug_print("apds9960: get gesture pulse length failed.\n");
2783 (void)apds9960_deinit(&gs_handle);
2784
2785 return 1;
2786 }
2787 apds9960_interface_debug_print("apds9960: check gesture pulse length %s.\n", gesture_len == APDS9960_GESTURE_PULSE_LENGTH_32_US ? "ok" : "error");
2788
2789 /* apds9960_set_gesture_pulse_count/apds9960_get_gesture_pulse_count test */
2790 apds9960_interface_debug_print("apds9960: apds9960_set_gesture_pulse_count/apds9960_get_gesture_pulse_count test.\n");
2791
2792 count = rand() % 0x3F;
2793 res = apds9960_set_gesture_pulse_count(&gs_handle, count);
2794 if (res != 0)
2795 {
2796 apds9960_interface_debug_print("apds9960: set gesture pulse count failed.\n");
2797 (void)apds9960_deinit(&gs_handle);
2798
2799 return 1;
2800 }
2801 apds9960_interface_debug_print("apds9960: set gesture pulse count %d.\n", count);
2802 res = apds9960_get_gesture_pulse_count(&gs_handle, (uint16_t *)&count_check);
2803 if (res != 0)
2804 {
2805 apds9960_interface_debug_print("apds9960: get gesture pulse count failed.\n");
2806 (void)apds9960_deinit(&gs_handle);
2807
2808 return 1;
2809 }
2810 apds9960_interface_debug_print("apds9960: check gesture pulse count %s.\n", count_check == count ? "ok" : "error");
2811
2812 /* apds9960_set_gesture_dimension/apds9960_get_gesture_dimension_select test */
2813 apds9960_interface_debug_print("apds9960: apds9960_set_gesture_dimension/apds9960_get_gesture_dimension_select test.\n");
2814
2815 /* set both pairs active */
2817 if (res != 0)
2818 {
2819 apds9960_interface_debug_print("apds9960: set gesture dimension failed.\n");
2820 (void)apds9960_deinit(&gs_handle);
2821
2822 return 1;
2823 }
2824 apds9960_interface_debug_print("apds9960: set both pairs active.\n");
2825 res = apds9960_get_gesture_dimension_select(&gs_handle, &s);
2826 if (res != 0)
2827 {
2828 apds9960_interface_debug_print("apds9960: get gesture dimension failed.\n");
2829 (void)apds9960_deinit(&gs_handle);
2830
2831 return 1;
2832 }
2833 apds9960_interface_debug_print("apds9960: check gesture dimension select %s.\n", s == APDS9960_GESTURE_DIMENSION_SELECT_BOTH_PAIRS_ACTIVE ? "ok" : "error");
2834
2835 /* set only up down pair active */
2837 if (res != 0)
2838 {
2839 apds9960_interface_debug_print("apds9960: set gesture dimension failed.\n");
2840 (void)apds9960_deinit(&gs_handle);
2841
2842 return 1;
2843 }
2844 apds9960_interface_debug_print("apds9960: set only up down pair active.\n");
2845 res = apds9960_get_gesture_dimension_select(&gs_handle, &s);
2846 if (res != 0)
2847 {
2848 apds9960_interface_debug_print("apds9960: get gesture dimension failed.\n");
2849 (void)apds9960_deinit(&gs_handle);
2850
2851 return 1;
2852 }
2853 apds9960_interface_debug_print("apds9960: check gesture dimension select %s.\n", s == APDS9960_GESTURE_DIMENSION_SELECT_ONLY_UP_DOWN_PAIRS_ACTIVE ? "ok" : "error");
2854
2855 /* set only left right pair active */
2857 if (res != 0)
2858 {
2859 apds9960_interface_debug_print("apds9960: set gesture dimension failed.\n");
2860 (void)apds9960_deinit(&gs_handle);
2861
2862 return 1;
2863 }
2864 apds9960_interface_debug_print("apds9960: set only left right pair active.\n");
2865 res = apds9960_get_gesture_dimension_select(&gs_handle, &s);
2866 if (res != 0)
2867 {
2868 apds9960_interface_debug_print("apds9960: get gesture dimension failed.\n");
2869 (void)apds9960_deinit(&gs_handle);
2870
2871 return 1;
2872 }
2873 apds9960_interface_debug_print("apds9960: check gesture dimension select %s.\n", s == APDS9960_GESTURE_DIMENSION_SELECT_ONLY_LEFT_RIGHT_PAIRS_ACTIVE ? "ok" : "error");
2874
2875 /* apds9960_set_gesture_interrupt/apds9960_get_gesture_interrupt test */
2876 apds9960_interface_debug_print("apds9960: apds9960_set_gesture_interrupt/apds9960_get_gesture_interrupt test.\n");
2877
2878 /* enable gesture interrupt */
2880 if (res != 0)
2881 {
2882 apds9960_interface_debug_print("apds9960: set gesture interrupt failed.\n");
2883 (void)apds9960_deinit(&gs_handle);
2884
2885 return 1;
2886 }
2887 apds9960_interface_debug_print("apds9960: enable gesture interrupt.\n");
2888 res = apds9960_get_gesture_interrupt(&gs_handle, &enable);
2889 if (res != 0)
2890 {
2891 apds9960_interface_debug_print("apds9960: get gesture interrupt failed.\n");
2892 (void)apds9960_deinit(&gs_handle);
2893
2894 return 1;
2895 }
2896 apds9960_interface_debug_print("apds9960: check gesture interrupt %s.\n", enable == APDS9960_BOOL_TRUE ? "ok" : "error");
2897
2898 /* disable gesture interrupt */
2900 if (res != 0)
2901 {
2902 apds9960_interface_debug_print("apds9960: set gesture interrupt failed.\n");
2903 (void)apds9960_deinit(&gs_handle);
2904
2905 return 1;
2906 }
2907 apds9960_interface_debug_print("apds9960: disable gesture interrupt.\n");
2908 res = apds9960_get_gesture_interrupt(&gs_handle, &enable);
2909 if (res != 0)
2910 {
2911 apds9960_interface_debug_print("apds9960: get gesture interrupt failed.\n");
2912 (void)apds9960_deinit(&gs_handle);
2913
2914 return 1;
2915 }
2916 apds9960_interface_debug_print("apds9960: check gesture interrupt %s.\n", enable == APDS9960_BOOL_FALSE ? "ok" : "error");
2917
2918 /* apds9960_set_gesture_mode/apds9960_get_gesture_mode test */
2919 apds9960_interface_debug_print("apds9960: apds9960_set_gesture_mode/apds9960_get_gesture_mode test.\n");
2920
2921 /* enable gesture mode */
2923 if (res != 0)
2924 {
2925 apds9960_interface_debug_print("apds9960: set gesture mode failed.\n");
2926 (void)apds9960_deinit(&gs_handle);
2927
2928 return 1;
2929 }
2930 apds9960_interface_debug_print("apds9960: enable gesture mode.\n");
2931 res = apds9960_get_gesture_mode(&gs_handle, &enable);
2932 if (res != 0)
2933 {
2934 apds9960_interface_debug_print("apds9960: get gesture mode failed.\n");
2935 (void)apds9960_deinit(&gs_handle);
2936
2937 return 1;
2938 }
2939 apds9960_interface_debug_print("apds9960: check gesture mode %s.\n", enable == APDS9960_BOOL_TRUE ? "ok" : "error");
2940
2941 /* disable gesture mode */
2943 if (res != 0)
2944 {
2945 apds9960_interface_debug_print("apds9960: set gesture mode failed.\n");
2946 (void)apds9960_deinit(&gs_handle);
2947
2948 return 1;
2949 }
2950 apds9960_interface_debug_print("apds9960: disable gesture mode.\n");
2951 res = apds9960_get_gesture_mode(&gs_handle, &enable);
2952 if (res != 0)
2953 {
2954 apds9960_interface_debug_print("apds9960: get gesture mode failed.\n");
2955 (void)apds9960_deinit(&gs_handle);
2956
2957 return 1;
2958 }
2959 apds9960_interface_debug_print("apds9960: check gesture mode %s.\n", enable == APDS9960_BOOL_FALSE ? "ok" : "error");
2960
2961 /* apds9960_set_gesture_decode_threshold/apds9960_get_gesture_decode_threshold test */
2962 apds9960_interface_debug_print("apds9960: apds9960_set_gesture_decode_threshold/apds9960_get_gesture_decode_threshold test.\n");
2963
2964 reg = rand() % 256;
2965 res = apds9960_set_gesture_decode_threshold(&gs_handle, reg);
2966 if (res != 0)
2967 {
2968 apds9960_interface_debug_print("apds9960: set gesture decode threshold failed.\n");
2969 (void)apds9960_deinit(&gs_handle);
2970
2971 return 1;
2972 }
2973 apds9960_interface_debug_print("apds9960: set gesture decode threshold 0x%02X.\n", reg);
2974 res = apds9960_get_gesture_decode_threshold(&gs_handle, (uint8_t *)&reg_check);
2975 if (res != 0)
2976 {
2977 apds9960_interface_debug_print("apds9960: get gesture decode threshold failed.\n");
2978 (void)apds9960_deinit(&gs_handle);
2979
2980 return 1;
2981 }
2982 apds9960_interface_debug_print("apds9960: check gesture decode threshold %s.\n", reg_check == reg ? "ok" : "error");
2983
2984 /* apds9960_set_gesture_decode_sensitivity_1/apds9960_get_gesture_decode_sensitivity_1 test */
2985 apds9960_interface_debug_print("apds9960: apds9960_set_gesture_decode_sensitivity_1/apds9960_get_gesture_decode_sensitivity_1 test.\n");
2986
2987 sensitivity = rand() % 65536;
2988 res = apds9960_set_gesture_decode_sensitivity_1(&gs_handle, sensitivity);
2989 if (res != 0)
2990 {
2991 apds9960_interface_debug_print("apds9960: set gesture decode sensitivity 1 failed.\n");
2992 (void)apds9960_deinit(&gs_handle);
2993
2994 return 1;
2995 }
2996 apds9960_interface_debug_print("apds9960: set gesture decode sensitivity 1 %d.\n", sensitivity);
2997 res = apds9960_get_gesture_decode_sensitivity_1(&gs_handle, (int32_t *)&sensitivity_check);
2998 if (res != 0)
2999 {
3000 apds9960_interface_debug_print("apds9960: get gesture decode sensitivity 1 failed.\n");
3001 (void)apds9960_deinit(&gs_handle);
3002
3003 return 1;
3004 }
3005 apds9960_interface_debug_print("apds9960: check gesture decode sensitivity %s.\n", sensitivity_check == sensitivity ? "ok" : "error");
3006
3007 /* apds9960_set_gesture_decode_sensitivity_2/apds9960_get_gesture_decode_sensitivity_2 test */
3008 apds9960_interface_debug_print("apds9960: apds9960_set_gesture_decode_sensitivity_2/apds9960_get_gesture_decode_sensitivity_2 test.\n");
3009
3010 sensitivity = rand() % 65536;
3011 res = apds9960_set_gesture_decode_sensitivity_2(&gs_handle, sensitivity);
3012 if (res != 0)
3013 {
3014 apds9960_interface_debug_print("apds9960: set gesture decode sensitivity 2 failed.\n");
3015 (void)apds9960_deinit(&gs_handle);
3016
3017 return 1;
3018 }
3019 apds9960_interface_debug_print("apds9960: set gesture decode sensitivity 2 %d.\n", sensitivity);
3020 res = apds9960_get_gesture_decode_sensitivity_2(&gs_handle, (int32_t *)&sensitivity_check);
3021 if (res != 0)
3022 {
3023 apds9960_interface_debug_print("apds9960: get gesture decode sensitivity 2 failed.\n");
3024 (void)apds9960_deinit(&gs_handle);
3025
3026 return 1;
3027 }
3028 apds9960_interface_debug_print("apds9960: check gesture decode sensitivity %s.\n", sensitivity_check == sensitivity ? "ok" : "error");
3029
3030 /* apds9960_adc_integration_time_convert_to_register/apds9960_adc_integration_time_convert_to_data test */
3031 apds9960_interface_debug_print("apds9960: apds9960_adc_integration_time_convert_to_register/apds9960_adc_integration_time_convert_to_data test.\n");
3032
3033 ms = (float)(rand() % 1000 )/ 10.0f;
3034 res = apds9960_adc_integration_time_convert_to_register(&gs_handle, ms, (uint8_t *)&reg);
3035 if (res != 0)
3036 {
3037 apds9960_interface_debug_print("apds9960: adc integration time convert to register failed.\n");
3038 (void)apds9960_deinit(&gs_handle);
3039
3040 return 1;
3041 }
3042 apds9960_interface_debug_print("apds9960: set adc integration time %0.2f.\n", ms);
3043 res = apds9960_adc_integration_time_convert_to_data(&gs_handle, reg, (float *)&ms_check);
3044 if (res != 0)
3045 {
3046 apds9960_interface_debug_print("apds9960: adc integration time convert to data failed.\n");
3047 (void)apds9960_deinit(&gs_handle);
3048
3049 return 1;
3050 }
3051 apds9960_interface_debug_print("apds9960: check adc integration time %0.2f.\n", ms_check);
3052
3053 /* apds9960_wait_time_convert_to_register/apds9960_wait_time_convert_to_data test */
3054 apds9960_interface_debug_print("apds9960: apds9960_wait_time_convert_to_register/apds9960_wait_time_convert_to_data test.\n");
3055
3056 ms = (float)(rand() % 1000 )/ 10.0f;
3057 res = apds9960_wait_time_convert_to_register(&gs_handle, ms, (uint8_t *)&reg);
3058 if (res != 0)
3059 {
3060 apds9960_interface_debug_print("apds9960: wait time convert to register failed.\n");
3061 (void)apds9960_deinit(&gs_handle);
3062
3063 return 1;
3064 }
3065 apds9960_interface_debug_print("apds9960: set wait time %0.2f.\n", ms);
3066 res = apds9960_wait_time_convert_to_data(&gs_handle, reg, (float *)&ms_check);
3067 if (res != 0)
3068 {
3069 apds9960_interface_debug_print("apds9960: wait time convert to data failed.\n");
3070 (void)apds9960_deinit(&gs_handle);
3071
3072 return 1;
3073 }
3074 apds9960_interface_debug_print("apds9960: check wait time %0.2f.\n", ms_check);
3075
3076 /* apds9960_get_status test */
3077 apds9960_interface_debug_print("apds9960: apds9960_get_status test.\n");
3078
3079 /* get status */
3080 res = apds9960_get_status(&gs_handle, (uint8_t *)&status);
3081 if (res != 0)
3082 {
3083 apds9960_interface_debug_print("apds9960: get status failed.\n");
3084 (void)apds9960_deinit(&gs_handle);
3085
3086 return 1;
3087 }
3088 apds9960_interface_debug_print("apds9960: status is 0x%02X.\n", status);
3089
3090 /* apds9960_get_gesture_fifo_level test */
3091 apds9960_interface_debug_print("apds9960: apds9960_get_gesture_fifo_level test.\n");
3092
3093 /* get gesture fifo level */
3094 res = apds9960_get_gesture_fifo_level(&gs_handle, (uint8_t *)&level);
3095 if (res != 0)
3096 {
3097 apds9960_interface_debug_print("apds9960: get gesture fifo level failed.\n");
3098 (void)apds9960_deinit(&gs_handle);
3099
3100 return 1;
3101 }
3102 apds9960_interface_debug_print("apds9960: fifo level is 0x%02X.\n", level);
3103
3104 /* apds9960_get_gesture_status test */
3105 apds9960_interface_debug_print("apds9960: apds9960_get_gesture_status test.\n");
3106
3107 /* get gesture status */
3108 res = apds9960_get_gesture_status(&gs_handle, (uint8_t *)&status);
3109 if (res != 0)
3110 {
3111 apds9960_interface_debug_print("apds9960: get gesture status failed.\n");
3112 (void)apds9960_deinit(&gs_handle);
3113
3114 return 1;
3115 }
3116 apds9960_interface_debug_print("apds9960: gesture status is 0x%02X.\n", status);
3117
3118 /* apds9960_gesture_fifo_clear test */
3119 apds9960_interface_debug_print("apds9960: apds9960_gesture_fifo_clear test.\n");
3120
3121 /* gesture fifo clear */
3122 res = apds9960_gesture_fifo_clear(&gs_handle);
3123 if (res != 0)
3124 {
3125 apds9960_interface_debug_print("apds9960: gesture fifo clear failed.\n");
3126 (void)apds9960_deinit(&gs_handle);
3127
3128 return 1;
3129 }
3130 apds9960_interface_debug_print("apds9960: check gesture fifo clear %s.\n", res == 0 ? "ok" : "error");
3131
3132 /* apds9960_force_interrupt test */
3133 apds9960_interface_debug_print("apds9960: apds9960_force_interrupt test.\n");
3134
3135 /* force interrupt */
3136 res = apds9960_force_interrupt(&gs_handle);
3137 if (res != 0)
3138 {
3139 apds9960_interface_debug_print("apds9960: force interrupt failed.\n");
3140 (void)apds9960_deinit(&gs_handle);
3141
3142 return 1;
3143 }
3144 apds9960_interface_debug_print("apds9960: check force interrupt %s.\n", res == 0 ? "ok" : "error");
3145
3146 /* apds9960_proximity_interrupt_clear test */
3147 apds9960_interface_debug_print("apds9960: apds9960_proximity_interrupt_clear test.\n");
3148
3149 /* proximity interrupt clear */
3150 res = apds9960_proximity_interrupt_clear(&gs_handle);
3151 if (res != 0)
3152 {
3153 apds9960_interface_debug_print("apds9960: proximity interrupt clear failed.\n");
3154 (void)apds9960_deinit(&gs_handle);
3155
3156 return 1;
3157 }
3158 apds9960_interface_debug_print("apds9960: check proximity interrupt clear %s.\n", res == 0 ? "ok" : "error");
3159
3160 /* apds9960_als_interrupt_clear test */
3161 apds9960_interface_debug_print("apds9960: apds9960_als_interrupt_clear test.\n");
3162
3163 /* als interrupt clear */
3164 res = apds9960_als_interrupt_clear(&gs_handle);
3165 if (res != 0)
3166 {
3167 apds9960_interface_debug_print("apds9960: als interrupt clear failed.\n");
3168 (void)apds9960_deinit(&gs_handle);
3169
3170 return 1;
3171 }
3172 apds9960_interface_debug_print("apds9960: check als interrupt clear %s.\n", res == 0 ? "ok" : "error");
3173
3174 /* apds9960_all_non_gesture_interrupt_clear test */
3175 apds9960_interface_debug_print("apds9960: apds9960_all_non_gesture_interrupt_clear test.\n");
3176
3177 /* all non gesture interrupt clear */
3179 if (res != 0)
3180 {
3181 apds9960_interface_debug_print("apds9960: all non gesture interrupt clear failed.\n");
3182 (void)apds9960_deinit(&gs_handle);
3183
3184 return 1;
3185 }
3186 apds9960_interface_debug_print("apds9960: check all non gesture interrupt clear %s.\n", res == 0 ? "ok" : "error");
3187
3188 /* finish register test */
3189 apds9960_interface_debug_print("apds9960: finish register test.\n");
3190 (void)apds9960_deinit(&gs_handle);
3191
3192 return 0;
3193}
driver apds9960 register test header file
uint8_t apds9960_get_proximity_interrupt_high_threshold(apds9960_handle_t *handle, uint8_t *threshold)
get the proximity interrupt high threshold
uint8_t apds9960_set_gesture_dimension(apds9960_handle_t *handle, apds9960_gesture_dimension_select_t s)
set the gesture dimension
apds9960_led_boost_t
apds9960 led boost enumeration definition
uint8_t apds9960_set_gesture_gain(apds9960_handle_t *handle, apds9960_gesture_gain_control_t gain)
set the gesture gain
uint8_t apds9960_set_gesture_decode_sensitivity_2(apds9960_handle_t *handle, int32_t sensitivity)
set the gesture decode sensitivity 2
uint8_t apds9960_get_als_interrupt_high_threshold(apds9960_handle_t *handle, uint16_t *threshold)
get the als interrupt high threshold
uint8_t apds9960_set_als_interrupt_high_threshold(apds9960_handle_t *handle, uint16_t threshold)
set the als interrupt high threshold
uint8_t apds9960_deinit(apds9960_handle_t *handle)
close the chip
uint8_t apds9960_set_gesture_wait_time(apds9960_handle_t *handle, apds9960_gesture_wait_time_t t)
set the gesture wait time
apds9960_gesture_led_current_t
apds9960 gesture led current enumeration definition
uint8_t apds9960_get_led_current(apds9960_handle_t *handle, apds9960_led_current_t *current)
get the led current
uint8_t apds9960_set_gesture_exit_persistence(apds9960_handle_t *handle, apds9960_gesture_exit_persistence_t persistence)
set the gesture exit persistence
uint8_t apds9960_get_gesture_led_current(apds9960_handle_t *handle, apds9960_gesture_led_current_t *current)
get the gesture led current
uint8_t apds9960_get_conf(apds9960_handle_t *handle, apds9960_conf_t conf, apds9960_bool_t *enable)
get the configuration
uint8_t apds9960_set_proximity_pulse_length(apds9960_handle_t *handle, apds9960_proximity_pulse_length_t len)
set the proximity pulse length
uint8_t apds9960_adc_integration_time_convert_to_data(apds9960_handle_t *handle, uint8_t reg, float *ms)
convert the register raw data to the integration time
uint8_t apds9960_get_gesture_up_offset(apds9960_handle_t *handle, int8_t *offset)
get the gesture up offset
uint8_t apds9960_get_proximity_pulse_count(apds9960_handle_t *handle, uint16_t *count)
get the proximity pulse count
uint8_t apds9960_get_gesture_exit_mask(apds9960_handle_t *handle, uint8_t *mask)
get the gesture exit mask
uint8_t apds9960_get_gesture_decode_threshold(apds9960_handle_t *handle, uint8_t *threshold)
get the gesture decode threshold
uint8_t apds9960_get_proximity_down_left_offset(apds9960_handle_t *handle, int8_t *offset)
get the proximity down left offset
apds9960_proximity_interrupt_cycle_t
apds9960 proximity interrupt cycle enumeration definition
uint8_t apds9960_set_saturation_interrupt(apds9960_handle_t *handle, apds9960_saturation_interrupt_t saturation, apds9960_bool_t enable)
set the saturation interrupt
uint8_t apds9960_set_proximity_down_left_offset(apds9960_handle_t *handle, int8_t offset)
set the proximity down left offset
uint8_t apds9960_set_als_interrupt_cycle(apds9960_handle_t *handle, apds9960_als_interrupt_cycle_t cycle)
set the als interrupt cycle
uint8_t apds9960_get_gesture_gain(apds9960_handle_t *handle, apds9960_gesture_gain_control_t *gain)
get the gesture gain
uint8_t apds9960_get_gesture_status(apds9960_handle_t *handle, uint8_t *status)
get the gesture status
uint8_t apds9960_gesture_fifo_clear(apds9960_handle_t *handle)
clear the gesture fifo status
apds9960_proximity_gain_t
apds9960 proximity gain enumeration definition
uint8_t apds9960_get_proximity_interrupt_cycle(apds9960_handle_t *handle, apds9960_proximity_interrupt_cycle_t *cycle)
get the proximity interrupt cycle
uint8_t apds9960_wait_time_convert_to_register(apds9960_handle_t *handle, float ms, uint8_t *reg)
convert the wait time to the register raw data
uint8_t apds9960_get_proximity_gain(apds9960_handle_t *handle, apds9960_proximity_gain_t *gain)
get the proximity gain
apds9960_gesture_dimension_select_t
apds9960 gesture dimension select enumeration definition
uint8_t apds9960_set_proximity_gain(apds9960_handle_t *handle, apds9960_proximity_gain_t gain)
set the proximity gain
uint8_t apds9960_adc_integration_time_convert_to_register(apds9960_handle_t *handle, float ms, uint8_t *reg)
convert the adc integration time to the register raw data
uint8_t apds9960_init(apds9960_handle_t *handle)
initialize the chip
uint8_t apds9960_set_proximity_interrupt_cycle(apds9960_handle_t *handle, apds9960_proximity_interrupt_cycle_t cycle)
set the proximity interrupt cycle
uint8_t apds9960_set_gesture_right_offset(apds9960_handle_t *handle, int8_t offset)
set the gesture right offset
uint8_t apds9960_get_saturation_interrupt(apds9960_handle_t *handle, apds9960_saturation_interrupt_t saturation, apds9960_bool_t *enable)
get the saturation interrupt
uint8_t apds9960_set_gesture_fifo_threshold(apds9960_handle_t *handle, apds9960_gesture_fifo_threshold_t threshold)
set the gesture fifo threshold
uint8_t apds9960_set_proximity_pulse_count(apds9960_handle_t *handle, uint16_t count)
set the proximity pulse count
uint8_t apds9960_set_proximity_up_right_offset(apds9960_handle_t *handle, int8_t offset)
set the proximity up right offset
uint8_t apds9960_set_gesture_pulse_length(apds9960_handle_t *handle, apds9960_gesture_pulse_length_t len)
set the gesture pulse length
uint8_t apds9960_set_proximity_gain_compensation(apds9960_handle_t *handle, apds9960_bool_t enable)
enable or disable the proximity gain compensation
uint8_t apds9960_get_als_interrupt_cycle(apds9960_handle_t *handle, apds9960_als_interrupt_cycle_t *cycle)
get the als interrupt cycle
uint8_t apds9960_set_gesture_led_current(apds9960_handle_t *handle, apds9960_gesture_led_current_t current)
set the gesture led current
uint8_t apds9960_get_gesture_pulse_length(apds9960_handle_t *handle, apds9960_gesture_pulse_length_t *len)
get the gesture pulse length
uint8_t apds9960_force_interrupt(apds9960_handle_t *handle)
force an interrupt
uint8_t apds9960_get_gesture_dimension_select(apds9960_handle_t *handle, apds9960_gesture_dimension_select_t *s)
get the gesture dimension
apds9960_gesture_pulse_length_t
apds9960 gesture pulse length enumeration definition
uint8_t apds9960_get_proximity_pulse_length(apds9960_handle_t *handle, apds9960_proximity_pulse_length_t *len)
get the proximity pulse length
uint8_t apds9960_get_gesture_proximity_exit_threshold(apds9960_handle_t *handle, uint8_t *threshold)
get the gesture proximity exit threshold
uint8_t apds9960_get_als_interrupt_low_threshold(apds9960_handle_t *handle, uint16_t *threshold)
get the als interrupt low threshold
uint8_t apds9960_set_gesture_pulse_count(apds9960_handle_t *handle, uint16_t count)
set the gesture pulse count
uint8_t apds9960_wait_time_convert_to_data(apds9960_handle_t *handle, uint8_t reg, float *ms)
convert the register raw data to the wait time
uint8_t apds9960_get_gesture_exit_persistence(apds9960_handle_t *handle, apds9960_gesture_exit_persistence_t *persistence)
get the gesture exit persistence
uint8_t apds9960_set_wait_long(apds9960_handle_t *handle, apds9960_bool_t enable)
enable or disable the wait long
apds9960_gesture_wait_time_t
apds9960 gesture wait time enumeration definition
uint8_t apds9960_set_gesture_exit_mask(apds9960_handle_t *handle, uint8_t mask)
set the gesture exit mask
apds9960_bool_t
apds9960 bool enumeration definition
uint8_t apds9960_set_als_color_gain(apds9960_handle_t *handle, apds9960_als_color_gain_t gain)
set the als color gain
uint8_t apds9960_get_status(apds9960_handle_t *handle, uint8_t *status)
get the status
uint8_t apds9960_set_gesture_proximity_enter_threshold(apds9960_handle_t *handle, uint8_t threshold)
set the gesture proximity enter threshold
struct apds9960_info_s apds9960_info_t
apds9960 information structure definition
uint8_t apds9960_get_gesture_down_offset(apds9960_handle_t *handle, int8_t *offset)
get the gesture down offset
uint8_t apds9960_get_proximity_up_right_offset(apds9960_handle_t *handle, int8_t *offset)
get the proximity up right offset
uint8_t apds9960_set_gesture_mode(apds9960_handle_t *handle, apds9960_bool_t enable)
enable or disable the gesture mode
uint8_t apds9960_get_led_boost(apds9960_handle_t *handle, apds9960_led_boost_t *boost)
get the led boost
uint8_t apds9960_set_led_boost(apds9960_handle_t *handle, apds9960_led_boost_t boost)
set the led boost
struct apds9960_handle_s apds9960_handle_t
apds9960 handle structure definition
uint8_t apds9960_get_wait_long(apds9960_handle_t *handle, apds9960_bool_t *enable)
get the wait long status
uint8_t apds9960_get_gesture_right_offset(apds9960_handle_t *handle, int8_t *offset)
get the gesture right offset
uint8_t apds9960_set_sleep_after_interrupt(apds9960_handle_t *handle, apds9960_bool_t enable)
enable or disable sleeping after interrupt
uint8_t apds9960_get_wait_time(apds9960_handle_t *handle, uint8_t *wait_time)
get the wait time
uint8_t apds9960_all_non_gesture_interrupt_clear(apds9960_handle_t *handle)
clear the all not gesture interrupt
uint8_t apds9960_als_interrupt_clear(apds9960_handle_t *handle)
clear the als interrupt
uint8_t apds9960_set_conf(apds9960_handle_t *handle, apds9960_conf_t conf, apds9960_bool_t enable)
set the configuration
uint8_t apds9960_set_als_interrupt_low_threshold(apds9960_handle_t *handle, uint16_t threshold)
set the als interrupt low threshold
uint8_t apds9960_get_als_color_gain(apds9960_handle_t *handle, apds9960_als_color_gain_t *gain)
get the als color gain
uint8_t apds9960_set_gesture_up_offset(apds9960_handle_t *handle, int8_t offset)
set the gesture up offset
uint8_t apds9960_set_gesture_interrupt(apds9960_handle_t *handle, apds9960_bool_t enable)
enable or disable the gesture interrupt
apds9960_gesture_exit_persistence_t
apds9960 gesture exit persistence enumeration definition
uint8_t apds9960_get_adc_integration_time(apds9960_handle_t *handle, uint8_t *integration_time)
get the adc integration time
uint8_t apds9960_set_proximity_interrupt_low_threshold(apds9960_handle_t *handle, uint8_t threshold)
set the proximity interrupt low threshold
uint8_t apds9960_get_gesture_mode(apds9960_handle_t *handle, apds9960_bool_t *enable)
get the gesture mode status
apds9960_als_interrupt_cycle_t
apds9960 als interrupt cycle enumeration definition
uint8_t apds9960_get_proximity_gain_compensation(apds9960_handle_t *handle, apds9960_bool_t *enable)
get the proximity gain compensation status
apds9960_gesture_gain_control_t
apds9960 gesture gain control enumeration definition
uint8_t apds9960_set_gesture_left_offset(apds9960_handle_t *handle, int8_t offset)
set the gesture left offset
uint8_t apds9960_set_adc_integration_time(apds9960_handle_t *handle, uint8_t integration_time)
set the adc integration time
uint8_t apds9960_get_proximity_mask(apds9960_handle_t *handle, apds9960_proximity_mask_t mask, apds9960_bool_t *enable)
get the proximity mask status
uint8_t apds9960_get_proximity_interrupt_low_threshold(apds9960_handle_t *handle, uint8_t *threshold)
get the proximity interrupt low threshold
uint8_t apds9960_set_gesture_decode_threshold(apds9960_handle_t *handle, uint8_t threshold)
set the gesture decode threshold
uint8_t apds9960_get_gesture_decode_sensitivity_2(apds9960_handle_t *handle, int32_t *sensitivity)
get the gesture decode sensitivity 2
uint8_t apds9960_set_led_current(apds9960_handle_t *handle, apds9960_led_current_t current)
set the led current
uint8_t apds9960_get_gesture_fifo_threshold(apds9960_handle_t *handle, apds9960_gesture_fifo_threshold_t *threshold)
get the gesture fifo threshold
uint8_t apds9960_get_gesture_decode_sensitivity_1(apds9960_handle_t *handle, int32_t *sensitivity)
get the gesture decode sensitivity 1
uint8_t apds9960_set_proximity_interrupt_high_threshold(apds9960_handle_t *handle, uint8_t threshold)
set the proximity interrupt high threshold
uint8_t apds9960_get_gesture_proximity_enter_threshold(apds9960_handle_t *handle, uint8_t *threshold)
get the gesture proximity enter threshold
uint8_t apds9960_proximity_interrupt_clear(apds9960_handle_t *handle)
clear the proximity interrupt
uint8_t apds9960_get_gesture_left_offset(apds9960_handle_t *handle, int8_t *offset)
get the gesture left offset
uint8_t apds9960_set_wait_time(apds9960_handle_t *handle, uint8_t wait_time)
set the wait time
uint8_t apds9960_set_gesture_proximity_exit_threshold(apds9960_handle_t *handle, uint8_t threshold)
set the gesture proximity exit threshold
apds9960_proximity_pulse_length_t
apds9960 proximity pulse length enumeration definition
uint8_t apds9960_get_gesture_wait_time(apds9960_handle_t *handle, apds9960_gesture_wait_time_t *t)
get the gesture wait time
apds9960_led_current_t
apds9960 led current enumeration definition
uint8_t apds9960_set_proximity_mask(apds9960_handle_t *handle, apds9960_proximity_mask_t mask, apds9960_bool_t enable)
enable or disable the proximity mask
uint8_t apds9960_info(apds9960_info_t *info)
get chip's information
apds9960_als_color_gain_t
apds9960 als and color gain enumeration definition
uint8_t apds9960_get_gesture_fifo_level(apds9960_handle_t *handle, uint8_t *level)
get the gesture fifo level
apds9960_gesture_fifo_threshold_t
apds9960 gesture fifo threshold enumeration definition
uint8_t apds9960_get_gesture_pulse_count(apds9960_handle_t *handle, uint16_t *count)
get the gesture pulse count
uint8_t apds9960_set_gesture_decode_sensitivity_1(apds9960_handle_t *handle, int32_t sensitivity)
set the gesture decode sensitivity 1
uint8_t apds9960_get_sleep_after_interrupt(apds9960_handle_t *handle, apds9960_bool_t *enable)
get the sleeping after interrupt status
uint8_t apds9960_set_gesture_down_offset(apds9960_handle_t *handle, int8_t offset)
set the gesture down offset
uint8_t apds9960_get_gesture_interrupt(apds9960_handle_t *handle, apds9960_bool_t *enable)
get the gesture interrupt status
@ APDS9960_LED_BOOST_200_PERCENTAGE
@ APDS9960_LED_BOOST_150_PERCENTAGE
@ APDS9960_LED_BOOST_300_PERCENTAGE
@ APDS9960_LED_BOOST_100_PERCENTAGE
@ APDS9960_GESTURE_LED_CURRENT_25_MA
@ APDS9960_GESTURE_LED_CURRENT_100_MA
@ APDS9960_GESTURE_LED_CURRENT_12P5_MA
@ APDS9960_GESTURE_LED_CURRENT_50_MA
@ APDS9960_PROXIMITY_INTERRUPT_CYCLE_7
@ APDS9960_PROXIMITY_INTERRUPT_CYCLE_14
@ APDS9960_PROXIMITY_INTERRUPT_CYCLE_8
@ APDS9960_PROXIMITY_INTERRUPT_CYCLE_EVERY
@ APDS9960_PROXIMITY_INTERRUPT_CYCLE_15
@ APDS9960_PROXIMITY_INTERRUPT_CYCLE_3
@ APDS9960_PROXIMITY_INTERRUPT_CYCLE_10
@ APDS9960_PROXIMITY_INTERRUPT_CYCLE_11
@ APDS9960_PROXIMITY_INTERRUPT_CYCLE_5
@ APDS9960_PROXIMITY_INTERRUPT_CYCLE_9
@ APDS9960_PROXIMITY_INTERRUPT_CYCLE_ANY
@ APDS9960_PROXIMITY_INTERRUPT_CYCLE_4
@ APDS9960_PROXIMITY_INTERRUPT_CYCLE_6
@ APDS9960_PROXIMITY_INTERRUPT_CYCLE_12
@ APDS9960_PROXIMITY_INTERRUPT_CYCLE_2
@ APDS9960_PROXIMITY_INTERRUPT_CYCLE_13
@ APDS9960_PROXIMITY_GAIN_8X
@ APDS9960_PROXIMITY_GAIN_1X
@ APDS9960_PROXIMITY_GAIN_2X
@ APDS9960_PROXIMITY_GAIN_4X
@ APDS9960_GESTURE_DIMENSION_SELECT_ONLY_UP_DOWN_PAIRS_ACTIVE
@ APDS9960_GESTURE_DIMENSION_SELECT_ONLY_LEFT_RIGHT_PAIRS_ACTIVE
@ APDS9960_GESTURE_DIMENSION_SELECT_BOTH_PAIRS_ACTIVE
@ APDS9960_GESTURE_PULSE_LENGTH_4_US
@ APDS9960_GESTURE_PULSE_LENGTH_32_US
@ APDS9960_GESTURE_PULSE_LENGTH_16_US
@ APDS9960_GESTURE_PULSE_LENGTH_8_US
@ APDS9960_GESTURE_WAIT_TIME_0_MS
@ APDS9960_GESTURE_WAIT_TIME_5P6_MS
@ APDS9960_GESTURE_WAIT_TIME_8P4_MS
@ APDS9960_GESTURE_WAIT_TIME_22P4_MS
@ APDS9960_GESTURE_WAIT_TIME_2P8_MS
@ APDS9960_GESTURE_WAIT_TIME_39P2_MS
@ APDS9960_GESTURE_WAIT_TIME_30P8_MS
@ APDS9960_GESTURE_WAIT_TIME_14_MS
@ APDS9960_BOOL_FALSE
@ APDS9960_BOOL_TRUE
@ APDS9960_PROXIMITY_MASK_RIGHT
@ APDS9960_PROXIMITY_MASK_DOWN
@ APDS9960_PROXIMITY_MASK_UP
@ APDS9960_PROXIMITY_MASK_LEFT
@ APDS9960_GESTURE_EXIT_PERSISTENCE_1ST
@ APDS9960_GESTURE_EXIT_PERSISTENCE_2ND
@ APDS9960_GESTURE_EXIT_PERSISTENCE_7TH
@ APDS9960_GESTURE_EXIT_PERSISTENCE_4TH
@ APDS9960_ALS_INTERRUPT_CYCLE_25
@ APDS9960_ALS_INTERRUPT_CYCLE_35
@ APDS9960_ALS_INTERRUPT_CYCLE_2
@ APDS9960_ALS_INTERRUPT_CYCLE_55
@ APDS9960_ALS_INTERRUPT_CYCLE_10
@ APDS9960_ALS_INTERRUPT_CYCLE_EVERY
@ APDS9960_ALS_INTERRUPT_CYCLE_15
@ APDS9960_ALS_INTERRUPT_CYCLE_ANY
@ APDS9960_ALS_INTERRUPT_CYCLE_5
@ APDS9960_ALS_INTERRUPT_CYCLE_40
@ APDS9960_ALS_INTERRUPT_CYCLE_20
@ APDS9960_ALS_INTERRUPT_CYCLE_50
@ APDS9960_ALS_INTERRUPT_CYCLE_45
@ APDS9960_ALS_INTERRUPT_CYCLE_30
@ APDS9960_ALS_INTERRUPT_CYCLE_3
@ APDS9960_ALS_INTERRUPT_CYCLE_60
@ APDS9960_GESTURE_GAIN_4X
@ APDS9960_GESTURE_GAIN_8X
@ APDS9960_GESTURE_GAIN_1X
@ APDS9960_GESTURE_GAIN_2X
@ APDS9960_SATURATION_INTERRUPT_PROXIMITY
@ APDS9960_CONF_WAIT_ENABLE
@ APDS9960_CONF_ALS_ENABLE
@ APDS9960_CONF_PROXIMITY_DETECT_ENABLE
@ APDS9960_CONF_GESTURE_ENABLE
@ APDS9960_CONF_PROXIMITY_INTERRUPT_ENABLE
@ APDS9960_CONF_ALS_INTERRUPT_ENABLE
@ APDS9960_CONF_POWER_ON
@ APDS9960_PROXIMITY_PULSE_LENGTH_4_US
@ APDS9960_PROXIMITY_PULSE_LENGTH_16_US
@ APDS9960_PROXIMITY_PULSE_LENGTH_32_US
@ APDS9960_PROXIMITY_PULSE_LENGTH_8_US
@ APDS9960_LED_CURRENT_12P5_MA
@ APDS9960_LED_CURRENT_50_MA
@ APDS9960_LED_CURRENT_25_MA
@ APDS9960_LED_CURRENT_100_MA
@ APDS9960_ALS_COLOR_GAIN_4X
@ APDS9960_ALS_COLOR_GAIN_64X
@ APDS9960_ALS_COLOR_GAIN_16X
@ APDS9960_ALS_COLOR_GAIN_1X
@ APDS9960_GESTURE_FIFO_THRESHOLD_8_DATASET
@ APDS9960_GESTURE_FIFO_THRESHOLD_1_DATASET
@ APDS9960_GESTURE_FIFO_THRESHOLD_4_DATASET
@ APDS9960_GESTURE_FIFO_THRESHOLD_16_DATASET
uint8_t apds9960_interface_iic_init(void)
interface iic bus init
uint8_t apds9960_interface_iic_write(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus write
void apds9960_interface_receive_callback(uint8_t type)
interface receive callback
void apds9960_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t apds9960_interface_iic_deinit(void)
interface iic bus deinit
uint8_t apds9960_interface_iic_read(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus read
void apds9960_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t apds9960_register_test(void)
register test
char manufacturer_name[32]