From b5ca3990c2ec9dc240fb334002ed2f7c82eea853 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Tue, 16 Jun 2009 04:20:21 +0000 Subject: Added new USB_Host_SetDeviceConfiguration() convenience function. Change over Low Level host demos to use the new routine. --- LUFA/Drivers/USB/LowLevel/Host.c | 17 +++++++++++++++++ LUFA/Drivers/USB/LowLevel/Host.h | 13 +++++++++++++ 2 files changed, 30 insertions(+) (limited to 'LUFA/Drivers/USB') diff --git a/LUFA/Drivers/USB/LowLevel/Host.c b/LUFA/Drivers/USB/LowLevel/Host.c index 5f3eeb8e8..c059b43ac 100644 --- a/LUFA/Drivers/USB/LowLevel/Host.c +++ b/LUFA/Drivers/USB/LowLevel/Host.c @@ -285,4 +285,21 @@ static void USB_Host_ResetDevice(void) USB_INT_Enable(USB_INT_DDISCI); } + +uint8_t USB_Host_SetDeviceConfiguration(uint8_t ConfigNumber) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE), + .bRequest = REQ_SetConfiguration, + .wValue = ConfigNumber, + .wIndex = 0, + .wLength = 0, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(NULL); +} + #endif diff --git a/LUFA/Drivers/USB/LowLevel/Host.h b/LUFA/Drivers/USB/LowLevel/Host.h index 911b41bd9..7130c7579 100644 --- a/LUFA/Drivers/USB/LowLevel/Host.h +++ b/LUFA/Drivers/USB/LowLevel/Host.h @@ -173,6 +173,19 @@ #define USB_Host_IsResumeFromWakeupRequestSent() ((UHCON & (1 << RESUME)) ? false : true) #endif + /* Function Prototypes: */ + /** Convenience function. This routine sends a SetConfiguration standard request to the attached + * device, with the given configuration index. This can be used to easily set the device + * configuration without creating and sending the request manually. + * + * \note After this routine returns, the control pipe will be selected. + * + * \param ConfigNumber Configuration index to send to the device + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. + */ + uint8_t USB_Host_SetDeviceConfiguration(uint8_t ConfigNumber); + /* Enums: */ /** Enum for the various states of the USB Host state machine. Only some states are * implemented in the LUFA library - other states are left to the user to implement. -- cgit v1.2.3