diff options
Diffstat (limited to 'LUFA/Drivers/USB/LowLevel')
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/Endpoint.c | 6 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/Host.c | 12 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/LowLevel.c | 8 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/LowLevel.h | 3 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/Pipe.c | 6 |
5 files changed, 22 insertions, 13 deletions
diff --git a/LUFA/Drivers/USB/LowLevel/Endpoint.c b/LUFA/Drivers/USB/LowLevel/Endpoint.c index 099022c1c..d02071bbd 100644 --- a/LUFA/Drivers/USB/LowLevel/Endpoint.c +++ b/LUFA/Drivers/USB/LowLevel/Endpoint.c @@ -80,8 +80,6 @@ uint8_t Endpoint_WaitUntilReady(void) uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;
#endif
- USB_INT_Clear(USB_INT_SOFI);
-
for (;;)
{
if (Endpoint_GetEndpointDirection() == ENDPOINT_DIR_IN)
@@ -100,9 +98,9 @@ uint8_t Endpoint_WaitUntilReady(void) else if (Endpoint_IsStalled())
return ENDPOINT_READYWAIT_EndpointStalled;
- if (USB_INT_HasOccurred(USB_INT_SOFI))
+ if (FrameElapsed)
{
- USB_INT_Clear(USB_INT_SOFI);
+ FrameElapsed = false;
if (!(TimeoutMSRem--))
return ENDPOINT_READYWAIT_Timeout;
diff --git a/LUFA/Drivers/USB/LowLevel/Host.c b/LUFA/Drivers/USB/LowLevel/Host.c index b606515e6..02a1c2171 100644 --- a/LUFA/Drivers/USB/LowLevel/Host.c +++ b/LUFA/Drivers/USB/LowLevel/Host.c @@ -210,14 +210,13 @@ uint8_t USB_Host_WaitMS(uint8_t MS) bool BusSuspended = USB_Host_IsBusSuspended();
uint8_t ErrorCode = HOST_WAITERROR_Successful;
- USB_INT_Clear(USB_INT_HSOFI);
USB_Host_ResumeBus();
while (MS)
{
- if (USB_INT_HasOccurred(USB_INT_HSOFI))
+ if (FrameElapsed)
{
- USB_INT_Clear(USB_INT_HSOFI);
+ FrameElapsed = false;
MS--;
}
@@ -260,9 +259,10 @@ static void USB_Host_ResetDevice(void) USB_Host_ResetBus();
while (!(USB_Host_IsBusResetComplete()));
- USB_INT_Clear(USB_INT_HSOFI);
USB_Host_ResumeBus();
+ FrameElapsed = false;
+
for (uint8_t MSRem = 10; MSRem != 0; MSRem--)
{
/* Workaround for powerless-pull-up devices. After a USB bus reset,
@@ -270,8 +270,10 @@ static void USB_Host_ResetDevice(void) looked for - if it is found within 10ms, the device is still
present. */
- if (USB_INT_HasOccurred(USB_INT_HSOFI))
+ if (FrameElapsed)
{
+ FrameElapsed = false;
+
USB_INT_Clear(USB_INT_DDISCI);
break;
}
diff --git a/LUFA/Drivers/USB/LowLevel/LowLevel.c b/LUFA/Drivers/USB/LowLevel/LowLevel.c index 8b395be98..255a6ef29 100644 --- a/LUFA/Drivers/USB/LowLevel/LowLevel.c +++ b/LUFA/Drivers/USB/LowLevel/LowLevel.c @@ -38,6 +38,8 @@ volatile uint8_t USB_CurrentMode = USB_MODE_NONE; volatile uint8_t USB_Options;
#endif
+volatile bool FrameElapsed;
+
void USB_Init(
#if defined(USB_CAN_BE_BOTH)
const uint8_t Mode
@@ -150,6 +152,8 @@ void USB_ResetInterface(void) USB_INT_DisableAllInterrupts();
USB_INT_ClearAllInterrupts();
+ FrameElapsed = false;
+
USB_IsConnected = false;
#if defined(USB_CAN_BE_HOST)
@@ -224,6 +228,7 @@ void USB_ResetInterface(void) #if defined(USB_DEVICE_ONLY)
USB_INT_Enable(USB_INT_SUSPEND);
USB_INT_Enable(USB_INT_EORSTI);
+ USB_INT_Enable(USB_INT_SOFI);
#if defined(CONTROL_ONLY_DEVICE)
UENUM = ENDPOINT_CONTROLEP;
@@ -240,11 +245,13 @@ void USB_ResetInterface(void) USB_INT_Enable(USB_INT_SRPI);
USB_INT_Enable(USB_INT_BCERRI);
+ USB_INT_Enable(USB_INT_HSOFI);
#else
if (USB_CurrentMode == USB_MODE_DEVICE)
{
USB_INT_Enable(USB_INT_SUSPEND);
USB_INT_Enable(USB_INT_EORSTI);
+ USB_INT_Enable(USB_INT_SOFI);
#if defined(CONTROL_ONLY_DEVICE)
UENUM = ENDPOINT_CONTROLEP;
@@ -262,6 +269,7 @@ void USB_ResetInterface(void) USB_INT_Enable(USB_INT_SRPI);
USB_INT_Enable(USB_INT_BCERRI);
+ USB_INT_Enable(USB_INT_HSOFI);
}
#endif
}
diff --git a/LUFA/Drivers/USB/LowLevel/LowLevel.h b/LUFA/Drivers/USB/LowLevel/LowLevel.h index 41b0ff5f6..4279ca315 100644 --- a/LUFA/Drivers/USB/LowLevel/LowLevel.h +++ b/LUFA/Drivers/USB/LowLevel/LowLevel.h @@ -350,6 +350,9 @@ return USB_MODE_HOST;
}
#endif
+
+ /* External Variables: */
+ extern volatile bool FrameElapsed;
#endif
diff --git a/LUFA/Drivers/USB/LowLevel/Pipe.c b/LUFA/Drivers/USB/LowLevel/Pipe.c index 71a33d62f..720da1772 100644 --- a/LUFA/Drivers/USB/LowLevel/Pipe.c +++ b/LUFA/Drivers/USB/LowLevel/Pipe.c @@ -76,8 +76,6 @@ uint8_t Pipe_WaitUntilReady(void) uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;
#endif
- USB_INT_Clear(USB_INT_HSOFI);
-
for (;;)
{
if (Pipe_GetPipeToken() == PIPE_TOKEN_IN)
@@ -96,9 +94,9 @@ uint8_t Pipe_WaitUntilReady(void) else if (!(USB_IsConnected))
return PIPE_READYWAIT_DeviceDisconnected;
- if (USB_INT_HasOccurred(USB_INT_HSOFI))
+ if (FrameElapsed)
{
- USB_INT_Clear(USB_INT_HSOFI);
+ FrameElapsed = false;
if (!(TimeoutMSRem--))
return PIPE_READYWAIT_Timeout;
|