summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2020-10-13 23:26:44 +0800
committerGitHub <[email protected]>2020-10-13 23:26:44 +0800
commitb809c020150a371824481f7f4bb3b5608ff1f85e (patch)
tree1d70d7a4aa73978ac7a2fa61c77300eb9084aa7a
parent92c54a5c80fdd6f539d36566cd7aa848e0ecdd23 (diff)
parent01bdb2c86e8875dbe14efa6b47e2c7948555c4ab (diff)
Merge pull request #3957 from thread-liu/develop
[update] Dynamic change console
-rw-r--r--bsp/stm32/stm32mp157a-st-discovery/applications/main.c12
-rw-r--r--bsp/stm32/stm32mp157a-st-discovery/board/ports/OpenAMP/drv_openamp.c34
2 files changed, 38 insertions, 8 deletions
diff --git a/bsp/stm32/stm32mp157a-st-discovery/applications/main.c b/bsp/stm32/stm32mp157a-st-discovery/applications/main.c
index 43f0f648a4..d8f61de87e 100644
--- a/bsp/stm32/stm32mp157a-st-discovery/applications/main.c
+++ b/bsp/stm32/stm32mp157a-st-discovery/applications/main.c
@@ -12,20 +12,20 @@
#include <rtdevice.h>
#include <board.h>
-/* defined the LD8 pin: PD11 */
-#define LED8_PIN GET_PIN(D, 11)
+/* defined the LD7 pin: PH7 */
+#define LED7_PIN GET_PIN(H, 7)
int main(void)
{
int count = 1;
- /* set LD8 pin mode to output */
- rt_pin_mode(LED8_PIN, PIN_MODE_OUTPUT);
+ /* set LD7 pin mode to output */
+ rt_pin_mode(LED7_PIN, PIN_MODE_OUTPUT);
while (count++)
{
- rt_pin_write(LED8_PIN, PIN_HIGH);
+ rt_pin_write(LED7_PIN, PIN_HIGH);
rt_thread_mdelay(500);
- rt_pin_write(LED8_PIN, PIN_LOW);
+ rt_pin_write(LED7_PIN, PIN_LOW);
rt_thread_mdelay(500);
}
diff --git a/bsp/stm32/stm32mp157a-st-discovery/board/ports/OpenAMP/drv_openamp.c b/bsp/stm32/stm32mp157a-st-discovery/board/ports/OpenAMP/drv_openamp.c
index 2705f068a3..58e1c95f39 100644
--- a/bsp/stm32/stm32mp157a-st-discovery/board/ports/OpenAMP/drv_openamp.c
+++ b/bsp/stm32/stm32mp157a-st-discovery/board/ports/OpenAMP/drv_openamp.c
@@ -234,8 +234,6 @@ int rt_hw_openamp_init(void)
openamp_init();
rt_hw_openamp_register(&dev_openamp, "openamp", 0, NULL);
-
- rt_console_set_device("openamp");
return RT_EOK;
}
@@ -289,4 +287,36 @@ static int creat_openamp_thread(void)
}
INIT_APP_EXPORT(creat_openamp_thread);
+#ifdef FINSH_USING_MSH
+
+static int console(int argc, char **argv)
+{
+ rt_err_t result = RT_EOK;
+
+ if (argc > 1)
+ {
+ if (!strcmp(argv[1], "set"))
+ {
+ rt_kprintf("console change to %s\n", argv[2]);
+ rt_console_set_device(argv[2]);
+ finsh_set_device(argv[2]);
+ }
+ else
+ {
+ rt_kprintf("Unknown command. Please enter 'console' for help\n");
+ result = -RT_ERROR;
+ }
+ }
+ else
+ {
+ rt_kprintf("Usage: \n");
+ rt_kprintf("console set <name> - change console by name\n");
+ result = -RT_ERROR;
+ }
+ return result;
+}
+MSH_CMD_EXPORT(console, set console name);
+
+#endif /* FINSH_USING_MSH */
+
#endif