summaryrefslogtreecommitdiff
path: root/nuttx/arch/mips
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-06-02 17:57:39 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-06-02 17:57:39 +0000
commit2ae2dc308423c6dadb6ed5d44219873c9cfb7e99 (patch)
tree8fbbbac14a995c8ffe8efaf86aa850ebb6299dc4 /nuttx/arch/mips
parent46a632eaa001d0e40e2bccfc4d396c3abb99c117 (diff)
downloadpx4-nuttx-2ae2dc308423c6dadb6ed5d44219873c9cfb7e99.tar.gz
px4-nuttx-2ae2dc308423c6dadb6ed5d44219873c9cfb7e99.tar.bz2
px4-nuttx-2ae2dc308423c6dadb6ed5d44219873c9cfb7e99.zip
Add SD card support to the PIC32MX7 MMB board; Add regiser level debug instrumentatin for the PIC32 SPI driver
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4797 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/mips')
-rw-r--r--nuttx/arch/mips/src/pic32mx/pic32mx-spi.c85
1 files changed, 84 insertions, 1 deletions
diff --git a/nuttx/arch/mips/src/pic32mx/pic32mx-spi.c b/nuttx/arch/mips/src/pic32mx/pic32mx-spi.c
index fc81f3d25..ee7cea9eb 100644
--- a/nuttx/arch/mips/src/pic32mx/pic32mx-spi.c
+++ b/nuttx/arch/mips/src/pic32mx/pic32mx-spi.c
@@ -72,6 +72,7 @@
#ifndef CONFIG_DEBUG
# undef CONFIG_DEBUG_SPI
# undef CONFIG_DEBUG_VERBOSE
+# undef CONFIG_SPI_REGDEBUG
#endif
#ifdef CONFIG_DEBUG_SPI
@@ -309,13 +310,75 @@ static struct pic32mx_dev_s g_spi4dev =
*
****************************************************************************/
+#ifdef CONFIG_SPI_REGDEBUG
+static uint32_t spi_getreg(FAR struct pic32mx_dev_s *priv, unsigned int offset)
+{
+ /* Last address, value, and count */
+
+ static uint32_t prevaddr = 0;
+ static uint32_t prevalue = 0;
+ static uint32_t count = 0;
+
+ /* New address and value */
+
+ uint32_t addr;
+ uint32_t value;
+
+ /* Read the value from the register */
+
+ addr = priv->base + offset;
+ value = getreg32(addr);
+
+ /* Is this the same value that we read from the same register last time?
+ * Are we polling the register? If so, suppress some of the output.
+ */
+
+ if (addr == prevaddr && value == prevalue)
+ {
+ if (count == 0xffffffff || ++count > 3)
+ {
+ if (count == 4)
+ {
+ lldbg("...\n");
+ }
+ return value;
+ }
+ }
+
+ /* No this is a new address or value */
+
+ else
+ {
+ /* Did we print "..." for the previous value? */
+
+ if (count > 3)
+ {
+ /* Yes.. then show how many times the value repeated */
+
+ lldbg("[repeats %d more times]\n", count-3);
+ }
+
+ /* Save the new address, value, and count */
+
+ prevaddr = addr;
+ prevalue = value;
+ count = 1;
+ }
+
+ /* Show the register value read */
+
+ lldbg("%08x->%08x\n", addr, value);
+ return value;
+}
+#else
static uint32_t spi_getreg(FAR struct pic32mx_dev_s *priv, unsigned int offset)
{
return getreg32(priv->base + offset);
}
+#endif
/****************************************************************************
- * Name: spi_getreg
+ * Name: spi_putreg
*
* Description:
* Write a value to one, 32-bit SPI register
@@ -330,11 +393,31 @@ static uint32_t spi_getreg(FAR struct pic32mx_dev_s *priv, unsigned int offset)
*
****************************************************************************/
+#ifdef CONFIG_SPI_REGDEBUG
+static void spi_putreg(FAR struct pic32mx_dev_s *priv, unsigned int offset,
+ uint32_t value)
+{
+ uint32_t addr;
+
+ /* Get the address to write to */
+
+ addr = priv->base + offset;
+
+ /* Show the register value being written */
+
+ lldbg("%08x<-%08x\n", addr, value);
+
+ /* Then do the write */
+
+ putreg32(value, addr);
+}
+#else
static void spi_putreg(FAR struct pic32mx_dev_s *priv, unsigned int offset,
uint32_t value)
{
putreg32(value, priv->base + offset);
}
+#endif
/****************************************************************************
* Name: spi_lock