mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
STM32F4Discovery: Add support for the microSD card slot on the STM32F4DIS-BB base board
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/************************************************************************************
|
|
||||||
* configs/stm3240g-eval/include/board.h
|
* configs/stm3240g-eval/include/board.h
|
||||||
* include/arch/board/board.h
|
* include/arch/board/board.h
|
||||||
*
|
*
|
||||||
@@ -444,7 +444,7 @@
|
|||||||
|
|
||||||
/* DMA Channl/Stream Selections *****************************************************/
|
/* DMA Channl/Stream Selections *****************************************************/
|
||||||
/* Stream selections are arbitrary for now but might become important in the future
|
/* Stream selections are arbitrary for now but might become important in the future
|
||||||
* is we set aside more DMA channels/streams.
|
* if we set aside more DMA channels/streams.
|
||||||
*
|
*
|
||||||
* SDIO DMA
|
* SDIO DMA
|
||||||
* DMAMAP_SDIO_1 = Channel 4, Stream 3
|
* DMAMAP_SDIO_1 = Channel 4, Stream 3
|
||||||
|
|||||||
@@ -1261,6 +1261,34 @@ Where <subdir> is one of the following:
|
|||||||
and RJ5 network connector. Support is enabled for ICMP, TCP/IP,
|
and RJ5 network connector. Support is enabled for ICMP, TCP/IP,
|
||||||
UDP, and ARP.
|
UDP, and ARP.
|
||||||
|
|
||||||
|
3. SD card support is enabled. The STM32F4DIS-BB has an on-board
|
||||||
|
microSD slot that should be automatically registered as the block
|
||||||
|
device /dev/mmcsd0 when an SD card is present. The SD card can
|
||||||
|
then be mounted by the NSH command:
|
||||||
|
|
||||||
|
nsh> mount -t /dev/mmcsd0 /mnt/sdcard
|
||||||
|
|
||||||
|
4. CCM memory is not included in the heap in this configuration. That
|
||||||
|
is because the SD card uses DMA and if DMA memory is allocated from
|
||||||
|
the CCM memory, the DMA will failure. This is an STM32 hardware
|
||||||
|
limitation.
|
||||||
|
|
||||||
|
If you want to get the CCM memory back in the heap, then you can
|
||||||
|
|
||||||
|
a) Disable microSD support (and DMAC2 which is then no longer
|
||||||
|
needed). If you reduce the clocking by a huge amount, it might
|
||||||
|
be possible to use microSD without DMA. This, however, may
|
||||||
|
not be possible.
|
||||||
|
b) Develop a strategy to manage CCM memory and DMA memory. Look
|
||||||
|
at this discussion on the NuttX Wiki:
|
||||||
|
http://www.nuttx.org/doku.php?id=wiki:howtos:stm32-ccm-alloc
|
||||||
|
|
||||||
|
To put the CCM memory back into the heap you would need to change
|
||||||
|
the following in the NuttX configuration:
|
||||||
|
|
||||||
|
CONFIG_STM32_CCMEXCLUDE=n : Don't exclude CCM memory from the heap
|
||||||
|
CONFIG_MM_REGIONS=2 : With CCM, there will be two memory regions
|
||||||
|
|
||||||
nsh:
|
nsh:
|
||||||
---
|
---
|
||||||
Configures the NuttShell (nsh) located at apps/examples/nsh. The
|
Configures the NuttShell (nsh) located at apps/examples/nsh. The
|
||||||
|
|||||||
@@ -156,6 +156,36 @@
|
|||||||
#define STM32_TIM18_FREQUENCY STM32_HCLK_FREQUENCY
|
#define STM32_TIM18_FREQUENCY STM32_HCLK_FREQUENCY
|
||||||
#define STM32_TIM27_FREQUENCY (STM32_HCLK_FREQUENCY/2)
|
#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 ******************************************************************/
|
/* LED definitions ******************************************************************/
|
||||||
/* If CONFIG_ARCH_LEDS is not defined, then the user can control the LEDs in any
|
/* If CONFIG_ARCH_LEDS is not defined, then the user can control the LEDs in any
|
||||||
* way. The following definitions are used to access individual LEDs.
|
* way. The following definitions are used to access individual LEDs.
|
||||||
@@ -276,6 +306,17 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* 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
|
* Public Data
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|||||||
@@ -121,6 +121,9 @@ CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y
|
|||||||
# CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW is not set
|
# CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW is not set
|
||||||
# CONFIG_ARMV7M_TOOLCHAIN_RAISONANCE is not set
|
# CONFIG_ARMV7M_TOOLCHAIN_RAISONANCE is not set
|
||||||
# CONFIG_SERIAL_TERMIOS is not set
|
# CONFIG_SERIAL_TERMIOS is not set
|
||||||
|
CONFIG_SDIO_DMA=y
|
||||||
|
CONFIG_SDIO_DMAPRIO=0x00010000
|
||||||
|
# CONFIG_SDIO_WIDTH_D1_ONLY is not set
|
||||||
# CONFIG_NET_MULTICAST is not set
|
# CONFIG_NET_MULTICAST is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -270,7 +273,7 @@ CONFIG_STM32_HAVE_ETHMAC=y
|
|||||||
# CONFIG_STM32_CRC is not set
|
# CONFIG_STM32_CRC is not set
|
||||||
# CONFIG_STM32_CRYP is not set
|
# CONFIG_STM32_CRYP is not set
|
||||||
# CONFIG_STM32_DMA1 is not set
|
# CONFIG_STM32_DMA1 is not set
|
||||||
# CONFIG_STM32_DMA2 is not set
|
CONFIG_STM32_DMA2=y
|
||||||
# CONFIG_STM32_DAC1 is not set
|
# CONFIG_STM32_DAC1 is not set
|
||||||
# CONFIG_STM32_DAC2 is not set
|
# CONFIG_STM32_DAC2 is not set
|
||||||
# CONFIG_STM32_DCMI is not set
|
# CONFIG_STM32_DCMI is not set
|
||||||
@@ -284,7 +287,7 @@ CONFIG_STM32_ETHMAC=y
|
|||||||
# CONFIG_STM32_OTGHS is not set
|
# CONFIG_STM32_OTGHS is not set
|
||||||
CONFIG_STM32_PWR=y
|
CONFIG_STM32_PWR=y
|
||||||
# CONFIG_STM32_RNG is not set
|
# CONFIG_STM32_RNG is not set
|
||||||
# CONFIG_STM32_SDIO is not set
|
CONFIG_STM32_SDIO=y
|
||||||
CONFIG_STM32_SPI1=y
|
CONFIG_STM32_SPI1=y
|
||||||
# CONFIG_STM32_SPI2 is not set
|
# CONFIG_STM32_SPI2 is not set
|
||||||
# CONFIG_STM32_SPI3 is not set
|
# CONFIG_STM32_SPI3 is not set
|
||||||
@@ -324,13 +327,15 @@ CONFIG_STM32_JTAG_SW_ENABLE=y
|
|||||||
# CONFIG_STM32_DISABLE_IDLE_SLEEP_DURING_DEBUG is not set
|
# CONFIG_STM32_DISABLE_IDLE_SLEEP_DURING_DEBUG is not set
|
||||||
# CONFIG_STM32_FORCEPOWER is not set
|
# CONFIG_STM32_FORCEPOWER is not set
|
||||||
# CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG is not set
|
# CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG is not set
|
||||||
# CONFIG_STM32_CCMEXCLUDE is not set
|
CONFIG_STM32_CCMEXCLUDE=y
|
||||||
|
CONFIG_STM32_DMACAPABLE=y
|
||||||
CONFIG_STM32_USART=y
|
CONFIG_STM32_USART=y
|
||||||
|
|
||||||
#
|
#
|
||||||
# U[S]ART Configuration
|
# U[S]ART Configuration
|
||||||
#
|
#
|
||||||
# CONFIG_USART6_RS485 is not set
|
# CONFIG_USART6_RS485 is not set
|
||||||
|
# CONFIG_USART6_RXDMA is not set
|
||||||
# CONFIG_SERIAL_DISABLE_REORDERING is not set
|
# CONFIG_SERIAL_DISABLE_REORDERING is not set
|
||||||
# CONFIG_STM32_USART_SINGLEWIRE is not set
|
# CONFIG_STM32_USART_SINGLEWIRE is not set
|
||||||
|
|
||||||
@@ -340,6 +345,10 @@ CONFIG_STM32_USART=y
|
|||||||
# CONFIG_STM32_SPI_INTERRUPTS is not set
|
# CONFIG_STM32_SPI_INTERRUPTS is not set
|
||||||
# CONFIG_STM32_SPI_DMA is not set
|
# CONFIG_STM32_SPI_DMA is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# SDIO Configuration
|
||||||
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
# Ethernet MAC configuration
|
# Ethernet MAC configuration
|
||||||
#
|
#
|
||||||
@@ -373,7 +382,7 @@ CONFIG_STM32_RMII_EXTCLK=y
|
|||||||
#
|
#
|
||||||
# CONFIG_ARCH_NOINTC is not set
|
# CONFIG_ARCH_NOINTC is not set
|
||||||
# CONFIG_ARCH_VECNOTIRQ is not set
|
# CONFIG_ARCH_VECNOTIRQ is not set
|
||||||
# CONFIG_ARCH_DMA is not set
|
CONFIG_ARCH_DMA=y
|
||||||
CONFIG_ARCH_HAVE_IRQPRIO=y
|
CONFIG_ARCH_HAVE_IRQPRIO=y
|
||||||
# CONFIG_ARCH_L2CACHE is not set
|
# CONFIG_ARCH_L2CACHE is not set
|
||||||
# CONFIG_ARCH_HAVE_COHERENT_DCACHE is not set
|
# CONFIG_ARCH_HAVE_COHERENT_DCACHE is not set
|
||||||
@@ -441,6 +450,7 @@ CONFIG_ARCH_BUTTONS=y
|
|||||||
CONFIG_ARCH_HAVE_IRQBUTTONS=y
|
CONFIG_ARCH_HAVE_IRQBUTTONS=y
|
||||||
# CONFIG_ARCH_IRQBUTTONS is not set
|
# CONFIG_ARCH_IRQBUTTONS is not set
|
||||||
CONFIG_NSH_MMCSDMINOR=0
|
CONFIG_NSH_MMCSDMINOR=0
|
||||||
|
CONFIG_NSH_MMCSDSLOTNO=0
|
||||||
|
|
||||||
#
|
#
|
||||||
# Board-Specific Options
|
# Board-Specific Options
|
||||||
@@ -576,7 +586,18 @@ CONFIG_SPI_EXCHANGE=y
|
|||||||
# CONFIG_BCH is not set
|
# CONFIG_BCH is not set
|
||||||
# CONFIG_INPUT is not set
|
# CONFIG_INPUT is not set
|
||||||
# CONFIG_LCD is not set
|
# CONFIG_LCD is not set
|
||||||
# CONFIG_MMCSD is not set
|
CONFIG_MMCSD=y
|
||||||
|
CONFIG_MMCSD_NSLOTS=1
|
||||||
|
# CONFIG_MMCSD_READONLY is not set
|
||||||
|
CONFIG_MMCSD_MULTIBLOCK_DISABLE=y
|
||||||
|
# CONFIG_MMCSD_MMCSUPPORT is not set
|
||||||
|
CONFIG_MMCSD_HAVECARDDETECT=y
|
||||||
|
# CONFIG_MMCSD_SPI is not set
|
||||||
|
CONFIG_ARCH_HAVE_SDIO=y
|
||||||
|
CONFIG_MMCSD_SDIO=y
|
||||||
|
CONFIG_SDIO_PREFLIGHT=y
|
||||||
|
# CONFIG_SDIO_MUXBUS is not set
|
||||||
|
# CONFIG_SDIO_BLOCKSETUP is not set
|
||||||
# CONFIG_MTD is not set
|
# CONFIG_MTD is not set
|
||||||
CONFIG_NETDEVICES=y
|
CONFIG_NETDEVICES=y
|
||||||
|
|
||||||
@@ -783,10 +804,15 @@ CONFIG_NET_ETHERNET=y
|
|||||||
# CONFIG_DISABLE_MOUNTPOINT is not set
|
# CONFIG_DISABLE_MOUNTPOINT is not set
|
||||||
# CONFIG_FS_AUTOMOUNTER is not set
|
# CONFIG_FS_AUTOMOUNTER is not set
|
||||||
# CONFIG_DISABLE_PSEUDOFS_OPERATIONS is not set
|
# CONFIG_DISABLE_PSEUDOFS_OPERATIONS is not set
|
||||||
# CONFIG_FS_READABLE is not set
|
CONFIG_FS_READABLE=y
|
||||||
# CONFIG_FS_WRITABLE is not set
|
CONFIG_FS_WRITABLE=y
|
||||||
# CONFIG_FS_RAMMAP is not set
|
# CONFIG_FS_RAMMAP is not set
|
||||||
# CONFIG_FS_FAT is not set
|
CONFIG_FS_FAT=y
|
||||||
|
CONFIG_FAT_LCNAMES=y
|
||||||
|
CONFIG_FAT_LFN=y
|
||||||
|
CONFIG_FAT_MAXFNAME=32
|
||||||
|
# CONFIG_FS_FATTIME is not set
|
||||||
|
# CONFIG_FAT_DMAMEMORY is not set
|
||||||
# CONFIG_NFS is not set
|
# CONFIG_NFS is not set
|
||||||
# CONFIG_FS_NXFFS is not set
|
# CONFIG_FS_NXFFS is not set
|
||||||
# CONFIG_FS_ROMFS is not set
|
# CONFIG_FS_ROMFS is not set
|
||||||
@@ -809,7 +835,7 @@ CONFIG_NET_ETHERNET=y
|
|||||||
# Memory Management
|
# Memory Management
|
||||||
#
|
#
|
||||||
# CONFIG_MM_SMALL is not set
|
# CONFIG_MM_SMALL is not set
|
||||||
CONFIG_MM_REGIONS=2
|
CONFIG_MM_REGIONS=1
|
||||||
# CONFIG_ARCH_HAVE_HEAP2 is not set
|
# CONFIG_ARCH_HAVE_HEAP2 is not set
|
||||||
# CONFIG_GRAN is not set
|
# CONFIG_GRAN is not set
|
||||||
|
|
||||||
@@ -1039,6 +1065,7 @@ CONFIG_NSH_BUILTIN_APPS=y
|
|||||||
# CONFIG_NSH_DISABLE_LS is not set
|
# CONFIG_NSH_DISABLE_LS is not set
|
||||||
# CONFIG_NSH_DISABLE_MB is not set
|
# CONFIG_NSH_DISABLE_MB is not set
|
||||||
# CONFIG_NSH_DISABLE_MKDIR is not set
|
# CONFIG_NSH_DISABLE_MKDIR is not set
|
||||||
|
# CONFIG_NSH_DISABLE_MKFATFS is not set
|
||||||
# CONFIG_NSH_DISABLE_MKFIFO is not set
|
# CONFIG_NSH_DISABLE_MKFIFO is not set
|
||||||
# CONFIG_NSH_DISABLE_MKRD is not set
|
# CONFIG_NSH_DISABLE_MKRD is not set
|
||||||
# CONFIG_NSH_DISABLE_MH is not set
|
# CONFIG_NSH_DISABLE_MH is not set
|
||||||
@@ -1079,7 +1106,7 @@ CONFIG_NSH_FILEIOSIZE=512
|
|||||||
# Console Configuration
|
# Console Configuration
|
||||||
#
|
#
|
||||||
CONFIG_NSH_CONSOLE=y
|
CONFIG_NSH_CONSOLE=y
|
||||||
# CONFIG_NSH_ARCHINIT is not set
|
CONFIG_NSH_ARCHINIT=y
|
||||||
|
|
||||||
#
|
#
|
||||||
# Networking Configuration
|
# Networking Configuration
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ CFLAGS += -I$(TOPDIR)/sched
|
|||||||
ASRCS =
|
ASRCS =
|
||||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||||
|
|
||||||
CSRCS = stm32_boot.c stm32_spi.c
|
CSRCS = stm32_boot.c stm32_bringup.c stm32_spi.c
|
||||||
|
|
||||||
ifeq ($(CONFIG_HAVE_CXX),y)
|
ifeq ($(CONFIG_HAVE_CXX),y)
|
||||||
CSRCS += stm32_cxxinitialize.c
|
CSRCS += stm32_cxxinitialize.c
|
||||||
@@ -60,6 +60,10 @@ ifeq ($(CONFIG_STM32_OTGFS),y)
|
|||||||
CSRCS += stm32_usb.c
|
CSRCS += stm32_usb.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_STM32_SDIO),y)
|
||||||
|
CSRCS += stm32_sdio.c
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_PWM),y)
|
ifeq ($(CONFIG_PWM),y)
|
||||||
CSRCS += stm32_pwm.c
|
CSRCS += stm32_pwm.c
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -117,14 +117,8 @@ void stm32_boardinitialize(void)
|
|||||||
#ifdef CONFIG_BOARD_INITIALIZE
|
#ifdef CONFIG_BOARD_INITIALIZE
|
||||||
void board_initialize(void)
|
void board_initialize(void)
|
||||||
{
|
{
|
||||||
/* Perform NSH initialization here instead of from the NSH. This
|
/* Perform board-specific initialization */
|
||||||
* alternative NSH initialization is necessary when NSH is ran in user-space
|
|
||||||
* but the initialization function must run in kernel space.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(CONFIG_NSH_LIBRARY) && !defined(CONFIG_NSH_ARCHINIT)
|
(void)stm32_bringup();
|
||||||
(void)nsh_archinitialize();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,119 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* config/stm32f4discovery/src/stm32_bringup.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012, 2014 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>
|
||||||
|
|
||||||
|
#ifdef CONFIG_SYSTEM_USBMONITOR
|
||||||
|
# include <apps/usbmonitor.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_STM32_OTGFS
|
||||||
|
# include "stm32_usbhost.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "stm32.h"
|
||||||
|
#include "stm32f4discovery.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-Processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: stm32_bringup
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Perform architecture-specific initialization
|
||||||
|
*
|
||||||
|
* CONFIG_BOARD_INITIALIZE=y :
|
||||||
|
* Called from board_initialize().
|
||||||
|
*
|
||||||
|
* CONFIG_BOARD_INITIALIZE=n && CONFIG_NSH_ARCHINIT=y :
|
||||||
|
* Called from the NSH library
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int stm32_bringup(void)
|
||||||
|
{
|
||||||
|
int ret = OK;
|
||||||
|
|
||||||
|
#ifdef HAVE_SDIO
|
||||||
|
/* Initialize the SDIO block driver */
|
||||||
|
|
||||||
|
ret = stm32_sdio_initialize();
|
||||||
|
if (ret != OK)
|
||||||
|
{
|
||||||
|
fdbg("Failed to initialize MMC/SD driver: %d\n", ret);
|
||||||
|
return 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)
|
||||||
|
{
|
||||||
|
udbg("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)
|
||||||
|
{
|
||||||
|
udbg("Start USB monitor: %d\n", ret);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* config/stm32f4discovery/src/stm32_nsh.c
|
* config/stm32f4discovery/src/stm32_nsh.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -39,73 +39,14 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <debug.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#ifdef CONFIG_SYSTEM_USBMONITOR
|
|
||||||
# include <apps/usbmonitor.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_STM32_OTGFS
|
|
||||||
# include "stm32_usbhost.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "stm32.h"
|
|
||||||
#include "stm32f4discovery.h"
|
#include "stm32f4discovery.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-Processor Definitions
|
* Pre-Processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* Configuration ************************************************************/
|
#ifndef OK
|
||||||
|
# define OK 0
|
||||||
#define HAVE_USBDEV 1
|
|
||||||
#define HAVE_USBHOST 1
|
|
||||||
#define HAVE_USBMONITOR 1
|
|
||||||
|
|
||||||
/* 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
|
|
||||||
# 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
|
|
||||||
|
|
||||||
/* Debug ********************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_CPP_HAVE_VARARGS
|
|
||||||
# if defined(CONFIG_DEBUG) || !defined(CONFIG_NSH_ARCHINIT)
|
|
||||||
# define message(...) lowsyslog(__VA_ARGS__)
|
|
||||||
# else
|
|
||||||
# define message(...) printf(__VA_ARGS__)
|
|
||||||
# endif
|
|
||||||
#else
|
|
||||||
# if defined(CONFIG_DEBUG) || !defined(CONFIG_NSH_ARCHINIT)
|
|
||||||
# define message lowsyslog
|
|
||||||
# else
|
|
||||||
# define message printf
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -116,44 +57,17 @@
|
|||||||
* Name: nsh_archinitialize
|
* Name: nsh_archinitialize
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Perform architecture specific initialization
|
* Perform architecture-specific initialization (if this was not already
|
||||||
*
|
* done by board_initialize();
|
||||||
* CONFIG_NSH_ARCHINIT=y :
|
|
||||||
* Called from the NSH library
|
|
||||||
*
|
|
||||||
* CONFIG_BOARD_INITIALIZE=y, CONFIG_NSH_LIBRARY=y, &&
|
|
||||||
* CONFIG_NSH_ARCHINIT=n :
|
|
||||||
* Called from board_initialize().
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int nsh_archinitialize(void)
|
int nsh_archinitialize(void)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_USBHOST) || defined(HAVE_USBMONITOR)
|
#ifndef CONFIG_BOARD_INITIALIZE
|
||||||
int ret;
|
/* Perform board-specific initialization */
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_USBHOST
|
(void)stm32_bringup();
|
||||||
/* 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)
|
|
||||||
{
|
|
||||||
message("nsh_archinitialize: 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)
|
|
||||||
{
|
|
||||||
message("nsh_archinitialize: Start USB monitor: %d\n", ret);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|||||||
@@ -0,0 +1,175 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* config/stm32f4discovery/src/stm32_sdio.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014 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 "stm32f4discovery.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 */
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/****************************************************************************************************
|
/****************************************************************************
|
||||||
* configs/stm32f4discovery/src/stm32f4discovery.h
|
* configs/stm32f4discovery/src/stm32f4discovery.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
|
||||||
@@ -31,23 +31,23 @@
|
|||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
****************************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef __CONFIGS_STM32F4DISCOVERY_SRC_STM32F4DISCOVERY_H
|
#ifndef __CONFIGS_STM32F4DISCOVERY_SRC_STM32F4DISCOVERY_H
|
||||||
#define __CONFIGS_STM32F4DISCOVERY_SRC_STM32F4DISCOVERY_H
|
#define __CONFIGS_STM32F4DISCOVERY_SRC_STM32F4DISCOVERY_H
|
||||||
|
|
||||||
/****************************************************************************************************
|
/****************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
****************************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
#include <nuttx/compiler.h>
|
#include <nuttx/compiler.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
/****************************************************************************************************
|
/****************************************************************************
|
||||||
* Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************************************/
|
****************************************************************************/
|
||||||
/* Configuration ************************************************************************************/
|
/* Configuration *************************************************************/
|
||||||
/* How many SPI modules does this chip support? */
|
/* How many SPI modules does this chip support? */
|
||||||
|
|
||||||
#if STM32_NSPI < 1
|
#if STM32_NSPI < 1
|
||||||
@@ -61,7 +61,79 @@
|
|||||||
# undef CONFIG_STM32_SPI3
|
# undef CONFIG_STM32_SPI3
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* STM32F4 Discovery GPIOs **************************************************************************/
|
/* Assume that we have everything */
|
||||||
|
|
||||||
|
#define HAVE_USBDEV 1
|
||||||
|
#define HAVE_USBHOST 1
|
||||||
|
#define HAVE_USBMONITOR 1
|
||||||
|
#define HAVE_SDIO 1
|
||||||
|
|
||||||
|
/* 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
|
||||||
|
# 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
|
||||||
|
|
||||||
|
/* Can't support MMC/SD features if mountpoints are disabled or if SDIO support
|
||||||
|
* is not enabled.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_STM32_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"
|
||||||
|
# undef CONFIG_NSH_MMCSDSLOTNO
|
||||||
|
# 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_NSH_ARCHINIT=y, OR
|
||||||
|
* CONFIG_BOARD_INITIALIZE=y && CONFIG_BOARD_INITTHREAD=y
|
||||||
|
*/
|
||||||
|
|
||||||
|
# if defined(CONFIG_BOARD_INITIALIZE) && !defined(CONFIG_BOARD_INITTHREAD)
|
||||||
|
# warning "SDIO initialization cannot be perfomed on the IDLE thread"
|
||||||
|
# undef HAVE_SDIO
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* STM32F4 Discovery GPIOs **************************************************/
|
||||||
/* LEDs */
|
/* LEDs */
|
||||||
|
|
||||||
#define GPIO_LED1 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
|
#define GPIO_LED1 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
|
||||||
@@ -92,8 +164,8 @@
|
|||||||
|
|
||||||
/* SPI chip selects */
|
/* SPI chip selects */
|
||||||
|
|
||||||
#define GPIO_CS_MEMS (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
|
#define GPIO_CS_MEMS (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
|
||||||
GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN3)
|
GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN3)
|
||||||
|
|
||||||
/* USB OTG FS
|
/* USB OTG FS
|
||||||
*
|
*
|
||||||
@@ -102,14 +174,19 @@
|
|||||||
* PD5 OTG_FS_Overcurrent
|
* PD5 OTG_FS_Overcurrent
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define GPIO_OTGFS_VBUS (GPIO_INPUT|GPIO_FLOAT|GPIO_SPEED_100MHz|GPIO_OPENDRAIN|GPIO_PORTA|GPIO_PIN9)
|
#define GPIO_OTGFS_VBUS (GPIO_INPUT|GPIO_FLOAT|GPIO_SPEED_100MHz|\
|
||||||
#define GPIO_OTGFS_PWRON (GPIO_OUTPUT|GPIO_FLOAT|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTC|GPIO_PIN0)
|
GPIO_OPENDRAIN|GPIO_PORTA|GPIO_PIN9)
|
||||||
|
#define GPIO_OTGFS_PWRON (GPIO_OUTPUT|GPIO_FLOAT|GPIO_SPEED_100MHz|\
|
||||||
|
GPIO_PUSHPULL|GPIO_PORTC|GPIO_PIN0)
|
||||||
|
|
||||||
#ifdef CONFIG_USBHOST
|
#ifdef CONFIG_USBHOST
|
||||||
# define GPIO_OTGFS_OVER (GPIO_INPUT|GPIO_EXTI|GPIO_FLOAT|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTD|GPIO_PIN5)
|
# define GPIO_OTGFS_OVER (GPIO_INPUT|GPIO_EXTI|GPIO_FLOAT|\
|
||||||
|
GPIO_SPEED_100MHz|GPIO_PUSHPULL|\
|
||||||
|
GPIO_PORTD|GPIO_PIN5)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
# define GPIO_OTGFS_OVER (GPIO_INPUT|GPIO_FLOAT|GPIO_SPEED_100MHz|GPIO_PUSHPULL|GPIO_PORTD|GPIO_PIN5)
|
# define GPIO_OTGFS_OVER (GPIO_INPUT|GPIO_FLOAT|GPIO_SPEED_100MHz|\
|
||||||
|
GPIO_PUSHPULL|GPIO_PORTD|GPIO_PIN5)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* UG-2864AMBAG01 or UG-2864HSWEG01 OLED Display (SPI 4-wire):
|
/* UG-2864AMBAG01 or UG-2864HSWEG01 OLED Display (SPI 4-wire):
|
||||||
@@ -160,161 +237,190 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(CONFIG_STM32F4DISBB) && defined(CONFIG_STM32_SDIO)
|
#if defined(CONFIG_STM32F4DISBB) && defined(CONFIG_STM32_SDIO)
|
||||||
# define GPIO_SDIO_NCD (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTB|GPIO_PIN15)
|
# define GPIO_SDIO_NCD (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|\
|
||||||
|
GPIO_PORTB|GPIO_PIN15)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************************************
|
/****************************************************************************
|
||||||
* Public Types
|
* Public Types
|
||||||
****************************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************************************
|
/****************************************************************************
|
||||||
* Public data
|
* Public data
|
||||||
****************************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef __ASSEMBLY__
|
#ifndef __ASSEMBLY__
|
||||||
|
|
||||||
/****************************************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************************************
|
/****************************************************************************
|
||||||
* Name: stm32_spiinitialize
|
* Name: stm32_spiinitialize
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Called to configure SPI chip select GPIO pins for the stm32f4discovery board.
|
* Called to configure SPI chip select GPIO pins for the stm32f4discovery
|
||||||
|
* board.
|
||||||
*
|
*
|
||||||
****************************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void weak_function stm32_spiinitialize(void);
|
void weak_function stm32_spiinitialize(void);
|
||||||
|
|
||||||
/****************************************************************************************************
|
/****************************************************************************
|
||||||
|
* Name: stm32_bringup
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Perform architecture-specific initialization
|
||||||
|
*
|
||||||
|
* CONFIG_BOARD_INITIALIZE=y :
|
||||||
|
* Called from board_initialize().
|
||||||
|
*
|
||||||
|
* CONFIG_BOARD_INITIALIZE=y && CONFIG_NSH_ARCHINIT=y :
|
||||||
|
* Called from the NSH library
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int stm32_bringup(void);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
* Name: stm32_usbinitialize
|
* Name: stm32_usbinitialize
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Called from stm32_usbinitialize very early in inialization to setup USB-related
|
* Called from stm32_usbinitialize very early in initialization to setup
|
||||||
* GPIO pins for the STM32F4Discovery board.
|
* USB-related GPIO pins for the STM32F4Discovery board.
|
||||||
*
|
*
|
||||||
****************************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_STM32_OTGFS
|
#ifdef CONFIG_STM32_OTGFS
|
||||||
void weak_function stm32_usbinitialize(void);
|
void weak_function stm32_usbinitialize(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************************************
|
/****************************************************************************
|
||||||
* Name: stm32_usbhost_initialize
|
* Name: stm32_usbhost_initialize
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Called at application startup time to initialize the USB host functionality. This function will
|
* Called at application startup time to initialize the USB host
|
||||||
* start a thread that will monitor for device connection/disconnection events.
|
* functionality. This function will start a thread that will monitor for
|
||||||
|
* device connection/disconnection events.
|
||||||
*
|
*
|
||||||
****************************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_STM32_OTGFS) && defined(CONFIG_USBHOST)
|
#if defined(CONFIG_STM32_OTGFS) && defined(CONFIG_USBHOST)
|
||||||
int stm32_usbhost_initialize(void);
|
int stm32_usbhost_initialize(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************************************
|
/****************************************************************************
|
||||||
* Name: stm32_extmemgpios
|
* Name: stm32_extmemgpios
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Initialize GPIOs for external memory usage
|
* Initialize GPIOs for external memory usage
|
||||||
*
|
*
|
||||||
****************************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_STM32_FSMC
|
#ifdef CONFIG_STM32_FSMC
|
||||||
void stm32_extmemgpios(const uint32_t *gpios, int ngpios);
|
void stm32_extmemgpios(const uint32_t *gpios, int ngpios);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************************************
|
/****************************************************************************
|
||||||
* Name: stm32_extmemaddr
|
* Name: stm32_extmemaddr
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Initialize adress line GPIOs for external memory access
|
* Initialize adress line GPIOs for external memory access
|
||||||
*
|
*
|
||||||
****************************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_STM32_FSMC
|
#ifdef CONFIG_STM32_FSMC
|
||||||
void stm32_extmemaddr(int naddrs);
|
void stm32_extmemaddr(int naddrs);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************************************
|
/****************************************************************************
|
||||||
* Name: stm32_extmemdata
|
* Name: stm32_extmemdata
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Initialize data line GPIOs for external memory access
|
* Initialize data line GPIOs for external memory access
|
||||||
*
|
*
|
||||||
****************************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_STM32_FSMC
|
#ifdef CONFIG_STM32_FSMC
|
||||||
void stm32_extmemdata(int ndata);
|
void stm32_extmemdata(int ndata);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************************************
|
/****************************************************************************
|
||||||
* Name: stm32_enablefsmc
|
* Name: stm32_enablefsmc
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* enable clocking to the FSMC module
|
* enable clocking to the FSMC module
|
||||||
*
|
*
|
||||||
****************************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_STM32_FSMC
|
#ifdef CONFIG_STM32_FSMC
|
||||||
void stm32_enablefsmc(void);
|
void stm32_enablefsmc(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************************************
|
/****************************************************************************
|
||||||
* Name: stm32_disablefsmc
|
* Name: stm32_disablefsmc
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* enable clocking to the FSMC module
|
* enable clocking to the FSMC module
|
||||||
*
|
*
|
||||||
****************************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_STM32_FSMC
|
#ifdef CONFIG_STM32_FSMC
|
||||||
void stm32_disablefsmc(void);
|
void stm32_disablefsmc(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************************************
|
/****************************************************************************
|
||||||
* Name: stm32_led_pminitialize
|
* Name: stm32_led_pminitialize
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Enable logic to use the LEDs on the STM32F4Discovery to support power management testing
|
* Enable logic to use the LEDs on the STM32F4Discovery to support power
|
||||||
|
* management testing
|
||||||
*
|
*
|
||||||
****************************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_PM
|
#ifdef CONFIG_PM
|
||||||
void stm32_led_pminitialize(void);
|
void stm32_led_pminitialize(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************************************
|
/****************************************************************************
|
||||||
* Name: stm32_pm_buttons
|
* Name: stm32_pm_buttons
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Configure the user button of the STM32f4discovery board as EXTI,
|
* Configure the user button of the STM32f4discovery board as EXTI,
|
||||||
* so it is able to wakeup the MCU from the PM_STANDBY mode
|
* so it is able to wakeup the MCU from the PM_STANDBY mode
|
||||||
*
|
*
|
||||||
****************************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_PM) && defined(CONFIG_ARCH_IDLE_CUSTOM) && defined(CONFIG_PM_BUTTONS)
|
#if defined(CONFIG_PM) && defined(CONFIG_ARCH_IDLE_CUSTOM) && defined(CONFIG_PM_BUTTONS)
|
||||||
void stm32_pm_buttons(void);
|
void stm32_pm_buttons(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nsh_archinitialize
|
* Name: stm32_bringup
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Perform architecture specific initialization for NSH.
|
* Perform architecture-specific initialization
|
||||||
*
|
*
|
||||||
* CONFIG_NSH_ARCHINIT=y :
|
* CONFIG_BOARD_INITIALIZE=y :
|
||||||
* Called from the NSH library
|
|
||||||
*
|
|
||||||
* CONFIG_BOARD_INITIALIZE=y, CONFIG_NSH_LIBRARY=y, &&
|
|
||||||
* CONFIG_NSH_ARCHINIT=n :
|
|
||||||
* Called from board_initialize().
|
* Called from board_initialize().
|
||||||
*
|
*
|
||||||
|
* CONFIG_BOARD_INITIALIZE=n && CONFIG_NSH_ARCHINIT=y :
|
||||||
|
* Called from the NSH library
|
||||||
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_NSH_LIBRARY
|
int stm32_bringup(void);
|
||||||
int nsh_archinitialize(void);
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: stm32_sdio_initialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize SDIO-based MMC/SD card support
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_STM32_SDIO)
|
||||||
|
int stm32_sdio_initialize(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __ASSEMBLY__ */
|
#endif /* __ASSEMBLY__ */
|
||||||
|
|||||||
Reference in New Issue
Block a user