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