mirror of
https://github.com/apache/nuttx.git
synced 2026-05-29 04:19:37 +08:00
usbadb: add usbadb boardctl
Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
This commit is contained in:
@@ -45,6 +45,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_BOARDCTL_USBDEVCTRL
|
#ifdef CONFIG_BOARDCTL_USBDEVCTRL
|
||||||
|
# include <nuttx/usb/adb.h>
|
||||||
# include <nuttx/usb/cdcacm.h>
|
# include <nuttx/usb/cdcacm.h>
|
||||||
# include <nuttx/usb/pl2303.h>
|
# include <nuttx/usb/pl2303.h>
|
||||||
# include <nuttx/usb/usbmsc.h>
|
# include <nuttx/usb/usbmsc.h>
|
||||||
@@ -88,6 +89,39 @@ static inline int
|
|||||||
|
|
||||||
switch (ctrl->usbdev)
|
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
|
#ifdef CONFIG_CDCACM
|
||||||
case BOARDIOC_USBDEV_CDCACM: /* CDC/ACM, not in a composite */
|
case BOARDIOC_USBDEV_CDCACM: /* CDC/ACM, not in a composite */
|
||||||
switch (ctrl->action)
|
switch (ctrl->action)
|
||||||
|
|||||||
@@ -499,7 +499,9 @@ int sim_bringup(void)
|
|||||||
rc_dummy_initialize(0);
|
rc_dummy_initialize(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_USBADB) && !defined(CONFIG_USBADB_COMPOSITE)
|
#if defined(CONFIG_USBADB) && \
|
||||||
|
!defined(CONFIG_USBADB_COMPOSITE) && \
|
||||||
|
!defined(CONFIG_BOARDCTL_USBDEVCTRL)
|
||||||
usbdev_adb_initialize();
|
usbdev_adb_initialize();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
+16
-5
@@ -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.
|
* Initialize the Android Debug Bridge USB device driver.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* 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;
|
struct composite_devdesc_s devdesc;
|
||||||
FAR void *cdev;
|
|
||||||
|
|
||||||
usbdev_adb_get_composite_devdesc(&devdesc);
|
usbdev_adb_get_composite_devdesc(&devdesc);
|
||||||
cdev = composite_initialize(1, &devdesc);
|
return composite_initialize(1, &devdesc);
|
||||||
return cdev != NULL ? OK : -EINVAL;
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: usbdev_adb_uninitialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Uninitialize the Android Debug Bridge USB device driver.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void usbdev_adb_uninitialize(FAR void *handle)
|
||||||
|
{
|
||||||
|
composite_uninitialize(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
+12
-2
@@ -61,11 +61,21 @@ extern "C"
|
|||||||
* Initialize the Android Debug Bridge USB device driver.
|
* Initialize the Android Debug Bridge USB device driver.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* 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
|
* Name: usbdev_adb_get_composite_devdesc
|
||||||
|
|||||||
@@ -331,6 +331,9 @@ struct boardioc_builtin_s
|
|||||||
enum boardioc_usbdev_identifier_e
|
enum boardioc_usbdev_identifier_e
|
||||||
{
|
{
|
||||||
BOARDIOC_USBDEV_NONE = 0 /* Not valid */
|
BOARDIOC_USBDEV_NONE = 0 /* Not valid */
|
||||||
|
#ifdef CONFIG_USBADB
|
||||||
|
, BOARDIOC_USBDEV_ADB /* ADB */
|
||||||
|
#endif
|
||||||
#ifdef CONFIG_CDCACM
|
#ifdef CONFIG_CDCACM
|
||||||
, BOARDIOC_USBDEV_CDCACM /* CDC/ACM */
|
, BOARDIOC_USBDEV_CDCACM /* CDC/ACM */
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user