From 90e709409ce9e52c06beb82b4c944c11e6476186 Mon Sep 17 00:00:00 2001 From: Lee Lup Yuen Date: Sat, 7 May 2022 10:41:26 +0800 Subject: [PATCH 1/3] Fix SPI Test 2 for PineDio Stack --- examples/spi_test2/spi_test2_main.c | 32 +++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/examples/spi_test2/spi_test2_main.c b/examples/spi_test2/spi_test2_main.c index 64767970c4..d44b15cb49 100644 --- a/examples/spi_test2/spi_test2_main.c +++ b/examples/spi_test2/spi_test2_main.c @@ -31,6 +31,22 @@ #include +/* Define the SPI Test Driver for SX1262. (Not the regular SPI Driver) */ + +#ifdef CONFIG_LIBSX1262_SPI_DEVPATH +#define SPI_DEVPATH CONFIG_LIBSX1262_SPI_DEVPATH +#else +#define SPI_DEVPATH "/dev/spitest0" +#endif /* CONFIG_LIBSX1262_SPI_DEVPATH */ + +/* Define the GPIO for SX1262 Chip Select */ + +#ifdef CONFIG_LIBSX1262_CS_DEVPATH +#define CS_DEVPATH CONFIG_LIBSX1262_CS_DEVPATH +#else +#define CS_DEVPATH "/dev/gpio1" +#endif /* CONFIG_LIBSX1262_CS_DEVPATH */ + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -43,12 +59,12 @@ int main(int argc, FAR char *argv[]) { /* Open GPIO Output for SPI Chip Select */ - int cs = open("/dev/gpio1", O_RDWR); + int cs = open(CS_DEVPATH, O_RDWR); assert(cs >= 0); /* Open SPI Test Driver */ - int fd = open("/dev/spitest0", O_RDWR); + int fd = open(SPI_DEVPATH, O_RDWR); assert(fd >= 0); /* Set SPI Chip Select to Low */ @@ -116,6 +132,17 @@ int main(int argc, FAR char *argv[]) } printf("\nSX1262 Register 8 is 0x%02x\n", rx_data[4]); + /* Register 8 should be 0x80 */ + + if (rx_data[4] == 0x80) + { + printf("SX1262 is OK\n"); + } + else + { + printf("***** ERROR: SX1262 is NOT OK! Check SPI connection\n"); + } + /* Close SPI Test Driver */ close(fd); @@ -171,5 +198,6 @@ gpout_write: Writing 1 Read Register 8: received a8 a8 a8 a8 80 SX1262 Register 8 is 0x80 +SX1262 is OK spi_test_driver_close: */ \ No newline at end of file From 6ae65f0211e3d576a387f07b514336365fa0ac98 Mon Sep 17 00:00:00 2001 From: Lee Lup Yuen Date: Sun, 8 May 2022 14:02:46 +0800 Subject: [PATCH 2/3] Revert "Merge updates from master" --- .gitignore | 2 -- Application.mk | 2 +- nshlib/nsh_command.c | 4 ++-- nshlib/nsh_syscmds.c | 14 ++------------ 4 files changed, 5 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index e2c57e5e54..b1ef6cfe69 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,6 @@ *.d *.dSYM *.exe -*.gcno -*.gcda *.hobj *.i *.lib diff --git a/Application.mk b/Application.mk index 57b7eedc45..51ce6eff24 100644 --- a/Application.mk +++ b/Application.mk @@ -132,7 +132,7 @@ endef define ELFLD @echo "LD: $2" - $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) $(ARCHCRT0OBJ) $1 $(LDSTARTGROUP) $(LDLIBS) $(LDENDGROUP) -o $2 + $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) $(ARCHCRT0OBJ) $1 $(LDLIBS) -o $2 endef $(RAOBJS): %.s$(SUFFIX)$(OBJEXT): %.s diff --git a/nshlib/nsh_command.c b/nshlib/nsh_command.c index 99af79b22f..61fef3d188 100644 --- a/nshlib/nsh_command.c +++ b/nshlib/nsh_command.c @@ -402,8 +402,8 @@ static const struct cmdmap_s g_cmdmap[] = #endif #if defined(CONFIG_PM) && !defined(CONFIG_NSH_DISABLE_PMCONFIG) - { "pmconfig", cmd_pmconfig, 1, 4, - "[stay|relax] [normal|idle|standby|sleep] [domain]" }, + { "pmconfig", cmd_pmconfig, 1, 3, + "[stay|relax] [normal|idle|standby|sleep]" }, #endif #if defined(CONFIG_BOARDCTL_POWEROFF) && !defined(CONFIG_NSH_DISABLE_POWEROFF) diff --git a/nshlib/nsh_syscmds.c b/nshlib/nsh_syscmds.c index 40a4491131..dcad16d26c 100644 --- a/nshlib/nsh_syscmds.c +++ b/nshlib/nsh_syscmds.c @@ -178,7 +178,7 @@ int cmd_pmconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { }; - if (argc <= 2) + if (argc == 1) { int current_state; int normal_count; @@ -186,11 +186,6 @@ int cmd_pmconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) int standby_count; int sleep_count; - if (argc == 2) - { - ctrl.domain = atoi(argv[1]); - } - ctrl.action = BOARDIOC_PM_QUERYSTATE; boardctl(BOARDIOC_PM_CONTROL, (uintptr_t)&ctrl); current_state = ctrl.state; @@ -215,13 +210,8 @@ int cmd_pmconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) nsh_output(vtbl, "Current state %d, PM stay [%d, %d, %d, %d]\n", current_state, normal_count, idle_count, standby_count, sleep_count); } - else if (argc <= 4) + else if (argc == 3) { - if (argc == 4) - { - ctrl.domain = atoi(argv[3]); - } - if (strcmp(argv[1], "stay") == 0) { ctrl.action = BOARDIOC_PM_STAY; From 4d2cc0b0488581309e1608e79511bfbb760323aa Mon Sep 17 00:00:00 2001 From: Lee Lup Yuen Date: Mon, 9 May 2022 10:36:26 +0800 Subject: [PATCH 3/3] Revert "Revert "Merge updates from master"" --- .gitignore | 2 ++ Application.mk | 2 +- nshlib/nsh_command.c | 4 ++-- nshlib/nsh_syscmds.c | 14 ++++++++++++-- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index b1ef6cfe69..e2c57e5e54 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ *.d *.dSYM *.exe +*.gcno +*.gcda *.hobj *.i *.lib diff --git a/Application.mk b/Application.mk index 51ce6eff24..57b7eedc45 100644 --- a/Application.mk +++ b/Application.mk @@ -132,7 +132,7 @@ endef define ELFLD @echo "LD: $2" - $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) $(ARCHCRT0OBJ) $1 $(LDLIBS) -o $2 + $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) $(ARCHCRT0OBJ) $1 $(LDSTARTGROUP) $(LDLIBS) $(LDENDGROUP) -o $2 endef $(RAOBJS): %.s$(SUFFIX)$(OBJEXT): %.s diff --git a/nshlib/nsh_command.c b/nshlib/nsh_command.c index 61fef3d188..99af79b22f 100644 --- a/nshlib/nsh_command.c +++ b/nshlib/nsh_command.c @@ -402,8 +402,8 @@ static const struct cmdmap_s g_cmdmap[] = #endif #if defined(CONFIG_PM) && !defined(CONFIG_NSH_DISABLE_PMCONFIG) - { "pmconfig", cmd_pmconfig, 1, 3, - "[stay|relax] [normal|idle|standby|sleep]" }, + { "pmconfig", cmd_pmconfig, 1, 4, + "[stay|relax] [normal|idle|standby|sleep] [domain]" }, #endif #if defined(CONFIG_BOARDCTL_POWEROFF) && !defined(CONFIG_NSH_DISABLE_POWEROFF) diff --git a/nshlib/nsh_syscmds.c b/nshlib/nsh_syscmds.c index dcad16d26c..40a4491131 100644 --- a/nshlib/nsh_syscmds.c +++ b/nshlib/nsh_syscmds.c @@ -178,7 +178,7 @@ int cmd_pmconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { }; - if (argc == 1) + if (argc <= 2) { int current_state; int normal_count; @@ -186,6 +186,11 @@ int cmd_pmconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) int standby_count; int sleep_count; + if (argc == 2) + { + ctrl.domain = atoi(argv[1]); + } + ctrl.action = BOARDIOC_PM_QUERYSTATE; boardctl(BOARDIOC_PM_CONTROL, (uintptr_t)&ctrl); current_state = ctrl.state; @@ -210,8 +215,13 @@ int cmd_pmconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) nsh_output(vtbl, "Current state %d, PM stay [%d, %d, %d, %d]\n", current_state, normal_count, idle_count, standby_count, sleep_count); } - else if (argc == 3) + else if (argc <= 4) { + if (argc == 4) + { + ctrl.domain = atoi(argv[3]); + } + if (strcmp(argv[1], "stay") == 0) { ctrl.action = BOARDIOC_PM_STAY;