@@ -15,13 +15,13 @@ LibXR 支持两种串口类型:**硬件串口** 和 **USB CDC**。它们均可
1515
1616``` cpp
1717// 硬件串口
18- STM32UART usart1 (&huart1, usart1_rx_buf, usart1_tx_buf, 5, 5 );
18+ STM32UART usart1 (&huart1, usart1_rx_buf, usart1_tx_buf, 5);
1919
2020// USB CDC(FreeRTOS 或裸机下)
21- STM32VirtualUART uart_cdc(hUsbDeviceFS, UserTxBufferFS, UserRxBufferFS, 5, 5 );
21+ STM32VirtualUART uart_cdc(hUsbDeviceFS, UserTxBufferFS, UserRxBufferFS, 5);
2222
2323// USB CDC(ThreadX + USBX)
24- STM32VirtualUART uart_cdc(&hpcd_USB_FS, 2048, 2, 2048, 2, 5, 12, 256);
24+ STM32VirtualUART uart_cdc(&hpcd_USB_FS, 2048, 2, 2048, 2, 12, 256);
2525```
2626
2727> 注意:在 **ThreadX 系统** 中,使用 USBX 替代 ST 官方 USB 库,构造函数参数也不同,使用 USB PCD 句柄(如 `&hpcd_USB_FS`)初始化。
@@ -30,12 +30,12 @@ STM32VirtualUART uart_cdc(&hpcd_USB_FS, 2048, 2, 2048, 2, 5, 12, 256);
3030
3131```cpp
3232// 如果使用硬件串口
33- STDIO::read_ = & usart1.read_port_;
34- STDIO::write_ = & usart1.write_port_;
33+ STDIO::read_ = usart1.read_port_;
34+ STDIO::write_ = usart1.write_port_;
3535
3636// 如果使用 USB CDC
37- STDIO::read_ = & uart_cdc.read_port_;
38- STDIO::write_ = & uart_cdc.write_port_;
37+ STDIO::read_ = uart_cdc.read_port_;
38+ STDIO::write_ = uart_cdc.write_port_;
3939
4040// 创建虚拟文件系统
4141RamFS ramfs("XRobot");
@@ -63,23 +63,25 @@ terminal_thread.Create(&terminal, terminal.ThreadFun, "terminal", 512,
6363terminal_source : usb
6464
6565# 终端相关配置(可选)
66- terminal :
67- RunAsThread : true # 是否作为线程运行(ThreadX 推荐)
68- ThreadStackDepth : 512 # 线程栈深度
69- ThreadPriority : 3 # 线程优先级(对应 LibXR::Thread::Priority)
66+ Terminal :
67+ READ_BUFF_SIZE : 32 # 终端读取缓冲区大小
68+ MAX_LINE_SIZE : 32 # 每行最大字符数
69+ MAX_ARG_NUMBER : 5 # 每行最大参数个数
70+ MAX_HISTORY_NUMBER : 5 # 历史命令个数
71+ RunAsThread : true # 是否作为线程运行
72+ ThreadStackDepth : 1024 # 线程栈深度(仅在线程下有效)
73+ ThreadPriority : 3 # 线程优先级(仅在线程下有效)
7074
7175# 硬件串口配置
7276USART :
7377 usart1 :
7478 tx_buffer_size : 128
7579 rx_buffer_size : 128
7680 tx_queue_size : 5
77- rx_queue_size : 5
7881
7982# USB CDC 配置(FreeRTOS 下有效)
8083USB :
8184 tx_queue_size : 12
82- rx_queue_size : 12
8385` ` `
8486
8587> USB 的 ` UserTxBufferFS` 与 `UserRxBufferFS` 缓冲区仅在使用 **官方 USB 库**(FreeRTOS)时有效。ThreadX + USBX 模式不需要配置这些缓冲。
0 commit comments