diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-05-24 20:40:11 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-05-24 20:40:11 +0000 |
commit | 27ba39c2e6bc41ff30705525a98444dfbe5da1cd (patch) | |
tree | 690e9c2d705fa5fe195757591b2bbb400c1df08c /nuttx | |
parent | 9b2ed5ff44f02983b6ed3ca810ab6a951b838b17 (diff) | |
download | nuttx-27ba39c2e6bc41ff30705525a98444dfbe5da1cd.tar.gz nuttx-27ba39c2e6bc41ff30705525a98444dfbe5da1cd.tar.bz2 nuttx-27ba39c2e6bc41ff30705525a98444dfbe5da1cd.zip |
Debug microSD CS
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1824 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx')
-rw-r--r-- | nuttx/arch/arm/src/lm3s/lm3s_dumpgpio.c | 2 | ||||
-rwxr-xr-x | nuttx/arch/arm/src/lm3s/lm3s_ssi.c | 20 | ||||
-rw-r--r-- | nuttx/configs/eagle100/include/board.h | 7 | ||||
-rw-r--r-- | nuttx/configs/eagle100/src/eagle100_internal.h | 93 | ||||
-rw-r--r-- | nuttx/configs/eagle100/src/up_boot.c | 16 | ||||
-rw-r--r-- | nuttx/configs/eagle100/src/up_leds.c | 3 | ||||
-rw-r--r-- | nuttx/configs/eagle100/src/up_ssi.c | 52 |
7 files changed, 176 insertions, 17 deletions
diff --git a/nuttx/arch/arm/src/lm3s/lm3s_dumpgpio.c b/nuttx/arch/arm/src/lm3s/lm3s_dumpgpio.c index 766ad911b..aed9d00e4 100644 --- a/nuttx/arch/arm/src/lm3s/lm3s_dumpgpio.c +++ b/nuttx/arch/arm/src/lm3s/lm3s_dumpgpio.c @@ -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", diff --git a/nuttx/arch/arm/src/lm3s/lm3s_ssi.c b/nuttx/arch/arm/src/lm3s/lm3s_ssi.c index 7c91a0709..4b9386c8a 100755 --- a/nuttx/arch/arm/src/lm3s/lm3s_ssi.c +++ b/nuttx/arch/arm/src/lm3s/lm3s_ssi.c @@ -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); } /**************************************************************************** diff --git a/nuttx/configs/eagle100/include/board.h b/nuttx/configs/eagle100/include/board.h index 096ca8410..febc93038 100644 --- a/nuttx/configs/eagle100/include/board.h +++ b/nuttx/configs/eagle100/include/board.h @@ -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 ************************************************************************************/ diff --git a/nuttx/configs/eagle100/src/eagle100_internal.h b/nuttx/configs/eagle100/src/eagle100_internal.h new file mode 100644 index 000000000..e2ff65fd3 --- /dev/null +++ b/nuttx/configs/eagle100/src/eagle100_internal.h @@ -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 */
+
diff --git a/nuttx/configs/eagle100/src/up_boot.c b/nuttx/configs/eagle100/src/up_boot.c index 874d3dc06..175e8e924 100644 --- a/nuttx/configs/eagle100/src/up_boot.c +++ b/nuttx/configs/eagle100/src/up_boot.c @@ -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();
diff --git a/nuttx/configs/eagle100/src/up_leds.c b/nuttx/configs/eagle100/src/up_leds.c index 5cb6be0d7..f382e63a3 100644 --- a/nuttx/configs/eagle100/src/up_leds.c +++ b/nuttx/configs/eagle100/src/up_leds.c @@ -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 diff --git a/nuttx/configs/eagle100/src/up_ssi.c b/nuttx/configs/eagle100/src/up_ssi.c index c14c7ab89..723012042 100644 --- a/nuttx/configs/eagle100/src/up_ssi.c +++ b/nuttx/configs/eagle100/src/up_ssi.c @@ -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 */
|