Add new USB_Host_GetDeviceStringDescriptor() convenience function.
authorDean Camera <dean@fourwalledcubicle.com>
Sun, 6 Dec 2009 13:37:30 +0000 (13:37 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Sun, 6 Dec 2009 13:37:30 +0000 (13:37 +0000)
LUFA/Drivers/USB/LowLevel/Host.c
LUFA/Drivers/USB/LowLevel/Host.h
LUFA/ManPages/ChangeLog.txt

index 98185a4..e10d347 100644 (file)
@@ -308,6 +308,22 @@ uint8_t USB_Host_GetDeviceDescriptor(void* const DeviceDescriptorPtr)
        return USB_Host_SendControlRequest(DeviceDescriptorPtr);\r
 }\r
 \r
+uint8_t USB_Host_GetDeviceStringDescriptor(uint8_t Index, void* const Buffer, uint8_t BufferLength)\r
+{\r
+       USB_ControlRequest = (USB_Request_Header_t)\r
+               {\r
+                       bmRequestType: (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),\r
+                       bRequest:      REQ_GetDescriptor,\r
+                       wValue:        (DTYPE_String << 8) | Index,\r
+                       wIndex:        0,\r
+                       wLength:       BufferLength,\r
+               };\r
+\r
+       Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+       \r
+       return USB_Host_SendControlRequest(Buffer);\r
+}\r
+\r
 uint8_t USB_Host_ClearPipeStall(uint8_t EndpointNum)\r
 {\r
        if (Pipe_GetPipeToken() == PIPE_TOKEN_IN)\r
index 8cf1fe0..0a07002 100644 (file)
                         */\r
                        uint8_t USB_Host_GetDeviceDescriptor(void* const DeviceDescriptorPtr);\r
                        \r
+                       /** Convenience function. This routine sends a GetDescriptor standard request to the attached\r
+                        *  device, requesting the string descriptor of the specified index. This can be used to easily\r
+                        *  retrieve string descriptors from the device by index, after the index is obtained from the\r
+                        *  Device or Configuration descriptors.\r
+                        *\r
+                        *  \note After this routine returns, the control pipe will be selected.\r
+                        *\r
+                        *  \param[in] Index  Index of the string index to retrieve\r
+                        *  \param[out] Buffer  Pointer to the destination buffer where the retrieved string decriptor is\r
+                        *                      to be stored\r
+                        *  \param[in] BufferLength  Maximum size of the string descriptor which can be stored into the buffer\r
+                        *\r
+                        *  \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.\r
+                        */\r
+                       uint8_t USB_Host_GetDeviceStringDescriptor(uint8_t Index, void* const Buffer, uint8_t BufferLength);\r
+                       \r
                        /** Clears a stall condition on the given pipe, via a ClearFeature request to the attached device.\r
                         *\r
                         *  \note After this routine returns, the control pipe will be selected.\r
index 6294674..e68bf89 100644 (file)
@@ -22,6 +22,7 @@
   *  - Added new HID_ALIGN_DATA() macro to return the pre-retrieved value of a HID report item, left-aligned to a given datatype\r
   *  - Added new PreviousValue to the HID Report Parser report item structure, for easy monitoring of previous report item values\r
   *  - Added new EVK527 board target\r
+  *  - Added new USB_Host_GetDeviceStringDescriptor() convenience function\r
   *\r
   *  <b>Changed:</b>\r
   *  - Removed code in the Keyboard demos to send zeroed reports between two reports with differing numbers of keycodes\r