Loading...
Searching...
No Matches
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
9#pragma once
10
25
26#include "saul.h"
27#include "periph/i2c.h"
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
37#define TSL2561_ADDR_LOW (0x29)
38#define TSL2561_ADDR_FLOAT (0x39)
39#define TSL2561_ADDR_HIGH (0x49)
41
46#define TSL2561_INTEGRATIONTIME_13MS (0x00) /* 13.7ms */
47#define TSL2561_INTEGRATIONTIME_101MS (0x01) /* 101ms */
48#define TSL2561_INTEGRATIONTIME_402MS (0x02) /* 402ms */
49#define TSL2561_INTEGRATIONTIME_NA (0x03) /* N/A */
51
56#define TSL2561_GAIN_1X (0x00)
57#define TSL2561_GAIN_16X (0x10)
59
64#define TSL2561_OK (0)
65#define TSL2561_NOI2C (-1)
66#define TSL2561_BADDEV (-2)
68
72typedef struct {
74 uint8_t addr;
75 uint8_t gain;
76 uint8_t integration;
78
82typedef struct {
84} tsl2561_t;
85
96int tsl2561_init(tsl2561_t *dev, const tsl2561_params_t *params);
97
106
107#ifdef __cplusplus
108}
109#endif
110
Definition of the generic [S]ensor [A]ctuator [U]ber [L]ayer.
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:144
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.
Low-level I2C peripheral driver interface definition.
Device initialization parameters.
Definition tsl2561.h:72
uint8_t addr
address on I2C bus
Definition tsl2561.h:74
uint8_t gain
gain
Definition tsl2561.h:75
i2c_t i2c_dev
I2C device which is used.
Definition tsl2561.h:73
uint8_t integration
integration time
Definition tsl2561.h:76
Device descriptor for the TSL2561 sensor.
Definition tsl2561.h:82
tsl2561_params_t params
device initialization parameters
Definition tsl2561.h:83