mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 08:38:38 +08:00
usbadb: add usbadb boardctl
Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
This commit is contained in:
parent
419207d23d
commit
98fba71998
5 changed files with 68 additions and 8 deletions
|
@ -45,6 +45,7 @@
|
|||
#endif
|
||||
|
||||
#ifdef CONFIG_BOARDCTL_USBDEVCTRL
|
||||
# include <nuttx/usb/adb.h>
|
||||
# include <nuttx/usb/cdcacm.h>
|
||||
# include <nuttx/usb/pl2303.h>
|
||||
# include <nuttx/usb/usbmsc.h>
|
||||
|
@ -88,6 +89,39 @@ static inline int
|
|||
|
||||
switch (ctrl->usbdev)
|
||||
{
|
||||
#if defined(CONFIG_USBADB) && !defined(CONFIG_USBADB_COMPOSITE)
|
||||
case BOARDIOC_USBDEV_ADB: /* ADB class */
|
||||
switch (ctrl->action)
|
||||
{
|
||||
case BOARDIOC_USBDEV_INITIALIZE: /* Initialize ADB device */
|
||||
break;
|
||||
|
||||
case BOARDIOC_USBDEV_CONNECT: /* Connect the ADB device */
|
||||
{
|
||||
DEBUGASSERT(ctrl->handle != NULL);
|
||||
|
||||
*ctrl->handle = usbdev_adb_initialize();
|
||||
if (*ctrl->handle == NULL)
|
||||
{
|
||||
ret = -EIO;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case BOARDIOC_USBDEV_DISCONNECT: /* Disconnect the ADB device */
|
||||
{
|
||||
DEBUGASSERT(ctrl->handle != NULL && *ctrl->handle != NULL);
|
||||
usbdev_adb_uninitialize(*ctrl->handle);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CDCACM
|
||||
case BOARDIOC_USBDEV_CDCACM: /* CDC/ACM, not in a composite */
|
||||
switch (ctrl->action)
|
||||
|
|
|
@ -499,7 +499,9 @@ int sim_bringup(void)
|
|||
rc_dummy_initialize(0);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_USBADB) && !defined(CONFIG_USBADB_COMPOSITE)
|
||||
#if defined(CONFIG_USBADB) && \
|
||||
!defined(CONFIG_USBADB_COMPOSITE) && \
|
||||
!defined(CONFIG_BOARDCTL_USBDEVCTRL)
|
||||
usbdev_adb_initialize();
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1929,18 +1929,29 @@ static void adb_char_on_connect(FAR struct usbdev_adb_s *priv, int connect)
|
|||
* Initialize the Android Debug Bridge USB device driver.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 on success, -errno on failure
|
||||
* A non-NULL "handle" is returned on success.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int usbdev_adb_initialize(void)
|
||||
FAR void *usbdev_adb_initialize(void)
|
||||
{
|
||||
struct composite_devdesc_s devdesc;
|
||||
FAR void *cdev;
|
||||
|
||||
usbdev_adb_get_composite_devdesc(&devdesc);
|
||||
cdev = composite_initialize(1, &devdesc);
|
||||
return cdev != NULL ? OK : -EINVAL;
|
||||
return composite_initialize(1, &devdesc);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbdev_adb_uninitialize
|
||||
*
|
||||
* Description:
|
||||
* Uninitialize the Android Debug Bridge USB device driver.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void usbdev_adb_uninitialize(FAR void *handle)
|
||||
{
|
||||
composite_uninitialize(handle);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
@ -61,11 +61,21 @@ extern "C"
|
|||
* Initialize the Android Debug Bridge USB device driver.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 on success, -errno on failure
|
||||
* A non-NULL "handle" is returned on success.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int usbdev_adb_initialize(void);
|
||||
FAR void *usbdev_adb_initialize(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbdev_adb_uninitialize
|
||||
*
|
||||
* Description:
|
||||
* Uninitialize the Android Debug Bridge USB device driver.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void usbdev_adb_uninitialize(FAR void *handle);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbdev_adb_get_composite_devdesc
|
||||
|
|
|
@ -331,6 +331,9 @@ struct boardioc_builtin_s
|
|||
enum boardioc_usbdev_identifier_e
|
||||
{
|
||||
BOARDIOC_USBDEV_NONE = 0 /* Not valid */
|
||||
#ifdef CONFIG_USBADB
|
||||
, BOARDIOC_USBDEV_ADB /* ADB */
|
||||
#endif
|
||||
#ifdef CONFIG_CDCACM
|
||||
, BOARDIOC_USBDEV_CDCACM /* CDC/ACM */
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue