diff --git a/arch/avr/src/at90usb/at90usb_usbdev.c b/arch/avr/src/at90usb/at90usb_usbdev.c index deac78beb62..30223529486 100644 --- a/arch/avr/src/at90usb/at90usb_usbdev.c +++ b/arch/avr/src/at90usb/at90usb_usbdev.c @@ -2745,14 +2745,6 @@ void up_usbinitialize(void) { usbtrace(TRACE_DEVINIT, 0); - /* Shutdown the USB interface to put it in a known initial state */ - - avr_usbshutdown(); - - /* Select USB device mode */ - - UHWCON |= (1 << UIMOD); - /* Initialize the device state structure */ memset(&g_usbdev, 0, sizeof(struct avr_usbdev_s)); @@ -2760,10 +2752,6 @@ void up_usbinitialize(void) g_usbdev.usbdev.ep0 = &g_usbdev.eplist[AVR_EP0].ep; g_usbdev.epavail = AVR_ALL_EPS & ~(1 << AVR_EP0); - /* Reset the interface to force re-enumeration */ - - avr_usbreset(); - /* Attach USB controller general interrupt handler */ if (irq_attach(AT90USB_IRQ_USBGEN, avr_geninterrupt) != 0) @@ -2780,6 +2768,20 @@ void up_usbinitialize(void) goto errout; } + /* Shutdown the USB interface to put it in a known initial state */ + + avr_usbshutdown(); + + /* Select USB device mode */ + + UHWCON |= (1 << UIMOD); + + /* Reset the interface to force re-enumeration (the reset operation + * enables interrupts. + */ + + avr_usbreset(); + /* Set the VBUS pad */ USBCON |= (1 << OTGPADE);