amiro-os / modules / PowerManagement_1-1 / module.c @ 10853947
History | View | Annotate | Download (34.725 KB)
1 |
/*
|
---|---|
2 |
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
|
3 |
Copyright (C) 2016..2020 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 <amiroos.h> |
28 |
|
29 |
#include <string.h> |
30 |
|
31 |
/*===========================================================================*/
|
32 |
/**
|
33 |
* @name Module specific functions
|
34 |
* @{
|
35 |
*/
|
36 |
/*===========================================================================*/
|
37 |
|
38 |
/** @} */
|
39 |
|
40 |
/*===========================================================================*/
|
41 |
/**
|
42 |
* @name ChibiOS/HAL configuration
|
43 |
* @{
|
44 |
*/
|
45 |
/*===========================================================================*/
|
46 |
|
47 |
ADCConversionGroup moduleHalAdcVsysConversionGroup = { |
48 |
/* buffer type */ true, |
49 |
/* number of channels */ 1, |
50 |
/* callback function */ NULL, |
51 |
/* error callback */ NULL, |
52 |
/* CR1 */ ADC_CR1_AWDEN | ADC_CR1_AWDIE,
|
53 |
/* CR2 */ ADC_CR2_SWSTART | ADC_CR2_CONT,
|
54 |
/* SMPR1 */ 0, |
55 |
/* SMPR2 */ ADC_SMPR2_SMP_AN9(ADC_SAMPLE_480),
|
56 |
/* HTR */ ADC_HTR_HT,
|
57 |
/* LTR */ 0, |
58 |
/* SQR1 */ ADC_SQR1_NUM_CH(1), |
59 |
/* SQR2 */ 0, |
60 |
/* SQR3 */ ADC_SQR3_SQ1_N(ADC_CHANNEL_IN9),
|
61 |
}; |
62 |
|
63 |
CANConfig moduleHalCanConfig = { |
64 |
/* mcr */ CAN_MCR_ABOM | CAN_MCR_AWUM | CAN_MCR_TXFP,
|
65 |
/* btr */ CAN_BTR_SJW(1) | CAN_BTR_TS2(3) | CAN_BTR_TS1(15) | CAN_BTR_BRP(1), |
66 |
}; |
67 |
|
68 |
I2CConfig moduleHalI2cSrPm18Pm33GaugeRearConfig = { |
69 |
/* I²C mode */ OPMODE_I2C,
|
70 |
/* frequency */ 400000, // TODO: replace with some macro (-> ChibiOS/HAL) |
71 |
/* duty cycle */ FAST_DUTY_CYCLE_2,
|
72 |
}; |
73 |
|
74 |
I2CConfig moduleHalI2cSrPm42Pm50PmVddEepromGaugeFrontConfig = { |
75 |
/* I²C mode */ OPMODE_I2C,
|
76 |
/* frequency */ 400000, // TODO: replace with some macro (-> ChibiOS/HAL) |
77 |
/* duty cycle */ FAST_DUTY_CYCLE_2,
|
78 |
}; |
79 |
|
80 |
PWMConfig moduleHalPwmBuzzerConfig = { |
81 |
/* frequency */ 1000000, |
82 |
/* period */ 0, |
83 |
/* callback */ NULL, |
84 |
/* channel configurations */ {
|
85 |
/* channel 0 */ {
|
86 |
/* mode */ PWM_OUTPUT_DISABLED,
|
87 |
/* callback */ NULL |
88 |
}, |
89 |
/* channel 1 */ {
|
90 |
/* mode */ PWM_OUTPUT_ACTIVE_HIGH,
|
91 |
/* callback */ NULL |
92 |
}, |
93 |
/* channel 2 */ {
|
94 |
/* mode */ PWM_OUTPUT_DISABLED,
|
95 |
/* callback */ NULL |
96 |
}, |
97 |
/* channel 3 */ {
|
98 |
/* mode */ PWM_OUTPUT_DISABLED,
|
99 |
/* callback */ NULL |
100 |
}, |
101 |
}, |
102 |
/* TIM CR2 register */ 0, |
103 |
#if (STM32_PWM_USE_ADVANCED == TRUE)
|
104 |
/* TIM BDTR register */ 0, |
105 |
#endif /* (STM32_PWM_USE_ADVANCED == TRUE) */ |
106 |
/* TIM DIER register */ 0, |
107 |
}; |
108 |
|
109 |
SerialConfig moduleHalProgIfConfig = { |
110 |
/* bit rate */ 115200, |
111 |
/* CR1 */ 0, |
112 |
/* CR1 */ 0, |
113 |
/* CR1 */ 0, |
114 |
}; |
115 |
|
116 |
/** @} */
|
117 |
|
118 |
/*===========================================================================*/
|
119 |
/**
|
120 |
* @name GPIO definitions
|
121 |
* @{
|
122 |
*/
|
123 |
/*===========================================================================*/
|
124 |
|
125 |
/**
|
126 |
* @brief SYS_REG_EN output signal GPIO.
|
127 |
*/
|
128 |
static apalGpio_t _gpioSysRegEn = {
|
129 |
/* line */ LINE_SYS_REG_EN,
|
130 |
}; |
131 |
ROMCONST apalControlGpio_t moduleGpioSysRegEn = { |
132 |
/* GPIO */ &_gpioSysRegEn,
|
133 |
/* meta */ {
|
134 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
135 |
/* active state */ APAL_GPIO_ACTIVE_HIGH,
|
136 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
137 |
}, |
138 |
}; |
139 |
|
140 |
/**
|
141 |
* @brief IR_INT1 input signal GPIO.
|
142 |
*/
|
143 |
static apalGpio_t _gpioIrInt1 = {
|
144 |
/* line */ LINE_IR_INT1_N,
|
145 |
}; |
146 |
ROMCONST apalControlGpio_t moduleGpioIrInt1 = { |
147 |
/* GPIO */ &_gpioIrInt1,
|
148 |
/* meta */ {
|
149 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
150 |
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR)
|
151 |
/* active state */ (VCNL4020_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
152 |
/* interrupt edge */ VCNL4020_LLD_INT_EDGE,
|
153 |
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X)
|
154 |
/* active state */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
155 |
/* interrupt edge */ PCAL6524_LLD_INT_EDGE,
|
156 |
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X)
|
157 |
/* active state */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
158 |
/* interrupt edge */ PCAL6524_LLD_INT_EDGE,
|
159 |
#else /* (BOARD_SENSORRING == ?) */ |
160 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
161 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
162 |
#endif /* (BOARD_SENSORRING == ?) */ |
163 |
}, |
164 |
}; |
165 |
|
166 |
/**
|
167 |
* @brief POWER_EN output signal GPIO.
|
168 |
*/
|
169 |
static apalGpio_t _gpioPowerEn = {
|
170 |
/* line */ LINE_POWER_EN,
|
171 |
}; |
172 |
ROMCONST apalControlGpio_t moduleGpioPowerEn = { |
173 |
/* GPIO */ &_gpioPowerEn,
|
174 |
/* meta */ {
|
175 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
176 |
/* active state */ APAL_GPIO_ACTIVE_HIGH,
|
177 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
178 |
}, |
179 |
}; |
180 |
|
181 |
/**
|
182 |
* @brief SYS_UART_DN bidirectional signal GPIO.
|
183 |
*/
|
184 |
static apalGpio_t _gpioSysUartDn = {
|
185 |
/* line */ LINE_SYS_UART_DN,
|
186 |
}; |
187 |
ROMCONST apalControlGpio_t moduleGpioSysUartDn = { |
188 |
/* GPIO */ &_gpioSysUartDn,
|
189 |
/* meta */ {
|
190 |
/* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
191 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
192 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
193 |
}, |
194 |
}; |
195 |
|
196 |
/**
|
197 |
* @brief CHARGE_STAT2A input signal GPIO.
|
198 |
*/
|
199 |
static apalGpio_t _gpioChargeStat2A = {
|
200 |
/* line */ LINE_CHARGE_STAT2A,
|
201 |
}; |
202 |
ROMCONST apalControlGpio_t moduleGpioChargeStat2A = { |
203 |
/* GPIO */ &_gpioChargeStat2A,
|
204 |
/* meta */ {
|
205 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
206 |
/* active state */ BQ241xx_LLD_CHARGE_STATUS_GPIO_ACTIVE_STATE,
|
207 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
208 |
}, |
209 |
}; |
210 |
|
211 |
/**
|
212 |
* @brief GAUGE_BATLOW2 input signal GPIO.
|
213 |
*/
|
214 |
static apalGpio_t _gpioGaugeBatLow2 = {
|
215 |
/* line */ LINE_GAUGE_BATLOW2,
|
216 |
}; |
217 |
ROMCONST apalControlGpio_t moduleGpioGaugeBatLow2 = { |
218 |
/* GPIO */ &_gpioGaugeBatLow2,
|
219 |
/* meta */ {
|
220 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
221 |
/* active state */ BQ27500_LLD_BATLOW_ACTIVE_STATE,
|
222 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
223 |
}, |
224 |
}; |
225 |
|
226 |
/**
|
227 |
* @brief GAUGE_BATGD2 input signal GPIO.
|
228 |
*/
|
229 |
static apalGpio_t _gpioGaugeBatGd2 = {
|
230 |
/* line */ LINE_GAUGE_BATGD2_N,
|
231 |
}; |
232 |
ROMCONST apalControlGpio_t moduleGpioGaugeBatGd2 = { |
233 |
/* GPIO */ &_gpioGaugeBatGd2,
|
234 |
/* meta */ {
|
235 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
236 |
/* active state */ BQ27500_LLD_BATGOOD_ACTIVE_STATE,
|
237 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
238 |
}, |
239 |
}; |
240 |
|
241 |
/**
|
242 |
* @brief LED output signal GPIO.
|
243 |
*/
|
244 |
static apalGpio_t _gpioLed = {
|
245 |
/* line */ LINE_LED,
|
246 |
}; |
247 |
ROMCONST apalControlGpio_t moduleGpioLed = { |
248 |
/* GPIO */ &_gpioLed,
|
249 |
/* meta */ {
|
250 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
251 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
252 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
253 |
}, |
254 |
}; |
255 |
|
256 |
/**
|
257 |
* @brief SYS_UART_UP bidirectional signal GPIO.
|
258 |
*/
|
259 |
static apalGpio_t _gpioSysUartUp = {
|
260 |
/* line */ LINE_SYS_UART_UP,
|
261 |
}; |
262 |
ROMCONST apalControlGpio_t moduleGpioSysUartUp = { |
263 |
/* GPIO */ &_gpioSysUartUp,
|
264 |
/* meta */ {
|
265 |
/* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
266 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
267 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
268 |
}, |
269 |
}; |
270 |
|
271 |
/**
|
272 |
* @brief CHARGE_STAT1A input signal GPIO.
|
273 |
*/
|
274 |
static apalGpio_t _gpioChargeStat1A = {
|
275 |
/* line */ LINE_CHARGE_STAT1A,
|
276 |
}; |
277 |
ROMCONST apalControlGpio_t moduleGpioChargeStat1A = { |
278 |
/* GPIO */ &_gpioChargeStat1A,
|
279 |
/* meta */ {
|
280 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
281 |
/* active state */ BQ241xx_LLD_CHARGE_STATUS_GPIO_ACTIVE_STATE,
|
282 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
283 |
}, |
284 |
}; |
285 |
|
286 |
/**
|
287 |
* @brief GAUGE_BATLOW1 input signal GPIO.
|
288 |
*/
|
289 |
static apalGpio_t _gpioGaugeBatLow1 = {
|
290 |
/* line */ LINE_GAUGE_BATLOW1,
|
291 |
}; |
292 |
ROMCONST apalControlGpio_t moduleGpioGaugeBatLow1 = { |
293 |
/* GPIO */ &_gpioGaugeBatLow1,
|
294 |
/* meta */ {
|
295 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
296 |
/* active state */ BQ27500_LLD_BATLOW_ACTIVE_STATE,
|
297 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
298 |
}, |
299 |
}; |
300 |
|
301 |
/**
|
302 |
* @brief GAUGE_BATGD1 input signal GPIO.
|
303 |
*/
|
304 |
static apalGpio_t _gpioGaugeBatGd1 = {
|
305 |
/* line */ LINE_GAUGE_BATGD1_N,
|
306 |
}; |
307 |
ROMCONST apalControlGpio_t moduleGpioGaugeBatGd1 = { |
308 |
/* GPIO */ &_gpioGaugeBatGd1,
|
309 |
/* meta */ {
|
310 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
311 |
/* active state */ BQ27500_LLD_BATGOOD_ACTIVE_STATE,
|
312 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
313 |
}, |
314 |
}; |
315 |
|
316 |
/**
|
317 |
* @brief CHARG_EN1 output signal GPIO.
|
318 |
*/
|
319 |
static apalGpio_t _gpioChargeEn1 = {
|
320 |
/* line */ LINE_CHARGE_EN1_N,
|
321 |
}; |
322 |
ROMCONST apalControlGpio_t moduleGpioChargeEn1 = { |
323 |
/* GPIO */ &_gpioChargeEn1,
|
324 |
/* meta */ {
|
325 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
326 |
/* active state */ BQ241xx_LLD_ENABLED_GPIO_ACTIVE_STATE,
|
327 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
328 |
}, |
329 |
}; |
330 |
|
331 |
/**
|
332 |
* @brief IR_INT2 input signal GPIO.
|
333 |
*/
|
334 |
static apalGpio_t _gpioIrInt2 = {
|
335 |
/* line */ LINE_IR_INT2_N,
|
336 |
}; |
337 |
ROMCONST apalControlGpio_t moduleGpioIrInt2 = { |
338 |
/* GPIO */ &_gpioIrInt2,
|
339 |
/* meta */ {
|
340 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
341 |
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR)
|
342 |
/* active state */ (VCNL4020_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
343 |
/* interrupt edge */ VCNL4020_LLD_INT_EDGE,
|
344 |
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X)
|
345 |
/* active state */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
346 |
/* interrupt edge */ PCAL6524_LLD_INT_EDGE,
|
347 |
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X)
|
348 |
/* active state */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
349 |
/* interrupt edge */ PCAL6524_LLD_INT_EDGE,
|
350 |
#else /* (BOARD_SENSORRING == ?) */ |
351 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
352 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
353 |
#endif /* (BOARD_SENSORRING == ?) */ |
354 |
}, |
355 |
}; |
356 |
|
357 |
/**
|
358 |
* @brief TOUCH_INT input signal GPIO.
|
359 |
*/
|
360 |
static apalGpio_t _gpioTouchInt = {
|
361 |
/* line */ LINE_TOUCH_INT_N,
|
362 |
}; |
363 |
ROMCONST apalControlGpio_t moduleGpioTouchInt = { |
364 |
/* GPIO */ &_gpioTouchInt,
|
365 |
/* meta */ {
|
366 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
367 |
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR)
|
368 |
/* active state */ (MPR121_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
369 |
/* interrupt edge */ MPR121_LLD_INT_EDGE,
|
370 |
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X)
|
371 |
/* active state */ (AT42QT1050_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
372 |
/* interrupt edge */ AT42QT1050_LLD_INT_EDGE,
|
373 |
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X)
|
374 |
/* active state */ (AT42QT1050_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
|
375 |
/* interrupt edge */ AT42QT1050_LLD_INT_EDGE,
|
376 |
#else /* (BOARD_SENSORRING == ?) */ |
377 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
378 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
379 |
#endif /* (BOARD_SENSORRING == ?) */ |
380 |
}, |
381 |
}; |
382 |
|
383 |
/**
|
384 |
* @brief SYS_DONE input signal GPIO.
|
385 |
*/
|
386 |
static apalGpio_t _gpioSysDone = {
|
387 |
/* line */ LINE_SYS_DONE,
|
388 |
}; |
389 |
ROMCONST apalControlGpio_t moduleGpioSysDone = { |
390 |
/* GPIO */ &_gpioSysDone,
|
391 |
/* meta */ {
|
392 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
393 |
/* active state */ APAL_GPIO_ACTIVE_HIGH,
|
394 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
395 |
}, |
396 |
}; |
397 |
|
398 |
/**
|
399 |
* @brief SYS_PROG output signal GPIO.
|
400 |
*/
|
401 |
static apalGpio_t _gpioSysProg = {
|
402 |
/* line */ LINE_SYS_PROG_N,
|
403 |
}; |
404 |
ROMCONST apalControlGpio_t moduleGpioSysProg = { |
405 |
/* GPIO */ &_gpioSysProg,
|
406 |
/* meta */ {
|
407 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
408 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
409 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
410 |
}, |
411 |
}; |
412 |
|
413 |
/**
|
414 |
* @brief PATH_DC input signal GPIO.
|
415 |
*/
|
416 |
static apalGpio_t _gpioPathDc = {
|
417 |
/* line */ LINE_PATH_DC,
|
418 |
}; |
419 |
ROMCONST apalControlGpio_t moduleGpioPathDc = { |
420 |
/* GPIO */ &_gpioPathDc,
|
421 |
/* meta */ {
|
422 |
/* direction */ APAL_GPIO_DIRECTION_INPUT,
|
423 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
424 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
425 |
}, |
426 |
}; |
427 |
|
428 |
/**
|
429 |
* @brief SYS_SPI_DIR bidirectional signal GPIO.
|
430 |
*/
|
431 |
static apalGpio_t _gpioSysSpiDir = {
|
432 |
/* line */ LINE_SYS_SPI_DIR,
|
433 |
}; |
434 |
ROMCONST apalControlGpio_t moduleGpioSysSpiDir = { |
435 |
/* GPIO */ &_gpioSysSpiDir,
|
436 |
/* meta */ {
|
437 |
/* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
438 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
439 |
/* interrupt edge */ APAL_GPIO_EDGE_FALLING,
|
440 |
}, |
441 |
}; |
442 |
|
443 |
/**
|
444 |
* @brief SYS_SYNC bidirectional signal GPIO.
|
445 |
*/
|
446 |
static apalGpio_t _gpioSysSync = {
|
447 |
/* line */ LINE_SYS_INT_N,
|
448 |
}; |
449 |
ROMCONST apalControlGpio_t moduleGpioSysSync = { |
450 |
/* GPIO */ &_gpioSysSync,
|
451 |
/* meta */ {
|
452 |
/* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
453 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
454 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
455 |
}, |
456 |
}; |
457 |
|
458 |
/**
|
459 |
* @brief SYS_PD bidirectional signal GPIO.
|
460 |
*/
|
461 |
static apalGpio_t _gpioSysPd = {
|
462 |
/* line */ LINE_SYS_PD_N,
|
463 |
}; |
464 |
ROMCONST apalControlGpio_t moduleGpioSysPd = { |
465 |
/* GPIO */ &_gpioSysPd,
|
466 |
/* meta */ {
|
467 |
/* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
468 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
469 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
470 |
}, |
471 |
}; |
472 |
|
473 |
/**
|
474 |
* @brief SYS_WARMRST bidirectional signal GPIO.
|
475 |
*/
|
476 |
static apalGpio_t _gpioSysWarmrst = {
|
477 |
/* line */ LINE_SYS_WARMRST_N,
|
478 |
}; |
479 |
ROMCONST apalControlGpio_t moduleGpioSysWarmrst = { |
480 |
/* GPIO */ &_gpioSysWarmrst,
|
481 |
/* meta */ {
|
482 |
/* direction */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
|
483 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
484 |
/* interrupt edge */ APAL_GPIO_EDGE_BOTH,
|
485 |
}, |
486 |
}; |
487 |
|
488 |
/**
|
489 |
* @brief BT_RST output signal GPIO.
|
490 |
*/
|
491 |
static apalGpio_t _gpioBtRst = {
|
492 |
/* line */ LINE_BT_RST,
|
493 |
}; |
494 |
ROMCONST apalControlGpio_t moduleGpioBtRst = { |
495 |
/* GPIO */ &_gpioBtRst,
|
496 |
/* meta */ {
|
497 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
498 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
499 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
500 |
}, |
501 |
}; |
502 |
|
503 |
/**
|
504 |
* @brief CHARGE_EN2 output signal GPIO.
|
505 |
*/
|
506 |
static apalGpio_t _gpioChargeEn2 = {
|
507 |
/* line */ LINE_CHARGE_EN2_N,
|
508 |
}; |
509 |
ROMCONST apalControlGpio_t moduleGpioChargeEn2 = { |
510 |
/* GPIO */ &_gpioChargeEn2,
|
511 |
/* meta */ {
|
512 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT,
|
513 |
/* active state */ BQ241xx_LLD_ENABLED_GPIO_ACTIVE_STATE,
|
514 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE,
|
515 |
}, |
516 |
}; |
517 |
|
518 |
/** @} */
|
519 |
|
520 |
/*===========================================================================*/
|
521 |
/**
|
522 |
* @name AMiRo-OS core configurations
|
523 |
* @{
|
524 |
*/
|
525 |
/*===========================================================================*/
|
526 |
|
527 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__) |
528 |
ROMCONST char* moduleShellPrompt = "PowerManagement"; |
529 |
#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) */ |
530 |
|
531 |
/** @} */
|
532 |
|
533 |
/*===========================================================================*/
|
534 |
/**
|
535 |
* @name Startup Shutdown Synchronization Protocol (SSSP)
|
536 |
* @{
|
537 |
*/
|
538 |
/*===========================================================================*/
|
539 |
|
540 |
#if ((AMIROOS_CFG_SSSP_ENABLE == true) && (AMIROOS_CFG_SSSP_MSI == true)) || defined(__DOXYGEN__) |
541 |
|
542 |
/* some local definitions */
|
543 |
// maximum number of bytes per CAN frame
|
544 |
#define CAN_BYTES_PER_FRAME 8 |
545 |
// identifier (as dominant as possible)
|
546 |
#define MSI_BCBMSG_CANID 0 |
547 |
|
548 |
aos_ssspbcbstatus_t moduleSsspBcbTransmit(const uint8_t* buffer, size_t length)
|
549 |
{ |
550 |
aosDbgCheck(buffer != NULL);
|
551 |
aosDbgCheck(length > 0 && length <= CAN_BYTES_PER_FRAME);
|
552 |
|
553 |
// local variables
|
554 |
CANTxFrame frame; |
555 |
|
556 |
// setup the common parts of the message frame
|
557 |
frame.DLC = (uint8_t)length; |
558 |
frame.RTR = CAN_RTR_DATA; |
559 |
frame.IDE = CAN_IDE_STD; |
560 |
frame.SID = MSI_BCBMSG_CANID; |
561 |
memcpy(frame.data8, buffer, length); |
562 |
|
563 |
// sent the frame and return
|
564 |
return (canTransmitTimeout(&MODULE_HAL_CAN, CAN_ANY_MAILBOX, &frame, TIME_IMMEDIATE) == MSG_OK) ? AOS_SSSP_BCB_SUCCESS : AOS_SSSP_BCB_ERROR;
|
565 |
} |
566 |
|
567 |
aos_ssspbcbstatus_t moduleSsspBcbReceive(uint8_t* buffer, size_t length) |
568 |
{ |
569 |
aosDbgCheck(buffer != NULL);
|
570 |
aosDbgCheck(length > 0 && length <= CAN_BYTES_PER_FRAME);
|
571 |
|
572 |
// local variables
|
573 |
CANRxFrame frame; |
574 |
|
575 |
// receive a frame and check for errors
|
576 |
if (canReceiveTimeout(&MODULE_HAL_CAN, CAN_ANY_MAILBOX, &frame, TIME_IMMEDIATE) == MSG_OK) {
|
577 |
// a correct frame was received
|
578 |
if (frame.DLC == length &&
|
579 |
frame.RTR == CAN_RTR_DATA && |
580 |
frame.IDE == CAN_IDE_STD && |
581 |
frame.SID == MSI_BCBMSG_CANID) { |
582 |
// success: fetch the data and return
|
583 |
memcpy(buffer, frame.data8, length); |
584 |
return AOS_SSSP_BCB_SUCCESS;
|
585 |
} |
586 |
// an unexpected frame was received
|
587 |
else {
|
588 |
return AOS_SSSP_BCB_INVALIDMSG;
|
589 |
} |
590 |
} else {
|
591 |
// failure: return with error
|
592 |
return AOS_SSSP_BCB_ERROR;
|
593 |
} |
594 |
} |
595 |
|
596 |
#undef MSI_BCBMSG_CANID
|
597 |
#undef CAN_BYTES_PER_FRAME
|
598 |
|
599 |
#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) && (AMIROOS_CFG_SSSP_MSI == true) */ |
600 |
|
601 |
/** @} */
|
602 |
|
603 |
/*===========================================================================*/
|
604 |
/**
|
605 |
* @name Low-level drivers
|
606 |
* @{
|
607 |
*/
|
608 |
/*===========================================================================*/
|
609 |
|
610 |
AT24C01BDriver moduleLldEeprom = { |
611 |
/* I2C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
612 |
/* I2C address */ AT24C01B_LLD_I2C_ADDR_FIXED,
|
613 |
}; |
614 |
|
615 |
BQ241xxDriver moduleLldBatteryChargerFront = { |
616 |
/* charge enable GPIO */ &moduleGpioChargeEn1,
|
617 |
/* charge status GPIO */ &moduleGpioChargeStat1A,
|
618 |
}; |
619 |
|
620 |
BQ241xxDriver moduleLldBatteryChargerRear = { |
621 |
/* charge enable GPIO */ &moduleGpioChargeEn2,
|
622 |
/* charge status GPIO */ &moduleGpioChargeStat2A,
|
623 |
}; |
624 |
|
625 |
BQ27500Driver moduleLldFuelGaugeFront = { |
626 |
/* I2C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
627 |
/* battery low GPIO */ &moduleGpioGaugeBatLow1,
|
628 |
/* battery good GPIO */ &moduleGpioGaugeBatGd1,
|
629 |
}; |
630 |
|
631 |
BQ27500Driver moduleLldFuelGaugeRear = { |
632 |
/* I2C driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
633 |
/* battery low GPIO */ &moduleGpioGaugeBatLow2,
|
634 |
/* battery good GPIO */ &moduleGpioGaugeBatGd2,
|
635 |
}; |
636 |
|
637 |
INA219Driver moduleLldPowerMonitorVdd = { |
638 |
/* I2C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
639 |
/* I²C address */ INA219_LLD_I2C_ADDR_A0 | INA219_LLD_I2C_ADDR_A1,
|
640 |
/* current LSB (uA) */ 0x00u, |
641 |
/* configuration */ NULL, |
642 |
}; |
643 |
|
644 |
INA219Driver moduleLldPowerMonitorVio18 = { |
645 |
/* I2C Driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
646 |
/* I²C address */ INA219_LLD_I2C_ADDR_A1,
|
647 |
/* current LSB (uA) */ 0x00u, |
648 |
/* configuration */ NULL, |
649 |
}; |
650 |
|
651 |
INA219Driver moduleLldPowerMonitorVio33 = { |
652 |
/* I2C Driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
653 |
/* I²C address */ INA219_LLD_I2C_ADDR_FIXED,
|
654 |
/* current LSB (uA) */ 0x00u, |
655 |
/* configuration */ NULL, |
656 |
}; |
657 |
|
658 |
INA219Driver moduleLldPowerMonitorVsys42 = { |
659 |
/* I2C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
660 |
/* I²C address */ INA219_LLD_I2C_ADDR_FIXED,
|
661 |
/* current LSB (uA) */ 0x00u, |
662 |
/* configuration */ NULL, |
663 |
}; |
664 |
|
665 |
INA219Driver moduleLldPowerMonitorVio50 = { |
666 |
/* I2C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
667 |
/* I²C address */ INA219_LLD_I2C_ADDR_A1,
|
668 |
/* current LSB (uA) */ 0x00u, |
669 |
/* configuration */ NULL, |
670 |
}; |
671 |
|
672 |
LEDDriver moduleLldStatusLed = { |
673 |
/* LED GPIO */ &moduleGpioLed,
|
674 |
}; |
675 |
|
676 |
TPS6211xDriver moduleLldStepDownConverter = { |
677 |
/* Power enable GPIO */ &moduleGpioPowerEn,
|
678 |
}; |
679 |
|
680 |
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) || defined(__DOXYGEN__)
|
681 |
|
682 |
MPR121Driver moduleLldTouch = { |
683 |
/* I²C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
684 |
}; |
685 |
|
686 |
PCA9544ADriver moduleLldI2cMultiplexer1 = { |
687 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
688 |
/* I²C address */ PCA9544A_LLD_I2C_ADDR_A0 | PCA9544A_LLD_I2C_ADDR_A1 | PCA9544A_LLD_I2C_ADDR_A2,
|
689 |
}; |
690 |
|
691 |
PCA9544ADriver moduleLldI2cMultiplexer2 = { |
692 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
693 |
/* I²C address */ PCA9544A_LLD_I2C_ADDR_A0 | PCA9544A_LLD_I2C_ADDR_A1 | PCA9544A_LLD_I2C_ADDR_A2,
|
694 |
}; |
695 |
|
696 |
VCNL4020Driver moduleLldProximity1 = { |
697 |
/* I²C Driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
698 |
}; |
699 |
|
700 |
VCNL4020Driver moduleLldProximity2 = { |
701 |
/* I²C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
702 |
}; |
703 |
|
704 |
#endif /* (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) */ |
705 |
|
706 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) || defined(__DOXYGEN__)
|
707 |
|
708 |
PCAL6524Driver moduleLldGpioExtender1 = { |
709 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
710 |
/* I²C address */ PCAL6524_LLD_I2C_ADDR_VDD,
|
711 |
}; |
712 |
|
713 |
PCAL6524Driver moduleLldGpioExtender2 = { |
714 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
715 |
/* I²C address */ PCAL6524_LLD_I2C_ADDR_VDD,
|
716 |
}; |
717 |
|
718 |
AT42QT1050Driver moduleLldTouch = { |
719 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
720 |
/* I²C address */ AT42QT1050_LLD_I2C_ADDRSEL_LOW,
|
721 |
}; |
722 |
|
723 |
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) */ |
724 |
|
725 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) || defined(__DOXYGEN__)
|
726 |
|
727 |
PCAL6524Driver moduleLldGpioExtender1 = { |
728 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
|
729 |
/* I²C address */ PCAL6524_LLD_I2C_ADDR_VDD,
|
730 |
}; |
731 |
|
732 |
PCAL6524Driver moduleLldGpioExtender2 = { |
733 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
734 |
/* I²C address */ PCAL6524_LLD_I2C_ADDR_VDD,
|
735 |
}; |
736 |
|
737 |
AT42QT1050Driver moduleLldTouch = { |
738 |
/* I²C driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
|
739 |
/* I²C address */ AT42QT1050_LLD_I2C_ADDRSEL_LOW,
|
740 |
}; |
741 |
|
742 |
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) */ |
743 |
|
744 |
/** @} */
|
745 |
|
746 |
/*===========================================================================*/
|
747 |
/**
|
748 |
* @name Tests
|
749 |
* @{
|
750 |
*/
|
751 |
/*===========================================================================*/
|
752 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
753 |
|
754 |
/*
|
755 |
* ADC (VSYS)
|
756 |
*/
|
757 |
#include <module_test_adc.h> |
758 |
static int _testAdcShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
759 |
{ |
760 |
return moduleTestAdcShellCb(stream, argc, argv, NULL); |
761 |
} |
762 |
AOS_SHELL_COMMAND(moduleTestAdcShellCmd, "test:ADC", _testAdcShellCmdCb);
|
763 |
|
764 |
/*
|
765 |
* AT24C01BN-SH-B (EEPROM)
|
766 |
*/
|
767 |
#include <module_test_AT24C01B.h> |
768 |
static int _testAt24c01bShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
769 |
{ |
770 |
return moduleTestAt24c01bShellCb(stream, argc, argv, NULL); |
771 |
} |
772 |
AOS_SHELL_COMMAND(moduleTestAt24c01bShellCmd, "test:EEPROM", _testAt24c01bShellCmdCb);
|
773 |
|
774 |
/*
|
775 |
* bq24103a (battery charger)
|
776 |
*/
|
777 |
#include <module_test_bq241xx.h> |
778 |
static int _testBq241xxShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
779 |
{ |
780 |
return moduleTestBq241xxShellCb(stream, argc, argv, NULL); |
781 |
} |
782 |
AOS_SHELL_COMMAND(moduleTestBq241xxShellCmd, "test:BatteryCharger", _testBq241xxShellCmdCb);
|
783 |
|
784 |
/*
|
785 |
* bq27500 (fuel gauge)
|
786 |
*/
|
787 |
#include <module_test_bq27500.h> |
788 |
static int _testBq27500ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
789 |
{ |
790 |
return moduleTestBq27500ShellCb(stream, argc, argv, NULL); |
791 |
} |
792 |
AOS_SHELL_COMMAND(moduleTestBq27500ShellCmd, "test:FuelGauge", _testBq27500ShellCmdCb);
|
793 |
|
794 |
/*
|
795 |
* bq27500 (fuel gauge) in combination with bq24103a (battery charger)
|
796 |
*/
|
797 |
#include <module_test_bq27500_bq241xx.h> |
798 |
static int _testBq27500Bq241xxShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
799 |
{ |
800 |
return moduleTestBq27500Bq241xxShellCb(stream, argc, argv, NULL); |
801 |
} |
802 |
AOS_SHELL_COMMAND(moduleTestBq27500Bq241xxShellCmd, "test:FuelGauge&BatteryCharger", _testBq27500Bq241xxShellCmdCb);
|
803 |
|
804 |
/*
|
805 |
* INA219 (power monitor)
|
806 |
*/
|
807 |
#include <module_test_INA219.h> |
808 |
static int _testIna219ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
809 |
{ |
810 |
return moduleTestIna219ShellCb(stream, argc, argv, NULL); |
811 |
} |
812 |
AOS_SHELL_COMMAND(moduleTestIna219ShellCmd, "test:PowerMonitor", _testIna219ShellCmdCb);
|
813 |
|
814 |
/*
|
815 |
* Status LED
|
816 |
*/
|
817 |
#include <module_test_LED.h> |
818 |
static int _testLedShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
819 |
{ |
820 |
return moduleTestLedShellCb(stream, argc, argv, NULL); |
821 |
} |
822 |
AOS_SHELL_COMMAND(moduleTestLedShellCmd, "test:StatusLED", _testLedShellCmdCb);
|
823 |
|
824 |
/*
|
825 |
* PKLCS1212E4001 (buzzer)
|
826 |
*/
|
827 |
#include <module_test_PKxxxExxx.h> |
828 |
static int _testPkxxxexxxShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
829 |
{ |
830 |
return moduleTestPkxxxexxxShellCb(stream, argc, argv, NULL); |
831 |
} |
832 |
AOS_SHELL_COMMAND(moduleTestPkxxxexxxShellCmd, "test:Buzzer", _testPkxxxexxxShellCmdCb);
|
833 |
|
834 |
/*
|
835 |
* TPS62113 (step-down converter)
|
836 |
*/
|
837 |
#include <module_test_TPS6211x.h> |
838 |
static int _testTps6211xShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
839 |
{ |
840 |
return moduleTestTps6211xShellCb(stream, argc, argv, NULL); |
841 |
} |
842 |
AOS_SHELL_COMMAND(moduleTestTps6211xShellCmd, "test:StepDownConverter", _testTps6211xShellCmdCb);
|
843 |
|
844 |
/*
|
845 |
* TPS62113 (step-sown converter) in combination with INA219 (power monitor)
|
846 |
*/
|
847 |
#include <module_test_TPS6211x_INA219.h> |
848 |
static int _testTps6211xIna219ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
849 |
{ |
850 |
return moduleTestTps6211xIna219ShellCb(stream, argc, argv, NULL); |
851 |
} |
852 |
AOS_SHELL_COMMAND(moduleTestTps6211xIna219ShellCmd, "test:StepDownConverter&PowerMonitor", _testTps6211xIna219ShellCmdCb);
|
853 |
|
854 |
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) || defined(__DOXYGEN__)
|
855 |
|
856 |
/*
|
857 |
* MPR121 (touch sensor)
|
858 |
*/
|
859 |
#include <module_test_MPR121.h> |
860 |
static int _testMpr121ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
861 |
{ |
862 |
return moduleTestMpr121ShellCb(stream, argc, argv, NULL); |
863 |
} |
864 |
AOS_SHELL_COMMAND(moduleTestMpr121ShellCmd, "test:Touch", _testMpr121ShellCmdCb);
|
865 |
|
866 |
/*
|
867 |
* PCA9544A (I2C multiplexer)
|
868 |
*/
|
869 |
#include <module_test_PCA9544A.h> |
870 |
static int _testPca9544aShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
871 |
{ |
872 |
return moduleTestPca9544aShellCb(stream, argc, argv, NULL); |
873 |
} |
874 |
AOS_SHELL_COMMAND(moduleTestPca9544aShellCmd, "test:I2CMultiplexer", _testPca9544aShellCmdCb);
|
875 |
|
876 |
/*
|
877 |
* VCNL4020 (proximity sensor)
|
878 |
*/
|
879 |
#include <module_test_VCNL4020.h> |
880 |
static int _testVcnl4020ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
881 |
{ |
882 |
return moduleTestVcnl4020ShellCb(stream, argc, argv, NULL); |
883 |
} |
884 |
AOS_SHELL_COMMAND(moduleTestVcnl4020ShellCmd, "test:Proximity", _testVcnl4020ShellCmdCb);
|
885 |
|
886 |
#endif /* (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) */ |
887 |
|
888 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) || defined(__DOXYGEN__)
|
889 |
|
890 |
/*
|
891 |
* PCAL6524 (GPIO extender)
|
892 |
*/
|
893 |
#include <module_test_PCAL6524.h> |
894 |
static int _testPcal6524ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
895 |
{ |
896 |
return moduleTestPcal6524ShellCb(stream, argc, argv, NULL); |
897 |
} |
898 |
AOS_SHELL_COMMAND(moduleTestPcal6524ShellCmd, "test:GPIOExtenter", _testPcal6524ShellCmdCb);
|
899 |
|
900 |
/*
|
901 |
* AT42QT1050 (touch sensor)
|
902 |
*/
|
903 |
#include <module_test_AT42QT1050.h> |
904 |
static int _testAt42qt1050ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
905 |
{ |
906 |
return moduleTestAt42qt1050ShellCb(stream, argc, argv, NULL); |
907 |
} |
908 |
AOS_SHELL_COMMAND(moduleTestAt42qt1050ShellCmd, "test:Touch", _testAt42qt1050ShellCmdCb);
|
909 |
|
910 |
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) */ |
911 |
|
912 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) || defined(__DOXYGEN__)
|
913 |
|
914 |
/*
|
915 |
* PCAL6524 (GPIO extender)
|
916 |
*/
|
917 |
#include <module_test_PCAL6524.h> |
918 |
static int _testPcal6524ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
919 |
{ |
920 |
return moduleTestPcal6524ShellCb(stream, argc, argv, NULL); |
921 |
} |
922 |
AOS_SHELL_COMMAND(moduleTestPcal6524ShellCmd, "test:GPIOExtenter", _testPcal6524ShellCmdCb);
|
923 |
|
924 |
/*
|
925 |
* AT42QT1050 (touch sensor)
|
926 |
*/
|
927 |
#include <module_test_AT42QT1050.h> |
928 |
static int _testAt42qt1050ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
929 |
{ |
930 |
return moduleTestAt42qt1050ShellCb(stream, argc, argv, NULL); |
931 |
} |
932 |
AOS_SHELL_COMMAND(moduleTestAt42qt1050ShellCmd, "test:Touch", _testAt42qt1050ShellCmdCb);
|
933 |
|
934 |
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) */ |
935 |
|
936 |
/*
|
937 |
* entire module
|
938 |
*/
|
939 |
static int _testAllShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
940 |
{ |
941 |
(void)argc;
|
942 |
(void)argv;
|
943 |
|
944 |
int status = AOS_OK;
|
945 |
char* targv[AMIROOS_CFG_SHELL_MAXARGS] = {NULL}; |
946 |
aos_testresult_t result_test = {0, 0}; |
947 |
aos_testresult_t result_total = {0, 0}; |
948 |
|
949 |
/* ADC */
|
950 |
status |= moduleTestAdcShellCb(stream, 0, targv, &result_test);
|
951 |
result_total = aosTestResultAdd(result_total, result_test); |
952 |
|
953 |
/* AT24C01BN-SH-B (EEPROM) */
|
954 |
status |= moduleTestAt24c01bShellCb(stream, 0, targv, &result_test);
|
955 |
result_total = aosTestResultAdd(result_total, result_test); |
956 |
|
957 |
/* bq24103a (battery charger) */
|
958 |
// front
|
959 |
targv[1] = "-f"; |
960 |
status |= moduleTestBq241xxShellCb(stream, 2, targv, &result_test);
|
961 |
result_total = aosTestResultAdd(result_total, result_test); |
962 |
// rear
|
963 |
targv[1] = "-r"; |
964 |
status |= moduleTestBq241xxShellCb(stream, 2, targv, &result_test);
|
965 |
result_total = aosTestResultAdd(result_total, result_test); |
966 |
targv[1] = ""; |
967 |
|
968 |
/* bq27500 (fuel gauge) */
|
969 |
// front
|
970 |
targv[1] = "-f"; |
971 |
status |= moduleTestBq27500ShellCb(stream, 2, targv, &result_test);
|
972 |
result_total = aosTestResultAdd(result_total, result_test); |
973 |
// rear
|
974 |
targv[1] = "-r"; |
975 |
status |= moduleTestBq27500ShellCb(stream, 2, targv, &result_test);
|
976 |
result_total = aosTestResultAdd(result_total, result_test); |
977 |
targv[1] = ""; |
978 |
|
979 |
/* bq 27500 (fuel gauge) in combination with bq24103a (battery charger) */
|
980 |
// front
|
981 |
targv[1] = "-f"; |
982 |
status |= moduleTestBq27500Bq241xxShellCb(stream, 2, targv, &result_test);
|
983 |
result_total = aosTestResultAdd(result_total, result_test); |
984 |
// rear
|
985 |
targv[1] = "-r"; |
986 |
status |= moduleTestBq27500Bq241xxShellCb(stream, 2, targv, &result_test);
|
987 |
result_total = aosTestResultAdd(result_total, result_test); |
988 |
targv[1] = ""; |
989 |
|
990 |
/* INA219 (power monitor) */
|
991 |
// VDD
|
992 |
targv[1] = "VDD"; |
993 |
status |= moduleTestIna219ShellCb(stream, 2, targv, &result_test);
|
994 |
result_total = aosTestResultAdd(result_total, result_test); |
995 |
// VIO 1.8V
|
996 |
targv[1] = "VIO1.8"; |
997 |
status |= moduleTestIna219ShellCb(stream, 2, targv, &result_test);
|
998 |
result_total = aosTestResultAdd(result_total, result_test); |
999 |
// VIO 3.3V
|
1000 |
targv[1] = "VIO3.3"; |
1001 |
status |= moduleTestIna219ShellCb(stream, 2, targv, &result_test);
|
1002 |
result_total = aosTestResultAdd(result_total, result_test); |
1003 |
// VSYS 4.2V
|
1004 |
targv[1] = "VSYS4.2"; |
1005 |
status |= moduleTestIna219ShellCb(stream, 2, targv, &result_test);
|
1006 |
result_total = aosTestResultAdd(result_total, result_test); |
1007 |
// VIO 5.0V
|
1008 |
targv[1] = "VIO5.0"; |
1009 |
status |= moduleTestIna219ShellCb(stream, 2, targv, &result_test);
|
1010 |
result_total = aosTestResultAdd(result_total, result_test); |
1011 |
targv[1] = ""; |
1012 |
|
1013 |
/* status LED */
|
1014 |
status |= moduleTestLedShellCb(stream, 0, targv, &result_test);
|
1015 |
result_total = aosTestResultAdd(result_total, result_test); |
1016 |
|
1017 |
/* PKLCS1212E4001 (buzzer) */
|
1018 |
status |= moduleTestPkxxxexxxShellCb(stream, 0, targv, &result_test);
|
1019 |
result_total = aosTestResultAdd(result_total, result_test); |
1020 |
|
1021 |
/* TPS62113 (step-down converter) */
|
1022 |
status |= moduleTestTps6211xShellCb(stream, 0, targv, &result_test);
|
1023 |
result_total = aosTestResultAdd(result_total, result_test); |
1024 |
|
1025 |
/* TPS62113 (step-down converter) in combination with INA219 (power monitor) */
|
1026 |
status |= moduleTestTps6211xIna219ShellCb(stream, 0, targv, &result_test);
|
1027 |
result_total = aosTestResultAdd(result_total, result_test); |
1028 |
|
1029 |
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR)
|
1030 |
|
1031 |
/* MPR121 (touch sensor) */
|
1032 |
status |= moduleTestMpr121ShellCb(stream, 0, targv, &result_test);
|
1033 |
result_total = aosTestResultAdd(result_total, result_test); |
1034 |
|
1035 |
/* PCA9544A (I2C multiplexer) */
|
1036 |
// #1
|
1037 |
targv[1] = "#1"; |
1038 |
status |= moduleTestPca9544aShellCb(stream, 2, targv, &result_test);
|
1039 |
result_total = aosTestResultAdd(result_total, result_test); |
1040 |
// #2
|
1041 |
targv[1] = "#2"; |
1042 |
status |= moduleTestPca9544aShellCb(stream, 2, targv, &result_test);
|
1043 |
result_total = aosTestResultAdd(result_total, result_test); |
1044 |
targv[1] = ""; |
1045 |
|
1046 |
/* VCNL4020 (proximity sensor) */
|
1047 |
// north-northeast
|
1048 |
targv[1] = "-nne"; |
1049 |
status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
|
1050 |
result_total = aosTestResultAdd(result_total, result_test); |
1051 |
// east-northeast
|
1052 |
targv[1] = "-ene"; |
1053 |
status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
|
1054 |
result_total = aosTestResultAdd(result_total, result_test); |
1055 |
// east-southeast
|
1056 |
targv[1] = "-ese"; |
1057 |
status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
|
1058 |
result_total = aosTestResultAdd(result_total, result_test); |
1059 |
// south-southeast
|
1060 |
targv[1] = "-sse"; |
1061 |
status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
|
1062 |
result_total = aosTestResultAdd(result_total, result_test); |
1063 |
// south-southwest
|
1064 |
targv[1] = "-ssw"; |
1065 |
status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
|
1066 |
result_total = aosTestResultAdd(result_total, result_test); |
1067 |
// west-southwest
|
1068 |
targv[1] = "-wsw"; |
1069 |
status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
|
1070 |
result_total = aosTestResultAdd(result_total, result_test); |
1071 |
// west-northwest
|
1072 |
targv[1] = "-wnw"; |
1073 |
status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
|
1074 |
result_total = aosTestResultAdd(result_total, result_test); |
1075 |
// west-northwest
|
1076 |
targv[1] = "-nnw"; |
1077 |
status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test);
|
1078 |
result_total = aosTestResultAdd(result_total, result_test); |
1079 |
targv[1] = ""; |
1080 |
|
1081 |
#endif /* (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) */ |
1082 |
|
1083 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X)
|
1084 |
|
1085 |
/* PCAL6524 (GPIO extender) */
|
1086 |
// #1
|
1087 |
targv[1] = "#1"; |
1088 |
status |= moduleTestPcal6524ShellCb(stream, 2, targv, &result_test);
|
1089 |
result_total = aosTestResultAdd(result_total, result_test); |
1090 |
// #2
|
1091 |
targv[1] = "#2"; |
1092 |
status |= moduleTestPcal6524ShellCb(stream, 2, targv, &result_test);
|
1093 |
result_total = aosTestResultAdd(result_total, result_test); |
1094 |
targv[1] = ""; |
1095 |
|
1096 |
/* AT42QT1050 (touch sensor) */
|
1097 |
status |= moduleTestAt42qt1050ShellCb(stream, 2, targv, &result_test);
|
1098 |
result_total = aosTestResultAdd(result_total, result_test); |
1099 |
|
1100 |
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) */ |
1101 |
|
1102 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X)
|
1103 |
|
1104 |
/* PCAL6524 (GPIO extender) */
|
1105 |
// #1
|
1106 |
targv[1] = "#1"; |
1107 |
status |= moduleTestPcal6524ShellCb(stream, 2, targv, &result_test);
|
1108 |
result_total = aosTestResultAdd(result_total, result_test); |
1109 |
// #2
|
1110 |
targv[1] = "#2"; |
1111 |
status |= moduleTestPcal6524ShellCb(stream, 2, targv, &result_test);
|
1112 |
result_total = aosTestResultAdd(result_total, result_test); |
1113 |
targv[1] = ""; |
1114 |
|
1115 |
/* AT42QT1050 (touch sensor) */
|
1116 |
status |= moduleTestAt42qt1050ShellCb(stream, 2, targv, &result_test);
|
1117 |
result_total = aosTestResultAdd(result_total, result_test); |
1118 |
|
1119 |
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) */ |
1120 |
|
1121 |
// print total result
|
1122 |
chprintf(stream, "\n");
|
1123 |
aosTestResultPrintSummary(stream, &result_total, "entire module");
|
1124 |
|
1125 |
return status;
|
1126 |
} |
1127 |
AOS_SHELL_COMMAND(moduleTestAllShellCmd, "test:all", _testAllShellCmdCb);
|
1128 |
|
1129 |
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
1130 |
|
1131 |
/** @} */
|
1132 |
/** @} */
|