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. --- .../MouseHostWithParser/MouseHostWithParser.c | 49 ++++++++-------------- 1 file changed, 18 insertions(+), 31 deletions(-) (limited to 'Demos/Host/LowLevel/MouseHostWithParser') diff --git a/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c b/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c index 3ef5503b3..5f0d35866 100644 --- a/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c +++ b/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c @@ -132,37 +132,7 @@ void Mouse_HID_Task(void) /* Switch to determine what user-application handled host state the host state machine is in */ switch (USB_HostState) { - case HOST_STATE_Addressed: - /* Standard request to set the device configuration to configuration 1 */ - USB_ControlRequest = (USB_Request_Header_t) - { - .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE), - .bRequest = REQ_SetConfiguration, - .wValue = 1, - .wIndex = 0, - .wLength = 0, - }; - - /* Select the control pipe for the request transfer */ - Pipe_SelectPipe(PIPE_CONTROLPIPE); - - /* Send the request, display error and wait for device detach if request fails */ - if ((ErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful) - { - puts_P(PSTR("Control Error (Set Configuration).\r\n")); - printf_P(PSTR(" -- Error Code: %d\r\n"), ErrorCode); - - /* Indicate error via status LEDs */ - LEDs_SetAllLEDs(LEDMASK_USB_ERROR); - - /* Wait until USB device disconnected */ - while (USB_IsConnected); - break; - } - - USB_HostState = HOST_STATE_Configured; - break; - case HOST_STATE_Configured: + case HOST_STATE_Addressed: puts_P(PSTR("Getting Config Data.\r\n")); /* Get and process the configuration descriptor data */ @@ -183,6 +153,23 @@ void Mouse_HID_Task(void) break; } + /* Set the device configuration to the first configuration (rarely do devices use multiple configurations) */ + if ((ErrorCode = USB_Host_SetDeviceConfiguration(1)) != HOST_SENDCONTROL_Successful) + { + puts_P(PSTR("Control Error (Set Configuration).\r\n")); + printf_P(PSTR(" -- Error Code: %d\r\n"), ErrorCode); + + /* Indicate error via status LEDs */ + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); + + /* Wait until USB device disconnected */ + while (USB_IsConnected); + break; + } + + USB_HostState = HOST_STATE_Configured; + break; + case HOST_STATE_Configured: puts_P(PSTR("Processing HID Report.\r\n")); /* Get and process the device's first HID report descriptor */ -- cgit v1.2.3