Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (16.566 KB)

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

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

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

15
You should have received a copy of the GNU General Public License
16
along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
/**
20
 * @file
21 034cb15a Thomas Schöpping
 * @brief   Structures and constant for the LightRing v1.2 module.
22 9ae7c4f3 Thomas Schöpping
 *
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 ee884101 Thomas Schöpping
I2CConfig moduleHalI2cEepromPwrmtrBreakoutConfig = {
51 9ae7c4f3 Thomas Schöpping
  /* 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 3106e8cc Thomas Schöpping
  /* chip select line port       */ PAL_PORT(LINE_LIGHT_XLAT),
67
  /* chip select line pad number */ PAL_PAD(LINE_LIGHT_XLAT),
68 9ae7c4f3 Thomas Schöpping
  /* 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 3106e8cc Thomas Schöpping
  /* line */ LINE_LIGHT_BLANK,
85 9ae7c4f3 Thomas Schöpping
};
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 3106e8cc Thomas Schöpping
  /* line */ LINE_RS232_R_EN_N,
100 9ae7c4f3 Thomas Schöpping
};
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 3106e8cc Thomas Schöpping
  /* line */ LINE_SW_V33_EN,
115 9ae7c4f3 Thomas Schöpping
};
116
ROMCONST apalControlGpio_t moduleGpioSwV33En = {
117
  /* GPIO */ &_gpioSwV33En,
118
  /* meta */ {
119
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
120 ee884101 Thomas Schöpping
    /* active state   */ MIC9404x_LLD_EN_ACTIVE_STATE,
121 9ae7c4f3 Thomas Schöpping
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
122
  },
123
};
124
125 9acb8326 Thomas Schöpping
// 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 9ae7c4f3 Thomas Schöpping
141
/**
142
 * @brief   SW_V50_EN output signal GPIO.
143
 */
144
static apalGpio_t _gpioSwV50En = {
145 3106e8cc Thomas Schöpping
  /* line */ LINE_SW_V50_EN,
146 9ae7c4f3 Thomas Schöpping
};
147
ROMCONST apalControlGpio_t moduleGpioSwV50En = {
148
  /* GPIO */ &_gpioSwV50En,
149
  /* meta */ {
150
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
151 ee884101 Thomas Schöpping
    /* active state   */ MIC9404x_LLD_EN_ACTIVE_STATE,
152 9ae7c4f3 Thomas Schöpping
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
153
  },
154
};
155
156
/**
157
 * @brief   IO_3 breakout signal GPIO.
158
 */
159
static apalGpio_t _gpioBreakoutIo3 = {
160 3106e8cc Thomas Schöpping
  /* line */ LINE_IO_3,
161 9ae7c4f3 Thomas Schöpping
};
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 3106e8cc Thomas Schöpping
  /* line */ LINE_IO_5,
176 9ae7c4f3 Thomas Schöpping
};
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 3106e8cc Thomas Schöpping
  /* line */ LINE_IO_6,
191 9ae7c4f3 Thomas Schöpping
};
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 3106e8cc Thomas Schöpping
  /* line */ LINE_SYS_UART_DN,
206 9ae7c4f3 Thomas Schöpping
};
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 3106e8cc Thomas Schöpping
  /* line */ LINE_IO_7,
221 9ae7c4f3 Thomas Schöpping
};
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 3106e8cc Thomas Schöpping
  /* line */ LINE_IO_8,
236 9ae7c4f3 Thomas Schöpping
};
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 3106e8cc Thomas Schöpping
  /* line */ LINE_IO_4,
251 9ae7c4f3 Thomas Schöpping
};
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 3106e8cc Thomas Schöpping
  /* line */ LINE_IO_1,
266 9ae7c4f3 Thomas Schöpping
};
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 3106e8cc Thomas Schöpping
  /* line */ LINE_IO_2,
281 9ae7c4f3 Thomas Schöpping
};
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 3106e8cc Thomas Schöpping
  /* line */ LINE_LED,
296 9ae7c4f3 Thomas Schöpping
};
297
ROMCONST apalControlGpio_t moduleGpioLed = {
298
  /* GPIO */ &_gpioLed,
299
  /* meta */ {
300
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
301 4c72a54c Thomas Schöpping
    /* active state   */ APAL_GPIO_ACTIVE_LOW,
302 9ae7c4f3 Thomas Schöpping
    /* interrupt edge */ APAL_GPIO_EDGE_NONE,
303
  },
304
};
305
306
/**
307 c930aa01 Thomas Schöpping
 * @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 9ae7c4f3 Thomas Schöpping
 * @brief   SW_V18_EN output signal GPIO.
323
 */
324
static apalGpio_t _gpioSwV18En = {
325 3106e8cc Thomas Schöpping
  /* line */ LINE_SW_V18_EN,
326 9ae7c4f3 Thomas Schöpping
};
327
ROMCONST apalControlGpio_t moduleGpioSwV18En = {
328
  /* GPIO */ &_gpioSwV18En,
329
  /* meta */ {
330
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
331 ee884101 Thomas Schöpping
    /* active state   */ MIC9404x_LLD_EN_ACTIVE_STATE,
332 9ae7c4f3 Thomas Schöpping
    /* 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 3106e8cc Thomas Schöpping
  /* line */ LINE_SW_VSYS_EN,
341 9ae7c4f3 Thomas Schöpping
};
342
ROMCONST apalControlGpio_t moduleGpioSwVsysEn = {
343
  /* GPIO */ &_gpioSwVsysEn,
344
  /* meta */ {
345
    /* direction      */ APAL_GPIO_DIRECTION_OUTPUT,
346 ee884101 Thomas Schöpping
    /* active state   */ APAL_GPIO_ACTIVE_HIGH,
347 9ae7c4f3 Thomas Schöpping
    /* 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 3106e8cc Thomas Schöpping
  /* line */ LINE_SYS_UART_UP,
356 9ae7c4f3 Thomas Schöpping
};
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 3106e8cc Thomas Schöpping
  /* line */ LINE_SYS_PD_N,
371 9ae7c4f3 Thomas Schöpping
};
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 3106e8cc Thomas Schöpping
  /* line */ LINE_SYS_INT_N,
386 9ae7c4f3 Thomas Schöpping
};
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 ee884101 Thomas Schöpping
  /* I2C driver   */ &MODULE_HAL_I2C_EEPROM_PWRMTR_BREAKOUT,
429 9ae7c4f3 Thomas Schöpping
  /* I2C address  */ 0x00u,
430
};
431
432 ee884101 Thomas Schöpping
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 c4989d30 Julia Niermann
P9221RDriver moduleQiCharger = {
440
  /* I2C Driver       */ &MODULE_HAL_I2C_EEPROM_PWRMTR_BREAKOUT,
441
  /* I²C address      */ P9221R_LLD_I2C_ADDR_FIXED,
442
  /* current LSB (uA) */ 0x00u,
443
  /* configuration    */ NULL,
444
};
445
446 ee884101 Thomas Schöpping
LEDDriver moduleLldStatusLed = {
447
  /* LED enable Gpio */ &moduleGpioLed,
448
};
449
450
MIC9404xDriver moduleLldPowerSwitchV18 = {
451
  /* power enable GPIO  */ &moduleGpioSwV18En,
452
};
453
454
MIC9404xDriver moduleLldPowerSwitchV33 = {
455
  /* power enable GPIO  */ &moduleGpioSwV33En,
456
};
457
458 9acb8326 Thomas Schöpping
// The 4.2V switch is disabled due to a hardware bug.
459
//MIC9404xDriver moduleLldPowerSwitchV42 = {
460
//  /* power enable GPIO  */ &moduleGpioSwV42En,
461
//};
462 ee884101 Thomas Schöpping
463
MIC9404xDriver moduleLldPowerSwitchV50 = {
464
  /* power enable GPIO  */ &moduleGpioSwV50En,
465
};
466
467
MIC9404xDriver moduleLldPowerSwitchVsys = {
468
  /* power enable GPIO  */ &moduleGpioSwVsysEn,
469
};
470
471 4c72a54c Thomas Schöpping
// TODO: add SNx5C3221E
472
473 9ae7c4f3 Thomas Schöpping
TLC5947Driver moduleLldLedPwm = {
474
  /* SPI driver         */ &MODULE_HAL_SPI_LIGHT,
475
  /* BLANK signal GPIO  */ &moduleGpioLightBlank,
476 c930aa01 Thomas Schöpping
  /* XLAT signal GPIO   */ &moduleGpioLightXlat,
477 9ae7c4f3 Thomas Schöpping
};
478
479
/** @} */
480
481
/*===========================================================================*/
482
/**
483 4c72a54c Thomas Schöpping
 * @name Tests
484 9ae7c4f3 Thomas Schöpping
 * @{
485
 */
486
/*===========================================================================*/
487
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
488
489
/*
490 4c72a54c Thomas Schöpping
 * AT24C01BN-SH-B (EEPROM)
491 9ae7c4f3 Thomas Schöpping
 */
492 4c72a54c Thomas Schöpping
#include <module_test_AT24C01B.h>
493
static int _testAt24co1bShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
494 9ae7c4f3 Thomas Schöpping
{
495 4c72a54c Thomas Schöpping
  return moduleTestAt24c01bShellCb(stream, argc, argv, NULL);
496 9ae7c4f3 Thomas Schöpping
}
497 4c72a54c Thomas Schöpping
AOS_SHELL_COMMAND(moduleTestAt24c01bShellCmd, "test:EEPROM", _testAt24co1bShellCmdCb);
498 9ae7c4f3 Thomas Schöpping
499
/*
500 ee884101 Thomas Schöpping
 * INA219 (power monitor)
501
 */
502 4c72a54c Thomas Schöpping
#include <module_test_INA219.h>
503
static int _testIna219ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
504 ee884101 Thomas Schöpping
{
505 4c72a54c Thomas Schöpping
  return moduleTestIna219ShellCb(stream, argc, argv, NULL);
506 ee884101 Thomas Schöpping
}
507 4c72a54c Thomas Schöpping
AOS_SHELL_COMMAND(moduleTestIna219ShellCmd, "test:PowerMonitor", _testIna219ShellCmdCb);
508 ee884101 Thomas Schöpping
509
/*
510 c4989d30 Julia Niermann
 * P9221R (qi charger)
511
 */
512 c60ee2dd Julia Niermann
#include <module_test_P9221R.h>
513
static int _testP9221rShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
514
{
515
  return moduleTestP9221rShellCb(stream, argc, argv, NULL);
516
}
517
AOS_SHELL_COMMAND(moduleTestP9221rShellCmd, "test:QiCharger", _testP9221rShellCmdCb);
518 5b1af1ae Julia Niermann
519
/*
520 ee884101 Thomas Schöpping
 * Status LED
521
 */
522 4c72a54c Thomas Schöpping
#include <module_test_LED.h>
523
static int _testLedShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
524 c4989d30 Julia Niermann
{
525 4c72a54c Thomas Schöpping
  return moduleTestLedShellCb(stream, argc, argv, NULL);
526 c4989d30 Julia Niermann
}
527 4c72a54c Thomas Schöpping
AOS_SHELL_COMMAND(moduleTestLedShellCmd, "test:StatusLED", _testLedShellCmdCb);
528 c4989d30 Julia Niermann
529
/*
530 4c72a54c Thomas Schöpping
 * MIC9404x (power switch)
531 ee884101 Thomas Schöpping
 */
532 4c72a54c Thomas Schöpping
#include <module_test_MIC9404x.h>
533
static int _testMic9404xShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
534 ee884101 Thomas Schöpping
{
535 4c72a54c Thomas Schöpping
  return moduleTestMic9404xShellCb(stream, argc, argv, NULL);
536 ee884101 Thomas Schöpping
}
537 4c72a54c Thomas Schöpping
AOS_SHELL_COMMAND(moduleTestMic9404xShellCmd, "test:PowerSwitch", _testMic9404xShellCmdCb);
538
539
// TODO: add SNx5C3221E
540 ee884101 Thomas Schöpping
541
/*
542 4c72a54c Thomas Schöpping
 * TLC5947 (24 channel PWM LED driver)
543 ee884101 Thomas Schöpping
 */
544 4c72a54c Thomas Schöpping
#include <module_test_TLC5947.h>
545
static int _testTlc5947ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
546 ee884101 Thomas Schöpping
{
547 4c72a54c Thomas Schöpping
  return moduleTestTlc5947ShellCb(stream, argc, argv, NULL);
548 ee884101 Thomas Schöpping
}
549 4c72a54c Thomas Schöpping
AOS_SHELL_COMMAND(moduleTestTlc5947ShellCmd, "test:Lights", _testTlc5947ShellCmdCb);
550 ee884101 Thomas Schöpping
551
/*
552 4c72a54c Thomas Schöpping
 * entire module
553 9ae7c4f3 Thomas Schöpping
 */
554 4c72a54c Thomas Schöpping
static int _testAllShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[])
555 9ae7c4f3 Thomas Schöpping
{
556
  (void)argc;
557
  (void)argv;
558 4c72a54c Thomas Schöpping
559
  int status = AOS_OK;
560
  char* targv[AMIROOS_CFG_SHELL_MAXARGS] = {NULL};
561
  aos_testresult_t result_test = {0, 0};
562
  aos_testresult_t result_total = {0, 0};
563
564
  /* AT24C01B (EEPROM) */
565
  status |= moduleTestAt24c01bShellCb(stream, 0, targv, &result_test);
566
  result_total = aosTestResultAdd(result_total, result_test);
567
568
  /* INA219 (power monitor) */
569
  status |= moduleTestIna219ShellCb(stream, 0, targv, &result_test);
570
  result_total = aosTestResultAdd(result_total, result_test);
571
572
  /* Status LED */
573
  status |= moduleTestLedShellCb(stream, 0, targv, &result_test);
574
  result_total = aosTestResultAdd(result_total, result_test);
575
576
  /* MIC9404x (power switch) */
577
  // 1.8V
578
  targv[1] = "1.8V";
579
  status |= moduleTestMic9404xShellCb(stream, 2, targv, &result_test);
580
  result_total = aosTestResultAdd(result_total, result_test);
581
  // 3.3V
582
  targv[1] = "3.3V";
583
  status |= moduleTestMic9404xShellCb(stream, 2, targv, &result_test);
584
  result_total = aosTestResultAdd(result_total, result_test);
585
// The 4.2V switch is disabled due to a hardware bug.
586
//  // 4.2V
587
//  targv[1] = "4.2V";
588
//  status |= moduleTestMic9404xShellCb(stream, 2, targv, &result_test);
589
//  result_total = aosTestResultAdd(result_total, result_test);
590
  // 5.0V
591
  targv[1] = "5.0V";
592
  status |= moduleTestMic9404xShellCb(stream, 2, targv, &result_test);
593
  result_total = aosTestResultAdd(result_total, result_test);
594
  //VSYS
595
  targv[1] = "VSYS";
596
  status |= moduleTestMic9404xShellCb(stream, 2, targv, &result_test);
597
  result_total = aosTestResultAdd(result_total, result_test);
598
  targv[1] = "";
599
600
  // TODO: add SNx5C3221E
601
602
  /* TLC5947 (24 channel PWM LED driver) */
603
  status |= moduleTestTlc5947ShellCb(stream, 0, targv, &result_test);
604
  result_total = aosTestResultAdd(result_total, result_test);
605
606
  // print total result
607
  chprintf(stream, "\n");
608
  aosTestResultPrintSummary(stream, &result_total, "entire module");
609
610
  return status;
611 9ae7c4f3 Thomas Schöpping
}
612 4c72a54c Thomas Schöpping
AOS_SHELL_COMMAND(moduleTestAllShellCmd, "test:all", _testAllShellCmdCb);
613
614 9ae7c4f3 Thomas Schöpping
615
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */
616
617
/** @} */
618
/** @} */