Changes for clean STM32 USB host driver build

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5040 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo
2012-08-20 16:06:39 +00:00
parent 4f56a72bea
commit 27bd0bbee4
11 changed files with 309 additions and 140 deletions
File diff suppressed because it is too large Load Diff
+26
View File
@@ -49,6 +49,32 @@
#if defined(CONFIG_STM32_OTGFS) && defined(CONFIG_USBHOST)
/************************************************************************************
* Public Functions
************************************************************************************/
/*
* 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.
*/
/************************************************************************************
* Public Functions
************************************************************************************/
+30 -1
View File
@@ -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 <subdir> 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:
-----
+31 -1
View File
@@ -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
#
+40 -24
View File
@@ -55,7 +55,12 @@
# include <nuttx/mmcsd.h>
#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)
{
+6 -4
View File
@@ -43,6 +43,8 @@
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <sched.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/usb/usbdev.h>
@@ -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;
+31 -1
View File
@@ -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 <subdir> 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:
+23
View File
@@ -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
==============
+4 -4
View File
@@ -122,8 +122,8 @@ static void usbhost_putle16(uint8_t *dest, uint16_t val)
*
*******************************************************************************/
static inline int usbhost_devdesc(const struct usb_devdesc_s *devdesc,
struct usbhost_id_s *id)
static inline int usbhost_devdesc(FAR const struct usb_devdesc_s *devdesc,
FAR struct usbhost_id_s *id)
{
/* Clear the ID info */
@@ -131,7 +131,7 @@ static inline int usbhost_devdesc(const struct usb_devdesc_s *devdesc,
/* Pick off the class ID info */
id->base = devdesc->class;
id->base = devdesc->classid;
id->subclass = devdesc->subclass;
id->proto = devdesc->protocol;
@@ -194,7 +194,7 @@ static inline int usbhost_configdesc(const uint8_t *configdesc, int cfglen,
*/
DEBUGASSERT(remaining >= sizeof(struct usb_ifdesc_s));
id->base = ifdesc->class;
id->base = ifdesc->classid;
id->subclass = ifdesc->subclass;
id->proto = ifdesc->protocol;
uvdbg("class:%d subclass:%d protocol:%d\n",
+5 -1
View File
@@ -255,7 +255,9 @@ static inline int usbhost_devinit(FAR struct usbhost_state_s *priv);
static inline uint16_t usbhost_getle16(const uint8_t *val);
static inline void usbhost_putle16(uint8_t *dest, uint16_t val);
static inline uint32_t usbhost_getle32(const uint8_t *val);
#if 0 /* Not used */
static void usbhost_putle32(uint8_t *dest, uint32_t val);
#endif
/* Transfer descriptor memory management */
@@ -701,7 +703,7 @@ static int usbhost_kbdpoll(int argc, char *argv[])
#if defined(CONFIG_DEBUG_USB) && defined(CONFIG_DEBUG_VERBOSE)
unsigned int npolls = 0;
#endif
unsigned int nerrors;
unsigned int nerrors = 0;
int ret;
uvdbg("Started\n");
@@ -1381,6 +1383,7 @@ static inline uint32_t usbhost_getle32(const uint8_t *val)
*
****************************************************************************/
#if 0 /* Not used */
static void usbhost_putle32(uint8_t *dest, uint32_t val)
{
/* Little endian means LS halfword first in byte stream */
@@ -1388,6 +1391,7 @@ static void usbhost_putle32(uint8_t *dest, uint32_t val)
usbhost_putle16(dest, (uint16_t)(val & 0xffff));
usbhost_putle16(dest+2, (uint16_t)(val >> 16));
}
#endif
/****************************************************************************
* Name: usbhost_tdalloc
+1 -1
View File
@@ -562,7 +562,7 @@ struct usbhost_epdesc_s
uint8_t addr; /* Endpoint address */
bool in; /* Direction: true->IN */
uint8_t funcaddr; /* USB address of function containing endpoint */
uint8_t xfrtype; /* Transfer type. See SB_EP_ATTR_XFER_* in usb.h */
uint8_t xfrtype; /* Transfer type. See USB_EP_ATTR_XFER_* in usb.h */
uint8_t interval; /* Polling interval */
uint16_t mxpacketsize; /* Max packetsize */
};