diff options
| author | thread-liu <[email protected]> | 2020-10-13 15:10:55 +0800 |
|---|---|---|
| committer | thread-liu <[email protected]> | 2020-10-13 15:11:37 +0800 |
| commit | 01bdb2c86e8875dbe14efa6b47e2c7948555c4ab (patch) | |
| tree | 3c08d015d88924912ff3956d580ba0238f509ade | |
| parent | 8edb7c316aae48b39b479c7fe03e3e3aaf435be4 (diff) | |
[update] Dynamic change console
| -rw-r--r-- | bsp/stm32/stm32mp157a-st-discovery/applications/main.c | 12 | ||||
| -rw-r--r-- | bsp/stm32/stm32mp157a-st-discovery/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 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 |
