diff options
author | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2012-01-26 19:37:34 +0000 |
---|---|---|
committer | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2012-01-26 19:37:34 +0000 |
commit | 804205a104bc65f3706c145c7d14e532af804dc7 (patch) | |
tree | 2fc58107b64208c80f0dc1235f5fdeed8d18a17d /nuttx/drivers | |
parent | 7bf58dba528b747678242fabc62d7787f8002869 (diff) | |
download | px4-firmware-804205a104bc65f3706c145c7d14e532af804dc7.tar.gz px4-firmware-804205a104bc65f3706c145c7d14e532af804dc7.tar.bz2 px4-firmware-804205a104bc65f3706c145c7d14e532af804dc7.zip |
More USB composite device logic
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4340 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx/drivers')
-rw-r--r-- | nuttx/drivers/usbdev/cdcacm.c | 1 | ||||
-rw-r--r-- | nuttx/drivers/usbdev/composite.c | 72 | ||||
-rw-r--r-- | nuttx/drivers/usbdev/composite.h | 28 | ||||
-rw-r--r-- | nuttx/drivers/usbdev/usbmsc.c | 1 |
4 files changed, 70 insertions, 32 deletions
diff --git a/nuttx/drivers/usbdev/cdcacm.c b/nuttx/drivers/usbdev/cdcacm.c index 4023d2f2d..530572408 100644 --- a/nuttx/drivers/usbdev/cdcacm.c +++ b/nuttx/drivers/usbdev/cdcacm.c @@ -64,6 +64,7 @@ #include "cdcacm.h" #ifdef CONFIG_USBMSC_COMPOSITE +# include <nuttx/composite.h> # include "composite.h" #endif diff --git a/nuttx/drivers/usbdev/composite.c b/nuttx/drivers/usbdev/composite.c index c689f1b66..69313f821 100644 --- a/nuttx/drivers/usbdev/composite.c +++ b/nuttx/drivers/usbdev/composite.c @@ -743,18 +743,25 @@ static void composite_resume(FAR struct usbdevclass_driver_s *driver, * Name: composite_initialize * * Description: - * Register USB composite port (and USB composite console if so configured). + * Register USB composite device as configured. This function will call + * board-specific implementations in order to obtain the class objects for + * each of the members of the composite (see board_mscclassobject(), + * board_cdcclassobjec(), ...) * * Input Parameter: - * Device minor number. E.g., minor 0 would correspond to /dev/ttyUSB0. + * None * * Returned Value: - * Zero (OK) means that the driver was successfully registered. On any - * failure, a negated errno value is retured. + * A non-NULL "handle" is returned on success. This handle may be used + * later with composite_uninitialize() in order to removed the composite + * device. This handle is the (untyped) internal representation of the + * the class driver instance. + * + * NULL is returned on any failure. * ****************************************************************************/ -int composite_initialize(int minor) +FAR void *composite_initialize(void) { FAR struct composite_alloc_s *alloc; FAR struct composite_dev_s *priv; @@ -767,7 +774,7 @@ int composite_initialize(int minor) if (!alloc) { usbtrace(TRACE_CLSERROR(USBCOMPOSITE_TRACEERR_ALLOCDEVSTRUCT), 0); - return -ENOMEM; + return NULL; } /* Convenience pointers into the allocated blob */ @@ -814,11 +821,60 @@ int composite_initialize(int minor) goto errout_with_alloc; } - return OK; + return (FAR void *)priv; errout_with_alloc: kfree(alloc); - return ret; + return NULL; +} + +/**************************************************************************** + * Name: usbmsc_uninitialize + * + * Description: + * Un-initialize the USB composite driver. The handle is the USB composite + * class' device object as was returned by composite_initialize(). This + * function will call board-specific implementations in order to free the + * class objects for each of the members of the composite (see + * board_mscuninitialize(), board_cdcuninitialize(), ...) + * + * Input Parameters: + * handle - The handle returned by a previous call to composite_initialize(). + * + * Returned Value: + * None + * + ***************************************************************************/ + +void usbmsc_uninitialize(FAR void *handle) +{ + FAR struct composite_dev_s *priv = (FAR struct composite_dev_s *)handle; + + DEBUGASSERT(priv != NULL); + + /* Uninitialize each of the member classes */ + + if (priv->dev1) + { + DEV1_UNINITIALIZE(priv->dev1); + priv->dev1 = NULL; + } + + if (priv->dev2) + { + DEV1_UNINITIALIZE(priv->dev2); + priv->dev2 = NULL; + } + + /* Then unregister and destroy the composite class */ + + usbdev_unregister(&priv->drvr.drvr); + + /* Free any resources used by the composite driver */ + + /* Then free the composite driver state structure itself */ + + kfree(priv); } /**************************************************************************** diff --git a/nuttx/drivers/usbdev/composite.h b/nuttx/drivers/usbdev/composite.h index 4cd3ac606..2e8476500 100644 --- a/nuttx/drivers/usbdev/composite.h +++ b/nuttx/drivers/usbdev/composite.h @@ -63,15 +63,6 @@ * Pre-processor Definitions ****************************************************************************/ /* Configuration ************************************************************/ - -#ifndef CONFIG_USBDEV_TRACE_NRECORDS -# define CONFIG_USBDEV_TRACE_NRECORDS 128 -#endif - -#ifndef CONFIG_USBDEV_TRACE_INITIALIDSET -# define CONFIG_USBDEV_TRACE_INITIALIDSET 0 -#endif - /* Packet sizes */ #ifndef CONFIG_COMPOSITE_EP0MAXPACKET @@ -128,6 +119,7 @@ # define DEV1_IS_CDCACM 1 # define DEV1_MKCFGDESC cdcacm_mkcfgdesc # define DEV1_CLASSOBJECT board_cdcclassobject +# define DEV1_UNINITIALIZE board_cdcuninitialize # define DEV1_NCONFIGS CDCACM_NCONFIGS # define DEV1_CONFIGID CDCACM_CONFIGID # define DEV1_FIRSTINTERFACE CONFIG_CDCACM_IFNOBASE @@ -139,6 +131,7 @@ # define DEV1_IS_USBMSC 1 # define DEV1_MKCFGDESC usbmsc_mkcfgdesc # define DEV1_CLASSOBJECT board_mscclassobject +# define DEV1_UNINITIALIZE board_mscuninitialize # define DEV1_NCONFIGS USBMSC_NCONFIGS # define DEV1_CONFIGID USBMSC_CONFIGID # define DEV1_FIRSTINTERFACE CONFIG_USBMSC_IFNOBASE @@ -158,6 +151,7 @@ # define DEV2_IS_CDCACM 1 # define DEV2_MKCFGDESC cdcacm_mkcfgdesc # define DEV2_CLASSOBJECT board_cdcclassobject +# define DEV2_UNINITIALIZE board_cdcuninitialize # define DEV2_NCONFIGS CDCACM_NCONFIGS # define DEV2_CONFIGID CDCACM_CONFIGID # define DEV2_FIRSTINTERFACE CONFIG_CDCACM_IFNOBASE @@ -168,6 +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_CLASSOBJECT board_mscclassobject # define DEV2_NCONFIGS USBMSC_NCONFIGS # define DEV2_CONFIGID USBMSC_CONFIGID @@ -253,21 +248,6 @@ extern const char g_compserialstr[]; ****************************************************************************/ /**************************************************************************** - * Name: composite_ep0submit - * - * Description: - * Members of the composite cannot send on EP0 directly because EP0 is - * is "owned" by the composite device. Instead, when configured as members - * of a composite device, those classes should call this method so that - * the composite device can send on EP0 onbehalf of the class. - * - ****************************************************************************/ - -int composite_ep0submit(FAR struct usbdevclass_driver_s *driver, - FAR struct usbdev_s *dev, - FAR struct usbdev_req_s *ctrlreq); - -/**************************************************************************** * Name: composite_mkstrdesc * * Description: diff --git a/nuttx/drivers/usbdev/usbmsc.c b/nuttx/drivers/usbdev/usbmsc.c index 3efa1e3db..a264ab232 100644 --- a/nuttx/drivers/usbdev/usbmsc.c +++ b/nuttx/drivers/usbdev/usbmsc.c @@ -83,6 +83,7 @@ #include "usbmsc.h" #ifdef CONFIG_USBMSC_COMPOSITE +# include <nuttx/composite.h> # include "composite.h" #endif |