From 435fb483a8f3ba0ca33e97214ed0dad6faa480b0 Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 20 Aug 2012 16:06:39 +0000 Subject: [PATCH] Changes for clean STM32 USB host driver build git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5040 42af7a65-404d-4744-a932-0658087f49c3 --- configs/stm3220g-eval/README.txt | 31 +++++++++++++- configs/stm3220g-eval/nsh/defconfig | 32 ++++++++++++++- configs/stm3220g-eval/src/up_nsh.c | 64 ++++++++++++++++++----------- configs/stm3220g-eval/src/up_usb.c | 10 +++-- configs/stm3240g-eval/README.txt | 32 ++++++++++++++- configs/stm32f4discovery/README.txt | 23 +++++++++++ 6 files changed, 161 insertions(+), 31 deletions(-) diff --git a/configs/stm3220g-eval/README.txt b/configs/stm3220g-eval/README.txt index 43d9b382e2..ad049ea4c5 100644 --- a/configs/stm3220g-eval/README.txt +++ b/configs/stm3220g-eval/README.txt @@ -669,6 +669,27 @@ STM3220G-EVAL-specific Configuration Options STM3220G-EVAL LCD Hardware Configuration + STM32 USB OTG FS Host Driver Support + + Pre-requisites + + CONFIG_USBHOST - Enable general USB host support + CONFIG_STM32_OTGFS - Enable the STM32 USB OTG FS block + CONFIG_STM32_SYSCFG - Needed + + Options: + + CONFIG_STM32_OTGFS_RXFIFO_SIZE - Size of the RX FIFO in 32-bit words. + Default 128 (512 bytes) + CONFIG_STM32_OTGFS_NPTXFIFO_SIZE - Size of the non-periodic Tx FIFO + in 32-bit words. Default 96 (384 bytes) + CONFIG_STM32_OTGFS_PTXFIFO_SIZE - Size of the periodic Tx FIFO in 32-bit + words. Default 96 (384 bytes) + CONFIG_STM32_OTGFS_SOFINTR - Enable SOF interrupts. Why would you ever + want to do that? + CONFIG_STM32_USBHOST_REGDEBUG - Enable very low-level register access + debug. Depends on CONFIG_DEBUG. + Configurations ============== @@ -834,7 +855,15 @@ Where is one of the following: CONFIG_NX=y : Enable graphics suppport CONFIG_MM_REGIONS=2 : When FSMC is enabled, so is the on-board SRAM memory region - 8. This configuration requires that jumper JP22 be set to enable RS-232 operation. + 8. USB OTG FS Device or Host Support + + CONFIG_USBDEV - Enable USB device support + CONFIG_USBHOST - Enable USB host support + CONFIG_STM32_OTGFS - Enable the STM32 USB OTG FS block + CONFIG_STM32_SYSCFG - Needed + CONFIG_SCHED_WORKQUEUE - Worker thread support is required + + 9. This configuration requires that jumper JP22 be set to enable RS-232 operation. nsh2: ----- diff --git a/configs/stm3220g-eval/nsh/defconfig b/configs/stm3220g-eval/nsh/defconfig index a0f7a64be2..a6c4db2547 100644 --- a/configs/stm3220g-eval/nsh/defconfig +++ b/configs/stm3220g-eval/nsh/defconfig @@ -998,7 +998,7 @@ CONFIG_STMPE811_THRESHX=26 CONFIG_STMPE811_THRESHY=34 # -# USB Device Configuration +# STM32 USB OTG FS Device Configuration # # CONFIG_USBDEV # Enables USB device support @@ -1025,6 +1025,36 @@ CONFIG_USBDEV_MAXPOWER=100 CONFIG_USBDEV_TRACE=n CONFIG_USBDEV_TRACE_NRECORDS=128 +# +# STM32 USB OTG FS Host Configuration +# +# Pre-requisites +# +# CONFIG_USBHOST - Enable general USB host support +# CONFIG_STM32_OTGFS - Enable the STM32 USB OTG FS block +# CONFIG_STM32_SYSCFG - Needed +# CONFIG_SCHED_WORKQUEUE - Worker thread support is required +# +# Options: +# +# CONFIG_STM32_OTGFS_RXFIFO_SIZE - Size of the RX FIFO in 32-bit words. +# Default 128 (512 bytes) +# CONFIG_STM32_OTGFS_NPTXFIFO_SIZE - Size of the non-periodic Tx FIFO +# in 32-bit words. Default 96 (384 bytes) +# CONFIG_STM32_OTGFS_PTXFIFO_SIZE - Size of the periodic Tx FIFO in 32-bit +# words. Default 96 (384 bytes) +# CONFIG_STM32_OTGFS_SOFINTR - Enable SOF interrupts. Why would you ever +# want to do that? +# CONFIG_STM32_USBHOST_REGDEBUG - Enable very low-level register access +# debug. Depends on CONFIG_DEBUG. +# +CONFIG_USBHOST=n +# ONFIG_STM32_OTGFS_RXFIFO_SIZE +#CONFIG_STM32_OTGFS_NPTXFIFO_SIZE +#CONFIG_STM32_OTGFS_PTXFIFO_SIZE +CONFIG_STM32_OTGFS_SOFINTR=n +CONFIG_STM32_USBHOST_REGDEBUG=n + # # USB Serial Device Configuration # diff --git a/configs/stm3220g-eval/src/up_nsh.c b/configs/stm3220g-eval/src/up_nsh.c index 3b061902ba..e1359de96a 100644 --- a/configs/stm3220g-eval/src/up_nsh.c +++ b/configs/stm3220g-eval/src/up_nsh.c @@ -55,7 +55,12 @@ # include #endif +#ifdef CONFIG_STM32_OTGFS +# include "stm32_usbhost.h" +#endif + #include "stm32_internal.h" +#include "stm3220g-internal.h" /**************************************************************************** * Pre-Processor Definitions @@ -67,29 +72,19 @@ #undef CONFIG_STM32_SPI1 -/* PORT and SLOT number probably depend on the board configuration */ +/* MMCSD PORT and SLOT number probably depend on the board configuration */ -#ifdef CONFIG_ARCH_BOARD_STM3220G_EVAL -# define CONFIG_NSH_HAVEUSBDEV 1 -# define CONFIG_NSH_HAVEMMCSD 1 -# if defined(CONFIG_NSH_MMCSDSLOTNO) && CONFIG_NSH_MMCSDSLOTNO != 0 -# error "Only one MMC/SD slot" -# undef CONFIG_NSH_MMCSDSLOTNO -# endif -# ifndef CONFIG_NSH_MMCSDSLOTNO -# define CONFIG_NSH_MMCSDSLOTNO 0 -# endif -#else - /* Add configuration for new STM32 boards here */ -# error "Unrecognized STM32 board" -# undef CONFIG_NSH_HAVEUSBDEV -# undef CONFIG_NSH_HAVEMMCSD +#define HAVE_USBDEV 1 +#define HAVE_MMCSD 1 +#define HAVE_USBHOST 1 + +#if defined(CONFIG_NSH_MMCSDSLOTNO) && CONFIG_NSH_MMCSDSLOTNO != 0 +# error "Only one MMC/SD slot" +# undef CONFIG_NSH_MMCSDSLOTNO #endif -/* Can't support USB features if USB is not enabled */ - -#ifndef CONFIG_USBDEV -# undef CONFIG_NSH_HAVEUSBDEV +#ifndef CONFIG_NSH_MMCSDSLOTNO +# define CONFIG_NSH_MMCSDSLOTNO 0 #endif /* Can't support MMC/SD features if mountpoints are disabled or if SDIO support @@ -97,13 +92,32 @@ */ #if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_STM32_SDIO) -# undef CONFIG_NSH_HAVEMMCSD +# undef HAVE_MMCSD #endif #ifndef CONFIG_NSH_MMCSDMINOR # define CONFIG_NSH_MMCSDMINOR 0 #endif +/* Can't support USB host or device features if USB OTG FS is not enabled */ + +#ifndef CONFIG_STM32_OTGFS +# undef HAVE_USBDEV +# undef HAVE_USBHOST +#endif + +/* Can't support USB device is USB device is not enabled */ + +#ifndef CONFIG_USBDEV +# undef HAVE_USBDEV +#endif + +/* Can't support USB host is USB host is not enabled */ + +#ifndef CONFIG_USBHOST +# undef HAVE_USBHOST +#endif + /* Debug ********************************************************************/ #ifdef CONFIG_CPP_HAVE_VARARGS @@ -138,8 +152,10 @@ int nsh_archinitialize(void) FAR struct spi_dev_s *spi; FAR struct mtd_dev_s *mtd; #endif -#ifdef CONFIG_NSH_HAVEMMCSD +#ifdef HAVE_MMCSD FAR struct sdio_dev_s *sdio; +#endif +#if defined(HAVE_MMCSD) || defined (HAVE_USBHOST) int ret; #endif @@ -169,7 +185,7 @@ int nsh_archinitialize(void) /* Mount the SDIO-based MMC/SD block driver */ -#ifdef CONFIG_NSH_HAVEMMCSD +#ifdef HAVE_MMCSD /* First, get an instance of the SDIO interface */ message("nsh_archinitialize: Initializing SDIO slot %d\n", @@ -203,7 +219,7 @@ int nsh_archinitialize(void) * will monitor for USB connection and disconnection events. */ -#if defined(CONFIG_STM32_OTGFS) && defined(CONFIG_USBHOST) +#ifdef HAVE_USBHOST ret = stm32_usbhost_initialize(); if (ret != OK) { diff --git a/configs/stm3220g-eval/src/up_usb.c b/configs/stm3220g-eval/src/up_usb.c index 374d974ffc..be303a8a5b 100644 --- a/configs/stm3220g-eval/src/up_usb.c +++ b/configs/stm3220g-eval/src/up_usb.c @@ -43,6 +43,8 @@ #include #include #include +#include +#include #include #include @@ -59,10 +61,10 @@ * Definitions ************************************************************************************/ -#if defined(CONFIG_USBDEV) || defined(CONFIG_USBDEV) +#if defined(CONFIG_USBDEV) || defined(CONFIG_USBHOST) # define HAVE_USB 1 #else -# warning "CONFIG_STM32_OTGFS is enabled but neither CONFIG_USBDEV nor CONFIG_USBDEV" +# warning "CONFIG_STM32_OTGFS is enabled but neither CONFIG_USBDEV nor CONFIG_USBHOST" # undef HAVE_USB #endif @@ -78,7 +80,7 @@ * Private Data ************************************************************************************/ -#ifdef CONFIG_NSH_HAVEUSBHOST +#ifdef CONFIG_USBHOST static struct usbhost_driver_s *g_drvr; #endif @@ -94,7 +96,7 @@ static struct usbhost_driver_s *g_drvr; * ****************************************************************************/ -#ifdef CONFIG_NSH_HAVEUSBHOST +#ifdef CONFIG_USBHOST static int usbhost_waiter(int argc, char *argv[]) { bool connected = false; diff --git a/configs/stm3240g-eval/README.txt b/configs/stm3240g-eval/README.txt index 49e939a238..c8c1fdfa76 100755 --- a/configs/stm3240g-eval/README.txt +++ b/configs/stm3240g-eval/README.txt @@ -831,6 +831,28 @@ STM3240G-EVAL-specific Configuration Options CONFIG_STM32_ILI9320_DISABLE (includes ILI9321) CONFIG_STM32_ILI9325_DISABLE + STM32 USB OTG FS Host Driver Support + + Pre-requisites + + CONFIG_USBHOST - Enable USB host support + CONFIG_STM32_OTGFS - Enable the STM32 USB OTG FS block + CONFIG_STM32_SYSCFG - Needed + CONFIG_SCHED_WORKQUEUE - Worker thread support is required + + Options: + + CONFIG_STM32_OTGFS_RXFIFO_SIZE - Size of the RX FIFO in 32-bit words. + Default 128 (512 bytes) + CONFIG_STM32_OTGFS_NPTXFIFO_SIZE - Size of the non-periodic Tx FIFO + in 32-bit words. Default 96 (384 bytes) + CONFIG_STM32_OTGFS_PTXFIFO_SIZE - Size of the periodic Tx FIFO in 32-bit + words. Default 96 (384 bytes) + CONFIG_STM32_OTGFS_SOFINTR - Enable SOF interrupts. Why would you ever + want to do that? + CONFIG_STM32_USBHOST_REGDEBUG - Enable very low-level register access + debug. Depends on CONFIG_DEBUG. + Configurations ============== @@ -996,7 +1018,15 @@ Where is one of the following: CONFIG_NX=y : Enable graphics suppport CONFIG_MM_REGIONS=3 : When FSMC is enabled, so is the on-board SRAM memory region - 8. This configuration requires that jumper JP22 be set to enable RS-232 + 8. USB OTG FS Device or Host Support + + CONFIG_USBDEV - Enable USB device support + CONFIG_USBHOST - Enable USB host support + CONFIG_STM32_OTGFS - Enable the STM32 USB OTG FS block + CONFIG_STM32_SYSCFG - Needed + CONFIG_SCHED_WORKQUEUE - Worker thread support is required + + 9. This configuration requires that jumper JP22 be set to enable RS-232 operation. nsh2: diff --git a/configs/stm32f4discovery/README.txt b/configs/stm32f4discovery/README.txt index 09a2bb2b00..a1fe2c3560 100755 --- a/configs/stm32f4discovery/README.txt +++ b/configs/stm32f4discovery/README.txt @@ -883,6 +883,29 @@ STM32F4Discovery-specific Configuration Options CONFIG_SDIO_WIDTH_D1_ONLY - Select 1-bit transfer mode. Default: 4-bit transfer mode. + STM32 USB OTG FS Host Driver Support + + Pre-requisites + + CONFIG_USBDEV - Enable USB device support + CONFIG_USBHOST - Enable USB host support + CONFIG_STM32_OTGFS - Enable the STM32 USB OTG FS block + CONFIG_STM32_SYSCFG - Needed + CONFIG_SCHED_WORKQUEUE - Worker thread support is required + + Options: + + CONFIG_STM32_OTGFS_RXFIFO_SIZE - Size of the RX FIFO in 32-bit words. + Default 128 (512 bytes) + CONFIG_STM32_OTGFS_NPTXFIFO_SIZE - Size of the non-periodic Tx FIFO + in 32-bit words. Default 96 (384 bytes) + CONFIG_STM32_OTGFS_PTXFIFO_SIZE - Size of the periodic Tx FIFO in 32-bit + words. Default 96 (384 bytes) + CONFIG_STM32_OTGFS_SOFINTR - Enable SOF interrupts. Why would you ever + want to do that? + CONFIG_STM32_USBHOST_REGDEBUG - Enable very low-level register access + debug. Depends on CONFIG_DEBUG. + Configurations ==============