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 730667e069
commit cf06f00401
7 changed files with 176 additions and 17 deletions

View File

@ -141,7 +141,7 @@ int lm3s_dumpgpio(uint32 pinset, const char *msg)
lldbg(" AFSEL: %02x DEN: %02x DIR: %02x DATA: %02x\n",
getreg32(base + LM3S_GPIO_AFSEL_OFFSET), getreg32(base + LM3S_GPIO_DEN_OFFSET),
getreg32(base + LM3S_GPIO_DIR_OFFSET), getreg32(base + LM3S_GPIO_DATA_OFFSET + 0x3fc));
lldbg(" IS: %02x IBE: %02x IEV: %02x IM: %02x RIS: %02x MIS: %02x\n",
lldbg(" IS: %02x IBE: %02x IEV: %02x IM: %02x RIS: %08x MIS: %08x\n",
getreg32(base + LM3S_GPIO_IEV_OFFSET), getreg32(base + LM3S_GPIO_IM_OFFSET),
getreg32(base + LM3S_GPIO_RIS_OFFSET), getreg32(base + LM3S_GPIO_MIS_OFFSET));
lldbg(" 2MA: %02x 4MA: %02x 8MA: %02x ODR: %02x PUR %02x PDR: %02x SLR: %02x\n",

View File

@ -64,7 +64,7 @@
* CONFIG_DEBUG_VERBOSE too)
*/
#undef SSI_DEBUG /* Define to enable debug */
#undef SSI_DEBUG /* Define to enable debug */
#ifdef SSI_DEBUG
# define ssidbg lldbg
@ -426,12 +426,14 @@ static void ssi_semtake(sem_t *sem)
static void ssi_txnull(struct lm32_ssidev_s *priv)
{
ssivdbg("TX: ones\n");
ssi_putreg(priv, LM3S_SSI_DR_OFFSET, 0xffff);
}
static void ssi_txuint16(struct lm32_ssidev_s *priv)
{
uint16 *ptr = (uint16*)priv->txbuffer;
ssivdbg("TX: %p->%04x\n", ptr, *ptr);
ssi_putreg(priv, LM3S_SSI_DR_OFFSET, (uint32)(*ptr++));
priv->txbuffer = (void*)ptr;
}
@ -439,6 +441,7 @@ static void ssi_txuint16(struct lm32_ssidev_s *priv)
static void ssi_txubyte(struct lm32_ssidev_s *priv)
{
ubyte *ptr = (ubyte*)priv->txbuffer;
ssivdbg("TX: %p->%02x\n", ptr, *ptr);
ssi_putreg(priv, LM3S_SSI_DR_OFFSET, (uint32)(*ptr++));
priv->txbuffer = (void*)ptr;
}
@ -462,21 +465,28 @@ static void ssi_txubyte(struct lm32_ssidev_s *priv)
static void ssi_rxnull(struct lm32_ssidev_s *priv)
{
#if defined(SSI_DEBUG) && defined(CONFIG_DEBUG_VERBOSE)
uint32 regval = ssi_getreg(priv, LM3S_SSI_DR_OFFSET);
ssivdbg("RX: discard %04x\n", regval);
#else
(void)ssi_getreg(priv, LM3S_SSI_DR_OFFSET);
#endif
}
static void ssi_rxuint16(struct lm32_ssidev_s *priv)
{
uint16 *ptr = (uint16*)priv->rxbuffer;
*ptr++ = (uint16)ssi_getreg(priv, LM3S_SSI_DR_OFFSET);
priv->rxbuffer = (void*)ptr;
*ptr = (uint16)ssi_getreg(priv, LM3S_SSI_DR_OFFSET);
ssivdbg("RX: %p<-%04x\n", ptr, *ptr);
priv->rxbuffer = (void*)(++ptr);
}
static void ssi_rxubyte(struct lm32_ssidev_s *priv)
{
ubyte *ptr = (ubyte*)priv->rxbuffer;
*ptr++ = (ubyte)ssi_getreg(priv, LM3S_SSI_DR_OFFSET);
priv->rxbuffer = (void*)ptr;
*ptr = (ubyte)ssi_getreg(priv, LM3S_SSI_DR_OFFSET);
ssivdbg("RX: %p<-%02x\n", ptr, *ptr);
priv->rxbuffer = (void*)(++ptr);
}
/****************************************************************************

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 */