Revision ee884101 modules/LightRing_1-2/module.c
modules/LightRing_1-2/module.c | ||
---|---|---|
47 | 47 |
/* btr */ CAN_BTR_SJW(1) | CAN_BTR_TS2(2) | CAN_BTR_TS1(13) | CAN_BTR_BRP(1), |
48 | 48 |
}; |
49 | 49 |
|
50 |
I2CConfig moduleHalI2cEepromBreakoutConfig = { |
|
50 |
I2CConfig moduleHalI2cEepromPwrmtrBreakoutConfig = {
|
|
51 | 51 |
/* I²C mode */ OPMODE_I2C, |
52 | 52 |
/* frequency */ 400000, // TODO: replace with some macro (-> ChibiOS/HAL) |
53 | 53 |
/* duty cycle */ FAST_DUTY_CYCLE_2, |
... | ... | |
120 | 120 |
/* GPIO */ &_gpioSwV33En, |
121 | 121 |
/* meta */ { |
122 | 122 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT, |
123 |
/* active state */ APAL_GPIO_ACTIVE_HIGH, //TODO
|
|
123 |
/* active state */ MIC9404x_LLD_EN_ACTIVE_STATE,
|
|
124 | 124 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE, |
125 | 125 |
}, |
126 | 126 |
}; |
... | ... | |
136 | 136 |
/* GPIO */ &_gpioSwV42En, |
137 | 137 |
/* meta */ { |
138 | 138 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT, |
139 |
/* active state */ APAL_GPIO_ACTIVE_HIGH, //TODO
|
|
139 |
/* active state */ MIC9404x_LLD_EN_ACTIVE_STATE,
|
|
140 | 140 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE, |
141 | 141 |
}, |
142 | 142 |
}; |
... | ... | |
152 | 152 |
/* GPIO */ &_gpioSwV50En, |
153 | 153 |
/* meta */ { |
154 | 154 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT, |
155 |
/* active state */ APAL_GPIO_ACTIVE_HIGH, //TODO
|
|
155 |
/* active state */ MIC9404x_LLD_EN_ACTIVE_STATE,
|
|
156 | 156 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE, |
157 | 157 |
}, |
158 | 158 |
}; |
... | ... | |
344 | 344 |
/* GPIO */ &_gpioSwV18En, |
345 | 345 |
/* meta */ { |
346 | 346 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT, |
347 |
/* active state */ APAL_GPIO_ACTIVE_HIGH, //TODO
|
|
347 |
/* active state */ MIC9404x_LLD_EN_ACTIVE_STATE,
|
|
348 | 348 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE, |
349 | 349 |
}, |
350 | 350 |
}; |
... | ... | |
360 | 360 |
/* GPIO */ &_gpioSwVsysEn, |
361 | 361 |
/* meta */ { |
362 | 362 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT, |
363 |
/* active state */ APAL_GPIO_ACTIVE_HIGH, //TODO
|
|
363 |
/* active state */ APAL_GPIO_ACTIVE_HIGH, |
|
364 | 364 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE, |
365 | 365 |
}, |
366 | 366 |
}; |
... | ... | |
445 | 445 |
/*===========================================================================*/ |
446 | 446 |
|
447 | 447 |
AT24C01BDriver moduleLldEeprom = { |
448 |
/* I2C driver */ &MODULE_HAL_I2C_EEPROM_BREAKOUT, |
|
448 |
/* I2C driver */ &MODULE_HAL_I2C_EEPROM_PWRMTR_BREAKOUT,
|
|
449 | 449 |
/* I2C address */ 0x00u, |
450 | 450 |
}; |
451 | 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 |
|
|
452 | 483 |
TLC5947Driver moduleLldLedPwm = { |
453 | 484 |
/* SPI driver */ &MODULE_HAL_SPI_LIGHT, |
454 | 485 |
/* BLANK signal GPIO */ &moduleGpioLightBlank, |
... | ... | |
464 | 495 |
*/ |
465 | 496 |
/*===========================================================================*/ |
466 | 497 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
498 |
#include <string.h> |
|
467 | 499 |
|
468 | 500 |
/* |
469 | 501 |
* EEPROM (AT24C01B) |
... | ... | |
492 | 524 |
}; |
493 | 525 |
|
494 | 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_INVALID_ARGUMENTS; |
|
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 |
/* |
|
495 | 642 |
* LED PWM driver (TLC5947) |
496 | 643 |
*/ |
497 | 644 |
static int _utShellCmdCb_Tlc5947(BaseSequentialStream* stream, int argc, char* argv[]) |
Also available in: Unified diff