diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2011-11-24 11:33:10 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2011-11-24 11:33:10 +0000 |
commit | e915d968a5bdb8619c465b94d21a3801446a6539 (patch) | |
tree | e7cbe86dfc1d6a88c448ca759d70a9eb34a46bce /LUFA/Drivers/USB/Core | |
parent | 7f8dbb4908abd33b5ee8bfba7cc3870fa14f7366 (diff) | |
download | lufa-e915d968a5bdb8619c465b94d21a3801446a6539.tar.gz lufa-e915d968a5bdb8619c465b94d21a3801446a6539.tar.bz2 lufa-e915d968a5bdb8619c465b94d21a3801446a6539.zip |
Added new USB_Host_GetDeviceConfiguration() and USB_Host_GetInterfaceAltSetting() functions.
Diffstat (limited to 'LUFA/Drivers/USB/Core')
-rw-r--r-- | LUFA/Drivers/USB/Core/HostStandardReq.c | 35 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/HostStandardReq.h | 29 |
2 files changed, 63 insertions, 1 deletions
diff --git a/LUFA/Drivers/USB/Core/HostStandardReq.c b/LUFA/Drivers/USB/Core/HostStandardReq.c index ee5d8cb42..d7e7e3eba 100644 --- a/LUFA/Drivers/USB/Core/HostStandardReq.c +++ b/LUFA/Drivers/USB/Core/HostStandardReq.c @@ -211,6 +211,22 @@ uint8_t USB_Host_SetDeviceConfiguration(const uint8_t ConfigNumber) return ErrorCode; } +uint8_t USB_Host_GetDeviceConfiguration(uint8_t* const ConfigNumber) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE), + .bRequest = REQ_GetConfiguration, + .wValue = 0, + .wIndex = 0, + .wLength = sizeof(uint8_t), + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(ConfigNumber); +} + uint8_t USB_Host_GetDeviceDescriptor(void* const DeviceDescriptorPtr) { USB_ControlRequest = (USB_Request_Header_t) @@ -235,7 +251,7 @@ uint8_t USB_Host_GetDeviceStringDescriptor(const uint8_t Index, { .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE), .bRequest = REQ_GetDescriptor, - .wValue = (DTYPE_String << 8) | Index, + .wValue = ((DTYPE_String << 8) | Index), .wIndex = 0, .wLength = BufferLength, }; @@ -294,5 +310,22 @@ uint8_t USB_Host_SetInterfaceAltSetting(const uint8_t InterfaceIndex, return USB_Host_SendControlRequest(NULL); } +uint8_t USB_Host_GetInterfaceAltSetting(const uint8_t InterfaceIndex, + uint8_t* const AltSetting) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE), + .bRequest = REQ_GetInterface, + .wValue = 0, + .wIndex = InterfaceIndex, + .wLength = sizeof(uint8_t), + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(AltSetting); +} + #endif diff --git a/LUFA/Drivers/USB/Core/HostStandardReq.h b/LUFA/Drivers/USB/Core/HostStandardReq.h index 4bc3ddad2..ab4911980 100644 --- a/LUFA/Drivers/USB/Core/HostStandardReq.h +++ b/LUFA/Drivers/USB/Core/HostStandardReq.h @@ -130,6 +130,19 @@ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. */ uint8_t USB_Host_SetDeviceConfiguration(const uint8_t ConfigNumber); + + /** Sends a GET CONFIGURATION standard request to the attached device, to retrieve the currently selected + * device configuration index. + * + * \note After this routine returns, the control pipe will be selected. + * + * \ingroup Group_PipeControlReq + * + * \param[out] ConfigNumber Pointer to a location where the retrieved configuration index should be stored. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. + */ + uint8_t USB_Host_GetDeviceConfiguration(uint8_t* const ConfigNumber) ATTR_NON_NULL_PTR_ARG(1); /** Sends a GET DESCRIPTOR standard request to the attached device, requesting the device descriptor. * This can be used to easily retrieve information about the device such as its VID, PID and power @@ -206,6 +219,22 @@ uint8_t USB_Host_SetInterfaceAltSetting(const uint8_t InterfaceIndex, const uint8_t AltSetting); + + /** Retrieves the current alternative setting for the specified interface, via a GET INTERFACE standard request to + * the attached device. + * + * \note After this routine returns, the control pipe will be selected. + * + * \ingroup Group_PipeControlReq + * + * \param[in] InterfaceIndex Index of the interface whose alternative setting is to be altered. + * \param[out] AltSetting Pointer to a location where the retrieved alternative setting value should be stored. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. + */ + uint8_t USB_Host_GetInterfaceAltSetting(const uint8_t InterfaceIndex, + uint8_t* const AltSetting) ATTR_NON_NULL_PTR_ARG(2); + /* Private Interface - For use in library only: */ #if !defined(__DOXYGEN__) /* Enums: */ |