STM32F103C8
Serial(UART) to USB HID Keyboard Mouse Joystick
串口 转 USB键盘;鼠标;手柄
(1) 使用Composite Device 组合(复合)设备
(1.1) 1个Device -> 1个 Configuation -> 3个Interfance (Keyboard & Mouse & Joystick)
(1.2) 支持BIOS模式中的操作(使用HID boot模式) 以便兼容在计算器中设定BIOS :
(1.2.1) Keyboard Interfance -> HID (boot mode) -> 2个Endpoint(IN_0x81 & OUT_0x01) -> KeyboardReportDescriptor(不使用Report ID)
(1.2.2) Mouse Interfance -> HID (boot mode) -> 1个Endpoint(IN_0x82) -> MouseReportDescriptor(不使用Report ID)
(1.3) 支持Windows模式中的操作(使用Report ID) :
(1.3.1) Multimedia Keyboard Interfance -> HID -> 1个Endpoint(IN_0x85) -> KeyboardReportDescriptor(使用Report ID)
(1.3.1.1) Report ID (1) : HID Usage Page 0x0C, MediaKey
(1.3.1.2) Report ID (2) : HID Usage Page 0x01, PowerControl
(1.3.2) Mouse Interfance -> HID (boot mode) -> 1个Endpoint(IN_0x84) -> MouseReportDescriptor(使用Report ID)
(1.3.2.1) Report ID (1) : 相对坐标 (-32768 ~ 32767)
(1.3.2.2) Report ID (2) : 绝对坐标 (0 ~ 2048)
(1.4) 支持反馈Keyboard_LED灯号: All Off; Num Lock; Caps Lock; Scroll Lock; Compose; Kana
(1.5) Joystick Interfance -> HID -> 1个Endpoint(IN_0x83) -> JoyStickReportDescriptor
(1.7) 支持GPIO命令, 可控制 12个GPIO 0/1 (hi/low)输出
(1.8) 支持Hardware或Software 插拔(Connect/Disconnect)命令
(1.9) 支持Software Reset命令
(2) 串口接收 命令
(2.1) UART协议: 115200, n, 8, 1
(2.2) 1帧发送字符串格式, 以 '{'开始, '}'结束 ','分隔 共10个10进制数字
例如: {1,2,3,4,5,6,7,8,9,10}
(2.3) 第1位 区分 Keyboard(128) 或是 Mouse(64) 或是 Joystick(32) 或是 Control(32) 命令
Control_cmd = 0x10,
Joystick_cmd = 0x20,
Mouse_cmd = 0x40,
MouseHold_cmd = 0x41,
AbsMouse_cmd = 0x42,
AbsMouseHold_cmd= 0x43,
Keyboard_cmd = 0x80,
KeyboardHold_cmd= 0x81,
MediaKey_cmd = 0x82,
MediaKeyHold_cmd= 0x83,
Switch_cmd = 0xC0,
SwitchHold_cmd = 0xC1
例如:
{16, 0,0,0,0,0,0,0,0} --- 发送Control命令
{32, 0,0,0,0,0,0,0,0} --- 发送Joystick命令
{64, 0,0,0,0,0,0,0,0} --- 发送Mouse命令(相对坐标)
{65, 0,0,0,0,0,0,0,0} --- 发送Mouse命令(相对坐标)(按住不放)
{66, 0,0,0,0,0,0,0,0} --- 发送WinMouse命令(相对坐标/绝对坐标)
{67, 0,0,0,0
1