Add basic definitions for control of USB devices via boardctl()
This commit is contained in:
parent
164dad9cd2
commit
a2620361df
@ -1903,6 +1903,13 @@ config BOARDCTL_OS_SYMTAB
|
||||
---help---
|
||||
Enables support for the BOARDIOC_OS_SYMTAB boardctl() command.
|
||||
|
||||
config BOARDCTL_USBDEVCTRL
|
||||
bool "Enable USB device controls"
|
||||
default n
|
||||
depends on USBDEV
|
||||
---help---
|
||||
Enables support for the BOARDIOC_USBDEV_CONTROL boardctl() command.
|
||||
|
||||
config BOARDCTL_TSCTEST
|
||||
bool "Enable touchscreen test interfaces"
|
||||
default n
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* configs/boardctl.c
|
||||
*
|
||||
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -49,8 +49,134 @@
|
||||
#include <nuttx/module.h>
|
||||
#include <nuttx/binfmt/symtab.h>
|
||||
|
||||
#ifdef CONFIG_BOARDCTL_USBDEVCTRL
|
||||
# include <nuttx/usbdev/cdcacm.h>
|
||||
# include <nuttx/usbdev/usbmsc.h>
|
||||
# include <nuttx/usbdev/composite.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LIB_BOARDCTL
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: boardctl_usbdevctrl
|
||||
*
|
||||
* Description:
|
||||
* Handler the USB device control command.
|
||||
*
|
||||
* Input Parameters:
|
||||
* ctrl - Described the USB device control command.
|
||||
*
|
||||
* Returned Value:
|
||||
* On success zero (OK) is returned; -1 (ERROR) is returned on failure
|
||||
* with the errno variable to to indicate the nature of the failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_BOARDCTL_USBDEVCTRL
|
||||
static inline int boardctl_usbdevctrl(FAR struct boardioc_usbdev_ctrl_s *ctrl)
|
||||
{
|
||||
int ret = OK;
|
||||
|
||||
switch (ctrl->usbdev)
|
||||
{
|
||||
#if defined(CONFIG_CDCACM) && !defined(CONFIG_CDCACM_COMPOSITE)
|
||||
case BOARDIOC_USBDEV_CDCACM: /* CDC/ACM, not in a composite */
|
||||
switch (ctrl->action)
|
||||
{
|
||||
case BOARDIOC_USBDEV_INITIALIZE: /* Initialize CDC/ACM device */
|
||||
break; /* There is no CDC/ACM initialization */
|
||||
|
||||
case BOARDIOC_USBDEV_CONNECT: /* Connect the CDC/ACM device */
|
||||
{
|
||||
DEBUGASSERT(ctrl->handle != NULL);
|
||||
ret = cdcacm_initialize(ctrl->instance, ctrl->handle);
|
||||
}
|
||||
break;
|
||||
|
||||
case BOARDIOC_USBDEV_DISCONNECT: /* Disconnect the CDC/ACM device */
|
||||
{
|
||||
DEBUGASSERT(ctrl->handle != NULL);
|
||||
cdcacm_uninitialize(ctrl->handle);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_USBMSC) && !defined(CONFIG_USBMSC_COMPOSITE)
|
||||
case BOARDIOC_USBDEV_MSC: /* Mass storage class */
|
||||
switch (ctrl->action)
|
||||
{
|
||||
case BOARDIOC_USBDEV_INITIALIZE: /* Initialize USB MSC device */
|
||||
{
|
||||
ret = board_usbmsc_initialize(ctrl->instance);
|
||||
}
|
||||
break;
|
||||
|
||||
case BOARDIOC_USBDEV_CONNECT: /* Connect the USB MSC device */
|
||||
{
|
||||
DEBUGASSERT(ctrl->handle != NULL);
|
||||
???
|
||||
}
|
||||
break;
|
||||
|
||||
case BOARDIOC_USBDEV_DISCONNECT: /* Disconnect the USB MSC device */
|
||||
{
|
||||
DEBUGASSERT(ctrl->handle != NULL);
|
||||
usbmsc_uninitialize(ctrl->handle);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USBDEV_COMPOSITE
|
||||
case BOARDIOC_USBDEV_COMPOSITE: /* Composite device */
|
||||
switch (ctrl->action)
|
||||
{
|
||||
case BOARDIOC_USBDEV_INITIALIZE: /* Initialize Composite device */
|
||||
{
|
||||
ret = board_composite_initialize(ctrl->instance);
|
||||
}
|
||||
break;
|
||||
|
||||
case BOARDIOC_USBDEV_CONNECT: /* Connect the Composite device */
|
||||
{
|
||||
DEBUGASSERT(ctrl->handle != NULL);
|
||||
*(ctrl->handle) = composite_initialize();
|
||||
if (ctrl->handle == NULL)
|
||||
{
|
||||
ret = -EIO;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case BOARDIOC_USBDEV_DISCONNECT: /* Disconnect the Composite device */
|
||||
{
|
||||
DEBUGASSERT(ctrl->handle != NULL);
|
||||
composite_uninitialize(ctrl->handle);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -193,6 +319,25 @@ int boardctl(unsigned int cmd, uintptr_t arg)
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BOARDCTL_USBDEVCTRL
|
||||
/* CMD: BOARDIOC_USBDEV_CONTROL
|
||||
* DESCRIPTION: Manage USB device classes
|
||||
* ARG: A pointer to an instance of struct boardioc_usbdev_ctrl_s
|
||||
* CONFIGURATION: CONFIG_LIB_BOARDCTL && CONFIG_BOARDCTL_USBDEVCTRL
|
||||
* DEPENDENCIES: Board logic must provide board_<usbdev>_initialize()
|
||||
*/
|
||||
|
||||
case BOARDIOC_USBDEV_CONTROL:
|
||||
{
|
||||
FAR struct boardioc_usbdev_ctrl_s *ctrl =
|
||||
(FAR struct boardioc_usbdev_ctrl_s *)arg;
|
||||
|
||||
DEBUGASSERT(ctrl != NULL);
|
||||
ret = boardctl_usbdevctrl(ctrl);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BOARDCTL_TSCTEST
|
||||
/* CMD: BOARDIOC_TSCTEST_SETUP
|
||||
* DESCRIPTION: Touchscreen controller test configuration
|
||||
|
@ -1,7 +1,7 @@
|
||||
############################################################################
|
||||
# configs/samv71-xult/src/Makefile
|
||||
#
|
||||
# Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@ -78,6 +78,10 @@ ifeq ($(CONFIG_USBMSC),y)
|
||||
CSRCS += sam_usbmsc.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USBDEV_COMPOSITE),y)
|
||||
CSRCS += sam_composite.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SAMV7_MCAN),y)
|
||||
CSRCS += sam_mcan.c
|
||||
endif
|
||||
|
65
configs/samv71-xult/src/sam_composite.c
Normal file
65
configs/samv71-xult/src/sam_composite.c
Normal file
@ -0,0 +1,65 @@
|
||||
/****************************************************************************
|
||||
* configs/samv71-xult/src/sam_composite.c
|
||||
*
|
||||
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/usb/composite.h>
|
||||
|
||||
#include "samv71-xult.h"
|
||||
|
||||
#ifdef CONFIG_USBDEV_COMPOSITE
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_composite_initialize
|
||||
*
|
||||
* Description:
|
||||
* Perform architecture specific initialization of a composite USB device.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_composite_initialize(int port)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_USBDEV_COMPOSITE */
|
71
configs/samv71-xult/src/sam_usbmsc.c
Normal file
71
configs/samv71-xult/src/sam_usbmsc.c
Normal file
@ -0,0 +1,71 @@
|
||||
/****************************************************************************
|
||||
* configs/samv71-xult/src/sam_usbmsc.c
|
||||
*
|
||||
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "nuttx/board.h"
|
||||
|
||||
#include "samv71-xult.h"
|
||||
|
||||
#if defined(CONFIG_USBMSC) && !defined(CONFIG_USBMSC_COMPOSITE)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_usbmsc_initialize
|
||||
*
|
||||
* Description:
|
||||
* Perform architecture specific initialization of the USB MSC device.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_usbmsc_initialize(int port)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_USBMSC && !CONFIG_USBMSC_COMPOSITE */
|
@ -126,9 +126,6 @@
|
||||
#if defined(CONFIG_PM) && defined(CONFIG_RTC_ALARM)
|
||||
static volatile bool g_alarmwakeup; /* Wakeup Alarm indicator */
|
||||
#endif
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
|
Loading…
Reference in New Issue
Block a user