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

TSL2591 Driver. More...

#include "sarmfsw.h"
#include "I2C_component.h"
#include "I2C_peripheral.h"
#include "TSL2591_proc.h"
#include "TSL2591_ex.h"
Include dependency graph for TSL2591.h:
This graph shows which files directly or indirectly include this file:

Data Structures

union  uTSL2591_CMD
 Union for COMMAND register of TSL2591. More...
 
union  uTSL2591_REG__ENABLE
 Union for ENABLE register of TSL2591. More...
 
union  uTSL2591_REG__CONFIG
 Union for CONFIG register of TSL2591. More...
 
union  uTSL2591_REG__PERSIST
 Union for PERSIST register of TSL2591. More...
 
union  uTSL2591_REG__STATUS
 Union for STATUS register of TSL2591. More...
 

Macros

#define I2C_TSL2591_NB   1U
 Number of TSL2591 peripherals.
 
#define TSL2591_BASE_ADDR   0x29U
 TSL2591 Base address.
 

Enumerations

enum  TSL2591_reg {
  TSL2591__ENABLE = 0U , TSL2591__CONFIG , TSL2591__AILTL = 0x04U , TSL2591__AILTH ,
  TSL2591__AIHTL , TSL2591__AIHTH , TSL2591__NPAILTL , TSL2591__NPAILTH ,
  TSL2591__NPAIHTL , TSL2591__NPAIHTH , TSL2591__PERSIST , TSL2591__PID = 0x11U ,
  TSL2591__ID , TSL2591__STATUS , TSL2591__C0DATAL , TSL2591__C0DATAH ,
  TSL2591__C1DATAL , TSL2591__C1DATAH
}
 Register map enum of TSL2591. More...
 
enum  TSL2591_transaction { TSL2591__TRANS_NORMAL_OP = 1U , TSL2591__TRANS_SPECIAL_FUNC = 3U }
 Transaction types of TSL2591. More...
 
enum  TSL2591_spec_func { TSL2591__SF_FORCE_IT = 4U , TSL2591__SF_CLR_ALS_IT = 6U , TSL2591__SF_CLR_ALS_AND_NO_PERS = 7U , TSL2591__SF_CLR_NO_PERS = 9U }
 Special functions of TSL2591. More...
 
enum  TSL2591_gain { TSL2591__LOW_GAIN = 0U , TSL2591__MEDIUM_GAIN , TSL2591__HIGH_GAIN , TSL2591__MAXIMUM_GAIN }
 Gain values of TSL2591. More...
 
enum  TSL2591_integ {
  TSL2591__INTEG_100MS = 0U , TSL2591__INTEG_200MS , TSL2591__INTEG_300MS , TSL2591__INTEG_400MS ,
  TSL2591__INTEG_500MS , TSL2591__INTEG_600MS
}
 Integration times of TSL2591. More...
 
enum  TSL2591_it_persist {
  TSL2591__PERSIST_EVERY_ADC_CYCLE = 0U , TSL2591__PERSIST_ANY_OUTSIDE_THRESHOLD , TSL2591__PERSIST_2_IT_PERIODS , TSL2591__PERSIST_3_IT_PERIODS ,
  TSL2591__PERSIST_5_IT_PERIODS , TSL2591__PERSIST_10_IT_PERIODS , TSL2591__PERSIST_15_IT_PERIODS , TSL2591__PERSIST_20_IT_PERIODS ,
  TSL2591__PERSIST_25_IT_PERIODS , TSL2591__PERSIST_30_IT_PERIODS , TSL2591__PERSIST_35_IT_PERIODS , TSL2591__PERSIST_40_IT_PERIODS ,
  TSL2591__PERSIST_45_IT_PERIODS , TSL2591__PERSIST_50_IT_PERIODS , TSL2591__PERSIST_55_IT_PERIODS , TSL2591__PERSIST_60_IT_PERIODS
}
 Persistence control of TSL2591. More...
 

Functions

FctERR TSL2591_Init (const uint8_t idx, I2C_HandleTypeDef *const hi2c, const uint16_t devAddress)
 Initialization for TSL2591 peripheral.
 
FctERR TSL2591_Init_Single (void)
 Initialization for TSL2591 peripheral.
 
FctERR TSL2591_Write (I2C_slave_t *const pSlave, const uint8_t *data, const uint16_t addr, const uint16_t nb)
 I2C Write function for TSL2591.
 
FctERR TSL2591_Read (I2C_slave_t *const pSlave, uint8_t *data, const uint16_t addr, const uint16_t nb)
 I2C Read function for TSL2591.
 
FctERR TSL2591_Write_Word (I2C_slave_t *const pSlave, const uint16_t *data, const uint16_t addr)
 I2C Word Write (little endian) function for TSL2591.
 
FctERR TSL2591_Read_Word (I2C_slave_t *const pSlave, uint16_t *data, const uint16_t addr)
 I2C Word Read (little endian) function for TSL2591.
 
FctERR TSL2591_Write_Special (I2C_slave_t *const pSlave, const TSL2591_spec_func func)
 I2C Special function Write function for TSL2591.
 

Detailed Description

TSL2591 Driver.

Author
SMFSW

TSL2591: Very-high sensitivity light-to-digital converter

Macro Definition Documentation

◆ I2C_TSL2591_NB

#define I2C_TSL2591_NB   1U

Number of TSL2591 peripherals.

Note
Define I2C_TSL2591_NB to enable multiple peripherals of this type

◆ TSL2591_BASE_ADDR

#define TSL2591_BASE_ADDR   0x29U

TSL2591 Base address.

Note
Define TSL2591_BASE_ADDR to change default device base address

Enumeration Type Documentation

◆ TSL2591_gain

Gain values of TSL2591.

Enumerator
TSL2591__LOW_GAIN 

Low gain mode (x1)

TSL2591__MEDIUM_GAIN 

Medium gain mode (x25)

TSL2591__HIGH_GAIN 

High gain mode (x428)

TSL2591__MAXIMUM_GAIN 

Maximum gain mode (x9876)

◆ TSL2591_integ

Integration times of TSL2591.

Enumerator
TSL2591__INTEG_100MS 

100ms integration time

TSL2591__INTEG_200MS 

200ms integration time

TSL2591__INTEG_300MS 

300ms integration time

TSL2591__INTEG_400MS 

400ms integration time

TSL2591__INTEG_500MS 

500ms integration time

TSL2591__INTEG_600MS 

600ms integration time

◆ TSL2591_it_persist

Persistence control of TSL2591.

Enumerator
TSL2591__PERSIST_EVERY_ADC_CYCLE 

Every ADC cycle generates interrupt.

TSL2591__PERSIST_ANY_OUTSIDE_THRESHOLD 

Any value outside of threshold range.

TSL2591__PERSIST_2_IT_PERIODS 

2 integration time periods out of range

TSL2591__PERSIST_3_IT_PERIODS 

3 integration time periods out of range

TSL2591__PERSIST_5_IT_PERIODS 

5 integration time periods out of range

TSL2591__PERSIST_10_IT_PERIODS 

10 integration time periods out of range

TSL2591__PERSIST_15_IT_PERIODS 

15 integration time periods out of range

TSL2591__PERSIST_20_IT_PERIODS 

20 integration time periods out of range

TSL2591__PERSIST_25_IT_PERIODS 

25 integration time periods out of range

TSL2591__PERSIST_30_IT_PERIODS 

30 integration time periods out of range

TSL2591__PERSIST_35_IT_PERIODS 

35 integration time periods out of range

TSL2591__PERSIST_40_IT_PERIODS 

40 integration time periods out of range

TSL2591__PERSIST_45_IT_PERIODS 

45 integration time periods out of range

TSL2591__PERSIST_50_IT_PERIODS 

50 integration time periods out of range

TSL2591__PERSIST_55_IT_PERIODS 

55 integration time periods out of range

TSL2591__PERSIST_60_IT_PERIODS 

60 integration time periods out of range

◆ TSL2591_reg

Register map enum of TSL2591.

Enumerator
TSL2591__ENABLE 

Enables states and interrupts.

TSL2591__CONFIG 

ALS gain and integration time configuration.

TSL2591__AILTL 

ALS interrupt low threshold low byte.

TSL2591__AILTH 

ALS interrupt low threshold high byte.

TSL2591__AIHTL 

ALS interrupt high threshold low byte.

TSL2591__AIHTH 

ALS interrupt high threshold high byte.

TSL2591__NPAILTL 

No Persist ALS interrupt low threshold low byte.

TSL2591__NPAILTH 

No Persist ALS interrupt low threshold high byte.

TSL2591__NPAIHTL 

No Persist ALS interrupt high threshold low byte.

TSL2591__NPAIHTH 

No Persist ALS interrupt high threshold high byte.

TSL2591__PERSIST 

Interrupt persistence filter.

TSL2591__PID 

Package ID.

TSL2591__ID 

Device ID.

TSL2591__STATUS 

Device status.

TSL2591__C0DATAL 

CH0 ADC low data byte.

TSL2591__C0DATAH 

CH0 ADC high data byte.

TSL2591__C1DATAL 

CH1 ADC low data byte.

TSL2591__C1DATAH 

CH1 ADC high data byte.

◆ TSL2591_spec_func

Special functions of TSL2591.

Enumerator
TSL2591__SF_FORCE_IT 

Interrupt set (forces an interrupt)

TSL2591__SF_CLR_ALS_IT 

Clears ALS interrupt.

TSL2591__SF_CLR_ALS_AND_NO_PERS 

Clears ALS and no persist ALS interrupt.

TSL2591__SF_CLR_NO_PERS 

Clears no persist ALS interrupt.

◆ TSL2591_transaction

Transaction types of TSL2591.

Enumerator
TSL2591__TRANS_NORMAL_OP 

Normal operation.

TSL2591__TRANS_SPECIAL_FUNC 

Special Function.

Function Documentation

◆ TSL2591_Init()

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

Initialization for TSL2591 peripheral.

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

◆ TSL2591_Init_Single()

FctERR TSL2591_Init_Single ( void )

Initialization for TSL2591 peripheral.

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

◆ TSL2591_Read()

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

I2C Read function for TSL2591.

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:

◆ TSL2591_Read_Word()

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

I2C Word Read (little endian) function for TSL2591.

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:

◆ TSL2591_Write()

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

I2C Write function for TSL2591.

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:

◆ TSL2591_Write_Special()

FctERR TSL2591_Write_Special ( I2C_slave_t *const pSlave,
const TSL2591_spec_func func )

I2C Special function Write function for TSL2591.

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:

◆ TSL2591_Write_Word()

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

I2C Word Write (little endian) function for TSL2591.

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: