diff options
Diffstat (limited to 'LUFA/Drivers/USB/LowLevel')
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/DevChapter9.c | 19 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/DevChapter9.h | 2 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/Host.c | 9 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/Host.h | 6 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/LowLevel.c | 40 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/LowLevel.h | 4 |
6 files changed, 34 insertions, 46 deletions
diff --git a/LUFA/Drivers/USB/LowLevel/DevChapter9.c b/LUFA/Drivers/USB/LowLevel/DevChapter9.c index f9c52e666..033db094e 100644 --- a/LUFA/Drivers/USB/LowLevel/DevChapter9.c +++ b/LUFA/Drivers/USB/LowLevel/DevChapter9.c @@ -39,7 +39,7 @@ uint8_t USB_ConfigurationNumber; bool USB_RemoteWakeupEnabled;
bool USB_CurrentlySelfPowered;
-void USB_Device_ProcessControlPacket(void)
+void USB_Device_ProcessControlRequest(void)
{
bool RequestHandled = false;
uint8_t* RequestHeader = (uint8_t*)&USB_ControlRequest;
@@ -106,7 +106,7 @@ void USB_Device_ProcessControlPacket(void) }
if (!(RequestHandled))
- EVENT_USB_UnhandledControlPacket();
+ EVENT_USB_Device_UnhandledControlRequest();
if (Endpoint_IsSETUPReceived())
{
@@ -139,8 +139,6 @@ static void USB_Device_SetAddress(void) static void USB_Device_SetConfiguration(void)
{
- bool AlreadyConfigured = (USB_ConfigurationNumber != 0);
-
#if defined(FIXED_NUM_CONFIGURATIONS)
if ((uint8_t)USB_ControlRequest.wValue > FIXED_NUM_CONFIGURATIONS)
return;
@@ -195,18 +193,11 @@ static void USB_Device_SetConfiguration(void) Endpoint_ClearIN();
if (USB_ConfigurationNumber)
- {
- USB_DeviceState = DEVICE_STATE_Configured;
-
- if (!(AlreadyConfigured))
- EVENT_USB_DeviceEnumerationComplete();
- }
+ USB_DeviceState = DEVICE_STATE_Configured;
else
- {
- USB_DeviceState = DEVICE_STATE_Addressed;
- }
+ USB_DeviceState = DEVICE_STATE_Addressed;
- EVENT_USB_ConfigurationChanged();
+ EVENT_USB_Device_ConfigurationChanged();
}
void USB_Device_GetConfiguration(void)
diff --git a/LUFA/Drivers/USB/LowLevel/DevChapter9.h b/LUFA/Drivers/USB/LowLevel/DevChapter9.h index a70dd066e..e6baca2be 100644 --- a/LUFA/Drivers/USB/LowLevel/DevChapter9.h +++ b/LUFA/Drivers/USB/LowLevel/DevChapter9.h @@ -113,7 +113,7 @@ #endif
/* Function Prototypes: */
- void USB_Device_ProcessControlPacket(void);
+ void USB_Device_ProcessControlRequest(void);
#if defined(INCLUDE_FROM_DEVCHAPTER9_C)
static void USB_Device_SetAddress(void);
diff --git a/LUFA/Drivers/USB/LowLevel/Host.c b/LUFA/Drivers/USB/LowLevel/Host.c index 3d99b2594..8a51ae5bf 100644 --- a/LUFA/Drivers/USB/LowLevel/Host.c +++ b/LUFA/Drivers/USB/LowLevel/Host.c @@ -92,8 +92,6 @@ void USB_Host_ProcessNextHostState(void) USB_INT_Clear(USB_INT_VBERRI);
USB_INT_Enable(USB_INT_VBERRI);
-
- EVENT_USB_Connect();
USB_Host_ResumeBus();
Pipe_ClearPipes();
@@ -185,19 +183,18 @@ void USB_Host_ProcessNextHostState(void) case HOST_STATE_Default_PostAddressSet:
USB_Host_SetDeviceAddress(USB_HOST_DEVICEADDRESS);
- EVENT_USB_DeviceEnumerationComplete();
+ EVENT_USB_Host_DeviceEnumerationComplete();
USB_HostState = HOST_STATE_Addressed;
break;
}
if ((ErrorCode != HOST_ENUMERROR_NoError) && (USB_HostState != HOST_STATE_Unattached))
{
- EVENT_USB_DeviceEnumerationFailed(ErrorCode, SubErrorCode);
+ EVENT_USB_Host_DeviceEnumerationFailed(ErrorCode, SubErrorCode);
USB_Host_VBUS_Auto_Off();
- EVENT_USB_DeviceUnattached();
- EVENT_USB_Disconnect();
+ EVENT_USB_Host_DeviceUnattached();
USB_ResetInterface();
}
diff --git a/LUFA/Drivers/USB/LowLevel/Host.h b/LUFA/Drivers/USB/LowLevel/Host.h index a602cee77..50912ad7d 100644 --- a/LUFA/Drivers/USB/LowLevel/Host.h +++ b/LUFA/Drivers/USB/LowLevel/Host.h @@ -312,7 +312,7 @@ */
};
- /** Enum for the error codes for the \ref EVENT_USB_HostError() event.
+ /** Enum for the error codes for the \ref EVENT_USB_Host_HostError() event.
*
* \see \ref Group_Events for more information on this event.
*/
@@ -326,14 +326,14 @@ */
};
- /** Enum for the error codes for the \ref EVENT_USB_DeviceEnumerationFailed() event.
+ /** Enum for the error codes for the \ref EVENT_USB_Host_DeviceEnumerationFailed() event.
*
* \see \ref Group_Events for more information on this event.
*/
enum USB_Host_EnumerationErrorCodes_t
{
HOST_ENUMERROR_NoError = 0, /**< No error occurred. Used internally, this is not a valid
- * ErrorCode parameter value for the \ref EVENT_USB_DeviceEnumerationFailed()
+ * ErrorCode parameter value for the \ref EVENT_USB_Host_DeviceEnumerationFailed()
* event.
*/
HOST_ENUMERROR_WaitStage = 1, /**< One of the delays between enumeration steps failed
diff --git a/LUFA/Drivers/USB/LowLevel/LowLevel.c b/LUFA/Drivers/USB/LowLevel/LowLevel.c index 3ad1e9830..e6791098a 100644 --- a/LUFA/Drivers/USB/LowLevel/LowLevel.c +++ b/LUFA/Drivers/USB/LowLevel/LowLevel.c @@ -108,16 +108,6 @@ void USB_Init( void USB_ShutDown(void)
{
- #if defined(USB_CAN_BE_DEVICE)
- if (USB_DeviceState != DEVICE_STATE_Unattached)
- EVENT_USB_Disconnect();
- #endif
-
- #if defined(USB_CAN_BE_HOST)
- if (USB_HostState != HOST_STATE_Unattached)
- EVENT_USB_Disconnect();
- #endif
-
USB_ResetInterface();
USB_Detach();
USB_Controller_Disable();
@@ -191,8 +181,6 @@ void USB_ResetInterface(void) USB_Device_SetLowSpeed();
else
USB_Device_SetFullSpeed();
-
- USB_INT_Enable(USB_INT_VBUS);
}
#endif
@@ -204,11 +192,11 @@ void USB_ResetInterface(void) if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr) != NO_DESCRIPTOR)
{
#if defined(USE_RAM_DESCRIPTORS)
- USB_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size;
+ USB_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size;
#elif defined(USE_EEPROM_DESCRIPTORS)
- USB_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size);
+ USB_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size);
#else
- USB_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size);
+ USB_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size);
#endif
}
}
@@ -216,13 +204,19 @@ void USB_ResetInterface(void) USB_Attach();
- #if defined(USB_DEVICE_ONLY)
+ #if defined(USB_DEVICE_ONLY)
+ USB_INT_Clear(USB_INT_SUSPEND);
USB_INT_Enable(USB_INT_SUSPEND);
+ USB_INT_Clear(USB_INT_EORSTI);
USB_INT_Enable(USB_INT_EORSTI);
- #if defined(CONTROL_ONLY_DEVICE)
- UENUM = ENDPOINT_CONTROLEP;
- #endif
-
+
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
+ USB_INT_Enable(USB_INT_VBUS);
+ #endif
+
+ #if defined(CONTROL_ONLY_DEVICE)
+ UENUM = ENDPOINT_CONTROLEP;
+ #endif
#elif defined(USB_HOST_ONLY)
USB_Host_HostMode_On();
@@ -237,9 +231,15 @@ void USB_ResetInterface(void) #else
if (USB_CurrentMode == USB_MODE_DEVICE)
{
+ USB_INT_Clear(USB_INT_SUSPEND);
USB_INT_Enable(USB_INT_SUSPEND);
+ USB_INT_Clear(USB_INT_EORSTI);
USB_INT_Enable(USB_INT_EORSTI);
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
+ USB_INT_Enable(USB_INT_VBUS);
+ #endif
+
#if defined(CONTROL_ONLY_DEVICE)
UENUM = ENDPOINT_CONTROLEP;
#endif
diff --git a/LUFA/Drivers/USB/LowLevel/LowLevel.h b/LUFA/Drivers/USB/LowLevel/LowLevel.h index 1ca54ed9d..b8f7b9de1 100644 --- a/LUFA/Drivers/USB/LowLevel/LowLevel.h +++ b/LUFA/Drivers/USB/LowLevel/LowLevel.h @@ -191,7 +191,7 @@ #endif
/** Detaches the device from the USB bus. This has the effect of removing the device from any
- * host if, ceasing USB communications. If no host is present, this prevents any host from
+ * attached host, ceasing USB communications. If no host is present, this prevents any host from
* enumerating the device once attached until \ref USB_Attach() is called.
*/
#define USB_Detach() MACROS{ UDCON |= (1 << DETACH); }MACROE
@@ -342,7 +342,7 @@ #define USB_Controller_Enable() MACROS{ USBCON |= (1 << USBE); }MACROE
#define USB_Controller_Disable() MACROS{ USBCON &= ~(1 << USBE); }MACROE
- #define USB_Controller_Reset() MACROS{ uint8_t Temp = USBCON; USBCON = (Temp & ~(1 << USBE)); \
+ #define USB_Controller_Reset() MACROS{ const uint8_t Temp = USBCON; USBCON = (Temp & ~(1 << USBE)); \
USBCON = (Temp | (1 << USBE)); }MACROE
/* Inline Functions: */
|