diff --git a/Demos/Host/CDCHost/CDCHost.c b/Demos/Host/CDCHost/CDCHost.c index a51f597a2f1c65ff99bcf5b25bf9bb7b28837f4f..9ecf060b3fad4f229103b642c6291f91171e8373 100644 --- a/Demos/Host/CDCHost/CDCHost.c +++ b/Demos/Host/CDCHost/CDCHost.c @@ -196,6 +196,9 @@ TASK(USB_CDC_Host) 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) { diff --git a/Demos/Host/GenericHIDHost/GenericHIDHost.c b/Demos/Host/GenericHIDHost/GenericHIDHost.c index 605fc6f678867cc75dfce6f1ef6df1db18457661..4d2fefb38c931714bef1756687f49d17aafe2988 100644 --- a/Demos/Host/GenericHIDHost/GenericHIDHost.c +++ b/Demos/Host/GenericHIDHost/GenericHIDHost.c @@ -262,6 +262,9 @@ void WriteNextReport(uint8_t* ReportOUTData, uint16_t ReportLength) wLength: ReportLength, }; + /* Select the control pipe for the request transfer */ + Pipe_SelectPipe(PIPE_CONTROLPIPE); + /* Send the request to the device */ USB_Host_SendControlRequest(ReportOUTData); } @@ -288,6 +291,9 @@ TASK(USB_HID_Host) 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) { diff --git a/Demos/Host/KeyboardHost/KeyboardHost.c b/Demos/Host/KeyboardHost/KeyboardHost.c index f73e5689387abdf7aed376db7aa1b35e3acc8061..947f23281a03822fab866439f76a102e192f3388 100644 --- a/Demos/Host/KeyboardHost/KeyboardHost.c +++ b/Demos/Host/KeyboardHost/KeyboardHost.c @@ -263,6 +263,9 @@ TASK(USB_Keyboard_Host) 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) { @@ -310,6 +313,9 @@ TASK(USB_Keyboard_Host) 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) { diff --git a/Demos/Host/KeyboardHostWithParser/HIDReport.c b/Demos/Host/KeyboardHostWithParser/HIDReport.c index 89bd1c866e2af2dd06fcfa17a47e7ed045b7d660..d177a8877d0f97bba688de0b8c891a3ca86923b9 100644 --- a/Demos/Host/KeyboardHostWithParser/HIDReport.c +++ b/Demos/Host/KeyboardHostWithParser/HIDReport.c @@ -56,6 +56,9 @@ uint8_t GetHIDReportData(void) wLength: HIDReportSize, }; + /* Select the control pipe for the request transfer */ + Pipe_SelectPipe(PIPE_CONTROLPIPE); + /* Send control request to retrieve the HID report from the attached device */ if (USB_Host_SendControlRequest(HIDReportData) != HOST_SENDCONTROL_Successful) return ParseControlError; diff --git a/Demos/Host/KeyboardHostWithParser/KeyboardHostWithParser.c b/Demos/Host/KeyboardHostWithParser/KeyboardHostWithParser.c index eefd2fa56b6667340b3e60ff9541001cc0198bf7..d19929d4d1eb3dd44155813537d4f816ea728cda 100644 --- a/Demos/Host/KeyboardHostWithParser/KeyboardHostWithParser.c +++ b/Demos/Host/KeyboardHostWithParser/KeyboardHostWithParser.c @@ -199,6 +199,9 @@ TASK(USB_Keyboard_Host) 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) { diff --git a/Demos/Host/MassStorageHost/MassStorageHost.c b/Demos/Host/MassStorageHost/MassStorageHost.c index a7b550ca74fe5f6d989a9b7fee8b7ad29da3b81f..ec5bc6107bc735640bfc90ed49e72d4d2e0cf472 100644 --- a/Demos/Host/MassStorageHost/MassStorageHost.c +++ b/Demos/Host/MassStorageHost/MassStorageHost.c @@ -170,6 +170,9 @@ TASK(USB_MassStore_Host) 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) { diff --git a/Demos/Host/MassStorageHost/MassStoreCommands.c b/Demos/Host/MassStorageHost/MassStoreCommands.c index 0d88acbd564314f3df5e6c836a6a9d21125b6b73..bf736e79c470ad2aabfec4ebd475e08f8052cd83 100644 --- a/Demos/Host/MassStorageHost/MassStoreCommands.c +++ b/Demos/Host/MassStorageHost/MassStoreCommands.c @@ -256,6 +256,9 @@ uint8_t MassStore_ClearPipeStall(const uint8_t EndpointNum) wLength: 0, }; + /* Select the control pipe for the request transfer */ + Pipe_SelectPipe(PIPE_CONTROLPIPE); + return USB_Host_SendControlRequest(NULL); } @@ -275,6 +278,9 @@ uint8_t MassStore_MassStorageReset(void) wLength: 0, }; + /* Select the control pipe for the request transfer */ + Pipe_SelectPipe(PIPE_CONTROLPIPE); + return USB_Host_SendControlRequest(NULL); } @@ -298,6 +304,9 @@ uint8_t MassStore_GetMaxLUN(uint8_t* const MaxLUNIndex) wLength: 1, }; + /* Select the control pipe for the request transfer */ + Pipe_SelectPipe(PIPE_CONTROLPIPE); + if ((ErrorCode = USB_Host_SendControlRequest(MaxLUNIndex)) == HOST_SENDCONTROL_SetupStalled) { /* Clear the pipe stall */ diff --git a/Demos/Host/MouseHost/MouseHost.c b/Demos/Host/MouseHost/MouseHost.c index 29cbd8741bbe3efac5c64021d6781a79c6d460cb..ff2542834e65ddb192cbdee1515f7ae31628e980 100644 --- a/Demos/Host/MouseHost/MouseHost.c +++ b/Demos/Host/MouseHost/MouseHost.c @@ -259,6 +259,9 @@ TASK(USB_Mouse_Host) 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) { @@ -306,6 +309,9 @@ TASK(USB_Mouse_Host) 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) { diff --git a/Demos/Host/MouseHostWithParser/HIDReport.c b/Demos/Host/MouseHostWithParser/HIDReport.c index 55f250dd9832eb9db98b5121089ea06a774480b0..3d06bb1409d4f8a87367d60df197e9df16f3c7fc 100644 --- a/Demos/Host/MouseHostWithParser/HIDReport.c +++ b/Demos/Host/MouseHostWithParser/HIDReport.c @@ -56,6 +56,9 @@ uint8_t GetHIDReportData(void) wLength: HIDReportSize, }; + /* Select the control pipe for the request transfer */ + Pipe_SelectPipe(PIPE_CONTROLPIPE); + /* Send control request to retrieve the HID report from the attached device */ if (USB_Host_SendControlRequest(HIDReportData) != HOST_SENDCONTROL_Successful) return ParseControlError; diff --git a/Demos/Host/MouseHostWithParser/MouseHostWithParser.c b/Demos/Host/MouseHostWithParser/MouseHostWithParser.c index 79cecdf5b2249e98e3566bd9fa52afb358aaee31..6aeca4ba56c3d888d180038774420ed28d73daf4 100644 --- a/Demos/Host/MouseHostWithParser/MouseHostWithParser.c +++ b/Demos/Host/MouseHostWithParser/MouseHostWithParser.c @@ -200,6 +200,9 @@ TASK(USB_Mouse_Host) 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) { diff --git a/Demos/Host/StillImageHost/StillImageCommands.c b/Demos/Host/StillImageHost/StillImageCommands.c index be6f7482df7941e2b8fc9a583baaa911be46b99b..43e57e126ebcdb1d9aaf3ef7ec19c1589c2ab3bb 100644 --- a/Demos/Host/StillImageHost/StillImageCommands.c +++ b/Demos/Host/StillImageHost/StillImageCommands.c @@ -272,5 +272,8 @@ uint8_t SImage_ClearPipeStall(const uint8_t PipeEndpointNum) wLength: 0, }; + /* Select the control pipe for the request transfer */ + Pipe_SelectPipe(PIPE_CONTROLPIPE); + return USB_Host_SendControlRequest(NULL); } diff --git a/Demos/Host/StillImageHost/StillImageHost.c b/Demos/Host/StillImageHost/StillImageHost.c index 787629c3b25139d1930d25af5a44f4418e74710a..1694322ee86b6d01b91b1b733bc63fc61f0f3fa2 100644 --- a/Demos/Host/StillImageHost/StillImageHost.c +++ b/Demos/Host/StillImageHost/StillImageHost.c @@ -165,6 +165,9 @@ TASK(USB_SImage_Host) 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 (USB_Host_SendControlRequest(NULL) != HOST_SENDCONTROL_Successful) { diff --git a/LUFA/ChangeLog.txt b/LUFA/ChangeLog.txt index 78f1ec747407916df1b8c1fb8b0ed5f05c0b7de0..80436f66a98f8f4de1516e7af157b65c0b5c06e2 100644 --- a/LUFA/ChangeLog.txt +++ b/LUFA/ChangeLog.txt @@ -31,6 +31,9 @@ * - Fixed WriteNextReport code in the GenericHIDHost demo using incorrect parameter types and not selecting the correct endpoint * - Adjusted sample CTC timer calculations in the AudioOutput and AudioInput demos to account for situations where the division results * in a value with no remainder, requiring one to be subtracted from the result (thanks to Robin Theunis) + * - The USB_Host_SendControlRequest() function no longer automatically selects the Control pipe (pipe 0), so that other control type + * pipes can be used with the function + * - The USB Host management task now saves and restores the currently selected pipe before and after the task completes * * \section Sec_ChangeLog090401 Version 090401 * diff --git a/LUFA/Drivers/USB/Class/ConfigDescriptor.c b/LUFA/Drivers/USB/Class/ConfigDescriptor.c index d79106916f4ece7cc59a81d65e59f640377daa70..f22426bf06bfad21691dd3c1d088d07b20f51f5c 100644 --- a/LUFA/Drivers/USB/Class/ConfigDescriptor.c +++ b/LUFA/Drivers/USB/Class/ConfigDescriptor.c @@ -43,6 +43,8 @@ uint8_t USB_Host_GetDeviceConfigDescriptor(uint16_t* const ConfigSizePtr, void* wLength: sizeof(USB_Descriptor_Configuration_Header_t), }; + Pipe_SelectPipe(PIPE_CONTROLPIPE); + if (BufferPtr == NULL) { uint8_t ConfigHeader[sizeof(USB_Descriptor_Configuration_Header_t)]; diff --git a/LUFA/Drivers/USB/HighLevel/USBTask.c b/LUFA/Drivers/USB/HighLevel/USBTask.c index 395f2d25e4d934b0206551a27c191179bfb5eafd..e62ac687fcb332ed652b94db88665ff6d6b81645 100644 --- a/LUFA/Drivers/USB/HighLevel/USBTask.c +++ b/LUFA/Drivers/USB/HighLevel/USBTask.c @@ -86,6 +86,10 @@ static void USB_HostTask(void) static uint16_t WaitMSRemaining; static uint8_t PostWaitState; + uint8_t PrevPipe = Pipe_GetCurrentPipe(); + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + switch (USB_HostState) { case HOST_STATE_WaitForDevice: @@ -249,5 +253,7 @@ static void USB_HostTask(void) USB_ResetInterface(); } + + Pipe_SelectPipe(PrevPipe); } #endif diff --git a/LUFA/Drivers/USB/LowLevel/HostChapter9.c b/LUFA/Drivers/USB/LowLevel/HostChapter9.c index 123a1d25f32dcd8fcbc3bacb44b66a54b9d04d3f..5367c984cb1ac37fc45d9a12e9aeb3b0f7914b0c 100644 --- a/LUFA/Drivers/USB/LowLevel/HostChapter9.c +++ b/LUFA/Drivers/USB/LowLevel/HostChapter9.c @@ -50,7 +50,6 @@ uint8_t USB_Host_SendControlRequest(void* BufferPtr) if ((ReturnStatus = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful) return ReturnStatus; - Pipe_SelectPipe(PIPE_CONTROLPIPE); Pipe_SetToken(PIPE_TOKEN_SETUP); Pipe_ClearErrorFlags(); Pipe_ClearSetupSent(); diff --git a/LUFA/Drivers/USB/LowLevel/HostChapter9.h b/LUFA/Drivers/USB/LowLevel/HostChapter9.h index 84ee8ae8a8288f91b9b3a338497873721fb84b31..7ced889b33a3a05281ffa98e5c7efc0d72bf154b 100644 --- a/LUFA/Drivers/USB/LowLevel/HostChapter9.h +++ b/LUFA/Drivers/USB/LowLevel/HostChapter9.h @@ -95,7 +95,7 @@ /* Function Prototypes: */ /** Sends the request stored in the USB_HostRequest global structure to the attached device, * and transfers the data stored in the buffer to the device, or from the device to the buffer - * as requested. + * as requested. The transfer is made on the currently selected pipe. * * \param BufferPtr Pointer to the start of the data buffer if the request has a data stage, or * NULL if the request transfers no data to or from the device. diff --git a/LUFA/MigrationInformation.txt b/LUFA/MigrationInformation.txt index 9aa3b0005f45c1fb5e0952925f436f5348ade7a9..49fa25dea8d057224c9cc7c0789b0fe37376c8e7 100644 --- a/LUFA/MigrationInformation.txt +++ b/LUFA/MigrationInformation.txt @@ -12,6 +12,12 @@ * * \section Sec_MigrationXXXXXX Migrating from 090401 to XXXXXX * + * <b>Host Mode</b> + * - The USB_Host_SendControlRequest() function no longer automatically selects the Control pipe (pipe 0) to allow it to be used on + * other control type pipes. Care should be taken to ensure that the Control pipe is always selected before the function is called + * in existing projects where the Control pipe is to be operated on. + * - The USB Host management task now saves and restores the currently selected pipe before and after the task runs. Projects no longer + * need to manage this manually when calling the USB management task. * * \section Sec_Migration090401 Migrating from 090209 to 090401 *