Revision 4c72a54c modules/PowerManagement_1-2/module.c
modules/PowerManagement_1-2/module.c | ||
---|---|---|
261 | 261 |
/* GPIO */ &_gpioLed, |
262 | 262 |
/* meta */ { |
263 | 263 |
/* direction */ APAL_GPIO_DIRECTION_OUTPUT, |
264 |
/* active state */ LED_LLD_GPIO_ACTIVE_STATE,
|
|
264 |
/* active state */ APAL_GPIO_ACTIVE_LOW,
|
|
265 | 265 |
/* interrupt edge */ APAL_GPIO_EDGE_NONE, |
266 | 266 |
}, |
267 | 267 |
}; |
... | ... | |
697 | 697 |
|
698 | 698 |
/*===========================================================================*/ |
699 | 699 |
/** |
700 |
* @name Unit tests (UT)
|
|
700 |
* @name Tests
|
|
701 | 701 |
* @{ |
702 | 702 |
*/ |
703 | 703 |
/*===========================================================================*/ |
704 | 704 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
705 |
#include <string.h> |
|
706 | 705 |
|
707 | 706 |
/* |
708 |
* ADC |
|
707 |
* ADC (VSYS)
|
|
709 | 708 |
*/ |
710 |
static int _utShellCmdCb_Adc(BaseSequentialStream* stream, int argc, char* argv[]) |
|
709 |
#include <module_test_adc.h> |
|
710 |
static int _testAdcShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
|
711 | 711 |
{ |
712 |
(void)argc; |
|
713 |
(void)argv; |
|
714 |
aosUtRun(stream, &moduleUtAdcVsys, NULL); |
|
715 |
return AOS_OK; |
|
712 |
return moduleTestAdcShellCb(stream, argc, argv, NULL); |
|
716 | 713 |
} |
717 |
static ut_adcdata_t _utAdcVsysData = { |
|
718 |
/* driver */ &MODULE_HAL_ADC_VSYS, |
|
719 |
/* ADC conversion group */ &moduleHalAdcVsysConversionGroup, |
|
720 |
}; |
|
721 |
aos_unittest_t moduleUtAdcVsys = { |
|
722 |
/* name */ "ADC", |
|
723 |
/* info */ "VSYS", |
|
724 |
/* test function */ utAdcFunc, |
|
725 |
/* shell command */ { |
|
726 |
/* name */ "unittest:ADC", |
|
727 |
/* callback */ _utShellCmdCb_Adc, |
|
728 |
/* next */ NULL, |
|
729 |
}, |
|
730 |
/* data */ &_utAdcVsysData, |
|
731 |
}; |
|
714 |
AOS_SHELL_COMMAND(moduleTestAdcShellCmd, "test:ADC", _testAdcShellCmdCb); |
|
732 | 715 |
|
733 | 716 |
/* |
734 |
* AT24C01B (EEPROM) |
|
717 |
* AT24C01BN-SH-B (EEPROM)
|
|
735 | 718 |
*/ |
736 |
static int _utShellCmdCb_AlldAt24c01b(BaseSequentialStream* stream, int argc, char* argv[]) |
|
719 |
#include <module_test_AT24C01B.h> |
|
720 |
static int _testAt24c01bShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
|
737 | 721 |
{ |
738 |
(void)argc; |
|
739 |
(void)argv; |
|
740 |
aosUtRun(stream, &moduleUtAlldAt24c01b, NULL); |
|
741 |
return AOS_OK; |
|
722 |
return moduleTestAt24c01bShellCb(stream, argc, argv, NULL); |
|
742 | 723 |
} |
743 |
static ut_at24c01bdata_t _utAlldAt24c01bData = { |
|
744 |
/* driver */ &moduleLldEeprom, |
|
745 |
/* timeout */ MICROSECONDS_PER_SECOND, |
|
746 |
}; |
|
747 |
aos_unittest_t moduleUtAlldAt24c01b = { |
|
748 |
/* name */ "AT24C01B", |
|
749 |
/* info */ "1kbit EEPROM", |
|
750 |
/* test function */ utAlldAt24c01bFunc, |
|
751 |
/* shell command */ { |
|
752 |
/* name */ "unittest:EEPROM", |
|
753 |
/* callback */ _utShellCmdCb_AlldAt24c01b, |
|
754 |
/* next */ NULL, |
|
755 |
}, |
|
756 |
/* data */ &_utAlldAt24c01bData, |
|
757 |
}; |
|
724 |
AOS_SHELL_COMMAND(moduleTestAt24c01bShellCmd, "test:EEPROM", _testAt24c01bShellCmdCb); |
|
758 | 725 |
|
759 | 726 |
/* |
760 | 727 |
* bq24103a (battery charger) |
761 | 728 |
*/ |
762 |
static int _utShellCmdCb_AlldBq24103a(BaseSequentialStream* stream, int argc, char* argv[]) |
|
729 |
#include <module_test_bq241xx.h> |
|
730 |
static int _testBq241xxShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
|
763 | 731 |
{ |
764 |
// local variables |
|
765 |
bool print_help = false; |
|
766 |
|
|
767 |
// evaluate argument |
|
768 |
if (argc == 2) { |
|
769 |
if (strcmp(argv[1], "-f") == 0 || strcmp(argv[1], "--front") == 0) { |
|
770 |
moduleUtAlldBq24103a.data = &moduleLldBatteryChargerFront; |
|
771 |
aosUtRun(stream, &moduleUtAlldBq24103a, "front battery"); |
|
772 |
moduleUtAlldBq24103a.data = NULL; |
|
773 |
} |
|
774 |
else if (strcmp(argv[1], "-r") == 0 || strcmp(argv[1], "--rear") == 0) { |
|
775 |
moduleUtAlldBq24103a.data = &moduleLldBatteryChargerRear; |
|
776 |
aosUtRun(stream, &moduleUtAlldBq24103a, "rear battery"); |
|
777 |
moduleUtAlldBq24103a.data = NULL; |
|
778 |
} |
|
779 |
else { |
|
780 |
print_help = true; |
|
781 |
} |
|
782 |
} else { |
|
783 |
print_help = true; |
|
784 |
} |
|
785 |
|
|
786 |
// print help or just return |
|
787 |
if (print_help) { |
|
788 |
chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
|
789 |
chprintf(stream, "Options:\n"); |
|
790 |
chprintf(stream, " --front, -f\n"); |
|
791 |
chprintf(stream, " Test the front battery charger.\n"); |
|
792 |
chprintf(stream, " --rear, -r\n"); |
|
793 |
chprintf(stream, " Test the rear battery charger.\n"); |
|
794 |
return AOS_INVALIDARGUMENTS; |
|
795 |
} else { |
|
796 |
return AOS_OK; |
|
797 |
} |
|
732 |
return moduleTestBq241xxShellCb(stream, argc, argv, NULL); |
|
798 | 733 |
} |
799 |
aos_unittest_t moduleUtAlldBq24103a = { |
|
800 |
/* name */ "bq24103a", |
|
801 |
/* info */ "battery charger", |
|
802 |
/* test function */ utAlldBq241xxFunc, |
|
803 |
/* shell command */ { |
|
804 |
/* name */ "unittest:BatteryCharger", |
|
805 |
/* callback */ _utShellCmdCb_AlldBq24103a, |
|
806 |
/* next */ NULL, |
|
807 |
}, |
|
808 |
/* data */ NULL, |
|
809 |
}; |
|
734 |
AOS_SHELL_COMMAND(moduleTestBq241xxShellCmd, "test:BatteryCharger", _testBq241xxShellCmdCb); |
|
810 | 735 |
|
811 | 736 |
/* |
812 | 737 |
* bq27500 (fuel gauge) |
813 | 738 |
*/ |
814 |
static int _utShellCmdCb_AlldBq27500(BaseSequentialStream* stream, int argc, char* argv[]) |
|
739 |
#include <module_test_bq27500.h> |
|
740 |
static int _testBq27500ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
|
815 | 741 |
{ |
816 |
// evaluate arguments |
|
817 |
if (argc == 2) { |
|
818 |
if (strcmp(argv[1], "-f") == 0 || strcmp(argv[1], "--front") == 0) { |
|
819 |
((ut_bq27500data_t*)moduleUtAlldBq27500.data)->driver = &moduleLldFuelGaugeFront; |
|
820 |
aosUtRun(stream, &moduleUtAlldBq27500, "front battery"); |
|
821 |
((ut_bq27500data_t*)moduleUtAlldBq27500.data)->driver = NULL; |
|
822 |
return AOS_OK; |
|
823 |
} |
|
824 |
else if (strcmp(argv[1], "-r") == 0 || strcmp(argv[1], "--rear") == 0) { |
|
825 |
((ut_bq27500data_t*)moduleUtAlldBq27500.data)->driver = &moduleLldFuelGaugeRear; |
|
826 |
aosUtRun(stream, &moduleUtAlldBq27500, "rear battery"); |
|
827 |
((ut_bq27500data_t*)moduleUtAlldBq27500.data)->driver = NULL; |
|
828 |
return AOS_OK; |
|
829 |
} |
|
830 |
} |
|
831 |
// print help |
|
832 |
chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
|
833 |
chprintf(stream, "Options:\n"); |
|
834 |
chprintf(stream, " --front, -f\n"); |
|
835 |
chprintf(stream, " Test the front battery fuel gauge.\n"); |
|
836 |
chprintf(stream, " --rear, -r\n"); |
|
837 |
chprintf(stream, " Test the rear battery fuel gauge.\n"); |
|
838 |
return AOS_INVALIDARGUMENTS; |
|
742 |
return moduleTestBq27500ShellCb(stream, argc, argv, NULL); |
|
839 | 743 |
} |
840 |
static ut_bq27500data_t _utAlldBq27500Data = { |
|
841 |
/* driver */ NULL, |
|
842 |
/* timeout */ MICROSECONDS_PER_SECOND, |
|
843 |
}; |
|
844 |
aos_unittest_t moduleUtAlldBq27500 = { |
|
845 |
/* name */ "bq27500", |
|
846 |
/* info */ "fuel gauge", |
|
847 |
/* test function */ utAlldBq27500Func, |
|
848 |
/* shell command */ { |
|
849 |
/* name */ "unittest:FuelGauge", |
|
850 |
/* callback */ _utShellCmdCb_AlldBq27500, |
|
851 |
/* next */ NULL, |
|
852 |
}, |
|
853 |
/* data */ &_utAlldBq27500Data, |
|
854 |
}; |
|
744 |
AOS_SHELL_COMMAND(moduleTestBq27500ShellCmd, "test:FuelGauge", _testBq27500ShellCmdCb); |
|
855 | 745 |
|
856 | 746 |
/* |
857 | 747 |
* bq27500 (fuel gauge) in combination with bq24103a (battery charger) |
858 | 748 |
*/ |
859 |
static int _utShellCmdCb_AlldBq27500Bq24103a(BaseSequentialStream* stream, int argc, char* argv[]) |
|
749 |
#include <module_test_bq27500_bq241xx.h> |
|
750 |
static int _testBq27500Bq241xxShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
|
860 | 751 |
{ |
861 |
// evaluate arguments |
|
862 |
if (argc == 2) { |
|
863 |
if (strcmp(argv[1], "-f") == 0 || strcmp(argv[1], "--front") == 0) { |
|
864 |
((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq27500 = &moduleLldFuelGaugeFront; |
|
865 |
((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq241xx = &moduleLldBatteryChargerFront; |
|
866 |
aosUtRun(stream, &moduleUtAlldBq27500Bq24103a, "front battery"); |
|
867 |
((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq27500 = NULL; |
|
868 |
((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq241xx = NULL; |
|
869 |
return AOS_OK; |
|
870 |
} |
|
871 |
else if (strcmp(argv[1], "-r") == 0 || strcmp(argv[1], "--rear") == 0) { |
|
872 |
((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq27500 = &moduleLldFuelGaugeRear; |
|
873 |
((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq241xx = &moduleLldBatteryChargerRear; |
|
874 |
aosUtRun(stream, &moduleUtAlldBq27500Bq24103a, "rear battery"); |
|
875 |
((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq27500 = NULL; |
|
876 |
((ut_bq27500bq241xxdata_t*)moduleUtAlldBq27500Bq24103a.data)->bq241xx = NULL; |
|
877 |
return AOS_OK; |
|
878 |
} |
|
879 |
} |
|
880 |
// print help |
|
881 |
chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
|
882 |
chprintf(stream, "Options:\n"); |
|
883 |
chprintf(stream, " --front, -f\n"); |
|
884 |
chprintf(stream, " Test the front battery fuel gauge and charger.\n"); |
|
885 |
chprintf(stream, " --rear, -r\n"); |
|
886 |
chprintf(stream, " Test the rear battery fuel gauge and charger.\n"); |
|
887 |
return AOS_INVALIDARGUMENTS; |
|
752 |
return moduleTestBq27500Bq241xxShellCb(stream, argc, argv, NULL); |
|
888 | 753 |
} |
889 |
static ut_bq27500bq241xxdata_t _utAlldBq27500Bq24103aData= { |
|
890 |
/* bq27500 driver */ NULL, |
|
891 |
/* bq24103a driver */ NULL, |
|
892 |
/* timeout */ MICROSECONDS_PER_SECOND, |
|
893 |
}; |
|
894 |
aos_unittest_t moduleUtAlldBq27500Bq24103a = { |
|
895 |
/* name */ "BQ27500 & BQ24103A", |
|
896 |
/* info */ "fuel gauge & battery charger", |
|
897 |
/* test function */ utAlldBq27500Bq241xxFunc, |
|
898 |
/* shell command */ { |
|
899 |
/* name */ "unittest:FuelGauge&BatteryCharger", |
|
900 |
/* callback */ _utShellCmdCb_AlldBq27500Bq24103a, |
|
901 |
/* next */ NULL, |
|
902 |
}, |
|
903 |
/* data */ &_utAlldBq27500Bq24103aData, |
|
904 |
}; |
|
754 |
AOS_SHELL_COMMAND(moduleTestBq27500Bq241xxShellCmd, "test:FuelGauge&BatteryCharger", _testBq27500Bq241xxShellCmdCb); |
|
905 | 755 |
|
906 | 756 |
/* |
907 | 757 |
* INA219 (power monitor) |
908 | 758 |
*/ |
909 |
static int _utShellCmdCb_AlldIna219(BaseSequentialStream* stream, int argc, char* argv[]) |
|
759 |
#include <module_test_INA219.h> |
|
760 |
static int _testIna219ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
|
910 | 761 |
{ |
911 |
// evaluate arguments |
|
912 |
if (argc == 2) { |
|
913 |
if (strcmp(argv[1], "VDD") == 0) { |
|
914 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVdd; |
|
915 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 3.3f; |
|
916 |
aosUtRun(stream, &moduleUtAlldIna219, "VDD (3.3V)"); |
|
917 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL; |
|
918 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f; |
|
919 |
return AOS_OK; |
|
920 |
} |
|
921 |
else if (strcmp(argv[1], "VIO1.8") == 0) { |
|
922 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVio18; |
|
923 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 1.8f; |
|
924 |
aosUtRun(stream, &moduleUtAlldIna219, "VIO (1.8V)"); |
|
925 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL; |
|
926 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f; |
|
927 |
return AOS_OK; |
|
928 |
} |
|
929 |
else if (strcmp(argv[1], "VIO3.3") == 0) { |
|
930 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVio33; |
|
931 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 3.3f; |
|
932 |
aosUtRun(stream, &moduleUtAlldIna219, "VIO (3.3V)"); |
|
933 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL; |
|
934 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f; |
|
935 |
return AOS_OK; |
|
936 |
} |
|
937 |
else if (strcmp(argv[1], "VSYS4.2") == 0) { |
|
938 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVsys42; |
|
939 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 4.2f; |
|
940 |
aosUtRun(stream, &moduleUtAlldIna219, "VSYS (4.2V)"); |
|
941 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL; |
|
942 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f; |
|
943 |
return AOS_OK; |
|
944 |
} |
|
945 |
else if (strcmp(argv[1], "VIO5.0") == 0) { |
|
946 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = &moduleLldPowerMonitorVio50; |
|
947 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 5.0f; |
|
948 |
aosUtRun(stream, &moduleUtAlldIna219, "VIO (5.0V)"); |
|
949 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->inad = NULL; |
|
950 |
((ut_ina219data_t*)moduleUtAlldIna219.data)->v_expected = 0.0f; |
|
951 |
return AOS_OK; |
|
952 |
} |
|
953 |
} |
|
954 |
// print help |
|
955 |
chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
|
956 |
chprintf(stream, "Options:\n"); |
|
957 |
chprintf(stream, " VDD\n"); |
|
958 |
chprintf(stream, " Test VDD (3.3V) power monitor.\n"); |
|
959 |
chprintf(stream, " VIO1.8\n"); |
|
960 |
chprintf(stream, " Test VIO 1.8V power monitor.\n"); |
|
961 |
chprintf(stream, " VIO3.3\n"); |
|
962 |
chprintf(stream, " Test VIO 3.3V power monitor.\n"); |
|
963 |
chprintf(stream, " VSYS4.2\n"); |
|
964 |
chprintf(stream, " Test VSYS 4.2V power monitor.\n"); |
|
965 |
chprintf(stream, " VIO5.0\n"); |
|
966 |
chprintf(stream, " Test VIO 5.0V power monitor.\n"); |
|
967 |
return AOS_INVALIDARGUMENTS; |
|
762 |
return moduleTestIna219ShellCb(stream, argc, argv, NULL); |
|
968 | 763 |
} |
969 |
static ut_ina219data_t _utAlldIna219Data = { |
|
970 |
/* driver */ NULL, |
|
971 |
/* expected voltage */ 0.0f, |
|
972 |
/* tolerance */ 0.05f, |
|
973 |
/* timeout */ MICROSECONDS_PER_SECOND, |
|
974 |
}; |
|
975 |
aos_unittest_t moduleUtAlldIna219 = { |
|
976 |
/* name */ "INA219", |
|
977 |
/* info */ "power monitor", |
|
978 |
/* test function */ utAlldIna219Func, |
|
979 |
/* shell command */ { |
|
980 |
/* name */ "unittest:PowerMonitor", |
|
981 |
/* callback */ _utShellCmdCb_AlldIna219, |
|
982 |
/* next */ NULL, |
|
983 |
}, |
|
984 |
/* data */ &_utAlldIna219Data, |
|
985 |
}; |
|
764 |
AOS_SHELL_COMMAND(moduleTestIna219ShellCmd, "test:PowerMonitor", _testIna219ShellCmdCb); |
|
986 | 765 |
|
987 | 766 |
/* |
988 | 767 |
* Status LED |
989 | 768 |
*/ |
990 |
static int _utShellCmdCb_AlldLed(BaseSequentialStream* stream, int argc, char* argv[]) |
|
769 |
#include <module_test_LED.h> |
|
770 |
static int _testLedShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
|
991 | 771 |
{ |
992 |
(void)argc; |
|
993 |
(void)argv; |
|
994 |
aosUtRun(stream, &moduleUtAlldLed, NULL); |
|
995 |
return AOS_OK; |
|
772 |
return moduleTestLedShellCb(stream, argc, argv, NULL); |
|
996 | 773 |
} |
997 |
aos_unittest_t moduleUtAlldLed = { |
|
998 |
/* name */ "LED", |
|
999 |
/* info */ NULL, |
|
1000 |
/* test function */ utAlldLedFunc, |
|
1001 |
/* shell command */ { |
|
1002 |
/* name */ "unittest:StatusLED", |
|
1003 |
/* callback */ _utShellCmdCb_AlldLed, |
|
1004 |
/* next */ NULL, |
|
1005 |
}, |
|
1006 |
/* data */ &moduleLldStatusLed, |
|
1007 |
}; |
|
774 |
AOS_SHELL_COMMAND(moduleTestLedShellCmd, "test:StatusLED", _testLedShellCmdCb); |
|
1008 | 775 |
|
1009 | 776 |
/* |
1010 | 777 |
* PKLCS1212E4001 (buzzer) |
1011 | 778 |
*/ |
1012 |
static int _utShellCmdCb_AlldPklcs1212e4001(BaseSequentialStream* stream, int argc, char* argv[]) |
|
779 |
#include <module_test_PKxxxExxx.h> |
|
780 |
static int _testPkxxxexxxShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
|
1013 | 781 |
{ |
1014 |
(void)argc; |
|
1015 |
(void)argv; |
|
1016 |
aosUtRun(stream, &moduleUtAlldPklcs1212e4001, NULL); |
|
1017 |
return AOS_OK; |
|
782 |
return moduleTestPkxxxexxxShellCb(stream, argc, argv, NULL); |
|
1018 | 783 |
} |
1019 |
static ut_pkxxxexxx_t _utAlldPklcs1212e4001Data = { |
|
1020 |
/* PWM driver */ &MODULE_HAL_PWM_BUZZER, |
|
1021 |
/* PWM channel */ MODULE_HAL_PWM_BUZZER_CHANNEL |
|
1022 |
}; |
|
1023 |
aos_unittest_t moduleUtAlldPklcs1212e4001 = { |
|
1024 |
/* name */ "PKLCS1212E4001", |
|
1025 |
/* info */ "buzzer", |
|
1026 |
/* test function */ utAlldPkxxxexxxFunc, |
|
1027 |
/* shell command */ { |
|
1028 |
/* name */ "unittest:Buzzer", |
|
1029 |
/* callback */ _utShellCmdCb_AlldPklcs1212e4001, |
|
1030 |
/* next */ NULL, |
|
1031 |
}, |
|
1032 |
/* data */ &_utAlldPklcs1212e4001Data, |
|
1033 |
}; |
|
784 |
AOS_SHELL_COMMAND(moduleTestPkxxxexxxShellCmd, "test:Buzzer", _testPkxxxexxxShellCmdCb); |
|
1034 | 785 |
|
1035 | 786 |
/* |
1036 | 787 |
* TPS62113 (step-down converter) |
1037 | 788 |
*/ |
1038 |
static int _utShellCmdCb_AlldTps62113(BaseSequentialStream* stream, int argc, char* argv[]) |
|
789 |
#include <module_test_TPS6211x.h> |
|
790 |
static int _testTps6211xShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
|
1039 | 791 |
{ |
1040 |
// Although there are four TPS62113 on the PCB, they all share the same input signal. |
|
1041 |
// A sa result, no additional shell arguments need to be evaluated. |
|
1042 |
(void)argc; |
|
1043 |
(void)argv; |
|
1044 |
aosUtRun(stream, &moduleUtAlldTps62113, NULL); |
|
1045 |
return AOS_OK; |
|
792 |
return moduleTestTps6211xShellCb(stream, argc, argv, NULL); |
|
1046 | 793 |
} |
1047 |
aos_unittest_t moduleUtAlldTps62113 = { |
|
1048 |
/* name */ "TPS62113", |
|
1049 |
/* info */ "step-down converter", |
|
1050 |
/* test function */ utAlldTps6211xFunc, |
|
1051 |
/* shell command */ { |
|
1052 |
/* name */ "unittest:StepDownConverter", |
|
1053 |
/* callback */ _utShellCmdCb_AlldTps62113, |
|
1054 |
/* next */ NULL, |
|
1055 |
}, |
|
1056 |
/* data */ &moduleLldStepDownConverter, |
|
1057 |
}; |
|
794 |
AOS_SHELL_COMMAND(moduleTestTps6211xShellCmd, "test:StepDownConverter", _testTps6211xShellCmdCb); |
|
1058 | 795 |
|
1059 | 796 |
/* |
1060 |
* TPS62113 (step-donw converter) in combination with INA219 (power monitor)
|
|
797 |
* TPS62113 (step-sown converter) in combination with INA219 (power monitor)
|
|
1061 | 798 |
*/ |
1062 |
static int _utShellCmdCb_AlldTps62113Ina219(BaseSequentialStream* stream, int argc, char* argv[]) |
|
799 |
#include <module_test_TPS6211x_INA219.h> |
|
800 |
static int _testTps6211xIna219ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
|
1063 | 801 |
{ |
1064 |
(void)argc; |
|
1065 |
(void)argv; |
|
1066 |
aosUtRun(stream, &moduleUtAlldTps62113Ina219, "VSYS (4.2V)"); |
|
1067 |
return AOS_OK; |
|
802 |
return moduleTestTps6211xIna219ShellCb(stream, argc, argv, NULL); |
|
1068 | 803 |
} |
1069 |
static ut_tps6211xina219data_t _utAlldTps62113Ina219Data = { |
|
1070 |
/* TPS62113 */ &moduleLldStepDownConverter, |
|
1071 |
/* INA219 */ &moduleLldPowerMonitorVsys42, |
|
1072 |
/* timeout */ MICROSECONDS_PER_SECOND, |
|
1073 |
}; |
|
1074 |
aos_unittest_t moduleUtAlldTps62113Ina219 = { |
|
1075 |
/* name */ "TPS62113 & INA219", |
|
1076 |
/* info */ "step-down converter & power monitor", |
|
1077 |
/* test function */ utAlldTps6211xIna219Func, |
|
1078 |
/* shell command */ { |
|
1079 |
/* name */ "unittest:StepDownConverter&PowerMonitor", |
|
1080 |
/* callback */ _utShellCmdCb_AlldTps62113Ina219, |
|
1081 |
/* next */ NULL, |
|
1082 |
}, |
|
1083 |
/* data */ &_utAlldTps62113Ina219Data, |
|
1084 |
}; |
|
804 |
AOS_SHELL_COMMAND(moduleTestTps6211xIna219ShellCmd, "test:StepDownConverter&PowerMonitor", _testTps6211xIna219ShellCmdCb); |
|
1085 | 805 |
|
1086 | 806 |
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) || defined(__DOXYGEN__) |
1087 | 807 |
|
1088 | 808 |
/* |
1089 | 809 |
* MPR121 (touch sensor) |
1090 | 810 |
*/ |
1091 |
static int _utShellCmdCb_AlldMpr121(BaseSequentialStream* stream, int argc, char* argv[]) |
|
811 |
#include <module_test_MPR121.h> |
|
812 |
static int _testMpr121ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
|
1092 | 813 |
{ |
1093 |
(void)argc; |
|
1094 |
(void)argv; |
|
1095 |
aosUtRun(stream, &moduleUtAlldMpr121, NULL); |
|
1096 |
return AOS_OK; |
|
814 |
return moduleTestMpr121ShellCb(stream, argc, argv, NULL); |
|
1097 | 815 |
} |
1098 |
static ut_mpr121data_t _utAlldMpr121Data= { |
|
1099 |
/* MPR121 driver */ &moduleLldTouch, |
|
1100 |
/* timeout */ MICROSECONDS_PER_SECOND, |
|
1101 |
/* event source */ &aos.events.io, |
|
1102 |
/* event flags */ MODULE_OS_IOEVENTFLAGS_TOUCHINT, |
|
1103 |
}; |
|
1104 |
aos_unittest_t moduleUtAlldMpr121 = { |
|
1105 |
/* name */ "MPR121", |
|
1106 |
/* info */ "touch sensor", |
|
1107 |
/* test function */ utAlldMpr121Func, |
|
1108 |
/* shell command */ { |
|
1109 |
/* name */ "unittest:Touch", |
|
1110 |
/* callback */ _utShellCmdCb_AlldMpr121, |
|
1111 |
/* next */ NULL, |
|
1112 |
}, |
|
1113 |
/* data */ &_utAlldMpr121Data, |
|
1114 |
}; |
|
816 |
AOS_SHELL_COMMAND(moduleTestMpr121ShellCmd, "test:Touch", _testMpr121ShellCmdCb); |
|
1115 | 817 |
|
1116 | 818 |
/* |
1117 | 819 |
* PCA9544A (I2C multiplexer) |
1118 | 820 |
*/ |
1119 |
static int _utShellCmdCb_AlldPca5944a(BaseSequentialStream* stream, int argc, char* argv[]) |
|
821 |
#include <module_test_PCA9544A.h> |
|
822 |
static int _testPca9544aShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
|
1120 | 823 |
{ |
1121 |
// evaluate arguments |
|
1122 |
if (argc == 2) { |
|
1123 |
if (strcmp(argv[1], "#1") == 0) { |
|
1124 |
((ut_pca9544adata_t*)moduleUtAlldPca9544a.data)->driver = &moduleLldI2cMultiplexer1; |
|
1125 |
aosUtRun(stream, &moduleUtAlldPca9544a, "I2C bus #1"); |
|
1126 |
((ut_pca9544adata_t*)moduleUtAlldPca9544a.data)->driver = NULL; |
|
1127 |
return AOS_OK; |
|
1128 |
} |
|
1129 |
else if (strcmp(argv[1], "#2") == 0) { |
|
1130 |
((ut_pca9544adata_t*)moduleUtAlldPca9544a.data)->driver = &moduleLldI2cMultiplexer2; |
|
1131 |
aosUtRun(stream, &moduleUtAlldPca9544a, "I2C bus #2"); |
|
1132 |
((ut_pca9544adata_t*)moduleUtAlldPca9544a.data)->driver = NULL; |
|
1133 |
return AOS_OK; |
|
1134 |
} |
|
1135 |
} |
|
1136 |
// print help |
|
1137 |
chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
|
1138 |
chprintf(stream, "Options:\n"); |
|
1139 |
chprintf(stream, " #1\n"); |
|
1140 |
chprintf(stream, " Test the multiplexer on the I2C bus #1.\n"); |
|
1141 |
chprintf(stream, " #2\n"); |
|
1142 |
chprintf(stream, " Test the multiplexer on the I2C bus #2.\n"); |
|
1143 |
return AOS_INVALIDARGUMENTS; |
|
824 |
return moduleTestPca9544aShellCb(stream, argc, argv, NULL); |
|
1144 | 825 |
} |
1145 |
static ut_pca9544adata_t _utAlldPca9544aData = { |
|
1146 |
/* driver */ NULL, |
|
1147 |
/* timeout */ MICROSECONDS_PER_SECOND, |
|
1148 |
}; |
|
1149 |
aos_unittest_t moduleUtAlldPca9544a = { |
|
1150 |
/* name */ "PCA9544A", |
|
1151 |
/* info */ "I2C multiplexer", |
|
1152 |
/* test function */ utAlldPca9544aFunc, |
|
1153 |
/* shell command */ { |
|
1154 |
/* name */ "unittest:I2CMultiplexer", |
|
1155 |
/* callback */ _utShellCmdCb_AlldPca5944a, |
|
1156 |
/* next */ NULL, |
|
1157 |
}, |
|
1158 |
/* data */ &_utAlldPca9544aData, |
|
1159 |
}; |
|
826 |
AOS_SHELL_COMMAND(moduleTestPca9544aShellCmd, "test:I2CMultiplexer", _testPca9544aShellCmdCb); |
|
1160 | 827 |
|
1161 | 828 |
/* |
1162 | 829 |
* VCNL4020 (proximity sensor) |
1163 | 830 |
*/ |
1164 |
static void _utAlldVcnl4020_disableInterrupt(VCNL4020Driver* vcnl) |
|
831 |
#include <module_test_VCNL4020.h> |
|
832 |
static int _testVcnl4020ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
|
1165 | 833 |
{ |
1166 |
uint8_t intstatus; |
|
1167 |
vcnl4020_lld_writereg(vcnl, VCNL4020_LLD_REGADDR_INTCTRL, 0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
|
1168 |
vcnl4020_lld_readreg(vcnl, VCNL4020_LLD_REGADDR_INTSTATUS, &intstatus, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
|
1169 |
if (intstatus) { |
|
1170 |
vcnl4020_lld_writereg(vcnl, VCNL4020_LLD_REGADDR_INTSTATUS, intstatus, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
|
1171 |
} |
|
1172 |
return; |
|
834 |
return moduleTestVcnl4020ShellCb(stream, argc, argv, NULL); |
|
1173 | 835 |
} |
1174 |
static int _utShellCmdCb_AlldVcnl4020(BaseSequentialStream* stream, int argc, char* argv[]) |
|
1175 |
{ |
|
1176 |
enum { |
|
1177 |
UNKNOWN, |
|
1178 |
NNE, ENE, ESE, SSE, SSW,WSW,WNW, NNW, |
|
1179 |
} sensor = UNKNOWN; |
|
1180 |
// evaluate arguments |
|
1181 |
if (argc == 2) { |
|
1182 |
if (strcmp(argv[1], "-nne") == 0) { |
|
1183 |
sensor = NNE; |
|
1184 |
} else if (strcmp(argv[1], "-ene") == 0) { |
|
1185 |
sensor = ENE; |
|
1186 |
} else if (strcmp(argv[1], "-ese") == 0) { |
|
1187 |
sensor = ESE; |
|
1188 |
} else if (strcmp(argv[1], "-sse") == 0) { |
|
1189 |
sensor = SSE; |
|
1190 |
} else if (strcmp(argv[1], "-ssw") == 0) { |
|
1191 |
sensor = SSW; |
|
1192 |
} else if (strcmp(argv[1], "-wsw") == 0) { |
|
1193 |
sensor = WSW; |
|
1194 |
} else if (strcmp(argv[1], "-wnw") == 0) { |
|
1195 |
sensor = WNW; |
|
1196 |
} else if (strcmp(argv[1], "-nnw") == 0) { |
|
1197 |
sensor = NNW; |
|
1198 |
} |
|
1199 |
} |
|
1200 |
if (sensor != UNKNOWN) { |
|
1201 |
PCA9544ADriver* mux = NULL; |
|
1202 |
switch (sensor) { |
|
1203 |
case SSE: |
|
1204 |
case SSW: |
|
1205 |
case WSW: |
|
1206 |
case WNW: |
|
1207 |
mux = &moduleLldI2cMultiplexer1; |
|
1208 |
((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld = &moduleLldProximity1; |
|
1209 |
((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT2; |
|
1210 |
break; |
|
1211 |
case NNW: |
|
1212 |
case NNE: |
|
1213 |
case ENE: |
|
1214 |
case ESE: |
|
1215 |
mux = &moduleLldI2cMultiplexer2; |
|
1216 |
((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld = &moduleLldProximity2; |
|
1217 |
((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->evtflags = MODULE_OS_IOEVENTFLAGS_IRINT1; |
|
1218 |
break; |
|
1219 |
default: |
|
1220 |
break; |
|
1221 |
} |
|
1222 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
|
1223 |
_utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld); |
|
1224 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH1, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
|
1225 |
_utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld); |
|
1226 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH2, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
|
1227 |
_utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld); |
|
1228 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH3, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
|
1229 |
_utAlldVcnl4020_disableInterrupt(((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld); |
|
1230 |
switch (sensor) { |
|
1231 |
case NNE: |
|
1232 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH1, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
|
1233 |
aosUtRun(stream, &moduleUtAlldVcnl4020, "north-northeast sensor"); |
|
1234 |
break; |
|
1235 |
case ENE: |
|
1236 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH3, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
|
1237 |
aosUtRun(stream, &moduleUtAlldVcnl4020, "east-northeast sensor"); |
|
1238 |
break; |
|
1239 |
case ESE: |
|
1240 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH2, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
|
1241 |
aosUtRun(stream, &moduleUtAlldVcnl4020, "north-southeast sensor"); |
|
1242 |
break; |
|
1243 |
case SSE: |
|
1244 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
|
1245 |
aosUtRun(stream, &moduleUtAlldVcnl4020, "south-southeast sensor"); |
|
1246 |
break; |
|
1247 |
case SSW: |
|
1248 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH1, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
|
1249 |
aosUtRun(stream, &moduleUtAlldVcnl4020, "south-southwest sensor"); |
|
1250 |
break; |
|
1251 |
case WSW: |
|
1252 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH3, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
|
1253 |
aosUtRun(stream, &moduleUtAlldVcnl4020, "west-southwest sensor"); |
|
1254 |
break; |
|
1255 |
case WNW: |
|
1256 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH2, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
|
1257 |
aosUtRun(stream, &moduleUtAlldVcnl4020, "west-northwest sensor"); |
|
1258 |
break; |
|
1259 |
case NNW: |
|
1260 |
pca9544a_lld_setchannel(mux, PCA9544A_LLD_CH0, ((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->timeout); |
|
1261 |
aosUtRun(stream, &moduleUtAlldVcnl4020, "north-northwest sensor"); |
|
1262 |
break; |
|
1263 |
default: |
|
1264 |
break; |
|
1265 |
} |
|
1266 |
((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->vcnld = NULL; |
|
1267 |
((ut_vcnl4020data_t*)moduleUtAlldVcnl4020.data)->evtflags = 0; |
|
1268 |
return AOS_OK; |
|
1269 |
} |
|
1270 |
// print help |
|
1271 |
chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
|
1272 |
chprintf(stream, "Options:\n"); |
|
1273 |
chprintf(stream, " -nne\n"); |
|
1274 |
chprintf(stream, " Test north-northeast sensor.\n"); |
|
1275 |
chprintf(stream, " -ene\n"); |
|
1276 |
chprintf(stream, " Test east-northeast sensor.\n"); |
|
1277 |
chprintf(stream, " -ese\n"); |
|
1278 |
chprintf(stream, " Test east-southeast sensor.\n"); |
|
1279 |
chprintf(stream, " -sse\n"); |
|
1280 |
chprintf(stream, " Test south-southeast sensor.\n"); |
|
1281 |
chprintf(stream, " -ssw\n"); |
|
1282 |
chprintf(stream, " Test south-southwest sensor.\n"); |
|
1283 |
chprintf(stream, " -wsw\n"); |
|
1284 |
chprintf(stream, " Test west-southwest sensor.\n"); |
|
1285 |
chprintf(stream, " -wnw\n"); |
|
1286 |
chprintf(stream, " Test west-northwest sensor.\n"); |
|
1287 |
chprintf(stream, " -nnw\n"); |
|
1288 |
chprintf(stream, " Test north-northwest sensor.\n"); |
|
1289 |
return AOS_INVALIDARGUMENTS; |
|
1290 |
} |
|
1291 |
static ut_vcnl4020data_t _utAlldVcnl4020Data = { |
|
1292 |
/* driver */ NULL, |
|
1293 |
/* timeout */ MICROSECONDS_PER_SECOND, |
|
1294 |
/* event source */ &aos.events.io, |
|
1295 |
/* event flags */ 0, |
|
1296 |
}; |
|
1297 |
aos_unittest_t moduleUtAlldVcnl4020 = { |
|
1298 |
/* name */ "VCNL4020", |
|
1299 |
/* info */ "proximity sensor", |
|
1300 |
/* test function */ utAlldVcnl4020Func, |
|
1301 |
/* shell command */ { |
|
1302 |
/* name */ "unittest:Proximity", |
|
1303 |
/* callback */ _utShellCmdCb_AlldVcnl4020, |
|
1304 |
/* next */ NULL, |
|
1305 |
}, |
|
1306 |
/* data */ &_utAlldVcnl4020Data, |
|
1307 |
}; |
|
836 |
AOS_SHELL_COMMAND(moduleTestVcnl4020ShellCmd, "test:Proximity", _testVcnl4020ShellCmdCb); |
|
1308 | 837 |
|
1309 | 838 |
#endif /* (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) */ |
1310 | 839 |
|
... | ... | |
1313 | 842 |
/* |
1314 | 843 |
* PCAL6524 (GPIO extender) |
1315 | 844 |
*/ |
1316 |
static int _utShellCmdCb_AlldPcal6524(BaseSequentialStream* stream, int argc, char* argv[]) |
|
845 |
#include <module_test_PCAL6524.h> |
|
846 |
static int _testPcal6524ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
|
1317 | 847 |
{ |
1318 |
// evaluate arguments |
|
1319 |
if (argc == 2) { |
|
1320 |
if (strcmp(argv[1], "#1") == 0) { |
|
1321 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = &moduleLldGpioExtender1; |
|
1322 |
aosUtRun(stream, &moduleUtAlldPcal6524, "I2C bus #1"); |
|
1323 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = NULL; |
|
1324 |
return AOS_OK; |
|
1325 |
} |
|
1326 |
else if (strcmp(argv[1], "#2") == 0) { |
|
1327 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = &moduleLldGpioExtender2; |
|
1328 |
aosUtRun(stream, &moduleUtAlldPcal6524, "I2C bus #2"); |
|
1329 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = NULL; |
|
1330 |
return AOS_OK; |
|
1331 |
} |
|
1332 |
} |
|
1333 |
// print help |
|
1334 |
chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
|
1335 |
chprintf(stream, "Options:\n"); |
|
1336 |
chprintf(stream, " #1\n"); |
|
1337 |
chprintf(stream, " Test the GPIO extender on the I2C bus #1.\n"); |
|
1338 |
chprintf(stream, " #2\n"); |
|
1339 |
chprintf(stream, " Test the GPIO extender on the I2C bus #2.\n"); |
|
1340 |
return AOS_INVALIDARGUMENTS; |
|
848 |
return moduleTestPcal6524ShellCb(stream, argc, argv, NULL); |
|
1341 | 849 |
} |
1342 |
static ut_pcal6524data_t _utAlldPcal6524Data = { |
|
1343 |
/* driver */ NULL, |
|
1344 |
/* timeout */ MICROSECONDS_PER_SECOND, |
|
1345 |
}; |
|
1346 |
aos_unittest_t moduleUtAlldPcal6524 = { |
|
1347 |
/* name */ "PCAL6524", |
|
1348 |
/* info */ "GPIO extender", |
|
1349 |
/* test function */ utAlldPcal6524Func, |
|
1350 |
/* shell command */ { |
|
1351 |
/* name */ "unittest:GPIOExtender", |
|
1352 |
/* callback */ _utShellCmdCb_AlldPcal6524, |
|
1353 |
/* next */ NULL, |
|
1354 |
}, |
|
1355 |
/* data */ &_utAlldPcal6524Data, |
|
1356 |
}; |
|
850 |
AOS_SHELL_COMMAND(moduleTestPcal6524ShellCmd, "test:GPIOExtenter", _testPcal6524ShellCmdCb); |
|
1357 | 851 |
|
1358 | 852 |
/* |
1359 | 853 |
* AT42QT1050 (touch sensor) |
1360 | 854 |
*/ |
1361 |
static int _utShellCmdCb_AlldAt42qt1050(BaseSequentialStream* stream, int argc, char* argv[]) |
|
855 |
#include <module_test_AT42QT1050.h> |
|
856 |
static int _testAt42qt1050ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
|
1362 | 857 |
{ |
1363 |
(void)argc; |
|
1364 |
(void)argv; |
|
1365 |
aosUtRun(stream, &moduleUtAlldAt42qt1050, NULL); |
|
1366 |
return AOS_OK; |
|
858 |
return moduleTestAt42qt1050ShellCb(stream, argc, argv, NULL); |
|
1367 | 859 |
} |
1368 |
static ut_at42qt1050data_t _utAlldAt42qt1050Data= { |
|
1369 |
/* AT42QT1050 driver */ &moduleLldTouch, |
|
1370 |
/* timeout */ MICROSECONDS_PER_SECOND, |
|
1371 |
/* event source */ &aos.events.io, |
|
1372 |
/* event flags */ MODULE_OS_IOEVENTFLAGS_TOUCHINT, |
|
1373 |
}; |
|
1374 |
aos_unittest_t moduleUtAlldAt42qt1050 = { |
|
1375 |
/* name */ "AT42QT1050", |
|
1376 |
/* info */ "touch sensor", |
|
1377 |
/* test function */ utAlldAt42qt1050Func, |
|
1378 |
/* shell command */ { |
|
1379 |
/* name */ "unittest:Touch", |
|
1380 |
/* callback */ _utShellCmdCb_AlldAt42qt1050, |
|
1381 |
/* next */ NULL, |
|
1382 |
}, |
|
1383 |
/* data */ &_utAlldAt42qt1050Data, |
|
1384 |
}; |
|
860 |
AOS_SHELL_COMMAND(moduleTestAt42qt1050ShellCmd, "test:Touch", _testAt42qt1050ShellCmdCb); |
|
1385 | 861 |
|
1386 | 862 |
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) */ |
1387 | 863 |
|
... | ... | |
1390 | 866 |
/* |
1391 | 867 |
* PCAL6524 (GPIO extender) |
1392 | 868 |
*/ |
1393 |
static int _utShellCmdCb_AlldPcal6524(BaseSequentialStream* stream, int argc, char* argv[]) |
|
869 |
#include <module_test_PCAL6524.h> |
|
870 |
static int _testPcal6524ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
|
1394 | 871 |
{ |
1395 |
// evaluate arguments |
|
1396 |
if (argc == 2) { |
|
1397 |
if (strcmp(argv[1], "#1") == 0) { |
|
1398 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = &moduleLldGpioExtender1; |
|
1399 |
aosUtRun(stream, &moduleUtAlldPcal6524, "I2C bus #1"); |
|
1400 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = NULL; |
|
1401 |
return AOS_OK; |
|
1402 |
} |
|
1403 |
else if (strcmp(argv[1], "#2") == 0) { |
|
1404 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = &moduleLldGpioExtender2; |
|
1405 |
aosUtRun(stream, &moduleUtAlldPcal6524, "I2C bus #2"); |
|
1406 |
((ut_pcal6524data_t*)moduleUtAlldPcal6524.data)->pcal6524d = NULL; |
|
1407 |
return AOS_OK; |
|
1408 |
} |
|
1409 |
} |
|
1410 |
// print help |
|
1411 |
chprintf(stream, "Usage: %s OPTION\n", argv[0]); |
|
1412 |
chprintf(stream, "Options:\n"); |
|
1413 |
chprintf(stream, " #1\n"); |
|
1414 |
chprintf(stream, " Test the GPIO extender on the I2C bus #1.\n"); |
|
1415 |
chprintf(stream, " #2\n"); |
|
1416 |
chprintf(stream, " Test the GPIO extender on the I2C bus #2.\n"); |
|
1417 |
return AOS_INVALIDARGUMENTS; |
|
872 |
return moduleTestPcal6524ShellCb(stream, argc, argv, NULL); |
|
1418 | 873 |
} |
1419 |
static ut_pcal6524data_t _utAlldPcal6524Data = { |
|
1420 |
/* driver */ NULL, |
|
1421 |
/* timeout */ MICROSECONDS_PER_SECOND, |
|
1422 |
}; |
|
1423 |
aos_unittest_t moduleUtAlldPcal6524 = { |
|
1424 |
/* name */ "PCAL6524", |
|
1425 |
/* info */ "GPIO extender", |
|
1426 |
/* test function */ utAlldPcal6524Func, |
|
1427 |
/* shell command */ { |
|
1428 |
/* name */ "unittest:GPIOExtender", |
|
1429 |
/* callback */ _utShellCmdCb_AlldPcal6524, |
|
1430 |
/* next */ NULL, |
|
1431 |
}, |
|
1432 |
/* data */ &_utAlldPcal6524Data, |
|
1433 |
}; |
|
874 |
AOS_SHELL_COMMAND(moduleTestPcal6524ShellCmd, "test:GPIOExtenter", _testPcal6524ShellCmdCb); |
|
1434 | 875 |
|
1435 | 876 |
/* |
1436 | 877 |
* AT42QT1050 (touch sensor) |
1437 | 878 |
*/ |
1438 |
static int _utShellCmdCb_AlldAt42qt1050(BaseSequentialStream* stream, int argc, char* argv[]) |
|
879 |
#include <module_test_AT42QT1050.h> |
|
880 |
static int _testAt42qt1050ShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
|
881 |
{ |
|
882 |
return moduleTestAt42qt1050ShellCb(stream, argc, argv, NULL); |
|
883 |
} |
|
884 |
AOS_SHELL_COMMAND(moduleTestAt42qt1050ShellCmd, "test:Touch", _testAt42qt1050ShellCmdCb); |
|
885 |
|
|
886 |
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) */ |
|
887 |
|
|
888 |
/* |
|
889 |
* entire module |
|
890 |
*/ |
|
891 |
static int _testAllShellCmdCb(BaseSequentialStream* stream, int argc, char* argv[]) |
|
1439 | 892 |
{ |
1440 | 893 |
(void)argc; |
1441 | 894 |
(void)argv; |
1442 |
aosUtRun(stream, &moduleUtAlldAt42qt1050, NULL); |
|
1443 |
return AOS_OK; |
|
1444 |
} |
|
1445 |
static ut_at42qt1050data_t _utAlldAt42qt1050Data= { |
|
1446 |
/* AT42QT1050 driver */ &moduleLldTouch, |
|
1447 |
/* timeout */ MICROSECONDS_PER_SECOND, |
|
1448 |
/* event source */ &aos.events.io, |
|
1449 |
/* event flags */ MODULE_OS_IOEVENTFLAGS_TOUCHINT, |
|
1450 |
}; |
|
1451 |
aos_unittest_t moduleUtAlldAt42qt1050 = { |
|
1452 |
/* name */ "AT42QT1050", |
|
1453 |
/* info */ "touch sensor", |
|
1454 |
/* test function */ utAlldAt42qt1050Func, |
|
1455 |
/* shell command */ { |
|
1456 |
/* name */ "unittest:Touch", |
|
1457 |
/* callback */ _utShellCmdCb_AlldAt42qt1050, |
|
1458 |
/* next */ NULL, |
|
1459 |
}, |
|
1460 |
/* data */ &_utAlldAt42qt1050Data, |
|
1461 |
}; |
|
895 |
|
|
896 |
int status = AOS_OK; |
|
897 |
char* targv[AMIROOS_CFG_SHELL_MAXARGS] = {NULL}; |
|
898 |
aos_testresult_t result_test = {0, 0}; |
|
899 |
aos_testresult_t result_total = {0, 0}; |
|
900 |
|
|
901 |
/* ADC */ |
|
902 |
status |= moduleTestAdcShellCb(stream, 0, targv, &result_test); |
|
903 |
result_total = aosTestResultAdd(result_total, result_test); |
|
904 |
|
|
905 |
/* AT24C01BN-SH-B (EEPROM) */ |
|
906 |
status |= moduleTestAt24c01bShellCb(stream, 0, targv, &result_test); |
|
907 |
result_total = aosTestResultAdd(result_total, result_test); |
|
908 |
|
|
909 |
/* bq24103a (battery charger) */ |
|
910 |
// front |
|
911 |
targv[1] = "-f"; |
|
912 |
status |= moduleTestBq241xxShellCb(stream, 2, targv, &result_test); |
|
913 |
result_total = aosTestResultAdd(result_total, result_test); |
|
914 |
// rear |
|
915 |
targv[1] = "-r"; |
|
916 |
status |= moduleTestBq241xxShellCb(stream, 2, targv, &result_test); |
|
917 |
result_total = aosTestResultAdd(result_total, result_test); |
|
918 |
targv[1] = ""; |
|
919 |
|
|
920 |
/* bq27500 (fuel gauge) */ |
|
921 |
// front |
|
922 |
targv[1] = "-f"; |
|
923 |
status |= moduleTestBq27500ShellCb(stream, 2, targv, &result_test); |
|
924 |
result_total = aosTestResultAdd(result_total, result_test); |
|
925 |
// rear |
|
926 |
targv[1] = "-r"; |
|
927 |
status |= moduleTestBq27500ShellCb(stream, 2, targv, &result_test); |
|
928 |
result_total = aosTestResultAdd(result_total, result_test); |
|
929 |
targv[1] = ""; |
|
930 |
|
|
931 |
/* bq 27500 (fuel gauge) in combination with bq24103a (battery charger) */ |
|
932 |
// front |
|
933 |
targv[1] = "-f"; |
|
934 |
status |= moduleTestBq27500Bq241xxShellCb(stream, 2, targv, &result_test); |
|
935 |
result_total = aosTestResultAdd(result_total, result_test); |
|
936 |
// rear |
|
937 |
targv[1] = "-r"; |
|
938 |
status |= moduleTestBq27500Bq241xxShellCb(stream, 2, targv, &result_test); |
|
939 |
result_total = aosTestResultAdd(result_total, result_test); |
|
940 |
targv[1] = ""; |
|
941 |
|
|
942 |
/* INA219 (power monitor) */ |
|
943 |
// VDD |
|
944 |
targv[1] = "VDD"; |
|
945 |
status |= moduleTestIna219ShellCb(stream, 2, targv, &result_test); |
|
946 |
result_total = aosTestResultAdd(result_total, result_test); |
|
947 |
// VIO 1.8V |
|
948 |
targv[1] = "VIO1.8"; |
|
949 |
status |= moduleTestIna219ShellCb(stream, 2, targv, &result_test); |
|
950 |
result_total = aosTestResultAdd(result_total, result_test); |
|
951 |
// VIO 3.3V |
|
952 |
targv[1] = "VIO3.3"; |
|
953 |
status |= moduleTestIna219ShellCb(stream, 2, targv, &result_test); |
|
954 |
result_total = aosTestResultAdd(result_total, result_test); |
|
955 |
// VSYS 4.2V |
|
956 |
targv[1] = "VSYS4.2"; |
|
957 |
status |= moduleTestIna219ShellCb(stream, 2, targv, &result_test); |
|
958 |
result_total = aosTestResultAdd(result_total, result_test); |
|
959 |
// VIO 5.0V |
|
960 |
targv[1] = "VIO5.0"; |
|
961 |
status |= moduleTestIna219ShellCb(stream, 2, targv, &result_test); |
|
962 |
result_total = aosTestResultAdd(result_total, result_test); |
|
963 |
targv[1] = ""; |
|
964 |
|
|
965 |
/* status LED */ |
|
966 |
status |= moduleTestLedShellCb(stream, 0, targv, &result_test); |
|
967 |
result_total = aosTestResultAdd(result_total, result_test); |
|
968 |
|
|
969 |
/* PKLCS1212E4001 (buzzer) */ |
|
970 |
status |= moduleTestPkxxxexxxShellCb(stream, 0, targv, &result_test); |
|
971 |
result_total = aosTestResultAdd(result_total, result_test); |
|
972 |
|
|
973 |
/* TPS62113 (step-down converter) */ |
|
974 |
status |= moduleTestTps6211xShellCb(stream, 0, targv, &result_test); |
|
975 |
result_total = aosTestResultAdd(result_total, result_test); |
|
976 |
|
|
977 |
/* TPS62113 (step-down converter) in combination with INA219 (power monitor) */ |
|
978 |
status |= moduleTestTps6211xIna219ShellCb(stream, 0, targv, &result_test); |
|
979 |
result_total = aosTestResultAdd(result_total, result_test); |
|
980 |
|
|
981 |
#if (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) |
|
982 |
|
|
983 |
/* MPR121 (touch sensor) */ |
|
984 |
status |= moduleTestMpr121ShellCb(stream, 0, targv, &result_test); |
|
985 |
result_total = aosTestResultAdd(result_total, result_test); |
|
986 |
|
|
987 |
/* PCA9544A (I2C multiplexer) */ |
|
988 |
// #1 |
|
989 |
targv[1] = "#1"; |
|
990 |
status |= moduleTestPca9544aShellCb(stream, 2, targv, &result_test); |
|
991 |
result_total = aosTestResultAdd(result_total, result_test); |
|
992 |
// #2 |
|
993 |
targv[1] = "#2"; |
|
994 |
status |= moduleTestPca9544aShellCb(stream, 2, targv, &result_test); |
|
995 |
result_total = aosTestResultAdd(result_total, result_test); |
|
996 |
targv[1] = ""; |
|
997 |
|
|
998 |
/* VCNL4020 (proximity sensor) */ |
|
999 |
// north-northeast |
|
1000 |
targv[1] = "-nne"; |
|
1001 |
status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test); |
|
1002 |
result_total = aosTestResultAdd(result_total, result_test); |
|
1003 |
// east-northeast |
|
1004 |
targv[1] = "-ene"; |
|
1005 |
status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test); |
|
1006 |
result_total = aosTestResultAdd(result_total, result_test); |
|
1007 |
// east-southeast |
|
1008 |
targv[1] = "-ese"; |
|
1009 |
status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test); |
|
1010 |
result_total = aosTestResultAdd(result_total, result_test); |
|
1011 |
// south-southeast |
|
1012 |
targv[1] = "-sse"; |
|
1013 |
status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test); |
|
1014 |
result_total = aosTestResultAdd(result_total, result_test); |
|
1015 |
// south-southwest |
|
1016 |
targv[1] = "-ssw"; |
|
1017 |
status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test); |
|
1018 |
result_total = aosTestResultAdd(result_total, result_test); |
|
1019 |
// west-southwest |
|
1020 |
targv[1] = "-wsw"; |
|
1021 |
status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test); |
|
1022 |
result_total = aosTestResultAdd(result_total, result_test); |
|
1023 |
// west-northwest |
|
1024 |
targv[1] = "-wnw"; |
|
1025 |
status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test); |
|
1026 |
result_total = aosTestResultAdd(result_total, result_test); |
|
1027 |
// west-northwest |
|
1028 |
targv[1] = "-nnw"; |
|
1029 |
status |= moduleTestVcnl4020ShellCb(stream, 2, targv, &result_test); |
|
1030 |
result_total = aosTestResultAdd(result_total, result_test); |
|
1031 |
targv[1] = ""; |
|
1032 |
|
|
1033 |
#endif /* (BOARD_SENSORRING == BOARD_PROXIMITYSENSOR) */ |
|
1034 |
|
|
1035 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) |
|
1036 |
|
|
1037 |
/* PCAL6524 (GPIO extender) */ |
|
1038 |
// #1 |
|
1039 |
targv[1] = "#1"; |
|
1040 |
status |= moduleTestPcal6524ShellCb(stream, 2, targv, &result_test); |
|
1041 |
result_total = aosTestResultAdd(result_total, result_test); |
|
1042 |
// #2 |
|
1043 |
targv[1] = "#2"; |
|
1044 |
status |= moduleTestPcal6524ShellCb(stream, 2, targv, &result_test); |
|
1045 |
result_total = aosTestResultAdd(result_total, result_test); |
|
1046 |
targv[1] = ""; |
|
1047 |
|
|
1048 |
/* AT42QT1050 (touch sensor) */ |
|
1049 |
status |= moduleTestAt42qt1050ShellCb(stream, 2, targv, &result_test); |
|
1050 |
result_total = aosTestResultAdd(result_total, result_test); |
|
1051 |
|
|
1052 |
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L0X) */ |
|
1053 |
|
|
1054 |
#if (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) |
|
1055 |
|
|
1056 |
/* PCAL6524 (GPIO extender) */ |
|
1057 |
// #1 |
|
1058 |
targv[1] = "#1"; |
|
1059 |
status |= moduleTestPcal6524ShellCb(stream, 2, targv, &result_test); |
|
1060 |
result_total = aosTestResultAdd(result_total, result_test); |
|
1061 |
// #2 |
|
1062 |
targv[1] = "#2"; |
|
1063 |
status |= moduleTestPcal6524ShellCb(stream, 2, targv, &result_test); |
|
1064 |
result_total = aosTestResultAdd(result_total, result_test); |
|
1065 |
targv[1] = ""; |
|
1066 |
|
|
1067 |
/* AT42QT1050 (touch sensor) */ |
|
1068 |
status |= moduleTestAt42qt1050ShellCb(stream, 2, targv, &result_test); |
|
1069 |
result_total = aosTestResultAdd(result_total, result_test); |
|
1462 | 1070 |
|
1463 | 1071 |
#endif /* (BOARD_SENSORRING == BOARD_DISTANCESENSOR_VL53L1X) */ |
1464 | 1072 |
|
1073 |
// print total result |
|
1074 |
chprintf(stream, "\n"); |
|
1075 |
aosTestResultPrintSummary(stream, &result_total, "entire module"); |
|
1076 |
|
|
1077 |
return status; |
|
1078 |
} |
|
1079 |
AOS_SHELL_COMMAND(moduleTestAllShellCmd, "test:all", _testAllShellCmdCb); |
|
1080 |
|
|
1465 | 1081 |
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
1466 | 1082 |
|
1467 | 1083 |
/** @} */ |
Also available in: Unified diff