amiro-os / modules / PowerManagement_1-1 / module.c @ c7dcc892
History | View | Annotate | Download (46.712 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 SYS_REG_EN output signal GPIO.
|
125 |
*/
|
126 |
static apalGpio_t _gpioSysRegEn = {
|
127 |
/* line */ LINE_SYS_REG_EN,
|
128 |
}; |
129 |
ROMCONST apalControlGpio_t moduleGpioSysRegEn = { |
130 |
/* GPIO */ &_gpioSysRegEn,
|
131 |
/* meta */ {
|
132 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
133 |
/* active state */ APAL_GPIO_ACTIVE_HIGH,
|
134 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
135 |
}, |
136 |
}; |
137 |
|
138 |
/**
|
139 |
* @brief IR_INT1 input signal GPIO.
|
140 |
*/
|
141 |
static apalGpio_t _gpioIrInt1 = {
|
142 |
/* line */ LINE_IR_INT1_N,
|
143 |
}; |
144 |
ROMCONST apalControlGpio_t moduleGpioIrInt1 = { |
145 |
/* GPIO */ &_gpioIrInt1,
|
146 |
/* meta */ {
|
147 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
148 |
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR)
|
149 |
/* active state */ (VCNL4020_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
150 |
/* interrupt edge */ VCNL4020_LLD_INT_EDGE,
|
151 |
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X)
|
152 |
/* active state */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
153 |
/* interrupt edge */ PCAL6524_LLD_INT_EDGE,
|
154 |
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X)
|
155 |
/* active state */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
156 |
/* interrupt edge */ PCAL6524_LLD_INT_EDGE,
|
157 |
#else /* (BOARD_SENSORRING == ?) */ |
158 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
159 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
160 |
#endif /* (BOARD_SENSORRING == ?) */ |
161 |
}, |
162 |
}; |
163 |
|
164 |
/**
|
165 |
* @brief POWER_EN output signal GPIO.
|
166 |
*/
|
167 |
static apalGpio_t _gpioPowerEn = {
|
168 |
/* line */ LINE_POWER_EN,
|
169 |
}; |
170 |
ROMCONST apalControlGpio_t moduleGpioPowerEn = { |
171 |
/* GPIO */ &_gpioPowerEn,
|
172 |
/* meta */ {
|
173 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
174 |
/* active state */ APAL_GPIO_ACTIVE_HIGH,
|
175 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
176 |
}, |
177 |
}; |
178 |
|
179 |
/**
|
180 |
* @brief SYS_UART_DN bidirectional signal GPIO.
|
181 |
*/
|
182 |
static apalGpio_t _gpioSysUartDn = {
|
183 |
/* line */ LINE_SYS_UART_DN,
|
184 |
}; |
185 |
ROMCONST apalControlGpio_t moduleGpioSysUartDn = { |
186 |
/* GPIO */ &_gpioSysUartDn,
|
187 |
/* meta */ {
|
188 |
/* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
189 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
190 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
191 |
}, |
192 |
}; |
193 |
|
194 |
/**
|
195 |
* @brief CHARGE_STAT2A input signal GPIO.
|
196 |
*/
|
197 |
static apalGpio_t _gpioChargeStat2A = {
|
198 |
/* line */ LINE_CHARGE_STAT2A,
|
199 |
}; |
200 |
ROMCONST apalControlGpio_t moduleGpioChargeStat2A = { |
201 |
/* GPIO */ &_gpioChargeStat2A,
|
202 |
/* meta */ {
|
203 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
204 |
/* active state */ BQ241xx_LLD_CHARGE_STATUS_GPIO_ACTIVE_STATE,
|
205 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
206 |
}, |
207 |
}; |
208 |
|
209 |
/**
|
210 |
* @brief GAUGE_BATLOW2 input signal GPIO.
|
211 |
*/
|
212 |
static apalGpio_t _gpioGaugeBatLow2 = {
|
213 |
/* line */ LINE_GAUGE_BATLOW2,
|
214 |
}; |
215 |
ROMCONST apalControlGpio_t moduleGpioGaugeBatLow2 = { |
216 |
/* GPIO */ &_gpioGaugeBatLow2,
|
217 |
/* meta */ {
|
218 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
219 |
/* active state */ BQ27500_LLD_BATLOW_ACTIVE_STATE,
|
220 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
221 |
}, |
222 |
}; |
223 |
|
224 |
/**
|
225 |
* @brief GAUGE_BATGD2 input signal GPIO.
|
226 |
*/
|
227 |
static apalGpio_t _gpioGaugeBatGd2 = {
|
228 |
/* line */ LINE_GAUGE_BATGD2_N,
|
229 |
}; |
230 |
ROMCONST apalControlGpio_t moduleGpioGaugeBatGd2 = { |
231 |
/* GPIO */ &_gpioGaugeBatGd2,
|
232 |
/* meta */ {
|
233 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
234 |
/* active state */ BQ27500_LLD_BATGOOD_ACTIVE_STATE,
|
235 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
236 |
}, |
237 |
}; |
238 |
|
239 |
/**
|
240 |
* @brief LED output signal GPIO.
|
241 |
*/
|
242 |
static apalGpio_t _gpioLed = {
|
243 |
/* line */ LINE_LED,
|
244 |
}; |
245 |
ROMCONST apalControlGpio_t moduleGpioLed = { |
246 |
/* GPIO */ &_gpioLed,
|
247 |
/* meta */ {
|
248 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
249 |
/* active state */ LED_LLD_GPIO_ACTIVE_STATE,
|
250 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
251 |
}, |
252 |
}; |
253 |
|
254 |
/**
|
255 |
* @brief SYS_UART_UP bidirectional signal GPIO.
|
256 |
*/
|
257 |
static apalGpio_t _gpioSysUartUp = {
|
258 |
/* line */ LINE_SYS_UART_UP,
|
259 |
}; |
260 |
ROMCONST apalControlGpio_t moduleGpioSysUartUp = { |
261 |
/* GPIO */ &_gpioSysUartUp,
|
262 |
/* meta */ {
|
263 |
/* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
264 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
265 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
266 |
}, |
267 |
}; |
268 |
|
269 |
/**
|
270 |
* @brief CHARGE_STAT1A input signal GPIO.
|
271 |
*/
|
272 |
static apalGpio_t _gpioChargeStat1A = {
|
273 |
/* line */ LINE_CHARGE_STAT1A,
|
274 |
}; |
275 |
ROMCONST apalControlGpio_t moduleGpioChargeStat1A = { |
276 |
/* GPIO */ &_gpioChargeStat1A,
|
277 |
/* meta */ {
|
278 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
279 |
/* active state */ BQ241xx_LLD_CHARGE_STATUS_GPIO_ACTIVE_STATE,
|
280 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
281 |
}, |
282 |
}; |
283 |
|
284 |
/**
|
285 |
* @brief GAUGE_BATLOW1 input signal GPIO.
|
286 |
*/
|
287 |
static apalGpio_t _gpioGaugeBatLow1 = {
|
288 |
/* line */ LINE_GAUGE_BATLOW1,
|
289 |
}; |
290 |
ROMCONST apalControlGpio_t moduleGpioGaugeBatLow1 = { |
291 |
/* GPIO */ &_gpioGaugeBatLow1,
|
292 |
/* meta */ {
|
293 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
294 |
/* active state */ BQ27500_LLD_BATLOW_ACTIVE_STATE,
|
295 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
296 |
}, |
297 |
}; |
298 |
|
299 |
/**
|
300 |
* @brief GAUGE_BATGD1 input signal GPIO.
|
301 |
*/
|
302 |
static apalGpio_t _gpioGaugeBatGd1 = {
|
303 |
/* line */ LINE_GAUGE_BATGD1_N,
|
304 |
}; |
305 |
ROMCONST apalControlGpio_t moduleGpioGaugeBatGd1 = { |
306 |
/* GPIO */ &_gpioGaugeBatGd1,
|
307 |
/* meta */ {
|
308 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
309 |
/* active state */ BQ27500_LLD_BATGOOD_ACTIVE_STATE,
|
310 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
311 |
}, |
312 |
}; |
313 |
|
314 |
/**
|
315 |
* @brief CHARG_EN1 output signal GPIO.
|
316 |
*/
|
317 |
static apalGpio_t _gpioChargeEn1 = {
|
318 |
/* line */ LINE_CHARGE_EN1_N,
|
319 |
}; |
320 |
ROMCONST apalControlGpio_t moduleGpioChargeEn1 = { |
321 |
/* GPIO */ &_gpioChargeEn1,
|
322 |
/* meta */ {
|
323 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
324 |
/* active state */ BQ241xx_LLD_ENABLED_GPIO_ACTIVE_STATE,
|
325 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
326 |
}, |
327 |
}; |
328 |
|
329 |
/**
|
330 |
* @brief IR_INT2 input signal GPIO.
|
331 |
*/
|
332 |
static apalGpio_t _gpioIrInt2 = {
|
333 |
/* line */ LINE_IR_INT2_N,
|
334 |
}; |
335 |
ROMCONST apalControlGpio_t moduleGpioIrInt2 = { |
336 |
/* GPIO */ &_gpioIrInt2,
|
337 |
/* meta */ {
|
338 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
339 |
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR)
|
340 |
/* active state */ (VCNL4020_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
341 |
/* interrupt edge */ VCNL4020_LLD_INT_EDGE,
|
342 |
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X)
|
343 |
/* active state */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
344 |
/* interrupt edge */ PCAL6524_LLD_INT_EDGE,
|
345 |
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X)
|
346 |
/* active state */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
347 |
/* interrupt edge */ PCAL6524_LLD_INT_EDGE,
|
348 |
#else /* (BOARD_SENSORRING == ?) */ |
349 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
350 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
351 |
#endif /* (BOARD_SENSORRING == ?) */ |
352 |
}, |
353 |
}; |
354 |
|
355 |
/**
|
356 |
* @brief TOUCH_INT input signal GPIO.
|
357 |
*/
|
358 |
static apalGpio_t _gpioTouchInt = {
|
359 |
/* line */ LINE_TOUCH_INT_N,
|
360 |
}; |
361 |
ROMCONST apalControlGpio_t moduleGpioTouchInt = { |
362 |
/* GPIO */ &_gpioTouchInt,
|
363 |
/* meta */ {
|
364 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
365 |
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR)
|
366 |
/* active state */ (MPR121_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
367 |
/* interrupt edge */ MPR121_LLD_INT_EDGE,
|
368 |
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X)
|
369 |
/* active state */ (AT42QT1050_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
370 |
/* interrupt edge */ AT42QT1050_LLD_INT_EDGE,
|
371 |
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X)
|
372 |
/* active state */ (AT42QT1050_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
373 |
/* interrupt edge */ AT42QT1050_LLD_INT_EDGE,
|
374 |
#else /* (BOARD_SENSORRING == ?) */ |
375 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
376 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
377 |
#endif /* (BOARD_SENSORRING == ?) */ |
378 |
}, |
379 |
}; |
380 |
|
381 |
/**
|
382 |
* @brief SYS_DONE input signal GPIO.
|
383 |
*/
|
384 |
static apalGpio_t _gpioSysDone = {
|
385 |
/* line */ LINE_SYS_DONE,
|
386 |
}; |
387 |
ROMCONST apalControlGpio_t moduleGpioSysDone = { |
388 |
/* GPIO */ &_gpioSysDone,
|
389 |
/* meta */ {
|
390 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
391 |
/* active state */ APAL_GPIO_ACTIVE_HIGH,
|
392 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
393 |
}, |
394 |
}; |
395 |
|
396 |
/**
|
397 |
* @brief SYS_PROG output signal GPIO.
|
398 |
*/
|
399 |
static apalGpio_t _gpioSysProg = {
|
400 |
/* line */ LINE_SYS_PROG_N,
|
401 |
}; |
402 |
ROMCONST apalControlGpio_t moduleGpioSysProg = { |
403 |
/* GPIO */ &_gpioSysProg,
|
404 |
/* meta */ {
|
405 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
406 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
407 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
408 |
}, |
409 |
}; |
410 |
|
411 |
/**
|
412 |
* @brief PATH_DC input signal GPIO.
|
413 |
*/
|
414 |
static apalGpio_t _gpioPathDc = {
|
415 |
/* line */ LINE_PATH_DC,
|
416 |
}; |
417 |
ROMCONST apalControlGpio_t moduleGpioPathDc = { |
418 |
/* GPIO */ &_gpioPathDc,
|
419 |
/* meta */ {
|
420 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
421 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
422 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
423 |
}, |
424 |
}; |
425 |
|
426 |
/**
|
427 |
* @brief SYS_SPI_DIR bidirectional signal GPIO.
|
428 |
*/
|
429 |
static apalGpio_t _gpioSysSpiDir = {
|
430 |
/* line */ LINE_SYS_SPI_DIR,
|
431 |
}; |
432 |
ROMCONST apalControlGpio_t moduleGpioSysSpiDir = { |
433 |
/* GPIO */ &_gpioSysSpiDir,
|
434 |
/* meta */ {
|
435 |
/* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
436 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
437 |
/* interrupt edge */ APAL_GPIO_EDGE_FALLING,
|
438 |
}, |
439 |
}; |
440 |
|
441 |
/**
|
442 |
* @brief SYS_SYNC bidirectional signal GPIO.
|
443 |
*/
|
444 |
static apalGpio_t _gpioSysSync = {
|
445 |
/* line */ LINE_SYS_INT_N,
|
446 |
}; |
447 |
ROMCONST apalControlGpio_t moduleGpioSysSync = { |
448 |
/* GPIO */ &_gpioSysSync,
|
449 |
/* meta */ {
|
450 |
/* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
451 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
452 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
453 |
}, |
454 |
}; |
455 |
|
456 |
/**
|
457 |
* @brief SYS_PD bidirectional signal GPIO.
|
458 |
*/
|
459 |
static apalGpio_t _gpioSysPd = {
|
460 |
/* line */ LINE_SYS_PD_N,
|
461 |
}; |
462 |
ROMCONST apalControlGpio_t moduleGpioSysPd = { |
463 |
/* GPIO */ &_gpioSysPd,
|
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_WARMRST bidirectional signal GPIO.
|
473 |
*/
|
474 |
static apalGpio_t _gpioSysWarmrst = {
|
475 |
/* line */ LINE_SYS_WARMRST_N,
|
476 |
}; |
477 |
ROMCONST apalControlGpio_t moduleGpioSysWarmrst = { |
478 |
/* GPIO */ &_gpioSysWarmrst,
|
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 BT_RST output signal GPIO.
|
488 |
*/
|
489 |
static apalGpio_t _gpioBtRst = {
|
490 |
/* line */ LINE_BT_RST,
|
491 |
}; |
492 |
ROMCONST apalControlGpio_t moduleGpioBtRst = { |
493 |
/* GPIO */ &_gpioBtRst,
|
494 |
/* meta */ {
|
495 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
496 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
497 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
498 |
}, |
499 |
}; |
500 |
|
501 |
/**
|
502 |
* @brief CHARGE_EN2 output signal GPIO.
|
503 |
*/
|
504 |
static apalGpio_t _gpioChargeEn2 = {
|
505 |
/* line */ LINE_CHARGE_EN2_N,
|
506 |
}; |
507 |
ROMCONST apalControlGpio_t moduleGpioChargeEn2 = { |
508 |
/* GPIO */ &_gpioChargeEn2,
|
509 |
/* meta */ {
|
510 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
511 |
/* active state */ BQ241xx_LLD_ENABLED_GPIO_ACTIVE_STATE,
|
512 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
513 |
}, |
514 |
}; |
515 |
|
516 |
/** @} */
|
517 |
|
518 |
/*===========================================================================*/
|
519 |
/**
|
520 |
* @name AMiRo-OS core configurations
|
521 |
* @{
|
522 |
*/
|
523 |
/*===========================================================================*/
|
524 |
|
525 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
526 |
ROMCONST char* moduleShellPrompt = "PowerManagement"; |
527 |
#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */ |
528 |
|
529 |
/** @} */
|
530 |
|
531 |
/*===========================================================================*/
|
532 |
/**
|
533 |
* @name Startup Shutdown Synchronization Protocol (SSSP)
|
534 |
* @{
|
535 |
*/
|
536 |
/*===========================================================================*/
|
537 |
|
538 |
/** @} */
|
539 |
|
540 |
/*===========================================================================*/
|
541 |
/**
|
542 |
* @name Low-level drivers
|
543 |
* @{
|
544 |
*/
|
545 |
/*===========================================================================*/
|
546 |
|
547 |
AT24C01BDriver moduleLldEeprom = { |
548 |
/* I2C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
549 |
/* I2C address */ AT24C01B_LLD_I2C_ADDR_FIXED,
|
550 |
}; |
551 |
|
552 |
BQ241xxDriver moduleLldBatteryChargerFront = { |
553 |
/* charge enable GPIO */ &moduleGpioChargeEn1,
|
554 |
/* charge status GPIO */ &moduleGpioChargeStat1A,
|
555 |
}; |
556 |
|
557 |
BQ241xxDriver moduleLldBatteryChargerRear = { |
558 |
/* charge enable GPIO */ &moduleGpioChargeEn2,
|
559 |
/* charge status GPIO */ &moduleGpioChargeStat2A,
|
560 |
}; |
561 |
|
562 |
BQ27500Driver moduleLldFuelGaugeFront = { |
563 |
/* I2C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
564 |
/* battery low GPIO */ &moduleGpioGaugeBatLow1,
|
565 |
/* battery good GPIO */ &moduleGpioGaugeBatGd1,
|
566 |
}; |
567 |
|
568 |
BQ27500Driver moduleLldFuelGaugeRear = { |
569 |
/* I2C driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
570 |
/* battery low GPIO */ &moduleGpioGaugeBatLow2,
|
571 |
/* battery good GPIO */ &moduleGpioGaugeBatGd2,
|
572 |
}; |
573 |
|
574 |
INA219Driver moduleLldPowerMonitorVdd = { |
575 |
/* I2C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
576 |
/* I²C address */ INA219_LLD_I2C_ADDR_A0 | INA219_LLD_I2C_ADDR_A1,
|
577 |
/* current LSB (uA) */ 0x00u, |
578 |
/* configuration */ NULL, |
579 |
}; |
580 |
|
581 |
INA219Driver moduleLldPowerMonitorVio18 = { |
582 |
/* I2C Driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
583 |
/* I²C address */ INA219_LLD_I2C_ADDR_A1,
|
584 |
/* current LSB (uA) */ 0x00u, |
585 |
/* configuration */ NULL, |
586 |
}; |
587 |
|
588 |
INA219Driver moduleLldPowerMonitorVio33 = { |
589 |
/* I2C Driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
590 |
/* I²C address */ INA219_LLD_I2C_ADDR_FIXED,
|
591 |
/* current LSB (uA) */ 0x00u, |
592 |
/* configuration */ NULL, |
593 |
}; |
594 |
|
595 |
INA219Driver moduleLldPowerMonitorVsys42 = { |
596 |
/* I2C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
597 |
/* I²C address */ INA219_LLD_I2C_ADDR_FIXED,
|
598 |
/* current LSB (uA) */ 0x00u, |
599 |
/* configuration */ NULL, |
600 |
}; |
601 |
|
602 |
INA219Driver moduleLldPowerMonitorVio50 = { |
603 |
/* I2C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
604 |
/* I²C address */ INA219_LLD_I2C_ADDR_A1,
|
605 |
/* current LSB (uA) */ 0x00u, |
606 |
/* configuration */ NULL, |
607 |
}; |
608 |
|
609 |
LEDDriver moduleLldStatusLed = { |
610 |
/* LED GPIO */ &moduleGpioLed,
|
611 |
}; |
612 |
|
613 |
TPS6211xDriver moduleLldStepDownConverter = { |
614 |
/* Power enable GPIO */ &moduleGpioPowerEn,
|
615 |
}; |
616 |
|
617 |
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) || defined(__DOXYGEN__)
|
618 |
|
619 |
MPR121Driver moduleLldTouch = { |
620 |
/* I²C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
621 |
}; |
622 |
|
623 |
PCA9544ADriver moduleLldI2cMultiplexer1 = { |
624 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
625 |
/* I²C address */ PCA9544A_LLD_I2C_ADDR_A0 | PCA9544A_LLD_I2C_ADDR_A1 | PCA9544A_LLD_I2C_ADDR_A2,
|
626 |
}; |
627 |
|
628 |
PCA9544ADriver moduleLldI2cMultiplexer2 = { |
629 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
630 |
/* I²C address */ PCA9544A_LLD_I2C_ADDR_A0 | PCA9544A_LLD_I2C_ADDR_A1 | PCA9544A_LLD_I2C_ADDR_A2,
|
631 |
}; |
632 |
|
633 |
VCNL4020Driver moduleLldProximity1 = { |
634 |
/* I²C Driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
635 |
}; |
636 |
|
637 |
VCNL4020Driver moduleLldProximity2 = { |
638 |
/* I²C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
639 |
}; |
640 |
|
641 |
#endif /* (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) */ |
642 |
|
643 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) || defined(__DOXYGEN__)
|
644 |
|
645 |
PCAL6524Driver moduleLldGpioExtender1 = { |
646 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
647 |
/* I²C address */ PCAL6524_LLD_I2C_ADDR_VDD,
|
648 |
}; |
649 |
|
650 |
PCAL6524Driver moduleLldGpioExtender2 = { |
651 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
652 |
/* I²C address */ PCAL6524_LLD_I2C_ADDR_VDD,
|
653 |
}; |
654 |
|
655 |
AT42QT1050Driver moduleLldTouch = { |
656 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
657 |
/* I²C address */ AT42QT1050_LLD_I2C_ADDRSEL_LOW,
|
658 |
}; |
659 |
|
660 |
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) */ |
661 |
|
662 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) || defined(__DOXYGEN__)
|
663 |
|
664 |
PCAL6524Driver moduleLldGpioExtender1 = { |
665 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
666 |
/* I²C address */ PCAL6524_LLD_I2C_ADDR_VDD,
|
667 |
}; |
668 |
|
669 |
PCAL6524Driver moduleLldGpioExtender2 = { |
670 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
671 |
/* I²C address */ PCAL6524_LLD_I2C_ADDR_VDD,
|
672 |
}; |
673 |
|
674 |
AT42QT1050Driver moduleLldTouch = { |
675 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
676 |
/* I²C address */ AT42QT1050_LLD_I2C_ADDRSEL_LOW,
|
677 |
}; |
678 |
|
679 |
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) */ |
680 |
|
681 |
/** @} */
|
682 |
|
683 |
/*===========================================================================*/
|
684 |
/**
|
685 |
* @name Unit tests (UT)
|
686 |
* @{
|
687 |
*/
|
688 |
/*===========================================================================*/
|
689 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
690 |
#include <string.h> |
691 |
|
692 |
/*
|
693 |
* ADC
|
694 |
*/
|
695 |
static int _utShellCmdCb_Adc(BaseSequentialStream* stream, int argc, char* argv[]) |
696 |
{ |
697 |
(void)argc;
|
698 |
(void)argv;
|
699 |
aosUtRun(stream, &moduleUtAdcVsys, NULL);
|
700 |
return AOS_OK;
|
701 |
} |
702 |
static ut_adcdata_t _utAdcVsysData = {
|
703 |
/* driver */ &MODULE_HAL_ADC_VSYS,
|
704 |
/* ADC conversion group */ &moduleHalAdcVsysConversionGroup,
|
705 |
}; |
706 |
aos_unittest_t moduleUtAdcVsys = { |
707 |
/* name */ "ADC", |
708 |
/* info */ "VSYS", |
709 |
/* test function */ utAdcFunc,
|
710 |
/* shell command */ {
|
711 |
/* name */ "unittest:ADC", |
712 |
/* callback */ _utShellCmdCb_Adc,
|
713 |
/* next */ NULL, |
714 |
}, |
715 |
/* data */ &_utAdcVsysData,
|
716 |
}; |
717 |
|
718 |
/*
|
719 |
* AT24C01B (EEPROM)
|
720 |
*/
|
721 |
static int _utShellCmdCb_AlldAt24c01b(BaseSequentialStream* stream, int argc, char* argv[]) |
722 |
{ |
723 |
(void)argc;
|
724 |
(void)argv;
|
725 |
aosUtRun(stream, &moduleUtAlldAt24c01b, NULL);
|
726 |
return AOS_OK;
|
727 |
} |
728 |
static ut_at24c01bdata_t _utAlldAt24c01bData = {
|
729 |
/* driver */ &moduleLldEeprom,
|
730 |
/* timeout */ MICROSECONDS_PER_SECOND,
|
731 |
}; |
732 |
aos_unittest_t moduleUtAlldAt24c01b = { |
733 |
/* name */ "AT24C01B", |
734 |
/* info */ "1kbit EEPROM", |
735 |
/* test function */ utAlldAt24c01bFunc,
|
736 |
/* shell command */ {
|
737 |
/* name */ "unittest:EEPROM", |
738 |
/* callback */ _utShellCmdCb_AlldAt24c01b,
|
739 |
/* next */ NULL, |
740 |
}, |
741 |
/* data */ &_utAlldAt24c01bData,
|
742 |
}; |
743 |
|
744 |
/*
|
745 |
* bq24103a (battery charger)
|
746 |
*/
|
747 |
static int _utShellCmdCb_AlldBq24103a(BaseSequentialStream* stream, int argc, char* argv[]) |
748 |
{ |
749 |
// local variables
|
750 |
bool print_help = false; |
751 |
|
752 |
// evaluate argument
|
753 |
if (argc == 2) { |
754 |
if (strcmp(argv[1], "-f") == 0 || strcmp(argv[1], "--front") == 0) { |
755 |
moduleUtAlldBq24103a.data = &moduleLldBatteryChargerFront; |
756 |
aosUtRun(stream, &moduleUtAlldBq24103a, "front battery");
|
757 |
moduleUtAlldBq24103a.data = NULL;
|
758 |
} |
759 |
else if (strcmp(argv[1], "-r") == 0 || strcmp(argv[1], "--rear") == 0) { |
760 |
moduleUtAlldBq24103a.data = &moduleLldBatteryChargerRear; |
761 |
aosUtRun(stream, &moduleUtAlldBq24103a, "rear battery");
|
762 |
moduleUtAlldBq24103a.data = NULL;
|
763 |
} |
764 |
else {
|
765 |
print_help = true;
|
766 |
} |
767 |
} else {
|
768 |
print_help = true;
|
769 |
} |
770 |
|
771 |
// print help or just return
|
772 |
if (print_help) {
|
773 |
chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
774 |
chprintf(stream, "Options:\n");
|
775 |
chprintf(stream, " --front, -f\n");
|
776 |
chprintf(stream, " Test the front battery charger.\n");
|
777 |
chprintf(stream, " --rear, -r\n");
|
778 |
chprintf(stream, " Test the rear battery charger.\n");
|
779 |
return AOS_INVALIDARGUMENTS;
|
780 |
} else {
|
781 |
return AOS_OK;
|
782 |
} |
783 |
} |
784 |
aos_unittest_t moduleUtAlldBq24103a = { |
785 |
/* name */ "bq24103a", |
786 |
/* info */ "battery charger", |
787 |
/* test function */ utAlldBq241xxFunc,
|
788 |
/* shell command */ {
|
789 |
/* name */ "unittest:BatteryCharger", |
790 |
/* callback */ _utShellCmdCb_AlldBq24103a,
|
791 |
/* next */ NULL, |
792 |
}, |
793 |
/* data */ NULL, |
794 |
}; |
795 |
|
796 |
/*
|
797 |
* bq27500 (fuel gauge)
|
798 |
*/
|
799 |
static int _utShellCmdCb_AlldBq27500(BaseSequentialStream* stream, int argc, char* argv[]) |
800 |
{ |
801 |
// evaluate arguments
|
802 |
if (argc == 2) { |
803 |
if (strcmp(argv[1], "-f") == 0 || strcmp(argv[1], "--front") == 0) { |
804 |
((ut_bq27500data_t*)moduleUtAlldBq27500.data)->driver = &moduleLldFuelGaugeFront; |
805 |
aosUtRun(stream, &moduleUtAlldBq27500, "front battery");
|
806 |
((ut_bq27500data_t*)moduleUtAlldBq27500.data)->driver = NULL;
|
807 |
return AOS_OK;
|
808 |
} |
809 |
else if (strcmp(argv[1], "-r") == 0 || strcmp(argv[1], "--rear") == 0) { |
810 |
((ut_bq27500data_t*)moduleUtAlldBq27500.data)->driver = &moduleLldFuelGaugeRear; |
811 |
aosUtRun(stream, &moduleUtAlldBq27500, "rear battery");
|
812 |
((ut_bq27500data_t*)moduleUtAlldBq27500.data)->driver = NULL;
|
813 |
return AOS_OK;
|
814 |
} |
815 |
} |
816 |
// print help
|
817 |
chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
818 |
chprintf(stream, "Options:\n");
|
819 |
chprintf(stream, " --front, -f\n");
|
820 |
chprintf(stream, " Test the front battery fuel gauge.\n");
|
821 |
chprintf(stream, " --rear, -r\n");
|
822 |
chprintf(stream, " Test the rear battery fuel gauge.\n");
|
823 |
return AOS_INVALIDARGUMENTS;
|
824 |
} |
825 |
static ut_bq27500data_t _utAlldBq27500Data = {
|
826 |
/* driver */ NULL, |
827 |
/* timeout */ MICROSECONDS_PER_SECOND,
|
828 |
}; |
829 |
aos_unittest_t moduleUtAlldBq27500 = { |
830 |
/* name */ "bq27500", |
831 |
/* info */ "fuel gauge", |
832 |
/* test function */ utAlldBq27500Func,
|
833 |
/* shell command */ {
|
834 |
/* name */ "unittest:FuelGauge", |
835 |
/* callback */ _utShellCmdCb_AlldBq27500,
|
836 |
/* next */ NULL, |
837 |
}, |
838 |
/* data */ &_utAlldBq27500Data,
|
839 |
}; |
840 |
|
841 |
/*
|
842 |
* bq27500 (fuel gauge) in combination with bq24103a (battery charger)
|
843 |
*/
|
844 |
static int _utShellCmdCb_AlldBq27500Bq24103a(BaseSequentialStream* stream, int argc, char* argv[]) |
845 |
{ |
846 |
// evaluate arguments
|
847 |
if (argc == 2) { |
848 |
if (strcmp(argv[1], "-f") == 0 || strcmp(argv[1], "--front") == 0) { |
849 |
((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq27500 = &moduleLldFuelGaugeFront; |
850 |
((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq241xx = &moduleLldBatteryChargerFront; |
851 |
aosUtRun(stream, &moduleUtAlldBq27500Bq24103a, "front battery");
|
852 |
((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq27500 = NULL;
|
853 |
((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq241xx = NULL;
|
854 |
return AOS_OK;
|
855 |
} |
856 |
else if (strcmp(argv[1], "-r") == 0 || strcmp(argv[1], "--rear") == 0) { |
857 |
((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq27500 = &moduleLldFuelGaugeRear; |
858 |
((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq241xx = &moduleLldBatteryChargerRear; |
859 |
aosUtRun(stream, &moduleUtAlldBq27500Bq24103a, "rear battery");
|
860 |
((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq27500 = NULL;
|
861 |
((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq241xx = NULL;
|
862 |
return AOS_OK;
|
863 |
} |
864 |
} |
865 |
// print help
|
866 |
chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
867 |
chprintf(stream, "Options:\n");
|
868 |
chprintf(stream, " --front, -f\n");
|
869 |
chprintf(stream, " Test the front battery fuel gauge and charger.\n");
|
870 |
chprintf(stream, " --rear, -r\n");
|
871 |
chprintf(stream, " Test the rear battery fuel gauge and charger.\n");
|
872 |
return AOS_INVALIDARGUMENTS;
|
873 |
} |
874 |
static ut_bq27500bq241xxdata_t _utAlldBq27500Bq24103aData= {
|
875 |
/* bq27500 driver */ NULL, |
876 |
/* bq24103a driver */ NULL, |
877 |
/* timeout */ MICROSECONDS_PER_SECOND,
|
878 |
}; |
879 |
aos_unittest_t moduleUtAlldBq27500Bq24103a = { |
880 |
/* name */ "BQ27500 & BQ24103A", |
881 |
/* info */ "fuel gauge & battery charger", |
882 |
/* test function */ utAlldBq27500Bq241xxFunc,
|
883 |
/* shell command */ {
|
884 |
/* name */ "unittest:FuelGauge&BatteryCharger", |
885 |
/* callback */ _utShellCmdCb_AlldBq27500Bq24103a,
|
886 |
/* next */ NULL, |
887 |
}, |
888 |
/* data */ &_utAlldBq27500Bq24103aData,
|
889 |
}; |
890 |
|
891 |
/*
|
892 |
* INA219 (power monitor)
|
893 |
*/
|
894 |
static int _utShellCmdCb_AlldIna219(BaseSequentialStream* stream, int argc, char* argv[]) |
895 |
{ |
896 |
// evaluate arguments
|
897 |
if (argc == 2) { |
898 |
if (strcmp(argv[1], "VDD") == 0) { |
899 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVdd; |
900 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 3.3f; |
901 |
aosUtRun(stream, &moduleUtAlldIna219, "VDD (3.3V)");
|
902 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL;
|
903 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f; |
904 |
return AOS_OK;
|
905 |
} |
906 |
else if (strcmp(argv[1], "VIO1.8") == 0) { |
907 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVio18; |
908 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 1.8f; |
909 |
aosUtRun(stream, &moduleUtAlldIna219, "VIO (1.8V)");
|
910 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL;
|
911 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f; |
912 |
return AOS_OK;
|
913 |
} |
914 |
else if (strcmp(argv[1], "VIO3.3") == 0) { |
915 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVio33; |
916 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 3.3f; |
917 |
aosUtRun(stream, &moduleUtAlldIna219, "VIO (3.3V)");
|
918 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL;
|
919 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f; |
920 |
return AOS_OK;
|
921 |
} |
922 |
else if (strcmp(argv[1], "VSYS4.2") == 0) { |
923 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVsys42; |
924 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 4.2f; |
925 |
aosUtRun(stream, &moduleUtAlldIna219, "VSYS (4.2V)");
|
926 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL;
|
927 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f; |
928 |
return AOS_OK;
|
929 |
} |
930 |
else if (strcmp(argv[1], "VIO5.0") == 0) { |
931 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVio50; |
932 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 5.0f; |
933 |
aosUtRun(stream, &moduleUtAlldIna219, "VIO (5.0V)");
|
934 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL;
|
935 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f; |
936 |
return AOS_OK;
|
937 |
} |
938 |
} |
939 |
// print help
|
940 |
chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
941 |
chprintf(stream, "Options:\n");
|
942 |
chprintf(stream, " VDD\n");
|
943 |
chprintf(stream, " Test VDD (3.3V) power monitor.\n");
|
944 |
chprintf(stream, " VIO1.8\n");
|
945 |
chprintf(stream, " Test VIO 1.8V power monitor.\n");
|
946 |
chprintf(stream, " VIO3.3\n");
|
947 |
chprintf(stream, " Test VIO 3.3V power monitor.\n");
|
948 |
chprintf(stream, " VSYS4.2\n");
|
949 |
chprintf(stream, " Test VSYS 4.2V power monitor.\n");
|
950 |
chprintf(stream, " VIO5.0\n");
|
951 |
chprintf(stream, " Test VIO 5.0V power monitor.\n");
|
952 |
return AOS_INVALIDARGUMENTS;
|
953 |
} |
954 |
static ut_ina219data_t _utAlldIna219Data = {
|
955 |
/* driver */ NULL, |
956 |
/* expected voltage */ 0.0f, |
957 |
/* tolerance */ 0.05f, |
958 |
/* timeout */ MICROSECONDS_PER_SECOND,
|
959 |
}; |
960 |
aos_unittest_t moduleUtAlldIna219 = { |
961 |
/* name */ "INA219", |
962 |
/* info */ "power monitor", |
963 |
/* test function */ utAlldIna219Func,
|
964 |
/* shell command */ {
|
965 |
/* name */ "unittest:PowerMonitor", |
966 |
/* callback */ _utShellCmdCb_AlldIna219,
|
967 |
/* next */ NULL, |
968 |
}, |
969 |
/* data */ &_utAlldIna219Data,
|
970 |
}; |
971 |
|
972 |
/*
|
973 |
* Status LED
|
974 |
*/
|
975 |
static int _utShellCmdCb_AlldLed(BaseSequentialStream* stream, int argc, char* argv[]) |
976 |
{ |
977 |
(void)argc;
|
978 |
(void)argv;
|
979 |
aosUtRun(stream, &moduleUtAlldLed, NULL);
|
980 |
return AOS_OK;
|
981 |
} |
982 |
aos_unittest_t moduleUtAlldLed = { |
983 |
/* name */ "LED", |
984 |
/* info */ NULL, |
985 |
/* test function */ utAlldLedFunc,
|
986 |
/* shell command */ {
|
987 |
/* name */ "unittest:StatusLED", |
988 |
/* callback */ _utShellCmdCb_AlldLed,
|
989 |
/* next */ NULL, |
990 |
}, |
991 |
/* data */ &moduleLldStatusLed,
|
992 |
}; |
993 |
|
994 |
/*
|
995 |
* PKLCS1212E4001 (buzzer)
|
996 |
*/
|
997 |
static int _utShellCmdCb_AlldPklcs1212e4001(BaseSequentialStream* stream, int argc, char* argv[]) |
998 |
{ |
999 |
(void)argc;
|
1000 |
(void)argv;
|
1001 |
aosUtRun(stream, &moduleUtAlldPklcs1212e4001, NULL);
|
1002 |
return AOS_OK;
|
1003 |
} |
1004 |
static ut_pkxxxexxx_t _utAlldPklcs1212e4001Data = {
|
1005 |
/* PWM driver */ &MODULE_HAL_PWM_BUZZER,
|
1006 |
/* PWM channel */ MODULE_HAL_PWM_BUZZER_CHANNEL
|
1007 |
}; |
1008 |
aos_unittest_t moduleUtAlldPklcs1212e4001 = { |
1009 |
/* name */ "PKLCS1212E4001", |
1010 |
/* info */ "buzzer", |
1011 |
/* test function */ utAlldPkxxxexxxFunc,
|
1012 |
/* shell command */ {
|
1013 |
/* name */ "unittest:Buzzer", |
1014 |
/* callback */ _utShellCmdCb_AlldPklcs1212e4001,
|
1015 |
/* next */ NULL, |
1016 |
}, |
1017 |
/* data */ &_utAlldPklcs1212e4001Data,
|
1018 |
}; |
1019 |
|
1020 |
/*
|
1021 |
* TPS62113 (step-down converter)
|
1022 |
*/
|
1023 |
static int _utShellCmdCb_AlldTps62113(BaseSequentialStream* stream, int argc, char* argv[]) |
1024 |
{ |
1025 |
// Although there are four TPS62113 on the PCB, they all share the same input signal.
|
1026 |
// A sa result, no additional shell arguments need to be evaluated.
|
1027 |
(void)argc;
|
1028 |
(void)argv;
|
1029 |
aosUtRun(stream, &moduleUtAlldTps62113, NULL);
|
1030 |
return AOS_OK;
|
1031 |
} |
1032 |
aos_unittest_t moduleUtAlldTps62113 = { |
1033 |
/* name */ "TPS62113", |
1034 |
/* info */ "step-down converter", |
1035 |
/* test function */ utAlldTps6211xFunc,
|
1036 |
/* shell command */ {
|
1037 |
/* name */ "unittest:StepDownConverter", |
1038 |
/* callback */ _utShellCmdCb_AlldTps62113,
|
1039 |
/* next */ NULL, |
1040 |
}, |
1041 |
/* data */ &moduleLldStepDownConverter,
|
1042 |
}; |
1043 |
|
1044 |
/*
|
1045 |
* TPS62113 (step-donw converter) in combination with INA219 (power monitor)
|
1046 |
*/
|
1047 |
static int _utShellCmdCb_AlldTps62113Ina219(BaseSequentialStream* stream, int argc, char* argv[]) |
1048 |
{ |
1049 |
(void)argc;
|
1050 |
(void)argv;
|
1051 |
aosUtRun(stream, &moduleUtAlldTps62113Ina219, "VSYS (4.2V)");
|
1052 |
return AOS_OK;
|
1053 |
} |
1054 |
static ut_tps6211xina219data_t _utAlldTps62113Ina219Data = {
|
1055 |
/* TPS62113 */ &moduleLldStepDownConverter,
|
1056 |
/* INA219 */ &moduleLldPowerMonitorVsys42,
|
1057 |
/* timeout */ MICROSECONDS_PER_SECOND,
|
1058 |
}; |
1059 |
aos_unittest_t moduleUtAlldTps62113Ina219 = { |
1060 |
/* name */ "TPS62113 & INA219", |
1061 |
/* info */ "step-down converter & power monitor", |
1062 |
/* test function */ utAlldTps6211xIna219Func,
|
1063 |
/* shell command */ {
|
1064 |
/* name */ "unittest:StepDownConverter&PowerMonitor", |
1065 |
/* callback */ _utShellCmdCb_AlldTps62113Ina219,
|
1066 |
/* next */ NULL, |
1067 |
}, |
1068 |
/* data */ &_utAlldTps62113Ina219Data,
|
1069 |
}; |
1070 |
|
1071 |
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) || defined(__DOXYGEN__)
|
1072 |
|
1073 |
/*
|
1074 |
* MPR121 (touch sensor)
|
1075 |
*/
|
1076 |
static int _utShellCmdCb_AlldMpr121(BaseSequentialStream* stream, int argc, char* argv[]) |
1077 |
{ |
1078 |
(void)argc;
|
1079 |
(void)argv;
|
1080 |
aosUtRun(stream, &moduleUtAlldMpr121, NULL);
|
1081 |
return AOS_OK;
|
1082 |
} |
1083 |
static ut_mpr121data_t _utAlldMpr121Data= {
|
1084 |
/* MPR121 driver */ &moduleLldTouch,
|
1085 |
/* timeout */ MICROSECONDS_PER_SECOND,
|
1086 |
/* event source */ &aos.events.io,
|
1087 |
/* event flags */ MODULE_OS_IOEVENTFLAGS_TOUCHINT,
|
1088 |
}; |
1089 |
aos_unittest_t moduleUtAlldMpr121 = { |
1090 |
/* name */ "MPR121", |
1091 |
/* info */ "touch sensor", |
1092 |
/* test function */ utAlldMpr121Func,
|
1093 |
/* shell command */ {
|
1094 |
/* name */ "unittest:Touch", |
1095 |
/* callback */ _utShellCmdCb_AlldMpr121,
|
1096 |
/* next */ NULL, |
1097 |
}, |
1098 |
/* data */ &_utAlldMpr121Data,
|
1099 |
}; |
1100 |
|
1101 |
/*
|
1102 |
* PCA9544A (I2C multiplexer)
|
1103 |
*/
|
1104 |
static int _utShellCmdCb_AlldPca5944a(BaseSequentialStream* stream, int argc, char* argv[]) |
1105 |
{ |
1106 |
// evaluate arguments
|
1107 |
if (argc == 2) { |
1108 |
if (strcmp(argv[1], "#1") == 0) { |
1109 |
((ut_pca9544adata_t*)moduleUtAlldPca9544a.data)->driver = &moduleLldI2cMultiplexer1; |
1110 |
aosUtRun(stream, &moduleUtAlldPca9544a, "I2C bus #1");
|
1111 |
((ut_pca9544adata_t*)moduleUtAlldPca9544a.data)->driver = NULL;
|
1112 |
return AOS_OK;
|
1113 |
} |
1114 |
else if (strcmp(argv[1], "#2") == 0) { |
1115 |
((ut_pca9544adata_t*)moduleUtAlldPca9544a.data)->driver = &moduleLldI2cMultiplexer2; |
1116 |
aosUtRun(stream, &moduleUtAlldPca9544a, "I2C bus #2");
|
1117 |
((ut_pca9544adata_t*)moduleUtAlldPca9544a.data)->driver = NULL;
|
1118 |
return AOS_OK;
|
1119 |
} |
1120 |
} |
1121 |
// print help
|
1122 |
chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
1123 |
chprintf(stream, "Options:\n");
|
1124 |
chprintf(stream, " #1\n");
|
1125 |
chprintf(stream, " Test the multiplexer on the I2C bus #1.\n");
|
1126 |
chprintf(stream, " #2\n");
|
1127 |
chprintf(stream, " Test the multiplexer on the I2C bus #2.\n");
|
1128 |
return AOS_INVALIDARGUMENTS;
|
1129 |
} |
1130 |
static ut_pca9544adata_t _utAlldPca9544aData = {
|
1131 |
/* driver */ NULL, |
1132 |
/* timeout */ MICROSECONDS_PER_SECOND,
|
1133 |
}; |
1134 |
aos_unittest_t moduleUtAlldPca9544a = { |
1135 |
/* name */ "PCA9544A", |
1136 |
/* info */ "I2C multiplexer", |
1137 |
/* test function */ utAlldPca9544aFunc,
|
1138 |
/* shell command */ {
|
1139 |
/* name */ "unittest:I2CMultiplexer", |
1140 |
/* callback */ _utShellCmdCb_AlldPca5944a,
|
1141 |
/* next */ NULL, |
1142 |
}, |
1143 |
/* data */ &_utAlldPca9544aData,
|
1144 |
}; |
1145 |
|
1146 |
/*
|
1147 |
* VCNL4020 (proximity sensor)
|
1148 |
*/
|
1149 |
static void _utAlldVcnl4020_disableInterrupt(VCNL4020Driver* vcnl) |
1150 |
{ |
1151 |
uint8_t intstatus; |
1152 |
vcnl4020_lld_writereg(vcnl, VCNL4020_LLD_REGADDR_INTCTRL, 0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
|
1153 |
vcnl4020_lld_readreg(vcnl, VCNL4020_LLD_REGADDR_INTSTATUS, &intstatus, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
1154 |
if (intstatus) {
|
1155 |
vcnl4020_lld_writereg(vcnl, VCNL4020_LLD_REGADDR_INTSTATUS, intstatus, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
1156 |
} |
1157 |
return;
|
1158 |
} |
1159 |
static int _utShellCmdCb_AlldVcnl4020(BaseSequentialStream* stream, int argc, char* argv[]) |
1160 |
{ |
1161 |
enum {
|
1162 |
UNKNOWN, |
1163 |
NNE, ENE, ESE, SSE, SSW,WSW,WNW, NNW, |
1164 |
} sensor = UNKNOWN; |
1165 |
// evaluate arguments
|
1166 |
if (argc == 2) { |
1167 |
if (strcmp(argv[1], "-nne") == 0) { |
1168 |
sensor = NNE; |
1169 |
} else if (strcmp(argv[1], "-ene") == 0) { |
1170 |
sensor = ENE; |
1171 |
} else if (strcmp(argv[1], "-ese") == 0) { |
1172 |
sensor = ESE; |
1173 |
} else if (strcmp(argv[1], "-sse") == 0) { |
1174 |
sensor = SSE; |
1175 |
} else if (strcmp(argv[1], "-ssw") == 0) { |
1176 |
sensor = SSW; |
1177 |
} else if (strcmp(argv[1], "-wsw") == 0) { |
1178 |
sensor = WSW; |
1179 |
} else if (strcmp(argv[1], "-wnw") == 0) { |
1180 |
sensor = WNW; |
1181 |
} else if (strcmp(argv[1], "-nnw") == 0) { |
1182 |
sensor = NNW; |
1183 |
} |
1184 |
} |
1185 |
if (sensor != UNKNOWN) {
|
1186 |
PCA9544ADriver* mux = NULL;
|
1187 |
switch (sensor) {
|
1188 |
case SSE:
|
1189 |
case SSW:
|
1190 |
case WSW:
|
1191 |
case WNW:
|
1192 |
mux = &moduleLldI2cMultiplexer1; |
1193 |
((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld = &moduleLldProximity1; |
1194 |
((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT2; |
1195 |
break;
|
1196 |
case NNW:
|
1197 |
case NNE:
|
1198 |
case ENE:
|
1199 |
case ESE:
|
1200 |
mux = &moduleLldI2cMultiplexer2; |
1201 |
((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld = &moduleLldProximity2; |
1202 |
((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT1; |
1203 |
break;
|
1204 |
default:
|
1205 |
break;
|
1206 |
} |
1207 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
1208 |
_utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld); |
1209 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH1, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
1210 |
_utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld); |
1211 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH2, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
1212 |
_utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld); |
1213 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH3, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
1214 |
_utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld); |
1215 |
switch (sensor) {
|
1216 |
case NNE:
|
1217 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH1, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
1218 |
aosUtRun(stream, &moduleUtAlldVcnl4020, "north-northeast sensor");
|
1219 |
break;
|
1220 |
case ENE:
|
1221 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH3, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
1222 |
aosUtRun(stream, &moduleUtAlldVcnl4020, "east-northeast sensor");
|
1223 |
break;
|
1224 |
case ESE:
|
1225 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH2, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
1226 |
aosUtRun(stream, &moduleUtAlldVcnl4020, "north-southeast sensor");
|
1227 |
break;
|
1228 |
case SSE:
|
1229 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
1230 |
aosUtRun(stream, &moduleUtAlldVcnl4020, "south-southeast sensor");
|
1231 |
break;
|
1232 |
case SSW:
|
1233 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH1, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
1234 |
aosUtRun(stream, &moduleUtAlldVcnl4020, "south-southwest sensor");
|
1235 |
break;
|
1236 |
case WSW:
|
1237 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH3, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
1238 |
aosUtRun(stream, &moduleUtAlldVcnl4020, "west-southwest sensor");
|
1239 |
break;
|
1240 |
case WNW:
|
1241 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH2, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
1242 |
aosUtRun(stream, &moduleUtAlldVcnl4020, "west-northwest sensor");
|
1243 |
break;
|
1244 |
case NNW:
|
1245 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
1246 |
aosUtRun(stream, &moduleUtAlldVcnl4020, "north-northwest sensor");
|
1247 |
break;
|
1248 |
default:
|
1249 |
break;
|
1250 |
} |
1251 |
((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld = NULL;
|
1252 |
((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->evtflags = 0;
|
1253 |
return AOS_OK;
|
1254 |
} |
1255 |
// print help
|
1256 |
chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
1257 |
chprintf(stream, "Options:\n");
|
1258 |
chprintf(stream, " -nne\n");
|
1259 |
chprintf(stream, " Test north-northeast sensor.\n");
|
1260 |
chprintf(stream, " -ene\n");
|
1261 |
chprintf(stream, " Test east-northeast sensor.\n");
|
1262 |
chprintf(stream, " -ese\n");
|
1263 |
chprintf(stream, " Test east-southeast sensor.\n");
|
1264 |
chprintf(stream, " -sse\n");
|
1265 |
chprintf(stream, " Test south-southeast sensor.\n");
|
1266 |
chprintf(stream, " -ssw\n");
|
1267 |
chprintf(stream, " Test south-southwest sensor.\n");
|
1268 |
chprintf(stream, " -wsw\n");
|
1269 |
chprintf(stream, " Test west-southwest sensor.\n");
|
1270 |
chprintf(stream, " -wnw\n");
|
1271 |
chprintf(stream, " Test west-northwest sensor.\n");
|
1272 |
chprintf(stream, " -nnw\n");
|
1273 |
chprintf(stream, " Test north-northwest sensor.\n");
|
1274 |
return AOS_INVALIDARGUMENTS;
|
1275 |
} |
1276 |
static ut_vcnl4020data_t _utAlldVcnl4020Data = {
|
1277 |
/* driver */ NULL, |
1278 |
/* timeout */ MICROSECONDS_PER_SECOND,
|
1279 |
/* event source */ &aos.events.io,
|
1280 |
/* event flags */ 0, |
1281 |
}; |
1282 |
aos_unittest_t moduleUtAlldVcnl4020 = { |
1283 |
/* name */ "VCNL4020", |
1284 |
/* info */ "proximity sensor", |
1285 |
/* test function */ utAlldVcnl4020Func,
|
1286 |
/* shell command */ {
|
1287 |
/* name */ "unittest:Proximity", |
1288 |
/* callback */ _utShellCmdCb_AlldVcnl4020,
|
1289 |
/* next */ NULL, |
1290 |
}, |
1291 |
/* data */ &_utAlldVcnl4020Data,
|
1292 |
}; |
1293 |
|
1294 |
#endif /* (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) */ |
1295 |
|
1296 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) || defined(__DOXYGEN__)
|
1297 |
|
1298 |
/*
|
1299 |
* PCAL6524 (GPIO extender)
|
1300 |
*/
|
1301 |
static int _utShellCmdCb_AlldPcal6524(BaseSequentialStream* stream, int argc, char* argv[]) |
1302 |
{ |
1303 |
// evaluate arguments
|
1304 |
if (argc == 2) { |
1305 |
if (strcmp(argv[1], "#1") == 0) { |
1306 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = &moduleLldGpioExtender1; |
1307 |
aosUtRun(stream, &moduleUtAlldPcal6524, "I2C bus #1");
|
1308 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = NULL;
|
1309 |
return AOS_OK;
|
1310 |
} |
1311 |
else if (strcmp(argv[1], "#2") == 0) { |
1312 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = &moduleLldGpioExtender2; |
1313 |
aosUtRun(stream, &moduleUtAlldPcal6524, "I2C bus #2");
|
1314 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = NULL;
|
1315 |
return AOS_OK;
|
1316 |
} |
1317 |
} |
1318 |
// print help
|
1319 |
chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
1320 |
chprintf(stream, "Options:\n");
|
1321 |
chprintf(stream, " #1\n");
|
1322 |
chprintf(stream, " Test the GPIO extender on the I2C bus #1.\n");
|
1323 |
chprintf(stream, " #2\n");
|
1324 |
chprintf(stream, " Test the GPIO extender on the I2C bus #2.\n");
|
1325 |
return AOS_INVALIDARGUMENTS;
|
1326 |
} |
1327 |
static ut_pcal6524data_t _utAlldPcal6524Data = {
|
1328 |
/* driver */ NULL, |
1329 |
/* timeout */ MICROSECONDS_PER_SECOND,
|
1330 |
}; |
1331 |
aos_unittest_t moduleUtAlldPcal6524 = { |
1332 |
/* name */ "PCAL6524", |
1333 |
/* info */ "GPIO extender", |
1334 |
/* test function */ utAlldPcal6524Func,
|
1335 |
/* shell command */ {
|
1336 |
/* name */ "unittest:GPIOExtender", |
1337 |
/* callback */ _utShellCmdCb_AlldPcal6524,
|
1338 |
/* next */ NULL, |
1339 |
}, |
1340 |
/* data */ &_utAlldPcal6524Data,
|
1341 |
}; |
1342 |
|
1343 |
/*
|
1344 |
* AT42QT1050 (touch sensor)
|
1345 |
*/
|
1346 |
static int _utShellCmdCb_AlldAt42qt1050(BaseSequentialStream* stream, int argc, char* argv[]) |
1347 |
{ |
1348 |
(void)argc;
|
1349 |
(void)argv;
|
1350 |
aosUtRun(stream, &moduleUtAlldAt42qt1050, NULL);
|
1351 |
return AOS_OK;
|
1352 |
} |
1353 |
static ut_at42qt1050data_t _utAlldAt42qt1050Data= {
|
1354 |
/* AT42QT1050 driver */ &moduleLldTouch,
|
1355 |
/* timeout */ MICROSECONDS_PER_SECOND,
|
1356 |
/* event source */ &aos.events.io,
|
1357 |
/* event flags */ MODULE_OS_IOEVENTFLAGS_TOUCHINT,
|
1358 |
}; |
1359 |
aos_unittest_t moduleUtAlldAt42qt1050 = { |
1360 |
/* name */ "AT42QT1050", |
1361 |
/* info */ "touch sensor", |
1362 |
/* test function */ utAlldAt42qt1050Func,
|
1363 |
/* shell command */ {
|
1364 |
/* name */ "unittest:Touch", |
1365 |
/* callback */ _utShellCmdCb_AlldAt42qt1050,
|
1366 |
/* next */ NULL, |
1367 |
}, |
1368 |
/* data */ &_utAlldAt42qt1050Data,
|
1369 |
}; |
1370 |
|
1371 |
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) */ |
1372 |
|
1373 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) || defined(__DOXYGEN__)
|
1374 |
|
1375 |
/*
|
1376 |
* PCAL6524 (GPIO extender)
|
1377 |
*/
|
1378 |
static int _utShellCmdCb_AlldPcal6524(BaseSequentialStream* stream, int argc, char* argv[]) |
1379 |
{ |
1380 |
// evaluate arguments
|
1381 |
if (argc == 2) { |
1382 |
if (strcmp(argv[1], "#1") == 0) { |
1383 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = &moduleLldGpioExtender1; |
1384 |
aosUtRun(stream, &moduleUtAlldPcal6524, "I2C bus #1");
|
1385 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = NULL;
|
1386 |
return AOS_OK;
|
1387 |
} |
1388 |
else if (strcmp(argv[1], "#2") == 0) { |
1389 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = &moduleLldGpioExtender2; |
1390 |
aosUtRun(stream, &moduleUtAlldPcal6524, "I2C bus #2");
|
1391 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = NULL;
|
1392 |
return AOS_OK;
|
1393 |
} |
1394 |
} |
1395 |
// print help
|
1396 |
chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
1397 |
chprintf(stream, "Options:\n");
|
1398 |
chprintf(stream, " #1\n");
|
1399 |
chprintf(stream, " Test the GPIO extender on the I2C bus #1.\n");
|
1400 |
chprintf(stream, " #2\n");
|
1401 |
chprintf(stream, " Test the GPIO extender on the I2C bus #2.\n");
|
1402 |
return AOS_INVALIDARGUMENTS;
|
1403 |
} |
1404 |
static ut_pcal6524data_t _utAlldPcal6524Data = {
|
1405 |
/* driver */ NULL, |
1406 |
/* timeout */ MICROSECONDS_PER_SECOND,
|
1407 |
}; |
1408 |
aos_unittest_t moduleUtAlldPcal6524 = { |
1409 |
/* name */ "PCAL6524", |
1410 |
/* info */ "GPIO extender", |
1411 |
/* test function */ utAlldPcal6524Func,
|
1412 |
/* shell command */ {
|
1413 |
/* name */ "unittest:GPIOExtender", |
1414 |
/* callback */ _utShellCmdCb_AlldPcal6524,
|
1415 |
/* next */ NULL, |
1416 |
}, |
1417 |
/* data */ &_utAlldPcal6524Data,
|
1418 |
}; |
1419 |
|
1420 |
/*
|
1421 |
* AT42QT1050 (touch sensor)
|
1422 |
*/
|
1423 |
static int _utShellCmdCb_AlldAt42qt1050(BaseSequentialStream* stream, int argc, char* argv[]) |
1424 |
{ |
1425 |
(void)argc;
|
1426 |
(void)argv;
|
1427 |
aosUtRun(stream, &moduleUtAlldAt42qt1050, NULL);
|
1428 |
return AOS_OK;
|
1429 |
} |
1430 |
static ut_at42qt1050data_t _utAlldAt42qt1050Data= {
|
1431 |
/* AT42QT1050 driver */ &moduleLldTouch,
|
1432 |
/* timeout */ MICROSECONDS_PER_SECOND,
|
1433 |
/* event source */ &aos.events.io,
|
1434 |
/* event flags */ MODULE_OS_IOEVENTFLAGS_TOUCHINT,
|
1435 |
}; |
1436 |
aos_unittest_t moduleUtAlldAt42qt1050 = { |
1437 |
/* name */ "AT42QT1050", |
1438 |
/* info */ "touch sensor", |
1439 |
/* test function */ utAlldAt42qt1050Func,
|
1440 |
/* shell command */ {
|
1441 |
/* name */ "unittest:Touch", |
1442 |
/* callback */ _utShellCmdCb_AlldAt42qt1050,
|
1443 |
/* next */ NULL, |
1444 |
}, |
1445 |
/* data */ &_utAlldAt42qt1050Data,
|
1446 |
}; |
1447 |
|
1448 |
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) */ |
1449 |
|
1450 |
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
1451 |
|
1452 |
/** @} */
|
1453 |
/** @} */
|