Loading...
Searching...
No Matches
vl6180x_params.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2021 Gunar Schorcht
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
17#ifndef VL6180X_PARAMS_H
18#define VL6180X_PARAMS_H
19
20#include "board.h"
21#include "saul_reg.h"
22#include "vl6180x.h"
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
32#ifndef VL6180X_PARAM_DEV
34#define VL6180X_PARAM_DEV I2C_DEV(0)
35#endif
36
37#ifndef VL6180X_PARAM_ADDR
39#define VL6180X_PARAM_ADDR (VL6180X_I2C_ADDR)
40#endif
41
42#ifndef VL6180X_PARAM_INT_PIN
44#define VL6180X_PARAM_INT_PIN (GPIO_PIN(0, 1))
45#endif
46
47#ifndef VL6180X_PARAM_SHUTDOWN_PIN
49#define VL6180X_PARAM_SHUTDOWN_PIN (GPIO_PIN(0, 2))
50#endif
57#if !DOXYGEN
58/* Mapping of Kconfig defines to the respective driver enumeration values */
59
60#ifdef CONFIG_VL6180X_ALS_GAIN_1
61#define CONFIG_VL6180X_ALS_GAIN (VL6180X_ALS_GAIN_1)
62#elif CONFIG_VL6180X_ALS_GAIN_1_25
63#define CONFIG_VL6180X_ALS_GAIN (VL6180X_ALS_GAIN_1_25)
64#elif CONFIG_VL6180X_ALS_GAIN_1_67
65#define CONFIG_VL6180X_ALS_GAIN (VL6180X_ALS_GAIN_1_67)
66#elif CONFIG_VL6180X_ALS_GAIN_2_5
67#define CONFIG_VL6180X_ALS_GAIN (VL6180X_ALS_GAIN_2_5)
68#elif CONFIG_VL6180X_ALS_GAIN_5
69#define CONFIG_VL6180X_ALS_GAIN (VL6180X_ALS_GAIN_5)
70#elif CONFIG_VL6180X_ALS_GAIN_10
71#define CONFIG_VL6180X_ALS_GAIN (VL6180X_ALS_GAIN_10)
72#elif CONFIG_VL6180X_ALS_GAIN_20
73#define CONFIG_VL6180X_ALS_GAIN (VL6180X_ALS_GAIN_20)
74#elif CONFIG_VL6180X_ALS_GAIN_40
75#define CONFIG_VL6180X_ALS_GAIN (VL6180X_ALS_GAIN_40)
76#endif
77
78#ifdef CONFIG_VL6180X_RNG_INT_DRDY
79#define CONFIG_VL6180X_RNG_INT (VL6180X_INT_DRDY)
80#elif CONFIG_VL6180X_RNG_INT_LOW
81#define CONFIG_VL6180X_RNG_INT (VL6180X_INT_LOW)
82#elif CONFIG_VL6180X_RNG_INT_HIGH
83#define CONFIG_VL6180X_RNG_INT (VL6180X_INT_HIGH)
84#elif CONFIG_VL6180X_RNG_INT_OUT
85#define CONFIG_VL6180X_RNG_INT (VL6180X_INT_OUT)
86#endif
87
88#ifdef CONFIG_VL6180X_ALS_INT_DRDY
89#define CONFIG_VL6180X_ALS_INT (VL6180X_INT_DRDY)
90#elif CONFIG_VL6180X_ALS_INT_LOW
91#define CONFIG_VL6180X_ALS_INT (VL6180X_INT_LOW)
92#elif CONFIG_VL6180X_ALS_INT_HIGH
93#define CONFIG_VL6180X_ALS_INT (VL6180X_INT_HIGH)
94#elif CONFIG_VL6180X_ALS_INT_OUT
95#define CONFIG_VL6180X_ALS_INT (VL6180X_INT_OUT)
96#endif
97
98#endif /* !DOXYGEN */
99
100#ifndef CONFIG_VL6180X_MEAS_PERIOD
102#define CONFIG_VL6180X_MEAS_PERIOD (20)
103#endif
104
105#ifndef CONFIG_VL6180X_RNG_MAX_TIME
107#define CONFIG_VL6180X_RNG_MAX_TIME (50)
108#endif
109
110#ifndef CONFIG_VL6180X_RNG_INT
112#define CONFIG_VL6180X_RNG_INT (VL6180X_INT_DRDY)
113#endif
114
115#ifndef CONFIG_VL6180X_RNG_THRESH_LOW
117#define CONFIG_VL6180X_RNG_THRESH_LOW (20)
118#endif
119
120#ifndef CONFIG_VL6180X_RNG_THRESH_HIGH
122#define CONFIG_VL6180X_RNG_THRESH_HIGH (90)
123#endif
124
125#ifndef CONFIG_VL6180X_ALS_INT_TIME
127#define CONFIG_VL6180X_ALS_INT_TIME (100)
128#endif
129
130#ifndef CONFIG_VL6180X_ALS_GAIN
132#define CONFIG_VL6180X_ALS_GAIN (VL6180X_ALS_GAIN_1)
133#endif
134
135#ifndef CONFIG_VL6180X_ALS_LUX_RES
137#define CONFIG_VL6180X_ALS_LUX_RES 320
138#endif
139
140#ifndef CONFIG_VL6180X_ALS_INT
142#define CONFIG_VL6180X_ALS_INT (VL6180X_INT_DRDY)
143#endif
144
145#ifndef CONFIG_VL6180X_ALS_THRESH_LOW
147#define CONFIG_VL6180X_ALS_THRESH_LOW (50)
148#endif
149
150#ifndef CONFIG_VL6180X_ALS_THRESH_HIGH
152#define CONFIG_VL6180X_ALS_THRESH_HIGH (2000)
153#endif
154
155#if IS_USED(MODULE_VL6180X_RNG) || DOXYGEN
157#define VL6180X_PARAM_RANGE .rng_max_time = CONFIG_VL6180X_RNG_MAX_TIME,
158#else
159#define VL6180X_PARAM_RANGE
160#endif
161
162#if IS_USED(MODULE_VL6180X_ALS) || DOXYGEN
164#define VL6180X_PARAM_ALS .als_int_time = CONFIG_VL6180X_ALS_INT_TIME, \
165 .als_gain = CONFIG_VL6180X_ALS_GAIN, \
166 .als_lux_res = CONFIG_VL6180X_ALS_LUX_RES,
167#else
168#define VL6180X_PARAM_ALS
169#endif
170
171#if IS_USED(MODULE_VL6180X_SHUTDOWN) || DOXYGEN
173#define VL6180X_PARAM_SHUTDOWN .shutdown_pin = VL6180X_PARAM_SHUTDOWN_PIN,
174#else
175#define VL6180X_PARAM_SHUTDOWN
176#endif
177
178#if IS_USED(MODULE_VL6180X_IRQ) || DOXYGEN
180#define VL6180X_PARAM_INT .int_pin = VL6180X_PARAM_INT_PIN,
181
182#if IS_USED(MODULE_VL6180X_RNG) || DOXYGEN
184#define VL6180X_PARAM_INT_RNG_CFG .int_cfg.rng_int = CONFIG_VL6180X_RNG_INT, \
185 .int_thresh.rng_low = CONFIG_VL6180X_RNG_THRESH_LOW, \
186 .int_thresh.rng_high = CONFIG_VL6180X_RNG_THRESH_HIGH,
187#else /* IS_USED(MODULE_VL6180X_RNG) || DOXYGEN */
188#define VL6180X_PARAM_INT_RNG_CFG
189#endif /* IS_USED(MODULE_VL6180X_RNG) || DOXYGEN */
190
191#if IS_USED(MODULE_VL6180X_ALS) || DOXYGEN
193#define VL6180X_PARAM_INT_ALS_CFG .int_cfg.als_int = CONFIG_VL6180X_ALS_INT, \
194 .int_thresh.als_low = CONFIG_VL6180X_ALS_THRESH_LOW, \
195 .int_thresh.als_high = CONFIG_VL6180X_ALS_THRESH_HIGH,
196#else /* IS_USED(MODULE_VL6180X_ALS) || DOXYGEN */
197#define VL6180X_PARAM_INT_ALS_CFG
198#endif /* IS_USED(MODULE_VL6180X_ALS) || DOXYGEN */
199
200#else /* IS_USED(MODULE_VL6180X_IRQ) || DOXYGEN */
201#define VL6180X_PARAM_INT
202#define VL6180X_PARAM_INT_RNG_CFG
203#define VL6180X_PARAM_INT_ALS_CFG
204#endif /* IS_USED(MODULE_VL6180X_IRQ) || DOXYGEN */
205
206#if !VL6180X_PARAMS || DOXYGEN
208#define VL6180X_PARAMS { \
209 .i2c_dev = VL6180X_PARAM_DEV, \
210 .i2c_addr = VL6180X_PARAM_ADDR, \
211 .period = CONFIG_VL6180X_MEAS_PERIOD, \
212 VL6180X_PARAM_RANGE \
213 VL6180X_PARAM_ALS \
214 VL6180X_PARAM_SHUTDOWN \
215 VL6180X_PARAM_INT \
216 VL6180X_PARAM_INT_RNG_CFG \
217 VL6180X_PARAM_INT_ALS_CFG \
218 }
219#endif /* !VL6180X_PARAMS */
220
221#if !defined(VL6180X_SAUL_INFO) || DOXYGEN
223#define VL6180X_SAUL_INFO { .name = "vl6180x" }
224#endif
231{
233};
234
242
243#ifdef __cplusplus
244}
245#endif
246
247#endif /* VL6180X_PARAMS_H */
SAUL registry interface definition.
Additional data to collect for each entry.
Definition saul_reg.h:49
VL6180X device configuration.
Definition vl6180x.h:549
static const vl6180x_params_t vl6180x_params[]
Allocate some memory to store the actual configuration.
#define VL6180X_PARAMS
Default configuration parameter set.
#define VL6180X_SAUL_INFO
Default SAUL information.
static const saul_reg_info_t vl6180x_saul_info[]
Additional meta information to keep in the SAUL registry.