aboutsummaryrefslogtreecommitdiff
path: root/nuttx/drivers/usbdev
diff options
context:
space:
mode:
authorpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-01-26 23:14:27 +0000
committerpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-01-26 23:14:27 +0000
commitcd24ef4a3026c7201e5332d4f905bdddad76051e (patch)
tree4bd1111e23d7cdb1b43685aa7f699c694f7c8d7f /nuttx/drivers/usbdev
parent804205a104bc65f3706c145c7d14e532af804dc7 (diff)
downloadpx4-firmware-cd24ef4a3026c7201e5332d4f905bdddad76051e.tar.gz
px4-firmware-cd24ef4a3026c7201e5332d4f905bdddad76051e.tar.bz2
px4-firmware-cd24ef4a3026c7201e5332d4f905bdddad76051e.zip
Add a text for the new composite USB device
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4341 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx/drivers/usbdev')
-rw-r--r--nuttx/drivers/usbdev/cdcacm.c4
-rw-r--r--nuttx/drivers/usbdev/composite.c19
-rw-r--r--nuttx/drivers/usbdev/composite.h4
-rw-r--r--nuttx/drivers/usbdev/usbmsc.c48
4 files changed, 62 insertions, 13 deletions
diff --git a/nuttx/drivers/usbdev/cdcacm.c b/nuttx/drivers/usbdev/cdcacm.c
index 530572408..d34728a4b 100644
--- a/nuttx/drivers/usbdev/cdcacm.c
+++ b/nuttx/drivers/usbdev/cdcacm.c
@@ -64,7 +64,7 @@
#include "cdcacm.h"
#ifdef CONFIG_USBMSC_COMPOSITE
-# include <nuttx/composite.h>
+# include <nuttx/usb/composite.h>
# include "composite.h"
#endif
@@ -2116,7 +2116,7 @@ int cdcacm_initialize(int minor)
*
****************************************************************************/
-#ifndef CONFIG_CDCACM_COMPOSITE
+#ifdef CONFIG_CDCACM_COMPOSITE
void cdcacm_uninitialize(FAR struct usbdevclass_driver_s *classdev)
{
FAR struct cdcacm_driver_s *drvr = (FAR struct cdcacm_driver_s *)classdev;
diff --git a/nuttx/drivers/usbdev/composite.c b/nuttx/drivers/usbdev/composite.c
index 69313f821..2ca583a0b 100644
--- a/nuttx/drivers/usbdev/composite.c
+++ b/nuttx/drivers/usbdev/composite.c
@@ -108,7 +108,7 @@ static void composite_freereq(FAR struct usbdev_ep_s *ep,
/* USB class device ********************************************************/
static int composite_bind(FAR struct usbdevclass_driver_s *driver,
- FAR struct usbdev_s *dev)
+ FAR struct usbdev_s *dev);
static void composite_unbind(FAR struct usbdevclass_driver_s *driver,
FAR struct usbdev_s *dev);
static int composite_setup(FAR struct usbdevclass_driver_s *driver,
@@ -319,7 +319,7 @@ static int composite_bind(FAR struct usbdevclass_driver_s *driver,
return OK;
errout:
- composite_unbind(dev);
+ composite_unbind(driver, dev);
return ret;
}
@@ -821,7 +821,7 @@ FAR void *composite_initialize(void)
goto errout_with_alloc;
}
- return (FAR void *)priv;
+ return (FAR void *)alloc;
errout_with_alloc:
kfree(alloc);
@@ -829,7 +829,7 @@ errout_with_alloc:
}
/****************************************************************************
- * Name: usbmsc_uninitialize
+ * Name: composite_uninitialize
*
* Description:
* Un-initialize the USB composite driver. The handle is the USB composite
@@ -846,14 +846,16 @@ errout_with_alloc:
*
***************************************************************************/
-void usbmsc_uninitialize(FAR void *handle)
+void composite_uninitialize(FAR void *handle)
{
- FAR struct composite_dev_s *priv = (FAR struct composite_dev_s *)handle;
+ FAR struct composite_alloc_s *alloc = (FAR struct composite_alloc_s *)handle;
+ FAR struct composite_dev_s *priv;
- DEBUGASSERT(priv != NULL);
+ DEBUGASSERT(alloc != NULL);
/* Uninitialize each of the member classes */
+ priv = &alloc->dev;
if (priv->dev1)
{
DEV1_UNINITIALIZE(priv->dev1);
@@ -868,9 +870,10 @@ void usbmsc_uninitialize(FAR void *handle)
/* Then unregister and destroy the composite class */
- usbdev_unregister(&priv->drvr.drvr);
+ usbdev_unregister(&alloc->drvr.drvr);
/* Free any resources used by the composite driver */
+ /* None */
/* Then free the composite driver state structure itself */
diff --git a/nuttx/drivers/usbdev/composite.h b/nuttx/drivers/usbdev/composite.h
index 2e8476500..f1f624c1c 100644
--- a/nuttx/drivers/usbdev/composite.h
+++ b/nuttx/drivers/usbdev/composite.h
@@ -162,7 +162,7 @@
#elif defined(CONFIG_CDCACM_COMPOSITE) && !defined(DEV1_IS_USBMSC)
# define DEV2_IS_USBMSC 1
# define DEV2_MKCFGDESC usbmsc_mkcfgdesc
-# define DEV1_UNINITIALIZE board_mscuninitialize
+# define DEV2_UNINITIALIZE board_mscuninitialize
# define DEV2_CLASSOBJECT board_mscclassobject
# define DEV2_NCONFIGS USBMSC_NCONFIGS
# define DEV2_CONFIGID USBMSC_CONFIGID
@@ -181,7 +181,7 @@
# warning "The first interface number should be zero"
#endif
-#if (DEV1_FIRSTINTERFACE + DEV2_NINTERFACES) != DEV2_FIRSTINTERFACE
+#if (DEV1_FIRSTINTERFACE + DEV1_NINTERFACES) != DEV2_FIRSTINTERFACE
# warning "Interface numbers are not contiguous"
#endif
diff --git a/nuttx/drivers/usbdev/usbmsc.c b/nuttx/drivers/usbdev/usbmsc.c
index a264ab232..0c444c156 100644
--- a/nuttx/drivers/usbdev/usbmsc.c
+++ b/nuttx/drivers/usbdev/usbmsc.c
@@ -83,7 +83,7 @@
#include "usbmsc.h"
#ifdef CONFIG_USBMSC_COMPOSITE
-# include <nuttx/composite.h>
+# include <nuttx/usb/composite.h>
# include "composite.h"
#endif
@@ -139,6 +139,9 @@ static void usbmsc_disconnect(FAR struct usbdevclass_driver_s *driver,
/* Initialization/Uninitialization ******************************************/
static void usbmsc_lununinitialize(struct usbmsc_lun_s *lun);
+#ifndef CONFIG_USBMSC_COMPOSITE
+static int usbmsc_exportluns(FAR void *handle);
+#endif
/****************************************************************************
* Private Data
@@ -1571,6 +1574,9 @@ int usbmsc_unbindlun(FAR void *handle, unsigned int lunno)
*
****************************************************************************/
+#ifndef CONFIG_USBMSC_COMPOSITE
+static
+#endif
int usbmsc_exportluns(FAR void *handle)
{
FAR struct usbmsc_alloc_s *alloc = (FAR struct usbmsc_alloc_s *)handle;
@@ -1635,6 +1641,46 @@ errout_with_mutex:
}
/****************************************************************************
+ * Name: usbmsc_classobject
+ *
+ * Description:
+ * Register USB mass storage device and return the class object.
+ *
+ * Input Parameters:
+ * classdev - The location to return the CDC serial class' device
+ * instance.
+ *
+ * Returned Value:
+ * 0 on success; a negated errno on failure
+
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_USBMSC_COMPOSITE
+int usbmsc_classobject(FAR void *handle,
+ FAR struct usbdevclass_driver_s **classdev)
+{
+ int ret;
+
+ DEBUGASSERT(handle && classdev);
+
+ /* Export the LUNs as with the "standalone" USB mass storage driver, but
+ * don't register the class instance with the USB device infrastructure.
+ */
+
+ ret = usbmsc_exportluns(handle);
+ if (ret == OK)
+ {
+ /* On sucess, return an (typed) instance of the class instance */
+
+ *classdev = (FAR struct usbdevclass_driver_s *)
+ &((FAR struct usbmsc_alloc_s *)handle)->dev;
+ }
+ return ret;
+}
+#endif
+
+/****************************************************************************
* Name: usbmsc_uninitialize
*
* Description: