summaryrefslogtreecommitdiff
path: root/nuttx/arch/arm/src/lpc214x
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-02-02 04:35:35 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-02-02 04:35:35 +0000
commit7c4bd65d939a6db4f855c71b54c4fbc2727086ef (patch)
tree87c1b7fdf1d545097b2d76613a9eb6bba02496f4 /nuttx/arch/arm/src/lpc214x
parent7fb190093c485279c8c89b53578bb297ab1170e2 (diff)
downloadpx4-nuttx-7c4bd65d939a6db4f855c71b54c4fbc2727086ef.tar.gz
px4-nuttx-7c4bd65d939a6db4f855c71b54c4fbc2727086ef.tar.bz2
px4-nuttx-7c4bd65d939a6db4f855c71b54c4fbc2727086ef.zip
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
Diffstat (limited to 'nuttx/arch/arm/src/lpc214x')
-rw-r--r--nuttx/arch/arm/src/lpc214x/lpc214x_usbdev.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/nuttx/arch/arm/src/lpc214x/lpc214x_usbdev.c b/nuttx/arch/arm/src/lpc214x/lpc214x_usbdev.c
index 1c2b31548..a74ac7038 100644
--- a/nuttx/arch/arm/src/lpc214x/lpc214x_usbdev.c
+++ b/nuttx/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 <spudmonkey@racsa.co.cr>
+ * Copyright (C) 2008-2010, 2012 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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);
}
}