Debug microSD CS

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1824 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2009-05-24 20:40:11 +00:00
parent da61e40634
commit 42c45a3760
5 changed files with 160 additions and 11 deletions

View File

@ -110,13 +110,6 @@
#define LED_ASSERTION 6 /* ON OFF */
#define LED_PANIC 7 /* ON OFF */
/* Eagle-100 GPIOs ******************************************************************/
/* GPIO for microSD card chip select */
#define SDCCS_GPIO (GPIO_FUNC_OUTPUT | GPIO_PADTYPE_STDWPU | GPIO_STRENGTH_4MA | GPIO_VALUE_ONE | GPIO_PORTG | 2)
#define LED_GPIO (GPIO_FUNC_OUTPUT | GPIO_VALUE_ONE | GPIO_PORTE | 1)
/************************************************************************************
* Public Function Prototypes
************************************************************************************/

View File

@ -0,0 +1,93 @@
/************************************************************************************
* configs/eagle100/src/eagle100_internal.h
* arch/arm/src/board/eagle100_internal.n
*
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* 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.
*
************************************************************************************/
#ifndef __CONFIGS_EAGLE100_SRC_EAGLE100_INTERNAL_H
#define __CONFIGS_EAGLE100_SRC_EAGLE100_INTERNAL_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <sys/types.h>
/************************************************************************************
* Definitions
************************************************************************************/
/* How many SSI modules does this chip support? The LM3S6918 supports 2 SSI
* modules (others may support more -- in such case, the following must be
* expanded).
*/
#if LM3S_NSSI == 0
# undef CONFIG_SSI0_DISABLE
# define CONFIG_SSI0_DISABLE 1
# undef CONFIG_SSI1_DISABLE
# define CONFIG_SSI1_DISABLE 1
#elif LM3S_NSSI == 1
# undef CONFIG_SSI1_DISABLE
# define CONFIG_SSI1_DISABLE 1
#endif
/* Eagle-100 GPIOs ******************************************************************/
/* GPIO for microSD card chip select */
#define SDCCS_GPIO (GPIO_FUNC_OUTPUT | GPIO_PADTYPE_STDWPU | GPIO_STRENGTH_4MA | \
GPIO_VALUE_ONE | GPIO_PORTG | 1)
#define LED_GPIO (GPIO_FUNC_OUTPUT | GPIO_VALUE_ONE | GPIO_PORTE | 1)
/************************************************************************************
* Public Functions
************************************************************************************/
#ifndef __ASSEMBLY__
/************************************************************************************
* Name: lm3s_ssiinitialize
*
* Description:
* Called to configure SPI chip select GPIO pins for the Eagle100 board.
*
************************************************************************************/
extern void weak_function lm3s_ssiinitialize(void);
#endif /* __ASSEMBLY__ */
#endif /* __CONFIGS_EAGLE100_SRC_EAGLE100_INTERNAL_H */

View File

@ -46,6 +46,7 @@
#include <arch/board/board.h>
#include "up_arch.h"
#include "eagle100_internal.h"
/************************************************************************************
* Definitions
@ -70,11 +71,20 @@
void lm3s_boardinitialize(void)
{
/* Configure the SPI-based microSD CS GPIO */
/* Configure SPI chip selects if 1) SSI is not disabled, and 2) the weak function
* lm3s_ssiinitialize() has been brought into the link.
*/
lm3s_configgpio(SDCCS_GPIO);
/* The Eagle100 microSD CS is on SSI0 */
/* Configure on-board LEDs */
#if !defined(CONFIG_SSI0_DISABLE) /* || !defined(CONFIG_SSI1_DISABLE) */
if (lm3s_ssiinitialize)
{
lm3s_ssiinitialize();
}
#endif
/* Configure on-board LEDs if LED support has been selected. */
#ifdef CONFIG_ARCH_LEDS
up_ledinit();

View File

@ -49,6 +49,7 @@
#include "up_arch.h"
#include "up_internal.h"
#include "lm3s_internal.h"
#include "eagle100_internal.h"
/****************************************************************************
* Definitions
@ -58,7 +59,7 @@
* CONFIG_DEBUG_VERBOSE too)
*/
#undef LED_DEBUG /* Define to enable debug */
#undef LED_DEBUG /* Define to enable debug */
#ifdef LED_DEBUG
# define leddbg lldbg

View File

@ -41,16 +41,46 @@
#include <nuttx/config.h>
#include <sys/types.h>
#include <debug.h>
#include <nuttx/spi.h>
#include <arch/board/board.h>
#include "up_arch.h"
#include "chip.h"
#include "lm3s_internal.h"
#include "eagle100_internal.h"
/* The Eagle100 microSD CS is on SSI0 */
#if !defined(CONFIG_SSI0_DISABLE) /* || !defined(CONFIG_SSI1_DISABLE) */
/************************************************************************************
* Definitions
************************************************************************************/
/* Enables debug output from this file (needs CONFIG_DEBUG with CONFIG_DEBUG_VERBOSE
* too)
*/
#undef SSI_DEBUG /* Define to enable debug */
#ifdef SSI_DEBUG
# define ssidbg lldbg
# define ssivdbg llvdbg
#else
# define ssidbg(x...)
# define ssivdbg(x...)
#endif
/* Dump GPIO registers */
#ifdef SSI_DEBUG
# define ssi_dumpgpio(m) lm3s_dumpgpio(SDCCS_GPIO, m)
#else
# define ssi_dumpgpio(m)
#endif
/************************************************************************************
* Private Functions
************************************************************************************/
@ -59,6 +89,23 @@
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: lm3s_ssiinitialize
*
* Description:
* Called to configure SPI chip select GPIO pins for the Eagle100 board.
*
************************************************************************************/
void weak_function lm3s_ssiinitialize(void)
{
/* Configure the SPI-based microSD CS GPIO */
ssi_dumpgpio("lm3s_ssiinitialize() before lm3s_configgpio()");
lm3s_configgpio(SDCCS_GPIO);
ssi_dumpgpio("lm3s_ssiinitialize() after lm3s_configgpio()");
}
/****************************************************************************
* The external functions, lm3s_spiselect and lm3s_spistatus must be provided
* by board-specific logic. The are implementations of the select and status
@ -80,17 +127,22 @@
void lm3s_spiselect(FAR struct spi_dev_s *dev, enum spi_dev_e devid, boolean selected)
{
ssidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
if (devid == SPIDEV_MMCSD)
{
/* Assert the CS pin to the card */
ssi_dumpgpio("lm3s_spiselect() before lm3s_gpiowrite()");
lm3s_gpiowrite(SDCCS_GPIO, !selected);
ssi_dumpgpio("lm3s_spiselect() after lm3s_gpiowrite()");
}
}
ubyte lm3s_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
{
#warning "Need to check schematic"
ssidbg("Returning SPI_STATUS_PRESENT\n");
return SPI_STATUS_PRESENT;
}
#endif /* !CONFIG_SSI0_DISABLE || !CONFIG_SSI1_DISABLE */