From 05d4dd0f731d6320bc4077c34c6327fa7e9aca73 Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 3 Oct 2008 21:54:16 +0000 Subject: [PATCH] Don't enable interrupts until bound git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@976 42af7a65-404d-4744-a932-0658087f49c3 --- arch/arm/src/lpc214x/lpc214x_usbdev.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/arch/arm/src/lpc214x/lpc214x_usbdev.c b/arch/arm/src/lpc214x/lpc214x_usbdev.c index 08b12bf647..db9e1a409b 100644 --- a/arch/arm/src/lpc214x/lpc214x_usbdev.c +++ b/arch/arm/src/lpc214x/lpc214x_usbdev.c @@ -1432,14 +1432,14 @@ static inline void lpc214x_ep0setup(struct lpc214x_usbdev_s *priv) /* Read EP0 data */ - ret = lpc214x_epread(LPC214X_EP0_OUT, (ubyte*)&ctrl, sizeof(struct usb_ctrlreq_s)); + ret = lpc214x_epread(LPC214X_EP0_OUT, (ubyte*)&ctrl, USB_SIZEOF_CTRLREQ); if (ret <= 0) { return; } uvdbg("type=%02x req=%02x value=%04x index=%04x len=%04x\n", - ctrl.req, ctrl.type, + ctrl.type, ctrl.req, GETUINT16(ctrl.value), GETUINT16(ctrl.index), GETUINT16(ctrl.len)); /* Dispatch any non-standard requests */ @@ -2936,7 +2936,7 @@ void up_usbinitialize(void) usbtrace(TRACE_DEVINIT, 0); - /* Disable USB inerrupts */ + /* Disable USB interrupts */ lpc214x_putreg(0, LPC214X_USBDEV_INTST); @@ -2988,7 +2988,7 @@ void up_usbinitialize(void) reg |= LPC214X_PCONP_PCUSB; lpc214x_putreg(reg, LPC214X_PCON_PCONP); - /* Attach USB controller interrupt handler */ + /* Attach USB controller interrupt handler */ if (irq_attach(LPC214X_USB_IRQ, lpc214x_usbinterrupt) != 0) { @@ -2996,10 +2996,12 @@ void up_usbinitialize(void) goto errout; } - /* Enable USB inerrupts */ + /* Enable USB inerrupts at the controller -- but do not disable + * the ARM interrupt until the device is bound to the class + * driver + */ lpc214x_putreg(USBDEV_INTST_ENUSBINTS, LPC214X_USBDEV_INTST); - up_enable_irq(LPC214X_USB_IRQ); /* Disconnect device */ @@ -3103,6 +3105,12 @@ int usbdev_register(struct usbdevclass_driver_s *driver) usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_BINDFAILED), (uint16)-ret); g_usbdev.driver = NULL; } + else + { + /* Enable USB controller interrupts */ + + up_enable_irq(LPC214X_USB_IRQ); + } return ret; } @@ -3132,6 +3140,10 @@ int usbdev_unregister(struct usbdevclass_driver_s *driver) CLASS_UNBIND(driver, &g_usbdev.usbdev); + /* Disable USB controller interrupts */ + + up_disable_irq(LPC214X_USB_IRQ); + /* Unhook the driver */ g_usbdev.driver = NULL;