Make device mode configure the control endpoint even before the bus has been reset, so that the device will enumerate correctly on hosts that do not reset the device before initial use.

pull/1469/head
Dean Camera 14 years ago
parent b17e87d140
commit d66a925786

@ -60,6 +60,11 @@ void USB_Init(
USB_Options = Options; USB_Options = Options;
#endif #endif
if (!(USB_Options & USB_OPT_REG_DISABLED))
USB_REG_On();
else
USB_REG_Off();
#if defined(USB_CAN_BE_BOTH) #if defined(USB_CAN_BE_BOTH)
if (Mode == USB_MODE_UID) if (Mode == USB_MODE_UID)
{ {
@ -113,11 +118,6 @@ void USB_ResetInterface(void)
USB_Controller_Reset(); USB_Controller_Reset();
if (!(USB_Options & USB_OPT_REG_DISABLED))
USB_REG_On();
else
USB_REG_Off();
if (!(USB_Options & USB_OPT_MANUAL_PLL)) if (!(USB_Options & USB_OPT_MANUAL_PLL))
{ {
#if defined(USB_SERIES_4_AVR) #if defined(USB_SERIES_4_AVR)
@ -128,8 +128,6 @@ void USB_ResetInterface(void)
while (!(USB_PLL_IsReady())); while (!(USB_PLL_IsReady()));
} }
USB_CLK_Unfreeze();
#if defined(USB_CAN_BE_BOTH) #if defined(USB_CAN_BE_BOTH)
if (UIDModeSelectEnabled) if (UIDModeSelectEnabled)
{ {
@ -138,6 +136,8 @@ void USB_ResetInterface(void)
} }
#endif #endif
USB_CLK_Unfreeze();
if (USB_CurrentMode == USB_MODE_DEVICE) if (USB_CurrentMode == USB_MODE_DEVICE)
{ {
#if defined(USB_CAN_BE_DEVICE) #if defined(USB_CAN_BE_DEVICE)
@ -159,8 +159,6 @@ void USB_ResetInterface(void)
#if (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) #if (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
USB_OTGPAD_On(); USB_OTGPAD_On();
#endif #endif
USB_Attach();
} }
#if defined(USB_CAN_BE_DEVICE) #if defined(USB_CAN_BE_DEVICE)
@ -201,10 +199,14 @@ static void USB_Init_Device(void)
USB_INT_Enable(USB_INT_VBUS); USB_INT_Enable(USB_INT_VBUS);
#endif #endif
USB_INT_Clear(USB_INT_SUSPEND); Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL,
ENDPOINT_DIR_OUT, USB_ControlEndpointSize,
ENDPOINT_BANK_SINGLE);
USB_INT_Enable(USB_INT_SUSPEND); USB_INT_Enable(USB_INT_SUSPEND);
USB_INT_Clear(USB_INT_EORSTI);
USB_INT_Enable(USB_INT_EORSTI); USB_INT_Enable(USB_INT_EORSTI);
USB_Attach();
} }
#endif #endif

Loading…
Cancel
Save