本帖最后由 Rxxkles 于 2025-9-2 22:13 编辑
本人无USB应用的编程经验,今天尝试将例程中的USBH HID应用移植到现有的项目中时遇到了一些问题。
- while(1)
- {
- usbh_loop_handler(&otg_core_struct.host);
- }
将该段代码改写成rt-thread的线程
- while(1)
- {
- rt_thread_delay(50);
- usbh_loop_handler(&otg_core_struct.host);
- }
并且将 usb_conf.h 中的 void usb_delay_ms(uint32_t ms); 重定义为 #define usb_delay_ms(ms) rt_thread_delay(ms)
线程中加入rt_thread_delay(50);,串口无法输出键盘输入的字符;
将rt_thread_delay(50);注释之后串口就可以正常输出键盘输入的内容。
请问这是为什么。
|