mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 05:53:34 +08:00
More USB composite device logic
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4340 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
@@ -64,6 +64,7 @@
|
||||
#include "cdcacm.h"
|
||||
|
||||
#ifdef CONFIG_USBMSC_COMPOSITE
|
||||
# include <nuttx/composite.h>
|
||||
# include "composite.h"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -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
|
||||
@@ -252,21 +247,6 @@ extern const char g_compserialstr[];
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* 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
|
||||
*
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
#include "usbmsc.h"
|
||||
|
||||
#ifdef CONFIG_USBMSC_COMPOSITE
|
||||
# include <nuttx/composite.h>
|
||||
# include "composite.h"
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user