📄 usb_standard_desc.c
字号:
/* Copyright (c) 2007 Nordic Semiconductor. All Rights Reserved.
*
* The information contained herein is confidential property of
* Nordic Semiconductor. The use, copying, transfer or disclosure
* of such information is prohibited except by express written
* agreement with Nordic Semiconductor.
*/
/** @file
* USB device descriptor and USB HID configuration descriptior.
*
* @author Runar Kjellhaug
*
* @addtogroup usb_descriptors
* @{
*/
#include "usb_desc.h"
code const device_desc DEVICEDESC =
{
sizeof(device_desc), // bLength
0x01, // bDescriptorType
0x1001, // bcdUSB
0x00, // bDeviceClass
0x00, // bDeviceSubClass
0x00, // bDeviceProtocol
EP0_PACKET_SIZE, // bMaxPacketSize0
SWAP(VID), // idVendor (Nordic )
SWAP(PID), // idProduct (dongle)
0x0001, // bcdDevice
0x01, // iManufacturer
0x02, // iProduct
0x03, // iSerialNumber
0x01 // bNumConfigurations
};
// From "USB Device Class Definition for Human Interface Devices (HID)".
// Section 7.1:
// "When a Get_Descriptor(Configuration) request is issued,
// it returns the Configuration descriptor, all Interface descriptors,
// all Endpoint descriptors, and the HID descriptor for each interface."
code const hid_conf_desc HIDCONFIGDESC =
{
{ // configuration_descriptor hid_configuration_descriptor
sizeof(configuration_desc), // Length
0x02, // Type
SWAP(sizeof(hid_conf_desc)), // Totallength
0x03, // NumInterfaces
0x01, // bConfigurationValue
0x00, // iConfiguration
0xA0, // bmAttributes (0x80 + Remote Wakeup)
0x19 // MaxPower (in 2mA units) = 25 * 2mA
},
{ // interface_descriptor hid_interface_descriptor (MOUSE)
sizeof(interface_desc), // Length
0x04, // bDescriptorType
0x00, // bInterfaceNumber
0x00, // bAlternateSetting
0x01, // bNumEndpoints
0x03, // bInterfaceClass (3 = HID)
0x01, // bInterfaceSubClass
0x02, // bInterfaceProcotol(0=None, 1=Keyb, 2=Mouse)
0x00 // iInterface
},
{ // class_descriptor hid_descriptor
sizeof(class_desc), // Length
0x21, // bDescriptorType
0x0101, // bcdHID
0x00, // bCountryCode
0x01, // bNumDescriptors
0x22, // bDescriptorType
SWAP(HID_REPORT_DESCRIPTOR_SIZE_MOUSE), // wItemLength (tot. len. of report
// descriptor)
},
{ // endpoint_descriptor hid_endpoint_in_descriptor
sizeof(endpoint_desc), // Length
0x05, // bDescriptorType
0x81, // bEndpointAddress
0x03, // bmAttributes
EP1_PACKET_SIZE_LE, // MaxPacketSize (LITTLE ENDIAN)
2 // bInterval
},
{ // interface_descriptor hid_interface_descriptor (KEYBOARD)
sizeof(interface_desc), // Length
0x04, // bDescriptorType
0x01, // bInterfaceNumber
0x00, // bAlternateSetting
0x01, // bNumEndpoints
0x03, // bInterfaceClass (3 = HID)
0x01, // bInterfaceSubClass
0x01, // bInterfaceProcotol(0=None, 1=Keyb, 2=Mouse)
0x00 // iInterface
},
{ // class_descriptor hid_descriptor
sizeof(class_desc), // Length
0x21, // bDescriptorType
0x0101, // bcdHID
0x00, // bCountryCode
0x01, // bNumDescriptors
0x22, // bDescriptorType
SWAP(HID_REPORT_DESCRIPTOR_SIZE_KEYB), // wItemLength (tot. len. of report
// descriptor)
},
{ // endpoint_descriptor hid_endpoint_in_descriptor
sizeof(endpoint_desc), // Length
0x05, // bDescriptorType
0x82, // bEndpointAddress
0x03, // bmAttributes
EP1_PACKET_SIZE_LE, // MaxPacketSize (LITTLE ENDIAN)
10 // bInterval
},
{ // interface_descriptor hid_interface_descriptor (REMOTE CONTROL)
sizeof(interface_desc), // Length
0x04, // bDescriptorType
0x02, // bInterfaceNumber
0x00, // bAlternateSetting
0x01, // bNumEndpoints
0x03, // bInterfaceClass (3 = HID)
0x00, // bInterfaceSubClass
0x00, // bInterfaceProcotol(0=None, 1=Keyb, 2=Mouse)
0x00 // iInterface
},
{ // class_descriptor hid_descriptor
sizeof(class_desc), // Length
0x21, // bDescriptorType
SWAP(0x0111), // bcdHID
0x00, // bCountryCode
0x01, // bNumDescriptors
0x22, // bDescriptorType
SWAP(HID_REPORT_DESCRIPTOR_SIZE_RC), // wItemLength (tot. len. of report
// descriptor)
},
{ // endpoint_descriptor hid_endpoint_in_descriptor
sizeof(endpoint_desc), // Length
0x05, // bDescriptorType
0x83, // bEndpointAddress
0x03, // bmAttributes
EP1_PACKET_SIZE_LE, // MaxPacketSize (LITTLE ENDIAN)
10 // bInterval
}
};
/** @} */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -