From cce8760b9169dffe1a126e221f4b4c48c83192b9 Mon Sep 17 00:00:00 2001
From: Dean Camera <dean@fourwalledcubicle.com>
Date: Wed, 15 Sep 2010 13:11:28 +0000
Subject: [PATCH] Removed the EVENT_USB_InitFailure() event, as not specifying
 a USB mode to USB_Init() now defaults the controller into UID selection mode.

---
 LUFA/Drivers/USB/HighLevel/Events.h       | 10 ----------
 LUFA/Drivers/USB/LowLevel/USBController.c | 14 ++------------
 LUFA/Drivers/USB/LowLevel/USBController.h | 11 -----------
 LUFA/Drivers/USB/LowLevel/USBInterrupt.c  |  2 --
 LUFA/ManPages/ChangeLog.txt               |  1 +
 LUFA/ManPages/MigrationInformation.txt    |  2 ++
 6 files changed, 5 insertions(+), 35 deletions(-)

diff --git a/LUFA/Drivers/USB/HighLevel/Events.h b/LUFA/Drivers/USB/HighLevel/Events.h
index ae7debbb7..f1d6f0316 100644
--- a/LUFA/Drivers/USB/HighLevel/Events.h
+++ b/LUFA/Drivers/USB/HighLevel/Events.h
@@ -87,15 +87,6 @@
 	/* Public Interface - May be used in end-application: */			
 		/* Pseudo-Functions for Doxygen: */
 		#if !defined(__INCLUDE_FROM_EVENTS_C) || defined(__DOXYGEN__)
-			/** Event for USB stack initialization failure. This event fires when the USB interface fails to
-			 *  initialize correctly due to a hardware or software fault.
-			 *
-			 *  \note This event only exists on USB AVR models which support dual role modes.
-			 *
-			 *  \param[in] ErrorCode  Error code indicating the failure reason, a value in \ref USB_InitErrorCodes_t.
-			 */
-			void EVENT_USB_InitFailure(const uint8_t ErrorCode);
-
 			/** Event for USB mode pin level change. This event fires when the USB interface is set to dual role
 			 *  mode, and the UID pin level has changed to indicate a new mode (device or host). This event fires
 			 *  before the mode is switched to the newly indicated mode but after the \ref EVENT_USB_Device_Disconnect
@@ -344,7 +335,6 @@
 				void USB_Event_Stub(void) ATTR_CONST;
 					
 				#if defined(USB_CAN_BE_BOTH)
-					void EVENT_USB_InitFailure(const uint8_t ErrorCode) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
 					void EVENT_USB_UIDChange(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
 				#endif
 				
diff --git a/LUFA/Drivers/USB/LowLevel/USBController.c b/LUFA/Drivers/USB/LowLevel/USBController.c
index 7488a3003..fe6248216 100644
--- a/LUFA/Drivers/USB/LowLevel/USBController.c
+++ b/LUFA/Drivers/USB/LowLevel/USBController.c
@@ -72,16 +72,7 @@ void USB_Init(
 	#elif defined(USB_HOST_ONLY)
 	UHWCON &= ~(1 << UIMOD);
 	#elif defined(USB_CAN_BE_BOTH)
-	if (Mode == USB_MODE_UID)
-	{
-		UHWCON |=  (1 << UIDE);
-
-		USB_INT_Clear(USB_INT_IDTI);
-		USB_INT_Enable(USB_INT_IDTI);
-		
-		USB_CurrentMode = USB_GetUSBModeFromUID();
-	}
-	else if (Mode == USB_MODE_DEVICE)
+	if (Mode == USB_MODE_DEVICE)
 	{
 		UHWCON |=  (1 << UIMOD);
 	}
@@ -91,8 +82,7 @@ void USB_Init(
 	}
 	else
 	{
-		EVENT_USB_InitFailure(USB_INITERROR_NoUSBModeSpecified);
-		return;
+		UHWCON |=  (1 << UIDE);
 	}
 	#endif
 	
diff --git a/LUFA/Drivers/USB/LowLevel/USBController.h b/LUFA/Drivers/USB/LowLevel/USBController.h
index 980f818d4..8fdb24cba 100644
--- a/LUFA/Drivers/USB/LowLevel/USBController.h
+++ b/LUFA/Drivers/USB/LowLevel/USBController.h
@@ -317,17 +317,6 @@
 			 */
 			void USB_ResetInterface(void);
 
-		/* Enums: */
-			/** Enum for error codes relating to the powering on of the USB interface. These error codes are
-			 *  used in the ErrorCode parameter value of the \ref EVENT_USB_InitFailure() event.
-			 */
-			enum USB_InitErrorCodes_t
-			{
-				USB_INITERROR_NoUSBModeSpecified       = 0, /**< Indicates that \ref USB_Init() was called with an
-				                                             *   invalid or missing Mode parameter.
-				                                             */
-			};
-
 		/* Global Variables: */
 			#if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY)) || defined(__DOXYGEN__)
 				/** Indicates the mode that the USB interface is currently initialized to. This value will be
diff --git a/LUFA/Drivers/USB/LowLevel/USBInterrupt.c b/LUFA/Drivers/USB/LowLevel/USBInterrupt.c
index 36541cf7f..a49b8da7b 100644
--- a/LUFA/Drivers/USB/LowLevel/USBInterrupt.c
+++ b/LUFA/Drivers/USB/LowLevel/USBInterrupt.c
@@ -142,8 +142,6 @@ ISR(USB_GEN_vect, ISR_BLOCK)
 		USB_INT_Disable(USB_INT_SUSPEND);
 		USB_INT_Enable(USB_INT_WAKEUP);
 
-		Endpoint_ClearEndpoints();
-
 		Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL,
 		                           ENDPOINT_DIR_OUT, USB_ControlEndpointSize,
 		                           ENDPOINT_BANK_SINGLE);
diff --git a/LUFA/ManPages/ChangeLog.txt b/LUFA/ManPages/ChangeLog.txt
index 704f93e28..7fc73e9f2 100644
--- a/LUFA/ManPages/ChangeLog.txt
+++ b/LUFA/ManPages/ChangeLog.txt
@@ -41,6 +41,7 @@
   *  - Changed over all demos, drivers and internal functions to use the current frame number over the Start of Frame flag where possible
   *    to free up the Start of Frame flag for interrupt use in the user application
   *  - All project makefiles now correctly clean intermediate build files from assembly and C++ sources (thanks to Daniel Czigany)
+  *  - Removed the EVENT_USB_InitFailure() event, not specifying a USB mode now defaults to UID selection mode
   *
   *  <b>Fixed:</b>
   *  - Fixed USB_GetHIDReportItemInfo() function modifying the given report item's data when the report item does not exist
diff --git a/LUFA/ManPages/MigrationInformation.txt b/LUFA/ManPages/MigrationInformation.txt
index c0efcbdc6..414a4a31e 100644
--- a/LUFA/ManPages/MigrationInformation.txt
+++ b/LUFA/ManPages/MigrationInformation.txt
@@ -17,6 +17,8 @@
  *      variables.
  *    - A new USB driver source file, Drivers/USB/HighLevel/PipeStream.c now exists. This source file should be added to all
  *      project makefiles using the USB driver of LUFA, or the makefile should be updated to use the new module source variables.
+ *    - The EVENT_USB_InitFailure() event has been removed, as the USB_Init() function will no longer fail; if not USB mode is
+ *      specified, the controller will default to UID selection mode.
  *
  *  <b>Device Mode</b>
  *    - The signature for the CALLBACK_USB_GetDescriptor() callback has changed, the "void** const DescriptorAddress" parameter is
-- 
GitLab