mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 10:58:49 +08:00
Merged in alinjerpelea/nuttx (pull request #925)
configs: spresense: add MSC and USB Composite device * configs: spresense: add USB Composite device Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com> * configs: spresense: add usbmsc configuration the usbmsc support has been added and we can add an configuration for spresense board Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com> * configs: spresense: add button template Spresense board does not have buttons and this is a template for gpio buttons that can be connected on the external header Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com> Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
parent
574595dc32
commit
79e79f0a03
4 changed files with 472 additions and 0 deletions
|
@ -68,6 +68,10 @@ CSRCS += cxd56_userleds.c
|
|||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ARCH_BUTTONS),y)
|
||||
CSRCS += cxd56_buttons.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CXD56_GPIO_IRQ),y)
|
||||
CSRCS += cxd56_gpioif.c
|
||||
endif
|
||||
|
@ -100,6 +104,10 @@ ifeq ($(CONFIG_USBMSC),y)
|
|||
CSRCS += cxd56_usbmsc.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USBDEV_COMPOSITE),y)
|
||||
CSRCS += cxd56_composite.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NETDEVICES),y)
|
||||
CSRCS += cxd56_netinit.c
|
||||
endif
|
||||
|
|
96
configs/spresense/src/cxd56_buttons.c
Normal file
96
configs/spresense/src/cxd56_buttons.c
Normal file
|
@ -0,0 +1,96 @@
|
|||
/****************************************************************************
|
||||
* configs/spresense/src/cxd56_buttons.c
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* 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 of Sony Semiconductor Solutions Corporation 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 <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <debug.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "cxd56_gpio.h"
|
||||
#include "cxd56_gpioint.h"
|
||||
#include "cxd56_pinconfig.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/* Below functions are template to support the Board button for NuttX original
|
||||
* feature. If you support the feature, copy this file into your board
|
||||
* directory and implement the contents.
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_button_initialize
|
||||
****************************************************************************/
|
||||
|
||||
void board_button_initialize(void)
|
||||
{
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_buttons
|
||||
****************************************************************************/
|
||||
|
||||
uint32_t board_buttons(void)
|
||||
{
|
||||
uint8_t ret = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_button_irq
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
#endif
|
283
configs/spresense/src/cxd56_composite.c
Normal file
283
configs/spresense/src/cxd56_composite.c
Normal file
|
@ -0,0 +1,283 @@
|
|||
/****************************************************************************
|
||||
* configs/spresense/src/cxd56_composite.c
|
||||
*
|
||||
* Copyright (C) 2016, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* 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 <debug.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
#include <nuttx/usb/cdcacm.h>
|
||||
#include <nuttx/usb/usbmsc.h>
|
||||
#include <nuttx/usb/composite.h>
|
||||
|
||||
#if defined(CONFIG_BOARDCTL_USBDEVCTRL) && defined(CONFIG_USBDEV_COMPOSITE)
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_USBMSC_COMPOSITE
|
||||
static FAR void *g_mschandle;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_mscclassobject
|
||||
*
|
||||
* Description:
|
||||
* If the mass storage class driver is part of composite device, then
|
||||
* its instantiation and configuration is a multi-step, board-specific,
|
||||
* process (See comments for usbmsc_configure below). In this case,
|
||||
* board-specific logic must provide board_mscclassobject().
|
||||
*
|
||||
* board_mscclassobject() is called from the composite driver. It must
|
||||
* encapsulate the instantiation and configuration of the mass storage
|
||||
* class and the return the mass storage device's class driver instance
|
||||
* to the composite driver.
|
||||
*
|
||||
* Input Parameters:
|
||||
* classdev - The location to return the mass storage class' device
|
||||
* instance.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 on success; a negated errno on failure
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_USBMSC_COMPOSITE
|
||||
static int board_mscclassobject(int minor,
|
||||
FAR struct usbdev_devinfo_s *devinfo,
|
||||
FAR struct usbdevclass_driver_s **classdev)
|
||||
{
|
||||
int ret;
|
||||
|
||||
DEBUGASSERT(g_mschandle == NULL);
|
||||
|
||||
/* Configure the mass storage device */
|
||||
|
||||
uinfo("Configuring with NLUNS=1\n");
|
||||
ret = usbmsc_configure(1, &g_mschandle);
|
||||
if (ret < 0)
|
||||
{
|
||||
uerr("ERROR: usbmsc_configure failed: %d\n", -ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
uinfo("MSC handle=%p\n", g_mschandle);
|
||||
|
||||
/* Bind the LUN(s) */
|
||||
|
||||
uinfo("Bind LUN=0 to /dev/mmcsd0\n");
|
||||
ret = usbmsc_bindlun(g_mschandle, "/dev/mmcsd0", 0, 0, 0, false);
|
||||
if (ret < 0)
|
||||
{
|
||||
uerr("ERROR: usbmsc_bindlun failed for LUN 1 at /dev/mmcsd0: %d\n",
|
||||
ret);
|
||||
usbmsc_uninitialize(g_mschandle);
|
||||
g_mschandle = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Get the mass storage device's class object */
|
||||
|
||||
ret = usbmsc_classobject(g_mschandle, devinfo, classdev);
|
||||
if (ret < 0)
|
||||
{
|
||||
uerr("ERROR: usbmsc_classobject failed: %d\n", -ret);
|
||||
usbmsc_uninitialize(g_mschandle);
|
||||
g_mschandle = NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_mscuninitialize
|
||||
*
|
||||
* Description:
|
||||
* Un-initialize the USB storage class driver. This is just an application-
|
||||
* specific wrapper aboutn usbmsc_unitialize() that is called form the
|
||||
* composite device logic.
|
||||
*
|
||||
* Input Parameters:
|
||||
* classdev - The class driver instrance previously give to the composite
|
||||
* driver by board_mscclassobject().
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_USBMSC_COMPOSITE
|
||||
static void board_mscuninitialize(FAR struct usbdevclass_driver_s *classdev)
|
||||
{
|
||||
DEBUGASSERT(g_mschandle != NULL);
|
||||
usbmsc_uninitialize(g_mschandle);
|
||||
g_mschandle = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_composite_initialize
|
||||
*
|
||||
* Description:
|
||||
* Perform architecture specific initialization of a composite USB device.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_composite_initialize(int port)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_composite_connect
|
||||
*
|
||||
* Description:
|
||||
* Connect the USB composite device on the specified USB device port using
|
||||
* the specified configuration. The interpretation of the configid is
|
||||
* board specific.
|
||||
*
|
||||
* Input Parameters:
|
||||
* port - The USB device port.
|
||||
* configid - The USB composite configuration
|
||||
*
|
||||
* Returned Value:
|
||||
* A non-NULL handle value is returned on success. NULL is returned on
|
||||
* any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR void *board_composite_connect(int port, int configid)
|
||||
{
|
||||
/* Here we are composing the configuration of the usb composite device.
|
||||
*
|
||||
* The standard is to use one CDC/ACM and one USB mass storage device.
|
||||
*/
|
||||
|
||||
if (configid == 0)
|
||||
{
|
||||
#ifdef CONFIG_USBMSC_COMPOSITE
|
||||
struct composite_devdesc_s dev[2];
|
||||
int ifnobase = 0;
|
||||
int strbase = COMPOSITE_NSTRIDS;
|
||||
|
||||
/* Configure the mass storage device device */
|
||||
/* Ask the usbmsc driver to fill in the constants we didn't
|
||||
* know here.
|
||||
*/
|
||||
|
||||
usbmsc_get_composite_devdesc(&dev[0]);
|
||||
|
||||
/* Overwrite and correct some values... */
|
||||
/* The callback functions for the USBMSC class */
|
||||
|
||||
dev[0].classobject = board_mscclassobject;
|
||||
dev[0].uninitialize = board_mscuninitialize;
|
||||
|
||||
/* Interfaces */
|
||||
|
||||
dev[0].devinfo.ifnobase = ifnobase; /* Offset to Interface-IDs */
|
||||
dev[0].minor = 0; /* The minor interface number */
|
||||
|
||||
/* Strings */
|
||||
|
||||
dev[0].devinfo.strbase = strbase; /* Offset to String Numbers */
|
||||
|
||||
/* Endpoints */
|
||||
|
||||
dev[0].devinfo.epno[USBMSC_EP_BULKIN_IDX] = 1;
|
||||
dev[0].devinfo.epno[USBMSC_EP_BULKOUT_IDX] = 2;
|
||||
|
||||
/* Count up the base numbers */
|
||||
|
||||
ifnobase += dev[0].devinfo.ninterfaces;
|
||||
strbase += dev[0].devinfo.nstrings;
|
||||
|
||||
/* Configure the CDC/ACM device */
|
||||
|
||||
/* Ask the cdcacm driver to fill in the constants we didn't
|
||||
* know here.
|
||||
*/
|
||||
|
||||
cdcacm_get_composite_devdesc(&dev[1]);
|
||||
|
||||
/* Overwrite and correct some values... */
|
||||
/* The callback functions for the CDC/ACM class */
|
||||
|
||||
dev[1].classobject = cdcacm_classobject;
|
||||
dev[1].uninitialize = cdcacm_uninitialize;
|
||||
|
||||
/* Interfaces */
|
||||
|
||||
dev[1].devinfo.ifnobase = ifnobase; /* Offset to Interface-IDs */
|
||||
dev[1].minor = 0; /* The minor interface number */
|
||||
|
||||
/* Strings */
|
||||
|
||||
dev[1].devinfo.strbase = strbase; /* Offset to String Numbers */
|
||||
|
||||
/* Endpoints */
|
||||
|
||||
dev[1].devinfo.epno[CDCACM_EP_INTIN_IDX] = 3;
|
||||
dev[1].devinfo.epno[CDCACM_EP_BULKIN_IDX] = 4;
|
||||
dev[1].devinfo.epno[CDCACM_EP_BULKOUT_IDX] = 5;
|
||||
|
||||
return composite_initialize(2, dev);
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BOARDCTL_USBDEVCTRL && CONFIG_USBDEV_COMPOSITE */
|
85
configs/spresense/usbmsc/defconfig
Normal file
85
configs/spresense/usbmsc/defconfig
Normal file
|
@ -0,0 +1,85 @@
|
|||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_CXD56_I2C0_SCUSEQ is not set
|
||||
# CONFIG_MMCSD_HAVE_WRITEPROTECT is not set
|
||||
# CONFIG_MMCSD_SPI is not set
|
||||
# CONFIG_STANDARD_SERIAL is not set
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="spresense"
|
||||
CONFIG_ARCH_BOARD_SPRESENSE=y
|
||||
CONFIG_ARCH_CHIP_CXD56XX=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARMV7M_USEBASEPRI=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=5434
|
||||
CONFIG_BOOT_RUNFROMISRAM=y
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_CDCACM=y
|
||||
CONFIG_CDCACM_COMPOSITE=y
|
||||
CONFIG_CLOCK_MONOTONIC=y
|
||||
CONFIG_COMPOSITE_IAD=y
|
||||
CONFIG_COMPOSITE_MSFT_OS_DESCRIPTORS=y
|
||||
CONFIG_COMPOSITE_PRODUCTID=0x0bc2
|
||||
CONFIG_COMPOSITE_VENDORID=0x054c
|
||||
CONFIG_COMPOSITE_VENDORSTR="Sony"
|
||||
CONFIG_CXD56_I2C0=y
|
||||
CONFIG_CXD56_I2C=y
|
||||
CONFIG_CXD56_SDIO=y
|
||||
CONFIG_CXD56_SPI4=y
|
||||
CONFIG_CXD56_SPI5=y
|
||||
CONFIG_CXD56_SPI=y
|
||||
CONFIG_CXD56_USBDEV=y
|
||||
CONFIG_DEBUG_FULLOPT=y
|
||||
CONFIG_DEBUG_SYMBOLS=y
|
||||
CONFIG_FAT_LCNAMES=y
|
||||
CONFIG_FAT_LFN=y
|
||||
CONFIG_FAT_MAXFNAME=64
|
||||
CONFIG_FS_FAT=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_FS_PROCFS_REGISTER=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_I2C=y
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_MAX_WDOGPARMS=2
|
||||
CONFIG_MMCSD=y
|
||||
CONFIG_MMCSD_SDIO=y
|
||||
CONFIG_NFILE_DESCRIPTORS=8
|
||||
CONFIG_NFILE_STREAMS=8
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PREALLOC_MQ_MSGS=4
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_PREALLOC_WDOGS=16
|
||||
CONFIG_RAM_SIZE=1572864
|
||||
CONFIG_RAM_START=0x0d000000
|
||||
CONFIG_READLINE_CMD_HISTORY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_RTC=y
|
||||
CONFIG_RTC_DRIVER=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_SPI=y
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
CONFIG_START_YEAR=2011
|
||||
CONFIG_SYSTEM_CDCACM=y
|
||||
CONFIG_SYSTEM_CLE=y
|
||||
CONFIG_SYSTEM_COMPOSITE=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_NSH_CXXINITIALIZE=y
|
||||
CONFIG_SYSTEM_USBMSC=y
|
||||
CONFIG_UART1_SERIAL_CONSOLE=y
|
||||
CONFIG_USBDEV=y
|
||||
CONFIG_USBDEV_COMPOSITE=y
|
||||
CONFIG_USBDEV_DMA=y
|
||||
CONFIG_USBDEV_DUALSPEED=y
|
||||
CONFIG_USBMSC=y
|
||||
CONFIG_USBMSC_COMPOSITE=y
|
||||
CONFIG_USBMSC_REMOVABLE=y
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
Loading…
Reference in a new issue