rt_hw_swo_init(); //初始化SWO,此时仅支持输出功能
rt_console_set_device("swo");
/* ............. */
rt_hw_swo_start(); // 启动监听线程,仅能在调试器启动以后执行
finsh_set_device("swo"); // 启动监听以后,就可以支持输入功能了,可以把finsh设置过来
static int finsh_getchar(void)
{
#ifdef RT_USING_POSIX
return getchar();
#else
char ch = 0;
RT_ASSERT(shell != RT_NULL);
while (rt_device_read(shell->device, -1, &ch, 1) != 1)
rt_sem_take(&shell->rx_sem, RT_WAITING_FOREVER);
return (int)ch;
#endif
}
/**
* uart operators
*/
struct rt_uart_ops
{
rt_err_t (*configure)(struct rt_serial_device *serial, struct serial_configure *cfg);
rt_err_t (*control)(struct rt_serial_device *serial, int cmd, void *arg);
int (*putc)(struct rt_serial_device *serial, char c);
int (*getc)(struct rt_serial_device *serial);
rt_size_t (*dma_transmit)(struct rt_serial_device *serial, rt_uint8_t *buf, rt_size_t size, int direction);
};