vcnl40x0.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 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 
23 #ifndef VCNL40X0_H
24 #define VCNL40X0_H
25 
26 #include "saul.h"
27 #include "periph/i2c.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
36 enum {
45 };
46 
50 enum {
59 };
60 
66 enum {
75 };
76 
80 enum {
84 };
85 
89 typedef struct {
91  uint8_t i2c_addr;
92  uint8_t led_current;
93  uint8_t proximity_rate;
94  uint8_t ambient_rate;
95  uint8_t ambient_avg;
97 
101 typedef struct {
103 } vcnl40x0_t;
104 
115 int vcnl40x0_init(vcnl40x0_t *dev, const vcnl40x0_params_t *params);
116 
124 uint16_t vcnl40x0_read_proximity(const vcnl40x0_t *dev);
125 
133 uint16_t vcnl40x0_read_ambient_light(const vcnl40x0_t *dev);
134 
142 uint16_t vcnl40x0_read_illuminance(const vcnl40x0_t *dev);
143 
144 #ifdef __cplusplus
145 }
146 #endif
147 
148 #endif /* VCNL40X0_H */
149 
VCNL40X0_AMBIENT_AVERAGE_64
@ VCNL40X0_AMBIENT_AVERAGE_64
Decimal value 64.
Definition: vcnl40x0.h:73
vcnl40x0_params_t::ambient_rate
uint8_t ambient_rate
Ambient light rate.
Definition: vcnl40x0.h:94
VCNL40X0_PROXIMITY_RATE_125
@ VCNL40X0_PROXIMITY_RATE_125
125 measurements/s
Definition: vcnl40x0.h:43
VCNL40X0_PROXIMITY_RATE_250
@ VCNL40X0_PROXIMITY_RATE_250
250 measurements/s
Definition: vcnl40x0.h:44
VCNL40X0_AMBIENT_AVERAGE_4
@ VCNL40X0_AMBIENT_AVERAGE_4
Decimal value 4.
Definition: vcnl40x0.h:69
VCNL40X0_AMBIENT_AVERAGE_1
@ VCNL40X0_AMBIENT_AVERAGE_1
Decimal value 1.
Definition: vcnl40x0.h:67
VCNL40X0_OK
@ VCNL40X0_OK
Everything was fine.
Definition: vcnl40x0.h:81
VCNL40X0_AMBIENT_AVERAGE_16
@ VCNL40X0_AMBIENT_AVERAGE_16
Decimal value 16.
Definition: vcnl40x0.h:71
VCNL40X0_AMBIENT_RATE_4
@ VCNL40X0_AMBIENT_RATE_4
4 sample/s
Definition: vcnl40x0.h:54
vcnl40x0_t
Device descriptor for the VCNL40X0 sensor.
Definition: vcnl40x0.h:101
VCNL40X0_PROXIMITY_RATE_62
@ VCNL40X0_PROXIMITY_RATE_62
62.5 measurements/s
Definition: vcnl40x0.h:42
i2c_t
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:151
vcnl40x0_params_t::i2c_dev
i2c_t i2c_dev
I2C device which is used.
Definition: vcnl40x0.h:90
VCNL40X0_PROXIMITY_RATE_4
@ VCNL40X0_PROXIMITY_RATE_4
3.90625 measurements/s
Definition: vcnl40x0.h:38
vcnl40x0_params_t::ambient_avg
uint8_t ambient_avg
Ambient light conversion average.
Definition: vcnl40x0.h:95
VCNL40X0_ERR_NODEV
@ VCNL40X0_ERR_NODEV
Error wrong device.
Definition: vcnl40x0.h:83
vcnl40x0_params_t
Device initialization parameters.
Definition: vcnl40x0.h:89
VCNL40X0_AMBIENT_RATE_5
@ VCNL40X0_AMBIENT_RATE_5
5 sample/s
Definition: vcnl40x0.h:55
VCNL40X0_AMBIENT_RATE_8
@ VCNL40X0_AMBIENT_RATE_8
8 sample/s
Definition: vcnl40x0.h:57
VCNL40X0_PROXIMITY_RATE_16
@ VCNL40X0_PROXIMITY_RATE_16
16.625 measurements/s
Definition: vcnl40x0.h:40
VCNL40X0_AMBIENT_RATE_10
@ VCNL40X0_AMBIENT_RATE_10
10 sample/s
Definition: vcnl40x0.h:58
vcnl40x0_init
int vcnl40x0_init(vcnl40x0_t *dev, const vcnl40x0_params_t *params)
Initialize the given VCNL40X0 device.
VCNL40X0_PROXIMITY_RATE_8
@ VCNL40X0_PROXIMITY_RATE_8
7.8125 measurements/s
Definition: vcnl40x0.h:39
VCNL40X0_AMBIENT_RATE_2
@ VCNL40X0_AMBIENT_RATE_2
2 sample/s (default)
Definition: vcnl40x0.h:52
vcnl40x0_t::params
vcnl40x0_params_t params
Device parameters.
Definition: vcnl40x0.h:102
vcnl40x0_params_t::led_current
uint8_t led_current
LED current.
Definition: vcnl40x0.h:92
VCNL40X0_AMBIENT_AVERAGE_2
@ VCNL40X0_AMBIENT_AVERAGE_2
Decimal value 2.
Definition: vcnl40x0.h:68
vcnl40x0_params_t::i2c_addr
uint8_t i2c_addr
Address on I2C bus.
Definition: vcnl40x0.h:91
VCNL40X0_PROXIMITY_RATE_2
@ VCNL40X0_PROXIMITY_RATE_2
1.95 measurements/s (default)
Definition: vcnl40x0.h:37
vcnl40x0_read_proximity
uint16_t vcnl40x0_read_proximity(const vcnl40x0_t *dev)
Read proximity value from the vcnl40X0 device.
VCNL40X0_AMBIENT_AVERAGE_8
@ VCNL40X0_AMBIENT_AVERAGE_8
Decimal value 8.
Definition: vcnl40x0.h:70
VCNL40X0_ERR_I2C
@ VCNL40X0_ERR_I2C
Error initializing the I2C bus.
Definition: vcnl40x0.h:82
VCNL40X0_AMBIENT_RATE_1
@ VCNL40X0_AMBIENT_RATE_1
1 sample/s
Definition: vcnl40x0.h:51
VCNL40X0_PROXIMITY_RATE_31
@ VCNL40X0_PROXIMITY_RATE_31
31.25 measurements/s
Definition: vcnl40x0.h:41
saul.h
Definition of the generic [S]ensor [A]ctuator [U]ber [L]ayer.
VCNL40X0_AMBIENT_RATE_6
@ VCNL40X0_AMBIENT_RATE_6
6 sample/s
Definition: vcnl40x0.h:56
VCNL40X0_AMBIENT_AVERAGE_32
@ VCNL40X0_AMBIENT_AVERAGE_32
Decimal value 32 (default)
Definition: vcnl40x0.h:72
vcnl40x0_params_t::proximity_rate
uint8_t proximity_rate
Proximity rate.
Definition: vcnl40x0.h:93
i2c.h
Low-level I2C peripheral driver interface definition.
VCNL40X0_AMBIENT_AVERAGE_128
@ VCNL40X0_AMBIENT_AVERAGE_128
Decimal value 128.
Definition: vcnl40x0.h:74
vcnl40x0_read_ambient_light
uint16_t vcnl40x0_read_ambient_light(const vcnl40x0_t *dev)
Read ambient light value from the vcnl40X0 device.
VCNL40X0_AMBIENT_RATE_3
@ VCNL40X0_AMBIENT_RATE_3
3 sample/s
Definition: vcnl40x0.h:53
vcnl40x0_read_illuminance
uint16_t vcnl40x0_read_illuminance(const vcnl40x0_t *dev)
Read illuminance value from the vcnl40X0 device.