aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB/LowLevel/Host.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-07-21 13:31:21 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-07-21 13:31:21 +0000
commite071f3897a0946c6be1e1b5e1f78eda8dcbf6fc7 (patch)
tree51ac5c80564fd76c93a357ee4d52a347384ac84b /LUFA/Drivers/USB/LowLevel/Host.c
parent44179abcf85acb14fb3aff72ce50ae84281c0f2e (diff)
downloadlufa-e071f3897a0946c6be1e1b5e1f78eda8dcbf6fc7.tar.gz
lufa-e071f3897a0946c6be1e1b5e1f78eda8dcbf6fc7.tar.bz2
lufa-e071f3897a0946c6be1e1b5e1f78eda8dcbf6fc7.zip
Added new USB_DeviceState variable to keep track of the current Device mode USB state.
Added new Endpoint_ClearStatusStage() convenience function to assist with the status stages of control transfers. Removed vague USB_IsConnected global - test USB_DeviceState or USB_HostState explicitly to gain previous functionality. Removed USB_IsSuspended global - test USB_DeviceState against DEVICE_STATE_Suspended instead. Fixed possible enumeration errors from spinloops which may fail to exit if the USB connection is severed before the exit condition becomes true.
Diffstat (limited to 'LUFA/Drivers/USB/LowLevel/Host.c')
-rw-r--r--LUFA/Drivers/USB/LowLevel/Host.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/LUFA/Drivers/USB/LowLevel/Host.c b/LUFA/Drivers/USB/LowLevel/Host.c
index efe4baeeb..ae7525bee 100644
--- a/LUFA/Drivers/USB/LowLevel/Host.c
+++ b/LUFA/Drivers/USB/LowLevel/Host.c
@@ -60,12 +60,12 @@ void USB_Host_ProcessNextHostState(void)
}
break;
- case HOST_STATE_Attached:
+ case HOST_STATE_Powered:
WaitMSRemaining = HOST_DEVICE_SETTLE_DELAY_MS;
- USB_HostState = HOST_STATE_Attached_WaitForDeviceSettle;
+ USB_HostState = HOST_STATE_Powered_WaitForDeviceSettle;
break;
- case HOST_STATE_Attached_WaitForDeviceSettle:
+ case HOST_STATE_Powered_WaitForDeviceSettle:
#if HOST_DEVICE_SETTLE_DELAY_MS > 0
_delay_ms(1);
@@ -77,14 +77,14 @@ void USB_Host_ProcessNextHostState(void)
USB_Host_VBUS_Auto_Enable();
USB_Host_VBUS_Auto_On();
- USB_HostState = HOST_STATE_Attached_WaitForConnect;
+ USB_HostState = HOST_STATE_Powered_WaitForConnect;
}
#else
- USB_HostState = HOST_STATE_Attached_WaitForConnect;
+ USB_HostState = HOST_STATE_Powered_WaitForConnect;
#endif
break;
- case HOST_STATE_Attached_WaitForConnect:
+ case HOST_STATE_Powered_WaitForConnect:
if (USB_INT_HasOccurred(USB_INT_DCONNI))
{
USB_INT_Clear(USB_INT_DCONNI);
@@ -93,22 +93,21 @@ void USB_Host_ProcessNextHostState(void)
USB_INT_Clear(USB_INT_VBERRI);
USB_INT_Enable(USB_INT_VBERRI);
- USB_IsConnected = true;
EVENT_USB_Connect();
USB_Host_ResumeBus();
Pipe_ClearPipes();
- HOST_TASK_NONBLOCK_WAIT(100, HOST_STATE_Attached_DoReset);
+ HOST_TASK_NONBLOCK_WAIT(100, HOST_STATE_Powered_DoReset);
}
break;
- case HOST_STATE_Attached_DoReset:
+ case HOST_STATE_Powered_DoReset:
USB_Host_ResetDevice();
- HOST_TASK_NONBLOCK_WAIT(200, HOST_STATE_Powered);
+ HOST_TASK_NONBLOCK_WAIT(200, HOST_STATE_Powered_ConfigPipe);
break;
- case HOST_STATE_Powered:
+ case HOST_STATE_Powered_ConfigPipe:
Pipe_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL,
PIPE_TOKEN_SETUP, ENDPOINT_CONTROLEP,
PIPE_CONTROLPIPE_DEFAULT_SIZE, PIPE_BANK_SINGLE);
@@ -199,9 +198,7 @@ void USB_Host_ProcessNextHostState(void)
USB_Host_VBUS_Auto_Off();
EVENT_USB_DeviceUnattached();
-
- if (USB_IsConnected)
- EVENT_USB_Disconnect();
+ EVENT_USB_Disconnect();
USB_ResetInterface();
}
@@ -222,7 +219,7 @@ uint8_t USB_Host_WaitMS(uint8_t MS)
MS--;
}
- if ((USB_IsConnected == false) || (USB_CurrentMode == USB_MODE_DEVICE))
+ if ((USB_HostState == HOST_STATE_Unattached) || (USB_CurrentMode == USB_MODE_DEVICE))
{
ErrorCode = HOST_WAITERROR_DeviceDisconnect;