More M3 Wildfire logic; mmap-related bug fixes from Kate

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5124 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2012-09-10 20:00:04 +00:00
parent 941e056e99
commit 89d98d72cf
17 changed files with 913 additions and 30 deletions
+1 -1
View File
@@ -138,7 +138,7 @@ config ARCH_BOARD_FIRE_STM32V2
select ARCH_HAVE_IRQBUTTONS select ARCH_HAVE_IRQBUTTONS
---help--- ---help---
A configuration for the M3 Wildfile board. This board is based on the A configuration for the M3 Wildfile board. This board is based on the
STM32F103VET6 chip. STM32F103VET6 chip. See http://firestm32.taobao.com
config ARCH_BOARD_HYMINI_STM32V config ARCH_BOARD_HYMINI_STM32V
bool "HY-Mini STM32v board" bool "HY-Mini STM32v board"
+1 -1
View File
@@ -1545,7 +1545,7 @@ configs/ez80f0910200zco
configs/fire-stm32v2 configs/fire-stm32v2
A configuration for the M3 Wildfire STM32 board. This board is based on the A configuration for the M3 Wildfire STM32 board. This board is based on the
STM32F103VET6 chip. STM32F103VET6 chip. See http://firestm32.taobao.com
configs/hymini-stm32v configs/hymini-stm32v
A configuration for the HY-Mini STM32v board. This board is based on the A configuration for the HY-Mini STM32v board. This board is based on the
+1 -1
View File
@@ -2,7 +2,7 @@ README
====== ======
This README discusses issues unique to NuttX configurations for the M3 This README discusses issues unique to NuttX configurations for the M3
Wildfire development board (STM32F103VET6). Wildfire development board (STM32F103VET6). See http://firestm32.taobao.com
Contents Contents
======== ========
+1 -5
View File
@@ -40,7 +40,7 @@ CFLAGS += -I$(TOPDIR)/sched
ASRCS = ASRCS =
AOBJS = $(ASRCS:.S=$(OBJEXT)) AOBJS = $(ASRCS:.S=$(OBJEXT))
CSRCS = up_boot.c up_spi.c up_usbdev.c CSRCS = up_boot.c up_spi.c up_usbdev.c up_mmcsd.c
ifeq ($(CONFIG_STM32_FSMC),y) ifeq ($(CONFIG_STM32_FSMC),y)
CSRCS += up_lcd.c up_selectlcd.c CSRCS += up_lcd.c up_selectlcd.c
@@ -76,10 +76,6 @@ ifeq ($(CONFIG_USBDEV_COMPOSITE),y)
CSRCS += up_composite.c CSRCS += up_composite.c
endif endif
ifeq ($(CONFIG_CAN),y)
CSRCS += up_can.c
endif
ifeq ($(CONFIG_WATCHDOG),y) ifeq ($(CONFIG_WATCHDOG),y)
CSRCS += up_watchdog.c CSRCS += up_watchdog.c
endif endif
+11
View File
@@ -287,6 +287,17 @@ void weak_function stm32_usbinitialize(void);
void stm32_selectlcd(void); void stm32_selectlcd(void);
#endif #endif
/****************************************************************************
* Name: stm32_sdinitialize
*
* Description:
* Initialize the SPI-based SD card. Requires CONFIG_DISABLE_MOUNTPOINT=n
* and CONFIG_STM32_SPI1=y
*
****************************************************************************/
int stm32_sdinitialize(int minor);
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
#endif /* __CONFIGS_FIRE_STM32V2_SRC_FIRE_INTERNAL_H */ #endif /* __CONFIGS_FIRE_STM32V2_SRC_FIRE_INTERNAL_H */
-8
View File
@@ -53,14 +53,6 @@
/**************************************************************************** /****************************************************************************
* Private Data * Private Data
****************************************************************************/ ****************************************************************************/
/* Pin configuration for each Shenzhou button. This array is indexed by
* the BUTTON_* definitions in board.h
*/
static const uint16_t g_buttons[NUM_BUTTONS] =
{
GPIO_BTN_KEY1, GPIO_BTN_KEY1
};
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
+106
View File
@@ -0,0 +1,106 @@
/****************************************************************************
* configs/fire-stm32v2/src/up_composite.c
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Configure and register the STM32 SPI-based MMC/SD block driver.
*
* 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 <stdio.h>
#include <debug.h>
#include "fire-internal.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* Device minor number */
#ifndef CONFIG_EXAMPLES_COMPOSITE_DEVMINOR1
# define CONFIG_EXAMPLES_COMPOSITE_DEVMINOR1 0
#endif
/* Debug ********************************************************************/
#ifdef CONFIG_CPP_HAVE_VARARGS
# ifdef CONFIG_DEBUG
# define message(...) lib_lowprintf(__VA_ARGS__)
# define msgflush()
# else
# define message(...) printf(__VA_ARGS__)
# define msgflush() fflush(stdout)
# endif
#else
# ifdef CONFIG_DEBUG
# define message lib_lowprintf
# define msgflush()
# else
# define message printf
# define msgflush() fflush(stdout)
# endif
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: composite_archinitialize
*
* Description:
* Perform architecture specific initialization
*
****************************************************************************/
int composite_archinitialize(void)
{
/* If examples/composite is built as an NSH command, then SD slot should
* already have been initized in nsh_archinitialize() (see up_nsh.c). In
* this case, there is nothing further to be done here.
*
* NOTE: CONFIG_NSH_BUILTIN_APPS is not a fool-proof indication that NSH
* was built.
*/
#ifndef CONFIG_NSH_BUILTIN_APPS
return sd_mount(CONFIG_EXAMPLES_COMPOSITE_DEVMINOR1);
#else
return OK;
#endif /* CONFIG_NSH_BUILTIN_APPS */
}
+155
View File
@@ -0,0 +1,155 @@
/************************************************************************************
* configs/fire-stm32v2/src/up_cxxinitialize.c
* arch/arm/src/board/up_cxxinitialize.c
*
* Copyright (C) 2012 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 <debug.h>
#include <nuttx/arch.h>
#include <arch/stm32/chip.h>
#include "chip.h"
#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE)
/************************************************************************************
* Definitions
************************************************************************************/
/* Debug ****************************************************************************/
/* Non-standard debug that may be enabled just for testing the static constructors */
#ifndef CONFIG_DEBUG
# undef CONFIG_DEBUG_CXX
#endif
#ifdef CONFIG_DEBUG_CXX
# define cxxdbg dbg
# define cxxlldbg lldbg
# ifdef CONFIG_DEBUG_VERBOSE
# define cxxvdbg vdbg
# define cxxllvdbg llvdbg
# else
# define cxxvdbg(x...)
# define cxxllvdbg(x...)
# endif
#else
# define cxxdbg(x...)
# define cxxlldbg(x...)
# define cxxvdbg(x...)
# define cxxllvdbg(x...)
#endif
/************************************************************************************
* Private Types
************************************************************************************/
/* This type defines one entry in initialization array */
typedef void (*initializer_t)(void);
/************************************************************************************
* External references
************************************************************************************/
/* _sinit and _einit are symbols exported by the linker script that mark the
* beginning and the end of the C++ initialization section.
*/
extern initializer_t _sinit;
extern initializer_t _einit;
/* _stext and _etext are symbols exported by the linker script that mark the
* beginning and the end of text.
*/
extern uint32_t _stext;
extern uint32_t _etext;
/************************************************************************************
* Private Functions
************************************************************************************/
/************************************************************************************
* Public Functions
************************************************************************************/
/****************************************************************************
* Name: up_cxxinitialize
*
* Description:
* If C++ and C++ static constructors are supported, then this function
* must be provided by board-specific logic in order to perform
* initialization of the static C++ class instances.
*
* This function should then be called in the application-specific
* user_start logic in order to perform the C++ initialization. NOTE
* that no component of the core NuttX RTOS logic is involved; This
* function defintion only provides the 'contract' between application
* specific C++ code and platform-specific toolchain support
*
***************************************************************************/
void up_cxxinitialize(void)
{
initializer_t *initp;
cxxdbg("_sinit: %p _einit: %p _stext: %p _etext: %p\n",
&_sinit, &_einit, &_stext, &_etext);
/* Visit each entry in the initialzation table */
for (initp = &_sinit; initp != &_einit; initp++)
{
initializer_t initializer = *initp;
cxxdbg("initp: %p initializer: %p\n", initp, initializer);
/* Make sure that the address is non-NULL and lies in the text region
* defined by the linker script. Some toolchains may put NULL values
* or counts in the initialization table
*/
if ((void*)initializer > (void*)&_stext && (void*)initializer < (void*)&_etext)
{
cxxdbg("Calling %p\n", initializer);
initializer();
}
}
}
#endif /* CONFIG_HAVE_CXX && CONFIG_HAVE_CXXINITIALIZE */
+122
View File
@@ -0,0 +1,122 @@
/****************************************************************************
* config/fire-stm32v2/src/up_mmcsd.c
* arch/arm/src/board/up_mmcsd.c
*
* Copyright (C) 2012 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 <stdio.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/sdio.h>
#include <nuttx/mmcsd.h>
#include "fire-internal.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
#define HAVE_MMCSD 1 /* Assume that we have SD support */
#define STM32_MMCSDSLOTNO 0 /* There is only one slot */
/* Can't support MMC/SD features if the SDIO peripheral is disabled */
#ifndef CONFIG_STM32_SDIO
# undef HAVE_MMCSD
#endif
/* Can't support MMC/SD features if mountpoints are disabled */
#ifndef CONFIG_DISABLE_MOUNTPOINT
# undef HAVE_MMCSD
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: stm32_sdinitialize
*
* Description:
* Initialize the SPI-based SD card. Requires CONFIG_DISABLE_MOUNTPOINT=n
* and CONFIG_STM32_SPI1=y
*
****************************************************************************/
int stm32_sdinitialize(int minor)
{
#ifdef HAVE_MMCSD
FAR struct sdio_dev_s *sdio;
int ret;
/* First, get an instance of the SDIO interface */
sdio = sdio_initialize(STM32_MMCSDSLOTNO);
if (!sdio)
{
message("Failed to initialize SDIO slot %d\n", STM32_MMCSDSLOTNO);
return -ENODEV;
}
fvdbg("Initialized SDIO slot %d\n", STM32_MMCSDSLOTNO);
/* Now bind the SDIO interface to the MMC/SD driver */
ret = mmcsd_slotinitialize(minor, sdio);
if (ret != OK)
{
message("Failed to bind SDIO slot %d to the MMC/SD driver, minor=%d\n",
STM32_MMCSDSLOTNO, minor);
}
fvdbg("Bound SDIO slot %d to the MMC/SD driver, minor=%d\n",
STM32_MMCSDSLOTNO, minor);
/* Then let's guess and say that there is a card in the slot. I need to check to
* see if the M3 Wildfire board supports a GPIO to detect if there is a card in
* the slot.
*/
sdio_mediachange(sdio, true);
#endif
return OK;
}
+151
View File
@@ -0,0 +1,151 @@
/****************************************************************************
* config/fire-stm32v2/src/up_nsh.c
* arch/arm/src/board/up_nsh.c
*
* Copyright (C) 2012 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 "stm32_internal.h"
#include "fire-internal.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* Assume that we support everything until convinced otherwise */
#define HAVE_MMCSD 1
#define HAVE_USBDEV 1
/* Configuration ************************************************************/
/* SPI1 connects to the SD CARD (and to the SPI FLASH) */
#define STM32_MMCSDSPIPORTNO 1 /* SPI1 */
#define STM32_MMCSDSLOTNO 0 /* Only one slot */
/* Can't support MMC/SD features if the SDIO peripheral is disabled */
#ifndef CONFIG_STM32_SDIO
# undef HAVE_MMCSD
#endif
/* Can't support MMC/SD features if mountpoints are disabled */
#ifdef CONFIG_DISABLE_MOUNTPOINT
# undef HAVE_MMCSD
#endif
/* Default MMC/SD minor number */
#ifdef HAVE_MMCSD
# ifndef CONFIG_NSH_MMCSDMINOR
# define CONFIG_NSH_MMCSDMINOR 0
# endif
/* Default MMC/SD SLOT number */
# if defined(CONFIG_NSH_MMCSDSLOTNO) && CONFIG_NSH_MMCSDSLOTNO != STM32_MMCSDSLOTNO
# error "Only one MMC/SD slot: Slot 0"
# undef CONFIG_NSH_MMCSDSLOTNO
# define CONFIG_NSH_MMCSDSLOTNO STM32_MMCSDSLOTNO
# endif
# ifndef CONFIG_NSH_MMCSDSLOTNO
# define CONFIG_NSH_MMCSDSLOTNO STM32_MMCSDSLOTNO
# endif
#endif
/* Can't support USB host or device features if the USB peripheral or the USB
* device infrastructure is not enabled
*/
#if !defined(CONFIG_STM32_USB) || !defined(CONFIG_USBDEV)
# undef HAVE_USBDEV
#endif
/* Debug ********************************************************************/
#ifdef CONFIG_CPP_HAVE_VARARGS
# ifdef CONFIG_DEBUG
# define message(...) lib_lowprintf(__VA_ARGS__)
# else
# define message(...) printf(__VA_ARGS__)
# endif
#else
# ifdef CONFIG_DEBUG
# define message lib_lowprintf
# else
# define message printf
# endif
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nsh_archinitialize
*
* Description:
* Perform architecture specific initialization
*
****************************************************************************/
int nsh_archinitialize(void)
{
#ifdef HAVE_MMCSD
int ret;
/* Initialize the SDIO-based MMC/SD slot */
ret = stm32_sdinitialze(CONFIG_NSH_MMCSDMINOR);
if (ret < 0)
{
message("nsh_archinitialize: Failed to initialize MMC/SD slot %d: %d\n",
CONFIG_NSH_MMCSDSLOTNO, ret);
return ret;
}
#endif
return OK;
}
+4 -4
View File
@@ -1,8 +1,8 @@
/************************************************************************************ /************************************************************************************
* configs/stm3210e_eval/src/up_spi.c * configs/fire-stm32v2/src/up_spi.c
* arch/arm/src/board/up_spi.c * arch/arm/src/board/up_spi.c
* *
* Copyright (C) 2009 Gregory Nutt. All rights reserved. * Copyright (C) 2012 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
@@ -50,7 +50,7 @@
#include "up_arch.h" #include "up_arch.h"
#include "chip.h" #include "chip.h"
#include "stm32_internal.h" #include "stm32_internal.h"
#include "stm3210e-internal.h" #include "fire-internal.h"
#if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) #if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2)
@@ -88,7 +88,7 @@
* Name: stm32_spiinitialize * Name: stm32_spiinitialize
* *
* Description: * Description:
* Called to configure SPI chip select GPIO pins for the STM3210E-EVAL board. * Called to configure SPI chip select GPIO pins for the M3 Wildfire board.
* *
************************************************************************************/ ************************************************************************************/
+116
View File
@@ -0,0 +1,116 @@
/************************************************************************************
* configs/fire-stm32v2/src/up_usbdev.c
* arch/arm/src/board/up_boot.c
*
* Copyright (C) 2012 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 <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <nuttx/usb/usbdev.h>
#include <nuttx/usb/usbdev_trace.h>
#include "up_arch.h"
#include "stm32_internal.h"
#include "fire-internal.h"
/************************************************************************************
* Definitions
************************************************************************************/
/************************************************************************************
* Private Functions
************************************************************************************/
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: stm32_usbinitialize
*
* Description:
* Called to setup USB-related GPIO pins for the M3 Wildfire board.
*
************************************************************************************/
void stm32_usbinitialize(void)
{
/* USB Soft Connect Pullup: PB.14 */
stm32_configgpio(GPIO_USB_PULLUP);
}
/************************************************************************************
* Name: stm32_usbpullup
*
* Description:
* If USB is supported and the board supports a pullup via GPIO (for USB software
* connect and disconnect), then the board software must provide stm32_pullup.
* See include/nuttx/usb/usbdev.h for additional description of this method.
* Alternatively, if no pull-up GPIO the following EXTERN can be redefined to be
* NULL.
*
************************************************************************************/
int stm32_usbpullup(FAR struct usbdev_s *dev, bool enable)
{
usbtrace(TRACE_DEVPULLUP, (uint16_t)enable);
stm32_gpiowrite(GPIO_USB_PULLUP, !enable);
return OK;
}
/************************************************************************************
* Name: stm32_usbsuspend
*
* Description:
* Board logic must provide the stm32_usbsuspend logic if the USBDEV driver is
* used. This function is called whenever the USB enters or leaves suspend mode.
* This is an opportunity for the board logic to shutdown clocks, power, etc.
* while the USB is suspended.
*
************************************************************************************/
void stm32_usbsuspend(FAR struct usbdev_s *dev, bool resume)
{
ulldbg("resume: %d\n", resume);
}
+103
View File
@@ -0,0 +1,103 @@
/****************************************************************************
* configs/fire-stm32v2/src/up_usbmsc.c
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Configure and register the STM32 SPI-based MMC/SD block driver.
*
* 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 <stdio.h>
#include <debug.h>
#include <errno.h>
#include "stm32_internal.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
#ifndef CONFIG_EXAMPLES_USBMSC_DEVMINOR1
# define CONFIG_EXAMPLES_USBMSC_DEVMINOR1 0
#endif
/* Debug ********************************************************************/
#ifdef CONFIG_CPP_HAVE_VARARGS
# ifdef CONFIG_DEBUG
# define message(...) lib_lowprintf(__VA_ARGS__)
# define msgflush()
# else
# define message(...) printf(__VA_ARGS__)
# define msgflush() fflush(stdout)
# endif
#else
# ifdef CONFIG_DEBUG
# define message lib_lowprintf
# define msgflush()
# else
# define message printf
# define msgflush() fflush(stdout)
# endif
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: usbmsc_archinitialize
*
* Description:
* Perform architecture specific initialization
*
****************************************************************************/
int usbmsc_archinitialize(void)
{
/* If examples/usbmsc is built as an NSH command, then SD slot should
* already have been initized in nsh_archinitialize() (see up_nsh.c). In
* this case, there is nothing further to be done here.
*/
#ifndef CONFIG_EXAMPLES_USBMSC_BUILTIN
return stm32_sdinitialize(CONFIG_EXAMPLES_USBMSC_DEVMINOR1);
#else
return OK;
#endif
}
+136
View File
@@ -0,0 +1,136 @@
/************************************************************************************
* configs/fire-stm32v2/src/up_watchdog.c
* arch/arm/src/board/up_watchdog.c
*
* Copyright (C) 2012 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 <errno.h>
#include <debug.h>
#include <nuttx/watchdog.h>
#include <arch/board/board.h>
#include "stm32_wdg.h"
#ifdef CONFIG_WATCHDOG
/************************************************************************************
* Definitions
************************************************************************************/
/* Configuration *******************************************************************/
/* Wathdog hardware should be enabled */
#if !defined(CONFIG_STM32_WWDG) && !defined(CONFIG_STM32_IWDG)
# warning "One of CONFIG_STM32_WWDG or CONFIG_STM32_IWDG must be defined"
#endif
/* Select the path to the registered watchdog timer device */
#ifndef CONFIG_STM32_WDG_DEVPATH
# ifdef CONFIG_EXAMPLES_WATCHDOG_DEVPATH
# define CONFIG_STM32_WDG_DEVPATH CONFIG_EXAMPLES_WATCHDOG_DEVPATH
# else
# define CONFIG_STM32_WDG_DEVPATH "/dev/watchdog0"
# endif
#endif
/* Use the un-calibrated LSI frequency if we have nothing better */
#if defined(CONFIG_STM32_IWDG) && !defined(CONFIG_STM32_LSIFREQ)
# define CONFIG_STM32_LSIFREQ STM32_LSI_FREQUENCY
#endif
/* Debug ***************************************************************************/
/* Non-standard debug that may be enabled just for testing the watchdog timer */
#ifndef CONFIG_DEBUG
# undef CONFIG_DEBUG_WATCHDOG
#endif
#ifdef CONFIG_DEBUG_WATCHDOG
# define wdgdbg dbg
# define wdglldbg lldbg
# ifdef CONFIG_DEBUG_VERBOSE
# define wdgvdbg vdbg
# define wdgllvdbg llvdbg
# else
# define wdgvdbg(x...)
# define wdgllvdbg(x...)
# endif
#else
# define wdgdbg(x...)
# define wdglldbg(x...)
# define wdgvdbg(x...)
# define wdgllvdbg(x...)
#endif
/************************************************************************************
* Private Functions
************************************************************************************/
/************************************************************************************
* Public Functions
************************************************************************************/
/****************************************************************************
* Name: up_wdginitialize()
*
* Description:
* Perform architecuture-specific initialization of the Watchdog hardware.
* This interface must be provided by all configurations using
* apps/examples/watchdog
*
****************************************************************************/
int up_wdginitialize(void)
{
/* Initialize tha register the watchdog timer device */
#if defined(CONFIG_STM32_WWDG)
stm32_wwdginitialize(CONFIG_STM32_WDG_DEVPATH);
return OK;
#elif defined(CONFIG_STM32_IWDG)
stm32_iwdginitialize(CONFIG_STM32_WDG_DEVPATH, CONFIG_STM32_LSIFREQ);
return OK;
#else
return -ENODEV;
#endif
}
#endif /* CONFIG_WATCHDOG */
+1 -1
View File
@@ -44,7 +44,7 @@
#include <stdio.h> #include <stdio.h>
#include <debug.h> #include <debug.h>
#include "shenzhou_internal.h" #include "shenzhou-internal.h"
/**************************************************************************** /****************************************************************************
* Pre-Processor Definitions * Pre-Processor Definitions
+2 -1
View File
@@ -68,7 +68,7 @@
/* Can't support MMC/SD features if mountpoints are disabled */ /* Can't support MMC/SD features if mountpoints are disabled */
#ifndef CONFIG_DISABLE_MOUNTPOINT #ifndef CONFIG_DISABLE_MOUNTPOINT
# undef NSH_HAVEMMCSD # undef HAVE_MMCSD
#endif #endif
/**************************************************************************** /****************************************************************************
@@ -121,3 +121,4 @@ int stm32_sdinitialize(int minor)
#endif #endif
return OK; return OK;
} }
+1 -7
View File
@@ -71,13 +71,7 @@
/* Can't support MMC/SD features if mountpoints are disabled */ /* Can't support MMC/SD features if mountpoints are disabled */
#ifndef CONFIG_DISABLE_MOUNTPOINT #ifdef CONFIG_DISABLE_MOUNTPOINT
# undef NSH_HAVEMMCSD
#endif
/* Can't support MMC/SD features if mountpoints are disabled) */
#if defined(CONFIG_DISABLE_MOUNTPOINT)
# undef HAVE_MMCSD # undef HAVE_MMCSD
#endif #endif