Loading...
Searching...
No Matches
tsl2561.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016 Inria
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
22
23#include "saul.h"
24#include "periph/i2c.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
34#define TSL2561_ADDR_LOW (0x29)
35#define TSL2561_ADDR_FLOAT (0x39)
36#define TSL2561_ADDR_HIGH (0x49)
38
43#define TSL2561_INTEGRATIONTIME_13MS (0x00) /* 13.7ms */
44#define TSL2561_INTEGRATIONTIME_101MS (0x01) /* 101ms */
45#define TSL2561_INTEGRATIONTIME_402MS (0x02) /* 402ms */
46#define TSL2561_INTEGRATIONTIME_NA (0x03) /* N/A */
48
53#define TSL2561_GAIN_1X (0x00)
54#define TSL2561_GAIN_16X (0x10)
56
61#define TSL2561_OK (0)
62#define TSL2561_NOI2C (-1)
63#define TSL2561_BADDEV (-2)
65
69typedef struct {
71 uint8_t addr;
72 uint8_t gain;
73 uint8_t integration;
75
79typedef struct {
81} tsl2561_t;
82
93int tsl2561_init(tsl2561_t *dev, const tsl2561_params_t *params);
94
103
104#ifdef __cplusplus
105}
106#endif
107
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:155
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:69
uint8_t addr
address on I2C bus
Definition tsl2561.h:71
uint8_t gain
gain
Definition tsl2561.h:72
i2c_t i2c_dev
I2C device which is used.
Definition tsl2561.h:70
uint8_t integration
integration time
Definition tsl2561.h:73
Device descriptor for the TSL2561 sensor.
Definition tsl2561.h:79
tsl2561_params_t params
device initialization parameters
Definition tsl2561.h:80