tsl2561.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Inria
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
24 #ifndef TSL2561_H
25 #define TSL2561_H
26 
27 #include "saul.h"
28 #include "periph/i2c.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
38 #define TSL2561_ADDR_LOW (0x29)
39 #define TSL2561_ADDR_FLOAT (0x39)
40 #define TSL2561_ADDR_HIGH (0x49)
41 
47 #define TSL2561_INTEGRATIONTIME_13MS (0x00) /* 13.7ms */
48 #define TSL2561_INTEGRATIONTIME_101MS (0x01) /* 101ms */
49 #define TSL2561_INTEGRATIONTIME_402MS (0x02) /* 402ms */
50 #define TSL2561_INTEGRATIONTIME_NA (0x03) /* N/A */
51 
57 #define TSL2561_GAIN_1X (0x00)
58 #define TSL2561_GAIN_16X (0x10)
59 
65 #define TSL2561_OK (0)
66 #define TSL2561_NOI2C (-1)
67 #define TSL2561_BADDEV (-2)
68 
73 typedef struct {
75  uint8_t addr;
76  uint8_t gain;
77  uint8_t integration;
79 
83 typedef struct {
85 } tsl2561_t;
86 
97 int tsl2561_init(tsl2561_t *dev, const tsl2561_params_t *params);
98 
106 uint16_t tsl2561_read_illuminance(const tsl2561_t *dev);
107 
108 #ifdef __cplusplus
109 }
110 #endif
111 
112 #endif /* TSL2561_H */
113 
uint8_t gain
gain
Definition: tsl2561.h:76
uint16_t tsl2561_read_illuminance(const tsl2561_t *dev)
Read illuminance value from the given TSL2561 device, returned in lx.
tsl2561_params_t params
device initialization parameters
Definition: tsl2561.h:84
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:157
Device descriptor for the TSL2561 sensor.
Definition: tsl2561.h:83
Definition of the generic [S]ensor [A]ctuator [U]ber [L]ayer.
uint8_t addr
address on I2C bus
Definition: tsl2561.h:75
Device initialization parameters.
Definition: tsl2561.h:73
uint8_t integration
integration time
Definition: tsl2561.h:77
i2c_t i2c_dev
I2C device which is used.
Definition: tsl2561.h:74
int tsl2561_init(tsl2561_t *dev, const tsl2561_params_t *params)
Initialize the given TSL2561 device.
Low-level I2C peripheral driver interface definition.