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

APDS9930 Driver. More...

#include "sarmfsw.h"
#include "I2C_component.h"
#include "I2C_peripheral.h"
#include "APDS9930_proc.h"
#include "APDS9930_ex.h"
Include dependency graph for APDS9930.h:
This graph shows which files directly or indirectly include this file:

Data Structures

union  uAPDS9930_CMD
 Union for COMMAND register of APDS9930. More...
 
union  uAPDS9930_REG__ENABLE
 Union for ENABLE register of APDS9930. More...
 
union  uAPDS9930_REG__CONFIG
 Union for CONFIG register of APDS9930. More...
 
union  uAPDS9930_REG__CONTROL
 Union for CONTROL register of APDS9930. More...
 
union  uAPDS9930_REG__PERSIST
 Union for PERSIST register of APDS9930. More...
 
union  uAPDS9930_REG__STATUS
 Union for STATUS register of APDS9930. More...
 

Macros

#define I2C_APDS9930_NB   1U
 Number of APDS9930 peripherals.
 
#define APDS9930_ADDR   0x39U
 APDS9930 address.
 
#define APDS9930_BASE_ADDR   APDS9930_ADDR
 APDS9930 Base address.
 

Enumerations

enum  APDS9930_reg {
  APDS9930__ENABLE = 0U , APDS9930__ATIME , APDS9930__PTIME , APDS9930__WTIME ,
  APDS9930__AILTL , APDS9930__AILTH , APDS9930__AIHTL , APDS9930__AIHTH ,
  APDS9930__PILTL , APDS9930__PILTH , APDS9930__PIHTL , APDS9930__PIHTH ,
  APDS9930__PERS , APDS9930__CONFIG , APDS9930__PPULSE , APDS9930__CONTROL ,
  APDS9930__ID = 0x12 , APDS9930__STATUS , APDS9930__CH0DATAL , APDS9930__CH0DATAH ,
  APDS9930__CH1DATAL , APDS9930__CH1DATAH , APDS9930__PDATAL , APDS9930__PDATAH ,
  APDS9930__POFFSET
}
 Register map enum of APDS9930. More...
 
enum  APDS9930_transaction { APDS9930__TRANS_REPEATED_BYTE = 0U , APDS9930__TRANS_AUTO_INCREMENT = 1U , APDS9930__TRANS_SPECIAL_FUNC = 3U }
 Transaction types of APDS9930. More...
 
enum  APDS9930_spec_func { APDS9930__SF_CLR_PROX_IT = 5U , APDS9930__SF_CLR_ALS_IT = 6U , APDS9930__SF_CLR_PROX_ALS_IT = 7U }
 Special functions of APDS9930. More...
 
enum  APDS9930_als_gain { APDS9930__ALS_1X_GAIN = 0U , APDS9930__ALS_8X_GAIN , APDS9930__ALS_16X_GAIN , APDS9930__ALS_120X_GAIN }
 Gain values of APDS9930 ALS. More...
 
enum  APDS9930_prox_gain { APDS9930__PROX_1X_GAIN = 0U , APDS9930__PROX_2X_GAIN , APDS9930__PROX_4X_GAIN , APDS9930__PROX_8X_GAIN }
 Gain values of APDS9930 proximity. More...
 
enum  APDS9930_prox_diode { APDS9930__PDIODE_RESERVED1 = 0U , APDS9930__PDIODE_RESERVED2 , APDS9930__PDIODE_CH1 , APDS9930__PDIODE_RESERVED3 }
 Proximity Diode Select values. More...
 
enum  APDS9930_drive_strength { APDS9930__STRENGTH_MAX = 0U , APDS9930__STRENGTH_HIGH , APDS9930__STRENGTH_MEDIUM , APDS9930__STRENGTH_LOW }
 Proximity LED Drive strength values. More...
 
enum  APDS9930_als_it_persist {
  APDS9930__PERSIST_EVERY_ALS_CYCLE = 0U , APDS9930__PERSIST_1_ALS_PERIODS , APDS9930__PERSIST_2_ALS_PERIODS , APDS9930__PERSIST_3_ALS_PERIODS ,
  APDS9930__PERSIST_5_ALS_PERIODS , APDS9930__PERSIST_10_ALS_PERIODS , APDS9930__PERSIST_15_ALS_PERIODS , APDS9930__PERSIST_20_ALS_PERIODS ,
  APDS9930__PERSIST_25_ALS_PERIODS , APDS9930__PERSIST_30_ALS_PERIODS , APDS9930__PERSIST_35_ALS_PERIODS , APDS9930__PERSIST_40_ALS_PERIODS ,
  APDS9930__PERSIST_45_ALS_PERIODS , APDS9930__PERSIST_50_ALS_PERIODS , APDS9930__PERSIST_55_ALS_PERIODS , APDS9930__PERSIST_60_ALS_PERIODS
}
 Persistence control of APDS9930 ALS. More...
 
enum  APDS9930_prox_it_persist {
  APDS9930__PERSIST_EVERY_PROX_CYCLE = 0U , APDS9930__PERSIST_1_PROX_PERIODS , APDS9930__PERSIST_2_PROX_PERIODS , APDS9930__PERSIST_3_PROX_PERIODS ,
  APDS9930__PERSIST_4_PROX_PERIODS , APDS9930__PERSIST_5_PROX_PERIODS , APDS9930__PERSIST_6_PROX_PERIODS , APDS9930__PERSIST_7_PROX_PERIODS ,
  APDS9930__PERSIST_8_PROX_PERIODS , APDS9930__PERSIST_9_PROX_PERIODS , APDS9930__PERSIST_10_PROX_PERIODS , APDS9930__PERSIST_11_PROX_PERIODS ,
  APDS9930__PERSIST_12_PROX_PERIODS , APDS9930__PERSIST_13_PROX_PERIODS , APDS9930__PERSIST_14_PROX_PERIODS , APDS9930__PERSIST_15_PROX_PERIODS
}
 Persistence control of APDS9930 Proximity. More...
 

Functions

FctERR APDS9930_Init (const uint8_t idx, I2C_HandleTypeDef *const hi2c, const uint16_t devAddress)
 Initialization for APDS9930 peripheral.
 
FctERR APDS9930_Init_Single (void)
 Initialization for APDS9930 peripheral.
 
FctERR APDS9930_Write (I2C_slave_t *const pSlave, const uint8_t *data, const uint16_t addr, const uint16_t nb)
 I2C Write function for APDS9930.
 
FctERR APDS9930_Read (I2C_slave_t *const pSlave, uint8_t *data, const uint16_t addr, const uint16_t nb)
 I2C Read function for APDS9930.
 
FctERR APDS9930_Write_Word (I2C_slave_t *const pSlave, const uint16_t *data, const uint16_t addr)
 I2C Word Write (little endian) function for APDS9930.
 
FctERR APDS9930_Read_Word (I2C_slave_t *const pSlave, uint16_t *data, const uint16_t addr)
 I2C Word Read (little endian) function for APDS9930.
 
FctERR APDS9930_Write_Special (I2C_slave_t *const pSlave, const APDS9930_spec_func func)
 I2C Special function Write function for APDS9930.
 

Detailed Description

APDS9930 Driver.

Author
SMFSW

APDS9930: Digital Proximity and Ambient Light Sensor

Macro Definition Documentation

◆ APDS9930_ADDR

#define APDS9930_ADDR   0x39U

APDS9930 address.

◆ APDS9930_BASE_ADDR

#define APDS9930_BASE_ADDR   APDS9930_ADDR

APDS9930 Base address.

Note
Define APDS9930_BASE_ADDR to change default device base address

◆ I2C_APDS9930_NB

#define I2C_APDS9930_NB   1U

Number of APDS9930 peripherals.

Note
Define I2C_APDS9930_NB to enable multiple peripherals of this type

Enumeration Type Documentation

◆ APDS9930_als_gain

Gain values of APDS9930 ALS.

Enumerator
APDS9930__ALS_1X_GAIN 

ALS 1X Gain.

APDS9930__ALS_8X_GAIN 

ALS 8X Gain.

APDS9930__ALS_16X_GAIN 

ALS 16X Gain.

APDS9930__ALS_120X_GAIN 

ALS 120X Gain.

◆ APDS9930_als_it_persist

Persistence control of APDS9930 ALS.

Enumerator
APDS9930__PERSIST_EVERY_ALS_CYCLE 

Every ALS cycle generates interrupt.

APDS9930__PERSIST_1_ALS_PERIODS 

1 consecutive Ch0 channel values out of range

APDS9930__PERSIST_2_ALS_PERIODS 

2 consecutive Ch0 channel values out of range

APDS9930__PERSIST_3_ALS_PERIODS 

3 consecutive Ch0 channel values out of range

APDS9930__PERSIST_5_ALS_PERIODS 

5 consecutive Ch0 channel values out of range

APDS9930__PERSIST_10_ALS_PERIODS 

10 consecutive Ch0 channel values out of range

APDS9930__PERSIST_15_ALS_PERIODS 

15 consecutive Ch0 channel values out of range

APDS9930__PERSIST_20_ALS_PERIODS 

20 consecutive Ch0 channel values out of range

APDS9930__PERSIST_25_ALS_PERIODS 

25 consecutive Ch0 channel values out of range

APDS9930__PERSIST_30_ALS_PERIODS 

30 consecutive Ch0 channel values out of range

APDS9930__PERSIST_35_ALS_PERIODS 

35 consecutive Ch0 channel values out of range

APDS9930__PERSIST_40_ALS_PERIODS 

40 consecutive Ch0 channel values out of range

APDS9930__PERSIST_45_ALS_PERIODS 

45 consecutive Ch0 channel values out of range

APDS9930__PERSIST_50_ALS_PERIODS 

50 consecutive Ch0 channel values out of range

APDS9930__PERSIST_55_ALS_PERIODS 

55 consecutive Ch0 channel values out of range

APDS9930__PERSIST_60_ALS_PERIODS 

60 consecutive Ch0 channel values out of range

◆ APDS9930_drive_strength

Proximity LED Drive strength values.

Enumerator
APDS9930__STRENGTH_MAX 

PDL=0 : 100mA ; PDL=1 : 11.1mA.

APDS9930__STRENGTH_HIGH 

PDL=0 : 50mA ; PDL=1 : 5.6mA.

APDS9930__STRENGTH_MEDIUM 

PDL=0 : 25mA ; PDL=1 : 2.8mA.

APDS9930__STRENGTH_LOW 

PDL=0 : 12.5mA ; PDL=1 : 1.4mA.

◆ APDS9930_prox_diode

Proximity Diode Select values.

Enumerator
APDS9930__PDIODE_RESERVED1 

Reserved.

APDS9930__PDIODE_RESERVED2 

Reserved.

APDS9930__PDIODE_CH1 

Proximity uses the Ch1 diode.

APDS9930__PDIODE_RESERVED3 

Reserved.

◆ APDS9930_prox_gain

Gain values of APDS9930 proximity.

Enumerator
APDS9930__PROX_1X_GAIN 

Proximity 1X Gain.

APDS9930__PROX_2X_GAIN 

Proximity 2X Gain.

APDS9930__PROX_4X_GAIN 

Proximity 4X Gain.

APDS9930__PROX_8X_GAIN 

Proximity 8X Gain.

◆ APDS9930_prox_it_persist

Persistence control of APDS9930 Proximity.

Enumerator
APDS9930__PERSIST_EVERY_PROX_CYCLE 

Every proximity cycle generates an interrupt.

APDS9930__PERSIST_1_PROX_PERIODS 

1 consecutive proximity values out of range

APDS9930__PERSIST_2_PROX_PERIODS 

2 consecutive proximity values out of range

APDS9930__PERSIST_3_PROX_PERIODS 

3 consecutive proximity values out of range

APDS9930__PERSIST_4_PROX_PERIODS 

4 consecutive proximity values out of range

APDS9930__PERSIST_5_PROX_PERIODS 

5 consecutive proximity values out of range

APDS9930__PERSIST_6_PROX_PERIODS 

6 consecutive proximity values out of range

APDS9930__PERSIST_7_PROX_PERIODS 

7 consecutive proximity values out of range

APDS9930__PERSIST_8_PROX_PERIODS 

8 consecutive proximity values out of range

APDS9930__PERSIST_9_PROX_PERIODS 

9 consecutive proximity values out of range

APDS9930__PERSIST_10_PROX_PERIODS 

10 consecutive proximity values out of range

APDS9930__PERSIST_11_PROX_PERIODS 

11 consecutive proximity values out of range

APDS9930__PERSIST_12_PROX_PERIODS 

12 consecutive proximity values out of range

APDS9930__PERSIST_13_PROX_PERIODS 

13 consecutive proximity values out of range

APDS9930__PERSIST_14_PROX_PERIODS 

14 consecutive proximity values out of range

APDS9930__PERSIST_15_PROX_PERIODS 

15 consecutive proximity values out of range

◆ APDS9930_reg

Register map enum of APDS9930.

Enumerator
APDS9930__ENABLE 

Enables states and interrupts.

APDS9930__ATIME 

ALS ADC time.

APDS9930__PTIME 

Proximity ADC time.

APDS9930__WTIME 

Wait time.

APDS9930__AILTL 

ALS interrupt low threshold low byte.

APDS9930__AILTH 

ALS interrupt low threshold high byte.

APDS9930__AIHTL 

ALS interrupt high threshold low byte.

APDS9930__AIHTH 

ALS interrupt high threshold high byte.

APDS9930__PILTL 

Proximity interrupt low threshold low byte.

APDS9930__PILTH 

Proximity interrupt low threshold high byte.

APDS9930__PIHTL 

Proximity interrupt high threshold low byte.

APDS9930__PIHTH 

Proximity interrupt high threshold high byte.

APDS9930__PERS 

Interrupt persistence filter.

APDS9930__CONFIG 

Configuration.

APDS9930__PPULSE 

Proximity pulse count.

APDS9930__CONTROL 

Gain control register.

APDS9930__ID 

Device ID.

APDS9930__STATUS 

Device status.

APDS9930__CH0DATAL 

CH0 ADC low data register.

APDS9930__CH0DATAH 

CH0 ADC high data register.

APDS9930__CH1DATAL 

CH1 ADC low data register.

APDS9930__CH1DATAH 

CH1 ADC high data register.

APDS9930__PDATAL 

Proximity ADC low data register.

APDS9930__PDATAH 

Proximity ADC high data register.

APDS9930__POFFSET 

Proximity offset register.

◆ APDS9930_spec_func

Special functions of APDS9930.

Enumerator
APDS9930__SF_CLR_PROX_IT 

Proximity interrupt clear.

APDS9930__SF_CLR_ALS_IT 

ALS interrupt clear.

APDS9930__SF_CLR_PROX_ALS_IT 

Proximity and ALS interrupt clear.

◆ APDS9930_transaction

Transaction types of APDS9930.

Enumerator
APDS9930__TRANS_REPEATED_BYTE 

Repeated Byte protocol transaction.

APDS9930__TRANS_AUTO_INCREMENT 

Auto-Increment protocol transaction.

APDS9930__TRANS_SPECIAL_FUNC 

Special Function.

Function Documentation

◆ APDS9930_Init()

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

Initialization for APDS9930 peripheral.

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

◆ APDS9930_Init_Single()

FctERR APDS9930_Init_Single ( void )

Initialization for APDS9930 peripheral.

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

◆ APDS9930_Read()

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

I2C Read function for APDS9930.

Parameters
[in,out]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:

◆ APDS9930_Read_Word()

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

I2C Word Read (little endian) function for APDS9930.

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:

◆ APDS9930_Write()

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

I2C Write function for APDS9930.

Parameters
[in,out]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:

◆ APDS9930_Write_Special()

FctERR APDS9930_Write_Special ( I2C_slave_t *const pSlave,
const APDS9930_spec_func func )

I2C Special function Write function for APDS9930.

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:

◆ APDS9930_Write_Word()

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

I2C Word Write (little endian) function for APDS9930.

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: