Remove USB_MODE_* macros, replace with a semantically linked USB_Modes_t enum.
Moved the USB device selection logic for ENDPOINT_TOTAL_ENDPOINTS further up in Endpoint.h to where the endpoint bank capabilities are determined, to reduce the total number of device-specific logic. Change USB_Host_WaitMS() to test and disable the HSOFI interrupt before resuming the bus, so that it does not fire before the delay loop has run. Add missing const qualifier to the parameter of USB_Host_ClearPipeStall().
This commit is contained in:
parent
c1cfffd8eb
commit
7aaced1e8b
11 changed files with 77 additions and 78 deletions
|
@ -196,14 +196,13 @@ uint8_t USB_Host_WaitMS(uint8_t MS)
|
|||
{
|
||||
bool BusSuspended = USB_Host_IsBusSuspended();
|
||||
uint8_t ErrorCode = HOST_WAITERROR_Successful;
|
||||
bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI);
|
||||
|
||||
USB_Host_ResumeBus();
|
||||
|
||||
bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI);
|
||||
|
||||
USB_INT_Disable(USB_INT_HSOFI);
|
||||
USB_INT_Clear(USB_INT_HSOFI);
|
||||
|
||||
USB_Host_ResumeBus();
|
||||
|
||||
while (MS)
|
||||
{
|
||||
if (USB_INT_HasOccurred(USB_INT_HSOFI))
|
||||
|
@ -212,7 +211,7 @@ uint8_t USB_Host_WaitMS(uint8_t MS)
|
|||
MS--;
|
||||
}
|
||||
|
||||
if ((USB_HostState == HOST_STATE_Unattached) || (USB_CurrentMode == USB_MODE_DEVICE))
|
||||
if ((USB_HostState == HOST_STATE_Unattached) || (USB_CurrentMode != USB_MODE_Host))
|
||||
{
|
||||
ErrorCode = HOST_WAITERROR_DeviceDisconnect;
|
||||
|
||||
|
@ -236,12 +235,12 @@ uint8_t USB_Host_WaitMS(uint8_t MS)
|
|||
}
|
||||
}
|
||||
|
||||
if (HSOFIEnabled)
|
||||
USB_INT_Enable(USB_INT_HSOFI);
|
||||
|
||||
if (BusSuspended)
|
||||
USB_Host_SuspendBus();
|
||||
|
||||
if (HSOFIEnabled)
|
||||
USB_INT_Enable(USB_INT_HSOFI);
|
||||
|
||||
return ErrorCode;
|
||||
}
|
||||
|
||||
|
@ -336,7 +335,7 @@ uint8_t USB_Host_GetDeviceStringDescriptor(const uint8_t Index,
|
|||
return USB_Host_SendControlRequest(Buffer);
|
||||
}
|
||||
|
||||
uint8_t USB_Host_ClearPipeStall(uint8_t EndpointNum)
|
||||
uint8_t USB_Host_ClearPipeStall(const uint8_t EndpointNum)
|
||||
{
|
||||
USB_ControlRequest = (USB_Request_Header_t)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue