Loading...
Searching...
No Matches

Device driver interface for the illuminance TSL2561 sensor. More...

Detailed Description

Device driver interface for the illuminance TSL2561 sensor.

This driver provides [S]ensor [A]ctuator [U]ber [L]ayer capabilities.

Files

file  tsl2561.h
 Device driver interface for the illuminance TSL2561 sensor.
 
file  tsl2561_internals.h
 Internal addresses, registers, constants for the TSL2561 sensor.
 
file  tsl2561_params.h
 Default configuration for TSL2561.
 

Data Structures

struct  tsl2561_params_t
 Device initialization parameters. More...
 
struct  tsl2561_t
 Device descriptor for the TSL2561 sensor. More...
 

Functions

int tsl2561_init (tsl2561_t *dev, const tsl2561_params_t *params)
 Initialize the given TSL2561 device.
 
uint16_t tsl2561_read_illuminance (const tsl2561_t *dev)
 Read illuminance value from the given TSL2561 device, returned in lx.
 

TSL2561 I2C addresses

#define TSL2561_ADDR_LOW   (0x29)
 
#define TSL2561_ADDR_FLOAT   (0x39)
 
#define TSL2561_ADDR_HIGH   (0x49)
 

TSL2561 integration times

#define TSL2561_INTEGRATIONTIME_13MS   (0x00) /* 13.7ms */
 
#define TSL2561_INTEGRATIONTIME_101MS   (0x01) /* 101ms */
 
#define TSL2561_INTEGRATIONTIME_402MS   (0x02) /* 402ms */
 
#define TSL2561_INTEGRATIONTIME_NA   (0x03) /* N/A */
 

TSL2561 gains

#define TSL2561_GAIN_1X   (0x00)
 
#define TSL2561_GAIN_16X   (0x10)
 

TSL2561 driver initialization return codes

#define TSL2561_OK   (0)
 
#define TSL2561_NOI2C   (-1)
 
#define TSL2561_BADDEV   (-2)
 

Macro Definition Documentation

◆ TSL2561_ADDR_FLOAT

#define TSL2561_ADDR_FLOAT   (0x39)

Definition at line 39 of file tsl2561.h.

◆ TSL2561_ADDR_HIGH

#define TSL2561_ADDR_HIGH   (0x49)

Definition at line 40 of file tsl2561.h.

◆ TSL2561_ADDR_LOW

#define TSL2561_ADDR_LOW   (0x29)

Definition at line 38 of file tsl2561.h.

◆ TSL2561_BADDEV

#define TSL2561_BADDEV   (-2)

Definition at line 67 of file tsl2561.h.

◆ TSL2561_GAIN_16X

#define TSL2561_GAIN_16X   (0x10)

Definition at line 58 of file tsl2561.h.

◆ TSL2561_GAIN_1X

#define TSL2561_GAIN_1X   (0x00)

Definition at line 57 of file tsl2561.h.

◆ TSL2561_INTEGRATIONTIME_101MS

#define TSL2561_INTEGRATIONTIME_101MS   (0x01) /* 101ms */

Definition at line 48 of file tsl2561.h.

◆ TSL2561_INTEGRATIONTIME_13MS

#define TSL2561_INTEGRATIONTIME_13MS   (0x00) /* 13.7ms */

Definition at line 47 of file tsl2561.h.

◆ TSL2561_INTEGRATIONTIME_402MS

#define TSL2561_INTEGRATIONTIME_402MS   (0x02) /* 402ms */

Definition at line 49 of file tsl2561.h.

◆ TSL2561_INTEGRATIONTIME_NA

#define TSL2561_INTEGRATIONTIME_NA   (0x03) /* N/A */

Definition at line 50 of file tsl2561.h.

◆ TSL2561_NOI2C

#define TSL2561_NOI2C   (-1)

Definition at line 66 of file tsl2561.h.

◆ TSL2561_OK

#define TSL2561_OK   (0)

Definition at line 65 of file tsl2561.h.

Function Documentation

◆ tsl2561_init()

int tsl2561_init ( tsl2561_t dev,
const tsl2561_params_t params 
)

Initialize the given TSL2561 device.

Parameters
[out]devInitialized device descriptor of BMP180 device
[in]paramsInitialization parameters
Returns
0 on success
-1 if given I2C is not available
-2 if not a TSL2561 sensor

◆ tsl2561_read_illuminance()

uint16_t tsl2561_read_illuminance ( const tsl2561_t dev)

Read illuminance value from the given TSL2561 device, returned in lx.

Parameters
[in]devDevice descriptor of TSL2561 device to read from
Returns
Illuminance in Lux (lx)