可以参考一下arduino uno上串口模块的代码
原版的uno就是用单片机模拟的USB
可以参考这篇文章来学习stm32的HID设备
https://blog.csdn.net/tq384998430/article/details/53337245