Statistics
| Branch: | Tag: | Revision:

amiro-os / modules / LightRing_1-2 / module.c @ 916f8d28

History | View | Annotate | Download (17.4 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 LightRing v1.2 module.
22
 *
23
 * @addtogroup lightring_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
CANConfig moduleHalCanConfig = {
46
  /* mcr  */ CAN_MCR_ABOM | CAN_MCR_AWUM | CAN_MCR_TXFP,
47
  /* btr  */ CAN_BTR_SJW(1) | CAN_BTR_TS2(2) | CAN_BTR_TS1(13) | CAN_BTR_BRP(1),
48
};
49

    
50
I2CConfig moduleHalI2cEepromPwrmtrBreakoutConfig = {
51
  /* I²C mode   */ OPMODE_I2C,
52
  /* frequency  */ 400000, // TODO: replace with some macro (-> ChibiOS/HAL)
53
  /* duty cycle */ FAST_DUTY_CYCLE_2,
54
};
55

    
56
SerialConfig moduleHalProgIfConfig = {
57
  /* bit rate */ 115200,
58
  /* CR1      */ 0,
59
  /* CR1      */ 0,
60
  /* CR1      */ 0,
61
};
62

    
63
SPIConfig moduleHalSpiLightConfig = {
64
  /* circular buffer mode        */ false,
65
  /* callback function pointer   */ NULL,
66
  /* chip select line port       */ GPIOC,
67
  /* chip select line pad number */ GPIOC_LIGHT_XLAT,
68
  /* CR1                         */ SPI_CR1_BR_0 | SPI_CR1_BR_1,
69
  /* CR2                         */ SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN,
70
};
71

    
72

    
73
/*===========================================================================*/
74
/**
75
 * @name GPIO definitions
76
 * @{
77
 */
78
/*===========================================================================*/
79

    
80
/**
81
 * @brief   LIGHT_BANK output signal GPIO.
82
 */
83
static apalGpio_t _gpioLightBlank = {
84
  /* port */ GPIOA,
85
  /* pad  */ GPIOA_LIGHT_BLANK,
86
};
87
ROMCONST apalControlGpio_t moduleGpioLightBlank = {
88
  /* GPIO */ &_gpioLightBlank,
89
  /* meta */ {
90
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
91
    /* active state   */ TLC5947_LLD_BLANK_ACTIVE_STATE,
92
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
93
  },
94
};
95

    
96
/**
97
 * @brief   RS232_R_EN_N output signal GPIO.
98
 */
99
static apalGpio_t _gpioRs232En = {
100
  /* port */ GPIOA,
101
  /* pad  */ GPIOA_RS232_R_EN_N,
102
};
103
ROMCONST apalControlGpio_t moduleGpioRs232En = {
104
  /* GPIO */ &_gpioRs232En,
105
  /* meta */ {
106
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
107
    /* active state   */ APAL_GPIO_ACTIVE_LOW, //TODO
108
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
109
  },
110
};
111

    
112
/**
113
 * @brief   SW_V33_EN output signal GPIO.
114
 */
115
static apalGpio_t _gpioSwV33En = {
116
  /* port */ GPIOB,
117
  /* pad  */ GPIOB_SW_V33_EN,
118
};
119
ROMCONST apalControlGpio_t moduleGpioSwV33En = {
120
  /* GPIO */ &_gpioSwV33En,
121
  /* meta */ {
122
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
123
    /* active state   */ MIC9404x_LLD_EN_ACTIVE_STATE,
124
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
125
  },
126
};
127

    
128
/**
129
 * @brief   SW_V42_EN output signal GPIO.
130
 */
131
static apalGpio_t _gpioSwV42En = {
132
  /* port */ GPIOB,
133
  /* pad  */ GPIOB_SW_V42_EN,
134
};
135
ROMCONST apalControlGpio_t moduleGpioSwV42En = {
136
  /* GPIO */ &_gpioSwV42En,
137
  /* meta */ {
138
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
139
    /* active state   */ MIC9404x_LLD_EN_ACTIVE_STATE,
140
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
141
  },
142
};
143

    
144
/**
145
 * @brief   SW_V50_EN output signal GPIO.
146
 */
147
static apalGpio_t _gpioSwV50En = {
148
  /* port */ GPIOB,
149
  /* pad  */ GPIOB_SW_V50_EN,
150
};
151
ROMCONST apalControlGpio_t moduleGpioSwV50En = {
152
  /* GPIO */ &_gpioSwV50En,
153
  /* meta */ {
154
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
155
    /* active state   */ MIC9404x_LLD_EN_ACTIVE_STATE,
156
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
157
  },
158
};
159

    
160
/**
161
 * @brief   IO_3 breakout signal GPIO.
162
 */
163
static apalGpio_t _gpioBreakoutIo3 = {
164
  /* port */ GPIOB,
165
  /* pad  */ GPIOB_IO_3,
166
};
167
apalControlGpio_t moduleGpioBreakoutIo3 = {
168
  /* GPIO */ &_gpioBreakoutIo3,
169
  /* meta */ {
170
    /* direction      */ APAL_GPIO_DIRECTION_UNDEFINED,
171
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
172
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
173
  },
174
};
175

    
176
/**
177
 * @brief   IO_5 breakout signal GPIO.
178
 */
179
static apalGpio_t _gpioBreakoutIo5 = {
180
  /* port */ GPIOB,
181
  /* pad  */ GPIOB_IO_5,
182
};
183
apalControlGpio_t moduleGpioBreakoutIo5 = {
184
  /* GPIO */ &_gpioBreakoutIo5,
185
  /* meta */ {
186
    /* direction      */ APAL_GPIO_DIRECTION_UNDEFINED,
187
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
188
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
189
  },
190
};
191

    
192
/**
193
 * @brief   IO_6 breakout signal GPIO.
194
 */
195
static apalGpio_t _gpioBreakoutIo6 = {
196
  /* port */ GPIOB,
197
  /* pad  */ GPIOB_IO_6,
198
};
199
apalControlGpio_t moduleGpioBreakoutIo6 = {
200
  /* GPIO */ &_gpioBreakoutIo6,
201
  /* meta */ {
202
    /* direction      */ APAL_GPIO_DIRECTION_UNDEFINED,
203
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
204
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
205
  },
206
};
207

    
208
/**
209
 * @brief   SYS_UART_DN bidirectional signal GPIO.
210
 */
211
static apalGpio_t _gpioSysUartDn = {
212
  /* port */ GPIOB,
213
  /* pad  */ GPIOB_SYS_UART_DN,
214
};
215
ROMCONST apalControlGpio_t moduleGpioSysUartDn = {
216
  /* GPIO */ &_gpioSysUartDn,
217
  /* meta */ {
218
    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
219
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
220
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
221
  },
222
};
223

    
224
/**
225
 * @brief   IO_7 breakout signal GPIO.
226
 */
227
static apalGpio_t _gpioBreakoutIo7 = {
228
  /* port */ GPIOB,
229
  /* pad  */ GPIOB_IO_7,
230
};
231
apalControlGpio_t moduleGpioBreakoutIo7 = {
232
  /* GPIO */ &_gpioBreakoutIo7,
233
  /* meta */ {
234
    /* direction      */ APAL_GPIO_DIRECTION_UNDEFINED,
235
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
236
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
237
  },
238
};
239

    
240
/**
241
 * @brief   IO_8 breakout signal GPIO.
242
 */
243
static apalGpio_t _gpioBreakoutIo8 = {
244
  /* port */ GPIOB,
245
  /* pad  */ GPIOB_IO_8,
246
};
247
apalControlGpio_t moduleGpioBreakoutIo8 = {
248
  /* GPIO */ &_gpioBreakoutIo8,
249
  /* meta */ {
250
    /* direction      */ APAL_GPIO_DIRECTION_UNDEFINED,
251
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
252
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
253
  },
254
};
255

    
256
/**
257
 * @brief   IO_4 breakout signal GPIO.
258
 */
259
static apalGpio_t _gpioBreakoutIo4 = {
260
  /* port */ GPIOC,
261
  /* pad  */ GPIOC_IO_4,
262
};
263
apalControlGpio_t moduleGpioBreakoutIo4 = {
264
  /* GPIO */ &_gpioBreakoutIo4,
265
  /* meta */ {
266
    /* direction      */ APAL_GPIO_DIRECTION_UNDEFINED,
267
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
268
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
269
  },
270
};
271

    
272
/**
273
 * @brief   IO_1 breakout signal GPIO.
274
 */
275
static apalGpio_t _gpioBreakoutIo1 = {
276
  /* port */ GPIOC,
277
  /* pad  */ GPIOC_IO_1,
278
};
279
apalControlGpio_t moduleGpioBreakoutIo1 = {
280
  /* GPIO */ &_gpioBreakoutIo1,
281
  /* meta */ {
282
    /* direction      */ APAL_GPIO_DIRECTION_UNDEFINED,
283
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
284
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
285
  },
286
};
287

    
288
/**
289
 * @brief   IO_2 breakout signal GPIO.
290
 */
291
static apalGpio_t _gpioBreakoutIo2 = {
292
  /* port */ GPIOC,
293
  /* pad  */ GPIOC_IO_2,
294
};
295
apalControlGpio_t moduleGpioBreakoutIo2 = {
296
  /* GPIO */ &_gpioBreakoutIo2,
297
  /* meta */ {
298
    /* direction      */ APAL_GPIO_DIRECTION_UNDEFINED,
299
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
300
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
301
  },
302
};
303

    
304
/**
305
 * @brief   LED output signal GPIO.
306
 */
307
static apalGpio_t _gpioLed = {
308
  /* port */ GPIOC,
309
  /* pad  */ GPIOC_LED,
310
};
311
ROMCONST apalControlGpio_t moduleGpioLed = {
312
  /* GPIO */ &_gpioLed,
313
  /* meta */ {
314
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
315
    /* active state   */ LED_LLD_GPIO_ACTIVE_STATE,
316
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
317
  },
318
};
319

    
320
/**
321
 * @brief   LIGHT_XLAT output signal GPIO.
322
 */
323
static apalGpio_t _gpioLightXlat = {
324
  /* port */ GPIOC,
325
  /* pad  */ GPIOC_LIGHT_XLAT,
326
};
327
ROMCONST apalControlGpio_t moduleGpioLightXlat = {
328
  /* GPIO */ &_gpioLightXlat,
329
  /* meta */ {
330
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
331
    /* active state   */ TLC5947_LLD_XLAT_ACTIVE_STATE,
332
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
333
  },
334
};
335

    
336
/**
337
 * @brief   SW_V18_EN output signal GPIO.
338
 */
339
static apalGpio_t _gpioSwV18En = {
340
  /* port */ GPIOC,
341
  /* pad  */ GPIOC_SW_V18_EN,
342
};
343
ROMCONST apalControlGpio_t moduleGpioSwV18En = {
344
  /* GPIO */ &_gpioSwV18En,
345
  /* meta */ {
346
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
347
    /* active state   */ MIC9404x_LLD_EN_ACTIVE_STATE,
348
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
349
  },
350
};
351

    
352
/**
353
 * @brief   SW_VSYS_EN output signal GPIO.
354
 */
355
static apalGpio_t _gpioSwVsysEn = {
356
  /* port */ GPIOC,
357
  /* pad  */ GPIOC_SW_VSYS_EN,
358
};
359
ROMCONST apalControlGpio_t moduleGpioSwVsysEn = {
360
  /* GPIO */ &_gpioSwVsysEn,
361
  /* meta */ {
362
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
363
    /* active state   */ APAL_GPIO_ACTIVE_HIGH,
364
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
365
  },
366
};
367

    
368
/**
369
 * @brief   SYS_UART_UP bidirectional signal GPIO.
370
 */
371
static apalGpio_t _gpioSysUartUp = {
372
  /* port */ GPIOC,
373
  /* pad  */ GPIOC_SYS_UART_UP,
374
};
375
ROMCONST apalControlGpio_t moduleGpioSysUartUp = {
376
  /* GPIO */ &_gpioSysUartUp,
377
  /* meta */ {
378
    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
379
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
380
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
381
  },
382
};
383

    
384
/**
385
 * @brief   SYS_PD bidirectional signal GPIO.
386
 */
387
static apalGpio_t _gpioSysPd = {
388
  /* port */ GPIOC,
389
  /* pad  */ GPIOC_SYS_PD_N,
390
};
391
ROMCONST apalControlGpio_t moduleGpioSysPd = {
392
  /* GPIO */ &_gpioSysPd,
393
  /* meta */ {
394
    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
395
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
396
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
397
  },
398
};
399

    
400
/**
401
 * @brief   SYS_SYNC bidirectional signal GPIO.
402
 */
403
static apalGpio_t _gpioSysSync = {
404
  /* port */ GPIOD,
405
  /* pad  */ GPIOD_SYS_INT_N,
406
};
407
ROMCONST apalControlGpio_t moduleGpioSysSync = {
408
  /* GPIO */ &_gpioSysSync,
409
  /* meta */ {
410
    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
411
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
412
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
413
  },
414
};
415

    
416
/** @} */
417

    
418
/*===========================================================================*/
419
/**
420
 * @name AMiRo-OS core configurations
421
 * @{
422
 */
423
/*===========================================================================*/
424

    
425
#if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
426
ROMCONST char* moduleShellPrompt = "LightRing";
427
#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */
428

    
429
/** @} */
430

    
431
/*===========================================================================*/
432
/**
433
 * @name Startup Shutdown Synchronization Protocol (SSSP)
434
 * @{
435
 */
436
/*===========================================================================*/
437

    
438
/** @} */
439

    
440
/*===========================================================================*/
441
/**
442
 * @name Low-level drivers
443
 * @{
444
 */
445
/*===========================================================================*/
446

    
447
AT24C01BDriver moduleLldEeprom = {
448
  /* I2C driver   */ &MODULE_HAL_I2C_EEPROM_PWRMTR_BREAKOUT,
449
  /* I2C address  */ 0x00u,
450
};
451

    
452
INA219Driver moduleLldPowerMonitorVled = {
453
  /* I2C Driver       */ &MODULE_HAL_I2C_EEPROM_PWRMTR_BREAKOUT,
454
  /* I²C address      */ INA219_LLD_I2C_ADDR_FIXED,
455
  /* current LSB (uA) */ 0x00u,
456
  /* configuration    */ NULL,
457
};
458

    
459
LEDDriver moduleLldStatusLed = {
460
  /* LED enable Gpio */ &moduleGpioLed,
461
};
462

    
463
MIC9404xDriver moduleLldPowerSwitchV18 = {
464
  /* power enable GPIO  */ &moduleGpioSwV18En,
465
};
466

    
467
MIC9404xDriver moduleLldPowerSwitchV33 = {
468
  /* power enable GPIO  */ &moduleGpioSwV33En,
469
};
470

    
471
MIC9404xDriver moduleLldPowerSwitchV42 = {
472
  /* power enable GPIO  */ &moduleGpioSwV42En,
473
};
474

    
475
MIC9404xDriver moduleLldPowerSwitchV50 = {
476
  /* power enable GPIO  */ &moduleGpioSwV50En,
477
};
478

    
479
MIC9404xDriver moduleLldPowerSwitchVsys = {
480
  /* power enable GPIO  */ &moduleGpioSwVsysEn,
481
};
482

    
483
TLC5947Driver moduleLldLedPwm = {
484
  /* SPI driver         */ &MODULE_HAL_SPI_LIGHT,
485
  /* BLANK signal GPIO  */ &moduleGpioLightBlank,
486
  /* XLAT signal GPIO   */ &moduleGpioLightXlat,
487
};
488

    
489
/** @} */
490

    
491
/*===========================================================================*/
492
/**
493
 * @name Unit tests (UT)
494
 * @{
495
 */
496
/*===========================================================================*/
497
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
498
#include <string.h>
499

    
500
/*
501
 * EEPROM (AT24C01B)
502
 */
503
static int _utShellCmdCb_AlldAt24c01b(BaseSequentialStream* stream, int argc, char* argv[])
504
{
505
  (void)argc;
506
  (void)argv;
507
  aosUtRun(stream, &moduleUtAlldAt24c01b, NULL);
508
  return AOS_OK;
509
}
510
static ut_at24c01bdata_t _utAlldAt24c01bData = {
511
  /* driver   */ &moduleLldEeprom,
512
  /* timeout  */ MICROSECONDS_PER_SECOND,
513
};
514
aos_unittest_t moduleUtAlldAt24c01b = {
515
  /* name           */ "AT24C01B",
516
  /* info           */ "1kbit EEPROM",
517
  /* test function  */ utAlldAt24c01bFunc,
518
  /* shell command  */ {
519
    /* name     */ "unittest:EEPROM",
520
    /* callback */ _utShellCmdCb_AlldAt24c01b,
521
    /* next     */ NULL,
522
  },
523
  /* data           */ &_utAlldAt24c01bData,
524
};
525

    
526
/*
527
 * INA219 (power monitor)
528
 */
529
static int _utShellCmdCb_AlldIna219(BaseSequentialStream* stream, int argc, char* argv[])
530
{
531
  (void)argc;
532
  (void)argv;
533
  aosUtRun(stream, &moduleUtAlldIna219, "VLED (4.2V)");
534
  return AOS_OK;
535
}
536
static ut_ina219data_t _utIna219Data = {
537
  /* driver           */ &moduleLldPowerMonitorVled,
538
  /* expected voltage */ 4.2f,
539
  /* tolerance        */ 0.2f,
540
  /* timeout */ MICROSECONDS_PER_SECOND,
541
};
542
aos_unittest_t moduleUtAlldIna219 = {
543
  /* name           */ "INA219",
544
  /* info           */ "power monitor",
545
  /* test function  */ utAlldIna219Func,
546
  /* shell command  */ {
547
    /* name     */ "unittest:PowerMonitor",
548
    /* callback */ _utShellCmdCb_AlldIna219,
549
    /* next     */ NULL,
550
  },
551
  /* data           */ &_utIna219Data,
552
};
553

    
554
/*
555
 * Status LED
556
 */
557
static int _utShellCmdCb_AlldLed(BaseSequentialStream* stream, int argc, char* argv[])
558
{
559
  (void)argc;
560
  (void)argv;
561
  aosUtRun(stream, &moduleUtAlldLed, NULL);
562
  return AOS_OK;
563
}
564
aos_unittest_t moduleUtAlldLed = {
565
  /* name           */ "LED",
566
  /* info           */ NULL,
567
  /* test function  */ utAlldLedFunc,
568
  /* shell command  */ {
569
    /* name     */ "unittest:StatusLED",
570
    /* callback */ _utShellCmdCb_AlldLed,
571
    /* next     */ NULL,
572
  },
573
  /* data           */ &moduleLldStatusLed,
574
};
575

    
576
/*
577
 * Power switch driver (MIC9404x)
578
 */
579
static int _utShellCmdCb_Mic9404x(BaseSequentialStream* stream, int argc, char* argv[])
580
{
581
  // evaluate arguments
582
  if (argc == 2) {
583
    if (strcmp(argv[1], "1.8V") == 0) {
584
      moduleUtAlldMic9404x.data = &moduleLldPowerSwitchV18;
585
      aosUtRun(stream, &moduleUtAlldMic9404x, "1.8V");
586
      moduleUtAlldMic9404x.data = NULL;
587
      return AOS_OK;
588
    }
589
    else if (strcmp(argv[1], "3.3V") == 0) {
590
      moduleUtAlldMic9404x.data = &moduleLldPowerSwitchV33;
591
      aosUtRun(stream, &moduleUtAlldMic9404x, "3.3V");
592
      moduleUtAlldMic9404x.data = NULL;
593
      return AOS_OK;
594
    }
595
    else if (strcmp(argv[1], "4.2V") == 0) {
596
      moduleUtAlldMic9404x.data = &moduleLldPowerSwitchV42;
597
      aosUtRun(stream, &moduleUtAlldMic9404x, "4.2V");
598
      moduleUtAlldMic9404x.data = NULL;
599
      return AOS_OK;
600
    }
601
    else if (strcmp(argv[1], "5.0V") == 0) {
602
      moduleUtAlldMic9404x.data = &moduleLldPowerSwitchV50;
603
      aosUtRun(stream, &moduleUtAlldMic9404x, "5.0V");
604
      moduleUtAlldMic9404x.data = NULL;
605
      return AOS_OK;
606
    }
607
    else if (strcmp(argv[1], "VSYS") == 0) {
608
      moduleUtAlldMic9404x.data = &moduleLldPowerSwitchVsys;
609
      aosUtRun(stream, &moduleUtAlldMic9404x, "VSYS");
610
      moduleUtAlldMic9404x.data = NULL;
611
      return AOS_OK;
612
    }
613
  }
614
  // print help
615
  chprintf(stream, "Usage: %s OPTION\n", argv[0]);
616
  chprintf(stream, "Options:\n");
617
  chprintf(stream, "  1.8V\n");
618
  chprintf(stream, "    Test power switch for 1.8V supply.\n");
619
  chprintf(stream, "  3.3V\n");
620
  chprintf(stream, "    Test power switch for 3.3V supply.\n");
621
  chprintf(stream, "  4.2V\n");
622
  chprintf(stream, "    Test power switch for 4.2V supply.\n");
623
  chprintf(stream, "  5.0V\n");
624
  chprintf(stream, "    Test power switch for 5.0V supply.\n");
625
  chprintf(stream, "  VSYS\n");
626
  chprintf(stream, "    Test power switch for VSYS supply.\n");
627
  return AOS_INVALIDARGUMENTS;
628
}
629
aos_unittest_t moduleUtAlldMic9404x = {
630
  /* info           */ "MIC9404x",
631
  /* name           */ "power swicth driver",
632
  /* test function  */ utAlldMic9404xFunc,
633
  /* shell command  */ {
634
    /* name     */ "unittest:PowerSwitch",
635
    /* callback */ _utShellCmdCb_Mic9404x,
636
    /* next     */ NULL,
637
  },
638
  /* data           */ NULL,
639
};
640

    
641
/*
642
 * LED PWM driver (TLC5947)
643
 */
644
static int _utShellCmdCb_Tlc5947(BaseSequentialStream* stream, int argc, char* argv[])
645
{
646
  (void)argc;
647
  (void)argv;
648
  aosUtRun(stream, &moduleUtAlldTlc5947, NULL);
649
  return AOS_OK;
650
}
651
aos_unittest_t moduleUtAlldTlc5947 = {
652
  /* info           */ "TLC5947",
653
  /* name           */ "LED PWM driver",
654
  /* test function  */ utAlldTlc5947Func,
655
  /* shell command  */ {
656
    /* name     */ "unittest:Lights",
657
    /* callback */ _utShellCmdCb_Tlc5947,
658
    /* next     */ NULL,
659
  },
660
  /* data           */ &moduleLldLedPwm,
661
};
662

    
663
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */
664

    
665
/** @} */
666
/** @} */