![FTDI FT51A Скачать руководство пользователя страница 153](http://html1.mh-extra.com/html/ftdi/ft51a/ft51a_application-note_2341158153.webp)
Application Note
AN_289 FT51A Programming Guide
Version 1.0
Document Reference No.: FT_000962 Clearance No.: FTDI# 483
152
Copyright © 2015 Future Technology Devices International Limited
__code
struct
config_descriptor
{
USB_configuration_descriptor configuration;
USB_interface_descriptor interface;
USB_hid_descriptor hid;
USB_endpoint_descriptor endpoint;
};
struct
config_descriptor config_descriptor =
{
.configuration.bLength = 0x09,
.configuration.bDescriptorType = USB_DESCRIPTOR_TYPE_CONFIGURATION,
.configuration.wTotalLength =
sizeof
(
struct
config_descriptor_keyboard),
.configuration.bNumInterfaces = 0x01,
.configuration.bConfigurationValue = 0x01,
.configuration.iConfiguration = 0x00,
.configuration.bmAttributes = USB_CONFIG_BMATTRIBUTES_SELF_POWERED |
USB_CONFIG_BMATTRIBUTES_RESERVED_SET_TO_1,
.configuration.bMaxPower = 0xFA, // 500mA
// ---- INTERFACE DESCRIPTOR for Keyboard ----
.interface.bLength = 0x09,
.interface.bDescriptorType = USB_DESCRIPTOR_TYPE_INTERFACE,
.interface.bInterfaceNumber = 0,
.interface.bAlternateSetting = 0x00,
.interface.bNumEndpoints = 0x01,
.interface.bInterfaceClass = USB_CLASS_HID,
.interface.bInterfaceSubClass = 1,
.interface.bInterfaceProtocol = 1,
.interface.iInterface = 0x05,
// ---- HID DESCRIPTOR for Keyboard ----
.hid.bLength = 0x09,
.hid.bDescriptorType = 0x21,
.hid.bcdHID = USB_BCD_VERSION_HID_1_1,
.hid.bCountryCode = USB_HID_LANG_NOT_SUPPORTED,
.hid.bNumDescriptors = 0x01,
.hid.bDescriptorType_0 = USB_DESCRIPTOR_TYPE_REPORT,
.hid.wDescriptorLength_0 = 0x0041,
// ---- ENDPOINT DESCRIPTOR for Keyboard ----
.endpoint.bLength = 0x07,
.endpoint.bDescriptorType = USB_DESCRIPTOR_TYPE_ENDPOINT,
.endpoint.bEndpointAddress = 0x81,
.endpoint.bmAttributes = USB_ENDPOINT_DESCRIPTOR_ATTR_INTERRUPT,
.endpoint.wMaxPacketSize = 0x0008,
.endpoint.bInterval = 0x0a, // 10mS
};
3.2.2.3
String Descriptors
The string descriptor is an array of bytes. The first byte of each descriptor is the length of the
descriptor. This makes it possible for the array to be parsed to find a specified string in the array.
The standard_req_get_descriptor() function above will read through this byte array to find the
requested string.
__code u
int8_t string_descriptor[] =
{
// String 0 is actually a list of language IDs supported
// by the real strings.
0x04, USB_DESCRIPTOR_TYPE_STRING,
0x09, 0x04, // 0409 = English (US)
// String 1 (Manufacturer): "FTDI"
0x0a, USB_DESCRIPTOR_TYPE_STRING,