aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB/Core/UC3/Host_UC3.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2011-07-08 07:25:56 +0000
committerDean Camera <dean@fourwalledcubicle.com>2011-07-08 07:25:56 +0000
commit137ce280c1e9c33e9393f1dfd6bb160c131bd1a4 (patch)
tree9db0900f06376a93ef2b6d9e9ef1edbfdc2a1f79 /LUFA/Drivers/USB/Core/UC3/Host_UC3.c
parentbcb627e1a1bb9f013670d981ead2db97d7c70608 (diff)
downloadlufa-137ce280c1e9c33e9393f1dfd6bb160c131bd1a4.tar.gz
lufa-137ce280c1e9c33e9393f1dfd6bb160c131bd1a4.tar.bz2
lufa-137ce280c1e9c33e9393f1dfd6bb160c131bd1a4.zip
Updated all host mode demos and projects to use the EVENT_USB_Host_DeviceEnumerationComplete() event callback for device configuration instead of manual host state machine manipulations in the main application task.
Added new USB_Host_ConfigurationNumber global variable to indicate the selected configuration in an attached device. Renamed global state variables that are specific to a certain USB mode to clearly indicate which mode the variable relates to, by changing the USB_* prefix to USB_Device_* or USB_Host_*. Removed the HOST_STATE_WaitForDeviceRemoval and HOST_STATE_Suspended host state machine states, as these are no longer required. Altered the USB_Host_SetDeviceConfiguration() function to update the new USB_Host_ConfigurationNumber global as required. Moved out the Host mode standard request convenience/helper functions from the architecture specific Host driver files to the architecture agnostic HostStandardReq.c driver file.
Diffstat (limited to 'LUFA/Drivers/USB/Core/UC3/Host_UC3.c')
-rw-r--r--LUFA/Drivers/USB/Core/UC3/Host_UC3.c92
1 files changed, 6 insertions, 86 deletions
diff --git a/LUFA/Drivers/USB/Core/UC3/Host_UC3.c b/LUFA/Drivers/USB/Core/UC3/Host_UC3.c
index 1dd2b578b..a56ef4819 100644
--- a/LUFA/Drivers/USB/Core/UC3/Host_UC3.c
+++ b/LUFA/Drivers/USB/Core/UC3/Host_UC3.c
@@ -137,7 +137,7 @@ void USB_Host_ProcessNextHostState(void)
break;
}
- USB_ControlPipeSize = DataBuffer[offsetof(USB_Descriptor_Device_t, Endpoint0Size)];
+ USB_Host_ControlPipeSize = DataBuffer[offsetof(USB_Descriptor_Device_t, Endpoint0Size)];
USB_Host_ResetDevice();
@@ -146,7 +146,7 @@ void USB_Host_ProcessNextHostState(void)
case HOST_STATE_Default_PostReset:
Pipe_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL,
PIPE_TOKEN_SETUP, ENDPOINT_CONTROLEP,
- USB_ControlPipeSize, PIPE_BANK_SINGLE);
+ USB_Host_ControlPipeSize, PIPE_BANK_SINGLE);
if (!(Pipe_IsConfigured()))
{
@@ -175,8 +175,9 @@ void USB_Host_ProcessNextHostState(void)
case HOST_STATE_Default_PostAddressSet:
USB_Host_SetDeviceAddress(USB_HOST_DEVICEADDRESS);
- EVENT_USB_Host_DeviceEnumerationComplete();
USB_HostState = HOST_STATE_Addressed;
+
+ EVENT_USB_Host_DeviceEnumerationComplete();
break;
}
@@ -253,6 +254,8 @@ static void USB_Host_ResetDevice(void)
USB_Host_ResetBus();
while (!(USB_Host_IsBusResetComplete()));
USB_Host_ResumeBus();
+
+ USB_Host_ConfigurationNumber = 0;
bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI);
@@ -285,88 +288,5 @@ static void USB_Host_ResetDevice(void)
USB_INT_Enable(USB_INT_DDISCI);
}
-uint8_t USB_Host_SetDeviceConfiguration(const 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);
-}
-
-uint8_t USB_Host_GetDeviceDescriptor(void* const DeviceDescriptorPtr)
-{
- USB_ControlRequest = (USB_Request_Header_t)
- {
- .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),
- .bRequest = REQ_GetDescriptor,
- .wValue = (DTYPE_Device << 8),
- .wIndex = 0,
- .wLength = sizeof(USB_Descriptor_Device_t),
- };
-
- Pipe_SelectPipe(PIPE_CONTROLPIPE);
-
- return USB_Host_SendControlRequest(DeviceDescriptorPtr);
-}
-
-uint8_t USB_Host_GetDeviceStringDescriptor(const uint8_t Index,
- void* const Buffer,
- const 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(const uint8_t EndpointNum)
-{
- USB_ControlRequest = (USB_Request_Header_t)
- {
- .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT),
- .bRequest = REQ_ClearFeature,
- .wValue = FEATURE_SEL_EndpointHalt,
- .wIndex = EndpointNum,
- .wLength = 0,
- };
-
- Pipe_SelectPipe(PIPE_CONTROLPIPE);
-
- return USB_Host_SendControlRequest(NULL);
-}
-
-uint8_t USB_Host_SetInterfaceAltSetting(const uint8_t InterfaceIndex,
- const uint8_t AltSetting)
-{
- USB_ControlRequest = (USB_Request_Header_t)
- {
- .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_INTERFACE),
- .bRequest = REQ_SetInterface,
- .wValue = AltSetting,
- .wIndex = InterfaceIndex,
- .wLength = 0,
- };
-
- Pipe_SelectPipe(PIPE_CONTROLPIPE);
-
- return USB_Host_SendControlRequest(NULL);
-}
-
#endif