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 
21 #ifndef TSL2561_H
22 #define TSL2561_H
23 
24 #include "saul.h"
25 #include "periph/i2c.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
35 #define TSL2561_ADDR_LOW (0x29)
36 #define TSL2561_ADDR_FLOAT (0x39)
37 #define TSL2561_ADDR_HIGH (0x49)
38 
44 #define TSL2561_INTEGRATIONTIME_13MS (0x00) /* 13.7ms */
45 #define TSL2561_INTEGRATIONTIME_101MS (0x01) /* 101ms */
46 #define TSL2561_INTEGRATIONTIME_402MS (0x02) /* 402ms */
47 #define TSL2561_INTEGRATIONTIME_NA (0x03) /* N/A */
48 
54 #define TSL2561_GAIN_1X (0x00)
55 #define TSL2561_GAIN_16X (0x10)
56 
62 #define TSL2561_OK (0)
63 #define TSL2561_NOI2C (-1)
64 #define TSL2561_BADDEV (-2)
65 
70 typedef struct {
72  uint8_t addr;
73  uint8_t gain;
74  uint8_t integration;
75 } tsl2561_t;
76 
77 
82 
96 int tsl2561_init(tsl2561_t *dev, i2c_t i2c, uint8_t addr,
97  uint8_t gain, uint8_t integration);
98 
106 uint16_t tsl2561_read_illuminance(tsl2561_t *dev);
107 
108 #ifdef __cplusplus
109 }
110 #endif
111 
112 #endif /* TSL2561_H */
113 
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:104
Device descriptor for the TSL2561 sensor.
Definition: tsl2561.h:70
tsl2561_t tsl2561_params_t
Device initialization parameters.
Definition: tsl2561.h:81
uint8_t gain
gain
Definition: tsl2561.h:73
Definition of the generic [S]ensor [A]ctuator [U]ber [L]ayer.
uint16_t tsl2561_read_illuminance(tsl2561_t *dev)
Read illuminance value from the given TSL2561 device, returned in lx.
int tsl2561_init(tsl2561_t *dev, i2c_t i2c, uint8_t addr, uint8_t gain, uint8_t integration)
Initialize the given TSL2561 device.
uint8_t integration
integration time
Definition: tsl2561.h:74
i2c_t i2c_dev
I2C device which is used.
Definition: tsl2561.h:71
uint8_t addr
address on I2C bus
Definition: tsl2561.h:72
Low-level I2C peripheral driver interface definition.