amiro-os / modules / PowerManagement_1-2 / module.c @ a845d9eb
History | View | Annotate | Download (92 KB)
1 |
/*
|
---|---|
2 |
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
|
3 |
Copyright (C) 2016..2019 Thomas Schöpping et al.
|
4 |
|
5 |
This program is free software: you can redistribute it and/or modify
|
6 |
it under the terms of the GNU General Public License as published by
|
7 |
the Free Software Foundation, either version 3 of the License, or
|
8 |
(at your option) any later version.
|
9 |
|
10 |
This program is distributed in the hope that it will be useful,
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
GNU General Public License for more details.
|
14 |
|
15 |
You should have received a copy of the GNU General Public License
|
16 |
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17 |
*/
|
18 |
|
19 |
/**
|
20 |
* @file
|
21 |
* @brief Structures and constant for the PowerManagement module.
|
22 |
*
|
23 |
* @addtogroup powermanagement_module
|
24 |
* @{
|
25 |
*/
|
26 |
|
27 |
#include "module.h" |
28 |
|
29 |
/*===========================================================================*/
|
30 |
/**
|
31 |
* @name Module specific functions
|
32 |
* @{
|
33 |
*/
|
34 |
/*===========================================================================*/
|
35 |
|
36 |
/** @} */
|
37 |
|
38 |
/*===========================================================================*/
|
39 |
/**
|
40 |
* @name ChibiOS/HAL configuration
|
41 |
* @{
|
42 |
*/
|
43 |
/*===========================================================================*/
|
44 |
|
45 |
ADCConversionGroup moduleHalAdcVsysConversionGroup = { |
46 |
/* buffer type */ true, |
47 |
/* number of channels */ 1, |
48 |
/* callback function */ NULL, |
49 |
/* error callback */ NULL, |
50 |
/* CR1 */ ADC_CR1_AWDEN | ADC_CR1_AWDIE,
|
51 |
/* CR2 */ ADC_CR2_SWSTART | ADC_CR2_CONT,
|
52 |
/* SMPR1 */ 0, |
53 |
/* SMPR2 */ ADC_SMPR2_SMP_AN9(ADC_SAMPLE_480),
|
54 |
/* HTR */ ADC_HTR_HT,
|
55 |
/* LTR */ 0, |
56 |
/* SQR1 */ ADC_SQR1_NUM_CH(1), |
57 |
/* SQR2 */ 0, |
58 |
/* SQR3 */ ADC_SQR3_SQ1_N(ADC_CHANNEL_IN9),
|
59 |
}; |
60 |
|
61 |
CANConfig moduleHalCanConfig = { |
62 |
/* mcr */ CAN_MCR_ABOM | CAN_MCR_AWUM | CAN_MCR_TXFP,
|
63 |
/* btr */ CAN_BTR_SJW(1) | CAN_BTR_TS2(3) | CAN_BTR_TS1(15) | CAN_BTR_BRP(1), |
64 |
}; |
65 |
|
66 |
I2CConfig moduleHalI2cSrPm18Pm33GaugeRearConfig = { |
67 |
/* I²C mode */ OPMODE_I2C,
|
68 |
/* frequency */ 400000, // TODO: replace with some macro (-> ChibiOS/HAL) |
69 |
/* duty cycle */ FAST_DUTY_CYCLE_2,
|
70 |
}; |
71 |
|
72 |
I2CConfig moduleHalI2cSrPm42Pm50PmVddEepromGaugeFrontConfig = { |
73 |
/* I²C mode */ OPMODE_I2C,
|
74 |
/* frequency */ 400000, // TODO: replace with some macro (-> ChibiOS/HAL) |
75 |
/* duty cycle */ FAST_DUTY_CYCLE_2,
|
76 |
}; |
77 |
|
78 |
PWMConfig moduleHalPwmBuzzerConfig = { |
79 |
/* frequency */ 1000000, |
80 |
/* period */ 0, |
81 |
/* callback */ NULL, |
82 |
/* channel configurations */ {
|
83 |
/* channel 0 */ {
|
84 |
/* mode */ PWM_OUTPUT_DISABLED,
|
85 |
/* callback */ NULL |
86 |
}, |
87 |
/* channel 1 */ {
|
88 |
/* mode */ PWM_OUTPUT_ACTIVE_HIGH,
|
89 |
/* callback */ NULL |
90 |
}, |
91 |
/* channel 2 */ {
|
92 |
/* mode */ PWM_OUTPUT_DISABLED,
|
93 |
/* callback */ NULL |
94 |
}, |
95 |
/* channel 3 */ {
|
96 |
/* mode */ PWM_OUTPUT_DISABLED,
|
97 |
/* callback */ NULL |
98 |
}, |
99 |
}, |
100 |
/* TIM CR2 register */ 0, |
101 |
#if (STM32_PWM_USE_ADVANCED == TRUE)
|
102 |
/* TIM BDTR register */ 0, |
103 |
#endif /* (STM32_PWM_USE_ADVANCED == TRUE) */ |
104 |
/* TIM DIER register */ 0, |
105 |
}; |
106 |
|
107 |
SerialConfig moduleHalProgIfConfig = { |
108 |
/* bit rate */ 115200, |
109 |
/* CR1 */ 0, |
110 |
/* CR1 */ 0, |
111 |
/* CR1 */ 0, |
112 |
}; |
113 |
|
114 |
/** @} */
|
115 |
|
116 |
/*===========================================================================*/
|
117 |
/**
|
118 |
* @name GPIO definitions
|
119 |
* @{
|
120 |
*/
|
121 |
/*===========================================================================*/
|
122 |
|
123 |
/**
|
124 |
* @brief SWITCH_STATUS input signal GPIO.
|
125 |
*/
|
126 |
static apalGpio_t _gpioSwitchStatus = {
|
127 |
/* line */ LINE_SWITCH_STATUS_N,
|
128 |
}; |
129 |
ROMCONST apalControlGpio_t moduleGpioSwitchStatus = { |
130 |
/* GPIO */ &_gpioSwitchStatus,
|
131 |
/* meta */ {
|
132 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
133 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
134 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
135 |
}, |
136 |
}; |
137 |
|
138 |
/**
|
139 |
* @brief SYS_REG_EN output signal GPIO.
|
140 |
*/
|
141 |
static apalGpio_t _gpioSysRegEn = {
|
142 |
/* line */ LINE_SYS_REG_EN,
|
143 |
}; |
144 |
ROMCONST apalControlGpio_t moduleGpioSysRegEn = { |
145 |
/* GPIO */ &_gpioSysRegEn,
|
146 |
/* meta */ {
|
147 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
148 |
/* active state */ APAL_GPIO_ACTIVE_HIGH,
|
149 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
150 |
}, |
151 |
}; |
152 |
|
153 |
/**
|
154 |
* @brief IR_INT1 input signal GPIO.
|
155 |
*/
|
156 |
static apalGpio_t _gpioIrInt1 = {
|
157 |
/* line */ LINE_IR_INT1_N,
|
158 |
}; |
159 |
ROMCONST apalControlGpio_t moduleGpioIrInt1 = { |
160 |
/* GPIO */ &_gpioIrInt1,
|
161 |
/* meta */ {
|
162 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
163 |
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR)
|
164 |
/* active state */ (VCNL4020_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
165 |
/* interrupt edge */ VCNL4020_LLD_INT_EDGE,
|
166 |
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X)
|
167 |
/* active state */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
168 |
/* interrupt edge */ PCAL6524_LLD_INT_EDGE,
|
169 |
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X)
|
170 |
/* active state */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
171 |
/* interrupt edge */ PCAL6524_LLD_INT_EDGE,
|
172 |
#else /* (BOARD_SENSORRING == ?) */ |
173 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
174 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
175 |
#endif /* (BOARD_SENSORRING == ?) */ |
176 |
}, |
177 |
}; |
178 |
|
179 |
/**
|
180 |
* @brief POWER_EN output signal GPIO.
|
181 |
*/
|
182 |
static apalGpio_t _gpioPowerEn = {
|
183 |
/* line */ LINE_POWER_EN,
|
184 |
}; |
185 |
ROMCONST apalControlGpio_t moduleGpioPowerEn = { |
186 |
/* GPIO */ &_gpioPowerEn,
|
187 |
/* meta */ {
|
188 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
189 |
/* active state */ APAL_GPIO_ACTIVE_HIGH,
|
190 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
191 |
}, |
192 |
}; |
193 |
|
194 |
/**
|
195 |
* @brief SYS_UART_DN bidirectional signal GPIO.
|
196 |
*/
|
197 |
static apalGpio_t _gpioSysUartDn = {
|
198 |
/* line */ LINE_SYS_UART_DN,
|
199 |
}; |
200 |
ROMCONST apalControlGpio_t moduleGpioSysUartDn = { |
201 |
/* GPIO */ &_gpioSysUartDn,
|
202 |
/* meta */ {
|
203 |
/* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
204 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
205 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
206 |
}, |
207 |
}; |
208 |
|
209 |
/**
|
210 |
* @brief CHARGE_STAT2A input signal GPIO.
|
211 |
*/
|
212 |
static apalGpio_t _gpioChargeStat2A = {
|
213 |
/* line */ LINE_CHARGE_STAT2A,
|
214 |
}; |
215 |
ROMCONST apalControlGpio_t moduleGpioChargeStat2A = { |
216 |
/* GPIO */ &_gpioChargeStat2A,
|
217 |
/* meta */ {
|
218 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
219 |
/* active state */ BQ241xx_LLD_CHARGE_STATUS_GPIO_ACTIVE_STATE,
|
220 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
221 |
}, |
222 |
}; |
223 |
|
224 |
/**
|
225 |
* @brief GAUGE_BATLOW2 input signal GPIO.
|
226 |
*/
|
227 |
static apalGpio_t _gpioGaugeBatLow2 = {
|
228 |
/* line */ LINE_GAUGE_BATLOW2,
|
229 |
}; |
230 |
ROMCONST apalControlGpio_t moduleGpioGaugeBatLow2 = { |
231 |
/* GPIO */ &_gpioGaugeBatLow2,
|
232 |
/* meta */ {
|
233 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
234 |
/* active state */ BQ27500_LLD_BATLOW_ACTIVE_STATE,
|
235 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
236 |
}, |
237 |
}; |
238 |
|
239 |
/**
|
240 |
* @brief GAUGE_BATGD2 input signal GPIO.
|
241 |
*/
|
242 |
static apalGpio_t _gpioGaugeBatGd2 = {
|
243 |
/* line */ LINE_GAUGE_BATGD2_N,
|
244 |
}; |
245 |
ROMCONST apalControlGpio_t moduleGpioGaugeBatGd2 = { |
246 |
/* GPIO */ &_gpioGaugeBatGd2,
|
247 |
/* meta */ {
|
248 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
249 |
/* active state */ BQ27500_LLD_BATGOOD_ACTIVE_STATE,
|
250 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
251 |
}, |
252 |
}; |
253 |
|
254 |
/**
|
255 |
* @brief LED output signal GPIO.
|
256 |
*/
|
257 |
static apalGpio_t _gpioLed = {
|
258 |
/* line */ LINE_LED,
|
259 |
}; |
260 |
ROMCONST apalControlGpio_t moduleGpioLed = { |
261 |
/* GPIO */ &_gpioLed,
|
262 |
/* meta */ {
|
263 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
264 |
/* active state */ LED_LLD_GPIO_ACTIVE_STATE,
|
265 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
266 |
}, |
267 |
}; |
268 |
|
269 |
/**
|
270 |
* @brief SYS_UART_UP bidirectional signal GPIO.
|
271 |
*/
|
272 |
static apalGpio_t _gpioSysUartUp = {
|
273 |
/* line */ LINE_SYS_UART_UP,
|
274 |
}; |
275 |
ROMCONST apalControlGpio_t moduleGpioSysUartUp = { |
276 |
/* GPIO */ &_gpioSysUartUp,
|
277 |
/* meta */ {
|
278 |
/* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
279 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
280 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
281 |
}, |
282 |
}; |
283 |
|
284 |
/**
|
285 |
* @brief CHARGE_STAT1A input signal GPIO.
|
286 |
*/
|
287 |
static apalGpio_t _gpioChargeStat1A = {
|
288 |
/* line */ LINE_CHARGE_STAT1A,
|
289 |
}; |
290 |
ROMCONST apalControlGpio_t moduleGpioChargeStat1A = { |
291 |
/* GPIO */ &_gpioChargeStat1A,
|
292 |
/* meta */ {
|
293 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
294 |
/* active state */ BQ241xx_LLD_CHARGE_STATUS_GPIO_ACTIVE_STATE,
|
295 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
296 |
}, |
297 |
}; |
298 |
|
299 |
/**
|
300 |
* @brief GAUGE_BATLOW1 input signal GPIO.
|
301 |
*/
|
302 |
static apalGpio_t _gpioGaugeBatLow1 = {
|
303 |
/* line */ LINE_GAUGE_BATLOW1,
|
304 |
}; |
305 |
ROMCONST apalControlGpio_t moduleGpioGaugeBatLow1 = { |
306 |
/* GPIO */ &_gpioGaugeBatLow1,
|
307 |
/* meta */ {
|
308 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
309 |
/* active state */ BQ27500_LLD_BATLOW_ACTIVE_STATE,
|
310 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
311 |
}, |
312 |
}; |
313 |
|
314 |
/**
|
315 |
* @brief GAUGE_BATGD1 input signal GPIO.
|
316 |
*/
|
317 |
static apalGpio_t _gpioGaugeBatGd1 = {
|
318 |
/* line */ LINE_GAUGE_BATGD1_N,
|
319 |
}; |
320 |
ROMCONST apalControlGpio_t moduleGpioGaugeBatGd1 = { |
321 |
/* GPIO */ &_gpioGaugeBatGd1,
|
322 |
/* meta */ {
|
323 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
324 |
/* active state */ BQ27500_LLD_BATGOOD_ACTIVE_STATE,
|
325 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
326 |
}, |
327 |
}; |
328 |
|
329 |
/**
|
330 |
* @brief CHARG_EN1 output signal GPIO.
|
331 |
*/
|
332 |
static apalGpio_t _gpioChargeEn1 = {
|
333 |
/* line */ LINE_CHARGE_EN1_N,
|
334 |
}; |
335 |
ROMCONST apalControlGpio_t moduleGpioChargeEn1 = { |
336 |
/* GPIO */ &_gpioChargeEn1,
|
337 |
/* meta */ {
|
338 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
339 |
/* active state */ BQ241xx_LLD_ENABLED_GPIO_ACTIVE_STATE,
|
340 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
341 |
}, |
342 |
}; |
343 |
|
344 |
/**
|
345 |
* @brief IR_INT2 input signal GPIO.
|
346 |
*/
|
347 |
static apalGpio_t _gpioIrInt2 = {
|
348 |
/* line */ LINE_IR_INT2_N,
|
349 |
}; |
350 |
ROMCONST apalControlGpio_t moduleGpioIrInt2 = { |
351 |
/* GPIO */ &_gpioIrInt2,
|
352 |
/* meta */ {
|
353 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
354 |
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR)
|
355 |
/* active state */ (VCNL4020_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
356 |
/* interrupt edge */ VCNL4020_LLD_INT_EDGE,
|
357 |
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X)
|
358 |
/* active state */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
359 |
/* interrupt edge */ PCAL6524_LLD_INT_EDGE,
|
360 |
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X)
|
361 |
/* active state */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
362 |
/* interrupt edge */ PCAL6524_LLD_INT_EDGE,
|
363 |
#else /* (BOARD_SENSORRING == ?) */ |
364 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
365 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
366 |
#endif /* (BOARD_SENSORRING == ?) */ |
367 |
}, |
368 |
}; |
369 |
|
370 |
/**
|
371 |
* @brief TOUCH_INT input signal GPIO.
|
372 |
*/
|
373 |
static apalGpio_t _gpioTouchInt = {
|
374 |
/* line */ LINE_TOUCH_INT_N,
|
375 |
}; |
376 |
ROMCONST apalControlGpio_t moduleGpioTouchInt = { |
377 |
/* GPIO */ &_gpioTouchInt,
|
378 |
/* meta */ {
|
379 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
380 |
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR)
|
381 |
/* active state */ (MPR121_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
382 |
/* interrupt edge */ MPR121_LLD_INT_EDGE,
|
383 |
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X)
|
384 |
/* active state */ (AT42QT1050_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
385 |
/* interrupt edge */ AT42QT1050_LLD_INT_EDGE,
|
386 |
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X)
|
387 |
/* active state */ (AT42QT1050_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
388 |
/* interrupt edge */ AT42QT1050_LLD_INT_EDGE,
|
389 |
#else /* (BOARD_SENSORRING == ?) */ |
390 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
391 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
392 |
#endif /* (BOARD_SENSORRING == ?) */ |
393 |
}, |
394 |
}; |
395 |
|
396 |
/**
|
397 |
* @brief SYS_DONE input signal GPIO.
|
398 |
*/
|
399 |
static apalGpio_t _gpioSysDone = {
|
400 |
/* line */ LINE_SYS_DONE,
|
401 |
}; |
402 |
ROMCONST apalControlGpio_t moduleGpioSysDone = { |
403 |
/* GPIO */ &_gpioSysDone,
|
404 |
/* meta */ {
|
405 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
406 |
/* active state */ APAL_GPIO_ACTIVE_HIGH,
|
407 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
408 |
}, |
409 |
}; |
410 |
|
411 |
/**
|
412 |
* @brief SYS_PROG output signal GPIO.
|
413 |
*/
|
414 |
static apalGpio_t _gpioSysProg = {
|
415 |
/* line */ LINE_SYS_PROG_N,
|
416 |
}; |
417 |
ROMCONST apalControlGpio_t moduleGpioSysProg = { |
418 |
/* GPIO */ &_gpioSysProg,
|
419 |
/* meta */ {
|
420 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
421 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
422 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
423 |
}, |
424 |
}; |
425 |
|
426 |
/**
|
427 |
* @brief PATH_DC input signal GPIO.
|
428 |
*/
|
429 |
static apalGpio_t _gpioPathDc = {
|
430 |
/* line */ LINE_PATH_DC,
|
431 |
}; |
432 |
ROMCONST apalControlGpio_t moduleGpioPathDc = { |
433 |
/* GPIO */ &_gpioPathDc,
|
434 |
/* meta */ {
|
435 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
436 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
437 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
438 |
}, |
439 |
}; |
440 |
|
441 |
/**
|
442 |
* @brief SYS_SPI_DIR bidirectional signal GPIO.
|
443 |
*/
|
444 |
static apalGpio_t _gpioSysSpiDir = {
|
445 |
/* line */ LINE_SYS_SPI_DIR,
|
446 |
}; |
447 |
ROMCONST apalControlGpio_t moduleGpioSysSpiDir = { |
448 |
/* GPIO */ &_gpioSysSpiDir,
|
449 |
/* meta */ {
|
450 |
/* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
451 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
452 |
/* interrupt edge */ APAL_GPIO_EDGE_FALLING,
|
453 |
}, |
454 |
}; |
455 |
|
456 |
/**
|
457 |
* @brief SYS_SYNC bidirectional signal GPIO.
|
458 |
*/
|
459 |
static apalGpio_t _gpioSysSync = {
|
460 |
/* line */ LINE_SYS_INT_N,
|
461 |
}; |
462 |
ROMCONST apalControlGpio_t moduleGpioSysSync = { |
463 |
/* GPIO */ &_gpioSysSync,
|
464 |
/* meta */ {
|
465 |
/* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
466 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
467 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
468 |
}, |
469 |
}; |
470 |
|
471 |
/**
|
472 |
* @brief SYS_PD bidirectional signal GPIO.
|
473 |
*/
|
474 |
static apalGpio_t _gpioSysPd = {
|
475 |
/* line */ LINE_SYS_PD_N,
|
476 |
}; |
477 |
ROMCONST apalControlGpio_t moduleGpioSysPd = { |
478 |
/* GPIO */ &_gpioSysPd,
|
479 |
/* meta */ {
|
480 |
/* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
481 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
482 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
483 |
}, |
484 |
}; |
485 |
|
486 |
/**
|
487 |
* @brief SYS_WARMRST bidirectional signal GPIO.
|
488 |
*/
|
489 |
static apalGpio_t _gpioSysWarmrst = {
|
490 |
/* line */ LINE_SYS_WARMRST_N,
|
491 |
}; |
492 |
ROMCONST apalControlGpio_t moduleGpioSysWarmrst = { |
493 |
/* GPIO */ &_gpioSysWarmrst,
|
494 |
/* meta */ {
|
495 |
/* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
496 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
497 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
498 |
}, |
499 |
}; |
500 |
|
501 |
/**
|
502 |
* @brief BT_RST output signal GPIO.
|
503 |
*/
|
504 |
static apalGpio_t _gpioBtRst = {
|
505 |
/* line */ LINE_BT_RST,
|
506 |
}; |
507 |
ROMCONST apalControlGpio_t moduleGpioBtRst = { |
508 |
/* GPIO */ &_gpioBtRst,
|
509 |
/* meta */ {
|
510 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
511 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
512 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
513 |
}, |
514 |
}; |
515 |
|
516 |
/**
|
517 |
* @brief CHARGE_EN2 output signal GPIO.
|
518 |
*/
|
519 |
static apalGpio_t _gpioChargeEn2 = {
|
520 |
/* line */ LINE_CHARGE_EN2_N,
|
521 |
}; |
522 |
ROMCONST apalControlGpio_t moduleGpioChargeEn2 = { |
523 |
/* GPIO */ &_gpioChargeEn2,
|
524 |
/* meta */ {
|
525 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
526 |
/* active state */ BQ241xx_LLD_ENABLED_GPIO_ACTIVE_STATE,
|
527 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
528 |
}, |
529 |
}; |
530 |
|
531 |
/** @} */
|
532 |
|
533 |
/*===========================================================================*/
|
534 |
/**
|
535 |
* @name AMiRo-OS core configurations
|
536 |
* @{
|
537 |
*/
|
538 |
/*===========================================================================*/
|
539 |
|
540 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
541 |
ROMCONST char* moduleShellPrompt = "PowerManagement"; |
542 |
#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */ |
543 |
|
544 |
/** @} */
|
545 |
|
546 |
/*===========================================================================*/
|
547 |
/**
|
548 |
* @name Startup Shutdown Synchronization Protocol (SSSP)
|
549 |
* @{
|
550 |
*/
|
551 |
/*===========================================================================*/
|
552 |
|
553 |
/** @} */
|
554 |
|
555 |
/*===========================================================================*/
|
556 |
/**
|
557 |
* @name Low-level drivers
|
558 |
* @{
|
559 |
*/
|
560 |
/*===========================================================================*/
|
561 |
|
562 |
AT24C01BDriver moduleLldEeprom = { |
563 |
/* I2C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
564 |
/* I2C address */ AT24C01B_LLD_I2C_ADDR_FIXED,
|
565 |
}; |
566 |
|
567 |
BQ241xxDriver moduleLldBatteryChargerFront = { |
568 |
/* charge enable GPIO */ &moduleGpioChargeEn1,
|
569 |
/* charge status GPIO */ &moduleGpioChargeStat1A,
|
570 |
}; |
571 |
|
572 |
BQ241xxDriver moduleLldBatteryChargerRear = { |
573 |
/* charge enable GPIO */ &moduleGpioChargeEn2,
|
574 |
/* charge status GPIO */ &moduleGpioChargeStat2A,
|
575 |
}; |
576 |
|
577 |
BQ27500Driver moduleLldFuelGaugeFront = { |
578 |
/* I2C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
579 |
/* battery low GPIO */ &moduleGpioGaugeBatLow1,
|
580 |
/* battery good GPIO */ &moduleGpioGaugeBatGd1,
|
581 |
}; |
582 |
|
583 |
BQ27500Driver moduleLldFuelGaugeRear = { |
584 |
/* I2C driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
585 |
/* battery low GPIO */ &moduleGpioGaugeBatLow2,
|
586 |
/* battery good GPIO */ &moduleGpioGaugeBatGd2,
|
587 |
}; |
588 |
|
589 |
INA219Driver moduleLldPowerMonitorVdd = { |
590 |
/* I2C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
591 |
/* I²C address */ INA219_LLD_I2C_ADDR_A0 | INA219_LLD_I2C_ADDR_A1,
|
592 |
/* current LSB (uA) */ 0x00u, |
593 |
/* configuration */ NULL, |
594 |
}; |
595 |
|
596 |
INA219Driver moduleLldPowerMonitorVio18 = { |
597 |
/* I2C Driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
598 |
/* I²C address */ INA219_LLD_I2C_ADDR_A1,
|
599 |
/* current LSB (uA) */ 0x00u, |
600 |
/* configuration */ NULL, |
601 |
}; |
602 |
|
603 |
INA219Driver moduleLldPowerMonitorVio33 = { |
604 |
/* I2C Driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
605 |
/* I²C address */ INA219_LLD_I2C_ADDR_FIXED,
|
606 |
/* current LSB (uA) */ 0x00u, |
607 |
/* configuration */ NULL, |
608 |
}; |
609 |
|
610 |
INA219Driver moduleLldPowerMonitorVsys42 = { |
611 |
/* I2C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
612 |
/* I²C address */ INA219_LLD_I2C_ADDR_FIXED,
|
613 |
/* current LSB (uA) */ 0x00u, |
614 |
/* configuration */ NULL, |
615 |
}; |
616 |
|
617 |
INA219Driver moduleLldPowerMonitorVio50 = { |
618 |
/* I2C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
619 |
/* I²C address */ INA219_LLD_I2C_ADDR_A1,
|
620 |
/* current LSB (uA) */ 0x00u, |
621 |
/* configuration */ NULL, |
622 |
}; |
623 |
|
624 |
LEDDriver moduleLldStatusLed = { |
625 |
/* LED GPIO */ &moduleGpioLed,
|
626 |
}; |
627 |
|
628 |
TPS6211xDriver moduleLldStepDownConverter = { |
629 |
/* Power enable GPIO */ &moduleGpioPowerEn,
|
630 |
}; |
631 |
|
632 |
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) || defined(__DOXYGEN__)
|
633 |
|
634 |
MPR121Driver moduleLldTouch = { |
635 |
/* I²C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
636 |
}; |
637 |
|
638 |
PCA9544ADriver moduleLldI2cMultiplexer1 = { |
639 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
640 |
/* I²C address */ PCA9544A_LLD_I2C_ADDR_A0 | PCA9544A_LLD_I2C_ADDR_A1 | PCA9544A_LLD_I2C_ADDR_A2,
|
641 |
}; |
642 |
|
643 |
PCA9544ADriver moduleLldI2cMultiplexer2 = { |
644 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
645 |
/* I²C address */ PCA9544A_LLD_I2C_ADDR_A0 | PCA9544A_LLD_I2C_ADDR_A1 | PCA9544A_LLD_I2C_ADDR_A2,
|
646 |
}; |
647 |
|
648 |
VCNL4020Driver moduleLldProximity1 = { |
649 |
/* I²C Driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
650 |
}; |
651 |
|
652 |
VCNL4020Driver moduleLldProximity2 = { |
653 |
/* I²C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
654 |
}; |
655 |
|
656 |
#endif /* (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) */ |
657 |
|
658 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) || defined(__DOXYGEN__)
|
659 |
|
660 |
PCAL6524Driver moduleLldGpioExtender1 = { |
661 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
662 |
/* I²C address */ PCAL6524_LLD_I2C_ADDR_VDD,
|
663 |
}; |
664 |
|
665 |
PCAL6524Driver moduleLldGpioExtender2 = { |
666 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
667 |
/* I²C address */ PCAL6524_LLD_I2C_ADDR_VDD,
|
668 |
}; |
669 |
|
670 |
AT42QT1050Driver moduleLldTouch = { |
671 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
672 |
/* I²C address */ AT42QT1050_LLD_I2C_ADDRSEL_LOW,
|
673 |
}; |
674 |
|
675 |
VL53L0XDriver moduleLldProximity1 = { |
676 |
{ |
677 |
/* I²C Driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
678 |
/* I²C timeout */ TIME_INFINITE,
|
679 |
|
680 |
/* VL53L0X_DevData_t */
|
681 |
{ |
682 |
/* VL53L0X_DMaxData_t */
|
683 |
{ |
684 |
/* AmbTuningWindowFactor_K */ 0, |
685 |
/* RetSignalAt0mm */ 0, |
686 |
|
687 |
}, |
688 |
/* Part2PartOffsetNVMMicroMeter */ 0, |
689 |
/* Part2PartOffsetAdjustmentNVMMicroMeter */ 0, |
690 |
/* VL53L0X_DeviceParameters_t */
|
691 |
{ |
692 |
/* VL53L0X_DeviceModes DeviceMode 0 == singleranging*/ 0, |
693 |
/* VL53L0X_HistogramModes HistogramMode 0=disable */ 0, |
694 |
/* MeasurementTimingBudgetMicroSeconds */ 0, |
695 |
/* InterMeasurementPeriodMilliSeconds */ 0, |
696 |
/* !! XTalkCompensationEnable */ 0, |
697 |
/* XTalkCompensationRangeMilliMeter */ 0, |
698 |
/* XTalkCompensationRateMegaCps */ 0, |
699 |
/* RangeOffsetMicroMeters */ 0, |
700 |
/* !! LimitChecksEnable */ 0, |
701 |
/* LimitChecksStatus */ 0, |
702 |
/* !! WrapAroundCheckEnable */ 0, |
703 |
|
704 |
}, |
705 |
/* VL53L0X_RangingMeasurementData_t */
|
706 |
{ |
707 |
/* TimeStamp */ 0, |
708 |
/* MeasurementTimeUsec */ 0, |
709 |
/* RangeMilliMeter */ 0, |
710 |
/* !! RangeDMaxMilliMeter */ 0, |
711 |
/* SignalRateRtnMegaCps */ 0, |
712 |
/* AmbientRateRtnMegaCps */ 0, |
713 |
/* EffectiveSpadRtnCount */ 0, |
714 |
/* ZoneId */ 0, |
715 |
/* RangeFractionalPart */ 0, |
716 |
/* RangeStatus */ 0, |
717 |
}, |
718 |
/* VL53L0X_HistogramMeasurementData_t */
|
719 |
{ |
720 |
/* HistogramData */ 0, |
721 |
/* HistogramType */ 0, |
722 |
/* FirstBin */ 0, |
723 |
/* BufferSize */ 0, |
724 |
/* NumberOfBins */ 0, |
725 |
/* VL53L0X_DeviceError ErrorStatus 0 == None_error */ 0, |
726 |
}, |
727 |
/* VL53L0X_DeviceSpecificParameters_t */
|
728 |
{ |
729 |
/* OscFrequencyMHz */ 0, |
730 |
/* LastEncodedTimeout */ 0, |
731 |
/* !! VL53L0X_GpioFunctionality Pin0GpioFunctionality 0==no interrupt */ 0, |
732 |
/* FinalRangeTimeoutMicroSecs */ 0, |
733 |
/* FinalRangeVcselPulsePeriod */ 0, |
734 |
/* PreRangeTimeoutMicroSecs */ 0, |
735 |
/* PreRangeVcselPulsePeriod */ 0, |
736 |
/* SigmaEstRefArray */ 0, |
737 |
/* SigmaEstEffPulseWidth */ 0, |
738 |
/* SigmaEstEffAmbWidth */ 0, |
739 |
/* ReadDataFromDeviceDone 0 == read from device was not done */ 0, |
740 |
/* ModuleId */ 0, |
741 |
/* Revision */ 0, |
742 |
/* ProductId */ "0", |
743 |
/* !! ReferenceSpadCount */ 0, |
744 |
/* !! ReferenceSpadType */ 0, |
745 |
/* RefSpadsInitialised */ 0, |
746 |
/* PartUIDUpper */ 0, |
747 |
/* PartUIDLower */ 0, |
748 |
/* SignalRateMeasFixed400mm */ 0, |
749 |
}, |
750 |
/* VL53L0X_SpadData_t */
|
751 |
{ |
752 |
/* RefSpadEnables */ 0, |
753 |
/* RefGoodSpadMap */ 0, |
754 |
|
755 |
}, |
756 |
/* SequenceConfig */ 0, |
757 |
/* !! RangeFractionalEnable */ 0, |
758 |
/* VL53L0X_State PalState */ 0, |
759 |
/* !! VL53L0X_PowerModes PowerMode 0==VL53L0X_POWERMODE_STANDBY_LEVEL1 */ 0, |
760 |
/* SigmaEstRefArray */ 0, |
761 |
/* SigmaEstEffPulseWidth */ 0, |
762 |
/* SigmaEstEffAmbWidth */ 0, |
763 |
/* StopVariable */ 0, |
764 |
/* targetRefRate */ 0, |
765 |
/* SigmaEstimate */ 0, |
766 |
/* SignalEstimate */0 , |
767 |
/* LastSignalRefMcps */ 0, |
768 |
/* *pTuningSettingsPointer */ 0, |
769 |
/* UseInternalTuningSettings */ 0, |
770 |
/* LinearityCorrectiveGain */ 0, |
771 |
/* !! DmaxCalRangeMilliMeter */ 0, |
772 |
/* DmaxCalSignalRateRtnMegaCps */ 0, |
773 |
}, |
774 |
/* I²C address */ VL53L0X_LLD_I2C_ADDR,
|
775 |
/* COMM TYPE*/ 1, |
776 |
/* COMM SPEED*/ 1, |
777 |
}, |
778 |
}; |
779 |
|
780 |
VL53L0XDriver moduleLldProximity2 = { |
781 |
{ |
782 |
/* I²C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
783 |
/* I²C timeout */ TIME_INFINITE,
|
784 |
|
785 |
/* VL53L0X_DevData_t */
|
786 |
{ |
787 |
/* VL53L0X_DMaxData_t */
|
788 |
{ |
789 |
/* AmbTuningWindowFactor_K */ 0, |
790 |
/* RetSignalAt0mm */ 0, |
791 |
|
792 |
}, |
793 |
/* Part2PartOffsetNVMMicroMeter */ 0, |
794 |
/* Part2PartOffsetAdjustmentNVMMicroMeter */ 0, |
795 |
/* VL53L0X_DeviceParameters_t */
|
796 |
{ |
797 |
/* VL53L0X_DeviceModes DeviceMode 0 == singleranging*/ 0, |
798 |
/* VL53L0X_HistogramModes HistogramMode 0=disable */ 0, |
799 |
/* MeasurementTimingBudgetMicroSeconds */ 0, |
800 |
/* InterMeasurementPeriodMilliSeconds */ 0, |
801 |
/* !! XTalkCompensationEnable */ 0, |
802 |
/* XTalkCompensationRangeMilliMeter */ 0, |
803 |
/* XTalkCompensationRateMegaCps */ 0, |
804 |
/* RangeOffsetMicroMeters */ 0, |
805 |
/* !! LimitChecksEnable */ 0, |
806 |
/* LimitChecksStatus */ 0, |
807 |
/* !! WrapAroundCheckEnable */ 0, |
808 |
|
809 |
}, |
810 |
/* VL53L0X_RangingMeasurementData_t */
|
811 |
{ |
812 |
/* TimeStamp */ 0, |
813 |
/* MeasurementTimeUsec */ 0, |
814 |
/* RangeMilliMeter */ 0, |
815 |
/* !! RangeDMaxMilliMeter */ 0, |
816 |
/* SignalRateRtnMegaCps */ 0, |
817 |
/* AmbientRateRtnMegaCps */ 0, |
818 |
/* EffectiveSpadRtnCount */ 0, |
819 |
/* ZoneId */ 0, |
820 |
/* RangeFractionalPart */ 0, |
821 |
/* RangeStatus */ 0, |
822 |
}, |
823 |
/* VL53L0X_HistogramMeasurementData_t */
|
824 |
{ |
825 |
/* HistogramData */ 0, |
826 |
/* HistogramType */ 0, |
827 |
/* FirstBin */ 0, |
828 |
/* BufferSize */ 0, |
829 |
/* NumberOfBins */ 0, |
830 |
/* VL53L0X_DeviceError ErrorStatus 0 == None_error */ 0, |
831 |
}, |
832 |
/* VL53L0X_DeviceSpecificParameters_t */
|
833 |
{ |
834 |
/* OscFrequencyMHz */ 0, |
835 |
/* LastEncodedTimeout */ 0, |
836 |
/* !! VL53L0X_GpioFunctionality Pin0GpioFunctionality 0==no interrupt */ 0, |
837 |
/* FinalRangeTimeoutMicroSecs */ 0, |
838 |
/* FinalRangeVcselPulsePeriod */ 0, |
839 |
/* PreRangeTimeoutMicroSecs */ 0, |
840 |
/* PreRangeVcselPulsePeriod */ 0, |
841 |
/* SigmaEstRefArray */ 0, |
842 |
/* SigmaEstEffPulseWidth */ 0, |
843 |
/* SigmaEstEffAmbWidth */ 0, |
844 |
/* ReadDataFromDeviceDone 0 == read from device was not done */ 0, |
845 |
/* ModuleId */ 0, |
846 |
/* Revision */ 0, |
847 |
/* ProductId */ "0", |
848 |
/* !! ReferenceSpadCount */ 0, |
849 |
/* !! ReferenceSpadType */ 0, |
850 |
/* RefSpadsInitialised */ 0, |
851 |
/* PartUIDUpper */ 0, |
852 |
/* PartUIDLower */ 0, |
853 |
/* SignalRateMeasFixed400mm */ 0, |
854 |
}, |
855 |
/* VL53L0X_SpadData_t */
|
856 |
{ |
857 |
/* RefSpadEnables */ 0, |
858 |
/* RefGoodSpadMap */ 0, |
859 |
|
860 |
}, |
861 |
/* SequenceConfig */ 0, |
862 |
/* !! RangeFractionalEnable */ 0, |
863 |
/* VL53L0X_State PalState */ 0, |
864 |
/* !! VL53L0X_PowerModes PowerMode 0==VL53L0X_POWERMODE_STANDBY_LEVEL1 */ 0, |
865 |
/* SigmaEstRefArray */ 0, |
866 |
/* SigmaEstEffPulseWidth */ 0, |
867 |
/* SigmaEstEffAmbWidth */ 0, |
868 |
/* StopVariable */ 0, |
869 |
/* targetRefRate */ 0, |
870 |
/* SigmaEstimate */ 0, |
871 |
/* SignalEstimate */0 , |
872 |
/* LastSignalRefMcps */ 0, |
873 |
/* *pTuningSettingsPointer */ 0, |
874 |
/* UseInternalTuningSettings */ 0, |
875 |
/* LinearityCorrectiveGain */ 0, |
876 |
/* !! DmaxCalRangeMilliMeter */ 0, |
877 |
/* DmaxCalSignalRateRtnMegaCps */ 0, |
878 |
}, |
879 |
/* I²C address */ VL53L0X_LLD_I2C_ADDR,
|
880 |
/* COMM TYPE*/ 1, |
881 |
/* COMM SPEED*/ 1, |
882 |
}, |
883 |
}; |
884 |
|
885 |
|
886 |
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) */ |
887 |
|
888 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) || defined(__DOXYGEN__)
|
889 |
|
890 |
PCAL6524Driver moduleLldGpioExtender1 = { |
891 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
892 |
/* I²C address */ PCAL6524_LLD_I2C_ADDR_VDD,
|
893 |
}; |
894 |
|
895 |
PCAL6524Driver moduleLldGpioExtender2 = { |
896 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
897 |
/* I²C address */ PCAL6524_LLD_I2C_ADDR_VDD,
|
898 |
}; |
899 |
|
900 |
AT42QT1050Driver moduleLldTouch = { |
901 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
902 |
/* I²C address */ AT42QT1050_LLD_I2C_ADDRSEL_LOW,
|
903 |
}; |
904 |
|
905 |
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) */ |
906 |
|
907 |
/** @} */
|
908 |
|
909 |
/*===========================================================================*/
|
910 |
/**
|
911 |
* @name Unit tests (UT)
|
912 |
* @{
|
913 |
*/
|
914 |
/*===========================================================================*/
|
915 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
916 |
#include <string.h> |
917 |
|
918 |
/*
|
919 |
* ADC
|
920 |
*/
|
921 |
static int _utShellCmdCb_Adc(BaseSequentialStream* stream, int argc, char* argv[]) |
922 |
{ |
923 |
(void)argc;
|
924 |
(void)argv;
|
925 |
aosUtRun(stream, &moduleUtAdcVsys, NULL);
|
926 |
return AOS_OK;
|
927 |
} |
928 |
static ut_adcdata_t _utAdcVsysData = {
|
929 |
/* driver */ &MODULE_HAL_ADC_VSYS,
|
930 |
/* ADC conversion group */ &moduleHalAdcVsysConversionGroup,
|
931 |
}; |
932 |
aos_unittest_t moduleUtAdcVsys = { |
933 |
/* name */ "ADC", |
934 |
/* info */ "VSYS", |
935 |
/* test function */ utAdcFunc,
|
936 |
/* shell command */ {
|
937 |
/* name */ "unittest:ADC", |
938 |
/* callback */ _utShellCmdCb_Adc,
|
939 |
/* next */ NULL, |
940 |
}, |
941 |
/* data */ &_utAdcVsysData,
|
942 |
}; |
943 |
|
944 |
/*
|
945 |
* AT24C01B (EEPROM)
|
946 |
*/
|
947 |
static int _utShellCmdCb_AlldAt24c01b(BaseSequentialStream* stream, int argc, char* argv[]) |
948 |
{ |
949 |
(void)argc;
|
950 |
(void)argv;
|
951 |
aosUtRun(stream, &moduleUtAlldAt24c01b, NULL);
|
952 |
return AOS_OK;
|
953 |
} |
954 |
static ut_at24c01bdata_t _utAlldAt24c01bData = {
|
955 |
/* driver */ &moduleLldEeprom,
|
956 |
/* timeout */ MICROSECONDS_PER_SECOND,
|
957 |
}; |
958 |
aos_unittest_t moduleUtAlldAt24c01b = { |
959 |
/* name */ "AT24C01B", |
960 |
/* info */ "1kbit EEPROM", |
961 |
/* test function */ utAlldAt24c01bFunc,
|
962 |
/* shell command */ {
|
963 |
/* name */ "unittest:EEPROM", |
964 |
/* callback */ _utShellCmdCb_AlldAt24c01b,
|
965 |
/* next */ NULL, |
966 |
}, |
967 |
/* data */ &_utAlldAt24c01bData,
|
968 |
}; |
969 |
|
970 |
/*
|
971 |
* bq24103a (battery charger)
|
972 |
*/
|
973 |
static int _utShellCmdCb_AlldBq24103a(BaseSequentialStream* stream, int argc, char* argv[]) |
974 |
{ |
975 |
// local variables
|
976 |
bool print_help = false; |
977 |
|
978 |
// evaluate argument
|
979 |
if (argc == 2) { |
980 |
if (strcmp(argv[1], "-f") == 0 || strcmp(argv[1], "--front") == 0) { |
981 |
moduleUtAlldBq24103a.data = &moduleLldBatteryChargerFront; |
982 |
aosUtRun(stream, &moduleUtAlldBq24103a, "front battery");
|
983 |
moduleUtAlldBq24103a.data = NULL;
|
984 |
} |
985 |
else if (strcmp(argv[1], "-r") == 0 || strcmp(argv[1], "--rear") == 0) { |
986 |
moduleUtAlldBq24103a.data = &moduleLldBatteryChargerRear; |
987 |
aosUtRun(stream, &moduleUtAlldBq24103a, "rear battery");
|
988 |
moduleUtAlldBq24103a.data = NULL;
|
989 |
} |
990 |
else {
|
991 |
print_help = true;
|
992 |
} |
993 |
} else {
|
994 |
print_help = true;
|
995 |
} |
996 |
|
997 |
// print help or just return
|
998 |
if (print_help) {
|
999 |
chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
1000 |
chprintf(stream, "Options:\n");
|
1001 |
chprintf(stream, " --front, -f\n");
|
1002 |
chprintf(stream, " Test the front battery charger.\n");
|
1003 |
chprintf(stream, " --rear, -r\n");
|
1004 |
chprintf(stream, " Test the rear battery charger.\n");
|
1005 |
return AOS_INVALIDARGUMENTS;
|
1006 |
} else {
|
1007 |
return AOS_OK;
|
1008 |
} |
1009 |
} |
1010 |
aos_unittest_t moduleUtAlldBq24103a = { |
1011 |
/* name */ "bq24103a", |
1012 |
/* info */ "battery charger", |
1013 |
/* test function */ utAlldBq241xxFunc,
|
1014 |
/* shell command */ {
|
1015 |
/* name */ "unittest:BatteryCharger", |
1016 |
/* callback */ _utShellCmdCb_AlldBq24103a,
|
1017 |
/* next */ NULL, |
1018 |
}, |
1019 |
/* data */ NULL, |
1020 |
}; |
1021 |
|
1022 |
/*
|
1023 |
* bq27500 (fuel gauge)
|
1024 |
*/
|
1025 |
static int _utShellCmdCb_AlldBq27500(BaseSequentialStream* stream, int argc, char* argv[]) |
1026 |
{ |
1027 |
// evaluate arguments
|
1028 |
if (argc == 2) { |
1029 |
if (strcmp(argv[1], "-f") == 0 || strcmp(argv[1], "--front") == 0) { |
1030 |
((ut_bq27500data_t*)moduleUtAlldBq27500.data)->driver = &moduleLldFuelGaugeFront; |
1031 |
aosUtRun(stream, &moduleUtAlldBq27500, "front battery");
|
1032 |
((ut_bq27500data_t*)moduleUtAlldBq27500.data)->driver = NULL;
|
1033 |
return AOS_OK;
|
1034 |
} |
1035 |
else if (strcmp(argv[1], "-r") == 0 || strcmp(argv[1], "--rear") == 0) { |
1036 |
((ut_bq27500data_t*)moduleUtAlldBq27500.data)->driver = &moduleLldFuelGaugeRear; |
1037 |
aosUtRun(stream, &moduleUtAlldBq27500, "rear battery");
|
1038 |
((ut_bq27500data_t*)moduleUtAlldBq27500.data)->driver = NULL;
|
1039 |
return AOS_OK;
|
1040 |
} |
1041 |
} |
1042 |
// print help
|
1043 |
chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
1044 |
chprintf(stream, "Options:\n");
|
1045 |
chprintf(stream, " --front, -f\n");
|
1046 |
chprintf(stream, " Test the front battery fuel gauge.\n");
|
1047 |
chprintf(stream, " --rear, -r\n");
|
1048 |
chprintf(stream, " Test the rear battery fuel gauge.\n");
|
1049 |
return AOS_INVALIDARGUMENTS;
|
1050 |
} |
1051 |
static ut_bq27500data_t _utAlldBq27500Data = {
|
1052 |
/* driver */ NULL, |
1053 |
/* timeout */ MICROSECONDS_PER_SECOND,
|
1054 |
}; |
1055 |
aos_unittest_t moduleUtAlldBq27500 = { |
1056 |
/* name */ "bq27500", |
1057 |
/* info */ "fuel gauge", |
1058 |
/* test function */ utAlldBq27500Func,
|
1059 |
/* shell command */ {
|
1060 |
/* name */ "unittest:FuelGauge", |
1061 |
/* callback */ _utShellCmdCb_AlldBq27500,
|
1062 |
/* next */ NULL, |
1063 |
}, |
1064 |
/* data */ &_utAlldBq27500Data,
|
1065 |
}; |
1066 |
|
1067 |
/*
|
1068 |
* bq27500 (fuel gauge) in combination with bq24103a (battery charger)
|
1069 |
*/
|
1070 |
static int _utShellCmdCb_AlldBq27500Bq24103a(BaseSequentialStream* stream, int argc, char* argv[]) |
1071 |
{ |
1072 |
// evaluate arguments
|
1073 |
if (argc == 2) { |
1074 |
if (strcmp(argv[1], "-f") == 0 || strcmp(argv[1], "--front") == 0) { |
1075 |
((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq27500 = &moduleLldFuelGaugeFront; |
1076 |
((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq241xx = &moduleLldBatteryChargerFront; |
1077 |
aosUtRun(stream, &moduleUtAlldBq27500Bq24103a, "front battery");
|
1078 |
((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq27500 = NULL;
|
1079 |
((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq241xx = NULL;
|
1080 |
return AOS_OK;
|
1081 |
} |
1082 |
else if (strcmp(argv[1], "-r") == 0 || strcmp(argv[1], "--rear") == 0) { |
1083 |
((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq27500 = &moduleLldFuelGaugeRear; |
1084 |
((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq241xx = &moduleLldBatteryChargerRear; |
1085 |
aosUtRun(stream, &moduleUtAlldBq27500Bq24103a, "rear battery");
|
1086 |
((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq27500 = NULL;
|
1087 |
((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq241xx = NULL;
|
1088 |
return AOS_OK;
|
1089 |
} |
1090 |
} |
1091 |
// print help
|
1092 |
chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
1093 |
chprintf(stream, "Options:\n");
|
1094 |
chprintf(stream, " --front, -f\n");
|
1095 |
chprintf(stream, " Test the front battery fuel gauge and charger.\n");
|
1096 |
chprintf(stream, " --rear, -r\n");
|
1097 |
chprintf(stream, " Test the rear battery fuel gauge and charger.\n");
|
1098 |
return AOS_INVALIDARGUMENTS;
|
1099 |
} |
1100 |
static ut_bq27500bq241xxdata_t _utAlldBq27500Bq24103aData= {
|
1101 |
/* bq27500 driver */ NULL, |
1102 |
/* bq24103a driver */ NULL, |
1103 |
/* timeout */ MICROSECONDS_PER_SECOND,
|
1104 |
}; |
1105 |
aos_unittest_t moduleUtAlldBq27500Bq24103a = { |
1106 |
/* name */ "BQ27500 & BQ24103A", |
1107 |
/* info */ "fuel gauge & battery charger", |
1108 |
/* test function */ utAlldBq27500Bq241xxFunc,
|
1109 |
/* shell command */ {
|
1110 |
/* name */ "unittest:FuelGauge&BatteryCharger", |
1111 |
/* callback */ _utShellCmdCb_AlldBq27500Bq24103a,
|
1112 |
/* next */ NULL, |
1113 |
}, |
1114 |
/* data */ &_utAlldBq27500Bq24103aData,
|
1115 |
}; |
1116 |
|
1117 |
/*
|
1118 |
* INA219 (power monitor)
|
1119 |
*/
|
1120 |
static int _utShellCmdCb_AlldIna219(BaseSequentialStream* stream, int argc, char* argv[]) |
1121 |
{ |
1122 |
// evaluate arguments
|
1123 |
if (argc == 2) { |
1124 |
if (strcmp(argv[1], "VDD") == 0) { |
1125 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVdd; |
1126 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 3.3f; |
1127 |
aosUtRun(stream, &moduleUtAlldIna219, "VDD (3.3V)");
|
1128 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL;
|
1129 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f; |
1130 |
return AOS_OK;
|
1131 |
} |
1132 |
else if (strcmp(argv[1], "VIO1.8") == 0) { |
1133 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVio18; |
1134 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 1.8f; |
1135 |
aosUtRun(stream, &moduleUtAlldIna219, "VIO (1.8V)");
|
1136 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL;
|
1137 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f; |
1138 |
return AOS_OK;
|
1139 |
} |
1140 |
else if (strcmp(argv[1], "VIO3.3") == 0) { |
1141 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVio33; |
1142 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 3.3f; |
1143 |
aosUtRun(stream, &moduleUtAlldIna219, "VIO (3.3V)");
|
1144 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL;
|
1145 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f; |
1146 |
return AOS_OK;
|
1147 |
} |
1148 |
else if (strcmp(argv[1], "VSYS4.2") == 0) { |
1149 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVsys42; |
1150 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 4.2f; |
1151 |
aosUtRun(stream, &moduleUtAlldIna219, "VSYS (4.2V)");
|
1152 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL;
|
1153 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f; |
1154 |
return AOS_OK;
|
1155 |
} |
1156 |
else if (strcmp(argv[1], "VIO5.0") == 0) { |
1157 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVio50; |
1158 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 5.0f; |
1159 |
aosUtRun(stream, &moduleUtAlldIna219, "VIO (5.0V)");
|
1160 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL;
|
1161 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f; |
1162 |
return AOS_OK;
|
1163 |
} |
1164 |
} |
1165 |
// print help
|
1166 |
chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
1167 |
chprintf(stream, "Options:\n");
|
1168 |
chprintf(stream, " VDD\n");
|
1169 |
chprintf(stream, " Test VDD (3.3V) power monitor.\n");
|
1170 |
chprintf(stream, " VIO1.8\n");
|
1171 |
chprintf(stream, " Test VIO 1.8V power monitor.\n");
|
1172 |
chprintf(stream, " VIO3.3\n");
|
1173 |
chprintf(stream, " Test VIO 3.3V power monitor.\n");
|
1174 |
chprintf(stream, " VSYS4.2\n");
|
1175 |
chprintf(stream, " Test VSYS 4.2V power monitor.\n");
|
1176 |
chprintf(stream, " VIO5.0\n");
|
1177 |
chprintf(stream, " Test VIO 5.0V power monitor.\n");
|
1178 |
return AOS_INVALIDARGUMENTS;
|
1179 |
} |
1180 |
static ut_ina219data_t _utAlldIna219Data = {
|
1181 |
/* driver */ NULL, |
1182 |
/* expected voltage */ 0.0f, |
1183 |
/* tolerance */ 0.05f, |
1184 |
/* timeout */ MICROSECONDS_PER_SECOND,
|
1185 |
}; |
1186 |
aos_unittest_t moduleUtAlldIna219 = { |
1187 |
/* name */ "INA219", |
1188 |
/* info */ "power monitor", |
1189 |
/* test function */ utAlldIna219Func,
|
1190 |
/* shell command */ {
|
1191 |
/* name */ "unittest:PowerMonitor", |
1192 |
/* callback */ _utShellCmdCb_AlldIna219,
|
1193 |
/* next */ NULL, |
1194 |
}, |
1195 |
/* data */ &_utAlldIna219Data,
|
1196 |
}; |
1197 |
|
1198 |
/*
|
1199 |
* Status LED
|
1200 |
*/
|
1201 |
static int _utShellCmdCb_AlldLed(BaseSequentialStream* stream, int argc, char* argv[]) |
1202 |
{ |
1203 |
(void)argc;
|
1204 |
(void)argv;
|
1205 |
aosUtRun(stream, &moduleUtAlldLed, NULL);
|
1206 |
return AOS_OK;
|
1207 |
} |
1208 |
aos_unittest_t moduleUtAlldLed = { |
1209 |
/* name */ "LED", |
1210 |
/* info */ NULL, |
1211 |
/* test function */ utAlldLedFunc,
|
1212 |
/* shell command */ {
|
1213 |
/* name */ "unittest:StatusLED", |
1214 |
/* callback */ _utShellCmdCb_AlldLed,
|
1215 |
/* next */ NULL, |
1216 |
}, |
1217 |
/* data */ &moduleLldStatusLed,
|
1218 |
}; |
1219 |
|
1220 |
/*
|
1221 |
* PKLCS1212E4001 (buzzer)
|
1222 |
*/
|
1223 |
static int _utShellCmdCb_AlldPklcs1212e4001(BaseSequentialStream* stream, int argc, char* argv[]) |
1224 |
{ |
1225 |
(void)argc;
|
1226 |
(void)argv;
|
1227 |
aosUtRun(stream, &moduleUtAlldPklcs1212e4001, NULL);
|
1228 |
return AOS_OK;
|
1229 |
} |
1230 |
static ut_pkxxxexxx_t _utAlldPklcs1212e4001Data = {
|
1231 |
/* PWM driver */ &MODULE_HAL_PWM_BUZZER,
|
1232 |
/* PWM channel */ MODULE_HAL_PWM_BUZZER_CHANNEL
|
1233 |
}; |
1234 |
aos_unittest_t moduleUtAlldPklcs1212e4001 = { |
1235 |
/* name */ "PKLCS1212E4001", |
1236 |
/* info */ "buzzer", |
1237 |
/* test function */ utAlldPkxxxexxxFunc,
|
1238 |
/* shell command */ {
|
1239 |
/* name */ "unittest:Buzzer", |
1240 |
/* callback */ _utShellCmdCb_AlldPklcs1212e4001,
|
1241 |
/* next */ NULL, |
1242 |
}, |
1243 |
/* data */ &_utAlldPklcs1212e4001Data,
|
1244 |
}; |
1245 |
|
1246 |
/*
|
1247 |
* TPS62113 (step-down converter)
|
1248 |
*/
|
1249 |
static int _utShellCmdCb_AlldTps62113(BaseSequentialStream* stream, int argc, char* argv[]) |
1250 |
{ |
1251 |
// Although there are four TPS62113 on the PCB, they all share the same input signal.
|
1252 |
// A sa result, no additional shell arguments need to be evaluated.
|
1253 |
(void)argc;
|
1254 |
(void)argv;
|
1255 |
aosUtRun(stream, &moduleUtAlldTps62113, NULL);
|
1256 |
return AOS_OK;
|
1257 |
} |
1258 |
aos_unittest_t moduleUtAlldTps62113 = { |
1259 |
/* name */ "TPS62113", |
1260 |
/* info */ "step-down converter", |
1261 |
/* test function */ utAlldTps6211xFunc,
|
1262 |
/* shell command */ {
|
1263 |
/* name */ "unittest:StepDownConverter", |
1264 |
/* callback */ _utShellCmdCb_AlldTps62113,
|
1265 |
/* next */ NULL, |
1266 |
}, |
1267 |
/* data */ &moduleLldStepDownConverter,
|
1268 |
}; |
1269 |
|
1270 |
/*
|
1271 |
* TPS62113 (step-donw converter) in combination with INA219 (power monitor)
|
1272 |
*/
|
1273 |
static int _utShellCmdCb_AlldTps62113Ina219(BaseSequentialStream* stream, int argc, char* argv[]) |
1274 |
{ |
1275 |
(void)argc;
|
1276 |
(void)argv;
|
1277 |
aosUtRun(stream, &moduleUtAlldTps62113Ina219, "VSYS (4.2V)");
|
1278 |
return AOS_OK;
|
1279 |
} |
1280 |
static ut_tps6211xina219data_t _utAlldTps62113Ina219Data = {
|
1281 |
/* TPS62113 */ &moduleLldStepDownConverter,
|
1282 |
/* INA219 */ &moduleLldPowerMonitorVsys42,
|
1283 |
/* timeout */ MICROSECONDS_PER_SECOND,
|
1284 |
}; |
1285 |
aos_unittest_t moduleUtAlldTps62113Ina219 = { |
1286 |
/* name */ "TPS62113 & INA219", |
1287 |
/* info */ "step-down converter & power monitor", |
1288 |
/* test function */ utAlldTps6211xIna219Func,
|
1289 |
/* shell command */ {
|
1290 |
/* name */ "unittest:StepDownConverter&PowerMonitor", |
1291 |
/* callback */ _utShellCmdCb_AlldTps62113Ina219,
|
1292 |
/* next */ NULL, |
1293 |
}, |
1294 |
/* data */ &_utAlldTps62113Ina219Data,
|
1295 |
}; |
1296 |
|
1297 |
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) || defined(__DOXYGEN__)
|
1298 |
|
1299 |
/*
|
1300 |
* MPR121 (touch sensor)
|
1301 |
*/
|
1302 |
static int _utShellCmdCb_AlldMpr121(BaseSequentialStream* stream, int argc, char* argv[]) |
1303 |
{ |
1304 |
(void)argc;
|
1305 |
(void)argv;
|
1306 |
aosUtRun(stream, &moduleUtAlldMpr121, NULL);
|
1307 |
return AOS_OK;
|
1308 |
} |
1309 |
static ut_mpr121data_t _utAlldMpr121Data= {
|
1310 |
/* MPR121 driver */ &moduleLldTouch,
|
1311 |
/* timeout */ MICROSECONDS_PER_SECOND,
|
1312 |
/* event source */ &aos.events.io,
|
1313 |
/* event flags */ MODULE_OS_IOEVENTFLAGS_TOUCHINT,
|
1314 |
}; |
1315 |
aos_unittest_t moduleUtAlldMpr121 = { |
1316 |
/* name */ "MPR121", |
1317 |
/* info */ "touch sensor", |
1318 |
/* test function */ utAlldMpr121Func,
|
1319 |
/* shell command */ {
|
1320 |
/* name */ "unittest:Touch", |
1321 |
/* callback */ _utShellCmdCb_AlldMpr121,
|
1322 |
/* next */ NULL, |
1323 |
}, |
1324 |
/* data */ &_utAlldMpr121Data,
|
1325 |
}; |
1326 |
|
1327 |
/*
|
1328 |
* PCA9544A (I2C multiplexer)
|
1329 |
*/
|
1330 |
static int _utShellCmdCb_AlldPca5944a(BaseSequentialStream* stream, int argc, char* argv[]) |
1331 |
{ |
1332 |
// evaluate arguments
|
1333 |
if (argc == 2) { |
1334 |
if (strcmp(argv[1], "#1") == 0) { |
1335 |
((ut_pca9544adata_t*)moduleUtAlldPca9544a.data)->driver = &moduleLldI2cMultiplexer1; |
1336 |
aosUtRun(stream, &moduleUtAlldPca9544a, "I2C bus #1");
|
1337 |
((ut_pca9544adata_t*)moduleUtAlldPca9544a.data)->driver = NULL;
|
1338 |
return AOS_OK;
|
1339 |
} |
1340 |
else if (strcmp(argv[1], "#2") == 0) { |
1341 |
((ut_pca9544adata_t*)moduleUtAlldPca9544a.data)->driver = &moduleLldI2cMultiplexer2; |
1342 |
aosUtRun(stream, &moduleUtAlldPca9544a, "I2C bus #2");
|
1343 |
((ut_pca9544adata_t*)moduleUtAlldPca9544a.data)->driver = NULL;
|
1344 |
return AOS_OK;
|
1345 |
} |
1346 |
} |
1347 |
// print help
|
1348 |
chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
1349 |
chprintf(stream, "Options:\n");
|
1350 |
chprintf(stream, " #1\n");
|
1351 |
chprintf(stream, " Test the multiplexer on the I2C bus #1.\n");
|
1352 |
chprintf(stream, " #2\n");
|
1353 |
chprintf(stream, " Test the multiplexer on the I2C bus #2.\n");
|
1354 |
return AOS_INVALIDARGUMENTS;
|
1355 |
} |
1356 |
static ut_pca9544adata_t _utAlldPca9544aData = {
|
1357 |
/* driver */ NULL, |
1358 |
/* timeout */ MICROSECONDS_PER_SECOND,
|
1359 |
}; |
1360 |
aos_unittest_t moduleUtAlldPca9544a = { |
1361 |
/* name */ "PCA9544A", |
1362 |
/* info */ "I2C multiplexer", |
1363 |
/* test function */ utAlldPca9544aFunc,
|
1364 |
/* shell command */ {
|
1365 |
/* name */ "unittest:I2CMultiplexer", |
1366 |
/* callback */ _utShellCmdCb_AlldPca5944a,
|
1367 |
/* next */ NULL, |
1368 |
}, |
1369 |
/* data */ &_utAlldPca9544aData,
|
1370 |
}; |
1371 |
|
1372 |
/*
|
1373 |
* VCNL4020 (proximity sensor)
|
1374 |
*/
|
1375 |
static void _utAlldVcnl4020_disableInterrupt(VCNL4020Driver* vcnl) |
1376 |
{ |
1377 |
uint8_t intstatus; |
1378 |
vcnl4020_lld_writereg(vcnl, VCNL4020_LLD_REGADDR_INTCTRL, 0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
|
1379 |
vcnl4020_lld_readreg(vcnl, VCNL4020_LLD_REGADDR_INTSTATUS, &intstatus, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
1380 |
if (intstatus) {
|
1381 |
vcnl4020_lld_writereg(vcnl, VCNL4020_LLD_REGADDR_INTSTATUS, intstatus, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
1382 |
} |
1383 |
return;
|
1384 |
} |
1385 |
static int _utShellCmdCb_AlldVcnl4020(BaseSequentialStream* stream, int argc, char* argv[]) |
1386 |
{ |
1387 |
enum {
|
1388 |
UNKNOWN, |
1389 |
NNE, ENE, ESE, SSE, SSW,WSW,WNW, NNW, |
1390 |
} sensor = UNKNOWN; |
1391 |
// evaluate arguments
|
1392 |
if (argc == 2) { |
1393 |
if (strcmp(argv[1], "-nne") == 0) { |
1394 |
sensor = NNE; |
1395 |
} else if (strcmp(argv[1], "-ene") == 0) { |
1396 |
sensor = ENE; |
1397 |
} else if (strcmp(argv[1], "-ese") == 0) { |
1398 |
sensor = ESE; |
1399 |
} else if (strcmp(argv[1], "-sse") == 0) { |
1400 |
sensor = SSE; |
1401 |
} else if (strcmp(argv[1], "-ssw") == 0) { |
1402 |
sensor = SSW; |
1403 |
} else if (strcmp(argv[1], "-wsw") == 0) { |
1404 |
sensor = WSW; |
1405 |
} else if (strcmp(argv[1], "-wnw") == 0) { |
1406 |
sensor = WNW; |
1407 |
} else if (strcmp(argv[1], "-nnw") == 0) { |
1408 |
sensor = NNW; |
1409 |
} |
1410 |
} |
1411 |
if (sensor != UNKNOWN) {
|
1412 |
PCA9544ADriver* mux = NULL;
|
1413 |
switch (sensor) {
|
1414 |
case SSE:
|
1415 |
case SSW:
|
1416 |
case WSW:
|
1417 |
case WNW:
|
1418 |
mux = &moduleLldI2cMultiplexer1; |
1419 |
((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld = &moduleLldProximity1; |
1420 |
((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT2; |
1421 |
break;
|
1422 |
case NNW:
|
1423 |
case NNE:
|
1424 |
case ENE:
|
1425 |
case ESE:
|
1426 |
mux = &moduleLldI2cMultiplexer2; |
1427 |
((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld = &moduleLldProximity2; |
1428 |
((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT1; |
1429 |
break;
|
1430 |
default:
|
1431 |
break;
|
1432 |
} |
1433 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
1434 |
_utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld); |
1435 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH1, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
1436 |
_utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld); |
1437 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH2, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
1438 |
_utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld); |
1439 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH3, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
1440 |
_utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld); |
1441 |
switch (sensor) {
|
1442 |
case NNE:
|
1443 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH1, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
1444 |
aosUtRun(stream, &moduleUtAlldVcnl4020, "north-northeast sensor");
|
1445 |
break;
|
1446 |
case ENE:
|
1447 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH3, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
1448 |
aosUtRun(stream, &moduleUtAlldVcnl4020, "east-northeast sensor");
|
1449 |
break;
|
1450 |
case ESE:
|
1451 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH2, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
1452 |
aosUtRun(stream, &moduleUtAlldVcnl4020, "north-southeast sensor");
|
1453 |
break;
|
1454 |
case SSE:
|
1455 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
1456 |
aosUtRun(stream, &moduleUtAlldVcnl4020, "south-southeast sensor");
|
1457 |
break;
|
1458 |
case SSW:
|
1459 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH1, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
1460 |
aosUtRun(stream, &moduleUtAlldVcnl4020, "south-southwest sensor");
|
1461 |
break;
|
1462 |
case WSW:
|
1463 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH3, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
1464 |
aosUtRun(stream, &moduleUtAlldVcnl4020, "west-southwest sensor");
|
1465 |
break;
|
1466 |
case WNW:
|
1467 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH2, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
1468 |
aosUtRun(stream, &moduleUtAlldVcnl4020, "west-northwest sensor");
|
1469 |
break;
|
1470 |
case NNW:
|
1471 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
1472 |
aosUtRun(stream, &moduleUtAlldVcnl4020, "north-northwest sensor");
|
1473 |
break;
|
1474 |
default:
|
1475 |
break;
|
1476 |
} |
1477 |
((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld = NULL;
|
1478 |
((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->evtflags = 0;
|
1479 |
return AOS_OK;
|
1480 |
} |
1481 |
// print help
|
1482 |
chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
1483 |
chprintf(stream, "Options:\n");
|
1484 |
chprintf(stream, " -nne\n");
|
1485 |
chprintf(stream, " Test north-northeast sensor.\n");
|
1486 |
chprintf(stream, " -ene\n");
|
1487 |
chprintf(stream, " Test east-northeast sensor.\n");
|
1488 |
chprintf(stream, " -ese\n");
|
1489 |
chprintf(stream, " Test east-southeast sensor.\n");
|
1490 |
chprintf(stream, " -sse\n");
|
1491 |
chprintf(stream, " Test south-southeast sensor.\n");
|
1492 |
chprintf(stream, " -ssw\n");
|
1493 |
chprintf(stream, " Test south-southwest sensor.\n");
|
1494 |
chprintf(stream, " -wsw\n");
|
1495 |
chprintf(stream, " Test west-southwest sensor.\n");
|
1496 |
chprintf(stream, " -wnw\n");
|
1497 |
chprintf(stream, " Test west-northwest sensor.\n");
|
1498 |
chprintf(stream, " -nnw\n");
|
1499 |
chprintf(stream, " Test north-northwest sensor.\n");
|
1500 |
return AOS_INVALIDARGUMENTS;
|
1501 |
} |
1502 |
static ut_vcnl4020data_t _utAlldVcnl4020Data = {
|
1503 |
/* driver */ NULL, |
1504 |
/* timeout */ MICROSECONDS_PER_SECOND,
|
1505 |
/* event source */ &aos.events.io,
|
1506 |
/* event flags */ 0, |
1507 |
}; |
1508 |
aos_unittest_t moduleUtAlldVcnl4020 = { |
1509 |
/* name */ "VCNL4020", |
1510 |
/* info */ "proximity sensor", |
1511 |
/* test function */ utAlldVcnl4020Func,
|
1512 |
/* shell command */ {
|
1513 |
/* name */ "unittest:Proximity", |
1514 |
/* callback */ _utShellCmdCb_AlldVcnl4020,
|
1515 |
/* next */ NULL, |
1516 |
}, |
1517 |
/* data */ &_utAlldVcnl4020Data,
|
1518 |
}; |
1519 |
|
1520 |
#endif /* (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) */ |
1521 |
|
1522 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) || defined(__DOXYGEN__)
|
1523 |
|
1524 |
/*
|
1525 |
* PCAL6524 (GPIO extender)
|
1526 |
*/
|
1527 |
static int _utShellCmdCb_AlldPcal6524(BaseSequentialStream* stream, int argc, char* argv[]) |
1528 |
{ |
1529 |
// evaluate arguments
|
1530 |
if (argc == 2) { |
1531 |
if (strcmp(argv[1], "#1") == 0) { |
1532 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = &moduleLldGpioExtender1; |
1533 |
aosUtRun(stream, &moduleUtAlldPcal6524, "I2C bus #1");
|
1534 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = NULL;
|
1535 |
return AOS_OK;
|
1536 |
} |
1537 |
else if (strcmp(argv[1], "#2") == 0) { |
1538 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = &moduleLldGpioExtender2; |
1539 |
aosUtRun(stream, &moduleUtAlldPcal6524, "I2C bus #2");
|
1540 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = NULL;
|
1541 |
return AOS_OK;
|
1542 |
} |
1543 |
} |
1544 |
// print help
|
1545 |
chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
1546 |
chprintf(stream, "Options:\n");
|
1547 |
chprintf(stream, " #1\n");
|
1548 |
chprintf(stream, " Test the GPIO extender on the I2C bus #1.\n");
|
1549 |
chprintf(stream, " #2\n");
|
1550 |
chprintf(stream, " Test the GPIO extender on the I2C bus #2.\n");
|
1551 |
return AOS_INVALIDARGUMENTS;
|
1552 |
} |
1553 |
static ut_pcal6524data_t _utAlldPcal6524Data = {
|
1554 |
/* driver */ NULL, |
1555 |
/* timeout */ MICROSECONDS_PER_SECOND,
|
1556 |
}; |
1557 |
aos_unittest_t moduleUtAlldPcal6524 = { |
1558 |
/* name */ "PCAL6524", |
1559 |
/* info */ "GPIO extender", |
1560 |
/* test function */ utAlldPcal6524Func,
|
1561 |
/* shell command */ {
|
1562 |
/* name */ "unittest:GPIOExtender", |
1563 |
/* callback */ _utShellCmdCb_AlldPcal6524,
|
1564 |
/* next */ NULL, |
1565 |
}, |
1566 |
/* data */ &_utAlldPcal6524Data,
|
1567 |
}; |
1568 |
|
1569 |
/*
|
1570 |
* AT42QT1050 (touch sensor)
|
1571 |
*/
|
1572 |
static int _utShellCmdCb_AlldAt42qt1050(BaseSequentialStream* stream, int argc, char* argv[]) |
1573 |
{ |
1574 |
(void)argc;
|
1575 |
(void)argv;
|
1576 |
aosUtRun(stream, &moduleUtAlldAt42qt1050, NULL);
|
1577 |
return AOS_OK;
|
1578 |
} |
1579 |
static ut_at42qt1050data_t _utAlldAt42qt1050Data= {
|
1580 |
/* AT42QT1050 driver */ &moduleLldTouch,
|
1581 |
/* timeout */ MICROSECONDS_PER_SECOND,
|
1582 |
/* event source */ &aos.events.io,
|
1583 |
/* event flags */ MODULE_OS_IOEVENTFLAGS_TOUCHINT,
|
1584 |
}; |
1585 |
aos_unittest_t moduleUtAlldAt42qt1050 = { |
1586 |
/* name */ "AT42QT1050", |
1587 |
/* info */ "touch sensor", |
1588 |
/* test function */ utAlldAt42qt1050Func,
|
1589 |
/* shell command */ {
|
1590 |
/* name */ "unittest:Touch", |
1591 |
/* callback */ _utShellCmdCb_AlldAt42qt1050,
|
1592 |
/* next */ NULL, |
1593 |
}, |
1594 |
/* data */ &_utAlldAt42qt1050Data,
|
1595 |
}; |
1596 |
|
1597 |
/* VL53L0X (proximity sensor) */
|
1598 |
static int _utShellCmdCb_AlldVL53L0X(BaseSequentialStream* stream, int argc, char* argv[]) |
1599 |
{ |
1600 |
|
1601 |
|
1602 |
// first GPIO-Extender (the first 4 areas)
|
1603 |
PCAL6524Driver* mux1 = NULL;
|
1604 |
// second GPRO-Extender (the last 4 areas)
|
1605 |
PCAL6524Driver* mux2 = NULL;
|
1606 |
uint32_t status; |
1607 |
uint8_t buffer[2];
|
1608 |
mux1 = &moduleLldGpioExtender1; |
1609 |
mux2 = &moduleLldGpioExtender2; |
1610 |
|
1611 |
// set the XHUT Pins (P0_0 ... P0_7 P1_0 ... P1_3 ) from first GPIO-Extender to LOW (Pull-down)
|
1612 |
// first set Pull-up/pull-down enable register port to 1
|
1613 |
status = pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDENABLE_P0, 0xFF, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1614 |
// second set Pull-up/pull-down selection register for all XSHUT to pull-down (write a 0 in every bitmask)
|
1615 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDSELECTION_P0, 0x00, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1616 |
|
1617 |
|
1618 |
// first 4 register are XSHUT, last 4 are Interrupt, all need pull-up/pull-down
|
1619 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDENABLE_P1,0xFF, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1620 |
// XSHUT need pull-down and Interrupt need pull-up 11110000
|
1621 |
// 0xF0
|
1622 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDSELECTION_P1, 0x00, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1623 |
//set the interrupt register to input, write a 1 to configuration port registers (0Ch, 0Dh, 0Eh)
|
1624 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INPUT_P1, 0xF0, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1625 |
|
1626 |
// all Interrupt register need pull-up/pull-down
|
1627 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDENABLE_P2, 0xFF, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1628 |
// all interrupt register need Pull-up (set to 1)
|
1629 |
//0xFF == 11111111, we set all interrupt register to 00000000 == pull-down and only the register we need is pulled up
|
1630 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDSELECTION_P2, 0x00, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1631 |
//set the interrupt register to input, write a 1 to configuration port registers (0Ch, 0Dh, 0Eh)
|
1632 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INPUT_P2, 0xFF, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1633 |
|
1634 |
// set the XHUT Pins (P0_0 ... P0_7 P1_0 ... P1_3 ) from second GPIO-Extender to LOW
|
1635 |
// same as first GPIO-Extender
|
1636 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_PUPDENABLE_P0, 0xFF, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1637 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_PUPDSELECTION_P0, 0x00, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1638 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_PUPDENABLE_P1,0xFF, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1639 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_PUPDSELECTION_P1, 0x00, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1640 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INPUT_P1, 0xF0, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1641 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDENABLE_P2, 0xFF, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1642 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_PUPDSELECTION_P2, 0x00, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1643 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INPUT_P2, 0xFF, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1644 |
|
1645 |
|
1646 |
|
1647 |
//set one sensor to active
|
1648 |
/*only bus moduleLldGpioExtender1
|
1649 |
|
1650 |
A GP
|
1651 |
S1 S2 S3 | S4 S5 S6 | S7 S8 S9 | S10 S11 S12|
|
1652 |
GPIO
|
1653 |
XSHUT 1.3 1.2 1.1| 1.0 0.7 0.6| 0.5 0.4 0.3| 0.2 0.1 0.0|
|
1654 |
INTER 2.7 2.6 2.5| 2.4 2.3 2.2| 2.1 2.0 1.7| 1.6 1.5 1.4|
|
1655 |
|
1656 |
OPTION
|
1657 |
# 11 12 13 | 14 15 16 | 17 18 19 | 110 111 112|
|
1658 |
|
1659 |
|
1660 |
A == Anschluss
|
1661 |
GP == GPIO Extender
|
1662 |
*/
|
1663 |
if (argc == 2) { |
1664 |
if (strcmp(argv[1], "#11") == 0) { |
1665 |
buffer[0] = 0x8; // == P1.3 => Interrupt 2.7 |
1666 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDSELECTION_P1, buffer[0], ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1667 |
// enable pull-up for the one used interrupt register
|
1668 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDSELECTION_P2, 0x80, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1669 |
// only one pin is set to 0 as interrupt mask register => M2.7 == 01111111
|
1670 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTMASK_P2, 0x7F, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1671 |
// interrupt edge register IE2.7 with falling edge (from HIGH to LOW) == 10 00 00 00on adress 64h
|
1672 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTEDGE_P2B, 0x80, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1673 |
|
1674 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->vl53d = &moduleLldProximity1; |
1675 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT1; |
1676 |
|
1677 |
//set GPIO extender
|
1678 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->gpio = &moduleLldGpioExtender1; |
1679 |
} else if (strcmp(argv[1], "#12") == 0) { |
1680 |
buffer[0] = 0x4; // PUD1.2 with interrupt P2_6 |
1681 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDSELECTION_P1, buffer[0], ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1682 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTMASK_P2, 0x20, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1683 |
// only one pin is set to 0 as interrupt mask register M2.6 == 0xBF == 10111111
|
1684 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTMASK_P2, 0xBF, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1685 |
// interrupt edge register IE2.6 with falling edge (from HIGH to LOW) == 00100000
|
1686 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTEDGE_P2B, 0x20, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1687 |
|
1688 |
|
1689 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->vl53d = &moduleLldProximity1; |
1690 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT1; |
1691 |
|
1692 |
//set GPIO extender
|
1693 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->gpio = &moduleLldGpioExtender1; |
1694 |
} else if (strcmp(argv[1], "#13") == 0) { |
1695 |
buffer[0] = 0x2; // PUD1.1 with Interrupt P2_5 |
1696 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDSELECTION_P1, buffer[0], ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1697 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTMASK_P2, 0x10, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1698 |
// only one pin is set to 0 as interrupt mask register M2.5 == 0xDF == 11011111
|
1699 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTMASK_P2, 0xBF, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1700 |
// interrupt edge register IE2.5 with falling edge (from HIGH to LOW) == 0x8 == 00001000
|
1701 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTEDGE_P2B, 0x8, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1702 |
|
1703 |
|
1704 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->vl53d = &moduleLldProximity1; |
1705 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT1; |
1706 |
//set GPIO extender
|
1707 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->gpio = &moduleLldGpioExtender1; |
1708 |
} else if (strcmp(argv[1], "#14") == 0) { |
1709 |
buffer[0] = 0x1; // PUD1.0 with Interrupt P2_4 |
1710 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDSELECTION_P1, buffer[0], ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1711 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTMASK_P2, 0x8, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1712 |
// only one pin is set to 0 as interrupt mask register M2.4 == 0xEF == 11101111
|
1713 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTMASK_P2, 0xEF, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1714 |
// interrupt edge register IE2.4 with falling edge (from HIGH to LOW) == 0x8 == 00000010
|
1715 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTEDGE_P2B, 0x2, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1716 |
|
1717 |
|
1718 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->vl53d = &moduleLldProximity1; |
1719 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT1; |
1720 |
//set GPIO extender
|
1721 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->gpio = &moduleLldGpioExtender1; |
1722 |
} else if (strcmp(argv[1], "#15") == 0) { |
1723 |
buffer[0] = 0x80; // PUD0.7 with interrupt P2.3 |
1724 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDSELECTION_P0, buffer[0], ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1725 |
// enable pull-up for the one used interrupt register (set to 1) == 00001000
|
1726 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDSELECTION_P2, 0x8, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1727 |
// only one pin is set to 0 as interrupt mask register => M2.3 == 11110111
|
1728 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTMASK_P2, 0xF7, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1729 |
// interrupt edge register IE2.2 with falling edge (from HIGH to LOW) == 10000000 on adress 64h
|
1730 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTEDGE_P2A, 0x80, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1731 |
|
1732 |
|
1733 |
|
1734 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->vl53d = &moduleLldProximity1; |
1735 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT1; |
1736 |
//set GPIO extender
|
1737 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->gpio = &moduleLldGpioExtender1; |
1738 |
} else if (strcmp(argv[1], "#16") == 0) { |
1739 |
buffer[0] = 0x40; // PUD0.6 with interrupt P2.2 |
1740 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDSELECTION_P0, buffer[0], ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1741 |
// enable pull-up for the one used interrupt register (set to 1) == 00000100
|
1742 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDSELECTION_P2, 0x4, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1743 |
// only one pin is set to 0 as interrupt mask register => M2.2 == 11111011
|
1744 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTMASK_P2, 0xFB, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1745 |
// interrupt edge register IE2.2 with falling edge (from HIGH to LOW) == 00100000 on adress 64h
|
1746 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTEDGE_P2A, 0x20, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1747 |
|
1748 |
|
1749 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->vl53d = &moduleLldProximity1; |
1750 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT1; |
1751 |
//set GPIO extender
|
1752 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->gpio = &moduleLldGpioExtender1; |
1753 |
} else if (strcmp(argv[1], "#17") == 0) { |
1754 |
buffer[0] = 0x20; // PUD0.5 wirh interrupt P2.1 |
1755 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDSELECTION_P0, buffer[0], ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1756 |
// enable pull-up for the one used interrupt register (set to 1) == 00000010
|
1757 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDSELECTION_P2, 0x2, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1758 |
// only one pin is set to 0 as interrupt mask register => M2.1 == 11111101
|
1759 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTMASK_P2, 0xFD, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1760 |
// interrupt edge register IE2.1 with falling edge (from HIGH to LOW) == 00001000 on adress 64h
|
1761 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTEDGE_P2A, 0x8, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1762 |
|
1763 |
|
1764 |
|
1765 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->vl53d = &moduleLldProximity1; |
1766 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT1; |
1767 |
//set GPIO extender
|
1768 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->gpio = &moduleLldGpioExtender1; |
1769 |
} else if (strcmp(argv[1], "#18") == 0) { |
1770 |
buffer[0] = 0x10; // PUD0.4 with interrupt P2.0 |
1771 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDSELECTION_P0, buffer[0], ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1772 |
// enable pull-up for the one used interrupt register (set to 1) == 00000001
|
1773 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDSELECTION_P2, 0x1, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1774 |
// only one pin is set to 0 as interrupt mask register => M2.0 == 11111110
|
1775 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTMASK_P2, 0xFE, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1776 |
// interrupt edge register IE1.5 with falling edge (from HIGH to LOW) == 00000010 on adress 64h
|
1777 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTEDGE_P2A, 0x2, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1778 |
|
1779 |
|
1780 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->vl53d = &moduleLldProximity1; |
1781 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT1; |
1782 |
//set GPIO extender
|
1783 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->gpio = &moduleLldGpioExtender1; |
1784 |
} else if (strcmp(argv[1], "#19") == 0) { |
1785 |
|
1786 |
buffer[0] = 0x8; // PUD0.3 with interrupt P1_7 |
1787 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDSELECTION_P0, buffer[0], ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1788 |
// enable pull-up for the one used interrupt register (set to 1) == 10000000
|
1789 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDSELECTION_P1, 0x80, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1790 |
// only one pin is set to 0 as interrupt mask register => M1.7 == 01111111
|
1791 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTMASK_P1, 0x7F, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1792 |
// interrupt edge register IE1.5 with falling edge (from HIGH to LOW) == 10000000 on adress 63h
|
1793 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTEDGE_P1B, 0x80, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1794 |
|
1795 |
|
1796 |
|
1797 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->vl53d = &moduleLldProximity1; |
1798 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT1; |
1799 |
//set GPIO extender
|
1800 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->gpio = &moduleLldGpioExtender1; |
1801 |
} else if (strcmp(argv[1], "#110") == 0) { |
1802 |
|
1803 |
buffer[0] = 0x4; //PUD0.2 with interrupt P1_6 |
1804 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDSELECTION_P0, buffer[0], ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1805 |
// enable pull-up for the one used interrupt register (set to 1) == 01000000
|
1806 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDSELECTION_P1, 0x40, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1807 |
// only one pin is set to 0 as interrupt mask register => M1.6 == 10111111
|
1808 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTMASK_P1, 0xBF, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1809 |
// interrupt edge register IE1.5 with falling edge (from HIGH to LOW) == 00100000 on adress 63h
|
1810 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTEDGE_P1B, 0x20, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1811 |
|
1812 |
|
1813 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->vl53d = &moduleLldProximity1; |
1814 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT1; |
1815 |
//set GPIO extender
|
1816 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->gpio = &moduleLldGpioExtender1; |
1817 |
} else if (strcmp(argv[1], "#111") == 0) { |
1818 |
buffer[0] = 0x2; // PUD0.1 with interrupt P1_5 |
1819 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDSELECTION_P0, buffer[0], ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1820 |
// enable pull-up for the one used interrupt register (set to 1) == 00100000
|
1821 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDSELECTION_P1, 0x20, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1822 |
// only one pin is set to 0 as interrupt mask register => M1.5 == 11011111
|
1823 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTMASK_P1, 0xDF, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1824 |
// interrupt edge register IE1.5 with falling edge (from HIGH to LOW) == 00001000 on adress 63h
|
1825 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTEDGE_P1B, 0x8, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1826 |
|
1827 |
|
1828 |
|
1829 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->vl53d = &moduleLldProximity1; |
1830 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT1; |
1831 |
//set GPIO extender
|
1832 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->gpio = &moduleLldGpioExtender1; |
1833 |
} else if (strcmp(argv[1], "#112") == 0) { |
1834 |
|
1835 |
buffer[0] = 0x1; // PUD0.0 with interrupt P1_4 |
1836 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDSELECTION_P0, buffer[0], ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1837 |
// enable pull-up for the one used interrupt register (set to 1) == 00010000
|
1838 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDSELECTION_P1, 0x10, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1839 |
// only one pin is set to 0 as interrupt mask register => M1.4 == 11101111
|
1840 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTMASK_P1, 0xEF, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1841 |
// interrupt edge register IE1.4 with falling edge (from HIGH to LOW) == 00 00 00 10 on adress 63h
|
1842 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTEDGE_P1B, 0x2, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1843 |
|
1844 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->vl53d = &moduleLldProximity1; |
1845 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT1; |
1846 |
//set GPIO extender
|
1847 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->gpio = &moduleLldGpioExtender1; |
1848 |
|
1849 |
} else if (strcmp(argv[1], "#21") == 0) { |
1850 |
buffer[0] = 0x8; // == P1.3 => Interrupt 2.7 |
1851 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_PUPDSELECTION_P1, buffer[0], ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1852 |
// enable pull-up for the one used interrupt register
|
1853 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_PUPDSELECTION_P2, 0x80, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1854 |
// only one pin is set to 0 as interrupt mask register => M2.7 == 01111111
|
1855 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INTERRUPTMASK_P2, 0x7F, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1856 |
// interrupt edge register IE2.7 with falling edge (from HIGH to LOW) == 10 00 00 00on adress 64h
|
1857 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INTERRUPTEDGE_P2B, 0x80, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1858 |
|
1859 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->vl53d = &moduleLldProximity2; |
1860 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT2; |
1861 |
//set GPIO extender
|
1862 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->gpio = &moduleLldGpioExtender2; |
1863 |
} else if (strcmp(argv[1], "#22") == 0) { |
1864 |
buffer[0] = 0x4; // PUD1.2 with interrupt P2_6 |
1865 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_PUPDSELECTION_P1, buffer[0], ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1866 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INTERRUPTMASK_P2, 0x20, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1867 |
// only one pin is set to 0 as interrupt mask register M2.6 == 0xBF == 10111111
|
1868 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INTERRUPTMASK_P2, 0xBF, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1869 |
// interrupt edge register IE2.6 with falling edge (from HIGH to LOW) == 00100000
|
1870 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INTERRUPTEDGE_P2B, 0x20, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1871 |
|
1872 |
|
1873 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->vl53d = &moduleLldProximity2; |
1874 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT2; |
1875 |
//set GPIO extender
|
1876 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->gpio = &moduleLldGpioExtender2; |
1877 |
|
1878 |
} else if (strcmp(argv[1], "#23") == 0) { |
1879 |
buffer[0] = 0x2; // PUD1.1 with Interrupt P2_5 |
1880 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_PUPDSELECTION_P1, buffer[0], ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1881 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INTERRUPTMASK_P2, 0x10, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1882 |
// only one pin is set to 0 as interrupt mask register M2.5 == 0xDF == 11011111
|
1883 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INTERRUPTMASK_P2, 0xBF, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1884 |
// interrupt edge register IE2.5 with falling edge (from HIGH to LOW) == 0x8 == 00001000
|
1885 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INTERRUPTEDGE_P2B, 0x8, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1886 |
|
1887 |
|
1888 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->vl53d = &moduleLldProximity2; |
1889 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT2; |
1890 |
//set GPIO extender
|
1891 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->gpio = &moduleLldGpioExtender2; |
1892 |
} else if (strcmp(argv[1], "#24") == 0) { |
1893 |
buffer[0] = 0x1; // PUD1.0 with Interrupt P2_4 |
1894 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_PUPDSELECTION_P1, buffer[0], ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1895 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INTERRUPTMASK_P2, 0x8, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1896 |
// only one pin is set to 0 as interrupt mask register M2.4 == 0xEF == 11101111
|
1897 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INTERRUPTMASK_P2, 0xEF, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1898 |
// interrupt edge register IE2.4 with falling edge (from HIGH to LOW) == 0x8 == 00000010
|
1899 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INTERRUPTEDGE_P2B, 0x2, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1900 |
|
1901 |
|
1902 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->vl53d = &moduleLldProximity2; |
1903 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT2; |
1904 |
//set GPIO extender
|
1905 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->gpio = &moduleLldGpioExtender2; |
1906 |
} else if (strcmp(argv[1], "#25") == 0) { |
1907 |
buffer[0] = 0x80; // PUD0.7 with interrupt P2.3 |
1908 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_PUPDSELECTION_P0, buffer[0], ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1909 |
// enable pull-up for the one used interrupt register (set to 1) == 00001000
|
1910 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_PUPDSELECTION_P2, 0x8, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1911 |
// only one pin is set to 0 as interrupt mask register => M2.3 == 11110111
|
1912 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INTERRUPTMASK_P2, 0xF7, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1913 |
// interrupt edge register IE2.2 with falling edge (from HIGH to LOW) == 10000000 on adress 64h
|
1914 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INTERRUPTEDGE_P2A, 0x80, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1915 |
|
1916 |
|
1917 |
|
1918 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->vl53d = &moduleLldProximity2; |
1919 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT2; |
1920 |
//set GPIO extender
|
1921 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->gpio = &moduleLldGpioExtender2; |
1922 |
} else if (strcmp(argv[1], "#26") == 0) { |
1923 |
buffer[0] = 0x40; // PUD0.6 with interrupt P2.2 |
1924 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_PUPDSELECTION_P0, buffer[0], ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1925 |
// enable pull-up for the one used interrupt register (set to 1) == 00000100
|
1926 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_PUPDSELECTION_P2, 0x4, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1927 |
// only one pin is set to 0 as interrupt mask register => M2.2 == 11111011
|
1928 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INTERRUPTMASK_P2, 0xFB, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1929 |
// interrupt edge register IE2.2 with falling edge (from HIGH to LOW) == 00100000 on adress 64h
|
1930 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INTERRUPTEDGE_P2A, 0x20, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1931 |
|
1932 |
|
1933 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->vl53d = &moduleLldProximity2; |
1934 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT2; |
1935 |
//set GPIO extender
|
1936 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->gpio = &moduleLldGpioExtender2; |
1937 |
} else if (strcmp(argv[1], "#27") == 0) { |
1938 |
buffer[0] = 0x20; // PUD0.5 wirh interrupt P2.1 |
1939 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_PUPDSELECTION_P0, buffer[0], ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1940 |
// enable pull-up for the one used interrupt register (set to 1) == 00000010
|
1941 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_PUPDSELECTION_P2, 0x2, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1942 |
// only one pin is set to 0 as interrupt mask register => M2.1 == 11111101
|
1943 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INTERRUPTMASK_P2, 0xFD, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1944 |
// interrupt edge register IE2.1 with falling edge (from HIGH to LOW) == 00001000 on adress 64h
|
1945 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INTERRUPTEDGE_P2A, 0x8, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1946 |
|
1947 |
|
1948 |
|
1949 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->vl53d = &moduleLldProximity2; |
1950 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT2; |
1951 |
//set GPIO extender
|
1952 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->gpio = &moduleLldGpioExtender2; |
1953 |
} else if (strcmp(argv[1], "#28") == 0) { |
1954 |
buffer[0] = 0x10; // PUD0.4 with interrupt P2.0 |
1955 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_PUPDSELECTION_P0, buffer[0], ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1956 |
// enable pull-up for the one used interrupt register (set to 1) == 00000001
|
1957 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_PUPDSELECTION_P2, 0x1, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1958 |
// only one pin is set to 0 as interrupt mask register => M2.0 == 11111110
|
1959 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INTERRUPTMASK_P2, 0xFE, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1960 |
// interrupt edge register IE1.5 with falling edge (from HIGH to LOW) == 00000010 on adress 64h
|
1961 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INTERRUPTEDGE_P2A, 0x2, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1962 |
|
1963 |
|
1964 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->vl53d = &moduleLldProximity2; |
1965 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT2; |
1966 |
//set GPIO extender
|
1967 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->gpio = &moduleLldGpioExtender2; |
1968 |
} else if (strcmp(argv[1], "#29") == 0) { |
1969 |
|
1970 |
buffer[0] = 0x8; // PUD0.3 with interrupt P1_7 |
1971 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_PUPDSELECTION_P0, buffer[0], ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1972 |
// enable pull-up for the one used interrupt register (set to 1) == 10000000
|
1973 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_PUPDSELECTION_P1, 0x80, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1974 |
// only one pin is set to 0 as interrupt mask register => M1.7 == 01111111
|
1975 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INTERRUPTMASK_P1, 0x7F, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1976 |
// interrupt edge register IE1.5 with falling edge (from HIGH to LOW) == 10000000 on adress 63h
|
1977 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INTERRUPTEDGE_P1B, 0x80, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1978 |
|
1979 |
|
1980 |
|
1981 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->vl53d = &moduleLldProximity2; |
1982 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT2; |
1983 |
//set GPIO extender
|
1984 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->gpio = &moduleLldGpioExtender2; |
1985 |
} else if (strcmp(argv[1], "#210") == 0) { |
1986 |
|
1987 |
buffer[0] = 0x4; //PUD0.2 with interrupt P1_6 |
1988 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_PUPDSELECTION_P0, buffer[0], ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1989 |
// enable pull-up for the one used interrupt register (set to 1) == 01000000
|
1990 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_PUPDSELECTION_P1, 0x40, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1991 |
// only one pin is set to 0 as interrupt mask register => M1.6 == 10111111
|
1992 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INTERRUPTMASK_P1, 0xBF, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1993 |
// interrupt edge register IE1.5 with falling edge (from HIGH to LOW) == 00100000 on adress 63h
|
1994 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INTERRUPTEDGE_P1B, 0x20, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
1995 |
|
1996 |
|
1997 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->vl53d = &moduleLldProximity2; |
1998 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT2; |
1999 |
//set GPIO extender
|
2000 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->gpio = &moduleLldGpioExtender2; |
2001 |
} else if (strcmp(argv[1], "#211") == 0) { |
2002 |
buffer[0] = 0x2; // PUD0.1 with interrupt P1_5 |
2003 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_PUPDSELECTION_P0, buffer[0], ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
2004 |
// enable pull-up for the one used interrupt register (set to 1) == 00100000
|
2005 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_PUPDSELECTION_P1, 0x20, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
2006 |
// only one pin is set to 0 as interrupt mask register => M1.5 == 11011111
|
2007 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INTERRUPTMASK_P1, 0xDF, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
2008 |
// interrupt edge register IE1.5 with falling edge (from HIGH to LOW) == 00001000 on adress 63h
|
2009 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INTERRUPTEDGE_P1B, 0x8, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
2010 |
|
2011 |
|
2012 |
|
2013 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->vl53d = &moduleLldProximity2; |
2014 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT2; |
2015 |
//set GPIO extender
|
2016 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->gpio = &moduleLldGpioExtender2; |
2017 |
} else if (strcmp(argv[1], "#212") == 0) { |
2018 |
|
2019 |
buffer[0] = 0x1; // PUD0.0 with interrupt P1_4 |
2020 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_PUPDSELECTION_P0, buffer[0], ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
2021 |
// enable pull-up for the one used interrupt register (set to 1) == 00010000
|
2022 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_PUPDSELECTION_P1, 0x10, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
2023 |
// only one pin is set to 0 as interrupt mask register => M1.4 == 11101111
|
2024 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INTERRUPTMASK_P1, 0xEF, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
2025 |
// interrupt edge register IE1.4 with falling edge (from HIGH to LOW) == 00 00 00 10 on adress 63h
|
2026 |
status |= pcal6524_lld_write_reg(mux2, PCAL6524_LLD_CMD_INTERRUPTEDGE_P1B, 0x2, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
2027 |
|
2028 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->vl53d = &moduleLldProximity2; |
2029 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT2; |
2030 |
//set GPIO extender
|
2031 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->gpio = &moduleLldGpioExtender2; |
2032 |
} else{
|
2033 |
//use first sensor
|
2034 |
chprintf(stream, "unknown argument, use first sensor\n");
|
2035 |
usleep(2000000);
|
2036 |
buffer[0] = 0x8; // == P1.3 => Interrupt 2.7 |
2037 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDSELECTION_P1, buffer[0], ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
2038 |
// enable pull-up for the one used interrupt register
|
2039 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_PUPDSELECTION_P2, 0x80, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
2040 |
// only one pin is set to 0 as interrupt mask register => M2.7 == 01111111
|
2041 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTMASK_P2, 0x7F, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
2042 |
// interrupt edge register IE2.7 with falling edge (from HIGH to LOW) == 10 00 00 00on adress 64h
|
2043 |
status |= pcal6524_lld_write_reg(mux1, PCAL6524_LLD_CMD_INTERRUPTEDGE_P2B, 0x80, ((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->timeout);
|
2044 |
|
2045 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->vl53d = &moduleLldProximity1; |
2046 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT1; |
2047 |
|
2048 |
//set GPIO extender
|
2049 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->gpio = &moduleLldGpioExtender1; |
2050 |
} |
2051 |
|
2052 |
|
2053 |
|
2054 |
|
2055 |
|
2056 |
(void)argc;
|
2057 |
(void)argv;
|
2058 |
//wait 60 ms for boottime from sensor
|
2059 |
usleep(60000);
|
2060 |
aosUtRun(stream, &moduleUtAlldVl53l0x, "VL53");
|
2061 |
|
2062 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->vl53d = NULL;
|
2063 |
((ut_vl53l0xdata_t*)moduleUtAlldVl53l0x.data)->gpio = NULL;
|
2064 |
return AOS_OK;
|
2065 |
}else{
|
2066 |
|
2067 |
// print help
|
2068 |
chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
2069 |
chprintf(stream, "Options:\n");
|
2070 |
chprintf(stream, " #11\n");
|
2071 |
chprintf(stream, " Test the first VL53L0X sensor on the I2C bus #1.\n");
|
2072 |
chprintf(stream, " #12\n");
|
2073 |
chprintf(stream, " Test the second VL53L0X sensor on the I2C bus #1.\n");
|
2074 |
chprintf(stream, " ... #112\n");
|
2075 |
chprintf(stream, " Test the 12 VL53L0X sensor on the I2C bus #1.\n");
|
2076 |
chprintf(stream, " #21\n");
|
2077 |
chprintf(stream, " Test the first VL53L0X sensor on the I2C bus #2.\n");
|
2078 |
chprintf(stream, " ... #212\n");
|
2079 |
chprintf(stream, " Test the 12 VL53L0X sensor on the I2C bus #2.\n");
|
2080 |
return AOS_INVALIDARGUMENTS;
|
2081 |
} |
2082 |
|
2083 |
|
2084 |
// belegung der Hols beim Sensor:
|
2085 |
// obster/rechter: interrupt, XSHUT, GND
|
2086 |
// mittlerer: GND, interrupt, XSHUT, GND
|
2087 |
// Unterster/linker:GND, interrupt, XSHUT
|
2088 |
// set the XHUT Pins (P0_0 ... P0_7 P1_0 ... P1_3 ) from first GPIO-Extender to LOW
|
2089 |
// -> first: Der pin, der auf XSHUT weißt ist ein Output !
|
2090 |
// -> second: setze alle Sensoren unter reset == Der Pin erhält eine Spannung unter 1 Volt
|
2091 |
// -> third: setze einen Pin auf High (Spannung groesser 2 Volt) und dann kann man die Adresse
|
2092 |
// ansprechen.
|
2093 |
|
2094 |
|
2095 |
|
2096 |
} |
2097 |
static ut_vl53l0xdata_t _utAlldVL53L0XData = {
|
2098 |
/* driver */ NULL, |
2099 |
/* timeout */ MICROSECONDS_PER_SECOND,
|
2100 |
/* event source */ &aos.events.io,
|
2101 |
/* event flags */ 0, |
2102 |
/* gpio */ NULL, |
2103 |
}; |
2104 |
aos_unittest_t moduleUtAlldVl53l0x = { |
2105 |
/* name */ "VL53L0X", |
2106 |
/* info */ "proximity sensor", |
2107 |
/* test function */ utAlldVL53L0XFunc,
|
2108 |
/* shell command */ {
|
2109 |
/* name */ "unittest:Proximity", |
2110 |
/* callback */ _utShellCmdCb_AlldVL53L0X,
|
2111 |
/* next */ NULL, |
2112 |
}, |
2113 |
/* data */ &_utAlldVL53L0XData,
|
2114 |
}; |
2115 |
|
2116 |
|
2117 |
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) */ |
2118 |
|
2119 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) || defined(__DOXYGEN__)
|
2120 |
|
2121 |
/*
|
2122 |
* PCAL6524 (GPIO extender)
|
2123 |
*/
|
2124 |
static int _utShellCmdCb_AlldPcal6524(BaseSequentialStream* stream, int argc, char* argv[]) |
2125 |
{ |
2126 |
// evaluate arguments
|
2127 |
if (argc == 2) { |
2128 |
if (strcmp(argv[1], "#1") == 0) { |
2129 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = &moduleLldGpioExtender1; |
2130 |
aosUtRun(stream, &moduleUtAlldPcal6524, "I2C bus #1");
|
2131 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = NULL;
|
2132 |
return AOS_OK;
|
2133 |
} |
2134 |
else if (strcmp(argv[1], "#2") == 0) { |
2135 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = &moduleLldGpioExtender2; |
2136 |
aosUtRun(stream, &moduleUtAlldPcal6524, "I2C bus #2");
|
2137 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = NULL;
|
2138 |
return AOS_OK;
|
2139 |
} |
2140 |
} |
2141 |
// print help
|
2142 |
chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
2143 |
chprintf(stream, "Options:\n");
|
2144 |
chprintf(stream, " #1\n");
|
2145 |
chprintf(stream, " Test the GPIO extender on the I2C bus #1.\n");
|
2146 |
chprintf(stream, " #2\n");
|
2147 |
chprintf(stream, " Test the GPIO extender on the I2C bus #2.\n");
|
2148 |
return AOS_INVALIDARGUMENTS;
|
2149 |
} |
2150 |
static ut_pcal6524data_t _utAlldPcal6524Data = {
|
2151 |
/* driver */ NULL, |
2152 |
/* timeout */ MICROSECONDS_PER_SECOND,
|
2153 |
}; |
2154 |
aos_unittest_t moduleUtAlldPcal6524 = { |
2155 |
/* name */ "PCAL6524", |
2156 |
/* info */ "GPIO extender", |
2157 |
/* test function */ utAlldPcal6524Func,
|
2158 |
/* shell command */ {
|
2159 |
/* name */ "unittest:GPIOExtender", |
2160 |
/* callback */ _utShellCmdCb_AlldPcal6524,
|
2161 |
/* next */ NULL, |
2162 |
}, |
2163 |
/* data */ &_utAlldPcal6524Data,
|
2164 |
}; |
2165 |
|
2166 |
/*
|
2167 |
* AT42QT1050 (touch sensor)
|
2168 |
*/
|
2169 |
static int _utShellCmdCb_AlldAt42qt1050(BaseSequentialStream* stream, int argc, char* argv[]) |
2170 |
{ |
2171 |
(void)argc;
|
2172 |
(void)argv;
|
2173 |
aosUtRun(stream, &moduleUtAlldAt42qt1050, NULL);
|
2174 |
return AOS_OK;
|
2175 |
} |
2176 |
static ut_at42qt1050data_t _utAlldAt42qt1050Data= {
|
2177 |
/* AT42QT1050 driver */ &moduleLldTouch,
|
2178 |
/* timeout */ MICROSECONDS_PER_SECOND,
|
2179 |
/* event source */ &aos.events.io,
|
2180 |
/* event flags */ MODULE_OS_IOEVENTFLAGS_TOUCHINT,
|
2181 |
}; |
2182 |
aos_unittest_t moduleUtAlldAt42qt1050 = { |
2183 |
/* name */ "AT42QT1050", |
2184 |
/* info */ "touch sensor", |
2185 |
/* test function */ utAlldAt42qt1050Func,
|
2186 |
/* shell command */ {
|
2187 |
/* name */ "unittest:Touch", |
2188 |
/* callback */ _utShellCmdCb_AlldAt42qt1050,
|
2189 |
/* next */ NULL, |
2190 |
}, |
2191 |
/* data */ &_utAlldAt42qt1050Data,
|
2192 |
}; |
2193 |
|
2194 |
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) */ |
2195 |
|
2196 |
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
2197 |
|
2198 |
/** @} */
|
2199 |
/** @} */
|