amiro-os / modules / LightRing_1-2 / module.c @ b23ca7cc
History | View | Annotate | Download (21.201 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 */ APAL_GPIO_ACTIVE_LOW,
|
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 |
// TODO: add SNx5C3221E
|
465 |
|
466 |
TLC5947Driver moduleLldLedPwm = { |
467 |
/* SPI driver */ &MODULE_HAL_SPI_LIGHT,
|
468 |
/* BLANK signal GPIO */ &moduleGpioLightBlank,
|
469 |
/* XLAT signal GPIO */ &moduleGpioLightXlat,
|
470 |
}; |
471 |
|
472 |
/** @} */
|
473 |
|
474 |
/*===========================================================================*/
|
475 |
/**
|
476 |
* @name Tests
|
477 |
* @{
|
478 |
*/
|
479 |
/*===========================================================================*/
|
480 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
481 |
|
482 |
/*
|
483 |
* AT24C01BN-SH-B (EEPROM)
|
484 |
*/
|
485 |
#include <module_test_AT24C01B.h> |
486 |
static int _testAt24co1bShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
487 |
{ |
488 |
return moduleTestAt24c01bShellCb(stream, argc, argv, NULL); |
489 |
} |
490 |
AOS_SHELL_COMMAND(moduleTestAt24c01bShellCmd, "test:EEPROM", _testAt24co1bShellCmdCb);
|
491 |
|
492 |
/*
|
493 |
* INA219 (power monitor)
|
494 |
*/
|
495 |
#include <module_test_INA219.h> |
496 |
static int _testIna219ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
497 |
{ |
498 |
return moduleTestIna219ShellCb(stream, argc, argv, NULL); |
499 |
} |
500 |
AOS_SHELL_COMMAND(moduleTestIna219ShellCmd, "test:PowerMonitor", _testIna219ShellCmdCb);
|
501 |
|
502 |
/*
|
503 |
* Status LED
|
504 |
*/
|
505 |
#include <module_test_LED.h> |
506 |
static int _testLedShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
507 |
{ |
508 |
return moduleTestLedShellCb(stream, argc, argv, NULL); |
509 |
} |
510 |
AOS_SHELL_COMMAND(moduleTestLedShellCmd, "test:StatusLED", _testLedShellCmdCb);
|
511 |
|
512 |
/*
|
513 |
* MIC9404x (power switch)
|
514 |
*/
|
515 |
#include <module_test_MIC9404x.h> |
516 |
static int _testMic9404xShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
517 |
{ |
518 |
return moduleTestMic9404xShellCb(stream, argc, argv, NULL); |
519 |
} |
520 |
AOS_SHELL_COMMAND(moduleTestMic9404xShellCmd, "test:PowerSwitch", _testMic9404xShellCmdCb);
|
521 |
|
522 |
// TODO: add SNx5C3221E
|
523 |
|
524 |
/*
|
525 |
* TLC5947 (24 channel PWM LED driver)
|
526 |
*/
|
527 |
#include <module_test_TLC5947.h> |
528 |
static int _testTlc5947ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
529 |
{ |
530 |
return moduleTestTlc5947ShellCb(stream, argc, argv, NULL); |
531 |
} |
532 |
AOS_SHELL_COMMAND(moduleTestTlc5947ShellCmd, "test:Lights", _testTlc5947ShellCmdCb);
|
533 |
|
534 |
/*
|
535 |
* entire module
|
536 |
*/
|
537 |
static int _testAllShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
538 |
{ |
539 |
(void)argc;
|
540 |
(void)argv;
|
541 |
|
542 |
int status = AOS_OK;
|
543 |
char* targv[AMIROOS_CFG_SHELL_MAXARGS] = {NULL}; |
544 |
aos_testresult_t result_test = {0, 0}; |
545 |
aos_testresult_t result_total = {0, 0}; |
546 |
|
547 |
/* AT24C01B (EEPROM) */
|
548 |
status |= moduleTestAt24c01bShellCb(stream, 0, targv, &result_test);
|
549 |
result_total = aosTestResultAdd(result_total, result_test); |
550 |
|
551 |
/* INA219 (power monitor) */
|
552 |
status |= moduleTestIna219ShellCb(stream, 0, targv, &result_test);
|
553 |
result_total = aosTestResultAdd(result_total, result_test); |
554 |
|
555 |
/* Status LED */
|
556 |
status |= moduleTestLedShellCb(stream, 0, targv, &result_test);
|
557 |
result_total = aosTestResultAdd(result_total, result_test); |
558 |
|
559 |
/* MIC9404x (power switch) */
|
560 |
// 1.8V
|
561 |
targv[1] = "1.8V"; |
562 |
status |= moduleTestMic9404xShellCb(stream, 2, targv, &result_test);
|
563 |
result_total = aosTestResultAdd(result_total, result_test); |
564 |
// 3.3V
|
565 |
targv[1] = "3.3V"; |
566 |
status |= moduleTestMic9404xShellCb(stream, 2, targv, &result_test);
|
567 |
result_total = aosTestResultAdd(result_total, result_test); |
568 |
// The 4.2V switch is disabled due to a hardware bug.
|
569 |
// // 4.2V
|
570 |
// targv[1] = "4.2V";
|
571 |
// status |= moduleTestMic9404xShellCb(stream, 2, targv, &result_test);
|
572 |
// result_total = aosTestResultAdd(result_total, result_test);
|
573 |
// 5.0V
|
574 |
targv[1] = "5.0V"; |
575 |
status |= moduleTestMic9404xShellCb(stream, 2, targv, &result_test);
|
576 |
result_total = aosTestResultAdd(result_total, result_test); |
577 |
//VSYS
|
578 |
targv[1] = "VSYS"; |
579 |
status |= moduleTestMic9404xShellCb(stream, 2, targv, &result_test);
|
580 |
result_total = aosTestResultAdd(result_total, result_test); |
581 |
targv[1] = ""; |
582 |
|
583 |
// TODO: add SNx5C3221E
|
584 |
|
585 |
/* TLC5947 (24 channel PWM LED driver) */
|
586 |
status |= moduleTestTlc5947ShellCb(stream, 0, targv, &result_test);
|
587 |
result_total = aosTestResultAdd(result_total, result_test); |
588 |
|
589 |
// print total result
|
590 |
chprintf(stream, "\n");
|
591 |
aosTestResultPrintSummary(stream, &result_total, "entire module");
|
592 |
|
593 |
return status;
|
594 |
} |
595 |
AOS_SHELL_COMMAND(moduleTestAllShellCmd, "test:all", _testAllShellCmdCb);
|
596 |
|
597 |
|
598 |
|
599 |
|
600 |
//#include <string.h>
|
601 |
|
602 |
///*
|
603 |
// * EEPROM (AT24C01B)
|
604 |
// */
|
605 |
//static int _utShellCmdCb_AlldAt24c01b(BaseSequentialStream* stream, int argc, char* argv[])
|
606 |
//{
|
607 |
// (void)argc;
|
608 |
// (void)argv;
|
609 |
// aosUtRun(stream, &moduleUtAlldAt24c01b, NULL);
|
610 |
// return AOS_OK;
|
611 |
//}
|
612 |
//static ut_at24c01bdata_t _utAlldAt24c01bData = {
|
613 |
// /* driver */ &moduleLldEeprom,
|
614 |
// /* timeout */ MICROSECONDS_PER_SECOND,
|
615 |
//};
|
616 |
//aos_unittest_t moduleUtAlldAt24c01b = {
|
617 |
// /* name */ "AT24C01B",
|
618 |
// /* info */ "1kbit EEPROM",
|
619 |
// /* test function */ utAlldAt24c01bFunc,
|
620 |
// /* shell command */ {
|
621 |
// /* name */ "unittest:EEPROM",
|
622 |
// /* callback */ _utShellCmdCb_AlldAt24c01b,
|
623 |
// /* next */ NULL,
|
624 |
// },
|
625 |
// /* data */ &_utAlldAt24c01bData,
|
626 |
//};
|
627 |
|
628 |
///*
|
629 |
// * INA219 (power monitor)
|
630 |
// */
|
631 |
//static int _utShellCmdCb_AlldIna219(BaseSequentialStream* stream, int argc, char* argv[])
|
632 |
//{
|
633 |
// (void)argc;
|
634 |
// (void)argv;
|
635 |
// aosUtRun(stream, &moduleUtAlldIna219, "VLED (4.2V)");
|
636 |
// return AOS_OK;
|
637 |
//}
|
638 |
//static ut_ina219data_t _utIna219Data = {
|
639 |
// /* driver */ &moduleLldPowerMonitorVled,
|
640 |
// /* expected voltage */ 4.2f,
|
641 |
// /* tolerance */ 0.2f,
|
642 |
// /* timeout */ MICROSECONDS_PER_SECOND,
|
643 |
//};
|
644 |
//aos_unittest_t moduleUtAlldIna219 = {
|
645 |
// /* name */ "INA219",
|
646 |
// /* info */ "power monitor",
|
647 |
// /* test function */ utAlldIna219Func,
|
648 |
// /* shell command */ {
|
649 |
// /* name */ "unittest:PowerMonitor",
|
650 |
// /* callback */ _utShellCmdCb_AlldIna219,
|
651 |
// /* next */ NULL,
|
652 |
// },
|
653 |
// /* data */ &_utIna219Data,
|
654 |
//};
|
655 |
|
656 |
///*
|
657 |
// * Status LED
|
658 |
// */
|
659 |
//static int _utShellCmdCb_AlldLed(BaseSequentialStream* stream, int argc, char* argv[])
|
660 |
//{
|
661 |
// (void)argc;
|
662 |
// (void)argv;
|
663 |
// aosUtRun(stream, &moduleUtAlldLed, NULL);
|
664 |
// return AOS_OK;
|
665 |
//}
|
666 |
//aos_unittest_t moduleUtAlldLed = {
|
667 |
// /* name */ "LED",
|
668 |
// /* info */ NULL,
|
669 |
// /* test function */ utAlldLedFunc,
|
670 |
// /* shell command */ {
|
671 |
// /* name */ "unittest:StatusLED",
|
672 |
// /* callback */ _utShellCmdCb_AlldLed,
|
673 |
// /* next */ NULL,
|
674 |
// },
|
675 |
// /* data */ &moduleLldStatusLed,
|
676 |
//};
|
677 |
|
678 |
///*
|
679 |
// * Power switch driver (MIC9404x)
|
680 |
// */
|
681 |
//static int _utShellCmdCb_Mic9404x(BaseSequentialStream* stream, int argc, char* argv[])
|
682 |
//{
|
683 |
// // evaluate arguments
|
684 |
// if (argc == 2) {
|
685 |
// if (strcmp(argv[1], "1.8V") == 0) {
|
686 |
// moduleUtAlldMic9404x.data = &moduleLldPowerSwitchV18;
|
687 |
// aosUtRun(stream, &moduleUtAlldMic9404x, "1.8V");
|
688 |
// moduleUtAlldMic9404x.data = NULL;
|
689 |
// return AOS_OK;
|
690 |
// }
|
691 |
// else if (strcmp(argv[1], "3.3V") == 0) {
|
692 |
// moduleUtAlldMic9404x.data = &moduleLldPowerSwitchV33;
|
693 |
// aosUtRun(stream, &moduleUtAlldMic9404x, "3.3V");
|
694 |
// moduleUtAlldMic9404x.data = NULL;
|
695 |
// return AOS_OK;
|
696 |
// }
|
697 |
//// The 4.2V switch is disabled due to a hardware bug.
|
698 |
//// else if (strcmp(argv[1], "4.2V") == 0) {
|
699 |
//// moduleUtAlldMic9404x.data = &moduleLldPowerSwitchV42;
|
700 |
//// aosUtRun(stream, &moduleUtAlldMic9404x, "4.2V");
|
701 |
//// moduleUtAlldMic9404x.data = NULL;
|
702 |
//// return AOS_OK;
|
703 |
//// }
|
704 |
// else if (strcmp(argv[1], "5.0V") == 0) {
|
705 |
// moduleUtAlldMic9404x.data = &moduleLldPowerSwitchV50;
|
706 |
// aosUtRun(stream, &moduleUtAlldMic9404x, "5.0V");
|
707 |
// moduleUtAlldMic9404x.data = NULL;
|
708 |
// return AOS_OK;
|
709 |
// }
|
710 |
// else if (strcmp(argv[1], "VSYS") == 0) {
|
711 |
// moduleUtAlldMic9404x.data = &moduleLldPowerSwitchVsys;
|
712 |
// aosUtRun(stream, &moduleUtAlldMic9404x, "VSYS");
|
713 |
// moduleUtAlldMic9404x.data = NULL;
|
714 |
// return AOS_OK;
|
715 |
// }
|
716 |
// }
|
717 |
// // print help
|
718 |
// chprintf(stream, "Usage: %s OPTION\n", argv[0]);
|
719 |
// chprintf(stream, "Options:\n");
|
720 |
// chprintf(stream, " 1.8V\n");
|
721 |
// chprintf(stream, " Test power switch for 1.8V supply.\n");
|
722 |
// chprintf(stream, " 3.3V\n");
|
723 |
// chprintf(stream, " Test power switch for 3.3V supply.\n");
|
724 |
//// The 4.2V switch is disabled due to a hardware bug.
|
725 |
//// chprintf(stream, " 4.2V\n");
|
726 |
//// chprintf(stream, " Test power switch for 4.2V supply.\n");
|
727 |
// chprintf(stream, " 5.0V\n");
|
728 |
// chprintf(stream, " Test power switch for 5.0V supply.\n");
|
729 |
// chprintf(stream, " VSYS\n");
|
730 |
// chprintf(stream, " Test power switch for VSYS supply.\n");
|
731 |
// return AOS_INVALIDARGUMENTS;
|
732 |
//}
|
733 |
//aos_unittest_t moduleUtAlldMic9404x = {
|
734 |
// /* info */ "MIC9404x",
|
735 |
// /* name */ "power swicth driver",
|
736 |
// /* test function */ utAlldMic9404xFunc,
|
737 |
// /* shell command */ {
|
738 |
// /* name */ "unittest:PowerSwitch",
|
739 |
// /* callback */ _utShellCmdCb_Mic9404x,
|
740 |
// /* next */ NULL,
|
741 |
// },
|
742 |
// /* data */ NULL,
|
743 |
//};
|
744 |
|
745 |
///*
|
746 |
// * LED PWM driver (TLC5947)
|
747 |
// */
|
748 |
//static int _utShellCmdCb_Tlc5947(BaseSequentialStream* stream, int argc, char* argv[])
|
749 |
//{
|
750 |
// (void)argc;
|
751 |
// (void)argv;
|
752 |
// aosUtRun(stream, &moduleUtAlldTlc5947, NULL);
|
753 |
// return AOS_OK;
|
754 |
//}
|
755 |
//aos_unittest_t moduleUtAlldTlc5947 = {
|
756 |
// /* info */ "TLC5947",
|
757 |
// /* name */ "LED PWM driver",
|
758 |
// /* test function */ utAlldTlc5947Func,
|
759 |
// /* shell command */ {
|
760 |
// /* name */ "unittest:Lights",
|
761 |
// /* callback */ _utShellCmdCb_Tlc5947,
|
762 |
// /* next */ NULL,
|
763 |
// },
|
764 |
// /* data */ &moduleLldLedPwm,
|
765 |
//};
|
766 |
|
767 |
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
768 |
|
769 |
/** @} */
|
770 |
/** @} */
|