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