a752c7ab
elopes
add first test an...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
/*
* Copyright (C) 2015 PHYTEC Messtechnik GmbH
* 2017 Freie Universitรคt Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @defgroup drivers_tcs37727 TCS37727 RGB Light Sensor
* @ingroup drivers_sensors
* @brief Driver for the AMS TCS37727 Color Light-To-Digital Converter
*
*
* @{
*
* @file
* @brief Interface definition for the TCS37727 sensor driver.
*
* @author Felix Siebel <f.siebel@phytec.de>
* @author Johann Fischer <j.fischer@phytec.de>
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*/
#ifndef TCS37727_H
#define TCS37727_H
#include <stdint.h>
#include "saul.h"
#include "periph/i2c.h"
#ifdef __cplusplus
extern "C"
{
#endif
#ifndef TCS37727_I2C_ADDRESS
#define TCS37727_I2C_ADDRESS 0x29 /**< Default Device Address */
#endif
#ifndef TCS37727_ATIME_DEFAULT
#define TCS37727_ATIME_DEFAULT 200000 /**< Default RGBC integration time */
#endif
/**
* @brief Struct for storing TCS37727 sensor data
*/
typedef struct {
uint32_t red; /**< IR compensated channels red */
uint32_t green; /**< IR compensated channels green */
uint32_t blue; /**< IR compensated channels blue */
uint32_t clear; /**< channels clear */
uint32_t lux; /**< Lux */
uint32_t ct; /**< Color temperature */
} tcs37727_data_t;
/**
* @brief TCS37727 configuration parameters
*/
typedef struct {
i2c_t i2c; /**< I2C bus the sensor is connected to */
uint8_t addr; /**< the sensors address on the I2C bus */
uint32_t atime; /**< conversion time in microseconds */
} tcs37727_params_t;
/**
* @brief Device descriptor for TCS37727 sensors
*/
typedef struct {
tcs37727_params_t p; /**< device configuration */
int again; /**< amount of gain */
} tcs37727_t;
/**
* @brief Possible TCS27737 return values
*/
enum {
TCS37727_OK = 0, /**< everything worked as expected */
TCS37727_NOBUS = -1, /**< access to the configured I2C bus failed */
TCS37727_NODEV = -2 /**< no TCS37727 device found on the bus */
};
/**
* @brief Export the sensor's SAUL interface
*/
extern const saul_driver_t tcs37727_saul_driver;
/**
* @brief Initialize the given TCS37727 sensor
*
* The sensor is initialized in RGBC only mode with proximity detection turned
* off.
*
* The gain will be initially set to 4x, but it will be adjusted
*
* The gain value will be initially set to 4x, but it will be automatically
* adjusted during runtime.
*
* @param[out] dev device descriptor of sensor to initialize
* @param[in] params static configuration parameters
*
* @return TCS27737_OK on success
* @return TCS37727_NOBUS if initialization of I2C bus fails
* @return TCS37727_NODEV if no sensor can be found
*/
int tcs37727_init(tcs37727_t *dev, const tcs37727_params_t *params);
/**
* @brief Set RGBC enable, this activates periodic RGBC measurements.
*
* @param[out] dev device descriptor of sensor
*/
void tcs37727_set_rgbc_active(const tcs37727_t *dev);
/**
* @brief Set RGBC disable, this deactivates periodic RGBC measurements
*
* Also turns off the sensor when proximity measurement is disabled.
*
* @param[in] dev device descriptor of sensor
*/
void tcs37727_set_rgbc_standby(const tcs37727_t *dev);
/**
* @brief Read sensor's data
*
* Besides an Autogain routine is called. If a maximum or minimum threshold
* value of the channel clear is reached, then the gain will be changed
* correspond to max or min threshold.
*
* @param[in] dev device descriptor of sensor
* @param[out] data device sensor data, MUST not be NULL
*/
void tcs37727_read(const tcs37727_t *dev, tcs37727_data_t *data);
#ifdef __cplusplus
}
#endif
#endif /* TCS37727_H */
/** @} */
|