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