提交 01bdb2c8 编写于 作者: T thread-liu

[update] Dynamic change console

上级 8edb7c31
......@@ -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);
}
......
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册