43#define CHIP_NAME "Broadcom APDS9960"
44#define MANUFACTURER_NAME "Broadcom"
45#define SUPPLY_VOLTAGE_MIN 2.4f
46#define SUPPLY_VOLTAGE_MAX 3.6f
47#define MAX_CURRENT 100.0f
48#define TEMPERATURE_MIN -40.0f
49#define TEMPERATURE_MAX 85.0f
50#define DRIVER_VERSION 1000
55#define APDS9960_ADDRESS 0x72
60#define APDS9960_REG_ENABLE 0x80
61#define APDS9960_REG_ATIME 0x81
62#define APDS9960_REG_WTIME 0x83
63#define APDS9960_REG_AILTL 0x84
64#define APDS9960_REG_AILTH 0x85
65#define APDS9960_REG_AIHTL 0x86
66#define APDS9960_REG_AIHTH 0x87
67#define APDS9960_REG_PILT 0x89
68#define APDS9960_REG_PIHT 0x8B
69#define APDS9960_REG_PERS 0x8C
70#define APDS9960_REG_CONFIG1 0x8D
71#define APDS9960_REG_PPULSE 0x8E
72#define APDS9960_REG_CONTROL 0x8F
73#define APDS9960_REG_CONFIG2 0x90
74#define APDS9960_REG_ID 0x92
75#define APDS9960_REG_STATUS 0x93
76#define APDS9960_REG_CDATAL 0x94
77#define APDS9960_REG_CDATAH 0x95
78#define APDS9960_REG_RDATAL 0x96
79#define APDS9960_REG_RDATAH 0x97
80#define APDS9960_REG_GDATAL 0x98
81#define APDS9960_REG_GDATAH 0x99
82#define APDS9960_REG_BDATAL 0x9A
83#define APDS9960_REG_BDATAH 0x9B
84#define APDS9960_REG_PDATA 0x9C
85#define APDS9960_REG_POFFSET_UR 0x9D
86#define APDS9960_REG_POFFSET_DL 0x9E
87#define APDS9960_REG_CONFIG3 0x9F
88#define APDS9960_REG_GPENTH 0xA0
89#define APDS9960_REG_GEXTH 0xA1
90#define APDS9960_REG_GCONF1 0xA2
91#define APDS9960_REG_GCONF2 0xA3
92#define APDS9960_REG_GOFFSET_U 0xA4
93#define APDS9960_REG_GOFFSET_D 0xA5
94#define APDS9960_REG_GOFFSET_L 0xA7
95#define APDS9960_REG_GOFFSET_R 0xA9
96#define APDS9960_REG_GPULSE 0xA6
97#define APDS9960_REG_GCONF3 0xAA
98#define APDS9960_REG_GCONF4 0xAB
99#define APDS9960_REG_GFLVL 0xAE
100#define APDS9960_REG_GSTATUS 0xAF
101#define APDS9960_REG_IFORCE 0xE4
102#define APDS9960_REG_PICLEAR 0xE5
103#define APDS9960_REG_CICLEAR 0xE6
104#define APDS9960_REG_AICLEAR 0xE7
105#define APDS9960_REG_GFIFO_U 0xFC
106#define APDS9960_REG_GFIFO_D 0xFD
107#define APDS9960_REG_GFIFO_L 0xFE
108#define APDS9960_REG_GFIFO_R 0xFF
121static uint8_t a_apds9960_iic_read(
apds9960_handle_t *handle, uint8_t reg, uint8_t *data, uint16_t len)
144static uint8_t a_apds9960_iic_write(
apds9960_handle_t *handle, uint8_t reg, uint8_t *data, uint16_t len)
182 handle->
debug_print(
"apds9960: iic_init is null.\n");
188 handle->
debug_print(
"apds9960: iic_deinit is null.\n");
194 handle->
debug_print(
"apds9960: iic_read is null.\n");
200 handle->
debug_print(
"apds9960: iic_write is null.\n");
206 handle->
debug_print(
"apds9960: delay_ms is null.\n");
212 handle->
debug_print(
"apds9960: receive_callback is null.\n");
219 handle->
debug_print(
"apds9960: iic init failed.\n");
223 if (a_apds9960_iic_read(handle,
APDS9960_REG_ID, (uint8_t *)&
id, 1) != 0)
225 handle->
debug_print(
"apds9960: read id failed.\n");
279 handle->
debug_print(
"apds9960: read enable register failed.\n");
287 handle->
debug_print(
"apds9960: write enable register failed.\n");
294 handle->
debug_print(
"apds9960: iic deinit failed.\n");
318 uint8_t res, prev, prev1;
333 handle->
debug_print(
"apds9960: read status failed.\n");
340 handle->
debug_print(
"apds9960: read gesture status failed.\n");
423 handle->
debug_print(
"apds9960: clear all non-gesture interrupts failed.\n");
438 handle->
debug_print(
"apds9960: get gesture conf 4 register failed.\n");
454 handle->
debug_print(
"apds9960: set gesture conf 4 register failed.\n");
463 if ((prev & (1 << 0)) != 0)
470 if ((prev & (1 << 1)) != 0)
477 if ((prev & (1 << 2)) != 0)
484 if ((prev & (1 << 3)) != 0)
491 if ((prev & (1 << 4)) != 0)
498 if ((prev & (1 << 5)) != 0)
535 uint8_t u_first, d_first, l_first, r_first;
536 uint8_t u_last, d_last, l_last, r_last;
537 int32_t ud_ratio_first, lr_ratio_first, ud_ratio_last, lr_ratio_last;
538 int32_t ud_delta, lr_delta;
550 handle->
debug_print(
"apds9960: fifo level must be over 4.\n");
563 for (i = 0; i < len; i++)
571 u_first = data[i][0];
572 d_first = data[i][1];
573 l_first = data[i][2];
574 r_first = data[i][3];
579 if ((u_first == 0) ||
587 for (i = len - 1; i >= 0; i--)
603 ud_ratio_first = ((u_first - d_first) * 100) / (u_first + d_first);
604 lr_ratio_first = ((l_first - r_first) * 100) / (l_first + r_first);
605 ud_ratio_last = ((u_last - d_last) * 100) / (u_last + d_last);
606 lr_ratio_last = ((l_last - r_last) * 100) / (l_last + r_last);
607 ud_delta = ud_ratio_last - ud_ratio_first;
608 lr_delta = lr_ratio_last - lr_ratio_first;
642 if ((ud_delta == 0) && (lr_delta == 0))
646 else if ((ud_delta != 0) || (lr_delta != 0))
657 if ((ud_delta == 0) && (lr_delta == 0))
661 else if ((ud_delta != 0) && (lr_delta != 0))
677 if ((ud_delta == 0) && (lr_delta == 0))
952 handle->
debug_print(
"apds9960: get enable failed.\n");
956 prev &= ~(1 << conf);
957 prev |= enable << conf;
961 handle->
debug_print(
"apds9960: set enable failed.\n");
998 handle->
debug_print(
"apds9960: get enable failed.\n");
1032 prev = integration_time;
1036 handle->
debug_print(
"apds9960: set atime failed.\n");
1072 handle->
debug_print(
"apds9960: get atime failed.\n");
1076 *integration_time = prev;
1103 *reg = (uint8_t)(256.0f - ms / 2.78f);
1130 *ms = (float)(256 - reg) * 2.78f;
1164 handle->
debug_print(
"apds9960: set wtime failed.\n");
1200 handle->
debug_print(
"apds9960: get wtime failed.\n");
1238 handle->
debug_print(
"apds9960: get configuration register 1 failed.\n");
1243 if ((prev & (1 << 1)) != 0)
1245 *reg = (uint8_t)(256.0f - ms / (2.78f * 12.0f));
1249 *reg = (uint8_t)(256.0f - ms / 2.78f);
1284 handle->
debug_print(
"apds9960: get configuration register 1 failed.\n");
1289 if ((prev & (1 << 1)) != 0)
1291 *ms = (float)(256 - reg) * 2.78f * 12.0f;
1295 *ms = (float)(256 - reg) * 2.78f;
1326 buf[0] = (threshold >> 0) & 0xFF;
1327 buf[1] = (threshold >> 8) & 0xFF;
1331 handle->
debug_print(
"apds9960: set ailtl failed.\n");
1367 handle->
debug_print(
"apds9960: get ailtl failed.\n");
1371 *threshold = (uint16_t)(((uint16_t)buf[1] << 8) | buf[0]);
1401 buf[0] = (threshold >> 0) & 0xFF;
1402 buf[1] = (threshold >> 8) & 0xFF;
1406 handle->
debug_print(
"apds9960: set aihtl failed.\n");
1442 handle->
debug_print(
"apds9960: get aihtl failed.\n");
1446 *threshold = (uint16_t)(((uint16_t)buf[1] << 8) | buf[0]);
1480 handle->
debug_print(
"apds9960: set pilt failed.\n");
1516 handle->
debug_print(
"apds9960: get pilt failed.\n");
1554 handle->
debug_print(
"apds9960: set piht failed.\n");
1590 handle->
debug_print(
"apds9960: get piht failed.\n");
1627 handle->
debug_print(
"apds9960: get persistence register failed.\n");
1631 prev &= ~(0xF << 4);
1636 handle->
debug_print(
"apds9960: set persistence register failed.\n");
1672 handle->
debug_print(
"apds9960: get persistence register failed.\n");
1709 handle->
debug_print(
"apds9960: get persistence register failed.\n");
1713 prev &= ~(0xF << 0);
1718 handle->
debug_print(
"apds9960: set persistence register failed.\n");
1754 handle->
debug_print(
"apds9960: get persistence register failed.\n");
1791 handle->
debug_print(
"apds9960: get configuration register 1 failed.\n");
1796 prev |= enable << 1;
1800 handle->
debug_print(
"apds9960: set configuration register 1 failed.\n");
1836 handle->
debug_print(
"apds9960: get configuration register 1 failed.\n");
1873 handle->
debug_print(
"apds9960: get proximity pulse count register failed.\n");
1882 handle->
debug_print(
"apds9960: set proximity pulse count register failed.\n");
1918 handle->
debug_print(
"apds9960: get proximity pulse count register failed.\n");
1954 handle->
debug_print(
"apds9960: count is over 63.\n");
1962 handle->
debug_print(
"apds9960: get proximity pulse count register failed.\n");
1966 prev &= ~(0x3F << 0);
1967 prev |= (count & 0x3F) << 0;
1971 handle->
debug_print(
"apds9960: set proximity pulse count register failed.\n");
2007 handle->
debug_print(
"apds9960: get proximity pulse count register failed.\n");
2011 *count = prev & 0x3F;
2044 handle->
debug_print(
"apds9960: get control register failed.\n");
2048 prev &= ~(0x3 << 6);
2049 prev |= current << 6;
2053 handle->
debug_print(
"apds9960: set control register register failed.\n");
2089 handle->
debug_print(
"apds9960: get control register failed.\n");
2126 handle->
debug_print(
"apds9960: get control register failed.\n");
2130 prev &= ~(0x3 << 2);
2135 handle->
debug_print(
"apds9960: set control register register failed.\n");
2171 handle->
debug_print(
"apds9960: get control register failed.\n");
2208 handle->
debug_print(
"apds9960: get control register failed.\n");
2212 prev &= ~(0x3 << 0);
2217 handle->
debug_print(
"apds9960: set control register register failed.\n");
2253 handle->
debug_print(
"apds9960: get control register failed.\n");
2291 handle->
debug_print(
"apds9960: get control 2 register failed.\n");
2295 prev &= ~(1 << saturation);
2296 prev |= enable << saturation;
2300 handle->
debug_print(
"apds9960: set control 2 register register failed.\n");
2337 handle->
debug_print(
"apds9960: get control 2 register failed.\n");
2374 handle->
debug_print(
"apds9960: get control 2 register failed.\n");
2378 prev &= ~(0x3 << 4);
2383 handle->
debug_print(
"apds9960: set control 2 register register failed.\n");
2419 handle->
debug_print(
"apds9960: get control 2 register failed.\n");
2456 handle->
debug_print(
"apds9960: get status register failed.\n");
2496 handle->
debug_print(
"apds9960: get cdatal register failed.\n");
2503 handle->
debug_print(
"apds9960: get rdatal register failed.\n");
2510 handle->
debug_print(
"apds9960: get gdatal register failed.\n");
2517 handle->
debug_print(
"apds9960: get bdatal register failed.\n");
2521 *red = (uint16_t)(((uint16_t)buf[3] << 0) | buf[2]);
2522 *green = (uint16_t)(((uint16_t)buf[5] << 0) | buf[4]);
2523 *blue = (uint16_t)(((uint16_t)buf[7] << 0) | buf[6]);
2524 *clear = (uint16_t)(((uint16_t)buf[1] << 0) | buf[0]);
2557 handle->
debug_print(
"apds9960: get proximity data register failed.\n");
2603 handle->
debug_print(
"apds9960: set proximity offset up right register failed.\n");
2639 handle->
debug_print(
"apds9960: get proximity offset up right register failed.\n");
2643 if ((prev & 0x80) != 0)
2646 *offset = -(int8_t)(prev);
2650 *offset = (int8_t)(prev);
2693 handle->
debug_print(
"apds9960: set proximity offset down left register failed.\n");
2729 handle->
debug_print(
"apds9960: get proximity offset down left register failed.\n");
2733 if ((prev & 0x80) != 0)
2736 *offset = -(int8_t)(prev);
2740 *offset = (int8_t)(prev);
2774 handle->
debug_print(
"apds9960: get control 3 register failed.\n");
2779 prev |= enable << 5;
2783 handle->
debug_print(
"apds9960: set control 3 register register failed.\n");
2819 handle->
debug_print(
"apds9960: get control 3 register failed.\n");
2856 handle->
debug_print(
"apds9960: get control 3 register failed.\n");
2861 prev |= enable << 4;
2865 handle->
debug_print(
"apds9960: set control 3 register register failed.\n");
2901 handle->
debug_print(
"apds9960: get control 3 register failed.\n");
2939 handle->
debug_print(
"apds9960: get control 3 register failed.\n");
2943 prev &= ~(1 << mask);
2944 prev |= enable << mask;
2948 handle->
debug_print(
"apds9960: set control 3 register register failed.\n");
2985 handle->
debug_print(
"apds9960: get control 3 register failed.\n");
3023 handle->
debug_print(
"apds9960: set gesture proximity enter threshold register failed.\n");
3059 handle->
debug_print(
"apds9960: get gesture proximity enter threshold register failed.\n");
3097 handle->
debug_print(
"apds9960: set gesture proximity exit threshold register failed.\n");
3133 handle->
debug_print(
"apds9960: get gesture proximity exit threshold register failed.\n");
3170 handle->
debug_print(
"apds9960: get gesture control 1 register failed.\n");
3175 prev |= threshold << 6;
3179 handle->
debug_print(
"apds9960: set gesture control 1 register failed.\n");
3215 handle->
debug_print(
"apds9960: get gesture control 1 register failed.\n");
3252 handle->
debug_print(
"apds9960: get gesture control 1 register failed.\n");
3257 prev |= persistence << 0;
3261 handle->
debug_print(
"apds9960: set gesture control 1 register failed.\n");
3297 handle->
debug_print(
"apds9960: get gesture control 1 register failed.\n");
3333 handle->
debug_print(
"apds9960: mask is over 0xF.\n");
3341 handle->
debug_print(
"apds9960: get gesture control 1 register failed.\n");
3345 prev &= ~(0xF << 2);
3346 prev |= (mask & 0xF) << 2;
3350 handle->
debug_print(
"apds9960: set gesture control 1 register failed.\n");
3386 handle->
debug_print(
"apds9960: get gesture control 1 register failed.\n");
3390 *mask = (prev >> 2) & 0xF;
3423 handle->
debug_print(
"apds9960: get gesture control 2 register failed.\n");
3427 prev &= ~(0x3 << 5);
3432 handle->
debug_print(
"apds9960: set gesture control 2 register failed.\n");
3468 handle->
debug_print(
"apds9960: get gesture control 2 register failed.\n");
3505 handle->
debug_print(
"apds9960: get gesture control 2 register failed.\n");
3509 prev &= ~(0x3 << 3);
3510 prev |= current << 3;
3514 handle->
debug_print(
"apds9960: set gesture control 2 register failed.\n");
3550 handle->
debug_print(
"apds9960: get gesture control 2 register failed.\n");
3587 handle->
debug_print(
"apds9960: get gesture control 2 register failed.\n");
3591 prev &= ~(0x7 << 0);
3596 handle->
debug_print(
"apds9960: set gesture control 2 register failed.\n");
3632 handle->
debug_print(
"apds9960: get gesture control 2 register failed.\n");
3678 handle->
debug_print(
"apds9960: set gesture up offset register failed.\n");
3714 handle->
debug_print(
"apds9960: get gesture up offset register failed.\n");
3718 if ((prev & 0x80) != 0)
3721 *offset = -(int8_t)(prev);
3725 *offset = (int8_t)(prev);
3768 handle->
debug_print(
"apds9960: set gesture down offset register failed.\n");
3804 handle->
debug_print(
"apds9960: get gesture down offset register failed.\n");
3808 if ((prev & 0x80) != 0)
3811 *offset = -(int8_t)(prev);
3815 *offset = (int8_t)(prev);
3858 handle->
debug_print(
"apds9960: set gesture left offset register failed.\n");
3894 handle->
debug_print(
"apds9960: get gesture left offset register failed.\n");
3898 if ((prev & 0x80) != 0)
3901 *offset = -(int8_t)(prev);
3905 *offset = (int8_t)(prev);
3948 handle->
debug_print(
"apds9960: set gesture right offset register failed.\n");
3984 handle->
debug_print(
"apds9960: get gesture right offset register failed.\n");
3988 if ((prev & 0x80) != 0)
3991 *offset = -(int8_t)(prev);
3995 *offset = (int8_t)(prev);
4029 handle->
debug_print(
"apds9960: get gesture pulse count register failed.\n");
4038 handle->
debug_print(
"apds9960: set gesture pulse count register failed.\n");
4074 handle->
debug_print(
"apds9960: get gesture pulse count register failed.\n");
4110 handle->
debug_print(
"apds9960: count is over 63.\n");
4118 handle->
debug_print(
"apds9960: get gesture pulse count register failed.\n");
4122 prev &= ~(0x3F << 0);
4123 prev |= (count & 0x3F) << 0;
4127 handle->
debug_print(
"apds9960: set gesture pulse count register failed.\n");
4163 handle->
debug_print(
"apds9960: get gesture pulse count register failed.\n");
4167 *count = prev & 0x3F;
4200 handle->
debug_print(
"apds9960: get gesture conf 3 register failed.\n");
4209 handle->
debug_print(
"apds9960: set gesture conf 3 register failed.\n");
4245 handle->
debug_print(
"apds9960: get gesture conf 3 register failed.\n");
4281 handle->
debug_print(
"apds9960: get gesture conf 4 register failed.\n");
4290 handle->
debug_print(
"apds9960: set gesture conf 4 register failed.\n");
4326 handle->
debug_print(
"apds9960: get gesture conf 4 register failed.\n");
4331 prev |= enable << 1;
4335 handle->
debug_print(
"apds9960: set gesture conf 4 register failed.\n");
4371 handle->
debug_print(
"apds9960: get gesture conf 4 register failed.\n");
4408 handle->
debug_print(
"apds9960: get gesture conf 4 register failed.\n");
4413 prev |= enable << 0;
4417 handle->
debug_print(
"apds9960: set gesture conf 4 register failed.\n");
4453 handle->
debug_print(
"apds9960: get gesture conf 4 register failed.\n");
4490 handle->
debug_print(
"apds9960: get gesture fifo level register failed.\n");
4527 handle->
debug_print(
"apds9960: get gesture status register failed.\n");
4564 handle->
debug_print(
"apds9960: forces an interrupt failed.\n");
4600 handle->
debug_print(
"apds9960: proximity interrupt clear failed.\n");
4636 handle->
debug_print(
"apds9960: als interrupt clear failed.\n");
4672 handle->
debug_print(
"apds9960: clear all non-gesture interrupts failed.\n");
4709 handle->
debug_print(
"apds9960: get gesture fifo level register failed.\n");
4714 *len = level < (*len) ? level : (*len);
4718 handle->
debug_print(
"apds9960: read gesture fifo failed.\n");
4750 if (a_apds9960_iic_write(handle, reg, buf, len) != 0)
4784 if (a_apds9960_iic_read(handle, reg, buf, len) != 0)
#define APDS9960_REG_GCONF4
#define APDS9960_REG_CONFIG2
#define APDS9960_REG_GCONF3
#define APDS9960_REG_PIHT
#define APDS9960_ADDRESS
iic address definition
#define APDS9960_REG_PPULSE
#define APDS9960_REG_GPENTH
#define APDS9960_REG_CONFIG1
#define APDS9960_REG_RDATAL
#define APDS9960_REG_AILTL
#define APDS9960_REG_ATIME
#define APDS9960_REG_GPULSE
#define APDS9960_REG_BDATAL
#define APDS9960_REG_PERS
#define APDS9960_REG_WTIME
#define APDS9960_REG_CONFIG3
#define APDS9960_REG_GOFFSET_R
#define APDS9960_REG_GSTATUS
#define SUPPLY_VOLTAGE_MAX
#define APDS9960_REG_PICLEAR
#define APDS9960_REG_IFORCE
#define APDS9960_REG_GFLVL
#define APDS9960_REG_GOFFSET_L
#define APDS9960_REG_AIHTL
#define APDS9960_REG_PDATA
#define APDS9960_REG_GOFFSET_D
#define APDS9960_REG_CDATAL
#define APDS9960_REG_PILT
#define APDS9960_REG_GOFFSET_U
#define APDS9960_REG_GFIFO_U
#define MANUFACTURER_NAME
#define APDS9960_REG_CONTROL
#define SUPPLY_VOLTAGE_MIN
#define APDS9960_REG_GDATAL
#define APDS9960_REG_STATUS
#define APDS9960_REG_POFFSET_UR
#define APDS9960_REG_GCONF2
#define APDS9960_REG_CICLEAR
#define APDS9960_REG_GEXTH
#define APDS9960_REG_ENABLE
chip register definition
#define CHIP_NAME
chip information definition
#define APDS9960_REG_GCONF1
#define APDS9960_REG_POFFSET_DL
#define APDS9960_REG_AICLEAR
driver apds9960 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_read_gesture_fifo(apds9960_handle_t *handle, uint8_t(*data)[4], uint8_t *len)
read data from the gesture fifo
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_gesture_decode(apds9960_handle_t *handle, uint8_t(*data)[4], uint8_t len)
decode gestures from the fifo data
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_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_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_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_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_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_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
#define APDS9960_GESTURE_SENSITIVITY_2
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
apds9960_proximity_mask_t
apds9960 proximity mask enumeration definition
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
apds9960_saturation_interrupt_t
apds9960 saturation interrupt enumeration definition
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
#define APDS9960_GESTURE_THRESHOLD
apds9960 gesture algorithm params definition
uint8_t apds9960_get_gesture_proximity_enter_threshold(apds9960_handle_t *handle, uint8_t *threshold)
get the gesture proximity enter threshold
apds9960_conf_t
apds9960 conf enumeration definition
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
#define APDS9960_GESTURE_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_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_GESTURE_STATUS_FIFO_VALID
@ APDS9960_GESTURE_STATUS_FIFO_OVERFLOW
uint8_t apds9960_set_reg(apds9960_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set the chip register
uint8_t apds9960_get_reg(apds9960_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get the chip register
uint8_t gesture_threshold
int32_t gesture_sensitivity_2
int32_t gesture_near_count
void(* delay_ms)(uint32_t ms)
void(* receive_callback)(uint8_t type)
int32_t gesture_far_count
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
int32_t gesture_sensitivity_1
uint8_t(* iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v