Merge branch 'master' of bitbucket.org:nuttx/boards into HEAD
This commit is contained in:
commit
6e24c287f6
@ -5,9 +5,33 @@ The Olimex STM32-H407 configuration is based on
|
||||
stm32Fdiscovery and Olimex STM32-H405.
|
||||
|
||||
The H407 was programmed with ST-LINK/V2 from both Win8.1 and Ubuntu 14.04
|
||||
This release provides baseline for H407 12MHZ clock in include/board.h
|
||||
|
||||
nsh - Only basic shell response tested on USART2
|
||||
|
||||
This realease provides baseline for H407 12MHZ clock in include/board.h
|
||||
Development Environment
|
||||
=======================
|
||||
|
||||
TODO: Update to use mini USB-OTG and USB HOST
|
||||
Either Linux or Cygwin on Windows can be used for the development environment.
|
||||
The source has been built only using the GNU toolchain (see below). Other
|
||||
toolchains will likely cause problems.
|
||||
|
||||
LEDs
|
||||
====
|
||||
|
||||
The H407 board has 1 Status LED;
|
||||
|
||||
SDCard
|
||||
======
|
||||
|
||||
Expects to be plugged in else hangs. TODO: Shouldn't hang.
|
||||
SDIO 4bit with pulls/downs on pins. Doesn't have a SD card detect pin.
|
||||
|
||||
UARTs
|
||||
=====
|
||||
|
||||
On the H407 board, ?? all uarts are available for pin mappings
|
||||
USART2 is typically used for nsh console
|
||||
|
||||
STM32-H407-specific Configuration Options
|
||||
===============================================
|
||||
|
@ -153,11 +153,11 @@
|
||||
|
||||
/* Timers driven from APB2 will be twice PCLK2 */
|
||||
|
||||
#define STM32_APB2_TIM1_CLKIN (2*STM32_PCLK2_FREQUENCY)
|
||||
#define STM32_APB2_TIM8_CLKIN (2*STM32_PCLK2_FREQUENCY)
|
||||
#define STM32_APB2_TIM9_CLKIN (2*STM32_PCLK2_FREQUENCY)
|
||||
#define STM32_APB2_TIM10_CLKIN (2*STM32_PCLK2_FREQUENCY)
|
||||
#define STM32_APB2_TIM11_CLKIN (2*STM32_PCLK2_FREQUENCY)
|
||||
#define STM32_APB2_TIM1_CLKIN (2 * STM32_PCLK2_FREQUENCY)
|
||||
#define STM32_APB2_TIM8_CLKIN (2 * STM32_PCLK2_FREQUENCY)
|
||||
#define STM32_APB2_TIM9_CLKIN (2 * STM32_PCLK2_FREQUENCY)
|
||||
#define STM32_APB2_TIM10_CLKIN (2 * STM32_PCLK2_FREQUENCY)
|
||||
#define STM32_APB2_TIM11_CLKIN (2 * STM32_PCLK2_FREQUENCY)
|
||||
|
||||
/* Timer Frequencies, if APBx is set to 1, frequency is same to APBx
|
||||
* otherwise frequency is 2xAPBx.
|
||||
@ -165,7 +165,37 @@
|
||||
*/
|
||||
|
||||
#define STM32_TIM18_FREQUENCY STM32_HCLK_FREQUENCY
|
||||
#define STM32_TIM27_FREQUENCY STM32_HCLK_FREQUENCY
|
||||
#define STM32_TIM27_FREQUENCY (STM32_HCLK_FREQUENCY / 2)
|
||||
|
||||
/* SDIO dividers. Note that slower clocking is required when DMA is disabled
|
||||
* in order to avoid RX overrun/TX underrun errors due to delayed responses
|
||||
* to service FIFOs in interrupt driven mode. These values have not been
|
||||
* tuned!!!
|
||||
*
|
||||
* SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(118+2)=400 KHz
|
||||
*/
|
||||
|
||||
#define SDIO_INIT_CLKDIV (118 << SDIO_CLKCR_CLKDIV_SHIFT)
|
||||
|
||||
/* DMA ON: SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(1+2)=16 MHz
|
||||
* DMA OFF: SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(2+2)=12 MHz
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_SDIO_DMA
|
||||
# define SDIO_MMCXFR_CLKDIV (1 << SDIO_CLKCR_CLKDIV_SHIFT)
|
||||
#else
|
||||
# define SDIO_MMCXFR_CLKDIV (2 << SDIO_CLKCR_CLKDIV_SHIFT)
|
||||
#endif
|
||||
|
||||
/* DMA ON: SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(1+2)=16 MHz
|
||||
* DMA OFF: SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(2+2)=12 MHz
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_SDIO_DMA
|
||||
# define SDIO_SDXFR_CLKDIV (1 << SDIO_CLKCR_CLKDIV_SHIFT)
|
||||
#else
|
||||
# define SDIO_SDXFR_CLKDIV (2 << SDIO_CLKCR_CLKDIV_SHIFT)
|
||||
#endif
|
||||
|
||||
/* LED definitions ******************************************************************/
|
||||
/* If CONFIG_ARCH_LEDS is not defined, then the user can control the status LED in any
|
||||
@ -179,7 +209,7 @@
|
||||
|
||||
/* LED bits for use with board_userled_all() */
|
||||
|
||||
#define BOARD_LED_STATUS_BIT (1 << BOARD_LED1)
|
||||
#define BOARD_LED_STATUS_BIT (1 << BOARD_LED_STATUS)
|
||||
|
||||
/* If CONFIG_ARCH_LEDs is defined, then NuttX will control the status LED of the
|
||||
* Olimex STM32-H405. The following definitions describe how NuttX controls the LEDs:
|
||||
@ -205,6 +235,7 @@
|
||||
/* Alternate function pin selections ************************************************/
|
||||
|
||||
/* USART3: */
|
||||
|
||||
#if 0
|
||||
#define GPIO_USART3_RX GPIO_USART3_RX_1 /* PB11 */
|
||||
#define GPIO_USART3_TX GPIO_USART3_TX_1 /* PB10 */
|
||||
@ -221,10 +252,21 @@
|
||||
|
||||
/* CAN: */
|
||||
|
||||
#define GPIO_CAN1_RX GPIO_CAN1_RX_2 /* PB8 */
|
||||
#define GPIO_CAN1_TX GPIO_CAN1_TX_2 /* PB9 */
|
||||
#define GPIO_CAN2_RX GPIO_CAN1_RX_2 /* PB5 */
|
||||
#define GPIO_CAN2_TX GPIO_CAN1_TX_2 /* PB6 */
|
||||
#define GPIO_CAN1_RX GPIO_CAN1_RX_2 /* PB8 */
|
||||
#define GPIO_CAN1_TX GPIO_CAN1_TX_2 /* PB9 */
|
||||
#define GPIO_CAN2_RX GPIO_CAN1_RX_2 /* PB5 */
|
||||
#define GPIO_CAN2_TX GPIO_CAN1_TX_2 /* PB6 */
|
||||
|
||||
/* DMA Channl/Stream Selections *****************************************************/
|
||||
/* Stream selections are arbitrary for now but might become important in the future
|
||||
* if we set aside more DMA channels/streams.
|
||||
*
|
||||
* SDIO DMA
|
||||
* DMAMAP_SDIO_1 = Channel 4, Stream 3
|
||||
* DMAMAP_SDIO_2 = Channel 4, Stream 6
|
||||
*/
|
||||
|
||||
#define DMAMAP_SDIO DMAMAP_SDIO_1
|
||||
|
||||
/************************************************************************************
|
||||
* Public Data
|
||||
|
2
configs/olimex-stm32-h407/src/.gitignore
vendored
Normal file
2
configs/olimex-stm32-h407/src/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/.depend
|
||||
/Make.dep
|
@ -36,7 +36,7 @@
|
||||
-include $(TOPDIR)/Make.defs
|
||||
|
||||
ASRCS =
|
||||
CSRCS = stm32_boot.c
|
||||
CSRCS = stm32_boot.c stm32_bringup.c
|
||||
|
||||
ifeq ($(CONFIG_ARCH_LEDS),y)
|
||||
CSRCS += stm32_autoleds.c
|
||||
@ -48,7 +48,7 @@ ifeq ($(CONFIG_ARCH_BUTTONS),y)
|
||||
CSRCS += stm32_buttons.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NSH_LIBRARY),y)
|
||||
ifeq ($(CONFIG_LIB_BOARDCTL),y)
|
||||
CSRCS += stm32_appinit.c
|
||||
endif
|
||||
|
||||
@ -76,6 +76,10 @@ ifeq ($(CONFIG_CAN),y)
|
||||
CSRCS += stm32_can.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_STM32_SDIO),y)
|
||||
CSRCS += stm32_sdio.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ARCH_FPU),y)
|
||||
CSRCS += stm32_ostest.c
|
||||
endif
|
||||
|
@ -47,28 +47,115 @@
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
/* Olimex-STM32-P407 GPIOs ****************************************************/
|
||||
#define HAVE_USBDEV 1
|
||||
#define HAVE_USBHOST 1
|
||||
#define HAVE_USBMONITOR 1
|
||||
#define HAVE_SDIO 1
|
||||
#define HAVE_RTC_DRIVER 1
|
||||
#
|
||||
/* Can't support USB host or device features if USB OTG HS is not enabled */
|
||||
|
||||
#ifndef CONFIG_STM32_OTGHS
|
||||
# undef HAVE_USBDEV
|
||||
# undef HAVE_USBHOST
|
||||
# undef HAVE_USBMONITOR
|
||||
#endif
|
||||
|
||||
/* Can't support USB device monitor if USB device is not enabled */
|
||||
|
||||
#ifndef CONFIG_USBDEV
|
||||
# undef HAVE_USBDEV
|
||||
# undef HAVE_USBMONITOR
|
||||
#endif
|
||||
|
||||
/* Can't support USB host is USB host is not enabled */
|
||||
|
||||
#ifndef CONFIG_USBHOST
|
||||
# undef HAVE_USBHOST
|
||||
#endif
|
||||
|
||||
/* Check if we should enable the USB monitor before starting NSH */
|
||||
|
||||
#if !defined(CONFIG_USBDEV_TRACE) || !defined(CONFIG_SYSTEM_USBMONITOR)
|
||||
# undef HAVE_USBMONITOR
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_STM32_CAN1) && !defined(CONFIG_STM32_CAN2)
|
||||
# undef CONFIG_CAN
|
||||
#endif
|
||||
|
||||
/* Can't support MMC/SD features if mountpoints are disabled or if SDIO support
|
||||
* is not enabled. Can't support MMC/SD features if the upper half MMC/SD SDIO
|
||||
* driver is not enabled.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_STM32_SDIO)
|
||||
# undef HAVE_SDIO
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_MMCSD_SDIO)
|
||||
# undef HAVE_SDIO
|
||||
#endif
|
||||
|
||||
#undef SDIO_MINOR /* Any minor number, default 0 */
|
||||
#define SDIO_SLOTNO 0 /* Only one slot */
|
||||
|
||||
#ifdef HAVE_SDIO
|
||||
|
||||
# if defined(CONFIG_NSH_MMCSDSLOTNO) && CONFIG_NSH_MMCSDSLOTNO != 0
|
||||
# warning Only one MMC/SD slot, slot 0
|
||||
# define CONFIG_NSH_MMCSDSLOTNO SDIO_SLOTNO
|
||||
# endif
|
||||
|
||||
# if defined(CONFIG_NSH_MMCSDMINOR)
|
||||
# define SDIO_MINOR CONFIG_NSH_MMCSDMINOR
|
||||
# else
|
||||
# define SDIO_MINOR 0
|
||||
# endif
|
||||
|
||||
/* SD card bringup does not work if performed on the IDLE thread because it
|
||||
* will cause waiting. Use either:
|
||||
*
|
||||
* CONFIG_LIB_BOARDCTL=y, OR
|
||||
* CONFIG_BOARD_INITIALIZE=y && CONFIG_BOARD_INITTHREAD=y
|
||||
*/
|
||||
|
||||
# if defined(CONFIG_BOARD_INITIALIZE) && !defined(CONFIG_LIB_BOARDCTL) && \
|
||||
!defined(CONFIG_BOARD_INITTHREAD)
|
||||
# warning SDIO initialization cannot be perfomed on the IDLE thread
|
||||
# undef HAVE_SDIO
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Check if we can support the RTC driver */
|
||||
|
||||
#if !defined(CONFIG_RTC) || !defined(CONFIG_RTC_DRIVER)
|
||||
# undef HAVE_RTC_DRIVER
|
||||
#endif
|
||||
|
||||
/* Olimex-STM32-P407 GPIOs **************************************************/
|
||||
/* LEDs */
|
||||
|
||||
#define GPIO_LED_STATUS (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
|
||||
GPIO_OUTPUT_CLEAR|GPIO_PORTC|GPIO_PIN12)
|
||||
#define GPIO_LED_STATUS (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_50MHz | \
|
||||
GPIO_OUTPUT_CLEAR | GPIO_PORTC | GPIO_PIN12)
|
||||
|
||||
/* BUTTONS -- NOTE that all have EXTI interrupts configured */
|
||||
|
||||
#define MIN_IRQBUTTON BUTTON_BUT
|
||||
#define MAX_IRQBUTTON BUTTON_BUT
|
||||
#define NUM_IRQBUTTONS 1
|
||||
#define MIN_IRQBUTTON BUTTON_BUT
|
||||
#define MAX_IRQBUTTON BUTTON_BUT
|
||||
#define NUM_IRQBUTTONS 1
|
||||
|
||||
#define GPIO_BTN_BUT (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTA|GPIO_PIN0)
|
||||
#define GPIO_BTN_BUT (GPIO_INPUT | GPIO_FLOAT | GPIO_EXTI | GPIO_PORTA | \
|
||||
GPIO_PIN0)
|
||||
|
||||
/* USB OTG FS - USB-A connector
|
||||
*
|
||||
* PC4 OTG_FS_VBUS VBUS sensing
|
||||
*/
|
||||
|
||||
//#define GPIO_OTGFS_VBUS (GPIO_INPUT|GPIO_FLOAT|GPIO_PORTC|GPIO_PIN4)
|
||||
//#define GPIO_OTGFS_VBUS (GPIO_INPUT|GPIO_FLOAT|GPIO_PORTC|GPIO_PIN4)
|
||||
#define GPIO_OTGFS_VBUS (GPIO_INPUT | GPIO_FLOAT | GPIO_PORTC | GPIO_PIN4)
|
||||
|
||||
/* USB OTG HS - miniUSB connector
|
||||
*
|
||||
@ -77,62 +164,115 @@
|
||||
* PB5 OTG_HS_Overcurrent
|
||||
*/
|
||||
|
||||
#define GPIO_OTGHS_VBUS (GPIO_INPUT|GPIO_FLOAT|GPIO_SPEED_100MHz|GPIO_OPENDRAIN|GPIO_PORTB|GPIO_PIN13)
|
||||
#define GPIO_OTGHS_PWRON (GPIO_OUTPUT|GPIO_OUTPUT_SET|GPIO_FLOAT|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN8)
|
||||
#define GPIO_OTGHS_VBUS (GPIO_INPUT | GPIO_FLOAT | GPIO_SPEED_100MHz | \
|
||||
GPIO_OPENDRAIN | GPIO_PORTB | GPIO_PIN13)
|
||||
#define GPIO_OTGHS_PWRON (GPIO_OUTPUT | GPIO_OUTPUT_SET | GPIO_FLOAT | \
|
||||
GPIO_SPEED_100MHz | GPIO_PUSHPULL | GPIO_PORTA | GPIO_PIN8)
|
||||
|
||||
#ifdef CONFIG_USBHOST
|
||||
# define GPIO_OTGHS_OVER (GPIO_INPUT|GPIO_EXTI|GPIO_FLOAT|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTB|GPIO_PIN5)
|
||||
# define GPIO_OTGHS_OVER (GPIO_INPUT | GPIO_EXTI | GPIO_FLOAT | \
|
||||
GPIO_SPEED_100MHz | GPIO_PUSHPULL | GPIO_PORTB | \
|
||||
GPIO_PIN5)
|
||||
|
||||
#else
|
||||
# define GPIO_OTGHS_OVER (GPIO_INPUT|GPIO_FLOAT|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTB|GPIO_PIN5)
|
||||
# define GPIO_OTGHS_OVER (GPIO_INPUT | GPIO_FLOAT | GPIO_SPEED_100MHz | \
|
||||
GPIO_PUSHPULL | GPIO_PORTB | GPIO_PIN5)
|
||||
#endif
|
||||
|
||||
/****************************************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************************************/
|
||||
/* MicroSD SDIO
|
||||
*
|
||||
* ---------- -------- ------- ---------------------------
|
||||
* PIO SIGNAL Pulled Comments
|
||||
* ---------- -------- ------- -----------------------
|
||||
* -- NCD Card detect, combined with pins settings CD/PC11
|
||||
* PC9 DAT1 UP 33K Also interrupt
|
||||
* PC8 DAT0 UP 33K " " "" " "
|
||||
* PC12 CLK ---- " " "" " "
|
||||
* PD2 CMD UP 33K " " "" " "
|
||||
* PC11 CD/DAT3 DOWN 1M " " "" " "
|
||||
* PC10 DAT2 UP 33K Also Read wait operation
|
||||
* -- WrProtect Not Supported
|
||||
* ---------- -------- ------- ----------------------
|
||||
*/
|
||||
|
||||
/****************************************************************************************************
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public data
|
||||
****************************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: stm32_bringup
|
||||
*
|
||||
* Description:
|
||||
* Perform architecture specific initialization
|
||||
*
|
||||
* CONFIG_LIB_BOARDCTL=y:
|
||||
* If CONFIG_NSH_ARCHINITIALIZE=y:
|
||||
* Called from the NSH library (or other application)
|
||||
* Otherse, assumed to be called from some other application.
|
||||
*
|
||||
* Otherwise CONFIG_BOARD_INITIALIZE=y:
|
||||
* Called from board_initialize().
|
||||
*
|
||||
* Otherise, bad news: Never called
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_bringup(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_sdio_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize SDIO-based MMC/SD card support
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(HAVE_SDIO)
|
||||
int stm32_sdio_initialize(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_usbinitialize
|
||||
*
|
||||
* Description:
|
||||
* Called from stm32_usbinitialize very early in initialization to setup USB-related
|
||||
* GPIO pins for the Olimex-STM32-H405 board.
|
||||
* Called from stm32_usbinitialize very early in initialization to setup
|
||||
* USB-related GPIO pins for the Olimex-STM32-H405 board.
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_STM32_OTGFS) || defined(CONFIG_STM32_OTGHS)
|
||||
void weak_function stm32_usbinitialize(void);
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: stm32_adc_initialize
|
||||
*
|
||||
* Description:
|
||||
* Called at application startup time to initialize the ADC functionality.
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ADC
|
||||
int stm32_adc_initialize(void);
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Name: stm32_can_initialize
|
||||
*
|
||||
* Description:
|
||||
* Called at application startup time to initialize the CAN functionality.
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_CAN) && (defined(CONFIG_STM32_CAN1) || defined(CONFIG_STM32_CAN2))
|
||||
int stm32_can_initialize(void);
|
||||
|
@ -57,47 +57,12 @@
|
||||
#include "stm32.h"
|
||||
#include "olimex-stm32-h407.h"
|
||||
|
||||
#ifdef CONFIG_LIB_BOARDCTL
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
#define HAVE_USBDEV 1
|
||||
#define HAVE_USBHOST 1
|
||||
#define HAVE_USBMONITOR 1
|
||||
|
||||
/* Can't support USB host or device features if USB OTG HS is not enabled */
|
||||
|
||||
#ifndef CONFIG_STM32_OTGHS
|
||||
# undef HAVE_USBDEV
|
||||
# undef HAVE_USBHOST
|
||||
# undef HAVE_USBMONITOR
|
||||
#endif
|
||||
|
||||
/* Can't support USB device monitor if USB device is not enabled */
|
||||
|
||||
#ifndef CONFIG_USBDEV
|
||||
# undef HAVE_USBDEV
|
||||
# undef HAVE_USBMONITOR
|
||||
#endif
|
||||
|
||||
/* Can't support USB host is USB host is not enabled */
|
||||
|
||||
#ifndef CONFIG_USBHOST
|
||||
# undef HAVE_USBHOST
|
||||
#endif
|
||||
|
||||
/* Check if we should enable the USB monitor before starting NSH */
|
||||
|
||||
#if !defined(CONFIG_USBDEV_TRACE) || !defined(CONFIG_SYSTEM_USBMONITOR)
|
||||
# undef HAVE_USBMONITOR
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_STM32_CAN1) && !defined(CONFIG_STM32_CAN2)
|
||||
# undef CONFIG_CAN
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -108,63 +73,16 @@
|
||||
* Description:
|
||||
* Perform architecture specific initialization
|
||||
*
|
||||
* CONFIG_LIB_BOARDCTL=y :
|
||||
* Called from the NSH library
|
||||
*
|
||||
* CONFIG_BOARD_INITIALIZE=y, CONFIG_NSH_LIBRARY=y, &&
|
||||
* CONFIG_LIB_BOARDCTL=n :
|
||||
* Called from board_initialize().
|
||||
* CONFIG_LIB_BOARDCTL=y:
|
||||
* If CONFIG_NSH_ARCHINITIALIZE=y:
|
||||
* Called from the NSH library (or other application)
|
||||
* Otherse, assumed to be called from some other application.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_app_initialize(void)
|
||||
{
|
||||
#if defined(CONFIG_CAN) || defined(CONFIG_ADC)
|
||||
int ret;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CAN
|
||||
/* Configure on-board CAN if CAN support has been selected. */
|
||||
|
||||
ret = stm32_can_initialize();
|
||||
if (ret != OK)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to initialize CAN: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ADC
|
||||
/* Configure on-board ADCs if ADC support has been selected. */
|
||||
|
||||
ret = stm32_adc_initialize();
|
||||
if (ret != OK)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to initialize ADC: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_USBHOST
|
||||
/* Initialize USB host operation. stm32_usbhost_initialize() starts a thread
|
||||
* will monitor for USB connection and disconnection events.
|
||||
*/
|
||||
|
||||
ret = stm32_usbhost_initialize();
|
||||
if (ret != OK)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to initialize USB host: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_USBMONITOR
|
||||
/* Start the USB Monitor */
|
||||
|
||||
ret = usbmonitor_start(0, NULL);
|
||||
if (ret != OK)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to start USB monitor: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
return stm32_bringup();
|
||||
}
|
||||
|
||||
#endif /* CONFIG_LIB_BOARDCTL */
|
||||
|
@ -106,13 +106,14 @@ void stm32_boardinitialize(void)
|
||||
#ifdef CONFIG_BOARD_INITIALIZE
|
||||
void board_initialize(void)
|
||||
{
|
||||
#if defined(CONFIG_NSH_LIBRARY) && !defined(CONFIG_LIB_BOARDCTL)
|
||||
/* Perform NSH initialization here instead of from the NSH. This
|
||||
* alternative NSH initialization is necessary when NSH is ran in user-space
|
||||
* but the initialization function must run in kernel space.
|
||||
#ifndef CONFIG_LIB_BOARDCTL
|
||||
/* Perform NSH initialization here instead of from the board_app_initialize.
|
||||
* If CONFIG_LIB_BOARDCTL=y we assume that come application will perform
|
||||
* the initialization by calling board_app_initialize indirectly through
|
||||
* boardctl().
|
||||
*/
|
||||
|
||||
board_app_initialize();
|
||||
stm32_bringup();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
190
configs/olimex-stm32-h407/src/stm32_bringup.c
Normal file
190
configs/olimex-stm32-h407/src/stm32_bringup.c
Normal file
@ -0,0 +1,190 @@
|
||||
/****************************************************************************
|
||||
* config/olimex-stm32-h407/src/stm32_bringup.c
|
||||
*
|
||||
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <syslog.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
|
||||
#ifdef CONFIG_SYSTEM_USBMONITOR
|
||||
# include <apps/usbmonitor.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32_OTGFS
|
||||
# include "stm32_usbhost.h"
|
||||
#endif
|
||||
|
||||
#include "stm32.h"
|
||||
#include "olimex-stm32-h407.h"
|
||||
|
||||
/* Conditional logic in olimex-stm32-h407.h will determine if certain features
|
||||
* are supported. Tests for these features need to be made after including
|
||||
* olimex-stm32-h407.h.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_RTC_DRIVER
|
||||
# include <nuttx/timers/rtc.h>
|
||||
# include "stm32_rtc.h"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_bringup
|
||||
*
|
||||
* Description:
|
||||
* Perform architecture specific initialization
|
||||
*
|
||||
* CONFIG_LIB_BOARDCTL=y:
|
||||
* If CONFIG_NSH_ARCHINITIALIZE=y:
|
||||
* Called from the NSH library (or other application)
|
||||
* Otherse, assumed to be called from some other application.
|
||||
*
|
||||
* Otherwise CONFIG_BOARD_INITIALIZE=y:
|
||||
* Called from board_initialize().
|
||||
*
|
||||
* Otherise, bad news: Never called
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_bringup(void)
|
||||
{
|
||||
#ifdef HAVE_RTC_DRIVER
|
||||
FAR struct rtc_lowerhalf_s *lower;
|
||||
#endif
|
||||
#if defined(CONFIG_CAN) || defined(CONFIG_ADC) || defined(HAVE_SDIO) || \
|
||||
defined(HAVE_RTC_DRIVER)
|
||||
int ret;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CAN
|
||||
/* Configure on-board CAN if CAN support has been selected. */
|
||||
|
||||
ret = stm32_can_initialize();
|
||||
if (ret != OK)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"ERROR: Failed to initialize CAN: %d\n",
|
||||
ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ADC
|
||||
/* Configure on-board ADCs if ADC support has been selected. */
|
||||
|
||||
ret = stm32_adc_initialize();
|
||||
if (ret != OK)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"ERROR: Failed to initialize ADC: %d\n",
|
||||
ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SDIO
|
||||
/* Initialize the SDIO block driver */
|
||||
|
||||
ret = stm32_sdio_initialize();
|
||||
if (ret != OK)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"ERROR: Failed to initialize MMC/SD driver: %d\n",
|
||||
ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_USBHOST
|
||||
/* Initialize USB host operation. stm32_usbhost_initialize() starts a thread
|
||||
* will monitor for USB connection and disconnection events.
|
||||
*/
|
||||
|
||||
ret = stm32_usbhost_initialize();
|
||||
if (ret != OK)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"ERROR: Failed to initialize USB host: %d\n",
|
||||
ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_USBMONITOR
|
||||
/* Start the USB Monitor */
|
||||
|
||||
ret = usbmonitor_start(0, NULL);
|
||||
if (ret != OK)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"ERROR: Failed to start USB monitor: %d\n",
|
||||
ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_RTC_DRIVER
|
||||
/* Instantiate the STM32 lower-half RTC driver */
|
||||
|
||||
lower = stm32_rtc_lowerhalf();
|
||||
if (!lower)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"ERROR: Failed to instantiate the RTC lower-half driver\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Bind the lower half driver and register the combined RTC driver
|
||||
* as /dev/rtc0
|
||||
*/
|
||||
|
||||
ret = rtc_initialize(0, lower);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"ERROR: Failed to bind/register the RTC driver: %d\n",
|
||||
ret);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
175
configs/olimex-stm32-h407/src/stm32_sdio.c
Normal file
175
configs/olimex-stm32-h407/src/stm32_sdio.c
Normal file
@ -0,0 +1,175 @@
|
||||
/****************************************************************************
|
||||
* config/olimex-stm32_h407/src/stm32_sdio.c
|
||||
*
|
||||
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/sdio.h>
|
||||
#include <nuttx/mmcsd.h>
|
||||
|
||||
#include "stm32.h"
|
||||
#include "olimex-stm32-h407.h"
|
||||
|
||||
#ifdef HAVE_SDIO
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
/* Card detections requires card support and a card detection GPIO */
|
||||
|
||||
#define HAVE_NCD 1
|
||||
#if !defined(HAVE_SDIO) || !defined(GPIO_SDIO_NCD)
|
||||
# undef HAVE_NCD
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static FAR struct sdio_dev_s *g_sdio_dev;
|
||||
#ifdef HAVE_NCD
|
||||
static bool g_sd_inserted = 0xff; /* Impossible value */
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_ncd_interrupt
|
||||
*
|
||||
* Description:
|
||||
* Card detect interrupt handler.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_NCD
|
||||
static int stm32_ncd_interrupt(int irq, FAR void *context)
|
||||
{
|
||||
bool present;
|
||||
|
||||
present = !stm32_gpioread(GPIO_SDIO_NCD);
|
||||
if (present != g_sd_inserted)
|
||||
{
|
||||
sdio_mediachange(g_sdio_dev, present);
|
||||
g_sd_inserted = present;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_sdio_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize SDIO-based MMC/SD card support
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_sdio_initialize(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
#ifdef HAVE_NCD
|
||||
/* Card detect */
|
||||
|
||||
bool cd_status;
|
||||
|
||||
/* Configure the card detect GPIO */
|
||||
|
||||
stm32_configgpio(GPIO_SDIO_NCD);
|
||||
|
||||
/* Register an interrupt handler for the card detect pin */
|
||||
|
||||
stm32_gpiosetevent(GPIO_SDIO_NCD, true, true, true, stm32_ncd_interrupt);
|
||||
#endif
|
||||
|
||||
/* Mount the SDIO-based MMC/SD block driver */
|
||||
/* First, get an instance of the SDIO interface */
|
||||
|
||||
fvdbg("Initializing SDIO slot %d\n", SDIO_SLOTNO);
|
||||
|
||||
g_sdio_dev = sdio_initialize(SDIO_SLOTNO);
|
||||
if (!g_sdio_dev)
|
||||
{
|
||||
fdbg("Failed to initialize SDIO slot %d\n", SDIO_SLOTNO);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Now bind the SDIO interface to the MMC/SD driver */
|
||||
|
||||
fvdbg("Bind SDIO to the MMC/SD driver, minor=%d\n", SDIO_MINOR);
|
||||
|
||||
ret = mmcsd_slotinitialize(SDIO_MINOR, g_sdio_dev);
|
||||
if (ret != OK)
|
||||
{
|
||||
fdbg("Failed to bind SDIO to the MMC/SD driver: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
fvdbg("Successfully bound SDIO to the MMC/SD driver\n");
|
||||
|
||||
#ifdef HAVE_NCD
|
||||
/* Use SD card detect pin to check if a card is g_sd_inserted */
|
||||
|
||||
cd_status = !stm32_gpioread(GPIO_SDIO_NCD);
|
||||
fvdbg("Card detect : %d\n", cd_status);
|
||||
|
||||
sdio_mediachange(g_sdio_dev, cd_status);
|
||||
#else
|
||||
/* Assume that the SD card is inserted. What choice do we have? */
|
||||
|
||||
sdio_mediachange(g_sdio_dev, true);
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
#endif /* HAVE_SDIO */
|
Loading…
Reference in New Issue
Block a user