{"id":97665,"date":"2026-08-29T23:17:22","date_gmt":"2026-08-29T15:17:22","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/97665.html"},"modified":"2026-08-29T23:17:22","modified_gmt":"2026-08-29T15:17:22","slug":"stm32-usb-hid-%e6%95%99%e7%a8%8b%ef%bc%9atinyusb-%e5%ae%9e%e7%8e%b0%e9%94%ae%e7%9b%98%e8%ae%be%e5%a4%87%ef%bc%8c%e4%bb%8e%e6%8f%8f%e8%bf%b0%e7%ac%a6%e5%88%b0%e6%9e%9a%e4%b8%be","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/97665.html","title":{"rendered":"STM32 USB HID \u6559\u7a0b\uff1aTinyUSB \u5b9e\u73b0\u952e\u76d8\u8bbe\u5907\uff0c\u4ece\u63cf\u8ff0\u7b26\u5230\u679a\u4e3e"},"content":{"rendered":"<h3>\u80cc\u666f&#xff1a;STM32 \u7684 USB \u5f00\u53d1\u4e3a\u4ec0\u4e48\u529d\u9000<\/h3>\n<p>USB \u534f\u8bae\u6808\u662f\u5d4c\u5165\u5f0f\u9886\u57df\u5b66\u4e60\u66f2\u7ebf\u6700\u9661\u7684\u6280\u672f\u4e4b\u4e00&#xff0c;\u800c STM32 \u7684 USB \u5f00\u53d1\u53c8\u628a\u8fd9\u5c42\u96be\u5ea6\u653e\u5927\u4e86&#xff1a;ST HAL \u5e93\u628a\u534f\u8bae\u6808\u85cf\u5728\u5c42\u5c42\u56de\u8c03\u540e\u9762&#xff0c;USB \u590d\u4f4d\u3001\u679a\u4e3e\u3001\u63cf\u8ff0\u7b26\u4ea4\u6362\u5168\u662f\u9ed1\u76d2&#xff0c;\u6539\u4e00\u4e2a\u5b57\u6bb5\u53ef\u80fd\u7275\u52a8\u516d\u4e2a\u5730\u65b9&#xff0c;\u51fa\u9519\u65f6\u53c8\u4e0d\u77e5\u9053\u4ece\u54ea\u91cc\u67e5\u2014\u2014USB \u5206\u6790\u4eea\u4e00\u53f0\u51e0\u5343\u5757&#xff0c;\u591a\u6570\u4eba\u53ea\u80fd\u9760 printf \u76f2\u8c03\u3002<\/p>\n<p>TinyUSB \u8d70\u7684\u662f\u53cd\u65b9\u5411&#xff1a;\u628a\u63cf\u8ff0\u7b26\u4ece\u9ed1\u76d2\u91cc\u62ff\u51fa\u6765&#xff0c;\u53d8\u6210\u4f60\u4eb2\u624b\u5199\u7684\u5b57\u8282\u6570\u7ec4\u3002\u672c\u6587\u7ed9\u51fa\u5728 STM32 \u4e0a\u5b9e\u73b0\u4e00\u4e2a USB HID \u952e\u76d8\u8bbe\u5907\u7684\u5b8c\u6574\u6d41\u7a0b\u3002<\/p>\n<p>\u73af\u5883&#xff1a;STM32F4 \/ F7 \/ H7 \/ L4 \/ G4&#xff08;TinyUSB \u5df2\u5185\u7f6e\u79fb\u690d\u5c42&#xff09;&#xff1b;CubeMX \u914d\u65f6\u949f&#xff1b;\u7f16\u8bd1\u94fe arm-none-eabi-gcc\u3002<\/p>\n<h3>\u4e00\u3001\u4e00\u4e2a\u5b8f\u5b9a\u4e0b\u8bbe\u5907\u7c7b\u578b<\/h3>\n<p><span class=\"token comment\">\/\/ tusb_config.h \u2014\u2014 \u4e09\u884c\u5b8f&#xff0c;USB \u8bbe\u5907\u7c7b\u578b\u5c31\u5b9a\u4e0b\u6765\u4e86<\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">define<\/span> <span class=\"token macro-name\">CFG_TUD_HID<\/span>   <span class=\"token expression\"><span class=\"token number\">1<\/span><\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">define<\/span> <span class=\"token macro-name\">CFG_TUD_CDC<\/span>   <span class=\"token expression\"><span class=\"token number\">0<\/span><\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">define<\/span> <span class=\"token macro-name\">CFG_TUD_MSC<\/span>   <span class=\"token expression\"><span class=\"token number\">0<\/span><\/span><\/span><\/p>\n<p>\u63d2\u4e0a USB \u7ebf&#xff0c;STM32 \u5c31\u662f\u4e00\u53f0\u6807\u51c6 HID \u8bbe\u5907&#xff0c;Windows \/ Linux \/ macOS \u81ea\u5e26\u9a71\u52a8\u3002\u5148\u5efa\u7acb\u76f4\u89c9&#xff1a;USB \u672c\u8d28\u662f\u4e00\u5957\u95ee\u7b54\u6e38\u620f&#xff0c;\u4e3b\u673a\u95ee\u300c\u4f60\u662f\u4ec0\u4e48\u8bbe\u5907\u300d\u8bbe\u5907\u7b54\u300c\u6211\u662f\u952e\u76d8\u300d&#xff0c;\u4e3b\u673a\u95ee\u300c\u6570\u636e\u683c\u5f0f\u300d\u8bbe\u5907\u7b54\u300c8 \u5b57\u8282&#xff0c;1 \u5b57\u8282\u4fee\u9970\u952e &#043; 6 \u5b57\u8282\u6309\u952e\u7801\u300d\u3002\u8fd9\u5957\u95ee\u7b54\u7684\u6807\u51c6\u7b54\u6848\u6a21\u677f&#xff0c;\u5c31\u662f\u63cf\u8ff0\u7b26\u3002<\/p>\n<p>\u5bf9\u6bd4\u4e24\u79cd\u5199\u6cd5\u7684\u5dee\u522b&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ HAL \u7684\u65b9\u5f0f&#xff1a;\u63cf\u8ff0\u7b26\u85cf\u5728\u7ed3\u6784\u4f53\u8d4b\u503c\u91cc<\/span><br \/>\npdev<span class=\"token operator\">-&gt;<\/span>DevDesc<span class=\"token punctuation\">.<\/span>bDeviceClass <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0x00<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ TinyUSB \u7684\u65b9\u5f0f&#xff1a;\u63cf\u8ff0\u7b26\u5c31\u662f\u624b\u5199\u7684\u5b57\u8282\u6570\u7ec4&#xff0c;\u4f60\u5199\u4ec0\u4e48\u603b\u7ebf\u4e0a\u5c31\u662f\u4ec0\u4e48<\/span><br \/>\n<span class=\"token class-name\">uint8_t<\/span> <span class=\"token keyword\">const<\/span> desc_hid_report<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token function\">TUD_HID_REPORT_DESC_KEYBOARD<\/span><span class=\"token punctuation\">(<\/span><span class=\"token function\">HID_REPORT_ID<\/span><span class=\"token punctuation\">(<\/span>RID_KEYBOARD<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u4ece\u6570\u636e\u5230\u603b\u7ebf\u7684\u6620\u5c04\u662f\u900f\u660e\u7684\u2014\u2014\u51fa\u4e86 bug \u628a\u6570\u7ec4 dump \u51fa\u6765\u8ddf USB \u89c4\u8303\u5bf9\u7167\u5373\u53ef\u3002<\/p>\n<h3>\u4e8c\u3001HID \u63cf\u8ff0\u7b26&#xff1a;\u4e09\u4efd\u8eab\u4efd\u6750\u6599<\/h3>\n<p>USB \u679a\u4e3e\u7684\u672c\u8d28\u662f\u8bbe\u5907\u5411\u4e3b\u673a\u9012\u4ea4\u4e09\u4efd\u6750\u6599&#xff1a;<\/p>\n<p>1. \u8bbe\u5907\u63cf\u8ff0\u7b26&#xff08;\u6211\u662f\u8c01&#xff09;&#xff1a;<\/p>\n<p><span class=\"token class-name\">tusb_desc_device_t<\/span> <span class=\"token keyword\">const<\/span> desc_device <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token punctuation\">.<\/span>bLength            <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">tusb_desc_device_t<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token punctuation\">.<\/span>bDescriptorType    <span class=\"token operator\">&#061;<\/span> TUSB_DESC_DEVICE<span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token punctuation\">.<\/span>bcdUSB             <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0x0200<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token punctuation\">.<\/span>idVendor           <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0xCafe<\/span><span class=\"token punctuation\">,<\/span>   <span class=\"token comment\">\/\/ \u4f60\u7684 VID<\/span><br \/>\n    <span class=\"token punctuation\">.<\/span>idProduct          <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0x4001<\/span><span class=\"token punctuation\">,<\/span>   <span class=\"token comment\">\/\/ \u4f60\u7684 PID<\/span><br \/>\n    <span class=\"token punctuation\">.<\/span>bNumConfigurations <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>VID\/PID \u5efa\u8bae&#xff1a;\u81ea\u5df1\u73a9\u7528 0xCAFE \/ 0xBEEF \u8fd9\u7c7b\u6d4b\u8bd5 ID&#xff1b;\u6b63\u5f0f\u4ea7\u54c1\u5411 USB-IF \u7533\u8bf7\u6216\u4ece\u82af\u7247\u5382\u5546\u83b7\u53d6\u5b50\u6388\u6743\u3002\u522b\u7528 STM32 \u5b98\u65b9 VID&#xff08;0x0483&#xff09;&#xff0c;\u5426\u5219 Linux \u4e0a\u53ef\u80fd\u628a\u8bbe\u5907\u8ba4\u6210 ST-Link\u3002<\/p>\n<p>2. \u914d\u7f6e\u63cf\u8ff0\u7b26&#xff08;\u6211\u80fd\u5e72\u4ec0\u4e48&#xff0c;HID \u901a\u5e38\u53ea\u7528\u4e00\u79cd\u914d\u7f6e&#xff09;\u3002<\/p>\n<p>3. HID \u62a5\u544a\u63cf\u8ff0\u7b26&#xff08;\u6211\u7684\u6570\u636e\u957f\u4ec0\u4e48\u6837&#xff0c;HID \u8bbe\u5907\u7684\u7075\u9b42&#xff09;\u3002TUD_HID_REPORT_DESC_KEYBOARD \u5b8f\u5c55\u5f00\u7ea6 60 \u5b57\u8282&#xff0c;\u5b9a\u4e49\u4fee\u9970\u952e 1 \u5b57\u8282\u3001\u4fdd\u7559 1 \u5b57\u8282\u3001\u6309\u952e\u7801 6 \u5b57\u8282\u3002<\/p>\n<h3>\u4e09\u3001\u4e94\u6b65\u4ece\u7f16\u8bd1\u5230\u679a\u4e3e<\/h3>\n<p>Step 1&#xff1a;CubeMX \u914d\u65f6\u949f\u3002 USB \u5916\u8bbe\u8981 48MHz \u7cbe\u51c6\u65f6\u949f&#xff0c;\u7528 HSI48 &#043; CRS&#xff08;\u65f6\u949f\u6062\u590d&#xff09;\u6700\u7701\u4e8b&#xff0c;\u65e0\u9700\u5916\u90e8\u6676\u632f\u3002\u52fe\u4e0a USB \u5916\u8bbe&#xff0c;\u4e0d\u8981\u52fe ST \u7684 USB Device \u4e2d\u95f4\u4ef6\u3002<\/p>\n<p>Step 2&#xff1a;\u62c9\u6e90\u7801\u3002 git clone https:\/\/github.com\/hathach\/tinyusb.git&#xff0c;\u628a src\/ \u62f7\u5230\u9879\u76ee Middlewares\/ \u4e0b&#xff0c;\u79fb\u690d tusb_config.h \u548c\u82af\u7247\u79fb\u690d\u5c42&#xff08;STM32F4 \u5df2\u5185\u7f6e&#xff09;\u3002<\/p>\n<p>Step 3&#xff1a;\u5199\u63cf\u8ff0\u7b26\u3002 \u5efa usb_descriptors.c \u5b9a\u4e49\u56db\u79cd\u63cf\u8ff0\u7b26&#xff0c;\u5b9e\u73b0\u56de\u8c03&#xff1a;<\/p>\n<p><span class=\"token class-name\">uint8_t<\/span> <span class=\"token keyword\">const<\/span> <span class=\"token operator\">*<\/span><span class=\"token function\">tud_descriptor_device_cb<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token class-name\">uint8_t<\/span> <span class=\"token keyword\">const<\/span> <span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span><span class=\"token operator\">&amp;<\/span>desc_device<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>Step 4&#xff1a;\u5b9e\u73b0 HID \u56de\u8c03\u3002<\/p>\n<p><span class=\"token class-name\">uint16_t<\/span> <span class=\"token function\">tud_hid_get_report_cb<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">uint8_t<\/span> instance<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">uint8_t<\/span> report_id<span class=\"token punctuation\">,<\/span><br \/>\n                                <span class=\"token class-name\">hid_report_type_t<\/span> report_type<span class=\"token punctuation\">,<\/span><br \/>\n                                <span class=\"token class-name\">uint8_t<\/span> <span class=\"token operator\">*<\/span>buffer<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">uint16_t<\/span> reqlen<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span>   <span class=\"token comment\">\/\/ \u4e3b\u673a\u8bfb\u62a5\u544a&#xff08;\u679a\u4e3e\u5b8c\u8bfb\u4e00\u6b21&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">tud_hid_set_report_cb<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">uint8_t<\/span> instance<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">uint8_t<\/span> report_id<span class=\"token punctuation\">,<\/span><br \/>\n                           <span class=\"token class-name\">hid_report_type_t<\/span> report_type<span class=\"token punctuation\">,<\/span><br \/>\n                           <span class=\"token class-name\">uint8_t<\/span> <span class=\"token keyword\">const<\/span> <span class=\"token operator\">*<\/span>buffer<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">uint16_t<\/span> bufsize<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u4e3b\u673a\u53d1\u62a5\u544a&#xff08;\u952e\u76d8 LED \u72b6\u6001&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>Step 5&#xff1a;\u4e3b\u5faa\u73af\u53d1\u6570\u636e\u3002<\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">hid_task<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token operator\">!<\/span><span class=\"token function\">tud_hid_ready<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">return<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u8fd8\u6ca1\u679a\u4e3e\u5b8c&#xff0c;\u8df3\u8fc7<\/span><\/p>\n<p>    <span class=\"token class-name\">uint8_t<\/span> report<span class=\"token punctuation\">[<\/span><span class=\"token number\">8<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    report<span class=\"token punctuation\">[<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;<\/span> HID_KEY_A<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">tud_hid_report<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">,<\/span> report<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span>report<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>   <span class=\"token comment\">\/\/ \u53d1\u9001 &#039;A&#039;<\/span><\/p>\n<p>    <span class=\"token function\">memset<\/span><span class=\"token punctuation\">(<\/span>report<span class=\"token punctuation\">,<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span>report<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">tud_hid_report<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">,<\/span> report<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span>report<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>   <span class=\"token comment\">\/\/ \u53d1\u7a7a\u62a5\u544a\u91ca\u653e\u6309\u952e<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u8fde\u4e0a USB \u7ebf&#xff0c;lsusb \u6216\u8bbe\u5907\u7ba1\u7406\u5668\u91cc\u5c31\u80fd\u770b\u5230 CAFE:4001 \u7684\u65b0\u8bbe\u5907\u3002<\/p>\n<h3>\u56db\u3001\u5c40\u9650<\/h3>\n<li>\u4e0d\u662f\u6240\u6709 STM32 \u7cfb\u5217\u90fd\u6709\u79fb\u690d\u5c42&#xff1a;\u5b98\u65b9\u652f\u6301 F4 \/ F7 \/ H7 \/ L4 \/ G4&#xff0c;\u8f83\u65b0\u7684 H5 \/ H7RS \/ U5&#xff08;\u5e26 USB 3.0 PHY&#xff09;\u79fb\u690d\u8fd8\u5728\u5f00\u53d1&#xff0c;\u9009\u578b\u524d\u5230 TinyUSB \u7684 supported MCU \u5217\u8868\u786e\u8ba4\u3002<\/li>\n<li>\u591a\u5b9e\u4f8b HID \u6709\u9650\u5236&#xff1a;\u53ef\u540c\u65f6\u505a\u952e\u76d8&#043;\u9f20\u6807&#xff0c;\u4f46\u7aef\u70b9\u914d\u7f6e\u5728 DCD \u5c42\u590d\u7528\u8d44\u6e90\u6c60&#xff0c;\u4e0d\u540c\u5b9e\u4f8b\u8981\u4e0d\u540c\u8f6e\u8be2\u95f4\u9694\u9700\u6539\u79fb\u690d\u5c42\u3002<\/li>\n<li>Isochronous \u4f20\u8f93\u4e0d\u6210\u719f&#xff1a;HID \u7528\u7684\u4e2d\u65ad\u4f20\u8f93\u6ca1\u95ee\u9898&#xff0c;\u4f46 USB \u9ea6\u514b\u98ce\/\u6444\u50cf\u5934\u8fd9\u7c7b Isochronous \u7aef\u70b9\u53ea\u5728\u90e8\u5206 MCU&#xff08;\u5982 ESP32-S2\/S3&#xff09;\u7a33\u5b9a\u3002<\/li>\n<li>\u8c03\u8bd5\u96be\u5ea6\u4f9d\u7136\u5728&#xff1a;\u4ee3\u7801\u6bd4 HAL \u900f\u660e&#xff0c;\u4f46\u534f\u8bae\u672c\u8eab\u6ca1\u53d8\u7b80\u5355\u3002\u65e0\u5206\u6790\u4eea\u65f6\u628a CFG_TUD_LOG_LEVEL \u5f00\u5230 3 \u770b\u63cf\u8ff0\u7b26\u8bf7\u6c42\u548c\u679a\u4e3e\u8fc7\u7a0b&#xff0c;\u662f\u53ef\u884c\u7684\u66ff\u4ee3\u3002<\/li>\n<h3>\u4e94\u3001\u603b\u7ed3<\/h3>\n<p>TinyUSB \u628a\u63cf\u8ff0\u7b26\u4ece HAL \u9ed1\u76d2\u91cc\u62ff\u51fa\u6765&#xff0c;\u53d8\u6210\u4f60\u76f4\u63a5\u53ef\u63a7\u7684\u5b57\u8282\u6570\u7ec4\u2014\u2014\u51fa\u4e86\u95ee\u9898\u80fd\u8ffd\u3001\u6539\u4e86\u80fd\u61c2\u3002\u60f3\u8981\u66f4\u7701\u4e8b\u53ef\u7528 Adafruit \u7684 TinyUSB Arduino \u5e93&#xff08;\u679a\u4e3e\u5168\u81ea\u52a8&#xff0c;\u7075\u6d3b\u5ea6\u6253\u6298&#xff09;&#xff1b;\u60f3\u7406\u89e3\u534f\u8bae\u3001\u8981\u7075\u6d3b\u63a7\u5236&#xff0c;\u5c31\u7528 TinyUSB\u3002\u5269\u4e0b\u7684\u4e8b&#xff1a;\u627e\u6839 USB \u7ebf\u3001\u70e7\u7a0b\u5e8f\u3001\u770b dmesg \u91cc\u5f39\u51fa\u65b0\u8bbe\u5907\u7684\u90a3\u4e00\u523b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u80cc\u666f&#xff1a;STM32 \u7684 USB \u5f00\u53d1\u4e3a\u4ec0\u4e48\u529d\u9000<br \/>\nUSB \u534f\u8bae\u6808\u662f\u5d4c\u5165\u5f0f\u9886\u57df\u5b66\u4e60\u66f2\u7ebf\u6700\u9661\u7684\u6280\u672f\u4e4b\u4e00&#xff0c;\u800c STM32 \u7684 USB \u5f00\u53d1\u53c8\u628a\u8fd9\u5c42\u96be\u5ea6\u653e\u5927\u4e86&#xff1a;ST HAL \u5e93\u628a\u534f\u8bae\u6808\u85cf\u5728\u5c42\u5c42\u56de\u8c03\u540e\u9762&#xff0c;USB \u590d\u4f4d\u3001\u679a\u4e3e\u3001\u63cf\u8ff0\u7b26\u4ea4\u6362\u5168\u662f\u9ed1\u76d2&#xff0c;\u6539\u4e00\u4e2a\u5b57\u6bb5\u53ef\u80fd\u7275\u52a8\u516d\u4e2a\u5730\u65b9&#xff0c;\u51fa\u9519\u65f6\u53c8\u4e0d\u77e5\u9053\u4ece\u54ea\u91cc\u67e5\u2014\u2014USB \u5206\u6790\u4eea\u4e00\u53f0\u51e0\u5343\u5757&#xff0c;\u591a\u6570\u4eba\u53ea\u80fd\u9760 printf \u76f2\u8c03\u3002<br \/>\nTinyUSB \u8d70\u7684\u662f\u53cd\u65b9\u5411&amp;#<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[822,217,270,269,168],"topic":[],"class_list":["post-97665","post","type-post","status-publish","format-standard","hentry","category-server","tag-mcu","tag-stm32","tag-270","tag-269","tag-168"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>STM32 USB HID \u6559\u7a0b\uff1aTinyUSB \u5b9e\u73b0\u952e\u76d8\u8bbe\u5907\uff0c\u4ece\u63cf\u8ff0\u7b26\u5230\u679a\u4e3e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/97665.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"STM32 USB HID \u6559\u7a0b\uff1aTinyUSB \u5b9e\u73b0\u952e\u76d8\u8bbe\u5907\uff0c\u4ece\u63cf\u8ff0\u7b26\u5230\u679a\u4e3e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u80cc\u666f&#xff1a;STM32 \u7684 USB \u5f00\u53d1\u4e3a\u4ec0\u4e48\u529d\u9000 USB \u534f\u8bae\u6808\u662f\u5d4c\u5165\u5f0f\u9886\u57df\u5b66\u4e60\u66f2\u7ebf\u6700\u9661\u7684\u6280\u672f\u4e4b\u4e00&#xff0c;\u800c STM32 \u7684 USB \u5f00\u53d1\u53c8\u628a\u8fd9\u5c42\u96be\u5ea6\u653e\u5927\u4e86&#xff1a;ST HAL \u5e93\u628a\u534f\u8bae\u6808\u85cf\u5728\u5c42\u5c42\u56de\u8c03\u540e\u9762&#xff0c;USB \u590d\u4f4d\u3001\u679a\u4e3e\u3001\u63cf\u8ff0\u7b26\u4ea4\u6362\u5168\u662f\u9ed1\u76d2&#xff0c;\u6539\u4e00\u4e2a\u5b57\u6bb5\u53ef\u80fd\u7275\u52a8\u516d\u4e2a\u5730\u65b9&#xff0c;\u51fa\u9519\u65f6\u53c8\u4e0d\u77e5\u9053\u4ece\u54ea\u91cc\u67e5\u2014\u2014USB \u5206\u6790\u4eea\u4e00\u53f0\u51e0\u5343\u5757&#xff0c;\u591a\u6570\u4eba\u53ea\u80fd\u9760 printf \u76f2\u8c03\u3002 TinyUSB \u8d70\u7684\u662f\u53cd\u65b9\u5411&amp;#\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/97665.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-29T15:17:22+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/97665.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/97665.html\",\"name\":\"STM32 USB HID \u6559\u7a0b\uff1aTinyUSB \u5b9e\u73b0\u952e\u76d8\u8bbe\u5907\uff0c\u4ece\u63cf\u8ff0\u7b26\u5230\u679a\u4e3e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-29T15:17:22+00:00\",\"dateModified\":\"2026-08-29T15:17:22+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/97665.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/97665.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/97665.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"STM32 USB HID \u6559\u7a0b\uff1aTinyUSB \u5b9e\u73b0\u952e\u76d8\u8bbe\u5907\uff0c\u4ece\u63cf\u8ff0\u7b26\u5230\u679a\u4e3e\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"STM32 USB HID \u6559\u7a0b\uff1aTinyUSB \u5b9e\u73b0\u952e\u76d8\u8bbe\u5907\uff0c\u4ece\u63cf\u8ff0\u7b26\u5230\u679a\u4e3e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/97665.html","og_locale":"zh_CN","og_type":"article","og_title":"STM32 USB HID \u6559\u7a0b\uff1aTinyUSB \u5b9e\u73b0\u952e\u76d8\u8bbe\u5907\uff0c\u4ece\u63cf\u8ff0\u7b26\u5230\u679a\u4e3e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u80cc\u666f&#xff1a;STM32 \u7684 USB \u5f00\u53d1\u4e3a\u4ec0\u4e48\u529d\u9000 USB \u534f\u8bae\u6808\u662f\u5d4c\u5165\u5f0f\u9886\u57df\u5b66\u4e60\u66f2\u7ebf\u6700\u9661\u7684\u6280\u672f\u4e4b\u4e00&#xff0c;\u800c STM32 \u7684 USB \u5f00\u53d1\u53c8\u628a\u8fd9\u5c42\u96be\u5ea6\u653e\u5927\u4e86&#xff1a;ST HAL \u5e93\u628a\u534f\u8bae\u6808\u85cf\u5728\u5c42\u5c42\u56de\u8c03\u540e\u9762&#xff0c;USB \u590d\u4f4d\u3001\u679a\u4e3e\u3001\u63cf\u8ff0\u7b26\u4ea4\u6362\u5168\u662f\u9ed1\u76d2&#xff0c;\u6539\u4e00\u4e2a\u5b57\u6bb5\u53ef\u80fd\u7275\u52a8\u516d\u4e2a\u5730\u65b9&#xff0c;\u51fa\u9519\u65f6\u53c8\u4e0d\u77e5\u9053\u4ece\u54ea\u91cc\u67e5\u2014\u2014USB \u5206\u6790\u4eea\u4e00\u53f0\u51e0\u5343\u5757&#xff0c;\u591a\u6570\u4eba\u53ea\u80fd\u9760 printf \u76f2\u8c03\u3002 TinyUSB \u8d70\u7684\u662f\u53cd\u65b9\u5411&amp;#","og_url":"https:\/\/www.wsisp.com\/helps\/97665.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-29T15:17:22+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/97665.html","url":"https:\/\/www.wsisp.com\/helps\/97665.html","name":"STM32 USB HID \u6559\u7a0b\uff1aTinyUSB \u5b9e\u73b0\u952e\u76d8\u8bbe\u5907\uff0c\u4ece\u63cf\u8ff0\u7b26\u5230\u679a\u4e3e - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-29T15:17:22+00:00","dateModified":"2026-08-29T15:17:22+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/97665.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/97665.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/97665.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"STM32 USB HID \u6559\u7a0b\uff1aTinyUSB \u5b9e\u73b0\u952e\u76d8\u8bbe\u5907\uff0c\u4ece\u63cf\u8ff0\u7b26\u5230\u679a\u4e3e"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/97665","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=97665"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/97665\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=97665"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=97665"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=97665"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=97665"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}