From 01bdb2c86e8875dbe14efa6b47e2c7948555c4ab Mon Sep 17 00:00:00 2001 From: thread-liu Date: Tue, 13 Oct 2020 15:10:55 +0800 Subject: [PATCH] [update] Dynamic change console --- .../applications/main.c | 12 +++---- .../board/ports/OpenAMP/drv_openamp.c | 34 +++++++++++++++++-- 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 43f0f648a..d8f61de87 100644 --- a/bsp/stm32/stm32mp157a-st-discovery/applications/main.c +++ b/bsp/stm32/stm32mp157a-st-discovery/applications/main.c @@ -12,20 +12,20 @@ #include #include -/* 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 2705f068a..58e1c95f3 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 - change console by name\n"); + result = -RT_ERROR; + } + return result; +} +MSH_CMD_EXPORT(console, set console name); + +#endif /* FINSH_USING_MSH */ + #endif -- GitLab