diff --git a/configs/Kconfig b/configs/Kconfig index 6cbd4cba5b..f3b3951d76 100644 --- a/configs/Kconfig +++ b/configs/Kconfig @@ -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 diff --git a/configs/boardctl.c b/configs/boardctl.c index 924e78e98c..d8f52d1d81 100644 --- a/configs/boardctl.c +++ b/configs/boardctl.c @@ -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 * * Redistribution and use in source and binary forms, with or without @@ -49,8 +49,134 @@ #include #include +#ifdef CONFIG_BOARDCTL_USBDEVCTRL +# include +# include +# include +#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__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 diff --git a/configs/samv71-xult/src/Makefile b/configs/samv71-xult/src/Makefile index 46dd2e6a4f..790601ecda 100644 --- a/configs/samv71-xult/src/Makefile +++ b/configs/samv71-xult/src/Makefile @@ -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 # # 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 diff --git a/configs/samv71-xult/src/sam_composite.c b/configs/samv71-xult/src/sam_composite.c new file mode 100644 index 0000000000..347b9faf79 --- /dev/null +++ b/configs/samv71-xult/src/sam_composite.c @@ -0,0 +1,65 @@ +/**************************************************************************** + * configs/samv71-xult/src/sam_composite.c + * + * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include + +#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 */ diff --git a/configs/samv71-xult/src/sam_usbmsc.c b/configs/samv71-xult/src/sam_usbmsc.c new file mode 100644 index 0000000000..45f7975823 --- /dev/null +++ b/configs/samv71-xult/src/sam_usbmsc.c @@ -0,0 +1,71 @@ +/**************************************************************************** + * configs/samv71-xult/src/sam_usbmsc.c + * + * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include + +#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 */ diff --git a/configs/stm3210e-eval/src/stm32_idle.c b/configs/stm3210e-eval/src/stm32_idle.c index 30d2e1c01a..7620735f22 100644 --- a/configs/stm3210e-eval/src/stm32_idle.c +++ b/configs/stm3210e-eval/src/stm32_idle.c @@ -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