初中生
最后登录1970-1-1
在线时间 小时
注册时间2016-3-25
|
楼主 |
发表于 2016-3-31 11:17:11
|
显示全部楼层
USB驱动描述
- const uint8_t CustomHID_DeviceDescriptor[CUSTOMHID_SIZ_DEVICE_DESC] =
- {
- 0x12, /*bLength */
- USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/
- 0x00, /*bcdUSB */
- 0x02,
- 0x00, /*bDeviceClass*/
- 0x00, /*bDeviceSubClass*/
- 0x00, /*bDeviceProtocol*/
- 0x40, /*bMaxPacketSize40*/
- LOBYTE(USBD_VID), /*idVendor*/
- HIBYTE(USBD_VID), /*idVendor*/
- LOBYTE(USBD_PID), /*idVendor*/
- HIBYTE(USBD_PID), /*idVendor*/
- 0x00, /*bcdDevice rel. 2.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*/
- }; /* CustomHID_DeviceDescriptor */
复制代码
- const uint8_t CustomHID_ConfigDescriptor[CUSTOMHID_SIZ_CONFIG_DESC] =
- {
- 0x09, /* bLength: Configuation Descriptor size */
- USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */
- CUSTOMHID_SIZ_CONFIG_DESC,
- /* wTotalLength: Bytes returned */
- 0x00,
- 0x01, /* bNumInterfaces: 1 interface */
- 0x01, /* bConfigurationValue: Configuration value */
- 0x00, /* iConfiguration: Index of string descriptor describing
- the configuration*/
- 0xE0, /* bmAttributes: Bus powered */
- /*Bus powered: 7th bit, Self Powered: 6th bit, Remote wakeup: 5th bit, reserved: 4..0 bits */
- 0xFA, /* MaxPower 500 mA: this current is used for detecting Vbus */
- /************** Descriptor of Custom HID interface ****************/
- /* 09 */
- 0x09, /* bLength: Interface Descriptor size */
- USB_INTERFACE_DESCRIPTOR_TYPE,/* bDescriptorType: Interface descriptor type */
- 0x00, /* bInterfaceNumber: Number of Interface */
- 0x00, /* bAlternateSetting: Alternate setting */
- 0x04, /* bNumEndpoints */
- 0xDC, /* bInterfaceClass: Class code = 0DCH */
- 0xA0, /* bInterfaceSubClass : Subclass code = 0A0H */
- 0xB0, /* nInterfaceProtocol : Protocol code = 0B0H */
- 0, /* iInterface: Index of string descriptor */
- /******************** endpoint descriptor ********************/
- /* 18 */
- 0x07, /* endpoint descriptor length = 07H */
- USB_ENDPOINT_DESCRIPTOR_TYPE, /* endpoint descriptor type = 05H */
- 0x81, /* endpoint 1 IN */
- 0x02, /* bulk transfer = 02H */
- 0x40,0x00, /* endpoint max packet size = 0040H */
- 0x00, /* the value is invalid when bulk transfer */
- 0x07, /* endpoint descriptor length = 07H */
- USB_ENDPOINT_DESCRIPTOR_TYPE, /* endpoint descriptor type = 05H */
- 0x01, /* endpoint 1 OUT */
- 0x02, /* bulk transfer = 02H */
- 0x40,0x00, /* endpoint max packet size = 0040H */
- 0x00, /* the value is invalid when bulk transfer */
-
- 0x07, /* endpoint descriptor length = 07H */
- USB_ENDPOINT_DESCRIPTOR_TYPE, /* endpoint descriptor type = 05H */
- 0x82, /* endpoint 2 IN */
- 0x02, /* bulk transfer = 02H */
- 0x40,0x00, /* endpoint max packet size = 0040H */
- 0x00, /* the value is invalid when bulk transfer */
-
- 0x07, /* endpoint descriptor length = 07H */
- USB_ENDPOINT_DESCRIPTOR_TYPE, /* endpoint descriptor type = 05H */
- 0x02, /* endpoint 2 OUT */
- 0x02, /* bulk transfer = 02H */
- 0x40,0x00, /* endpoint max packet size = 0040H */
- 0x00, /* the value is invalid when bulk transfer */
- }; /* CustomHID_ConfigDescriptor */
复制代码
下位机接收中断
- void EP1_OUT_Callback(void)
- {
- EP1_ReceivedCount = GetEPRxCount(ENDP1);
- PMAToUserBufferCopy(USB_Receive_Buffer, ENDP1_RXADDR, EP1_ReceivedCount);
- SetEPRxStatus(ENDP1, EP_RX_VALID);
- }
复制代码 |
|