From 0676572c28d08f71204ecb2846c35b4a0bec5f4b Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 2 Feb 2012 04:35:35 +0000 Subject: [PATCH] Add David Hewson's corrections to the LPC214x USB device driver; Add LPC214x configuration to test the USB composite device git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4359 42af7a65-404d-4744-a932-0658087f49c3 --- arch/arm/src/lpc214x/lpc214x_usbdev.c | 37 +++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/arch/arm/src/lpc214x/lpc214x_usbdev.c b/arch/arm/src/lpc214x/lpc214x_usbdev.c index 1c2b315489..a74ac70385 100644 --- a/arch/arm/src/lpc214x/lpc214x_usbdev.c +++ b/arch/arm/src/lpc214x/lpc214x_usbdev.c @@ -1,8 +1,8 @@ /******************************************************************************* * arch/arm/src/lpc214x/lpc214x_usbdev.c * - * Copyright (C) 2008-2010 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2008-2010, 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -1393,6 +1393,8 @@ static inline void lpc214x_dmareset(uint32_t enable) static void lpc214x_usbreset(struct lpc214x_usbdev_s *priv) { + int epphy; + /* Disable all endpoint interrupts */ lpc214x_putreg(0, LPC214X_USBDEV_EPINTEN); @@ -1410,6 +1412,28 @@ static void lpc214x_usbreset(struct lpc214x_usbdev_s *priv) priv->paddrset = 0; + /* Reset endpoints */ + + for (epphy = 0; epphy < LPC214X_NPHYSENDPOINTS; epphy++) + { + struct lpc214x_ep_s *privep = &priv->eplist[epphy]; + + lpc214x_cancelrequests(privep); + + /* Reset endpoint status */ + + privep->stalled = false; + } + + /* Tell the class driver that we are disconnected. The class + * driver should then accept any new configurations. + */ + + if (priv->driver) + { + CLASS_DISCONNECT(priv->driver, &priv->usbdev); + } + /* Endpoints not yet configured */ lpc214x_usbcmd(CMD_USB_DEV_CONFIG, 0); @@ -1418,13 +1442,12 @@ static void lpc214x_usbreset(struct lpc214x_usbdev_s *priv) lpc214x_ep0configure(priv); -#ifdef CONFIG_LPC214X_USBDEV_DMA /* Enable End_of_Transfer_Interrupt and System_Error_Interrupt USB DMA * interrupts */ +#ifdef CONFIG_LPC214X_USBDEV_DMA lpc214x_dmareset(CONFIG_LPC214X_USBDEV_DMAINTMASK); - #endif /* Enable Device interrupts */ @@ -1839,7 +1862,9 @@ static inline void lpc214x_ep0setup(struct lpc214x_usbdev_s *priv) if (priv->stalled) { usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_EP0SETUPSTALLED), priv->ep0state); + ep0 = &priv->eplist[LPC214X_EP0_OUT]; lpc214x_epstall(&ep0->ep, false); + ep0 = &priv->eplist[LPC214X_EP0_IN]; lpc214x_epstall(&ep0->ep, false); } } @@ -1903,6 +1928,7 @@ static inline void lpc214x_ep0dataoutinterrupt(struct lpc214x_usbdev_s *priv) usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_EP0OUTSTALLED), priv->ep0state); ep0 = &priv->eplist[LPC214X_EP0_OUT]; lpc214x_epstall(&ep0->ep, false); + ep0 = &priv->eplist[LPC214X_EP0_IN]; lpc214x_epstall(&ep0->ep, false); } return; @@ -1968,8 +1994,9 @@ static inline void lpc214x_ep0dataininterrupt(struct lpc214x_usbdev_s *priv) if (priv->stalled) { usbtrace(TRACE_DEVERROR(LPC214X_TRACEERR_EP0INSTALLED), priv->ep0state); - ep0 = &priv->eplist[LPC214X_EP0_IN]; + ep0 = &priv->eplist[LPC214X_EP0_OUT]; lpc214x_epstall(&ep0->ep, false); + ep0 = &priv->eplist[LPC214X_EP0_IN]; lpc214x_epstall(&ep0->ep, false); } }