mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
Olimex-STM32-P407: Update USB host support.
This commit is contained in:
@@ -12,6 +12,7 @@ are enabled so that the JTAG connection is not disconnected by the idle
|
|||||||
loop.
|
loop.
|
||||||
|
|
||||||
The following peripherals are enabled in this configuration.
|
The following peripherals are enabled in this configuration.
|
||||||
|
|
||||||
- LEDs: show the sytem status
|
- LEDs: show the sytem status
|
||||||
|
|
||||||
- Buttons: TAMPER-button, WKUP-button, J1-Joystick (consists of RIGHT-,
|
- Buttons: TAMPER-button, WKUP-button, J1-Joystick (consists of RIGHT-,
|
||||||
@@ -21,11 +22,12 @@ The following peripherals are enabled in this configuration.
|
|||||||
- ADC: ADC1 samples the red trim potentiometer AN_TR
|
- ADC: ADC1 samples the red trim potentiometer AN_TR
|
||||||
Built in app 'adc' works.
|
Built in app 'adc' works.
|
||||||
|
|
||||||
- USB-FS-OTG: enabled but not really tested, since there is only a
|
- USB-FS-OTG: Enabled but not really tested, since there is only a
|
||||||
USB-A-connector (host) connected to the full speed µC inputs.
|
USB-A-connector (host) connected to the full speed STM32
|
||||||
The other connector (device) is connected to the high speed µC
|
inputs.
|
||||||
inputs, but it seems that NuttX has currently no driver
|
|
||||||
for it.
|
- USB-HS_OTG: The other connector (device) is connected to the high speed
|
||||||
|
STM32 inputs (not enabled).
|
||||||
|
|
||||||
- CAN: Built in app 'can' works, but appart from that not really tested.
|
- CAN: Built in app 'can' works, but appart from that not really tested.
|
||||||
|
|
||||||
|
|||||||
@@ -5,4 +5,14 @@
|
|||||||
|
|
||||||
if ARCH_BOARD_OLIMEX_STM32P407
|
if ARCH_BOARD_OLIMEX_STM32P407
|
||||||
|
|
||||||
|
config STM32F4DISCO_OLIMEXP407_STACKSIZE
|
||||||
|
int "USB host waiter stack size"
|
||||||
|
default 1024
|
||||||
|
depends on USBHOST
|
||||||
|
|
||||||
|
config STM32F4DISCO_OLIMEXP407_PRIO
|
||||||
|
int "USB host waiter task priority"
|
||||||
|
default 100
|
||||||
|
depends on USBHOST
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -7,6 +7,14 @@ to share the same board design. Other code comes from the STM3240G board
|
|||||||
support (which has the same crystal and clocking) and from the STM32 F4
|
support (which has the same crystal and clocking) and from the STM32 F4
|
||||||
Discovery (which has the same STM32 part)
|
Discovery (which has the same STM32 part)
|
||||||
|
|
||||||
|
Contents
|
||||||
|
========
|
||||||
|
|
||||||
|
o Board Support
|
||||||
|
o microSD Card Interface
|
||||||
|
o OTGFS Host
|
||||||
|
o Configurations
|
||||||
|
|
||||||
Board Support
|
Board Support
|
||||||
=============
|
=============
|
||||||
|
|
||||||
@@ -21,11 +29,11 @@ The following peripherals are available in this configuration.
|
|||||||
- ADC: ADC1 samples the red trim potentiometer AN_TR
|
- ADC: ADC1 samples the red trim potentiometer AN_TR
|
||||||
Built in app 'adc' works.
|
Built in app 'adc' works.
|
||||||
|
|
||||||
- USB-FS-OTG: enabled but not really tested, since there is only a
|
- USB-FS-OTG: There is a USB-A-connector (host) connected to the full
|
||||||
USB-A-connector (host) connected to the full speed µC inputs.
|
speed STM32 inputs.
|
||||||
The other connector (device) is connected to the high speed µC
|
|
||||||
inputs, but it seems that NuttX has currently no driver
|
- USB-HS-OTG: The other connector (device) is connected to the high speed
|
||||||
for it.
|
STM32 inputs.
|
||||||
|
|
||||||
- CAN: Built in app 'can' works, but apart from that not really tested.
|
- CAN: Built in app 'can' works, but apart from that not really tested.
|
||||||
|
|
||||||
@@ -107,6 +115,67 @@ microSD Card Interface
|
|||||||
-------
|
-------
|
||||||
2017-01-28: There is no card communication. All commands to the SD card timeout.
|
2017-01-28: There is no card communication. All commands to the SD card timeout.
|
||||||
|
|
||||||
|
OTGFS Host
|
||||||
|
==========
|
||||||
|
STM32 USB OTG FS Host Board Support
|
||||||
|
-----------------------------------
|
||||||
|
A USB-A-connector (host) is connected to the full speed STM32 inputs. These
|
||||||
|
are the pins supported by the STM32:
|
||||||
|
|
||||||
|
PIN SIGNAL DIRECTION
|
||||||
|
---- ----------- ----------
|
||||||
|
PA8 OTG_FS_SOF SOF clock output
|
||||||
|
PA9 OTG_FS_VBUS VBUS input for device, Driven by external regulator by
|
||||||
|
host (not an alternate function)
|
||||||
|
PA10 OTG_FS_ID OTG ID pin (only needed in Dual mode)
|
||||||
|
PA11 OTG_FS_DM D- I/O
|
||||||
|
PA12 OTG_FS_DP D+ I/O
|
||||||
|
|
||||||
|
These are the signals available on-board:
|
||||||
|
|
||||||
|
OTG_FS_VBUS Used host VBUS sensing (device input only)
|
||||||
|
OTG_FS_DM Data minus
|
||||||
|
OTG_FS_DP Dta plus
|
||||||
|
|
||||||
|
NOTE: PA10 is currently used for DCMI_D1. The USB OTGFS host will
|
||||||
|
configure this as the ID input.
|
||||||
|
|
||||||
|
VBUS power is provided via an LM3526 and driven by USB_FS_VBUSON:
|
||||||
|
|
||||||
|
USB_FS_VBUSON PC2 power on output to LM3526 #ENA
|
||||||
|
USB_FS_FAULT PB10 overcurrent input from LM3526 FLAG_A.
|
||||||
|
|
||||||
|
STM32 USB OTG FS Host Driver Configuration
|
||||||
|
------------------------------------------
|
||||||
|
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_DESCSIZE - Maximum size of a descriptor. Default: 128
|
||||||
|
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_FEATURES.
|
||||||
|
CONFIG_STM32_USBHOST_PKTDUMP - Dump all incoming and outgoing USB
|
||||||
|
packets. Depends on CONFIG_DEBUG_FEATURES.
|
||||||
|
|
||||||
|
Class Driver Configuration
|
||||||
|
--------------------------
|
||||||
|
Individual class drivers have additional configuration requirements. The
|
||||||
|
USB mass storage class, for example, requires FAT file system support.
|
||||||
|
|
||||||
Configurations
|
Configurations
|
||||||
==============
|
==============
|
||||||
|
|
||||||
|
|||||||
@@ -159,11 +159,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define GPIO_OTGFS_VBUS (GPIO_INPUT|GPIO_FLOAT|GPIO_PORTA|GPIO_PIN9)
|
#define GPIO_OTGFS_VBUS (GPIO_INPUT|GPIO_FLOAT|GPIO_PORTA|GPIO_PIN9)
|
||||||
#define GPIO_OTGFS_PWRON (GPIO_OUTPUT|GPIO_FLOAT|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTC|GPIO_PIN2)
|
#define GPIO_OTGFS_PWRON (GPIO_OUTPUT|GPIO_FLOAT|GPIO_SPEED_100MHz|\
|
||||||
|
GPIO_PUSHPULL|GPIO_PORTC|GPIO_PIN2)
|
||||||
|
|
||||||
#ifdef CONFIG_USBHOST
|
#ifdef CONFIG_USBHOST
|
||||||
# define GPIO_OTGFS_OVER (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTB|GPIO_PIN10)
|
# define GPIO_OTGFS_OVER (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTB|GPIO_PIN10)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
# define GPIO_OTGFS_OVER (GPIO_INPUT|GPIO_FLOAT|GPIO_PORTB|GPIO_PIN10)
|
# define GPIO_OTGFS_OVER (GPIO_INPUT|GPIO_FLOAT|GPIO_PORTB|GPIO_PIN10)
|
||||||
#endif
|
#endif
|
||||||
@@ -225,7 +225,7 @@ void stm32_stram_configure(void);
|
|||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Called from stm32_boardinitialize very early in inialization to setup USB-related
|
* Called from stm32_boardinitialize very early in inialization to setup USB-related
|
||||||
* GPIO pins for the STM32F4Discovery board.
|
* GPIO pins for the Olimex STM32 P407 board.
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
|
|||||||
@@ -69,13 +69,13 @@ void stm32_boardinitialize(void)
|
|||||||
stm32_stram_configure();
|
stm32_stram_configure();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_STM32_OTGFS
|
||||||
/* Initialize USB if the 1) OTG FS controller is in the configuration and 2)
|
/* Initialize USB if the 1) OTG FS controller is in the configuration and 2)
|
||||||
* disabled, and 3) the weak function stm32_usb_configure() has been brought
|
* disabled, and 3) the weak function stm32_usb_configure() has been brought
|
||||||
* into the build. Presumeably either CONFIG_USBDEV or CONFIG_USBHOST is also
|
* into the build. Presumeably either CONFIG_USBDEV or CONFIG_USBHOST is also
|
||||||
* selected.
|
* selected.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef CONFIG_STM32_OTGFS
|
|
||||||
if (stm32_usb_configure)
|
if (stm32_usb_configure)
|
||||||
{
|
{
|
||||||
stm32_usb_configure();
|
stm32_usb_configure();
|
||||||
|
|||||||
@@ -51,6 +51,7 @@
|
|||||||
#include <nuttx/usb/usbhost.h>
|
#include <nuttx/usb/usbhost.h>
|
||||||
#include <nuttx/usb/usbdev_trace.h>
|
#include <nuttx/usb/usbdev_trace.h>
|
||||||
|
|
||||||
|
#include "up_arch.h"
|
||||||
#include "stm32.h"
|
#include "stm32.h"
|
||||||
#include "stm32_otgfs.h"
|
#include "stm32_otgfs.h"
|
||||||
#include "olimex-stm32-p407.h"
|
#include "olimex-stm32-p407.h"
|
||||||
@@ -68,16 +69,12 @@
|
|||||||
# undef HAVE_USB
|
# undef HAVE_USB
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_USBHOST_DEFPRIO
|
#ifndef CONFIG_OLIMEXP407_USBHOST_PRIO
|
||||||
# define CONFIG_USBHOST_DEFPRIO 50
|
# define CONFIG_OLIMEXP407_USBHOST_PRIO 100
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_USBHOST_STACKSIZE
|
#ifndef CONFIG_OLIMEXP407_USBHOST_STACKSIZE
|
||||||
# ifdef CONFIG_USBHOST_HUB
|
# define CONFIG_OLIMEXP407_USBHOST_STACKSIZE 1024
|
||||||
# define CONFIG_USBHOST_STACKSIZE 1536
|
|
||||||
# else
|
|
||||||
# define CONFIG_USBHOST_STACKSIZE 1024
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
@@ -134,21 +131,21 @@ static int usbhost_waiter(int argc, char *argv[])
|
|||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Name: stm32_usbdev_setup
|
* Name: stm32_usb_configure
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Called from stm32_usbdev_setup very early in inialization to setup USB-related
|
* Called from stm32_boardinitialize very early in inialization to setup USB-related
|
||||||
* GPIO pins for the STM32F4Discovery board.
|
* GPIO pins for the Olimex STM32 P407 board.
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
void stm32_usbdev_setup(void)
|
void stm32_usb_configure(void)
|
||||||
{
|
{
|
||||||
|
#ifdef CONFIG_STM32_OTGFS
|
||||||
/* The OTG FS has an internal soft pull-up. No GPIO configuration is required */
|
/* The OTG FS has an internal soft pull-up. No GPIO configuration is required */
|
||||||
|
|
||||||
/* Configure the OTG FS VBUS sensing GPIO, and Power On GPIOs */
|
/* Configure the OTG FS VBUS sensing GPIO, Power On, and Overcurrent GPIOs */
|
||||||
|
|
||||||
#ifdef CONFIG_STM32_OTGFS
|
|
||||||
stm32_configgpio(GPIO_OTGFS_VBUS);
|
stm32_configgpio(GPIO_OTGFS_VBUS);
|
||||||
stm32_configgpio(GPIO_OTGFS_PWRON);
|
stm32_configgpio(GPIO_OTGFS_PWRON);
|
||||||
stm32_configgpio(GPIO_OTGFS_OVER);
|
stm32_configgpio(GPIO_OTGFS_OVER);
|
||||||
@@ -169,9 +166,7 @@ void stm32_usbdev_setup(void)
|
|||||||
int stm32_usbhost_setup(void)
|
int stm32_usbhost_setup(void)
|
||||||
{
|
{
|
||||||
int pid;
|
int pid;
|
||||||
#if defined(CONFIG_USBHOST_HUB) || defined(CONFIG_USBHOST_MSC) || defined(CONFIG_USBHOST_CDCACM)
|
|
||||||
int ret;
|
int ret;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* First, register all of the class drivers needed to support the drivers
|
/* First, register all of the class drivers needed to support the drivers
|
||||||
* that we care about:
|
* that we care about:
|
||||||
@@ -190,7 +185,7 @@ int stm32_usbhost_setup(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_USBHOST_MSC
|
#ifdef CONFIG_USBHOST_MSC
|
||||||
/* Register the USB host Mass Storage Class */
|
/* Register the USB mass storage class class */
|
||||||
|
|
||||||
ret = usbhost_msc_initialize();
|
ret = usbhost_msc_initialize();
|
||||||
if (ret != OK)
|
if (ret != OK)
|
||||||
@@ -209,6 +204,28 @@ int stm32_usbhost_setup(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_USBHOST_HIDKBD
|
||||||
|
/* Initialize the HID keyboard class */
|
||||||
|
|
||||||
|
ret = usbhost_kbdinit();
|
||||||
|
if (ret != OK)
|
||||||
|
{
|
||||||
|
uerr("ERROR: Failed to register the HID keyboard class\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_USBHOST_HIDMOUSE
|
||||||
|
/* Initialize the HID mouse class */
|
||||||
|
|
||||||
|
ret = usbhost_mouse_init();
|
||||||
|
if (ret != OK)
|
||||||
|
{
|
||||||
|
uerr("ERROR: Failed to register the HID mouse class\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
UNUSED(ret);
|
||||||
|
|
||||||
/* Then get an instance of the USB host interface */
|
/* Then get an instance of the USB host interface */
|
||||||
|
|
||||||
uinfo("Initialize USB host\n");
|
uinfo("Initialize USB host\n");
|
||||||
@@ -219,8 +236,8 @@ int stm32_usbhost_setup(void)
|
|||||||
|
|
||||||
uinfo("Start usbhost_waiter\n");
|
uinfo("Start usbhost_waiter\n");
|
||||||
|
|
||||||
pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO,
|
pid = task_create("usbhost", CONFIG_OLIMEXP407_USBHOST_PRIO,
|
||||||
CONFIG_USBHOST_STACKSIZE,
|
CONFIG_OLIMEXP407_USBHOST_STACKSIZE,
|
||||||
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
(main_t)usbhost_waiter, (FAR char * const *)NULL);
|
||||||
return pid < 0 ? -ENOEXEC : OK;
|
return pid < 0 ? -ENOEXEC : OK;
|
||||||
}
|
}
|
||||||
@@ -229,30 +246,6 @@ int stm32_usbhost_setup(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/************************************************************************************
|
|
||||||
* Name: stm32_setup_overcurrent
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Setup to receive an interrupt-level callback if an overcurrent condition is
|
|
||||||
* detected.
|
|
||||||
*
|
|
||||||
* Input Parameter:
|
|
||||||
* handler - New overcurrent interrupt handler
|
|
||||||
* arg - The argument provided for the interrupt handler
|
|
||||||
*
|
|
||||||
* Returned value:
|
|
||||||
* Zero (OK) is returned on success. Otherwise, a negated errno value is returned
|
|
||||||
* to indicate the nature of the failure.
|
|
||||||
*
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_USBHOST
|
|
||||||
int stm32_setup_overcurrent(xcpt_t handler, void *arg)
|
|
||||||
{
|
|
||||||
return stm32_gpiosetevent(GPIO_OTGFS_OVER, true, true, true, handler, arg);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/***********************************************************************************
|
/***********************************************************************************
|
||||||
* Name: stm32_usbhost_vbusdrive
|
* Name: stm32_usbhost_vbusdrive
|
||||||
*
|
*
|
||||||
@@ -299,6 +292,30 @@ void stm32_usbhost_vbusdrive(int iface, bool enable)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Name: stm32_setup_overcurrent
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Setup to receive an interrupt-level callback if an overcurrent condition is
|
||||||
|
* detected.
|
||||||
|
*
|
||||||
|
* Input Parameter:
|
||||||
|
* handler - New overcurrent interrupt handler
|
||||||
|
* arg - The argument provided for the interrupt handler
|
||||||
|
*
|
||||||
|
* Returned value:
|
||||||
|
* Zero (OK) is returned on success. Otherwise, a negated errno value is returned
|
||||||
|
* to indicate the nature of the failure.
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_USBHOST
|
||||||
|
int stm32_setup_overcurrent(xcpt_t handler, void *arg)
|
||||||
|
{
|
||||||
|
return stm32_gpiosetevent(GPIO_OTGFS_OVER, true, true, true, handler, arg);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Name: stm32_usbsuspend
|
* Name: stm32_usbsuspend
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user