tsl4531x.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Freie Universität Berlin
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 
41 #ifndef TSL4531X_H
42 #define TSL4531X_H
43 
44 #include <stdint.h>
45 
46 #include "periph/i2c.h"
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
55 typedef enum {
56  TSL4531X_INTEGRATE_400MS = 0, /* 0b00 */
57  TSL4531X_INTEGRATE_200MS = 1, /* 0b01 */
58  TSL4531X_INTEGRATE_100MS = 2, /* 0b10 */
60 
67 #define TSL45311_PARTNO (0x8)
68 #define TSL45313_PARTNO (0x9)
69 #define TSL45315_PARTNO (0xA)
70 #define TSL45317_PARTNO (0xB)
71 
75 #define TSL45311_ADDR (0x39)
76 #define TSL45313_ADDR (0x39)
77 #define TSL45315_ADDR (0x29)
78 #define TSL45317_ADDR (0x29)
79 
84 typedef struct {
88  uint8_t low_power_mode : 1;
89  uint8_t part_number;
91 
95 typedef struct {
99  uint8_t low_power_mode : 1;
101  uint32_t sample_start_time;
102 } tsl4531x_t;
103 
115 int tsl4531x_init(tsl4531x_t *dev, const tsl4531x_params_t *params);
116 
125 int tsl4531x_set_low_power_mode(tsl4531x_t *dev, uint8_t low_power_on);
126 
137 
158 
176 int tsl4531x_get_sample(const tsl4531x_t *dev);
177 
189 
190 #ifdef __cplusplus
191 }
192 #endif
193 
194 #endif /* TSL4531X_H */
195 
tsl4531x_intgn_time_t
tsl4531x_intgn_time_t
Integration times.
Definition: tsl4531x.h:55
tsl4531x_params_t::low_power_mode
uint8_t low_power_mode
low power mode
Definition: tsl4531x.h:88
tsl4531x_params_t
Device initialization parameters.
Definition: tsl4531x.h:84
tsl4531x_time_until_sample_ready
uint32_t tsl4531x_time_until_sample_ready(tsl4531x_t *dev)
Deliver time in microseconds until sample is ready, or zero if it is ready.
i2c_t
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:151
tsl4531x_get_sample
int tsl4531x_get_sample(const tsl4531x_t *dev)
Reads the sample from the device immediately.
tsl4531x_t::integration_time
tsl4531x_intgn_time_t integration_time
integration time
Definition: tsl4531x.h:98
tsl4531x_t::sample_start_time
uint32_t sample_start_time
sample start time
Definition: tsl4531x.h:101
tsl4531x_params_t::i2c_dev
i2c_t i2c_dev
I2C device which is used.
Definition: tsl4531x.h:85
tsl4531x_t::high_power_mode_started_up
uint8_t high_power_mode_started_up
high power mode started up flag
Definition: tsl4531x.h:100
tsl4531x_simple_read
int tsl4531x_simple_read(tsl4531x_t *dev)
Reads the sample from the device.
tsl4531x_init
int tsl4531x_init(tsl4531x_t *dev, const tsl4531x_params_t *params)
Initialize the TSL4531x device.
tsl4531x_start_sample
int tsl4531x_start_sample(tsl4531x_t *dev)
Start collecting sample in low power mode.
tsl4531x_params_t::i2c_addr
i2c_t i2c_addr
I2C address of sensor.
Definition: tsl4531x.h:86
tsl4531x_params_t::part_number
uint8_t part_number
part number, according to variant
Definition: tsl4531x.h:89
tsl4531x_t
Device descriptor.
Definition: tsl4531x.h:95
tsl4531x_set_low_power_mode
int tsl4531x_set_low_power_mode(tsl4531x_t *dev, uint8_t low_power_on)
Set the low power mode of the driver on or off.
tsl4531x_params_t::integration_time
tsl4531x_intgn_time_t integration_time
integration time
Definition: tsl4531x.h:87
tsl4531x_t::i2c_dev
i2c_t i2c_dev
I2C device which is used.
Definition: tsl4531x.h:96
i2c.h
Low-level I2C peripheral driver interface definition.
tsl4531x_t::i2c_addr
i2c_t i2c_addr
I2C address of sensor.
Definition: tsl4531x.h:97
tsl4531x_t::low_power_mode
uint8_t low_power_mode
low power mode
Definition: tsl4531x.h:99