diff options
Diffstat (limited to 'LUFA/Drivers/USB/LowLevel/Host.c')
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/Host.c | 67 |
1 files changed, 34 insertions, 33 deletions
diff --git a/LUFA/Drivers/USB/LowLevel/Host.c b/LUFA/Drivers/USB/LowLevel/Host.c index 1fa5290fc..25b08b73b 100644 --- a/LUFA/Drivers/USB/LowLevel/Host.c +++ b/LUFA/Drivers/USB/LowLevel/Host.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -55,15 +55,15 @@ void USB_Host_ProcessNextHostState(void) ErrorCode = HOST_ENUMERROR_WaitStage; break; } - + if (!(--WaitMSRemaining)) USB_HostState = PostWaitState; } - + break; case HOST_STATE_Powered: WaitMSRemaining = HOST_DEVICE_SETTLE_DELAY_MS; - + USB_HostState = HOST_STATE_Powered_WaitForDeviceSettle; break; case HOST_STATE_Powered_WaitForDeviceSettle: @@ -79,23 +79,23 @@ void USB_Host_ProcessNextHostState(void) USB_OTGPAD_On(); USB_Host_VBUS_Auto_Enable(); USB_Host_VBUS_Auto_On(); - + USB_HostState = HOST_STATE_Powered_WaitForConnect; } - + break; - case HOST_STATE_Powered_WaitForConnect: + case HOST_STATE_Powered_WaitForConnect: if (USB_INT_HasOccurred(USB_INT_DCONNI)) - { + { USB_INT_Clear(USB_INT_DCONNI); USB_INT_Clear(USB_INT_DDISCI); USB_INT_Clear(USB_INT_VBERRI); USB_INT_Enable(USB_INT_VBERRI); - + USB_Host_ResumeBus(); Pipe_ClearPipes(); - + HOST_TASK_NONBLOCK_WAIT(100, HOST_STATE_Powered_DoReset); } @@ -108,8 +108,8 @@ void USB_Host_ProcessNextHostState(void) case HOST_STATE_Powered_ConfigPipe: Pipe_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL, PIPE_TOKEN_SETUP, ENDPOINT_CONTROLEP, - PIPE_CONTROLPIPE_DEFAULT_SIZE, PIPE_BANK_SINGLE); - + PIPE_CONTROLPIPE_DEFAULT_SIZE, PIPE_BANK_SINGLE); + if (!(Pipe_IsConfigured())) { ErrorCode = HOST_ENUMERROR_PipeConfigError; @@ -138,9 +138,9 @@ void USB_Host_ProcessNextHostState(void) } USB_ControlPipeSize = DataBuffer[offsetof(USB_Descriptor_Device_t, Endpoint0Size)]; - + USB_Host_ResetDevice(); - + HOST_TASK_NONBLOCK_WAIT(200, HOST_STATE_Default_PostReset); break; case HOST_STATE_Default_PostReset: @@ -197,7 +197,7 @@ 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_INT_Disable(USB_INT_HSOFI); USB_INT_Clear(USB_INT_HSOFI); @@ -210,11 +210,11 @@ uint8_t USB_Host_WaitMS(uint8_t MS) USB_INT_Clear(USB_INT_HSOFI); MS--; } - + if ((USB_HostState == HOST_STATE_Unattached) || (USB_CurrentMode != USB_MODE_Host)) { ErrorCode = HOST_WAITERROR_DeviceDisconnect; - + break; } @@ -222,16 +222,16 @@ uint8_t USB_Host_WaitMS(uint8_t MS) { Pipe_ClearError(); ErrorCode = HOST_WAITERROR_PipeError; - + break; } - + if (Pipe_IsStalled() == true) { Pipe_ClearStall(); ErrorCode = HOST_WAITERROR_SetupStalled; - - break; + + break; } } @@ -249,7 +249,7 @@ static void USB_Host_ResetDevice(void) bool BusSuspended = USB_Host_IsBusSuspended(); USB_INT_Disable(USB_INT_DDISCI); - + USB_Host_ResetBus(); while (!(USB_Host_IsBusResetComplete())); USB_Host_ResumeBus(); @@ -258,7 +258,7 @@ static void USB_Host_ResetDevice(void) USB_INT_Disable(USB_INT_HSOFI); USB_INT_Clear(USB_INT_HSOFI); - + for (uint8_t MSRem = 10; MSRem != 0; MSRem--) { /* Workaround for powerless-pull-up devices. After a USB bus reset, @@ -272,7 +272,7 @@ static void USB_Host_ResetDevice(void) USB_INT_Clear(USB_INT_DDISCI); break; } - + _delay_ms(1); } @@ -297,7 +297,7 @@ uint8_t USB_Host_SetDeviceConfiguration(const uint8_t ConfigNumber) }; Pipe_SelectPipe(PIPE_CONTROLPIPE); - + return USB_Host_SendControlRequest(NULL); } @@ -313,7 +313,7 @@ uint8_t USB_Host_GetDeviceDescriptor(void* const DeviceDescriptorPtr) }; Pipe_SelectPipe(PIPE_CONTROLPIPE); - + return USB_Host_SendControlRequest(DeviceDescriptorPtr); } @@ -331,7 +331,7 @@ uint8_t USB_Host_GetDeviceStringDescriptor(const uint8_t Index, }; Pipe_SelectPipe(PIPE_CONTROLPIPE); - + return USB_Host_SendControlRequest(Buffer); } @@ -347,8 +347,9 @@ uint8_t USB_Host_ClearPipeStall(const uint8_t EndpointNum) }; Pipe_SelectPipe(PIPE_CONTROLPIPE); - + return USB_Host_SendControlRequest(NULL); } #endif + |