I2C_Drivers (ARM) 1.1
SMFSW collection of HAL I2C Drivers for ARM
Loading...
Searching...
No Matches
APDS9960.h File Reference

APDS9960 Driver. More...

#include "sarmfsw.h"
#include "I2C_component.h"
#include "I2C_peripheral.h"
#include "APDS9960_proc.h"
#include "APDS9960_ex.h"
Include dependency graph for APDS9960.h:
This graph shows which files directly or indirectly include this file:

Data Structures

union  uAPDS9960_REG__ENABLE
 Union for ENABLE register of APDS9960. More...
 
union  uAPDS9960_REG__PERSIST
 Union for PERSIST register of APDS9960. More...
 
union  uAPDS9960_REG__CONFIG1
 Union for CONFIG1 register of APDS9960. More...
 
union  uAPDS9960_REG__CONFIG2
 Union for CONFIG2 register of APDS9960. More...
 
union  uAPDS9960_REG__CONFIG3
 Union for CONFIG3 register of APDS9960. More...
 
union  uAPDS9960_REG__GCONFIG1
 Union for GCONFIG1 register of APDS9960. More...
 
union  uAPDS9960_REG__GCONFIG2
 Union for GCONFIG2 register of APDS9960. More...
 
union  uAPDS9960_REG__GCONFIG3
 Union for GCONFIG3 register of APDS9960. More...
 
union  uAPDS9960_REG__GCONFIG4
 Union for GCONFIG4 register of APDS9960. More...
 
union  uAPDS9960_REG__PULSE
 Union for PPULSE & GPULSE registers of APDS9960. More...
 
union  uAPDS9960_REG__CONTROL
 Union for CONTROL register of APDS9960. More...
 
union  uAPDS9960_REG__STATUS
 Union for STATUS register of APDS9960. More...
 
union  uAPDS9960_REG__GSTATUS
 Union for GSTATUS register of APDS9960. More...
 

Macros

#define I2C_APDS9960_NB   1U
 Number of APDS9960 peripherals.
 
#define APDS9960_ADDR   0x39U
 APDS9960 address.
 
#define APDS9960_BASE_ADDR   APDS9960_ADDR
 APDS9960 Base address.
 

Enumerations

enum  APDS9960_reg {
  APDS9960__ENABLE = 0x80U , APDS9960__ATIME , APDS9960__WTIME = 0x83U , APDS9960__AILTL ,
  APDS9960__AILTH , APDS9960__AIHTL , APDS9960__AIHTH , APDS9960__PILT = 0x89U ,
  APDS9960__PIHT = 0x8BU , APDS9960__PERS , APDS9960__CONFIG1 , APDS9960__PPULSE ,
  APDS9960__CONTROL , APDS9960__CONFIG2 , APDS9960__ID = 0x92U , APDS9960__STATUS ,
  APDS9960__CDATAL , APDS9960__CDATAH , APDS9960__RDATAL , APDS9960__RDATAH ,
  APDS9960__GDATAL , APDS9960__GDATAH , APDS9960__BDATAL , APDS9960__BDATAH ,
  APDS9960__PDATA , APDS9960__POFFSET_UR , APDS9960__POFFSET_DL , APDS9960__CONFIG3 ,
  APDS9960__GPENTH , APDS9960__GEXTH , APDS9960__GCONF1 , APDS9960__GCONF2 ,
  APDS9960__GOFFSET_U , APDS9960__GOFFSET_D , APDS9960__GPULSE , APDS9960__GOFFSET_L ,
  APDS9960__GOFFSET_R = 0xA9U , APDS9960__GCONF3 , APDS9960__GCONF4 , APDS9960__GFLVL = 0xAEU ,
  APDS9960__GSTATUS , APDS9960__IFORCE = 0xE4U , APDS9960__PICLEAR , APDS9960__CICLEAR ,
  APDS9960__AICLEAR , APDS9960__GFIFO_U = 0xFCU , APDS9960__GFIFO_D , APDS9960__GFIFO_L ,
  APDS9960__GFIFO_R
}
 Register map enum of APDS9960. More...
 
enum  APDS9960_spec_func { APDS9960__SF_IFORCE = 0U , APDS9960__SF_PICLEAR , APDS9960__SF_CICLEAR , APDS9960__SF_AICLEAR }
 Special functions of APDS9960. More...
 
enum  APDS9960_als_it_persist {
  APDS9960__PERSIST_EVERY_ALS_CYCLE = 0U , APDS9960__PERSIST_1_ALS_PERIODS , APDS9960__PERSIST_2_ALS_PERIODS , APDS9960__PERSIST_3_ALS_PERIODS ,
  APDS9960__PERSIST_5_ALS_PERIODS , APDS9960__PERSIST_10_ALS_PERIODS , APDS9960__PERSIST_15_ALS_PERIODS , APDS9960__PERSIST_20_ALS_PERIODS ,
  APDS9960__PERSIST_25_ALS_PERIODS , APDS9960__PERSIST_30_ALS_PERIODS , APDS9960__PERSIST_35_ALS_PERIODS , APDS9960__PERSIST_40_ALS_PERIODS ,
  APDS9960__PERSIST_45_ALS_PERIODS , APDS9960__PERSIST_50_ALS_PERIODS , APDS9960__PERSIST_55_ALS_PERIODS , APDS9960__PERSIST_60_ALS_PERIODS
}
 Persistence control of APDS9960 ALS. More...
 
enum  APDS9960_prox_it_persist {
  APDS9960__PERSIST_EVERY_PROX_CYCLE = 0U , APDS9960__PERSIST_1_PROX_PERIODS , APDS9960__PERSIST_2_PROX_PERIODS , APDS9960__PERSIST_3_PROX_PERIODS ,
  APDS9960__PERSIST_4_PROX_PERIODS , APDS9960__PERSIST_5_PROX_PERIODS , APDS9960__PERSIST_6_PROX_PERIODS , APDS9960__PERSIST_7_PROX_PERIODS ,
  APDS9960__PERSIST_8_PROX_PERIODS , APDS9960__PERSIST_9_PROX_PERIODS , APDS9960__PERSIST_10_PROX_PERIODS , APDS9960__PERSIST_11_PROX_PERIODS ,
  APDS9960__PERSIST_12_PROX_PERIODS , APDS9960__PERSIST_13_PROX_PERIODS , APDS9960__PERSIST_14_PROX_PERIODS , APDS9960__PERSIST_15_PROX_PERIODS
}
 Persistence control of APDS9960 Proximity. More...
 
enum  APDS9960_pulse_length { APDS9960__PL_4US = 0U , APDS9960__PL_8US , APDS9960__PL_16US , APDS9960__PL_32US }
 Proximity LED Pulse Length values. More...
 
enum  APDS9960_als_gain { APDS9960__ALS_1X_GAIN = 0U , APDS9960__ALS_4X_GAIN , APDS9960__ALS_16X_GAIN , APDS9960__ALS_64X_GAIN }
 Gain values of APDS9960 ALS & Color. More...
 
enum  APDS9960_prox_gain { APDS9960__PROX_1X_GAIN = 0U , APDS9960__PROX_2X_GAIN , APDS9960__PROX_4X_GAIN , APDS9960__PROX_8X_GAIN }
 Gain values of APDS9960 proximity. More...
 
enum  APDS9960_drive_strength { APDS9960__DS_100MA = 0U , APDS9960__DS_50MA , APDS9960__DS_25MA , APDS9960__DS_12_5MA }
 Proximity LED Drive strength values. More...
 
enum  APDS9960_led_boost { APDS9960__BOOST_1X = 0U , APDS9960__BOOST_1_5X , APDS9960__BOOST_2X , APDS9960__BOOST_3X }
 Proximity LED boost values. More...
 
enum  APDS9960_gesture_dim { APDS9960__GD_UDLR = 0U , APDS9960__GD_UD , APDS9960__GD_LR , APDS9960__GD_UDLR2 }
 Gesture dimension values. More...
 

Functions

FctERR APDS9960_Init (const uint8_t idx, I2C_HandleTypeDef *const hi2c, const uint16_t devAddress)
 Initialization for APDS9960 peripheral.
 
FctERR APDS9960_Init_Single (void)
 Initialization for APDS9960 peripheral.
 
FctERR APDS9960_Write (I2C_slave_t *const pSlave, const uint8_t *data, const uint16_t addr, const uint16_t nb)
 I2C Write function for APDS9960.
 
FctERR APDS9960_Read (I2C_slave_t *const pSlave, uint8_t *data, const uint16_t addr, const uint16_t nb)
 I2C Read function for APDS9960.
 
FctERR APDS9960_Write_Word (I2C_slave_t *const pSlave, const uint16_t *data, const uint16_t addr)
 I2C Word Write (little endian) function for APDS9960.
 
FctERR APDS9960_Read_Word (I2C_slave_t *const pSlave, uint16_t *data, const uint16_t addr)
 I2C Word Read (little endian) function for APDS9960.
 
FctERR APDS9960_Write_Special (I2C_slave_t *const pSlave, const APDS9960_spec_func func)
 I2C Special function Write function for APDS9960.
 

Detailed Description

APDS9960 Driver.

Author
SMFSW

APDS9960: Digital Proximity, Ambient Light, RGB and Gesture Sensor

Macro Definition Documentation

◆ APDS9960_ADDR

#define APDS9960_ADDR   0x39U

APDS9960 address.

◆ APDS9960_BASE_ADDR

#define APDS9960_BASE_ADDR   APDS9960_ADDR

APDS9960 Base address.

Note
Define APDS9960_BASE_ADDR to change default device base address

◆ I2C_APDS9960_NB

#define I2C_APDS9960_NB   1U

Number of APDS9960 peripherals.

Note
Define I2C_APDS9960_NB to enable multiple peripherals of this type

Enumeration Type Documentation

◆ APDS9960_als_gain

Gain values of APDS9960 ALS & Color.

Enumerator
APDS9960__ALS_1X_GAIN 

ALS 1X Gain.

APDS9960__ALS_4X_GAIN 

ALS 4X Gain.

APDS9960__ALS_16X_GAIN 

ALS 16X Gain.

APDS9960__ALS_64X_GAIN 

ALS 64X Gain.

◆ APDS9960_als_it_persist

Persistence control of APDS9960 ALS.

Enumerator
APDS9960__PERSIST_EVERY_ALS_CYCLE 

Every ALS cycle generates interrupt.

APDS9960__PERSIST_1_ALS_PERIODS 

1 consecutive Ch0 channel values out of range

APDS9960__PERSIST_2_ALS_PERIODS 

2 consecutive Ch0 channel values out of range

APDS9960__PERSIST_3_ALS_PERIODS 

3 consecutive Ch0 channel values out of range

APDS9960__PERSIST_5_ALS_PERIODS 

5 consecutive Ch0 channel values out of range

APDS9960__PERSIST_10_ALS_PERIODS 

10 consecutive Ch0 channel values out of range

APDS9960__PERSIST_15_ALS_PERIODS 

15 consecutive Ch0 channel values out of range

APDS9960__PERSIST_20_ALS_PERIODS 

20 consecutive Ch0 channel values out of range

APDS9960__PERSIST_25_ALS_PERIODS 

25 consecutive Ch0 channel values out of range

APDS9960__PERSIST_30_ALS_PERIODS 

30 consecutive Ch0 channel values out of range

APDS9960__PERSIST_35_ALS_PERIODS 

35 consecutive Ch0 channel values out of range

APDS9960__PERSIST_40_ALS_PERIODS 

40 consecutive Ch0 channel values out of range

APDS9960__PERSIST_45_ALS_PERIODS 

45 consecutive Ch0 channel values out of range

APDS9960__PERSIST_50_ALS_PERIODS 

50 consecutive Ch0 channel values out of range

APDS9960__PERSIST_55_ALS_PERIODS 

55 consecutive Ch0 channel values out of range

APDS9960__PERSIST_60_ALS_PERIODS 

60 consecutive Ch0 channel values out of range

◆ APDS9960_drive_strength

Proximity LED Drive strength values.

Enumerator
APDS9960__DS_100MA 

Proximity LED Drive Strength 100mA.

APDS9960__DS_50MA 

Proximity LED Drive Strength 50mA.

APDS9960__DS_25MA 

Proximity LED Drive Strength 25mA.

APDS9960__DS_12_5MA 

Proximity LED Drive Strength 12.5mA.

◆ APDS9960_gesture_dim

Gesture dimension values.

Enumerator
APDS9960__GD_UDLR 

Both pairs are active. UP-DOWN and LEFT-RIGHT FIFO data is valid.

APDS9960__GD_UD 

Only the UP-DOWN pair is active. Ignore LEFT-RIGHT data in FIFO.

APDS9960__GD_LR 

Only the LEFT-RIGHT pair is active. Ignore UP-DOWN data in FIFO.

APDS9960__GD_UDLR2 

Both pairs are active. UP-DOWN and LEFT-RIGHT FIFO data is valid.

◆ APDS9960_led_boost

Proximity LED boost values.

Enumerator
APDS9960__BOOST_1X 

LED Boost 100%. A LED_BOOST value of 0 results in 100% of the current as set by LDRIVE (no additional current)

APDS9960__BOOST_1_5X 

LED Boost 150%.

APDS9960__BOOST_2X 

LED Boost 200%.

APDS9960__BOOST_3X 

LED Boost 300%.

◆ APDS9960_prox_gain

Gain values of APDS9960 proximity.

Enumerator
APDS9960__PROX_1X_GAIN 

Proximity 1X Gain.

APDS9960__PROX_2X_GAIN 

Proximity 2X Gain.

APDS9960__PROX_4X_GAIN 

Proximity 4X Gain.

APDS9960__PROX_8X_GAIN 

Proximity 8X Gain.

◆ APDS9960_prox_it_persist

Persistence control of APDS9960 Proximity.

Enumerator
APDS9960__PERSIST_EVERY_PROX_CYCLE 

Every proximity cycle generates an interrupt.

APDS9960__PERSIST_1_PROX_PERIODS 

1 consecutive proximity values out of range

APDS9960__PERSIST_2_PROX_PERIODS 

2 consecutive proximity values out of range

APDS9960__PERSIST_3_PROX_PERIODS 

3 consecutive proximity values out of range

APDS9960__PERSIST_4_PROX_PERIODS 

4 consecutive proximity values out of range

APDS9960__PERSIST_5_PROX_PERIODS 

5 consecutive proximity values out of range

APDS9960__PERSIST_6_PROX_PERIODS 

6 consecutive proximity values out of range

APDS9960__PERSIST_7_PROX_PERIODS 

7 consecutive proximity values out of range

APDS9960__PERSIST_8_PROX_PERIODS 

8 consecutive proximity values out of range

APDS9960__PERSIST_9_PROX_PERIODS 

9 consecutive proximity values out of range

APDS9960__PERSIST_10_PROX_PERIODS 

10 consecutive proximity values out of range

APDS9960__PERSIST_11_PROX_PERIODS 

11 consecutive proximity values out of range

APDS9960__PERSIST_12_PROX_PERIODS 

12 consecutive proximity values out of range

APDS9960__PERSIST_13_PROX_PERIODS 

13 consecutive proximity values out of range

APDS9960__PERSIST_14_PROX_PERIODS 

14 consecutive proximity values out of range

APDS9960__PERSIST_15_PROX_PERIODS 

15 consecutive proximity values out of range

◆ APDS9960_pulse_length

Proximity LED Pulse Length values.

Enumerator
APDS9960__PL_4US 

Pulse Length 4�s.

APDS9960__PL_8US 

Pulse Length 8�s.

APDS9960__PL_16US 

Pulse Length 16�s.

APDS9960__PL_32US 

Pulse Length 32�s.

◆ APDS9960_reg

Register map enum of APDS9960.

Enumerator
APDS9960__ENABLE 

Enables states and interrupts.

APDS9960__ATIME 

ADC integration time.

APDS9960__WTIME 

Wait time (non-gesture)

APDS9960__AILTL 

ALS interrupt low threshold low byte.

APDS9960__AILTH 

ALS interrupt low threshold high byte.

APDS9960__AIHTL 

ALS interrupt high threshold low byte.

APDS9960__AIHTH 

ALS interrupt high threshold high byte.

APDS9960__PILT 

Proximity interrupt low threshold.

APDS9960__PIHT 

Proximity interrupt high threshold.

APDS9960__PERS 

Interrupt persistence filters (non-gesture)

APDS9960__CONFIG1 

Configuration register one.

APDS9960__PPULSE 

Proximity pulse count and length.

APDS9960__CONTROL 

Gain control.

APDS9960__CONFIG2 

Configuration register two.

APDS9960__ID 

Device ID.

APDS9960__STATUS 

Device status.

APDS9960__CDATAL 

Low byte of clear channel data.

APDS9960__CDATAH 

High byte of clear channel data.

APDS9960__RDATAL 

Low byte of red channel data.

APDS9960__RDATAH 

High byte of red channel data.

APDS9960__GDATAL 

Low byte of green channel data.

APDS9960__GDATAH 

High byte of green channel data.

APDS9960__BDATAL 

Low byte of blue channel data.

APDS9960__BDATAH 

High byte of blue channel data.

APDS9960__PDATA 

Proximity data.

APDS9960__POFFSET_UR 

Proximity offset for UP and RIGHT photodiodes.

APDS9960__POFFSET_DL 

Proximity offset for DOWN and LEFT photodiodes.

APDS9960__CONFIG3 

Configuration register three.

APDS9960__GPENTH 

Gesture proximity enter threshold.

APDS9960__GEXTH 

Gesture exit threshold.

APDS9960__GCONF1 

Gesture configuration one.

APDS9960__GCONF2 

Gesture configuration two.

APDS9960__GOFFSET_U 

Gesture UP offset register.

APDS9960__GOFFSET_D 

Gesture DOWN offset register.

APDS9960__GPULSE 

Gesture pulse count and length.

APDS9960__GOFFSET_L 

Gesture LEFT offset register.

APDS9960__GOFFSET_R 

Gesture RIGHT offset register.

APDS9960__GCONF3 

Gesture configuration three.

APDS9960__GCONF4 

Gesture configuration four.

APDS9960__GFLVL 

Gesture FIFO level.

APDS9960__GSTATUS 

Gesture status.

APDS9960__IFORCE 

Force interrupt.

APDS9960__PICLEAR 

Proximity interrupt clear.

APDS9960__CICLEAR 

ALS clear channel interrupt clear.

APDS9960__AICLEAR 

All non-gesture interrupts clear.

APDS9960__GFIFO_U 

Gesture FIFO UP value.

APDS9960__GFIFO_D 

Gesture FIFO DOWN value.

APDS9960__GFIFO_L 

Gesture FIFO LEFT value.

APDS9960__GFIFO_R 

Gesture FIFO RIGHT value.

◆ APDS9960_spec_func

Special functions of APDS9960.

Enumerator
APDS9960__SF_IFORCE 

Forces an interrupt.

APDS9960__SF_PICLEAR 

Proximity interrupt clear.

APDS9960__SF_CICLEAR 

ALS interrupt clear.

APDS9960__SF_AICLEAR 

Clears all non-gesture interrupts.

Function Documentation

◆ APDS9960_Init()

FctERR APDS9960_Init ( const uint8_t idx,
I2C_HandleTypeDef *const hi2c,
const uint16_t devAddress )

Initialization for APDS9960 peripheral.

Parameters
[in]idx- APDS9960 index
[in]hi2c- pointer to APDS9960 I2C instance
[in]devAddress- APDS9960 device address
Returns
FctERR - error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ APDS9960_Init_Single()

FctERR APDS9960_Init_Single ( void )

Initialization for APDS9960 peripheral.

Warning
In case multiple devices (defined by I2C_APDS9960_NB > 1), you shall use APDS9960_Init instead
Returns
FctERR - error code
Here is the call graph for this function:

◆ APDS9960_Read()

FctERR APDS9960_Read ( I2C_slave_t *const pSlave,
uint8_t * data,
const uint16_t addr,
const uint16_t nb )

I2C Read function for APDS9960.

Parameters
[in]pSlave- Pointer to I2C slave instance
[in,out]data- pointer to read to
[in]addr- Address to read from
[in]nb- Number of bytes to read
Returns
FctERR - error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ APDS9960_Read_Word()

FctERR APDS9960_Read_Word ( I2C_slave_t *const pSlave,
uint16_t * data,
const uint16_t addr )

I2C Word Read (little endian) function for APDS9960.

Parameters
[in,out]pSlave- Pointer to I2C slave instance
[in,out]data- pointer to read to
[in]addr- Address to read from
Returns
FctERR - error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ APDS9960_Write()

FctERR APDS9960_Write ( I2C_slave_t *const pSlave,
const uint8_t * data,
const uint16_t addr,
const uint16_t nb )

I2C Write function for APDS9960.

Parameters
[in]pSlave- Pointer to I2C slave instance
[in]data- pointer to write from
[in]addr- Address to write to
[in]nb- Number of bytes to write
Returns
FctERR - error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ APDS9960_Write_Special()

FctERR APDS9960_Write_Special ( I2C_slave_t *const pSlave,
const APDS9960_spec_func func )

I2C Special function Write function for APDS9960.

Parameters
[in,out]pSlave- Pointer to I2C slave instance
[in]func- special function to execute
Returns
FctERR - error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ APDS9960_Write_Word()

FctERR APDS9960_Write_Word ( I2C_slave_t *const pSlave,
const uint16_t * data,
const uint16_t addr )

I2C Word Write (little endian) function for APDS9960.

Parameters
[in,out]pSlave- Pointer to I2C slave instance
[in]data- pointer to write from
[in]addr- Address to write to
Returns
FctERR - error code
Here is the call graph for this function:
Here is the caller graph for this function: