Statistics
| Branch: | Tag: | Revision:

amiro-os / modules / PowerManagement_1-2 / module.c @ c53ef0b1

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