diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2009-12-06 13:37:30 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2009-12-06 13:37:30 +0000 |
commit | c1fa2306181924ebd8b36b0e3910b7904143beb8 (patch) | |
tree | 12e177044da8f008fdf34b479d7b9cd09f1d76f5 /LUFA/Drivers | |
parent | c49bdcb7c930f2d0e0cf6887b3326f9e8f7f37b3 (diff) | |
download | lufa-c1fa2306181924ebd8b36b0e3910b7904143beb8.tar.gz lufa-c1fa2306181924ebd8b36b0e3910b7904143beb8.tar.bz2 lufa-c1fa2306181924ebd8b36b0e3910b7904143beb8.zip |
Add new USB_Host_GetDeviceStringDescriptor() convenience function.
Diffstat (limited to 'LUFA/Drivers')
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/Host.c | 16 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/Host.h | 16 |
2 files changed, 32 insertions, 0 deletions
diff --git a/LUFA/Drivers/USB/LowLevel/Host.c b/LUFA/Drivers/USB/LowLevel/Host.c index 98185a487..e10d34781 100644 --- a/LUFA/Drivers/USB/LowLevel/Host.c +++ b/LUFA/Drivers/USB/LowLevel/Host.c @@ -308,6 +308,22 @@ uint8_t USB_Host_GetDeviceDescriptor(void* const DeviceDescriptorPtr) return USB_Host_SendControlRequest(DeviceDescriptorPtr);
}
+uint8_t USB_Host_GetDeviceStringDescriptor(uint8_t Index, void* const Buffer, uint8_t BufferLength)
+{
+ USB_ControlRequest = (USB_Request_Header_t)
+ {
+ bmRequestType: (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),
+ bRequest: REQ_GetDescriptor,
+ wValue: (DTYPE_String << 8) | Index,
+ wIndex: 0,
+ wLength: BufferLength,
+ };
+
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);
+
+ return USB_Host_SendControlRequest(Buffer);
+}
+
uint8_t USB_Host_ClearPipeStall(uint8_t EndpointNum)
{
if (Pipe_GetPipeToken() == PIPE_TOKEN_IN)
diff --git a/LUFA/Drivers/USB/LowLevel/Host.h b/LUFA/Drivers/USB/LowLevel/Host.h index 8cf1fe047..0a0700210 100644 --- a/LUFA/Drivers/USB/LowLevel/Host.h +++ b/LUFA/Drivers/USB/LowLevel/Host.h @@ -201,6 +201,22 @@ */
uint8_t USB_Host_GetDeviceDescriptor(void* const DeviceDescriptorPtr);
+ /** Convenience function. This routine sends a GetDescriptor standard request to the attached
+ * device, requesting the string descriptor of the specified index. This can be used to easily
+ * retrieve string descriptors from the device by index, after the index is obtained from the
+ * Device or Configuration descriptors.
+ *
+ * \note After this routine returns, the control pipe will be selected.
+ *
+ * \param[in] Index Index of the string index to retrieve
+ * \param[out] Buffer Pointer to the destination buffer where the retrieved string decriptor is
+ * to be stored
+ * \param[in] BufferLength Maximum size of the string descriptor which can be stored into the buffer
+ *
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.
+ */
+ uint8_t USB_Host_GetDeviceStringDescriptor(uint8_t Index, void* const Buffer, uint8_t BufferLength);
+
/** Clears a stall condition on the given pipe, via a ClearFeature request to the attached device.
*
* \note After this routine returns, the control pipe will be selected.
|