Viewtools netnsh configuration supports Telnet console; A framework for SD card and USB device support

This commit is contained in:
Gregory Nutt 2013-12-25 14:51:56 -06:00
parent 53bc0bce00
commit 091e5fdf66
10 changed files with 662 additions and 38 deletions

View file

@ -6303,4 +6303,7 @@
LCD on the Maple board. From Librae (2013-12-23).
* configs/viewtool-stm32f107/netnsh: Add a NSH configuration that
supports networking with the DP83848C module installed (2013-12-25).
* configs/viewtool-stm32f107/src/stm32_nsh.c, stm32_mmcsd.c, stm32_usb.c,
and stm32_usbmsc.c: Lay out basic framework for USB and SD card
support. Code is incomplete and has been neither built nor tested
(2013-12-25).

View file

@ -25,6 +25,8 @@ Contents
- J5 - USART1
- PL-2013 USB-to-Serial Interface
- RS-232 Module
o USB Interface
o microSD Card Interface
o ViewTool DP83848 Ethernet Module
o Toolchains
- NOTE about Windows native toolchains
@ -119,6 +121,72 @@ Serial Console
J35 - CON2. Jumper Setting:
1 <-> 2 : Proves 3.3V to the RS-232 module.
USB Interface
=============
USB Connector
-------------
The Viewtool base board has a USB Mini-B connector. Only USB device can
be supported with this connector.
------------------------- ------------------------------------
USB Connector
J10 mini-USB GPIO CONFIGURATION(s)
--- --------- ----------- ------------------------------------
Pin Signal
--- --------- ----------- ------------------------------------
1 USB_VBUS VDD_USB (No sensing available)
2 OTG_DM PA11 GPIO_OTG_FSDM
3 OTG_DP PA12 GPIO_OTG_FSDP
4 OTG_ID PA10 GPIO_OTG_FSID
5 Shield N/A N/A
6 Shield N/A N/A
7 Shield N/A N/A
8 Shield N/A N/A
9 Shield N/A N/A
PE11 USB_EN GPIO controlled soft pull-up
NOTES:
1. GPIO_OTG_FSVBUS should not be configured. No VBUS sensing
2. GPIO_OTG_FSSOF is not used
Configuration
-------------
To be provided. Some logic is in place, leveraged from other boards.
But this logic is not full implemented, not has it ever been built or\
tested.
microSD Card Interface
======================
microSD Connector
-----------------
----------------------------- ------------------------- --------------------------------
Connector J17 GPIO CONFIGURATION(s)
PIN SIGNAL LEGEND (no remapping) DP83848C Board
--- ------------- ----------- ------------------------- --------------------------------
1 VDD 3.3 N/A N/A 3.3
2 GND N/A N/A GND
3 PC8 SDIO_D0 GPIO_SDIO_D0 D0
4 PD2 SDIO_CMD GPIO_SDIO_CMD CMD
5 PC12 SDIO_CLK GPIO_SDIO_CK CLK
6 PC11 SDIO_D3 GPIO_SDIO_D3 D3
7 PC10 SDIO_D2 GPIO_SDIO_D2 D2
8 PC9 SDIO_D1 GPIO_SDIO_D1 D1
9 PA8 CD Board-specific GPIO input CD
--- ------------- ----------- ------------------------- --------------------------------
NOTES:
1. The STM32F107 does not support the SDIO/memory card interface. So the SD card
cannot be used with the STM32F107 (unless the pin-out just happens to match up
with an SPI-based card interface???)
Configuration
-------------
To be provided (for the STM32F103 only)
ViewTool DP83848 Ethernet Module
================================
@ -163,48 +231,57 @@ ViewTool DP83848 Ethernet Module
-------------
System Type -> STM32 Peripheral Support
CONFIG_STM32_ETHMAC=y
CONFIG_STM32_ETHMAC=y : Enable Ethernet driver
System Type -> Ethernet MAC Configuration
CONFIG_STM32_RMII=y
CONFIG_STM32_AUTONEG=y
CONFIG_STM32_PHYADDR=1
CONFIG_STM32_PHYSR=16
CONFIG_STM32_PHYSR_SPEED=0x0002
CONFIG_STM32_PHYSR_100MBPS=0x0000
CONFIG_STM32_PHYSR_MODE=0x0004
CONFIG_STM32_PHYSR_FULLDUPLEX=0x0004
CONFIG_STM32_RMII_EXTCLK=y
CONFIG_STM32_RMII=y : Configuration RM-II DP83848C PHY
CONFIG_STM32_AUTONEG=y
CONFIG_STM32_PHYADDR=1
CONFIG_STM32_PHYSR=16
CONFIG_STM32_PHYSR_SPEED=0x0002
CONFIG_STM32_PHYSR_100MBPS=0x0000
CONFIG_STM32_PHYSR_MODE=0x0004
CONFIG_STM32_PHYSR_FULLDUPLEX=0x0004
CONFIG_STM32_RMII_EXTCLK=y
Device Drivers -> Networking Devices
CONFIG_NETDEVICES=y
CONFIG_ETH0_PHY_DP83848C=y
CONFIG_NETDEVICES=y : More PHY stuff
CONFIG_ETH0_PHY_DP83848C=y
Networking (required)
CONFIG_NET=y
CONFIG_NET_MULTIBUFFER=y
CONFIG_NSH_NOMAC=y
CONFIG_NET=y : Enabled networking support
CONFIG_NET_MULTIBUFFER=y : Required by driver
CONFIG_NSH_NOMAC=y
Networking (recommended/typical)
CONFIG_NSOCKET_DESCRIPTORS=10
CONFIG_NET_SOCKOPTS=y
CONFIG_NSOCKET_DESCRIPTORS=10 : Socket-related
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_BUFSIZE=650
CONFIG_NET_RECEIVE_WINDOW=650
CONFIG_NET_TCP_READAHEAD_BUFSIZE=650
CONFIG_NET_BUFSIZE=650 : Maximum packet size
CONFIG_NET_RECEIVE_WINDOW=650
CONFIG_NET_TCP_READAHEAD_BUFSIZE=650
CONFIG_NET_TCP=y
CONFIG_NET_NTCP_READAHEAD_BUFFERS=8
CONFIG_NET_TCP=y : TCP support
CONFIG_NET_NTCP_READAHEAD_BUFFERS=8
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CONNS=8
CONFIG_NET_UDP=y : UDP support
CONFIG_NET_UDP_CONNS=8
CONFIG_NET_ICMP=y
CONFIG_NET_ICMP_PING=y
CONFIG_NET_ICMP=y : ICMP support
CONFIG_NET_ICMP_PING=y
CONFIG_NSH_DRIPADDR=0x0a000001
CONFIG_NSH_IPADDR=0x0a000002
CONFIG_NSH_NETMASK=0xffffff00
CONFIG_NSH_DRIPADDR=0x0a000001 : Network identity
CONFIG_NSH_IPADDR=0x0a000002
CONFIG_NSH_NETMASK=0xffffff00
Network Utilities (basic)
CONFIG_NETUTILS_TFTPC=y : Needed by NSH unless to disable TFTP commands
CONFIG_NETUTILS_DHCPC=y : Fun stuff
CONFIG_NETUTILS_TELNETD=y : Support for a Telnet NSH console
CONFIG_NSH_TELNET=y
(also FTP, TFTP, WGET, NFS, etc. if you also have a mass storage
device).
Toolchains
==========
@ -347,9 +424,6 @@ Configurations
CONFIG_WINDOWS_CYGWIN=y : POSIX environment under windows
CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y : CodeSourcery for Windows
STATUS: As of this writing (2013-12-25), the STM32 communicates with the
PHY, but the DP83848 fails to return good linkstatus from the STM32.
nsh:
This configuration directory provide the basic NuttShell (NSH).

View file

@ -758,7 +758,7 @@ CONFIG_EXAMPLES_NSH=y
# Networking Utilities
#
# CONFIG_NETUTILS_CODECS is not set
# CONFIG_NETUTILS_DHCPC is not set
CONFIG_NETUTILS_DHCPC=y
# CONFIG_NETUTILS_DHCPD is not set
# CONFIG_NETUTILS_FTPC is not set
# CONFIG_NETUTILS_FTPD is not set
@ -767,7 +767,7 @@ CONFIG_NETUTILS_RESOLV=y
CONFIG_NET_RESOLV_ENTRIES=8
CONFIG_NET_RESOLV_MAXRESPONSE=96
# CONFIG_NETUTILS_SMTP is not set
# CONFIG_NETUTILS_TELNETD is not set
CONFIG_NETUTILS_TELNETD=y
CONFIG_NETUTILS_TFTPC=y
# CONFIG_NETUTILS_THTTPD is not set
CONFIG_NETUTILS_UIPLIB=y
@ -853,7 +853,14 @@ CONFIG_NSH_CONSOLE=y
#
# CONFIG_NSH_CONDEV is not set
# CONFIG_NSH_ARCHINIT is not set
# CONFIG_NSH_TELNET is not set
CONFIG_NSH_TELNET=y
CONFIG_NSH_TELNETD_PORT=23
CONFIG_NSH_TELNETD_DAEMONPRIO=100
CONFIG_NSH_TELNETD_DAEMONSTACKSIZE=2048
CONFIG_NSH_TELNETD_CLIENTPRIO=100
CONFIG_NSH_TELNETD_CLIENTSTACKSIZE=2048
CONFIG_NSH_IOBUFFER_SIZE=512
# CONFIG_NSH_TELNET_LOGIN is not set
CONFIG_NSH_IPADDR=0x0a000002
CONFIG_NSH_DRIPADDR=0x0a000001
CONFIG_NSH_NETMASK=0xffffff00

View file

@ -50,6 +50,22 @@ ifeq ($(CONFIG_CAN),y)
CSRCS += stm32_can.c
endif
ifeq ($(CONFIG_MMCSD),y)
CSRCS += stm32_mmcsd.c
endif
ifeq ($(CONFIG_STM32_OTGFS),y)
CSRCS += stm32_usbdev.c
endif
ifeq ($(CONFIG_NSH_ARCHINIT),y)
CSRCS += stm32_nsh.c
endif
ifeq ($(CONFIG_USBMSC),y)
CSRCS += stm32_usbmsc.c
endif
ifeq ($(CONFIG_ARCH_BUTTONS),y)
CSRCS += stm32_buttons.c
endif

View file

@ -79,6 +79,18 @@ void stm32_boardinitialize(void)
}
#endif
/* Initialize USB is 1) USBDEV is selected, 2) the USB controller is not
* disabled, and 3) the weak function stm32_usbdev_initialize() has been brought
* into the build.
*/
#if defined(CONFIG_STM32_OTGFS) && defined(CONFIG_USBDEV)
if (stm32_usbdev_initialize)
{
stm32_usbdev_initialize();
}
#endif
/* Configure on-board LEDs (unconditionally). */
stm32_ledinit();

View file

@ -0,0 +1,133 @@
/****************************************************************************
* config/viewtool-stm32f107/src/up_mmcsd.c
*
* Copyright (C) 2013 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 "stm32_sdio.h"
#include "viewtool_stm32f107.h"
/* Only the STM32F103 supports the SDIO interface */
#ifdef CONFIG_ARCH_CHIP_STM32F103VCT6
/****************************************************************************
* 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 */
#ifdef 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_SDIO=y
*
****************************************************************************/
int stm32_sdinitialize(int minor)
{
#ifdef HAVE_MMCSD
FAR struct sdio_dev_s *sdio;
int ret;
/* Configure the card-detect GPIO */
#warning REVISIT: Missing logic
/* First, get an instance of the SDIO interface */
sdio = sdio_initialize(STM32_MMCSDSLOTNO);
if (!sdio)
{
fdbg("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)
{
fdbg("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.
*/
#warning REVISIT: Need to read the current state of the card-detect pin
#warning REVISIT: Need to support interrupts from the card-detect pin
sdio_mediachange(sdio, true);
#endif
return OK;
}
#endif /* CONFIG_ARCH_CHIP_STM32F103VCT6 */

View file

@ -0,0 +1,81 @@
/****************************************************************************
* config/viewtool-stm32f107/src/stm32_nsh.c
*
* Copyright (C) 2013 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 "viewtool_stm32f107.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/* Debug ********************************************************************/
#ifdef CONFIG_CPP_HAVE_VARARGS
# ifdef CONFIG_DEBUG
# define message(...) lowsyslog(__VA_ARGS__)
# else
# define message(...) printf(__VA_ARGS__)
# endif
#else
# ifdef CONFIG_DEBUG
# define message lowsyslog
# else
# define message printf
# endif
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nsh_archinitialize
*
* Description:
* Perform architecture specific initialization
*
****************************************************************************/
int nsh_archinitialize(void)
{
return OK;
}

View file

@ -0,0 +1,113 @@
/************************************************************************************
* configs/viewtool-stm32f107/src/stm32_usbdev.c
*
* Copyright (C) 2013 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 <stdbool.h>
#include <debug.h>
#include <nuttx/usb/usbdev.h>
#include "stm32_otgfs.h"
#include "viewtool_stm32f107.h"
#ifdef CONFIG_STM32_OTGFS
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
#ifdef CONFIG_USBDEV
# define HAVE_USB 1
#else
# warning CONFIG_STM32_OTGFS is enabled but CONFIG_USBDEV is not
# undef HAVE_USB
#endif
/************************************************************************************
* Private Data
************************************************************************************/
/************************************************************************************
* Private Functions
************************************************************************************/
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: stm32_usbdev_initialize
*
* Description:
* Called from stm32_boardinitialize very early in initialization to setup USB-
* related GPIO pins for the Viewtool STM32F107 board.
*
************************************************************************************/
void stm32_usbdev_initialize(void)
{
/* The OTG FS has an internal soft pull-up. No GPIO configuration is required */
#warning REVISIT: The Viewtool board does, indeed, have a soft connect GPIO
/* Configure the OTG FS VBUS sensing GPIO, Power On, and Overcurrent GPIOs */
#ifdef CONFIG_STM32_OTGFS
#warning REVISIT: GPIO setup
#endif
}
/************************************************************************************
* 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);
}
#endif /* CONFIG_STM32_OTGFS */

View file

@ -0,0 +1,104 @@
/****************************************************************************
* configs/viewtool-stm32f107/src/stm32_usbmsc.c
*
* Copyright (C) 2013 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.h"
#include "viewtool_stm32f107.h"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
#ifndef CONFIG_SYSTEM_USBMSC_DEVMINOR1
# define CONFIG_SYSTEM_USBMSC_DEVMINOR1 0
#endif
/* Debug ********************************************************************/
#ifdef CONFIG_CPP_HAVE_VARARGS
# ifdef CONFIG_DEBUG
# define message(...) lowsyslog(__VA_ARGS__)
# define msgflush()
# else
# define message(...) printf(__VA_ARGS__)
# define msgflush() fflush(stdout)
# endif
#else
# ifdef CONFIG_DEBUG
# define message lowsyslog
# 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 system/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_NSH_BUILTIN_APPS
return stm32_sdinitialize(CONFIG_SYSTEM_USBMSC_DEVMINOR1);
#else
return OK;
#endif
}

View file

@ -87,6 +87,63 @@
#define GPIO_SW4 (GPIO_INPUT | GPIO_CNF_INFLOAT | GPIO_MODE_INPUT | \
GPIO_EXTI | GPIO_PORTA | GPIO_PIN10)
/* microSD Card Interface
*
* microSD Connector
* -----------------
*
* ----------------------------- ------------------------- --------------------------------
* Connector J17 GPIO CONFIGURATION(s)
* PIN SIGNAL LEGEND (no remapping) DP83848C Board
* --- ------------- ----------- ------------------------- --------------------------------
* 1 VDD 3.3 N/A N/A 3.3
* 2 GND N/A N/A GND
* 3 PC8 SDIO_D0 GPIO_SDIO_D0 D0
* 4 PD2 SDIO_CMD GPIO_SDIO_CMD CMD
* 5 PC12 SDIO_CLK GPIO_SDIO_CK CLK
* 6 PC11 SDIO_D3 GPIO_SDIO_D3 D3
* 7 PC10 SDIO_D2 GPIO_SDIO_D2 D2
* 8 PC9 SDIO_D1 GPIO_SDIO_D1 D1
* 9 PA8 CD Board-specific GPIO input CD
* --- ------------- ----------- ------------------------- --------------------------------
*
* NOTES:
* 1. The STM32F107 does not support the SDIO/memory card interface. So the SD card
* cannot be used with the STM32F107 (unless the pin-out just happens to match up
* with an SPI-based card interface???)
*/
#ifdef CONFIG_ARCH_CHIP_STM32F103VCT6
# define GPIO_SD_CD (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_EXTI|GPIO_PORTA|GPIO_PIN8)
#endif
/* USB
*
* The Viewtool base board has a USB Mini-B connector. Only USB device can
* be supported with this connector.
*
* ------------------------- ------------------------------------
* USB Connector
* J10 mini-USB GPIO CONFIGURATION(s)
* --- --------- ----------- ------------------------------------
* Pin Signal
* --- --------- ----------- ------------------------------------
* 1 USB_VBUS VDD_USB (No sensing available)
* 2 OTG_DM PA11 GPIO_OTG_FSDM
* 3 OTG_DP PA12 GPIO_OTG_FSDP
* 4 OTG_ID PA10 GPIO_OTG_FSID
* 5 Shield N/A N/A
* 6 Shield N/A N/A
* 7 Shield N/A N/A
* 8 Shield N/A N/A
* 9 Shield N/A N/A
* PE11 USB_EN GPIO controlled soft pull-up
*
* NOTES:
* 1. GPIO_OTG_FSVBUS should not be configured. No VBUS sensing
* 2. GPIO_OTG_FSSOF is not used
*/
/************************************************************************************
* Public Functions
************************************************************************************/
@ -103,13 +160,37 @@
void weak_function stm32_spiinitialize(void);
/****************************************************************************
/************************************************************************************
* Name: stm32_usbdev_initialize
*
* Description:
* Called from stm32_usbdev_initialize very early in initialization to setup USB-related
* GPIO pins for the Viewtool STM32F107 board.
*
************************************************************************************/
#if defined(CONFIG_STM32_OTGFS) && defined(CONFIG_USBDEV)
void weak_function stm32_usbdev_initialize(void);
#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);
/************************************************************************************
* Name: up_ledinit
*
* Description:
* Configure LEDs. LEDs are left in the OFF state.
*
****************************************************************************/
************************************************************************************/
void stm32_ledinit(void);