Statistics
| Branch: | Tag: | Revision:

amiro-os / modules / LightRing_1-2 / module.c @ c7dcc892

History | View | Annotate | Download (17.29 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       */ PAL_PORT(LINE_LIGHT_XLAT),
67
  /* chip select line pad number */ PAL_PAD(LINE_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
  /* line */ LINE_LIGHT_BLANK,
85
};
86
ROMCONST apalControlGpio_t moduleGpioLightBlank = {
87
  /* GPIO */ &_gpioLightBlank,
88
  /* meta */ {
89
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
90
    /* active state   */ TLC5947_LLD_BLANK_ACTIVE_STATE,
91
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
92
  },
93
};
94

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

    
110
/**
111
 * @brief   SW_V33_EN output signal GPIO.
112
 */
113
static apalGpio_t _gpioSwV33En = {
114
  /* line */ LINE_SW_V33_EN,
115
};
116
ROMCONST apalControlGpio_t moduleGpioSwV33En = {
117
  /* GPIO */ &_gpioSwV33En,
118
  /* meta */ {
119
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
120
    /* active state   */ MIC9404x_LLD_EN_ACTIVE_STATE,
121
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
122
  },
123
};
124

    
125
// The 4.2V switch is disabled due to a hardware bug.
126
///**
127
// * @brief   SW_V42_EN output signal GPIO.
128
// */
129
//static apalGpio_t _gpioSwV42En = {
130
//  /* line */ LINE_SW_V42_EN,
131
//};
132
//ROMCONST apalControlGpio_t moduleGpioSwV42En = {
133
//  /* GPIO */ &_gpioSwV42En,
134
//  /* meta */ {
135
//    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
136
//    /* active state   */ MIC9404x_LLD_EN_ACTIVE_STATE,
137
//    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
138
//  },
139
//};
140

    
141
/**
142
 * @brief   SW_V50_EN output signal GPIO.
143
 */
144
static apalGpio_t _gpioSwV50En = {
145
  /* line */ LINE_SW_V50_EN,
146
};
147
ROMCONST apalControlGpio_t moduleGpioSwV50En = {
148
  /* GPIO */ &_gpioSwV50En,
149
  /* meta */ {
150
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
151
    /* active state   */ MIC9404x_LLD_EN_ACTIVE_STATE,
152
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
153
  },
154
};
155

    
156
/**
157
 * @brief   IO_3 breakout signal GPIO.
158
 */
159
static apalGpio_t _gpioBreakoutIo3 = {
160
  /* line */ LINE_IO_3,
161
};
162
apalControlGpio_t moduleGpioBreakoutIo3 = {
163
  /* GPIO */ &_gpioBreakoutIo3,
164
  /* meta */ {
165
    /* direction      */ APAL_GPIO_DIRECTION_UNDEFINED,
166
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
167
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
168
  },
169
};
170

    
171
/**
172
 * @brief   IO_5 breakout signal GPIO.
173
 */
174
static apalGpio_t _gpioBreakoutIo5 = {
175
  /* line */ LINE_IO_5,
176
};
177
apalControlGpio_t moduleGpioBreakoutIo5 = {
178
  /* GPIO */ &_gpioBreakoutIo5,
179
  /* meta */ {
180
    /* direction      */ APAL_GPIO_DIRECTION_UNDEFINED,
181
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
182
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
183
  },
184
};
185

    
186
/**
187
 * @brief   IO_6 breakout signal GPIO.
188
 */
189
static apalGpio_t _gpioBreakoutIo6 = {
190
  /* line */ LINE_IO_6,
191
};
192
apalControlGpio_t moduleGpioBreakoutIo6 = {
193
  /* GPIO */ &_gpioBreakoutIo6,
194
  /* meta */ {
195
    /* direction      */ APAL_GPIO_DIRECTION_UNDEFINED,
196
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
197
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
198
  },
199
};
200

    
201
/**
202
 * @brief   SYS_UART_DN bidirectional signal GPIO.
203
 */
204
static apalGpio_t _gpioSysUartDn = {
205
  /* line */ LINE_SYS_UART_DN,
206
};
207
ROMCONST apalControlGpio_t moduleGpioSysUartDn = {
208
  /* GPIO */ &_gpioSysUartDn,
209
  /* meta */ {
210
    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
211
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
212
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
213
  },
214
};
215

    
216
/**
217
 * @brief   IO_7 breakout signal GPIO.
218
 */
219
static apalGpio_t _gpioBreakoutIo7 = {
220
  /* line */ LINE_IO_7,
221
};
222
apalControlGpio_t moduleGpioBreakoutIo7 = {
223
  /* GPIO */ &_gpioBreakoutIo7,
224
  /* meta */ {
225
    /* direction      */ APAL_GPIO_DIRECTION_UNDEFINED,
226
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
227
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
228
  },
229
};
230

    
231
/**
232
 * @brief   IO_8 breakout signal GPIO.
233
 */
234
static apalGpio_t _gpioBreakoutIo8 = {
235
  /* line */ LINE_IO_8,
236
};
237
apalControlGpio_t moduleGpioBreakoutIo8 = {
238
  /* GPIO */ &_gpioBreakoutIo8,
239
  /* meta */ {
240
    /* direction      */ APAL_GPIO_DIRECTION_UNDEFINED,
241
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
242
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
243
  },
244
};
245

    
246
/**
247
 * @brief   IO_4 breakout signal GPIO.
248
 */
249
static apalGpio_t _gpioBreakoutIo4 = {
250
  /* line */ LINE_IO_4,
251
};
252
apalControlGpio_t moduleGpioBreakoutIo4 = {
253
  /* GPIO */ &_gpioBreakoutIo4,
254
  /* meta */ {
255
    /* direction      */ APAL_GPIO_DIRECTION_UNDEFINED,
256
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
257
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
258
  },
259
};
260

    
261
/**
262
 * @brief   IO_1 breakout signal GPIO.
263
 */
264
static apalGpio_t _gpioBreakoutIo1 = {
265
  /* line */ LINE_IO_1,
266
};
267
apalControlGpio_t moduleGpioBreakoutIo1 = {
268
  /* GPIO */ &_gpioBreakoutIo1,
269
  /* meta */ {
270
    /* direction      */ APAL_GPIO_DIRECTION_UNDEFINED,
271
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
272
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
273
  },
274
};
275

    
276
/**
277
 * @brief   IO_2 breakout signal GPIO.
278
 */
279
static apalGpio_t _gpioBreakoutIo2 = {
280
  /* line */ LINE_IO_2,
281
};
282
apalControlGpio_t moduleGpioBreakoutIo2 = {
283
  /* GPIO */ &_gpioBreakoutIo2,
284
  /* meta */ {
285
    /* direction      */ APAL_GPIO_DIRECTION_UNDEFINED,
286
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
287
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
288
  },
289
};
290

    
291
/**
292
 * @brief   LED output signal GPIO.
293
 */
294
static apalGpio_t _gpioLed = {
295
  /* line */ LINE_LED,
296
};
297
ROMCONST apalControlGpio_t moduleGpioLed = {
298
  /* GPIO */ &_gpioLed,
299
  /* meta */ {
300
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
301
    /* active state   */ LED_LLD_GPIO_ACTIVE_STATE,
302
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
303
  },
304
};
305

    
306
/**
307
 * @brief   LIGHT_XLAT output signal GPIO.
308
 */
309
static apalGpio_t _gpioLightXlat = {
310
  /* line */ LINE_LIGHT_XLAT,
311
};
312
ROMCONST apalControlGpio_t moduleGpioLightXlat = {
313
  /* GPIO */ &_gpioLightXlat,
314
  /* meta */ {
315
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
316
    /* active state   */ (TLC5947_LLD_XLAT_UPDATE_EDGE == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_ACTIVE_HIGH : APAL_GPIO_ACTIVE_LOW,
317
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
318
  },
319
};
320

    
321
/**
322
 * @brief   SW_V18_EN output signal GPIO.
323
 */
324
static apalGpio_t _gpioSwV18En = {
325
  /* line */ LINE_SW_V18_EN,
326
};
327
ROMCONST apalControlGpio_t moduleGpioSwV18En = {
328
  /* GPIO */ &_gpioSwV18En,
329
  /* meta */ {
330
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
331
    /* active state   */ MIC9404x_LLD_EN_ACTIVE_STATE,
332
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
333
  },
334
};
335

    
336
/**
337
 * @brief   SW_VSYS_EN output signal GPIO.
338
 */
339
static apalGpio_t _gpioSwVsysEn = {
340
  /* line */ LINE_SW_VSYS_EN,
341
};
342
ROMCONST apalControlGpio_t moduleGpioSwVsysEn = {
343
  /* GPIO */ &_gpioSwVsysEn,
344
  /* meta */ {
345
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
346
    /* active state   */ APAL_GPIO_ACTIVE_HIGH,
347
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
348
  },
349
};
350

    
351
/**
352
 * @brief   SYS_UART_UP bidirectional signal GPIO.
353
 */
354
static apalGpio_t _gpioSysUartUp = {
355
  /* line */ LINE_SYS_UART_UP,
356
};
357
ROMCONST apalControlGpio_t moduleGpioSysUartUp = {
358
  /* GPIO */ &_gpioSysUartUp,
359
  /* meta */ {
360
    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
361
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
362
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
363
  },
364
};
365

    
366
/**
367
 * @brief   SYS_PD bidirectional signal GPIO.
368
 */
369
static apalGpio_t _gpioSysPd = {
370
  /* line */ LINE_SYS_PD_N,
371
};
372
ROMCONST apalControlGpio_t moduleGpioSysPd = {
373
  /* GPIO */ &_gpioSysPd,
374
  /* meta */ {
375
    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
376
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
377
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
378
  },
379
};
380

    
381
/**
382
 * @brief   SYS_SYNC bidirectional signal GPIO.
383
 */
384
static apalGpio_t _gpioSysSync = {
385
  /* line */ LINE_SYS_INT_N,
386
};
387
ROMCONST apalControlGpio_t moduleGpioSysSync = {
388
  /* GPIO */ &_gpioSysSync,
389
  /* meta */ {
390
    /* direction      */ APAL_GPIO_DIRECTION_BIDIRECTIONAL,
391
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
392
    /* interrupt edge */ APAL_GPIO_EDGE_BOTH,
393
  },
394
};
395

    
396
/** @} */
397

    
398
/*===========================================================================*/
399
/**
400
 * @name AMiRo-OS core configurations
401
 * @{
402
 */
403
/*===========================================================================*/
404

    
405
#if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
406
ROMCONST char* moduleShellPrompt = "LightRing";
407
#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */
408

    
409
/** @} */
410

    
411
/*===========================================================================*/
412
/**
413
 * @name Startup Shutdown Synchronization Protocol (SSSP)
414
 * @{
415
 */
416
/*===========================================================================*/
417

    
418
/** @} */
419

    
420
/*===========================================================================*/
421
/**
422
 * @name Low-level drivers
423
 * @{
424
 */
425
/*===========================================================================*/
426

    
427
AT24C01BDriver moduleLldEeprom = {
428
  /* I2C driver   */ &MODULE_HAL_I2C_EEPROM_PWRMTR_BREAKOUT,
429
  /* I2C address  */ 0x00u,
430
};
431

    
432
INA219Driver moduleLldPowerMonitorVled = {
433
  /* I2C Driver       */ &MODULE_HAL_I2C_EEPROM_PWRMTR_BREAKOUT,
434
  /* I²C address      */ INA219_LLD_I2C_ADDR_FIXED,
435
  /* current LSB (uA) */ 0x00u,
436
  /* configuration    */ NULL,
437
};
438

    
439
LEDDriver moduleLldStatusLed = {
440
  /* LED enable Gpio */ &moduleGpioLed,
441
};
442

    
443
MIC9404xDriver moduleLldPowerSwitchV18 = {
444
  /* power enable GPIO  */ &moduleGpioSwV18En,
445
};
446

    
447
MIC9404xDriver moduleLldPowerSwitchV33 = {
448
  /* power enable GPIO  */ &moduleGpioSwV33En,
449
};
450

    
451
// The 4.2V switch is disabled due to a hardware bug.
452
//MIC9404xDriver moduleLldPowerSwitchV42 = {
453
//  /* power enable GPIO  */ &moduleGpioSwV42En,
454
//};
455

    
456
MIC9404xDriver moduleLldPowerSwitchV50 = {
457
  /* power enable GPIO  */ &moduleGpioSwV50En,
458
};
459

    
460
MIC9404xDriver moduleLldPowerSwitchVsys = {
461
  /* power enable GPIO  */ &moduleGpioSwVsysEn,
462
};
463

    
464
TLC5947Driver moduleLldLedPwm = {
465
  /* SPI driver         */ &MODULE_HAL_SPI_LIGHT,
466
  /* BLANK signal GPIO  */ &moduleGpioLightBlank,
467
  /* XLAT signal GPIO   */ &moduleGpioLightXlat,
468
};
469

    
470
/** @} */
471

    
472
/*===========================================================================*/
473
/**
474
 * @name Unit tests (UT)
475
 * @{
476
 */
477
/*===========================================================================*/
478
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
479
#include <string.h>
480

    
481
/*
482
 * EEPROM (AT24C01B)
483
 */
484
static int _utShellCmdCb_AlldAt24c01b(BaseSequentialStream* stream, int argc, char* argv[])
485
{
486
  (void)argc;
487
  (void)argv;
488
  aosUtRun(stream, &moduleUtAlldAt24c01b, NULL);
489
  return AOS_OK;
490
}
491
static ut_at24c01bdata_t _utAlldAt24c01bData = {
492
  /* driver   */ &moduleLldEeprom,
493
  /* timeout  */ MICROSECONDS_PER_SECOND,
494
};
495
aos_unittest_t moduleUtAlldAt24c01b = {
496
  /* name           */ "AT24C01B",
497
  /* info           */ "1kbit EEPROM",
498
  /* test function  */ utAlldAt24c01bFunc,
499
  /* shell command  */ {
500
    /* name     */ "unittest:EEPROM",
501
    /* callback */ _utShellCmdCb_AlldAt24c01b,
502
    /* next     */ NULL,
503
  },
504
  /* data           */ &_utAlldAt24c01bData,
505
};
506

    
507
/*
508
 * INA219 (power monitor)
509
 */
510
static int _utShellCmdCb_AlldIna219(BaseSequentialStream* stream, int argc, char* argv[])
511
{
512
  (void)argc;
513
  (void)argv;
514
  aosUtRun(stream, &moduleUtAlldIna219, "VLED (4.2V)");
515
  return AOS_OK;
516
}
517
static ut_ina219data_t _utIna219Data = {
518
  /* driver           */ &moduleLldPowerMonitorVled,
519
  /* expected voltage */ 4.2f,
520
  /* tolerance        */ 0.2f,
521
  /* timeout */ MICROSECONDS_PER_SECOND,
522
};
523
aos_unittest_t moduleUtAlldIna219 = {
524
  /* name           */ "INA219",
525
  /* info           */ "power monitor",
526
  /* test function  */ utAlldIna219Func,
527
  /* shell command  */ {
528
    /* name     */ "unittest:PowerMonitor",
529
    /* callback */ _utShellCmdCb_AlldIna219,
530
    /* next     */ NULL,
531
  },
532
  /* data           */ &_utIna219Data,
533
};
534

    
535
/*
536
 * Status LED
537
 */
538
static int _utShellCmdCb_AlldLed(BaseSequentialStream* stream, int argc, char* argv[])
539
{
540
  (void)argc;
541
  (void)argv;
542
  aosUtRun(stream, &moduleUtAlldLed, NULL);
543
  return AOS_OK;
544
}
545
aos_unittest_t moduleUtAlldLed = {
546
  /* name           */ "LED",
547
  /* info           */ NULL,
548
  /* test function  */ utAlldLedFunc,
549
  /* shell command  */ {
550
    /* name     */ "unittest:StatusLED",
551
    /* callback */ _utShellCmdCb_AlldLed,
552
    /* next     */ NULL,
553
  },
554
  /* data           */ &moduleLldStatusLed,
555
};
556

    
557
/*
558
 * Power switch driver (MIC9404x)
559
 */
560
static int _utShellCmdCb_Mic9404x(BaseSequentialStream* stream, int argc, char* argv[])
561
{
562
  // evaluate arguments
563
  if (argc == 2) {
564
    if (strcmp(argv[1], "1.8V") == 0) {
565
      moduleUtAlldMic9404x.data = &moduleLldPowerSwitchV18;
566
      aosUtRun(stream, &moduleUtAlldMic9404x, "1.8V");
567
      moduleUtAlldMic9404x.data = NULL;
568
      return AOS_OK;
569
    }
570
    else if (strcmp(argv[1], "3.3V") == 0) {
571
      moduleUtAlldMic9404x.data = &moduleLldPowerSwitchV33;
572
      aosUtRun(stream, &moduleUtAlldMic9404x, "3.3V");
573
      moduleUtAlldMic9404x.data = NULL;
574
      return AOS_OK;
575
    }
576
// The 4.2V switch is disabled due to a hardware bug.
577
//    else if (strcmp(argv[1], "4.2V") == 0) {
578
//      moduleUtAlldMic9404x.data = &moduleLldPowerSwitchV42;
579
//      aosUtRun(stream, &moduleUtAlldMic9404x, "4.2V");
580
//      moduleUtAlldMic9404x.data = NULL;
581
//      return AOS_OK;
582
//    }
583
    else if (strcmp(argv[1], "5.0V") == 0) {
584
      moduleUtAlldMic9404x.data = &moduleLldPowerSwitchV50;
585
      aosUtRun(stream, &moduleUtAlldMic9404x, "5.0V");
586
      moduleUtAlldMic9404x.data = NULL;
587
      return AOS_OK;
588
    }
589
    else if (strcmp(argv[1], "VSYS") == 0) {
590
      moduleUtAlldMic9404x.data = &moduleLldPowerSwitchVsys;
591
      aosUtRun(stream, &moduleUtAlldMic9404x, "VSYS");
592
      moduleUtAlldMic9404x.data = NULL;
593
      return AOS_OK;
594
    }
595
  }
596
  // print help
597
  chprintf(stream, "Usage: %s OPTION\n", argv[0]);
598
  chprintf(stream, "Options:\n");
599
  chprintf(stream, "  1.8V\n");
600
  chprintf(stream, "    Test power switch for 1.8V supply.\n");
601
  chprintf(stream, "  3.3V\n");
602
  chprintf(stream, "    Test power switch for 3.3V supply.\n");
603
// The 4.2V switch is disabled due to a hardware bug.
604
//  chprintf(stream, "  4.2V\n");
605
//  chprintf(stream, "    Test power switch for 4.2V supply.\n");
606
  chprintf(stream, "  5.0V\n");
607
  chprintf(stream, "    Test power switch for 5.0V supply.\n");
608
  chprintf(stream, "  VSYS\n");
609
  chprintf(stream, "    Test power switch for VSYS supply.\n");
610
  return AOS_INVALIDARGUMENTS;
611
}
612
aos_unittest_t moduleUtAlldMic9404x = {
613
  /* info           */ "MIC9404x",
614
  /* name           */ "power swicth driver",
615
  /* test function  */ utAlldMic9404xFunc,
616
  /* shell command  */ {
617
    /* name     */ "unittest:PowerSwitch",
618
    /* callback */ _utShellCmdCb_Mic9404x,
619
    /* next     */ NULL,
620
  },
621
  /* data           */ NULL,
622
};
623

    
624
/*
625
 * LED PWM driver (TLC5947)
626
 */
627
static int _utShellCmdCb_Tlc5947(BaseSequentialStream* stream, int argc, char* argv[])
628
{
629
  (void)argc;
630
  (void)argv;
631
  aosUtRun(stream, &moduleUtAlldTlc5947, NULL);
632
  return AOS_OK;
633
}
634
aos_unittest_t moduleUtAlldTlc5947 = {
635
  /* info           */ "TLC5947",
636
  /* name           */ "LED PWM driver",
637
  /* test function  */ utAlldTlc5947Func,
638
  /* shell command  */ {
639
    /* name     */ "unittest:Lights",
640
    /* callback */ _utShellCmdCb_Tlc5947,
641
    /* next     */ NULL,
642
  },
643
  /* data           */ &moduleLldLedPwm,
644
};
645

    
646
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */
647

    
648
/** @} */
649
/** @} */