FLASH is on PB2 (not PA4); MMC/SD is SDIO, not SPI (need to fix)

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2161 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2009-10-18 22:15:23 +00:00
parent ea4ab4fad8
commit bc8e8d2477
3 changed files with 160 additions and 157 deletions

View File

@ -72,11 +72,12 @@
/* MMC/SD SPI1 chip select: PC.12 */ /* MMC/SD SPI1 chip select: PC.12 */
#warning "MicoSD is on SDIO port, not SPI"
#define GPIO_MMCSD_CS (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN12) #define GPIO_MMCSD_CS (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN12)
/* SPI FLASH chip select: PA.4 */ /* SPI FLASH chip select: PA.4 */
#define GPIO_FLASH_CS (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|GPIO_OUTPUT_SET|GPIO_PORTA|GPIO_PIN4) #define GPIO_FLASH_CS (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN2)
/************************************************************************************ /************************************************************************************
* Public Functions * Public Functions

View File

@ -63,6 +63,7 @@
#endif #endif
/* MMC/SD is on SPI1 */ /* MMC/SD is on SPI1 */
#warning "MicoSD is on SDIO port, not SPI"
#ifndef CONFIG_STM32_SPI1 #ifndef CONFIG_STM32_SPI1
# undef CONFIG_EXAMPLES_NSH_MMCSDSPIPORTNO # undef CONFIG_EXAMPLES_NSH_MMCSDSPIPORTNO

View File

@ -1,86 +1,86 @@
/************************************************************************************ /************************************************************************************
* configs/stm3210e_eval/src/up_spi.c * configs/stm3210e_eval/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) 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* *
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in * notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the * the documentation and/or other materials provided with the
* distribution. * distribution.
* 3. Neither the name NuttX nor the names of its contributors may be * 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software * used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* 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.
* *
************************************************************************************/ ************************************************************************************/
/************************************************************************************ /************************************************************************************
* Included Files * Included Files
************************************************************************************/ ************************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
#include <debug.h> #include <debug.h>
#include <nuttx/spi.h> #include <nuttx/spi.h>
#include <arch/board/board.h> #include <arch/board/board.h>
#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 "stm3210e-internal.h"
#if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) #if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2)
/************************************************************************************ /************************************************************************************
* Definitions * Definitions
************************************************************************************/ ************************************************************************************/
/* Enables debug output from this file (needs CONFIG_DEBUG too) */ /* Enables debug output from this file (needs CONFIG_DEBUG too) */
#undef SPI_DEBUG /* Define to enable debug */ #undef SPI_DEBUG /* Define to enable debug */
#undef SPI_VERBOSE /* Define to enable verbose debug */ #undef SPI_VERBOSE /* Define to enable verbose debug */
#ifdef SPI_DEBUG #ifdef SPI_DEBUG
# define spidbg lldbg # define spidbg lldbg
# ifdef SPI_VERBOSE # ifdef SPI_VERBOSE
# define spivdbg lldbg # define spivdbg lldbg
# else # else
# define spivdbg(x...) # define spivdbg(x...)
# endif # endif
#else #else
# undef SPI_VERBOSE # undef SPI_VERBOSE
# define spidbg(x...) # define spidbg(x...)
# define spivdbg(x...) # define spivdbg(x...)
#endif #endif
/************************************************************************************ /************************************************************************************
* Private Functions * Private Functions
************************************************************************************/ ************************************************************************************/
static void stm32_chipselect(FAR struct spi_dev_s *dev, uint32 pinset, boolean pinval, boolean selected) static void stm32_chipselect(FAR struct spi_dev_s *dev, uint32 pinset, boolean pinval, boolean selected)
{ {
spidbg("devid: %d CS: %s pinset: %08x pinval: %s\n", spidbg("devid: %d CS: %s pinset: %08x pinval: %s\n",
(int)devid, selected ? "assert" : "de-assert", pinset, pinval ? "HIGH" : "LOW"); (int)devid, selected ? "assert" : "de-assert", pinset, pinval ? "HIGH" : "LOW");
@ -109,35 +109,36 @@ static void stm32_chipselect(FAR struct spi_dev_s *dev, uint32 pinset, boolean p
} }
} }
/************************************************************************************ /************************************************************************************
* Public Functions * Public Functions
************************************************************************************/ ************************************************************************************/
/************************************************************************************ /************************************************************************************
* 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 STM3210E-EVAL board.
* *
************************************************************************************/ ************************************************************************************/
void weak_function stm32_spiinitialize(void) void weak_function stm32_spiinitialize(void)
{ {
/* NOTE: Clocking for SPI1 and/or SPI2 was already provided in stm32_rcc.c. /* NOTE: Clocking for SPI1 and/or SPI2 was already provided in stm32_rcc.c.
* Configurations of SPI pins is performed in stm32_spi.c. * Configurations of SPI pins is performed in stm32_spi.c.
* Here, we only initialize chip select pins unique to the board * Here, we only initialize chip select pins unique to the board
* architecture. * architecture.
*/ */
#ifdef CONFIG_STM32_SPI1 #ifdef CONFIG_STM32_SPI1
/* Configure the SPI-based microSD and FLASH CS GPIO */ /* Configure the SPI-based microSD and FLASH CS GPIO */
stm32_configgpio(GPIO_MMCSD_CS); #warning "MicoSD is on SDIO port, not SPI"
stm32_configgpio(GPIO_FLASH_CS); stm32_configgpio(GPIO_MMCSD_CS);
stm32_configgpio(GPIO_FLASH_CS);
#endif #endif
} }
/**************************************************************************** /****************************************************************************
* Name: stm32_spi1/2/3select and stm32_spi1/2/3status * Name: stm32_spi1/2/3select and stm32_spi1/2/3status
* *
* Description: * Description:
@ -159,59 +160,59 @@ void weak_function stm32_spiinitialize(void)
* 3. Add a calls to up_spiinitialize() in your low level application * 3. Add a calls to up_spiinitialize() in your low level application
* initialization logic * initialization logic
* 4. The handle returned by up_spiinitialize() may then be used to bind the * 4. The handle returned by up_spiinitialize() may then be used to bind the
* SPI driver to higher level logic (e.g., calling * SPI driver to higher level logic (e.g., calling
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to * mmcsd_spislotinitialize(), for example, will bind the SPI driver to
* the SPI MMC/SD driver). * the SPI MMC/SD driver).
* *
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_STM32_SPI1
void stm32_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, boolean selected)
{
spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
if (devid == SPIDEV_MMCSD)
{
/* Set the GPIO low to select and high to de-select */
stm32_chipselect(dev, GPIO_MMCSD_CS,!selected, selected); #ifdef CONFIG_STM32_SPI1
} void stm32_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, boolean selected)
else if (devid == SPIDEV_FLASH) {
{ spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
/* Set the GPIO low to select and high to de-select */
if (devid == SPIDEV_MMCSD)
stm32_chipselect(dev, GPIO_FLASH_CS,!selected, selected); {
} /* Set the GPIO low to select and high to de-select */
}
stm32_chipselect(dev, GPIO_MMCSD_CS,!selected, selected);
ubyte stm32_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid) }
{ else if (devid == SPIDEV_FLASH)
return SPI_STATUS_PRESENT; {
} /* Set the GPIO low to select and high to de-select */
#endif
stm32_chipselect(dev, GPIO_FLASH_CS,!selected, selected);
#ifdef CONFIG_STM32_SPI2 }
void stm32_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, boolean selected) }
{
spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); ubyte stm32_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
} {
return SPI_STATUS_PRESENT;
ubyte stm32_spi2status(FAR struct spi_dev_s *dev, enum spi_dev_e devid) }
{ #endif
return SPI_STATUS_PRESENT;
} #ifdef CONFIG_STM32_SPI2
#endif void stm32_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, boolean selected)
{
#ifdef CONFIG_STM32_SPI3 spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
void stm32_spi3select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, boolean selected) }
{
spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); ubyte stm32_spi2status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
} {
return SPI_STATUS_PRESENT;
ubyte stm32_spi3status(FAR struct spi_dev_s *dev, enum spi_dev_e devid) }
{ #endif
return SPI_STATUS_PRESENT;
} #ifdef CONFIG_STM32_SPI3
#endif void stm32_spi3select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, boolean selected)
{
#endif /* CONFIG_STM32_SPI1 || CONFIG_STM32_SPI2 */ spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
}
ubyte stm32_spi3status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
{
return SPI_STATUS_PRESENT;
}
#endif
#endif /* CONFIG_STM32_SPI1 || CONFIG_STM32_SPI2 */