<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.8.13">
  <compounddef id="_page__usb_descriptors" kind="page">
    <compoundname>Page_UsbDescriptors</compoundname>
    <title>Defining USB Descriptors</title>
    <detaileddescription>
<para>A USB device provides information about itself in data structures called USB descriptors. This section provides information about various descriptors that a USB device should provide to host during enumeration process.</para><sect1 id="_page__usb_descriptors_1USBD_Descriptors">
<title>Defining USB Descriptors</title>
<para>The host obtains descriptors from an attached device by sending various standard control requests (GET_DESCRIPTOR requests) to the default endpoint. Those requests specify the type of descriptor to retrieve. In response to such requests, the device sends descriptors that include information about the device, its configurations, interfaces and the related endpoints. Device descriptors contain information about the whole device. Configuration descriptors contain information about each device configuration. String descriptors contain Unicode text strings. The USB ROM stack handles all these standard requests eliminating the complexity from user application, as long as the user application provides the proper descriptor arrays to stack initialization routine.</para><para>Every USB device exposes a device descriptor that indicates the device&apos;s class information, vendor and product identifiers, and number of configurations. Each configuration exposes its configuration descriptor that indicates number of interfaces and power characteristics. Each interface exposes an interface descriptor for each of its alternate settings that contain information about the class and the number of endpoints. Each endpoint within each interface exposes endpoint descriptors that indicate the endpoint type and the maximum packet size. User application should provide these descriptors to the ROM stack for proper handling of standard requests.</para><sect2 id="_page__usb_descriptors_1USBD_DeviceDes">
<title>Defining USB Device Descriptor</title>
<para>The device descriptor contains information about a USB device as a whole. The pointer to the memory containing device descriptor should be provided by application through <emphasis>device_desc</emphasis> field of <ref refid="struct_u_s_b___c_o_r_e___d_e_s_c_s___t" kindref="compound">USB_CORE_DESCS_T</ref> structure, whose address is passed to stack initialization routine <emphasis>usbapi-&gt;hw-&gt;init()</emphasis>. The user application can create an instance of <ref refid="struct___u_s_b___d_e_v_i_c_e___d_e_s_c_r_i_p_t_o_r" kindref="compound">_USB_DEVICE_DESCRIPTOR</ref> structure in global scope (defined in memory accessible by USB bus master) and pass the address of the instance in <emphasis>device_desc</emphasis> field. Or the application can define the descriptor as character array as shown below:</para><para><programlisting><codeline><highlight class="normal">/*<sp/>USB<sp/>Standard<sp/>Device<sp/>Descriptor<sp/>*/</highlight></codeline>
<codeline><highlight class="normal">ALIGNED(4)<sp/>const<sp/>uint8_t<sp/>USB_DeviceDescriptor[]<sp/>=</highlight></codeline>
<codeline><highlight class="normal">{</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>USB_DEVICE_DESC_SIZE,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bLength<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>USB_DEVICE_DESCRIPTOR_TYPE,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bDescriptorType<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>WBVAL(0x0200),<sp/>/*<sp/>2.00<sp/>*/<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bcdUSB<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>0x00,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bDeviceClass<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>0x00,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bDeviceSubClass<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>0x00,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bDeviceProtocol<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>USB_MAX_PACKET0,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bMaxPacketSize<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>WBVAL(0x1FC9),<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>idVendor:<sp/>Vendor<sp/>ID<sp/>(assigned<sp/>by<sp/>the<sp/>USB-IF)<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>WBVAL(0x0001),<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>idProduct<sp/>Product<sp/>ID<sp/>(assigned<sp/>by<sp/>the<sp/>manufacturer)*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>WBVAL(0x0100),<sp/>/*<sp/>1.00<sp/>*/<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bcdDevice<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>0x01,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>iManufacturer<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>0x02,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>iProduct<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>0x03,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>iSerialNumber<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>0x01<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bNumConfigurations<sp/>*/</highlight></codeline>
<codeline><highlight class="normal">};</highlight></codeline>
</programlisting></para><para><itemizedlist>
<listitem><para><bold>bLength:</bold> Size of this descriptor in bytes. Always set this field to 18.</para></listitem><listitem><para><bold>bDescriptorType:</bold> DEVICE descriptor type. Always set this field to 0x01.</para></listitem><listitem><para><bold>bcdUSB:</bold> Set to USB specification version the device and its descriptors are compliant. Setting the value to WBVAL(0x0200) implies the device is compliant with USB specification version 2.00.</para></listitem><listitem><para><bold>bDeviceClass:</bold> Class code. If this field is reset to zero, each interface within a configuration specifies its own class information and the various interfaces operate independently. If this field is set to a value between 1 and FEH, the device supports different class specifications on different interfaces and the interfaces may not operate independently. This value identifies the class definition used for the aggregate interfaces. If this field is set to FFH, the device class is vendor-specific.</para></listitem><listitem><para><bold>bDeviceSubClass:</bold> Set the subclass code of the device as assigned by the USB specification group.</para></listitem><listitem><para><bold>bDeviceProtocol:</bold> Set the protocol code of the device as assigned by the USB specification group.</para></listitem><listitem><para><bold>bMaxPacketSize:</bold> Maximum packet size, in bytes, for endpoint zero of the device. Current ROM stack implementation assumes 64 bytes, hence set this field to 64.</para></listitem><listitem><para><bold>idVendor:</bold> Set the USB Vendor ID assigned to the manufacturer of this product, by the USB-IF.</para></listitem><listitem><para><bold>idProduct:</bold> Set the product ID assigned by the manufacturer for this product.</para></listitem><listitem><para><bold>bcdDevice:</bold> Device release number in binary-coded decimal.</para></listitem><listitem><para><bold>iManufacturer:</bold> Set index of the string descriptor that provides a string containing the name of the manufacturer of this device. Check <ref refid="_page__usb_descriptors_1USBD_StringDes" kindref="member">Defining USB String Descriptor</ref> for more details in defining string descriptors.</para></listitem><listitem><para><bold>iProduct:</bold> Set index of the string descriptor that provides a string that contains a description of the device. Check <ref refid="_page__usb_descriptors_1USBD_StringDes" kindref="member">Defining USB String Descriptor</ref> for more details in defining string descriptors.</para></listitem><listitem><para><bold>iSerialNumber:</bold> Set index of the string descriptor that provides a string that contains a manufacturer-determined serial number for the device. Check <ref refid="_page__usb_descriptors_1USBD_StringDes" kindref="member">Defining USB String Descriptor</ref> for more details in defining string descriptors.</para></listitem><listitem><para><bold>bNumConfigurations:</bold> Set the total number of possible configurations for the device.</para></listitem></itemizedlist>
</para></sect2>
<sect2 id="_page__usb_descriptors_1USBD_DevQualifier">
<title>Defining USB Device Qualifier Descriptor</title>
<para>The device_qualifier descriptor describes information about a high-speed capable device that would change if the device were operating at the other speed (see <ref refid="struct___u_s_b___d_e_v_i_c_e___q_u_a_l_i_f_i_e_r___d_e_s_c_r_i_p_t_o_r" kindref="compound">_USB_DEVICE_QUALIFIER_DESCRIPTOR</ref> structure). For example, if the device is currently operating at full-speed, the device_qualifier returns information about how it would operate at high-speed and vice-versa. The pointer to the memory containing device qualifier descriptor should be provided by application through <emphasis>device_qualifier</emphasis> field of <ref refid="struct_u_s_b___c_o_r_e___d_e_s_c_s___t" kindref="compound">USB_CORE_DESCS_T</ref> structure, whose address is passed to stack initialization routine <emphasis>usbapi-&gt;hw-&gt;init()</emphasis>. <simplesect kind="note"><para>If application is implementing full-speed only device this field should be set to 0. And also the field <emphasis>high_speed_desc</emphasis> and <emphasis>full_speed_desc</emphasis> should point to full-speed configuration descriptor array.</para></simplesect>
<programlisting><codeline><highlight class="normal">/*<sp/>USB<sp/>Device<sp/>Qualifier<sp/>*/</highlight></codeline>
<codeline><highlight class="normal">ALIGNED(4)<sp/>const<sp/>uint8_t<sp/>USB_DeviceQualifier[]<sp/>=<sp/>{</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>USB_DEVICE_QUALI_SIZE,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bLength<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE,<sp/>/*<sp/>bDescriptorType<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>WBVAL(0x0200),<sp/>/*<sp/>2.00<sp/>*/<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bcdUSB<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>0x00,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bDeviceClass<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>0x00,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bDeviceSubClass<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>0x00,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bDeviceProtocol<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>USB_MAX_PACKET0,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bMaxPacketSize0<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>0x01,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bNumOtherSpeedConfigurations<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>0x00<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bReserved<sp/>*/</highlight></codeline>
<codeline><highlight class="normal">};</highlight></codeline>
</programlisting></para></sect2>
<sect2 id="_page__usb_descriptors_1USBD_ConfigDes">
<title>Defining USB Configuration Descriptors Array</title>
<para>A USB device exposes its capabilities in the form of a series of interfaces called a USB configuration. A USB configuration is described in a configuration descriptor (see <ref refid="struct___u_s_b___c_o_n_f_i_g_u_r_a_t_i_o_n___d_e_s_c_r_i_p_t_o_r" kindref="compound">_USB_CONFIGURATION_DESCRIPTOR</ref> structure). A configuration descriptor contains information about the configuration and its interfaces, alternate settings, and their endpoints. Each interface descriptor or alternate setting is described in a <ref refid="struct___u_s_b___i_n_t_e_r_f_a_c_e___d_e_s_c_r_i_p_t_o_r" kindref="compound">_USB_INTERFACE_DESCRIPTOR</ref> structure. In a configuration, each interface descriptor is followed in memory by all of the endpoint descriptors for the interface and alternate setting. Each endpoint descriptor is stored in a <ref refid="struct___u_s_b___e_n_d_p_o_i_n_t___d_e_s_c_r_i_p_t_o_r" kindref="compound">_USB_ENDPOINT_DESCRIPTOR</ref> structure.</para><para>The ROM stack assumes that all the descriptors associated with the configuration are arranged as a consecutive byte array in memory. The address to this array is passed to the stack through <emphasis>full_speed_desc</emphasis> and <emphasis>high_speed_desc</emphasis> field of <ref refid="struct_u_s_b___c_o_r_e___d_e_s_c_s___t" kindref="compound">USB_CORE_DESCS_T</ref> structure, whose address is passed to <emphasis>usbapi-&gt;hw-&gt;init()</emphasis> routine. The following diagram illustrates how configuration information should be laid out in memory.</para><para><linebreak/>
<image type="html" name="config_des.png"></image>
 <linebreak/>
 The following example shows the configuration descriptor for the USB Mass storage class device: <programlisting><codeline><highlight class="normal">/*<sp/><sp/><sp/>All<sp/>Descriptors<sp/>(Configuration,<sp/>Interface,<sp/>Endpoint,<sp/>Class,<sp/>Vendor<sp/>*/</highlight></codeline>
<codeline><highlight class="normal">ALIGNED(4)<sp/><sp/>uint8_t<sp/>USB_FsConfigDescriptor[]<sp/>=<sp/>{</highlight></codeline>
<codeline><highlight class="normal">/*<sp/>Configuration<sp/>1<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>USB_CONFIGUARTION_DESC_SIZE,<sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bLength.<sp/>Set<sp/>to<sp/>0x09.<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>USB_CONFIGURATION_DESCRIPTOR_TYPE,<sp/>/*<sp/>bDescriptorType.<sp/>Set<sp/>to<sp/>0x02.*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>WBVAL(<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>wTotalLength:<sp/>contains<sp/>total<sp/>length<sp/>of<sp/>data<sp/>returned<sp/>for<sp/>this<sp/>configuration.<sp/>Includes<sp/>the<sp/>combined<sp/>length<sp/>of<sp/>all<sp/>descriptors<sp/>(configuration,<sp/>interface,<sp/>endpoint,<sp/>and<sp/>class-<sp/>or<sp/>vendor-specific)<sp/>returned<sp/>for<sp/>this<sp/>configuration.<sp/><sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/>1*USB_CONFIGUARTION_DESC_SIZE<sp/>+</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/>1*USB_INTERFACE_DESC_SIZE<sp/><sp/><sp/><sp/><sp/>+</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/>2*USB_ENDPOINT_DESC_SIZE</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>),</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>0x01,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bNumInterfaces:<sp/>total<sp/>number<sp/>of<sp/>interfaces<sp/>the<sp/>device<sp/>supports<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>0x01,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bConfigurationValue:<sp/>This<sp/>field<sp/>indicates<sp/>the<sp/>index<sp/>for<sp/>the<sp/>configuration<sp/>defined<sp/>in<sp/>the<sp/>firmware<sp/>of<sp/>the<sp/>device.<sp/>The<sp/>host<sp/>functional<sp/>driver<sp/>uses<sp/>that<sp/>index<sp/>value<sp/>to<sp/>select<sp/>an<sp/>active<sp/>configuration.<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>0x00,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>iConfiguration<sp/>*/</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal"><sp/><sp/>USB_CONFIG_SELF_POWERED,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bmAttributes:<sp/>contains<sp/>a<sp/>bitmask<sp/>that<sp/>indicates<sp/>whether<sp/>the<sp/>configuration<sp/>supports<sp/>the<sp/>remote<sp/>wake-up<sp/>feature,<sp/>and<sp/>whether<sp/>the<sp/>device<sp/>is<sp/>bus-powered<sp/>or<sp/>self-powered.<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>USB_CONFIG_POWER_MA(100),<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bMaxPower:<sp/>specifies<sp/>the<sp/>maximum<sp/>power<sp/>(in<sp/>milliamp<sp/>units)<sp/>that<sp/>the<sp/>device<sp/>can<sp/>draw<sp/>from<sp/>the<sp/>host,<sp/>when<sp/>the<sp/>device<sp/>is<sp/>bus-powered.<sp/><sp/>*/</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">/*<sp/>Interface<sp/>0,<sp/>Alternate<sp/>Setting<sp/>0,<sp/>MSC<sp/>Class<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>USB_INTERFACE_DESC_SIZE,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bLength<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>USB_INTERFACE_DESCRIPTOR_TYPE,<sp/><sp/><sp/><sp/><sp/>/*<sp/>bDescriptorType<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>0x00,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bInterfaceNumber<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>0x00,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bAlternateSetting<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>0x02,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bNumEndpoints<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>USB_DEVICE_CLASS_STORAGE,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bInterfaceClass<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>MSC_SUBCLASS_SCSI,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bInterfaceSubClass<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>MSC_PROTOCOL_BULK_ONLY,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bInterfaceProtocol<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>0x04,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>iInterface:<sp/>Index<sp/>to<sp/>string<sp/>descriptor<sp/>containing<sp/>interface<sp/>description.<sp/>*/</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">/*<sp/>Bulk<sp/>In<sp/>Endpoint<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>USB_ENDPOINT_DESC_SIZE,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bLength<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>USB_ENDPOINT_DESCRIPTOR_TYPE,<sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bDescriptorType<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>MSC_EP_IN,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bEndpointAddress<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>USB_ENDPOINT_TYPE_BULK,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bmAttributes<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>WBVAL(64),<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>wMaxPacketSize<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>0,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bInterval<sp/>*/</highlight></codeline>
<codeline><highlight class="normal">/*<sp/>Bulk<sp/>Out<sp/>Endpoint<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>USB_ENDPOINT_DESC_SIZE,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bLength<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>USB_ENDPOINT_DESCRIPTOR_TYPE,<sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bDescriptorType<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>MSC_EP_OUT,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bEndpointAddress<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>USB_ENDPOINT_TYPE_BULK,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bmAttributes<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>WBVAL(64),<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>wMaxPacketSize<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>0,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bInterval<sp/>*/</highlight></codeline>
<codeline><highlight class="normal">/*<sp/>Terminator<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>0<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bLength:<sp/>Indicates<sp/>to<sp/>ROM<sp/>stack<sp/>the<sp/>end<sp/>of<sp/>descriptor<sp/>array.<sp/>*/</highlight></codeline>
<codeline><highlight class="normal">};</highlight></codeline>
</programlisting></para><para><simplesect kind="note"><para>For devices implementing multiple configurations the second configuration descriptors should follow immediately after the first configuration descriptors with NULL descriptor at the end of the second configuration array.</para></simplesect>
</para></sect2>
<sect2 id="_page__usb_descriptors_1USBD_SpeedDes">
<title>Defining USB Other Speed Configuration</title>
<para>The other_speed_configuration describes a configuration of a high-speed capable device if it were operating at its other possible speed. The structure <ref refid="struct___u_s_b___o_t_h_e_r___s_p_e_e_d___c_o_n_f_i_g_u_r_a_t_i_o_n" kindref="compound">_USB_OTHER_SPEED_CONFIGURATION</ref> is identical to a configuration descriptor. Except the <emphasis>bDescriptorType</emphasis> field which is set to 0x07. To optimize application data memory usage the ROM stack reuses the meory pointed by <emphasis>full_speed_desc</emphasis> and <emphasis>high_speed_desc</emphasis> fields when reporting other speed configuration descriptor. <simplesect kind="note"><para>The stack updates <emphasis>bDescriptorType</emphasis> field before sending the descriptor data to host. Hence the applications should have the configuration descriptors in read-write memory area such as ISRAM and not declare the descriptor array with <emphasis>const</emphasis> qualifier.</para></simplesect>
</para></sect2>
<sect2 id="_page__usb_descriptors_1USBD_StringDes">
<title>Defining USB String Descriptor</title>
<para>Device, configuration, and interface descriptors may contain references to string descriptors. String descriptors are referenced by their one-based index number. A string descriptor contains one or more Unicode strings; each string is a translation of the others into another language.</para><para>A string descriptor contains:<itemizedlist>
<listitem><para><bold>bLength:</bold> Size of this descriptor in bytes. This field is at offset 0 and occupies 1 byte. The size of the descriptor is size of Unicode string + 2.</para></listitem><listitem><para><bold>bDescriptorType:</bold> STRING descriptor Type. Always set this field to 0x03. This field is at offset 1 and occupies 1 byte.</para></listitem><listitem><para><bold>bString:</bold> UNICODE encoded string.</para></listitem></itemizedlist>
</para><para>String index zero for all languages should return a string descriptor that contains an array of two-byte LANGID codes supported by the device. Current implementation of ROM stack assumes single language support. For applications using US English strings this descriptor should be: <programlisting><codeline><highlight class="normal">0x04,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bLength<sp/>*/</highlight></codeline>
<codeline><highlight class="normal">0x03,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bDescriptorType<sp/>*/</highlight></codeline>
<codeline><highlight class="normal">WBVAL(0x0409),<sp/>/*<sp/>wLANGID:<sp/>US<sp/>English<sp/>*/<sp/><sp/><sp/><sp/></highlight></codeline>
</programlisting></para><para>The ROM stack assumes that all USB strings referenced in various descriptors are provided to stack as a single character array containing multiple string descriptors. ROM stack traverses to the next descriptor in array by adding the value of <emphasis>bLength</emphasis> field to current index. Hence it is important to construct this descriptor array properly with <emphasis>bLength</emphasis> fields reflecting the exact size of its string descriptor.</para><para><programlisting><codeline><highlight class="normal">/*<sp/>USB<sp/>String<sp/>Descriptor<sp/>(optional)<sp/>*/</highlight></codeline>
<codeline><highlight class="normal">ALIGNED(4)<sp/>uint8_t<sp/>USB_StringDescriptor[]<sp/>=</highlight></codeline>
<codeline><highlight class="normal">{</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>Index<sp/>0x00:<sp/>LANGID<sp/>Codes<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>0x04,<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bLength<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>USB_STRING_DESCRIPTOR_TYPE,<sp/><sp/>/*<sp/>bDescriptorType<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>WBVAL(0x0409),<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>wLANGID<sp/>:<sp/>US<sp/>English<sp/>*/<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">/*<sp/>Index<sp/>0x01:<sp/>Manufacturer<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(2*2<sp/>+<sp/>2),<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bLength<sp/>(3<sp/>Char<sp/>+<sp/>Type<sp/>+<sp/>length)<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>USB_STRING_DESCRIPTOR_TYPE,<sp/><sp/>/*<sp/>bDescriptorType<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&apos;N&apos;,<sp/>0,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&apos;X&apos;,<sp/>0,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&apos;P&apos;,<sp/>0,</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>Index<sp/>0x02:<sp/>Product<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(20*2<sp/>+<sp/>2),<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bLength<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>USB_STRING_DESCRIPTOR_TYPE,<sp/><sp/>/*<sp/>bDescriptorType<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&apos;N&apos;,<sp/>0,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&apos;X&apos;,<sp/>0,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&apos;P&apos;,<sp/>0,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&apos;<sp/>&apos;,<sp/>0,</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>Index<sp/>0x03:<sp/>Serial<sp/>Number<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(13*2<sp/>+<sp/>2),<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>/*<sp/>bLength<sp/>(13<sp/>Char<sp/>+<sp/>Type<sp/>+<sp/>length)*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>USB_STRING_DESCRIPTOR_TYPE,<sp/><sp/>/*<sp/>bDescriptorType<sp/>*/</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&apos;A&apos;,<sp/>0,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&apos;B&apos;,<sp/>0,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&apos;C&apos;,<sp/>0,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&apos;D&apos;,<sp/>0,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&apos;1&apos;,<sp/>0,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&apos;2&apos;,<sp/>0,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&apos;3&apos;,<sp/>0,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&apos;4&apos;,<sp/>0,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&apos;5&apos;,<sp/>0,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&apos;6&apos;,<sp/>0,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&apos;7&apos;,<sp/>0,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&apos;8&apos;,<sp/>0,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&apos;9&apos;,<sp/>0,</highlight></codeline>
<codeline><highlight class="normal">};<sp/></highlight></codeline>
</programlisting> </para></sect2>
</sect1>
    </detaileddescription>
  </compounddef>
</doxygen>
