summaryrefslogtreecommitdiff
path: root/nuttx/arch/arm/src/lm3s/lm3s_ssi.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-05-28 17:51:24 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-05-28 17:51:24 +0000
commit6292602b85b085b1579cbc8bb6def5035f1abdf7 (patch)
tree22f8de1d73701910fa0149354df7d8b660a6ee0e /nuttx/arch/arm/src/lm3s/lm3s_ssi.c
parent2547315d49a4ee9f2fc61d54260a8b1f37f33cbd (diff)
downloadpx4-nuttx-6292602b85b085b1579cbc8bb6def5035f1abdf7.tar.gz
px4-nuttx-6292602b85b085b1579cbc8bb6def5035f1abdf7.tar.bz2
px4-nuttx-6292602b85b085b1579cbc8bb6def5035f1abdf7.zip
Final integration of microSD
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1830 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/arm/src/lm3s/lm3s_ssi.c')
-rwxr-xr-xnuttx/arch/arm/src/lm3s/lm3s_ssi.c46
1 files changed, 43 insertions, 3 deletions
diff --git a/nuttx/arch/arm/src/lm3s/lm3s_ssi.c b/nuttx/arch/arm/src/lm3s/lm3s_ssi.c
index ae45dbf97..3df87ecb2 100755
--- a/nuttx/arch/arm/src/lm3s/lm3s_ssi.c
+++ b/nuttx/arch/arm/src/lm3s/lm3s_ssi.c
@@ -122,6 +122,20 @@
#define LM3S_TXFIFO_WORDS 8
+/* Configuration settings */
+
+#ifndef CONFIG_SSI_TXLIMIT
+# define CONFIG_SSI_TXLIMIT (LM3S_TXFIFO_WORDS/2)
+#endif
+
+#if CONFIG_SSI_TXLIMIT < 1 || CONFIG_SSI_TXLIMIT > LM3S_TXFIFO_WORDS
+# error "Invalid range for CONFIG_SSI_TXLIMIT
+#endif
+
+#ifndef CONFIG_SSI_TXLIMIT && CONFIG_SSI_TXLIMIT < (LM3S_TXFIFO_WORDS/2)
+# error "CONFIG_SSI_TXLIMIT must be at least half the TX FIFO size"
+#endif
+
/****************************************************************************
* Private Type Definitions
****************************************************************************/
@@ -196,7 +210,11 @@ static void ssi_rxuint16(struct lm32_ssidev_s *priv);
static void ssi_rxubyte(struct lm32_ssidev_s *priv);
static inline boolean ssi_txfifofull(struct lm32_ssidev_s *priv);
static inline boolean ssi_rxfifoempty(struct lm32_ssidev_s *priv);
+#if CONFIG_SSI_TXLIMIT == 1 && defined(CONFIG_SSI_POLLWAIT)
+static inline int ssi_performtx(struct lm32_ssidev_s *priv);
+#else
static int ssi_performtx(struct lm32_ssidev_s *priv);
+#endif
static inline void ssi_performrx(struct lm32_ssidev_s *priv);
static int ssi_transfer(struct lm32_ssidev_s *priv, const void *txbuffer,
void *rxbuffer, unsigned int nwords);
@@ -543,6 +561,24 @@ static inline boolean ssi_rxfifoempty(struct lm32_ssidev_s *priv)
*
****************************************************************************/
+#if CONFIG_SSI_TXLIMIT == 1 && defined(CONFIG_SSI_POLLWAIT)
+static inline int ssi_performtx(struct lm32_ssidev_s *priv)
+{
+ /* Check if the Tx FIFO is full and more data to transfer */
+
+ if (!ssi_txfifofull(priv) && priv->ntxwords > 0)
+ {
+ /* Transfer one word to the Tx FIFO */
+
+ priv->txword(priv);
+ priv->ntxwords--;
+ return 1;
+ }
+ return 0;
+}
+
+#else /* CONFIG_SSI_TXLIMIT == 1 CONFIG_SSI_POLLWAIT */
+
static int ssi_performtx(struct lm32_ssidev_s *priv)
{
#ifndef CONFIG_SSI_POLLWAIT
@@ -561,12 +597,12 @@ static int ssi_performtx(struct lm32_ssidev_s *priv)
/* No.. Transfer more words until either the Tx FIFO is full or
* until all of the user provided data has been sent.
*/
-#if 1
+#ifdef CONFIG_SSI_TXLIMIT
/* Further limit the number of words that we put into the Tx
- * FIFO to half the half the FIFO depth. Otherwise, we could
+ * FIFO to CONFIG_SSI_TXLIMIT. Otherwise, we could
* overrun the Rx FIFO on a very fast SSI bus.
*/
- for (; ntxd < priv->ntxwords && ntxd < LM3S_TXFIFO_WORDS/2 && !ssi_txfifofull(priv); ntxd++)
+ for (; ntxd < priv->ntxwords && ntxd < CONFIG_SSI_TXLIMIT && !ssi_txfifofull(priv); ntxd++)
#else
for (; ntxd < priv->ntxwords && !ssi_txfifofull(priv); ntxd++)
#endif
@@ -609,6 +645,8 @@ static int ssi_performtx(struct lm32_ssidev_s *priv)
return ntxd;
}
+#endif /* CONFIG_SSI_TXLIMIT == 1 CONFIG_SSI_POLLWAIT */
+
/****************************************************************************
* Name: ssi_performrx
*
@@ -751,6 +789,7 @@ static int ssi_transfer(struct lm32_ssidev_s *priv, const void *txbuffer,
ssivdbg("ntxwords: %d nrxwords: %d nwords: %d SR: %08x\n",
priv->ntxwords, priv->nrxwords, priv->nwords,
ssi_getreg(priv, LM3S_SSI_SR_OFFSET));
+
ntxd = ssi_performtx(priv);
/* For the case where nwords < Tx FIFO size, ssi_performrx will
@@ -759,6 +798,7 @@ static int ssi_transfer(struct lm32_ssidev_s *priv, const void *txbuffer,
*/
ssi_performrx(priv);
+
ssivdbg("ntxwords: %d nrxwords: %d nwords: %d SR: %08x IM: %08x\n",
priv->ntxwords, priv->nrxwords, priv->nwords,
ssi_getreg(priv, LM3S_SSI_SR_OFFSET),