Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (47.6 KB)

1
/*
2
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
3
Copyright (C) 2016..2019  Thomas Schöpping et al.
4

5
This program is free software: you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation, either version 3 of the License, or
8
(at your option) any later version.
9

10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
GNU General Public License for more details.
14

15
You should have received a copy of the GNU General Public License
16
along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
*/
18

    
19
/**
20
 * @file
21
 * @brief   Structures and constant for the PowerManagement module.
22
 *
23
 * @addtogroup powermanagement_module
24
 * @{
25
 */
26

    
27
#include "module.h"
28

    
29
/*===========================================================================*/
30
/**
31
 * @name Module specific functions
32
 * @{
33
 */
34
/*===========================================================================*/
35

    
36
/** @} */
37

    
38
/*===========================================================================*/
39
/**
40
 * @name ChibiOS/HAL configuration
41
 * @{
42
 */
43
/*===========================================================================*/
44

    
45
ADCConversionGroup moduleHalAdcVsysConversionGroup = {
46
  /* buffer type        */ true,
47
  /* number of channels */ 1,
48
  /* callback function  */ NULL,
49
  /* error callback     */ NULL,
50
  /* CR1                */ ADC_CR1_AWDEN | ADC_CR1_AWDIE,
51
  /* CR2                */ ADC_CR2_SWSTART | ADC_CR2_CONT,
52
  /* SMPR1              */ 0,
53
  /* SMPR2              */ ADC_SMPR2_SMP_AN9(ADC_SAMPLE_480),
54
  /* HTR                */ ADC_HTR_HT,
55
  /* LTR                */ 0,
56
  /* SQR1               */ ADC_SQR1_NUM_CH(1),
57
  /* SQR2               */ 0,
58
  /* SQR3               */ ADC_SQR3_SQ1_N(ADC_CHANNEL_IN9),
59
};
60

    
61
CANConfig moduleHalCanConfig = {
62
  /* mcr  */ CAN_MCR_ABOM | CAN_MCR_AWUM | CAN_MCR_TXFP,
63
  /* btr  */ CAN_BTR_SJW(1) | CAN_BTR_TS2(3) | CAN_BTR_TS1(15) | CAN_BTR_BRP(1),
64
};
65

    
66
I2CConfig moduleHalI2cSrPm18Pm33GaugeRearConfig = {
67
  /* I²C mode   */ OPMODE_I2C,
68
  /* frequency  */ 400000, // TODO: replace with some macro (-> ChibiOS/HAL)
69
  /* duty cycle */ FAST_DUTY_CYCLE_2,
70
};
71

    
72
I2CConfig moduleHalI2cSrPm42Pm50PmVddEepromGaugeFrontConfig = {
73
  /* I²C mode   */ OPMODE_I2C,
74
  /* frequency  */ 400000, // TODO: replace with some macro (-> ChibiOS/HAL)
75
  /* duty cycle */ FAST_DUTY_CYCLE_2,
76
};
77

    
78
PWMConfig moduleHalPwmBuzzerConfig = {
79
  /* frequency              */ 1000000,
80
  /* period                 */ 0,
81
  /* callback               */ NULL,
82
  /* channel configurations */ {
83
    /* channel 0              */ {
84
      /* mode                   */ PWM_OUTPUT_DISABLED,
85
      /* callback               */ NULL
86
    },
87
    /* channel 1              */ {
88
      /* mode                   */ PWM_OUTPUT_ACTIVE_HIGH,
89
      /* callback               */ NULL
90
    },
91
    /* channel 2              */ {
92
      /* mode                   */ PWM_OUTPUT_DISABLED,
93
      /* callback               */ NULL
94
    },
95
    /* channel 3              */ {
96
      /* mode                   */ PWM_OUTPUT_DISABLED,
97
      /* callback               */ NULL
98
    },
99
  },
100
  /* TIM CR2 register       */ 0,
101
#if (STM32_PWM_USE_ADVANCED == TRUE)
102
  /* TIM BDTR register      */ 0,
103
#endif /* (STM32_PWM_USE_ADVANCED == TRUE) */
104
  /* TIM DIER register      */ 0,
105
};
106

    
107
SerialConfig moduleHalProgIfConfig = {
108
  /* bit rate */ 115200,
109
  /* CR1      */ 0,
110
  /* CR1      */ 0,
111
  /* CR1      */ 0,
112
};
113

    
114
/** @} */
115

    
116
/*===========================================================================*/
117
/**
118
 * @name GPIO definitions
119
 * @{
120
 */
121
/*===========================================================================*/
122

    
123
/**
124
 * @brief   SWITCH_STATUS input signal GPIO.
125
 */
126
static apalGpio_t _gpioSwitchStatus = {
127
  /* port */ GPIOA,
128
  /* pad  */ GPIOA_SWITCH_STATUS_N,
129
};
130
ROMCONST apalControlGpio_t moduleGpioSwitchStatus = {
131
  /* GPIO */ &_gpioSwitchStatus,
132
  /* meta */ {
133
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
134
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
135
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
136
  },
137
};
138

    
139
/**
140
 * @brief   SYS_REG_EN output signal GPIO.
141
 */
142
static apalGpio_t _gpioSysRegEn = {
143
  /* port */ GPIOA,
144
  /* pad  */ GPIOA_SYS_REG_EN,
145
};
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
  /* port */ GPIOB,
160
  /* pad  */ GPIOB_IR_INT1_N,
161
};
162
ROMCONST apalControlGpio_t moduleGpioIrInt1 = {
163
  /* GPIO */ &_gpioIrInt1,
164
  /* meta */ {
165
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
166
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR)
167
    /* active state   */ (VCNL4020_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
168
    /* interrupt edge */ VCNL4020_LLD_INT_EDGE,
169
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X)
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
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X)
173
    /* active state   */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
174
    /* interrupt edge */ PCAL6524_LLD_INT_EDGE,
175
#else /* (BOARD_SENSORRING == ?) */
176
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
177
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
178
#endif /* (BOARD_SENSORRING == ?) */
179
  },
180
};
181

    
182
/**
183
 * @brief   POWER_EN output signal GPIO.
184
 */
185
static apalGpio_t _gpioPowerEn = {
186
  /* port */ GPIOB,
187
  /* pad  */ GPIOB_POWER_EN,
188
};
189
ROMCONST apalControlGpio_t moduleGpioPowerEn = {
190
  /* GPIO */ &_gpioPowerEn,
191
  /* meta */ {
192
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
193
    /* active state   */ APAL_GPIO_ACTIVE_HIGH,
194
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
195
  },
196
};
197

    
198
/**
199
 * @brief   SYS_UART_DN bidirectional signal GPIO.
200
 */
201
static apalGpio_t _gpioSysUartDn = {
202
  /* port */ GPIOB,
203
  /* pad  */ GPIOB_SYS_UART_DN,
204
};
205
ROMCONST apalControlGpio_t moduleGpioSysUartDn = {
206
  /* GPIO */ &_gpioSysUartDn,
207
  /* meta */ {
208
    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
209
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
210
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
211
  },
212
};
213

    
214
/**
215
 * @brief   CHARGE_STAT2A input signal GPIO.
216
 */
217
static apalGpio_t _gpioChargeStat2A = {
218
  /* port */ GPIOB,
219
  /* pad  */ GPIOB_CHARGE_STAT2A,
220
};
221
ROMCONST apalControlGpio_t moduleGpioChargeStat2A = {
222
  /* GPIO */ &_gpioChargeStat2A,
223
  /* meta */ {
224
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
225
    /* active state   */ BQ241xx_LLD_CHARGE_STATUS_GPIO_ACTIVE_STATE,
226
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
227
  },
228
};
229

    
230
/**
231
 * @brief   GAUGE_BATLOW2 input signal GPIO.
232
 */
233
static apalGpio_t _gpioGaugeBatLow2 = {
234
  /* port */ GPIOB,
235
  /* pad  */ GPIOB_GAUGE_BATLOW2,
236
};
237
ROMCONST apalControlGpio_t moduleGpioGaugeBatLow2 = {
238
  /* GPIO */ &_gpioGaugeBatLow2,
239
  /* meta */ {
240
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
241
    /* active state   */ BQ27500_LLD_BATLOW_ACTIVE_STATE,
242
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
243
  },
244
};
245

    
246
/**
247
 * @brief   GAUGE_BATGD2 input signal GPIO.
248
 */
249
static apalGpio_t _gpioGaugeBatGd2 = {
250
  /* port */ GPIOB,
251
  /* pad  */ GPIOB_GAUGE_BATGD2_N,
252
};
253
ROMCONST apalControlGpio_t moduleGpioGaugeBatGd2 = {
254
  /* GPIO */ &_gpioGaugeBatGd2,
255
  /* meta */ {
256
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
257
    /* active state   */ BQ27500_LLD_BATGOOD_ACTIVE_STATE,
258
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
259
  },
260
};
261

    
262
/**
263
 * @brief   LED output signal GPIO.
264
 */
265
static apalGpio_t _gpioLed = {
266
  /* port */ GPIOB,
267
  /* pad  */ GPIOB_LED,
268
};
269
ROMCONST apalControlGpio_t moduleGpioLed = {
270
  /* GPIO */ &_gpioLed,
271
  /* meta */ {
272
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
273
    /* active state   */ LED_LLD_GPIO_ACTIVE_STATE,
274
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
275
  },
276
};
277

    
278
/**
279
 * @brief   SYS_UART_UP bidirectional signal GPIO.
280
 */
281
static apalGpio_t _gpioSysUartUp = {
282
  /* port */ GPIOB,
283
  /* pad  */ GPIOB_SYS_UART_UP,
284
};
285
ROMCONST apalControlGpio_t moduleGpioSysUartUp = {
286
  /* GPIO */ &_gpioSysUartUp,
287
  /* meta */ {
288
    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
289
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
290
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
291
  },
292
};
293

    
294
/**
295
 * @brief   CHARGE_STAT1A input signal GPIO.
296
 */
297
static apalGpio_t _gpioChargeStat1A = {
298
  /* port */ GPIOC,
299
  /* pad  */ GPIOC_CHARGE_STAT1A,
300
};
301
ROMCONST apalControlGpio_t moduleGpioChargeStat1A = {
302
  /* GPIO */ &_gpioChargeStat1A,
303
  /* meta */ {
304
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
305
    /* active state   */ BQ241xx_LLD_CHARGE_STATUS_GPIO_ACTIVE_STATE,
306
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
307
  },
308
};
309

    
310
/**
311
 * @brief   GAUGE_BATLOW1 input signal GPIO.
312
 */
313
static apalGpio_t _gpioGaugeBatLow1 = {
314
  /* port */ GPIOC,
315
  /* pad  */ GPIOC_GAUGE_BATLOW1,
316
};
317
ROMCONST apalControlGpio_t moduleGpioGaugeBatLow1 = {
318
  /* GPIO */ &_gpioGaugeBatLow1,
319
  /* meta */ {
320
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
321
    /* active state   */ BQ27500_LLD_BATLOW_ACTIVE_STATE,
322
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
323
  },
324
};
325

    
326
/**
327
 * @brief   GAUGE_BATGD1 input signal GPIO.
328
 */
329
static apalGpio_t _gpioGaugeBatGd1 = {
330
  /* port */ GPIOC,
331
  /* pad  */ GPIOC_GAUGE_BATGD1_N,
332
};
333
ROMCONST apalControlGpio_t moduleGpioGaugeBatGd1 = {
334
  /* GPIO */ &_gpioGaugeBatGd1,
335
  /* meta */ {
336
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
337
    /* active state   */ BQ27500_LLD_BATGOOD_ACTIVE_STATE,
338
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
339
  },
340
};
341

    
342
/**
343
 * @brief   CHARG_EN1 output signal GPIO.
344
 */
345
static apalGpio_t _gpioChargeEn1 = {
346
  /* port */ GPIOC,
347
  /* pad  */ GPIOC_CHARGE_EN1_N,
348
};
349
ROMCONST apalControlGpio_t moduleGpioChargeEn1 = {
350
  /* GPIO */ &_gpioChargeEn1,
351
  /* meta */ {
352
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
353
    /* active state   */ BQ241xx_LLD_ENABLED_GPIO_ACTIVE_STATE,
354
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
355
  },
356
};
357

    
358
/**
359
 * @brief   IR_INT2 input signal GPIO.
360
 */
361
static apalGpio_t _gpioIrInt2 = {
362
  /* port */ GPIOC,
363
  /* pad  */ GPIOC_IR_INT2_N,
364
};
365
ROMCONST apalControlGpio_t moduleGpioIrInt2 = {
366
  /* GPIO */ &_gpioIrInt2,
367
  /* meta */ {
368
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
369
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR)
370
    /* active state   */ (VCNL4020_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
371
    /* interrupt edge */ VCNL4020_LLD_INT_EDGE,
372
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X)
373
    /* active state   */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
374
    /* interrupt edge */ PCAL6524_LLD_INT_EDGE,
375
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X)
376
    /* active state   */ (PCAL6524_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
377
    /* interrupt edge */ PCAL6524_LLD_INT_EDGE,
378
#else /* (BOARD_SENSORRING == ?) */
379
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
380
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
381
#endif /* (BOARD_SENSORRING == ?) */
382
  },
383
};
384

    
385
/**
386
 * @brief   TOUCH_INT input signal GPIO.
387
 */
388
static apalGpio_t _gpioTouchInt = {
389
  /* port */ GPIOC,
390
  /* pad  */ GPIOC_TOUCH_INT_N,
391
};
392
ROMCONST apalControlGpio_t moduleGpioTouchInt = {
393
  /* GPIO */ &_gpioTouchInt,
394
  /* meta */ {
395
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
396
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR)
397
    /* active state   */ (MPR121_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
398
    /* interrupt edge */ MPR121_LLD_INT_EDGE,
399
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X)
400
    /* active state   */ (AT42QT1050_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
401
    /* interrupt edge */ AT42QT1050_LLD_INT_EDGE,
402
#elif (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X)
403
    /* active state   */ (AT42QT1050_LLD_INT_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
404
    /* interrupt edge */ AT42QT1050_LLD_INT_EDGE,
405
#else /* (BOARD_SENSORRING == ?) */
406
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
407
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
408
#endif /* (BOARD_SENSORRING == ?) */
409
  },
410
};
411

    
412
/**
413
 * @brief   SYS_DONE input signal GPIO.
414
 */
415
static apalGpio_t _gpioSysDone = {
416
  /* port */ GPIOC,
417
  /* pad  */ GPIOC_SYS_DONE,
418
};
419
ROMCONST apalControlGpio_t moduleGpioSysDone = {
420
  /* GPIO */ &_gpioSysDone,
421
  /* meta */ {
422
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
423
    /* active state   */ APAL_GPIO_ACTIVE_HIGH,
424
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
425
  },
426
};
427

    
428
/**
429
 * @brief   SYS_PROG output signal GPIO.
430
 */
431
static apalGpio_t _gpioSysProg = {
432
  /* port */ GPIOC,
433
  /* pad  */ GPIOC_SYS_PROG_N,
434
};
435
ROMCONST apalControlGpio_t moduleGpioSysProg = {
436
  /* GPIO */ &_gpioSysProg,
437
  /* meta */ {
438
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
439
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
440
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
441
  },
442
};
443

    
444
/**
445
 * @brief   PATH_DC input signal GPIO.
446
 */
447
static apalGpio_t _gpioPathDc = {
448
  /* port */ GPIOC,
449
  /* pad  */ GPIOC_PATH_DC,
450
};
451
ROMCONST apalControlGpio_t moduleGpioPathDc = {
452
  /* GPIO */ &_gpioPathDc,
453
  /* meta */ {
454
    /* direction      */ APAL_GPIO_DIRECTION_INPUT,
455
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
456
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
457
  },
458
};
459

    
460
/**
461
 * @brief   SYS_SPI_DIR bidirectional signal GPIO.
462
 */
463
static apalGpio_t _gpioSysSpiDir = {
464
  /* port */ GPIOC,
465
  /* pad  */ GPIOC_SYS_SPI_DIR,
466
};
467
ROMCONST apalControlGpio_t moduleGpioSysSpiDir = {
468
  /* GPIO */ &_gpioSysSpiDir,
469
  /* meta */ {
470
    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
471
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
472
    /* interrupt edge */ APAL_GPIO_EDGE_FALLING,
473
  },
474
};
475

    
476
/**
477
 * @brief   SYS_SYNC bidirectional signal GPIO.
478
 */
479
static apalGpio_t _gpioSysSync = {
480
  /* port */ GPIOC,
481
  /* pad  */ GPIOC_SYS_INT_N,
482
};
483
ROMCONST apalControlGpio_t moduleGpioSysSync = {
484
  /* GPIO */ &_gpioSysSync,
485
  /* meta */ {
486
    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
487
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
488
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
489
  },
490
};
491

    
492
/**
493
 * @brief   SYS_PD bidirectional signal GPIO.
494
 */
495
static apalGpio_t _gpioSysPd = {
496
  /* port */ GPIOC,
497
  /* pad  */ GPIOC_SYS_PD_N,
498
};
499
ROMCONST apalControlGpio_t moduleGpioSysPd = {
500
  /* GPIO */ &_gpioSysPd,
501
  /* meta */ {
502
    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
503
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
504
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
505
  },
506
};
507

    
508
/**
509
 * @brief   SYS_WARMRST bidirectional signal GPIO.
510
 */
511
static apalGpio_t _gpioSysWarmrst = {
512
  /* port */ GPIOC,
513
  /* pad  */ GPIOC_SYS_WARMRST_N,
514
};
515
ROMCONST apalControlGpio_t moduleGpioSysWarmrst = {
516
  /* GPIO */ &_gpioSysWarmrst,
517
  /* meta */ {
518
    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
519
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
520
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
521
  },
522
};
523

    
524
/**
525
 * @brief   BT_RST output signal GPIO.
526
 */
527
static apalGpio_t _gpioBtRst = {
528
  /* port */ GPIOC,
529
  /* pad  */ GPIOC_BT_RST,
530
};
531
ROMCONST apalControlGpio_t moduleGpioBtRst = {
532
  /* GPIO */ &_gpioBtRst,
533
  /* meta */ {
534
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
535
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
536
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
537
  },
538
};
539

    
540
/**
541
 * @brief   CHARGE_EN2 output signal GPIO.
542
 */
543
static apalGpio_t _gpioChargeEn2 = {
544
  /* port */ GPIOD,
545
  /* pad  */ GPIOD_CHARGE_EN2_N,
546
};
547
ROMCONST apalControlGpio_t moduleGpioChargeEn2 = {
548
  /* GPIO */ &_gpioChargeEn2,
549
  /* meta */ {
550
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
551
    /* active state   */ BQ241xx_LLD_ENABLED_GPIO_ACTIVE_STATE,
552
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
553
  },
554
};
555

    
556
/** @} */
557

    
558
/*===========================================================================*/
559
/**
560
 * @name AMiRo-OS core configurations
561
 * @{
562
 */
563
/*===========================================================================*/
564

    
565
#if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
566
ROMCONST char* moduleShellPrompt = "PowerManagement";
567
#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */
568

    
569
/** @} */
570

    
571
/*===========================================================================*/
572
/**
573
 * @name Startup Shutdown Synchronization Protocol (SSSP)
574
 * @{
575
 */
576
/*===========================================================================*/
577

    
578
/** @} */
579

    
580
/*===========================================================================*/
581
/**
582
 * @name Low-level drivers
583
 * @{
584
 */
585
/*===========================================================================*/
586

    
587
AT24C01BDriver moduleLldEeprom = {
588
  /* I2C driver   */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
589
  /* I2C address  */ AT24C01B_LLD_I2C_ADDR_FIXED,
590
};
591

    
592
BQ241xxDriver moduleLldBatteryChargerFront = {
593
  /* charge enable GPIO */ &moduleGpioChargeEn1,
594
  /* charge status GPIO */ &moduleGpioChargeStat1A,
595
};
596

    
597
BQ241xxDriver moduleLldBatteryChargerRear = {
598
  /* charge enable GPIO */ &moduleGpioChargeEn2,
599
  /* charge status GPIO */ &moduleGpioChargeStat2A,
600
};
601

    
602
BQ27500Driver moduleLldFuelGaugeFront = {
603
  /* I2C driver         */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
604
  /* battery low GPIO   */ &moduleGpioGaugeBatLow1,
605
  /* battery good GPIO  */ &moduleGpioGaugeBatGd1,
606
};
607

    
608
BQ27500Driver moduleLldFuelGaugeRear = {
609
  /* I2C driver         */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
610
  /* battery low GPIO   */ &moduleGpioGaugeBatLow2,
611
  /* battery good GPIO  */ &moduleGpioGaugeBatGd2,
612
};
613

    
614
INA219Driver moduleLldPowerMonitorVdd = {
615
  /* I2C Driver       */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
616
  /* I²C address      */ INA219_LLD_I2C_ADDR_A0 | INA219_LLD_I2C_ADDR_A1,
617
  /* current LSB (uA) */ 0x00u,
618
  /* configuration    */ NULL,
619
};
620

    
621
INA219Driver moduleLldPowerMonitorVio18 = {
622
  /* I2C Driver       */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
623
  /* I²C address      */ INA219_LLD_I2C_ADDR_A1,
624
  /* current LSB (uA) */ 0x00u,
625
  /* configuration    */ NULL,
626
};
627

    
628
INA219Driver moduleLldPowerMonitorVio33 = {
629
  /* I2C Driver       */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
630
  /* I²C address      */ INA219_LLD_I2C_ADDR_FIXED,
631
  /* current LSB (uA) */ 0x00u,
632
  /* configuration    */ NULL,
633
};
634

    
635
INA219Driver moduleLldPowerMonitorVsys42 = {
636
  /* I2C Driver       */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
637
  /* I²C address      */ INA219_LLD_I2C_ADDR_FIXED,
638
  /* current LSB (uA) */ 0x00u,
639
  /* configuration    */ NULL,
640
};
641

    
642
INA219Driver moduleLldPowerMonitorVio50 = {
643
  /* I2C Driver       */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
644
  /* I²C address      */ INA219_LLD_I2C_ADDR_A1,
645
  /* current LSB (uA) */ 0x00u,
646
  /* configuration    */ NULL,
647
};
648

    
649
LEDDriver moduleLldStatusLed = {
650
  /* LED GPIO */ &moduleGpioLed,
651
};
652

    
653
TPS6211xDriver moduleLldStepDownConverter = {
654
  /* Power enable GPIO */ &moduleGpioPowerEn,
655
};
656

    
657
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) || defined(__DOXYGEN__)
658

    
659
MPR121Driver moduleLldTouch = {
660
  /* I²C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
661
};
662

    
663
PCA9544ADriver moduleLldI2cMultiplexer1 = {
664
  /* I²C driver   */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
665
  /* I²C address  */ PCA9544A_LLD_I2C_ADDR_A0 | PCA9544A_LLD_I2C_ADDR_A1 | PCA9544A_LLD_I2C_ADDR_A2,
666
};
667

    
668
PCA9544ADriver moduleLldI2cMultiplexer2 = {
669
  /* I²C driver   */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
670
  /* I²C address  */ PCA9544A_LLD_I2C_ADDR_A0 | PCA9544A_LLD_I2C_ADDR_A1 | PCA9544A_LLD_I2C_ADDR_A2,
671
};
672

    
673
VCNL4020Driver moduleLldProximity1 = {
674
  /* I²C Driver */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
675
};
676

    
677
VCNL4020Driver moduleLldProximity2 = {
678
  /* I²C Driver */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
679
};
680

    
681
#endif /* (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) */
682

    
683
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) || defined(__DOXYGEN__)
684

    
685
PCAL6524Driver moduleLldGpioExtender1 = {
686
  /* I²C driver   */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
687
  /* I²C address  */ PCAL6524_LLD_I2C_ADDR_VDD,
688
};
689

    
690
PCAL6524Driver moduleLldGpioExtender2 = {
691
  /* I²C driver   */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
692
  /* I²C address  */ PCAL6524_LLD_I2C_ADDR_VDD,
693
};
694

    
695
AT42QT1050Driver moduleLldTouch = {
696
  /* I²C driver   */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
697
  /* I²C address  */ AT42QT1050_LLD_I2C_ADDRSEL_LOW,
698
};
699

    
700
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) */
701

    
702
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) || defined(__DOXYGEN__)
703

    
704
PCAL6524Driver moduleLldGpioExtender1 = {
705
  /* I²C driver   */ &MODULE_HAL_I2C_SR_PM18_PM33_GAUGEREAR,
706
  /* I²C address  */ PCAL6524_LLD_I2C_ADDR_VDD,
707
};
708

    
709
PCAL6524Driver moduleLldGpioExtender2 = {
710
  /* I²C driver   */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
711
  /* I²C address  */ PCAL6524_LLD_I2C_ADDR_VDD,
712
};
713

    
714
AT42QT1050Driver moduleLldTouch = {
715
  /* I²C driver   */ &MODULE_HAL_I2C_SR_PM42_PM50_PMVDD_EEPROM_GAUGEFRONT,
716
  /* I²C address  */ AT42QT1050_LLD_I2C_ADDRSEL_LOW,
717
};
718

    
719
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) */
720

    
721
/** @} */
722

    
723
/*===========================================================================*/
724
/**
725
 * @name Unit tests (UT)
726
 * @{
727
 */
728
/*===========================================================================*/
729
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
730
#include <string.h>
731

    
732
/*
733
 * ADC
734
 */
735
static int _utShellCmdCb_Adc(BaseSequentialStream* stream, int argc, char* argv[])
736
{
737
  (void)argc;
738
  (void)argv;
739
  aosUtRun(stream, &moduleUtAdcVsys, NULL);
740
  return AOS_OK;
741
}
742
static ut_adcdata_t _utAdcVsysData = {
743
  /* driver               */ &MODULE_HAL_ADC_VSYS,
744
  /* ADC conversion group */ &moduleHalAdcVsysConversionGroup,
745
};
746
aos_unittest_t moduleUtAdcVsys = {
747
  /* name           */ "ADC",
748
  /* info           */ "VSYS",
749
  /* test function  */ utAdcFunc,
750
  /* shell command  */ {
751
    /* name     */ "unittest:ADC",
752
    /* callback */ _utShellCmdCb_Adc,
753
    /* next     */ NULL,
754
  },
755
  /* data           */ &_utAdcVsysData,
756
};
757

    
758
/*
759
 * AT24C01B (EEPROM)
760
 */
761
static int _utShellCmdCb_AlldAt24c01b(BaseSequentialStream* stream, int argc, char* argv[])
762
{
763
  (void)argc;
764
  (void)argv;
765
  aosUtRun(stream, &moduleUtAlldAt24c01b, NULL);
766
  return AOS_OK;
767
}
768
static ut_at24c01bdata_t _utAlldAt24c01bData = {
769
  /* driver   */ &moduleLldEeprom,
770
  /* timeout  */ MICROSECONDS_PER_SECOND,
771
};
772
aos_unittest_t moduleUtAlldAt24c01b = {
773
  /* name           */ "AT24C01B",
774
  /* info           */ "1kbit EEPROM",
775
  /* test function  */ utAlldAt24c01bFunc,
776
  /* shell command  */ {
777
    /* name     */ "unittest:EEPROM",
778
    /* callback */ _utShellCmdCb_AlldAt24c01b,
779
    /* next     */ NULL,
780
  },
781
  /* data           */ &_utAlldAt24c01bData,
782
};
783

    
784
/*
785
 * bq24103a (battery charger)
786
 */
787
static int _utShellCmdCb_AlldBq24103a(BaseSequentialStream* stream, int argc, char* argv[])
788
{
789
  // local variables
790
  bool print_help = false;
791

    
792
  // evaluate argument
793
  if (argc == 2) {
794
    if (strcmp(argv[1], "-f") == 0 || strcmp(argv[1], "--front") == 0) {
795
      moduleUtAlldBq24103a.data = &moduleLldBatteryChargerFront;
796
      aosUtRun(stream, &moduleUtAlldBq24103a, "front battery");
797
      moduleUtAlldBq24103a.data = NULL;
798
    }
799
    else if (strcmp(argv[1], "-r") == 0 || strcmp(argv[1], "--rear") == 0) {
800
      moduleUtAlldBq24103a.data = &moduleLldBatteryChargerRear;
801
      aosUtRun(stream, &moduleUtAlldBq24103a, "rear battery");
802
      moduleUtAlldBq24103a.data = NULL;
803
    }
804
    else {
805
      print_help = true;
806
    }
807
  } else {
808
    print_help = true;
809
  }
810

    
811
  // print help or just return
812
  if (print_help) {
813
    chprintf(stream, "Usage: %s OPTION\n", argv[0]);
814
    chprintf(stream, "Options:\n");
815
    chprintf(stream, "  --front, -f\n");
816
    chprintf(stream, "    Test the front battery charger.\n");
817
    chprintf(stream, "  --rear, -r\n");
818
    chprintf(stream, "    Test the rear battery charger.\n");
819
    return AOS_INVALID_ARGUMENTS;
820
  } else {
821
    return AOS_OK;
822
  }
823
}
824
aos_unittest_t moduleUtAlldBq24103a = {
825
  /* name           */ "bq24103a",
826
  /* info           */ "battery charger",
827
  /* test function  */ utAlldBq241xxFunc,
828
  /* shell command  */ {
829
    /* name     */ "unittest:BatteryCharger",
830
    /* callback */ _utShellCmdCb_AlldBq24103a,
831
    /* next     */ NULL,
832
  },
833
  /* data           */ NULL,
834
};
835

    
836
/*
837
 * bq27500 (fuel gauge)
838
 */
839
static int _utShellCmdCb_AlldBq27500(BaseSequentialStream* stream, int argc, char* argv[])
840
{
841
  // evaluate arguments
842
  if (argc == 2) {
843
    if (strcmp(argv[1], "-f") == 0 || strcmp(argv[1], "--front") == 0) {
844
      ((ut_bq27500data_t*)moduleUtAlldBq27500.data)->driver = &moduleLldFuelGaugeFront;
845
      aosUtRun(stream, &moduleUtAlldBq27500, "front battery");
846
      ((ut_bq27500data_t*)moduleUtAlldBq27500.data)->driver = NULL;
847
      return AOS_OK;
848
    }
849
    else if (strcmp(argv[1], "-r") == 0 || strcmp(argv[1], "--rear") == 0) {
850
      ((ut_bq27500data_t*)moduleUtAlldBq27500.data)->driver = &moduleLldFuelGaugeRear;
851
      aosUtRun(stream, &moduleUtAlldBq27500, "rear battery");
852
      ((ut_bq27500data_t*)moduleUtAlldBq27500.data)->driver = NULL;
853
      return AOS_OK;
854
    }
855
  }
856
  // print help
857
  chprintf(stream, "Usage: %s OPTION\n", argv[0]);
858
  chprintf(stream, "Options:\n");
859
  chprintf(stream, "  --front, -f\n");
860
  chprintf(stream, "    Test the front battery fuel gauge.\n");
861
  chprintf(stream, "  --rear, -r\n");
862
  chprintf(stream, "    Test the rear battery fuel gauge.\n");
863
  return AOS_INVALID_ARGUMENTS;
864
}
865
static ut_bq27500data_t _utAlldBq27500Data = {
866
  /* driver   */ NULL,
867
  /* timeout  */ MICROSECONDS_PER_SECOND,
868
};
869
aos_unittest_t moduleUtAlldBq27500 = {
870
  /* name           */ "bq27500",
871
  /* info           */ "fuel gauge",
872
  /* test function  */ utAlldBq27500Func,
873
  /* shell command  */ {
874
    /* name     */ "unittest:FuelGauge",
875
    /* callback */ _utShellCmdCb_AlldBq27500,
876
    /* next     */ NULL,
877
  },
878
  /* data           */ &_utAlldBq27500Data,
879
};
880

    
881
/*
882
 * bq27500 (fuel gauge) in combination with bq24103a (battery charger)
883
 */
884
static int _utShellCmdCb_AlldBq27500Bq24103a(BaseSequentialStream* stream, int argc, char* argv[])
885
{
886
  // evaluate arguments
887
  if (argc == 2) {
888
    if (strcmp(argv[1], "-f") == 0 || strcmp(argv[1], "--front") == 0) {
889
      ((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq27500 = &moduleLldFuelGaugeFront;
890
      ((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq241xx = &moduleLldBatteryChargerFront;
891
      aosUtRun(stream, &moduleUtAlldBq27500Bq24103a, "front battery");
892
      ((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq27500 = NULL;
893
      ((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq241xx = NULL;
894
      return AOS_OK;
895
    }
896
    else if (strcmp(argv[1], "-r") == 0 || strcmp(argv[1], "--rear") == 0) {
897
      ((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq27500 = &moduleLldFuelGaugeRear;
898
      ((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq241xx = &moduleLldBatteryChargerRear;
899
      aosUtRun(stream, &moduleUtAlldBq27500Bq24103a, "rear battery");
900
      ((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq27500 = NULL;
901
      ((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq241xx = NULL;
902
      return AOS_OK;
903
    }
904
  }
905
  // print help
906
  chprintf(stream, "Usage: %s OPTION\n", argv[0]);
907
  chprintf(stream, "Options:\n");
908
  chprintf(stream, "  --front, -f\n");
909
  chprintf(stream, "    Test the front battery fuel gauge and charger.\n");
910
  chprintf(stream, "  --rear, -r\n");
911
  chprintf(stream, "    Test the rear battery fuel gauge and charger.\n");
912
  return AOS_INVALID_ARGUMENTS;
913
}
914
static ut_bq27500bq241xxdata_t _utAlldBq27500Bq24103aData= {
915
  /* bq27500 driver   */ NULL,
916
  /* bq24103a driver  */ NULL,
917
  /* timeout          */ MICROSECONDS_PER_SECOND,
918
};
919
aos_unittest_t moduleUtAlldBq27500Bq24103a = {
920
  /* name           */ "BQ27500 & BQ24103A",
921
  /* info           */ "fuel gauge & battery charger",
922
  /* test function  */ utAlldBq27500Bq241xxFunc,
923
  /* shell command  */ {
924
    /* name     */ "unittest:FuelGauge&BatteryCharger",
925
    /* callback */ _utShellCmdCb_AlldBq27500Bq24103a,
926
    /* next     */ NULL,
927
  },
928
  /* data           */ &_utAlldBq27500Bq24103aData,
929
};
930

    
931
/*
932
 * INA219 (power monitor)
933
 */
934
static int _utShellCmdCb_AlldIna219(BaseSequentialStream* stream, int argc, char* argv[])
935
{
936
  // evaluate arguments
937
  if (argc == 2) {
938
    if (strcmp(argv[1], "VDD") == 0) {
939
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVdd;
940
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 3.3f;
941
      aosUtRun(stream, &moduleUtAlldIna219, "VDD (3.3V)");
942
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL;
943
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f;
944
      return AOS_OK;
945
    }
946
    else if (strcmp(argv[1], "VIO1.8") == 0) {
947
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVio18;
948
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 1.8f;
949
      aosUtRun(stream, &moduleUtAlldIna219, "VIO (1.8V)");
950
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL;
951
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f;
952
      return AOS_OK;
953
    }
954
    else if (strcmp(argv[1], "VIO3.3") == 0) {
955
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVio33;
956
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 3.3f;
957
      aosUtRun(stream, &moduleUtAlldIna219, "VIO (3.3V)");
958
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL;
959
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f;
960
      return AOS_OK;
961
    }
962
    else if (strcmp(argv[1], "VSYS4.2") == 0) {
963
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVsys42;
964
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 4.2f;
965
      aosUtRun(stream, &moduleUtAlldIna219, "VSYS (4.2V)");
966
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL;
967
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f;
968
      return AOS_OK;
969
    }
970
    else if (strcmp(argv[1], "VIO5.0") == 0) {
971
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVio50;
972
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 5.0f;
973
      aosUtRun(stream, &moduleUtAlldIna219, "VIO (5.0V)");
974
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL;
975
      ((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f;
976
      return AOS_OK;
977
    }
978
  }
979
  // print help
980
  chprintf(stream, "Usage: %s OPTION\n", argv[0]);
981
  chprintf(stream, "Options:\n");
982
  chprintf(stream, "  VDD\n");
983
  chprintf(stream, "    Test VDD (3.3V) power monitor.\n");
984
  chprintf(stream, "  VIO1.8\n");
985
  chprintf(stream, "    Test VIO 1.8V power monitor.\n");
986
  chprintf(stream, "  VIO3.3\n");
987
  chprintf(stream, "    Test VIO 3.3V power monitor.\n");
988
  chprintf(stream, "  VSYS4.2\n");
989
  chprintf(stream, "    Test VSYS 4.2V power monitor.\n");
990
  chprintf(stream, "  VIO5.0\n");
991
  chprintf(stream, "    Test VIO 5.0V power monitor.\n");
992
  return AOS_INVALID_ARGUMENTS;
993
}
994
static ut_ina219data_t _utAlldIna219Data = {
995
  /* driver           */ NULL,
996
  /* expected voltage */ 0.0f,
997
  /* tolerance        */ 0.05f,
998
  /* timeout          */ MICROSECONDS_PER_SECOND,
999
};
1000
aos_unittest_t moduleUtAlldIna219 = {
1001
  /* name           */ "INA219",
1002
  /* info           */ "power monitor",
1003
  /* test function  */ utAlldIna219Func,
1004
  /* shell command  */ {
1005
    /* name     */ "unittest:PowerMonitor",
1006
    /* callback */ _utShellCmdCb_AlldIna219,
1007
    /* next     */ NULL,
1008
  },
1009
  /* data           */ &_utAlldIna219Data,
1010
};
1011

    
1012
/*
1013
 * Status LED
1014
 */
1015
static int _utShellCmdCb_AlldLed(BaseSequentialStream* stream, int argc, char* argv[])
1016
{
1017
  (void)argc;
1018
  (void)argv;
1019
  aosUtRun(stream, &moduleUtAlldLed, NULL);
1020
  return AOS_OK;
1021
}
1022
aos_unittest_t moduleUtAlldLed = {
1023
  /* name           */ "LED",
1024
  /* info           */ NULL,
1025
  /* test function  */ utAlldLedFunc,
1026
  /* shell command  */ {
1027
    /* name     */ "unittest:StatusLED",
1028
    /* callback */ _utShellCmdCb_AlldLed,
1029
    /* next     */ NULL,
1030
  },
1031
  /* data           */ &moduleLldStatusLed,
1032
};
1033

    
1034
/*
1035
 * PKLCS1212E4001 (buzzer)
1036
 */
1037
static int _utShellCmdCb_AlldPklcs1212e4001(BaseSequentialStream* stream, int argc, char* argv[])
1038
{
1039
  (void)argc;
1040
  (void)argv;
1041
  aosUtRun(stream, &moduleUtAlldPklcs1212e4001, NULL);
1042
  return AOS_OK;
1043
}
1044
static ut_pkxxxexxx_t _utAlldPklcs1212e4001Data = {
1045
  /* PWM driver   */ &MODULE_HAL_PWM_BUZZER,
1046
  /* PWM channel  */ MODULE_HAL_PWM_BUZZER_CHANNEL
1047
};
1048
aos_unittest_t moduleUtAlldPklcs1212e4001 = {
1049
  /* name           */ "PKLCS1212E4001",
1050
  /* info           */ "buzzer",
1051
  /* test function  */ utAlldPkxxxexxxFunc,
1052
  /* shell command  */ {
1053
    /* name     */ "unittest:Buzzer",
1054
    /* callback */ _utShellCmdCb_AlldPklcs1212e4001,
1055
    /* next     */ NULL,
1056
  },
1057
  /* data           */ &_utAlldPklcs1212e4001Data,
1058
};
1059

    
1060
/*
1061
 * TPS62113 (step-down converter)
1062
 */
1063
static int _utShellCmdCb_AlldTps62113(BaseSequentialStream* stream, int argc, char* argv[])
1064
{
1065
  // Although there are four TPS62113 on the PCB, they all share the same input signal.
1066
  // A sa result, no additional shell arguments need to be evaluated.
1067
  (void)argc;
1068
  (void)argv;
1069
  aosUtRun(stream, &moduleUtAlldTps62113, NULL);
1070
  return AOS_OK;
1071
}
1072
aos_unittest_t moduleUtAlldTps62113 = {
1073
  /* name           */ "TPS62113",
1074
  /* info           */ "step-down converter",
1075
  /* test function  */ utAlldTps6211xFunc,
1076
  /* shell command  */ {
1077
    /* name     */ "unittest:StepDownConverter",
1078
    /* callback */ _utShellCmdCb_AlldTps62113,
1079
    /* next     */ NULL,
1080
  },
1081
  /* data           */ &moduleLldStepDownConverter,
1082
};
1083

    
1084
/*
1085
 * TPS62113 (step-donw converter) in combination with INA219 (power monitor)
1086
 */
1087
static int _utShellCmdCb_AlldTps62113Ina219(BaseSequentialStream* stream, int argc, char* argv[])
1088
{
1089
  (void)argc;
1090
  (void)argv;
1091
  aosUtRun(stream, &moduleUtAlldTps62113Ina219, "VSYS (4.2V)");
1092
  return AOS_OK;
1093
}
1094
static ut_tps6211xina219data_t _utAlldTps62113Ina219Data = {
1095
  /* TPS62113 */ &moduleLldStepDownConverter,
1096
  /* INA219   */ &moduleLldPowerMonitorVsys42,
1097
  /* timeout  */ MICROSECONDS_PER_SECOND,
1098
};
1099
aos_unittest_t moduleUtAlldTps62113Ina219 = {
1100
  /* name           */ "TPS62113 & INA219",
1101
  /* info           */ "step-down converter & power monitor",
1102
  /* test function  */ utAlldTps6211xIna219Func,
1103
  /* shell command  */ {
1104
    /* name     */ "unittest:StepDownConverter&PowerMonitor",
1105
    /* callback */ _utShellCmdCb_AlldTps62113Ina219,
1106
    /* next     */ NULL,
1107
  },
1108
  /* data           */ &_utAlldTps62113Ina219Data,
1109
};
1110

    
1111
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) || defined(__DOXYGEN__)
1112

    
1113
/*
1114
 * MPR121 (touch sensor)
1115
 */
1116
static int _utShellCmdCb_AlldMpr121(BaseSequentialStream* stream, int argc, char* argv[])
1117
{
1118
  (void)argc;
1119
  (void)argv;
1120
  aosUtRun(stream, &moduleUtAlldMpr121, NULL);
1121
  return AOS_OK;
1122
}
1123
static ut_mpr121data_t _utAlldMpr121Data= {
1124
  /* MPR121 driver  */ &moduleLldTouch,
1125
  /* timeout        */ MICROSECONDS_PER_SECOND,
1126
  /* event source   */ &aos.events.io,
1127
  /* event flags    */ MODULE_OS_IOEVENTFLAGS_TOUCHINT,
1128
};
1129
aos_unittest_t moduleUtAlldMpr121 = {
1130
  /* name           */ "MPR121",
1131
  /* info           */ "touch sensor",
1132
  /* test function  */ utAlldMpr121Func,
1133
  /* shell command  */ {
1134
    /* name     */ "unittest:Touch",
1135
    /* callback */ _utShellCmdCb_AlldMpr121,
1136
    /* next     */ NULL,
1137
  },
1138
  /* data           */ &_utAlldMpr121Data,
1139
};
1140

    
1141
/*
1142
 * PCA9544A (I2C multiplexer)
1143
 */
1144
static int _utShellCmdCb_AlldPca5944a(BaseSequentialStream* stream, int argc, char* argv[])
1145
{
1146
  // evaluate arguments
1147
  if (argc == 2) {
1148
    if (strcmp(argv[1], "#1") == 0) {
1149
      ((ut_pca9544adata_t*)moduleUtAlldPca9544a.data)->driver = &moduleLldI2cMultiplexer1;
1150
      aosUtRun(stream, &moduleUtAlldPca9544a, "I2C bus #1");
1151
      ((ut_pca9544adata_t*)moduleUtAlldPca9544a.data)->driver = NULL;
1152
      return AOS_OK;
1153
    }
1154
    else if (strcmp(argv[1], "#2") == 0) {
1155
      ((ut_pca9544adata_t*)moduleUtAlldPca9544a.data)->driver = &moduleLldI2cMultiplexer2;
1156
      aosUtRun(stream, &moduleUtAlldPca9544a, "I2C bus #2");
1157
      ((ut_pca9544adata_t*)moduleUtAlldPca9544a.data)->driver = NULL;
1158
      return AOS_OK;
1159
    }
1160
  }
1161
  // print help
1162
  chprintf(stream, "Usage: %s OPTION\n", argv[0]);
1163
  chprintf(stream, "Options:\n");
1164
  chprintf(stream, "  #1\n");
1165
  chprintf(stream, "    Test the multiplexer on the I2C bus #1.\n");
1166
  chprintf(stream, "  #2\n");
1167
  chprintf(stream, "    Test the multiplexer on the I2C bus #2.\n");
1168
  return AOS_INVALID_ARGUMENTS;
1169
}
1170
static ut_pca9544adata_t _utAlldPca9544aData = {
1171
  /* driver   */ NULL,
1172
  /* timeout  */ MICROSECONDS_PER_SECOND,
1173
};
1174
aos_unittest_t moduleUtAlldPca9544a = {
1175
  /* name           */ "PCA9544A",
1176
  /* info           */ "I2C multiplexer",
1177
  /* test function  */ utAlldPca9544aFunc,
1178
  /* shell command  */ {
1179
    /* name     */ "unittest:I2CMultiplexer",
1180
    /* callback */ _utShellCmdCb_AlldPca5944a,
1181
    /* next     */ NULL,
1182
  },
1183
  /* data           */ &_utAlldPca9544aData,
1184
};
1185

    
1186
/*
1187
 * VCNL4020 (proximity sensor)
1188
 */
1189
static void _utAlldVcnl4020_disableInterrupt(VCNL4020Driver* vcnl)
1190
{
1191
  uint8_t intstatus;
1192
  vcnl4020_lld_writereg(vcnl, VCNL4020_LLD_REGADDR_INTCTRL, 0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1193
  vcnl4020_lld_readreg(vcnl, VCNL4020_LLD_REGADDR_INTSTATUS, &intstatus, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1194
  if (intstatus) {
1195
    vcnl4020_lld_writereg(vcnl, VCNL4020_LLD_REGADDR_INTSTATUS, intstatus, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1196
  }
1197
  return;
1198
}
1199
static int _utShellCmdCb_AlldVcnl4020(BaseSequentialStream* stream, int argc, char* argv[])
1200
{
1201
  enum {
1202
    UNKNOWN,
1203
    NNE, ENE, ESE, SSE, SSW,WSW,WNW, NNW,
1204
  } sensor = UNKNOWN;
1205
  // evaluate arguments
1206
  if (argc == 2) {
1207
    if (strcmp(argv[1], "-nne") == 0) {
1208
      sensor = NNE;
1209
    } else if (strcmp(argv[1], "-ene") == 0) {
1210
      sensor = ENE;
1211
    } else if (strcmp(argv[1], "-ese") == 0) {
1212
      sensor = ESE;
1213
    } else if (strcmp(argv[1], "-sse") == 0) {
1214
      sensor = SSE;
1215
    } else if (strcmp(argv[1], "-ssw") == 0) {
1216
      sensor = SSW;
1217
    } else if (strcmp(argv[1], "-wsw") == 0) {
1218
      sensor = WSW;
1219
    } else if (strcmp(argv[1], "-wnw") == 0) {
1220
      sensor = WNW;
1221
    } else if (strcmp(argv[1], "-nnw") == 0) {
1222
      sensor = NNW;
1223
    }
1224
  }
1225
  if (sensor != UNKNOWN) {
1226
    PCA9544ADriver* mux = NULL;
1227
    switch (sensor) {
1228
      case SSE:
1229
      case SSW:
1230
      case WSW:
1231
      case WNW:
1232
        mux = &moduleLldI2cMultiplexer1;
1233
        ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld = &moduleLldProximity1;
1234
        ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT2;
1235
        break;
1236
      case NNW:
1237
      case NNE:
1238
      case ENE:
1239
      case ESE:
1240
        mux = &moduleLldI2cMultiplexer2;
1241
        ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld = &moduleLldProximity2;
1242
        ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT1;
1243
        break;
1244
      default:
1245
        break;
1246
    }
1247
    pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1248
    _utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld);
1249
    pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH1, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1250
    _utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld);
1251
    pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH2, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1252
    _utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld);
1253
    pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH3, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1254
    _utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld);
1255
    switch (sensor) {
1256
      case NNE:
1257
        pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH1, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1258
        aosUtRun(stream, &moduleUtAlldVcnl4020, "north-northeast sensor");
1259
        break;
1260
      case ENE:
1261
        pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH3, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1262
        aosUtRun(stream, &moduleUtAlldVcnl4020, "east-northeast sensor");
1263
        break;
1264
      case ESE:
1265
        pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH2, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1266
        aosUtRun(stream, &moduleUtAlldVcnl4020, "north-southeast sensor");
1267
        break;
1268
      case SSE:
1269
        pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1270
        aosUtRun(stream, &moduleUtAlldVcnl4020, "south-southeast sensor");
1271
        break;
1272
      case SSW:
1273
        pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH1, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1274
        aosUtRun(stream, &moduleUtAlldVcnl4020, "south-southwest sensor");
1275
        break;
1276
      case WSW:
1277
        pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH3, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1278
        aosUtRun(stream, &moduleUtAlldVcnl4020, "west-southwest sensor");
1279
        break;
1280
      case WNW:
1281
        pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH2, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1282
        aosUtRun(stream, &moduleUtAlldVcnl4020, "west-northwest sensor");
1283
        break;
1284
      case NNW:
1285
        pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout);
1286
        aosUtRun(stream, &moduleUtAlldVcnl4020, "north-northwest sensor");
1287
        break;
1288
      default:
1289
        break;
1290
    }
1291
    ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld = NULL;
1292
    ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->evtflags = 0;
1293
    return AOS_OK;
1294
  }
1295
  // print help
1296
  chprintf(stream, "Usage: %s OPTION\n", argv[0]);
1297
  chprintf(stream, "Options:\n");
1298
  chprintf(stream, "  -nne\n");
1299
  chprintf(stream, "    Test north-northeast sensor.\n");
1300
  chprintf(stream, "  -ene\n");
1301
  chprintf(stream, "    Test east-northeast sensor.\n");
1302
  chprintf(stream, "  -ese\n");
1303
  chprintf(stream, "    Test east-southeast sensor.\n");
1304
  chprintf(stream, "  -sse\n");
1305
  chprintf(stream, "    Test south-southeast sensor.\n");
1306
  chprintf(stream, "  -ssw\n");
1307
  chprintf(stream, "    Test south-southwest sensor.\n");
1308
  chprintf(stream, "  -wsw\n");
1309
  chprintf(stream, "    Test west-southwest sensor.\n");
1310
  chprintf(stream, "  -wnw\n");
1311
  chprintf(stream, "    Test west-northwest sensor.\n");
1312
  chprintf(stream, "  -nnw\n");
1313
  chprintf(stream, "    Test north-northwest sensor.\n");
1314
  return AOS_INVALID_ARGUMENTS;
1315
}
1316
static ut_vcnl4020data_t _utAlldVcnl4020Data = {
1317
  /* driver       */ NULL,
1318
  /* timeout      */ MICROSECONDS_PER_SECOND,
1319
  /* event source */ &aos.events.io,
1320
  /* event flags  */ 0,
1321
};
1322
aos_unittest_t moduleUtAlldVcnl4020 = {
1323
  /* name           */ "VCNL4020",
1324
  /* info           */ "proximity sensor",
1325
  /* test function  */ utAlldVcnl4020Func,
1326
  /* shell command  */ {
1327
    /* name     */ "unittest:Proximity",
1328
    /* callback */ _utShellCmdCb_AlldVcnl4020,
1329
    /* next     */ NULL,
1330
  },
1331
  /* data           */ &_utAlldVcnl4020Data,
1332
};
1333

    
1334
#endif /* (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) */
1335

    
1336
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) || defined(__DOXYGEN__)
1337

    
1338
/*
1339
 * PCAL6524 (GPIO extender)
1340
 */
1341
static int _utShellCmdCb_AlldPcal6524(BaseSequentialStream* stream, int argc, char* argv[])
1342
{
1343
  // evaluate arguments
1344
  if (argc == 2) {
1345
    if (strcmp(argv[1], "#1") == 0) {
1346
      ((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = &moduleLldGpioExtender1;
1347
      aosUtRun(stream, &moduleUtAlldPcal6524, "I2C bus #1");
1348
      ((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = NULL;
1349
      return AOS_OK;
1350
    }
1351
    else if (strcmp(argv[1], "#2") == 0) {
1352
      ((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = &moduleLldGpioExtender2;
1353
      aosUtRun(stream, &moduleUtAlldPcal6524, "I2C bus #2");
1354
      ((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = NULL;
1355
      return AOS_OK;
1356
    }
1357
  }
1358
  // print help
1359
  chprintf(stream, "Usage: %s OPTION\n", argv[0]);
1360
  chprintf(stream, "Options:\n");
1361
  chprintf(stream, "  #1\n");
1362
  chprintf(stream, "    Test the GPIO extender on the I2C bus #1.\n");
1363
  chprintf(stream, "  #2\n");
1364
  chprintf(stream, "    Test the GPIO extender on the I2C bus #2.\n");
1365
  return AOS_INVALID_ARGUMENTS;
1366
}
1367
static ut_pcal6524data_t _utAlldPcal6524Data = {
1368
  /* driver   */ NULL,
1369
  /* timeout  */ MICROSECONDS_PER_SECOND,
1370
};
1371
aos_unittest_t moduleUtAlldPcal6524 = {
1372
  /* name           */ "PCAL6524",
1373
  /* info           */ "GPIO extender",
1374
  /* test function  */ utAlldPcal6524Func,
1375
  /* shell command  */ {
1376
    /* name     */ "unittest:GPIOExtender",
1377
    /* callback */ _utShellCmdCb_AlldPcal6524,
1378
    /* next     */ NULL,
1379
  },
1380
  /* data           */ &_utAlldPcal6524Data,
1381
};
1382

    
1383
/*
1384
 * AT42QT1050 (touch sensor)
1385
 */
1386
static int _utShellCmdCb_AlldAt42qt1050(BaseSequentialStream* stream, int argc, char* argv[])
1387
{
1388
  (void)argc;
1389
  (void)argv;
1390
  aosUtRun(stream, &moduleUtAlldAt42qt1050, NULL);
1391
  return AOS_OK;
1392
}
1393
static ut_at42qt1050data_t _utAlldAt42qt1050Data= {
1394
  /* AT42QT1050 driver  */ &moduleLldTouch,
1395
  /* timeout            */ MICROSECONDS_PER_SECOND,
1396
  /* event source       */ &aos.events.io,
1397
  /* event flags        */ MODULE_OS_IOEVENTFLAGS_TOUCHINT,
1398
};
1399
aos_unittest_t moduleUtAlldAt42qt1050 = {
1400
  /* name           */ "AT42QT1050",
1401
  /* info           */ "touch sensor",
1402
  /* test function  */ utAlldAt42qt1050Func,
1403
  /* shell command  */ {
1404
    /* name     */ "unittest:Touch",
1405
    /* callback */ _utShellCmdCb_AlldAt42qt1050,
1406
    /* next     */ NULL,
1407
  },
1408
  /* data           */ &_utAlldAt42qt1050Data,
1409
};
1410

    
1411
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) */
1412

    
1413
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) || defined(__DOXYGEN__)
1414

    
1415
/*
1416
 * PCAL6524 (GPIO extender)
1417
 */
1418
static int _utShellCmdCb_AlldPcal6524(BaseSequentialStream* stream, int argc, char* argv[])
1419
{
1420
  // evaluate arguments
1421
  if (argc == 2) {
1422
    if (strcmp(argv[1], "#1") == 0) {
1423
      ((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = &moduleLldGpioExtender1;
1424
      aosUtRun(stream, &moduleUtAlldPcal6524, "I2C bus #1");
1425
      ((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = NULL;
1426
      return AOS_OK;
1427
    }
1428
    else if (strcmp(argv[1], "#2") == 0) {
1429
      ((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = &moduleLldGpioExtender2;
1430
      aosUtRun(stream, &moduleUtAlldPcal6524, "I2C bus #2");
1431
      ((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = NULL;
1432
      return AOS_OK;
1433
    }
1434
  }
1435
  // print help
1436
  chprintf(stream, "Usage: %s OPTION\n", argv[0]);
1437
  chprintf(stream, "Options:\n");
1438
  chprintf(stream, "  #1\n");
1439
  chprintf(stream, "    Test the GPIO extender on the I2C bus #1.\n");
1440
  chprintf(stream, "  #2\n");
1441
  chprintf(stream, "    Test the GPIO extender on the I2C bus #2.\n");
1442
  return AOS_INVALID_ARGUMENTS;
1443
}
1444
static ut_pcal6524data_t _utAlldPcal6524Data = {
1445
  /* driver   */ NULL,
1446
  /* timeout  */ MICROSECONDS_PER_SECOND,
1447
};
1448
aos_unittest_t moduleUtAlldPcal6524 = {
1449
  /* name           */ "PCAL6524",
1450
  /* info           */ "GPIO extender",
1451
  /* test function  */ utAlldPcal6524Func,
1452
  /* shell command  */ {
1453
    /* name     */ "unittest:GPIOExtender",
1454
    /* callback */ _utShellCmdCb_AlldPcal6524,
1455
    /* next     */ NULL,
1456
  },
1457
  /* data           */ &_utAlldPcal6524Data,
1458
};
1459

    
1460
/*
1461
 * AT42QT1050 (touch sensor)
1462
 */
1463
static int _utShellCmdCb_AlldAt42qt1050(BaseSequentialStream* stream, int argc, char* argv[])
1464
{
1465
  (void)argc;
1466
  (void)argv;
1467
  aosUtRun(stream, &moduleUtAlldAt42qt1050, NULL);
1468
  return AOS_OK;
1469
}
1470
static ut_at42qt1050data_t _utAlldAt42qt1050Data= {
1471
  /* AT42QT1050 driver  */ &moduleLldTouch,
1472
  /* timeout            */ MICROSECONDS_PER_SECOND,
1473
  /* event source       */ &aos.events.io,
1474
  /* event flags        */ MODULE_OS_IOEVENTFLAGS_TOUCHINT,
1475
};
1476
aos_unittest_t moduleUtAlldAt42qt1050 = {
1477
  /* name           */ "AT42QT1050",
1478
  /* info           */ "touch sensor",
1479
  /* test function  */ utAlldAt42qt1050Func,
1480
  /* shell command  */ {
1481
    /* name     */ "unittest:Touch",
1482
    /* callback */ _utShellCmdCb_AlldAt42qt1050,
1483
    /* next     */ NULL,
1484
  },
1485
  /* data           */ &_utAlldAt42qt1050Data,
1486
};
1487

    
1488
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) */
1489

    
1490
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */
1491

    
1492
/** @} */
1493
/** @} */