amiro-os / modules / PowerManagement_1-1 / module.c @ 232ccea6
History | View | Annotate | Download (32.944 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 */ APAL_GPIO_ACTIVE_LOW,
|
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 Tests
|
686 |
* @{
|
687 |
*/
|
688 |
/*===========================================================================*/
|
689 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
690 |
|
691 |
/*
|
692 |
* ADC (VSYS)
|
693 |
*/
|
694 |
#include <module_test_adc.h> |
695 |
static int _testAdcShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
696 |
{ |
697 |
return moduleTestAdcShellCb(stream, argc, argv, NULL); |
698 |
} |
699 |
AOS_SHELL_COMMAND(moduleTestAdcShellCmd, "test:ADC", _testAdcShellCmdCb);
|
700 |
|
701 |
/*
|
702 |
* AT24C01BN-SH-B (EEPROM)
|
703 |
*/
|
704 |
#include <module_test_AT24C01B.h> |
705 |
static int _testAt24c01bShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
706 |
{ |
707 |
return moduleTestAt24c01bShellCb(stream, argc, argv, NULL); |
708 |
} |
709 |
AOS_SHELL_COMMAND(moduleTestAt24c01bShellCmd, "test:EEPROM", _testAt24c01bShellCmdCb);
|
710 |
|
711 |
/*
|
712 |
* bq24103a (battery charger)
|
713 |
*/
|
714 |
#include <module_test_bq241xx.h> |
715 |
static int _testBq241xxShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
716 |
{ |
717 |
return moduleTestBq241xxShellCb(stream, argc, argv, NULL); |
718 |
} |
719 |
AOS_SHELL_COMMAND(moduleTestBq241xxShellCmd, "test:BatteryCharger", _testBq241xxShellCmdCb);
|
720 |
|
721 |
/*
|
722 |
* bq27500 (fuel gauge)
|
723 |
*/
|
724 |
#include <module_test_bq27500.h> |
725 |
static int _testBq27500ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
726 |
{ |
727 |
return moduleTestBq27500ShellCb(stream, argc, argv, NULL); |
728 |
} |
729 |
AOS_SHELL_COMMAND(moduleTestBq27500ShellCmd, "test:FuelGauge", _testBq27500ShellCmdCb);
|
730 |
|
731 |
/*
|
732 |
* bq27500 (fuel gauge) in combination with bq24103a (battery charger)
|
733 |
*/
|
734 |
#include <module_test_bq27500_bq241xx.h> |
735 |
static int _testBq27500Bq241xxShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
736 |
{ |
737 |
return moduleTestBq27500Bq241xxShellCb(stream, argc, argv, NULL); |
738 |
} |
739 |
AOS_SHELL_COMMAND(moduleTestBq27500Bq241xxShellCmd, "test:FuelGauge&BatteryCharger", _testBq27500Bq241xxShellCmdCb);
|
740 |
|
741 |
/*
|
742 |
* INA219 (power monitor)
|
743 |
*/
|
744 |
#include <module_test_INA219.h> |
745 |
static int _testIna219ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
746 |
{ |
747 |
return moduleTestIna219ShellCb(stream, argc, argv, NULL); |
748 |
} |
749 |
AOS_SHELL_COMMAND(moduleTestIna219ShellCmd, "test:PowerMonitor", _testIna219ShellCmdCb);
|
750 |
|
751 |
/*
|
752 |
* Status LED
|
753 |
*/
|
754 |
#include <module_test_LED.h> |
755 |
static int _testLedShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
756 |
{ |
757 |
return moduleTestLedShellCb(stream, argc, argv, NULL); |
758 |
} |
759 |
AOS_SHELL_COMMAND(moduleTestLedShellCmd, "test:StatusLED", _testLedShellCmdCb);
|
760 |
|
761 |
/*
|
762 |
* PKLCS1212E4001 (buzzer)
|
763 |
*/
|
764 |
#include <module_test_PKxxxExxx.h> |
765 |
static int _testPkxxxexxxShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
766 |
{ |
767 |
return moduleTestPkxxxexxxShellCb(stream, argc, argv, NULL); |
768 |
} |
769 |
AOS_SHELL_COMMAND(moduleTestPkxxxexxxShellCmd, "test:Buzzer", _testPkxxxexxxShellCmdCb);
|
770 |
|
771 |
/*
|
772 |
* TPS62113 (step-down converter)
|
773 |
*/
|
774 |
#include <module_test_TPS6211x.h> |
775 |
static int _testTps6211xShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
776 |
{ |
777 |
return moduleTestTps6211xShellCb(stream, argc, argv, NULL); |
778 |
} |
779 |
AOS_SHELL_COMMAND(moduleTestTps6211xShellCmd, "test:StepDownConverter", _testTps6211xShellCmdCb);
|
780 |
|
781 |
/*
|
782 |
* TPS62113 (step-sown converter) in combination with INA219 (power monitor)
|
783 |
*/
|
784 |
#include <module_test_TPS6211x_INA219.h> |
785 |
static int _testTps6211xIna219ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
786 |
{ |
787 |
return moduleTestTps6211xIna219ShellCb(stream, argc, argv, NULL); |
788 |
} |
789 |
AOS_SHELL_COMMAND(moduleTestTps6211xIna219ShellCmd, "test:StepDownConverter&PowerMonitor", _testTps6211xIna219ShellCmdCb);
|
790 |
|
791 |
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) || defined(__DOXYGEN__)
|
792 |
|
793 |
/*
|
794 |
* MPR121 (touch sensor)
|
795 |
*/
|
796 |
#include <module_test_MPR121.h> |
797 |
static int _testMpr121ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
798 |
{ |
799 |
return moduleTestMpr121ShellCb(stream, argc, argv, NULL); |
800 |
} |
801 |
AOS_SHELL_COMMAND(moduleTestMpr121ShellCmd, "test:Touch", _testMpr121ShellCmdCb);
|
802 |
|
803 |
/*
|
804 |
* PCA9544A (I2C multiplexer)
|
805 |
*/
|
806 |
#include <module_test_PCA9544A.h> |
807 |
static int _testPca9544aShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
808 |
{ |
809 |
return moduleTestPca9544aShellCb(stream, argc, argv, NULL); |
810 |
} |
811 |
AOS_SHELL_COMMAND(moduleTestPca9544aShellCmd, "test:I2CMultiplexer", _testPca9544aShellCmdCb);
|
812 |
|
813 |
/*
|
814 |
* VCNL4020 (proximity sensor)
|
815 |
*/
|
816 |
#include <module_test_VCNL4020.h> |
817 |
static int _testVcnl4020ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
818 |
{ |
819 |
return moduleTestVcnl4020ShellCb(stream, argc, argv, NULL); |
820 |
} |
821 |
AOS_SHELL_COMMAND(moduleTestVcnl4020ShellCmd, "test:Proximity", _testVcnl4020ShellCmdCb);
|
822 |
|
823 |
#endif /* (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) */ |
824 |
|
825 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) || defined(__DOXYGEN__)
|
826 |
|
827 |
/*
|
828 |
* PCAL6524 (GPIO extender)
|
829 |
*/
|
830 |
#include <module_test_PCAL6524.h> |
831 |
static int _testPcal6524ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
832 |
{ |
833 |
return moduleTestPcal6524ShellCb(stream, argc, argv, NULL); |
834 |
} |
835 |
AOS_SHELL_COMMAND(moduleTestPcal6524ShellCmd, "test:GPIOExtenter", _testPcal6524ShellCmdCb);
|
836 |
|
837 |
/*
|
838 |
* AT42QT1050 (touch sensor)
|
839 |
*/
|
840 |
#include <module_test_AT42QT1050.h> |
841 |
static int _testAt42qt1050ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
842 |
{ |
843 |
return moduleTestAt42qt1050ShellCb(stream, argc, argv, NULL); |
844 |
} |
845 |
AOS_SHELL_COMMAND(moduleTestAt42qt1050ShellCmd, "test:Touch", _testAt42qt1050ShellCmdCb);
|
846 |
|
847 |
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) */ |
848 |
|
849 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) || defined(__DOXYGEN__)
|
850 |
|
851 |
/*
|
852 |
* PCAL6524 (GPIO extender)
|
853 |
*/
|
854 |
#include <module_test_PCAL6524.h> |
855 |
static int _testPcal6524ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
856 |
{ |
857 |
return moduleTestPcal6524ShellCb(stream, argc, argv, NULL); |
858 |
} |
859 |
AOS_SHELL_COMMAND(moduleTestPcal6524ShellCmd, "test:GPIOExtenter", _testPcal6524ShellCmdCb);
|
860 |
|
861 |
/*
|
862 |
* AT42QT1050 (touch sensor)
|
863 |
*/
|
864 |
#include <module_test_AT42QT1050.h> |
865 |
static int _testAt42qt1050ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
866 |
{ |
867 |
return moduleTestAt42qt1050ShellCb(stream, argc, argv, NULL); |
868 |
} |
869 |
AOS_SHELL_COMMAND(moduleTestAt42qt1050ShellCmd, "test:Touch", _testAt42qt1050ShellCmdCb);
|
870 |
|
871 |
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) */ |
872 |
|
873 |
/*
|
874 |
* entire module
|
875 |
*/
|
876 |
static int _testAllShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
877 |
{ |
878 |
(void)argc;
|
879 |
(void)argv;
|
880 |
|
881 |
int status = AOS_OK;
|
882 |
char* targv[AMIROOS_CFG_SHELL_MAXARGS] = {NULL}; |
883 |
aos_testresult_t result_test = {0, 0}; |
884 |
aos_testresult_t result_total = {0, 0}; |
885 |
|
886 |
/* ADC */
|
887 |
status |= moduleTestAdcShellCb(stream, 0, targv, &result_test);
|
888 |
result_total = aosTestResultAdd(result_total, result_test); |
889 |
|
890 |
/* AT24C01BN-SH-B (EEPROM) */
|
891 |
status |= moduleTestAt24c01bShellCb(stream, 0, targv, &result_test);
|
892 |
result_total = aosTestResultAdd(result_total, result_test); |
893 |
|
894 |
/* bq24103a (battery charger) */
|
895 |
// front
|
896 |
targv[1] = "-f"; |
897 |
status |= moduleTestBq241xxShellCb(stream, 2, targv, &result_test);
|
898 |
result_total = aosTestResultAdd(result_total, result_test); |
899 |
// rear
|
900 |
targv[1] = "-r"; |
901 |
status |= moduleTestBq241xxShellCb(stream, 2, targv, &result_test);
|
902 |
result_total = aosTestResultAdd(result_total, result_test); |
903 |
targv[1] = ""; |
904 |
|
905 |
/* bq27500 (fuel gauge) */
|
906 |
// front
|
907 |
targv[1] = "-f"; |
908 |
status |= moduleTestBq27500ShellCb(stream, 2, targv, &result_test);
|
909 |
result_total = aosTestResultAdd(result_total, result_test); |
910 |
// rear
|
911 |
targv[1] = "-r"; |
912 |
status |= moduleTestBq27500ShellCb(stream, 2, targv, &result_test);
|
913 |
result_total = aosTestResultAdd(result_total, result_test); |
914 |
targv[1] = ""; |
915 |
|
916 |
/* bq 27500 (fuel gauge) in combination with bq24103a (battery charger) */
|
917 |
// front
|
918 |
targv[1] = "-f"; |
919 |
status |= moduleTestBq27500Bq241xxShellCb(stream, 2, targv, &result_test);
|
920 |
result_total = aosTestResultAdd(result_total, result_test); |
921 |
// rear
|
922 |
targv[1] = "-r"; |
923 |
status |= moduleTestBq27500Bq241xxShellCb(stream, 2, targv, &result_test);
|
924 |
result_total = aosTestResultAdd(result_total, result_test); |
925 |
targv[1] = ""; |
926 |
|
927 |
/* INA219 (power monitor) */
|
928 |
// VDD
|
929 |
targv[1] = "VDD"; |
930 |
status |= moduleTestIna219ShellCb(stream, 2, targv, &result_test);
|
931 |
result_total = aosTestResultAdd(result_total, result_test); |
932 |
// VIO 1.8V
|
933 |
targv[1] = "VIO1.8"; |
934 |
status |= moduleTestIna219ShellCb(stream, 2, targv, &result_test);
|
935 |
result_total = aosTestResultAdd(result_total, result_test); |
936 |
// VIO 3.3V
|
937 |
targv[1] = "VIO3.3"; |
938 |
status |= moduleTestIna219ShellCb(stream, 2, targv, &result_test);
|
939 |
result_total = aosTestResultAdd(result_total, result_test); |
940 |
// VSYS 4.2V
|
941 |
targv[1] = "VSYS4.2"; |
942 |
status |= moduleTestIna219ShellCb(stream, 2, targv, &result_test);
|
943 |
result_total = aosTestResultAdd(result_total, result_test); |
944 |
// VIO 5.0V
|
945 |
targv[1] = "VIO5.0"; |
946 |
status |= moduleTestIna219ShellCb(stream, 2, targv, &result_test);
|
947 |
result_total = aosTestResultAdd(result_total, result_test); |
948 |
targv[1] = ""; |
949 |
|
950 |
/* status LED */
|
951 |
status |= moduleTestLedShellCb(stream, 0, targv, &result_test);
|
952 |
result_total = aosTestResultAdd(result_total, result_test); |
953 |
|
954 |
/* PKLCS1212E4001 (buzzer) */
|
955 |
status |= moduleTestPkxxxexxxShellCb(stream, 0, targv, &result_test);
|
956 |
result_total = aosTestResultAdd(result_total, result_test); |
957 |
|
958 |
/* TPS62113 (step-down converter) */
|
959 |
status |= moduleTestTps6211xShellCb(stream, 0, targv, &result_test);
|
960 |
result_total = aosTestResultAdd(result_total, result_test); |
961 |
|
962 |
/* TPS62113 (step-down converter) in combination with INA219 (power monitor) */
|
963 |
status |= moduleTestTps6211xIna219ShellCb(stream, 0, targv, &result_test);
|
964 |
result_total = aosTestResultAdd(result_total, result_test); |
965 |
|
966 |
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR)
|
967 |
|
968 |
/* MPR121 (touch sensor) */
|
969 |
status |= moduleTestMpr121ShellCb(stream, 0, targv, &result_test);
|
970 |
result_total = aosTestResultAdd(result_total, result_test); |
971 |
|
972 |
/* PCA9544A (I2C multiplexer) */
|
973 |
// #1
|
974 |
targv[1] = "#1"; |
975 |
status |= moduleTestPca9544aShellCb(stream, 2, targv, &result_test);
|
976 |
result_total = aosTestResultAdd(result_total, result_test); |
977 |
// #2
|
978 |
targv[1] = "#2"; |
979 |
status |= moduleTestPca9544aShellCb(stream, 2, targv, &result_test);
|
980 |
result_total = aosTestResultAdd(result_total, result_test); |
981 |
targv[1] = ""; |
982 |
|
983 |
/* VCNL4020 (proximity sensor) */
|
984 |
// north-northeast
|
985 |
targv[1] = "-nne"; |
986 |
status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
|
987 |
result_total = aosTestResultAdd(result_total, result_test); |
988 |
// east-northeast
|
989 |
targv[1] = "-ene"; |
990 |
status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
|
991 |
result_total = aosTestResultAdd(result_total, result_test); |
992 |
// east-southeast
|
993 |
targv[1] = "-ese"; |
994 |
status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
|
995 |
result_total = aosTestResultAdd(result_total, result_test); |
996 |
// south-southeast
|
997 |
targv[1] = "-sse"; |
998 |
status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
|
999 |
result_total = aosTestResultAdd(result_total, result_test); |
1000 |
// south-southwest
|
1001 |
targv[1] = "-ssw"; |
1002 |
status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
|
1003 |
result_total = aosTestResultAdd(result_total, result_test); |
1004 |
// west-southwest
|
1005 |
targv[1] = "-wsw"; |
1006 |
status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
|
1007 |
result_total = aosTestResultAdd(result_total, result_test); |
1008 |
// west-northwest
|
1009 |
targv[1] = "-wnw"; |
1010 |
status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
|
1011 |
result_total = aosTestResultAdd(result_total, result_test); |
1012 |
// west-northwest
|
1013 |
targv[1] = "-nnw"; |
1014 |
status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
|
1015 |
result_total = aosTestResultAdd(result_total, result_test); |
1016 |
targv[1] = ""; |
1017 |
|
1018 |
#endif /* (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) */ |
1019 |
|
1020 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X)
|
1021 |
|
1022 |
/* PCAL6524 (GPIO extender) */
|
1023 |
// #1
|
1024 |
targv[1] = "#1"; |
1025 |
status |= moduleTestPcal6524ShellCb(stream, 2, targv, &result_test);
|
1026 |
result_total = aosTestResultAdd(result_total, result_test); |
1027 |
// #2
|
1028 |
targv[1] = "#2"; |
1029 |
status |= moduleTestPcal6524ShellCb(stream, 2, targv, &result_test);
|
1030 |
result_total = aosTestResultAdd(result_total, result_test); |
1031 |
targv[1] = ""; |
1032 |
|
1033 |
/* AT42QT1050 (touch sensor) */
|
1034 |
status |= moduleTestAt42qt1050ShellCb(stream, 2, targv, &result_test);
|
1035 |
result_total = aosTestResultAdd(result_total, result_test); |
1036 |
|
1037 |
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) */ |
1038 |
|
1039 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X)
|
1040 |
|
1041 |
/* PCAL6524 (GPIO extender) */
|
1042 |
// #1
|
1043 |
targv[1] = "#1"; |
1044 |
status |= moduleTestPcal6524ShellCb(stream, 2, targv, &result_test);
|
1045 |
result_total = aosTestResultAdd(result_total, result_test); |
1046 |
// #2
|
1047 |
targv[1] = "#2"; |
1048 |
status |= moduleTestPcal6524ShellCb(stream, 2, targv, &result_test);
|
1049 |
result_total = aosTestResultAdd(result_total, result_test); |
1050 |
targv[1] = ""; |
1051 |
|
1052 |
/* AT42QT1050 (touch sensor) */
|
1053 |
status |= moduleTestAt42qt1050ShellCb(stream, 2, targv, &result_test);
|
1054 |
result_total = aosTestResultAdd(result_total, result_test); |
1055 |
|
1056 |
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) */ |
1057 |
|
1058 |
// print total result
|
1059 |
chprintf(stream, "\n");
|
1060 |
aosTestResultPrintSummary(stream, &result_total, "entire module");
|
1061 |
|
1062 |
return status;
|
1063 |
} |
1064 |
AOS_SHELL_COMMAND(moduleTestAllShellCmd, "test:all", _testAllShellCmdCb);
|
1065 |
|
1066 |
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
1067 |
|
1068 |
/** @} */
|
1069 |
/** @} */
|