<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>

新聞中心

EEPW首頁(yè) > 嵌入式系統 > 設計應用 > STM32的USB鍵盤(pán)及鼠標例程

STM32的USB鍵盤(pán)及鼠標例程

作者: 時(shí)間:2011-07-19 來(lái)源:網(wǎng)絡(luò ) 收藏

例程通過(guò)網(wǎng)絡(luò )可以搜到很,但是在同一個(gè)設備中集成的例程卻比較少見(jiàn)(我通過(guò)GOOGLE只搜到圈圈的基于51+D12的版本)。以下為我參考圈圈的例程做出來(lái)的集成的程序。

本文引用地址:http://dyxdggzs.com/article/172617.htm

  程序上除了usb_desc.c及usb_endp.c外,其它部份同單一的鍵盤(pán)鼠標一樣。下面著(zhù)重說(shuō)一下usb_desc.c及usb_endp.c的不同之處。

  單一鍵盤(pán)鼠標跟集成鍵盤(pán)鼠標這區別主要是報告描述符不同。單一鍵盤(pán)鼠標的報告描述符因只有一組報告輸入/輸出,故沒(méi)有報告ID,而集成的有兩組報告(鍵盤(pán)及鼠標),所以每一組報告都有一個(gè)報告ID加以區別。

  另外就是在usb_endp.c中對端點(diǎn)的數據發(fā)送不知道是不是我的原因,待發(fā)送數據長(cháng)度有問(wèn)題,原因還未找到,只能在后面增加一條設置發(fā)送數據長(cháng)度的語(yǔ)句。(如果不加的話(huà),PC端只會(huì )收到8位數據,盡管我程序里設置了9位數據)

  完整的usb_desc.c文件如下:

  #include LibLibusb_lib.h

  #include usb_desc.h

  // KM_DeviceDescriptor

  const u8 HID_DeviceDescriptor[HID_SIZE_DEVICE_DESC]=

  {

  0X12, // bLength

  _DEVICE_DESCRIPTOR_TYPE, // bDescriptorType

  0x00, // bcdUSB

  0x02,

  0x00, // bDeviceClass

  0X00, // bDeviceSubClass

  0x00, // bDeviceProtocol

  0x40, // bMaxPacketSize40

  0x34, // idVendor (0x0483)

  0x12,

  0x78, // idProduct = 0x5710

  0x56,

  0x00, // bcdDevice rel.20.00

  0x02,

  1, // index of string descriptor describing manufacturer

  2, // index of string descriptor describing product

  3, // index of string descriptor describing the device serial number

  0x01 // bNumConfigurations

  };

  // USB Configuration Descriptor

  const u8 HID_ConfigDescriptor[HID_SIZE_CONFIG_DESC]=

  {

  0X09, // bLength

  USB_CONFIGURATION_DESCRIPTOR_TYPE, // bDescriptorType

  HID_SIZE_CONFIG_DESC, // wTotalLength

  0x00,

  0x01, // bNumInterfaces 接口數目

  0x01, // bConfigurationValue set_configuration命令所需要的參數值

  0x00, // iConfiguration

  0xE0, // bmAttributes

  0x32, // MaxPower 100mA

  //***************接口1配置***************

  0x09,

  USB_INTERFACE_DESCRIPTOR_TYPE,

  0x00, // 接口編號

  0x00,

  0x02, // 端點(diǎn)數

  0x03,

  0x01, // 1 = boot 0 = no boot

  0x01, // 0 = none 1 = keyboard 2 = mouse

  0, //接口描述符索引值

  //***************HID 描述符****************

  0x09,

  HID_DESCRIPTOR_TYPE,

  0x10,

  0x01,

  0x00,

  0x01,

  0x22,

  HID_SIZE_REPORT_DESC,

  0x00,

  //***************端點(diǎn)1輸入描述***************

  0x07,

  USB_ENDPOINT_DESCRIPTOR_TYPE,

  0x81,

  0x03,

  0x0A,

  0x00,

  0x20,

絕對值編碼器相關(guān)文章:絕對值編碼器原理

上一頁(yè) 1 2 3 下一頁(yè)

關(guān)鍵詞: 鼠標 鍵盤(pán) USB STM32

評論


相關(guān)推薦

技術(shù)專(zhuān)區

關(guān)閉
国产精品自在自线亚洲|国产精品无圣光一区二区|国产日产欧洲无码视频|久久久一本精品99久久K精品66|欧美人与动牲交片免费播放
<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>