LibDriver APDS9960
Loading...
Searching...
No Matches
driver_apds9960_interrupt_test.c
Go to the documentation of this file.
1
36
38
39static apds9960_handle_t gs_handle;
40static volatile uint8_t gs_flag;
41
50{
51 if (apds9960_irq_handler(&gs_handle) != 0)
52 {
53 return 1;
54 }
55 else
56 {
57 return 0;
58 }
59}
60
66static void a_callback(uint8_t type)
67{
68 switch (type)
69 {
71 {
72 apds9960_interface_debug_print("apds9960: irq gesture left.\n");
73
74 break;
75 }
77 {
78 apds9960_interface_debug_print("apds9960: irq gesture right.\n");
79
80 break;
81 }
83 {
84 apds9960_interface_debug_print("apds9960: irq gesture up.\n");
85
86 break;
87 }
89 {
90 apds9960_interface_debug_print("apds9960: irq gesture down.\n");
91
92 break;
93 }
95 {
96 apds9960_interface_debug_print("apds9960: irq gesture near.\n");
97
98 break;
99 }
101 {
102 apds9960_interface_debug_print("apds9960: irq gesture far.\n");
103
104 break;
105 }
107 {
108 apds9960_interface_debug_print("apds9960: irq gesture fifo overflow.\n");
109
110 break;
111 }
113 {
114 apds9960_interface_debug_print("apds9960: irq gesture fifo data.\n");
115
116 break;
117 }
119 {
120 apds9960_interface_debug_print("apds9960: irq clear photo diode saturation.\n");
121
122 break;
123 }
125 {
126 apds9960_interface_debug_print("apds9960: irq analog saturation.\n");
127
128 break;
129 }
131 {
132 uint8_t res;
133 uint8_t proximity;
134
135 /* read proximity */
136 proximity = 0;
137 res = apds9960_read_proximity(&gs_handle, (uint8_t *)&proximity);
138 if (res != 0)
139 {
140 apds9960_interface_debug_print("apds9960: read proximity failed.\n");
141 }
142 apds9960_interface_debug_print("apds9960: proximity is 0x%02X.\n", proximity);
143 gs_flag = 1;
144
145 break;
146 }
148 {
149 uint8_t res;
150 uint16_t red, green, blue, clear;
151
152 /* read rgbc */
153 red = 0;
154 green = 0;
155 blue = 0;
156 clear = 0;
157 res = apds9960_read_rgbc(&gs_handle, (uint16_t *)&red, (uint16_t *)&green, (uint16_t *)&blue, (uint16_t *)&clear);
158 if (res != 0)
159 {
160 apds9960_interface_debug_print("apds9960: read rgbc failed.\n");
161 }
162 /* output */
163 apds9960_interface_debug_print("apds9960: red is 0x%04X.\n", red);
164 apds9960_interface_debug_print("apds9960: green is 0x%04X.\n", green);
165 apds9960_interface_debug_print("apds9960: blue is 0x%04X.\n", blue);
166 apds9960_interface_debug_print("apds9960: clear is 0x%04X.\n", clear);
167 gs_flag = 1;
168
169 break;
170 }
172 {
173 apds9960_interface_debug_print("apds9960: irq gesture interrupt.\n");
174
175 break;
176 }
178 {
179 break;
180 }
182 {
183 break;
184 }
185 default :
186 {
187 apds9960_interface_debug_print("apds9960: irq unknown.\n");
188
189 break;
190 }
191 }
192}
193
206uint8_t apds9960_interrupt_test(uint32_t times, uint16_t als_low_threshold, uint16_t als_high_threshold,
207 uint8_t proximity_low_threshold, uint8_t proximity_high_threshold)
208{
209 uint8_t res;
210 uint8_t reg;
211 uint32_t i;
212 apds9960_info_t info;
213
214 /* link interface function */
222 DRIVER_APDS9960_LINK_RECEIVE_CALLBACK(&gs_handle, a_callback);
223
224 /* get information */
225 res = apds9960_info(&info);
226 if (res != 0)
227 {
228 apds9960_interface_debug_print("apds9960: get info failed.\n");
229
230 return 1;
231 }
232 else
233 {
234 /* print chip info */
235 apds9960_interface_debug_print("apds9960: chip is %s.\n", info.chip_name);
236 apds9960_interface_debug_print("apds9960: manufacturer is %s.\n", info.manufacturer_name);
237 apds9960_interface_debug_print("apds9960: interface is %s.\n", info.interface);
238 apds9960_interface_debug_print("apds9960: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
239 apds9960_interface_debug_print("apds9960: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
240 apds9960_interface_debug_print("apds9960: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
241 apds9960_interface_debug_print("apds9960: max current is %0.2fmA.\n", info.max_current_ma);
242 apds9960_interface_debug_print("apds9960: max temperature is %0.1fC.\n", info.temperature_max);
243 apds9960_interface_debug_print("apds9960: min temperature is %0.1fC.\n", info.temperature_min);
244 }
245
246 /* start interrupt test */
247 apds9960_interface_debug_print("apds9960: start interrupt test.\n");
248
249 /* init the apds9960 */
250 res = apds9960_init(&gs_handle);
251 if (res != 0)
252 {
253 apds9960_interface_debug_print("apds9960: init failed.\n");
254
255 return 1;
256 }
257
258 /* power on */
260 if (res != 0)
261 {
262 apds9960_interface_debug_print("apds9960: set conf failed.\n");
263 (void)apds9960_deinit(&gs_handle);
264
265 return 1;
266 }
267
268 /* disable wait time */
270 if (res != 0)
271 {
272 apds9960_interface_debug_print("apds9960: set conf failed.\n");
273 (void)apds9960_deinit(&gs_handle);
274
275 return 1;
276 }
277
278 /* disable proximity detect */
280 if (res != 0)
281 {
282 apds9960_interface_debug_print("apds9960: set conf failed.\n");
283 (void)apds9960_deinit(&gs_handle);
284
285 return 1;
286 }
287
288 /* disable als */
290 if (res != 0)
291 {
292 apds9960_interface_debug_print("apds9960: set conf failed.\n");
293 (void)apds9960_deinit(&gs_handle);
294
295 return 1;
296 }
297
298 /* disable als interrupt */
300 if (res != 0)
301 {
302 apds9960_interface_debug_print("apds9960: set conf failed.\n");
303 (void)apds9960_deinit(&gs_handle);
304
305 return 1;
306 }
307
308 /* disable proximity interrupt */
310 if (res != 0)
311 {
312 apds9960_interface_debug_print("apds9960: set conf failed.\n");
313 (void)apds9960_deinit(&gs_handle);
314
315 return 1;
316 }
317
318 /* disable gesture */
320 if (res != 0)
321 {
322 apds9960_interface_debug_print("apds9960: set conf failed.\n");
323 (void)apds9960_deinit(&gs_handle);
324
325 return 1;
326 }
327
328 /* convert adc integration time */
329 res = apds9960_adc_integration_time_convert_to_register(&gs_handle, 103.0f, (uint8_t *)&reg);
330 if (res != 0)
331 {
332 apds9960_interface_debug_print("apds9960: adc integration time convert to register failed.\n");
333 (void)apds9960_deinit(&gs_handle);
334
335 return 1;
336 }
337
338 /* set adc integration time */
339 res = apds9960_set_adc_integration_time(&gs_handle, reg);
340 if (res != 0)
341 {
342 apds9960_interface_debug_print("apds9960: set adc integration time failed.\n");
343 (void)apds9960_deinit(&gs_handle);
344
345 return 1;
346 }
347
348 /* disable wait long */
350 if (res != 0)
351 {
352 apds9960_interface_debug_print("apds9960: set wait long failed.\n");
353 (void)apds9960_deinit(&gs_handle);
354
355 return 1;
356 }
357
358 /* wait time convert to register */
359 res = apds9960_wait_time_convert_to_register(&gs_handle, 10.0f, (uint8_t *)&reg);
360 if (res != 0)
361 {
362 apds9960_interface_debug_print("apds9960: wait time convert to register failed.\n");
363 (void)apds9960_deinit(&gs_handle);
364
365 return 1;
366 }
367
368 /* set wait time */
369 res = apds9960_set_wait_time(&gs_handle, reg);
370 if (res != 0)
371 {
372 apds9960_interface_debug_print("apds9960: set wait time failed.\n");
373 (void)apds9960_deinit(&gs_handle);
374
375 return 1;
376 }
377
378 /* set als interrupt low threshold */
379 res = apds9960_set_als_interrupt_low_threshold(&gs_handle, als_low_threshold);
380 if (res != 0)
381 {
382 apds9960_interface_debug_print("apds9960: set als interrupt low threshold failed.\n");
383 (void)apds9960_deinit(&gs_handle);
384
385 return 1;
386 }
387
388 /* set als interrupt high threshold */
389 res = apds9960_set_als_interrupt_high_threshold(&gs_handle, als_high_threshold);
390 if (res != 0)
391 {
392 apds9960_interface_debug_print("apds9960: set als interrupt high threshold failed.\n");
393 (void)apds9960_deinit(&gs_handle);
394
395 return 1;
396 }
397
398 /* set proximity interrupt low threshold */
399 res = apds9960_set_proximity_interrupt_low_threshold(&gs_handle, proximity_low_threshold);
400 if (res != 0)
401 {
402 apds9960_interface_debug_print("apds9960: set proximity interrupt low threshold failed.\n");
403 (void)apds9960_deinit(&gs_handle);
404
405 return 1;
406 }
407
408 /* set proximity interrupt high threshold */
409 res = apds9960_set_proximity_interrupt_high_threshold(&gs_handle, proximity_high_threshold);
410 if (res != 0)
411 {
412 apds9960_interface_debug_print("apds9960: set proximity interrupt high threshold failed.\n");
413 (void)apds9960_deinit(&gs_handle);
414
415 return 1;
416 }
417
418 /* proximity interrupt cycle 2 */
420 if (res != 0)
421 {
422 apds9960_interface_debug_print("apds9960: set proximity interrupt cycle failed.\n");
423 (void)apds9960_deinit(&gs_handle);
424
425 return 1;
426 }
427
428 /* als interrupt cycle 2 */
430 if (res != 0)
431 {
432 apds9960_interface_debug_print("apds9960: set als interrupt cycle failed.\n");
433 (void)apds9960_deinit(&gs_handle);
434
435 return 1;
436 }
437
438 /* set proximity pulse length */
440 if (res != 0)
441 {
442 apds9960_interface_debug_print("apds9960: set proximity pulse length failed.\n");
443 (void)apds9960_deinit(&gs_handle);
444
445 return 1;
446 }
447
448 /* set proximity pulse count */
449 res = apds9960_set_proximity_pulse_count(&gs_handle, 7);
450 if (res != 0)
451 {
452 apds9960_interface_debug_print("apds9960: set proximity pulse count failed.\n");
453 (void)apds9960_deinit(&gs_handle);
454
455 return 1;
456 }
457
458 /* set led current */
460 if (res != 0)
461 {
462 apds9960_interface_debug_print("apds9960: set led current failed.\n");
463 (void)apds9960_deinit(&gs_handle);
464
465 return 1;
466 }
467
468 /* set proximity gain */
470 if (res != 0)
471 {
472 apds9960_interface_debug_print("apds9960: set proximity gain failed.\n");
473 (void)apds9960_deinit(&gs_handle);
474
475 return 1;
476 }
477
478 /* set als color gain */
480 if (res != 0)
481 {
482 apds9960_interface_debug_print("apds9960: set als color gain failed.\n");
483 (void)apds9960_deinit(&gs_handle);
484
485 return 1;
486 }
487
488 /* enable proximity saturation interrupt */
490 if (res != 0)
491 {
492 apds9960_interface_debug_print("apds9960: set saturation interrupt failed.\n");
493 (void)apds9960_deinit(&gs_handle);
494
495 return 1;
496 }
497
498 /* enable clear photo diode saturation interrupt */
500 if (res != 0)
501 {
502 apds9960_interface_debug_print("apds9960: set saturation interrupt failed.\n");
503 (void)apds9960_deinit(&gs_handle);
504
505 return 1;
506 }
507
508 /* 100% */
510 if (res != 0)
511 {
512 apds9960_interface_debug_print("apds9960: set led boost failed.\n");
513 (void)apds9960_deinit(&gs_handle);
514
515 return 1;
516 }
517
518 /* set proximity up right offset */
519 res = apds9960_set_proximity_up_right_offset(&gs_handle, 0);
520 if (res != 0)
521 {
522 apds9960_interface_debug_print("apds9960: set proximity up right offset failed.\n");
523 (void)apds9960_deinit(&gs_handle);
524
525 return 1;
526 }
527
528 /* set proximity down left offset */
529 res = apds9960_set_proximity_down_left_offset(&gs_handle, 0);
530 if (res != 0)
531 {
532 apds9960_interface_debug_print("apds9960: set proximity down left offset failed.\n");
533 (void)apds9960_deinit(&gs_handle);
534
535 return 1;
536 }
537
538 /* set proximity gain compensation */
540 if (res != 0)
541 {
542 apds9960_interface_debug_print("apds9960: set proximity gain compensation failed.\n");
543 (void)apds9960_deinit(&gs_handle);
544
545 return 1;
546 }
547
548 /* disable */
550 if (res != 0)
551 {
552 apds9960_interface_debug_print("apds9960: set sleep after interrupt failed.\n");
553 (void)apds9960_deinit(&gs_handle);
554
555 return 1;
556 }
557
558 /* disable proximity mask up */
560 if (res != 0)
561 {
562 apds9960_interface_debug_print("apds9960: set proximity mask failed.\n");
563 (void)apds9960_deinit(&gs_handle);
564
565 return 1;
566 }
567
568 /* disable proximity mask down */
570 if (res != 0)
571 {
572 apds9960_interface_debug_print("apds9960: set proximity mask failed.\n");
573 (void)apds9960_deinit(&gs_handle);
574
575 return 1;
576 }
577
578 /* disable proximity mask left */
580 if (res != 0)
581 {
582 apds9960_interface_debug_print("apds9960: set proximity mask failed.\n");
583 (void)apds9960_deinit(&gs_handle);
584
585 return 1;
586 }
587
588 /* disable proximity mask right */
590 if (res != 0)
591 {
592 apds9960_interface_debug_print("apds9960: set proximity mask failed.\n");
593 (void)apds9960_deinit(&gs_handle);
594
595 return 1;
596 }
597
598 /* set gesture proximity enter threshold */
600 if (res != 0)
601 {
602 apds9960_interface_debug_print("apds9960: set gesture proximity enter threshold failed.\n");
603 (void)apds9960_deinit(&gs_handle);
604
605 return 1;
606 }
607
608 /* set gesture proximity exit threshold */
609 res = apds9960_set_gesture_proximity_exit_threshold(&gs_handle, 0xFF);
610 if (res != 0)
611 {
612 apds9960_interface_debug_print("apds9960: set gesture proximity exit threshold failed.\n");
613 (void)apds9960_deinit(&gs_handle);
614
615 return 1;
616 }
617
618 /* set gesture fifo threshold */
620 if (res != 0)
621 {
622 apds9960_interface_debug_print("apds9960: set gesture fifo threshold failed.\n");
623 (void)apds9960_deinit(&gs_handle);
624
625 return 1;
626 }
627
628 /* set gesture exit persistence */
630 if (res != 0)
631 {
632 apds9960_interface_debug_print("apds9960: set gesture exit persistence failed.\n");
633 (void)apds9960_deinit(&gs_handle);
634
635 return 1;
636 }
637
638 /* set gesture exit mask */
639 res = apds9960_set_gesture_exit_mask(&gs_handle, 0x00);
640 if (res != 0)
641 {
642 apds9960_interface_debug_print("apds9960: set gesture exit mask failed.\n");
643 (void)apds9960_deinit(&gs_handle);
644
645 return 1;
646 }
647
648 /* set gesture gain */
650 if (res != 0)
651 {
652 apds9960_interface_debug_print("apds9960: set gesture gain failed.\n");
653 (void)apds9960_deinit(&gs_handle);
654
655 return 1;
656 }
657
658 /* set gesture led current */
660 if (res != 0)
661 {
662 apds9960_interface_debug_print("apds9960: set gesture led current failed.\n");
663 (void)apds9960_deinit(&gs_handle);
664
665 return 1;
666 }
667
668 /* set gesture wait time */
670 if (res != 0)
671 {
672 apds9960_interface_debug_print("apds9960: set gesture wait time failed.\n");
673 (void)apds9960_deinit(&gs_handle);
674
675 return 1;
676 }
677
678 /* set gesture up offset */
679 res = apds9960_set_gesture_up_offset(&gs_handle, 0);
680 if (res != 0)
681 {
682 apds9960_interface_debug_print("apds9960: set gesture up offset failed.\n");
683 (void)apds9960_deinit(&gs_handle);
684
685 return 1;
686 }
687
688 /* set gesture down offset */
689 res = apds9960_set_gesture_down_offset(&gs_handle, 0);
690 if (res != 0)
691 {
692 apds9960_interface_debug_print("apds9960: set gesture down offset failed.\n");
693 (void)apds9960_deinit(&gs_handle);
694
695 return 1;
696 }
697
698 /* set gesture left offset */
699 res = apds9960_set_gesture_left_offset(&gs_handle, 0);
700 if (res != 0)
701 {
702 apds9960_interface_debug_print("apds9960: set gesture left offset failed.\n");
703 (void)apds9960_deinit(&gs_handle);
704
705 return 1;
706 }
707
708 /* set gesture right offset */
709 res = apds9960_set_gesture_right_offset(&gs_handle, 0);
710 if (res != 0)
711 {
712 apds9960_interface_debug_print("apds9960: set gesture right offset failed.\n");
713 (void)apds9960_deinit(&gs_handle);
714
715 return 1;
716 }
717
718 /* set gesture pulse length */
720 if (res != 0)
721 {
722 apds9960_interface_debug_print("apds9960: set gesture pulse length failed.\n");
723 (void)apds9960_deinit(&gs_handle);
724
725 return 1;
726 }
727
728 /* set gesture pulse count */
729 res = apds9960_set_gesture_pulse_count(&gs_handle, 9);
730 if (res != 0)
731 {
732 apds9960_interface_debug_print("apds9960: set gesture pulse count failed.\n");
733 (void)apds9960_deinit(&gs_handle);
734
735 return 1;
736 }
737
738 /* set gesture dimension */
740 if (res != 0)
741 {
742 apds9960_interface_debug_print("apds9960: set gesture dimension failed.\n");
743 (void)apds9960_deinit(&gs_handle);
744
745 return 1;
746 }
747
748 /* gesture fifo clear */
749 res = apds9960_gesture_fifo_clear(&gs_handle);
750 if (res != 0)
751 {
752 apds9960_interface_debug_print("apds9960: gesture fifo clear failed.\n");
753 (void)apds9960_deinit(&gs_handle);
754
755 return 1;
756 }
757
758 /* set gesture interrupt */
760 if (res != 0)
761 {
762 apds9960_interface_debug_print("apds9960: set gesture interrupt failed.\n");
763 (void)apds9960_deinit(&gs_handle);
764
765 return 1;
766 }
767
768 /* set gesture mode */
770 if (res != 0)
771 {
772 apds9960_interface_debug_print("apds9960: set gesture mode failed.\n");
773 (void)apds9960_deinit(&gs_handle);
774
775 return 1;
776 }
777
778 /* all non gesture interrupt clear */
780 if (res != 0)
781 {
782 apds9960_interface_debug_print("apds9960: all non gesture interrupt clear failed.\n");
783 (void)apds9960_deinit(&gs_handle);
784
785 return 1;
786 }
787
788 /* enable wait time */
790 if (res != 0)
791 {
792 apds9960_interface_debug_print("apds9960: set conf failed.\n");
793 (void)apds9960_deinit(&gs_handle);
794
795 return 1;
796 }
797
798 /* enable proximity detect */
800 if (res != 0)
801 {
802 apds9960_interface_debug_print("apds9960: set conf failed.\n");
803 (void)apds9960_deinit(&gs_handle);
804
805 return 1;
806 }
807
808 /* enable als */
810 if (res != 0)
811 {
812 apds9960_interface_debug_print("apds9960: set conf failed.\n");
813 (void)apds9960_deinit(&gs_handle);
814
815 return 1;
816 }
817
818 /* enable als interrupt */
820 if (res != 0)
821 {
822 apds9960_interface_debug_print("apds9960: set conf failed.\n");
823 (void)apds9960_deinit(&gs_handle);
824
825 return 1;
826 }
827
828 /* enable proximity interrupt */
830 if (res != 0)
831 {
832 apds9960_interface_debug_print("apds9960: set conf failed.\n");
833 (void)apds9960_deinit(&gs_handle);
834
835 return 1;
836 }
837
838 gs_flag = 0;
839 for (i = 0; i < times; i++)
840 {
841 while (1)
842 {
843 if (gs_flag != 0)
844 {
845 gs_flag = 0;
846
847 /* 1000 ms */
849
850 break;
851 }
852 else
853 {
854 /* 1000 ms */
856
857 continue;
858 }
859 }
860 }
861
862 /* finish interrupt test */
863 apds9960_interface_debug_print("apds9960: finish interrupt test.\n");
864 (void)apds9960_deinit(&gs_handle);
865
866 return 0;
867}
driver apds9960 interrupt test header file
uint8_t apds9960_set_gesture_dimension(apds9960_handle_t *handle, apds9960_gesture_dimension_select_t s)
set the gesture dimension
uint8_t apds9960_set_gesture_gain(apds9960_handle_t *handle, apds9960_gesture_gain_control_t gain)
set the gesture gain
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
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_set_proximity_pulse_length(apds9960_handle_t *handle, apds9960_proximity_pulse_length_t len)
set the proximity pulse length
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_gesture_fifo_clear(apds9960_handle_t *handle)
clear the gesture fifo status
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_read_proximity(apds9960_handle_t *handle, uint8_t *proximity)
read the proximity data
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_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_irq_handler(apds9960_handle_t *handle)
irq handler
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_set_gesture_led_current(apds9960_handle_t *handle, apds9960_gesture_led_current_t current)
set the gesture led current
uint8_t apds9960_set_gesture_pulse_count(apds9960_handle_t *handle, uint16_t count)
set the gesture pulse count
uint8_t apds9960_set_wait_long(apds9960_handle_t *handle, apds9960_bool_t enable)
enable or disable the wait long
uint8_t apds9960_set_gesture_exit_mask(apds9960_handle_t *handle, uint8_t mask)
set the gesture exit mask
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_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_set_gesture_mode(apds9960_handle_t *handle, apds9960_bool_t enable)
enable or disable the gesture mode
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_set_sleep_after_interrupt(apds9960_handle_t *handle, apds9960_bool_t enable)
enable or disable sleeping after interrupt
uint8_t apds9960_read_rgbc(apds9960_handle_t *handle, uint16_t *red, uint16_t *green, uint16_t *blue, uint16_t *clear)
read the rgbc data
uint8_t apds9960_all_non_gesture_interrupt_clear(apds9960_handle_t *handle)
clear the all not gesture 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_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
uint8_t apds9960_set_proximity_interrupt_low_threshold(apds9960_handle_t *handle, uint8_t threshold)
set the proximity interrupt low threshold
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_set_led_current(apds9960_handle_t *handle, apds9960_led_current_t current)
set the led current
uint8_t apds9960_set_proximity_interrupt_high_threshold(apds9960_handle_t *handle, uint8_t threshold)
set the proximity interrupt high threshold
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
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
uint8_t apds9960_set_gesture_down_offset(apds9960_handle_t *handle, int8_t offset)
set the gesture down offset
@ APDS9960_LED_BOOST_100_PERCENTAGE
@ APDS9960_GESTURE_LED_CURRENT_100_MA
@ APDS9960_INTERRUPT_STATUS_CPSAT
@ APDS9960_INTERRUPT_STATUS_GESTURE_NEAR
@ APDS9960_INTERRUPT_STATUS_AVALID
@ APDS9960_INTERRUPT_STATUS_GVALID
@ APDS9960_INTERRUPT_STATUS_GESTURE_RIGHT
@ APDS9960_INTERRUPT_STATUS_GESTURE_LEFT
@ APDS9960_INTERRUPT_STATUS_GESTURE_DOWN
@ APDS9960_INTERRUPT_STATUS_AINT
@ APDS9960_INTERRUPT_STATUS_GINT
@ APDS9960_INTERRUPT_STATUS_PGSAT
@ APDS9960_INTERRUPT_STATUS_GESTURE_FAR
@ APDS9960_INTERRUPT_STATUS_PVALID
@ APDS9960_INTERRUPT_STATUS_GESTURE_UP
@ APDS9960_INTERRUPT_STATUS_PINT
@ APDS9960_INTERRUPT_STATUS_GFOV
@ APDS9960_PROXIMITY_INTERRUPT_CYCLE_2
@ APDS9960_PROXIMITY_GAIN_4X
@ APDS9960_GESTURE_DIMENSION_SELECT_BOTH_PAIRS_ACTIVE
@ APDS9960_GESTURE_PULSE_LENGTH_32_US
@ APDS9960_GESTURE_WAIT_TIME_2P8_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_ALS_INTERRUPT_CYCLE_2
@ APDS9960_GESTURE_GAIN_2X
@ APDS9960_SATURATION_INTERRUPT_PROXIMITY
@ APDS9960_SATURATION_INTERRUPT_CLEAR_PHOTODIODE
@ 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_8_US
@ APDS9960_LED_CURRENT_100_MA
@ APDS9960_ALS_COLOR_GAIN_4X
@ APDS9960_GESTURE_FIFO_THRESHOLD_8_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_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_interrupt_test(uint32_t times, uint16_t als_low_threshold, uint16_t als_high_threshold, uint8_t proximity_low_threshold, uint8_t proximity_high_threshold)
interrupt test
uint8_t apds9960_interrupt_test_irq_handler(void)
interrupt test irq
char manufacturer_name[32]