summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-12-03 01:37:56 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-12-03 01:37:56 +0000
commit5076c4bb878881610884750c5a8fd43bdf99c471 (patch)
treec28e5e59c702dfc7394e9d365b9bcb7c3209b7ea
parent42a5fb251254f855b5f3911337d56f0cccfcc37f (diff)
downloadpx4-nuttx-5076c4bb878881610884750c5a8fd43bdf99c471.tar.gz
px4-nuttx-5076c4bb878881610884750c5a8fd43bdf99c471.tar.bz2
px4-nuttx-5076c4bb878881610884750c5a8fd43bdf99c471.zip
Add cmddata method to the SPI interface
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3157 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--nuttx/arch/arm/src/imx/chip.h2
-rwxr-xr-xnuttx/arch/arm/src/imx/imx_cspi.h23
-rw-r--r--nuttx/arch/arm/src/imx/imx_memorymap.h2
-rwxr-xr-xnuttx/arch/arm/src/imx/imx_spi.c3
-rwxr-xr-xnuttx/arch/arm/src/imx/imx_system.h2
-rw-r--r--nuttx/arch/arm/src/lm3s/lm3s_internal.h18
-rwxr-xr-xnuttx/arch/arm/src/lm3s/lm3s_ssi.c5
-rwxr-xr-xnuttx/arch/arm/src/lpc17xx/lpc17_internal.h29
-rwxr-xr-xnuttx/arch/arm/src/lpc17xx/lpc17_spi.c3
-rwxr-xr-xnuttx/arch/arm/src/lpc17xx/lpc17_ssp.c6
-rwxr-xr-xnuttx/arch/arm/src/lpc313x/lpc313x_internal.h23
-rw-r--r--nuttx/arch/arm/src/lpc313x/lpc313x_spi.c3
-rwxr-xr-xnuttx/arch/arm/src/stm32/stm32_internal.h25
-rwxr-xr-xnuttx/arch/arm/src/stm32/stm32_spi.c9
-rwxr-xr-xnuttx/arch/z80/src/ez80/ez80_spi.c3
-rw-r--r--nuttx/arch/z80/src/ez80/ez80f91_spi.h21
-rw-r--r--nuttx/configs/mcu123-lpc214x/src/up_spi.c38
-rw-r--r--nuttx/configs/olimex-strp711/src/up_spi.c38
-rw-r--r--nuttx/include/nuttx/spi.h31
19 files changed, 234 insertions, 50 deletions
diff --git a/nuttx/arch/arm/src/imx/chip.h b/nuttx/arch/arm/src/imx/chip.h
index 00272ccdb..c8a6615d7 100644
--- a/nuttx/arch/arm/src/imx/chip.h
+++ b/nuttx/arch/arm/src/imx/chip.h
@@ -1,7 +1,7 @@
/************************************************************************************
* arch/arm/src/imx/chip.h
*
- * Copyright (C) 2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
diff --git a/nuttx/arch/arm/src/imx/imx_cspi.h b/nuttx/arch/arm/src/imx/imx_cspi.h
index e0d97f2d4..421b6a4e3 100755
--- a/nuttx/arch/arm/src/imx/imx_cspi.h
+++ b/nuttx/arch/arm/src/imx/imx_cspi.h
@@ -1,7 +1,7 @@
/************************************************************************************
* arch/arm/src/imx/imx_cspi.h
*
- * Copyright (C) 2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -176,23 +176,30 @@ extern "C" {
* Public Functions
************************************************************************************/
-/* The external functions, imx_spiselect and imx_spistatus must be provided by
- * board-specific logic. The are implementations of the select and status methods
- * SPI interface defined by struct spi_ops_s (see include/nuttx/spi.h). All other
- * methods (including up_spiinitialize()) are provided by common logic. To use this
- * common SPI logic on your board:
+/* The external functions, imx_spiselect, imx_spistatus, and imx_cmddaa must be
+ * provided by board-specific logic. These are implementations of the select and
+ * status methods of the SPI interface defined by struct spi_ops_s (see
+ * include/nuttx/spi.h). All other methods (including up_spiinitialize()) are
+ * provided by common logic. To use this common SPI logic on your board:
*
* 1. Provide imx_spiselect() and imx_spistatus() functions in your board-specific
* logic. This function will perform chip selection and status operations using
* GPIOs in the way your board is configured.
- * 2. Add a call to up_spiinitialize() in your low level initialization logic
- * 3. The handle returned by up_spiinitialize() may then be used to bind the
+ * 2. If CONFIG_SPI_CMDDATA is defined in your NuttX configuration, provide the
+ * imx_spicmddata() function in your board-specific logic. This function will
+ * perform cmd/data selection operations using GPIOs in the way your board is
+ * configured.
+ * 3. Add a call to up_spiinitialize() in your low level initialization logic
+ * 4. The handle returned by up_spiinitialize() may then be used to bind the
* SPI driver to higher level logic (e.g., calling mmcsd_spislotinitialize(),
* for example, will bind the SPI driver to the SPI MMC/SD driver).
*/
EXTERN void imx_spiselect(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
EXTERN uint8_t imx_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+#ifdef CONFIG_SPI_CMDDATA
+EXTERN int imx_spicmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+#endif
#undef EXTERN
#ifdef __cplusplus
diff --git a/nuttx/arch/arm/src/imx/imx_memorymap.h b/nuttx/arch/arm/src/imx/imx_memorymap.h
index d656b2f80..0b7603bef 100644
--- a/nuttx/arch/arm/src/imx/imx_memorymap.h
+++ b/nuttx/arch/arm/src/imx/imx_memorymap.h
@@ -1,7 +1,7 @@
/************************************************************************************
* arch/arm/src/imx/imx_memorymap.h
*
- * Copyright (C) 2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
diff --git a/nuttx/arch/arm/src/imx/imx_spi.c b/nuttx/arch/arm/src/imx/imx_spi.c
index 578e274cd..e07cd5d32 100755
--- a/nuttx/arch/arm/src/imx/imx_spi.c
+++ b/nuttx/arch/arm/src/imx/imx_spi.c
@@ -197,6 +197,9 @@ static const struct spi_ops_s g_spiops =
.setmode = spi_setmode,
.setbits = spi_setbits,
.status = imx_spistatus, /* Provided externally by board logic */
+#ifdef CONFIG_SPI_CMDDATA
+ .cmddata = imx_spicmddata,
+#endif
.send = spi_send,
#ifdef CONFIG_SPI_EXCHANGE
.exchange = spi_exchange,
diff --git a/nuttx/arch/arm/src/imx/imx_system.h b/nuttx/arch/arm/src/imx/imx_system.h
index fe575cf41..a3a4b4c54 100755
--- a/nuttx/arch/arm/src/imx/imx_system.h
+++ b/nuttx/arch/arm/src/imx/imx_system.h
@@ -1,7 +1,7 @@
/************************************************************************************
* arch/arm/src/imx/imx_system.h
*
- * Copyright (C) 2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
diff --git a/nuttx/arch/arm/src/lm3s/lm3s_internal.h b/nuttx/arch/arm/src/lm3s/lm3s_internal.h
index 38a079743..43bcf2d6f 100644
--- a/nuttx/arch/arm/src/lm3s/lm3s_internal.h
+++ b/nuttx/arch/arm/src/lm3s/lm3s_internal.h
@@ -474,9 +474,10 @@ EXTERN int lm3s_ethinitialize(int intf);
#endif
/****************************************************************************
- * The external functions, lm3s_spiselect and lm3s_spistatus must be provided
- * by board-specific logic. The are implementations of the select and status
- * methods SPI interface defined by struct spi_ops_s (see include/nuttx/spi.h).
+ * The external functions, lm3s_spiselect, lm3s_spistatus, and
+ * lm3s_spicmddata must be provided by board-specific logic. These are
+ * implementations of the select, status, and cmddaa methods of the SPI
+ * interface defined by struct spi_ops_s (see include/nuttx/spi.h).
* All other methods (including up_spiinitialize()) are provided by common
* logic. To use this common SPI logic on your board:
*
@@ -485,9 +486,13 @@ EXTERN int lm3s_ethinitialize(int intf);
* 2. Provide lm3s_spiselect() and lm3s_spistatus() functions in your
* board-specific logic. These functions will perform chip selection and
* status operations using GPIOs in the way your board is configured.
- * 3. Add a call to up_spiinitialize() in your low level application
+ * 3. If CONFIG_SPI_CMDDATA is defined in your NuttX configuration, provide
+ * the lm3s_spicmddata() function in your board-specific logic. This
+ * functions will perform cmd/data selection operations using GPIOs in
+ * the way your board is configured.
+ * 4. Add a call to up_spiinitialize() in your low level application
* initialization logic
- * 4. The handle returned by up_spiinitialize() may then be used to bind the
+ * 5. The handle returned by up_spiinitialize() may then be used to bind the
* SPI driver to higher level logic (e.g., calling
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to
* the SPI MMC/SD driver).
@@ -498,6 +503,9 @@ struct spi_dev_s;
enum spi_dev_e;
EXTERN void lm3s_spiselect(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
EXTERN uint8_t lm3s_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+#ifdef CONFIG_SPI_CMDDATA
+EXTERN int lm3s_spicmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+#endif
#undef EXTERN
#if defined(__cplusplus)
diff --git a/nuttx/arch/arm/src/lm3s/lm3s_ssi.c b/nuttx/arch/arm/src/lm3s/lm3s_ssi.c
index 8c3929ad7..3b6abab2c 100755
--- a/nuttx/arch/arm/src/lm3s/lm3s_ssi.c
+++ b/nuttx/arch/arm/src/lm3s/lm3s_ssi.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * arch/arm/src/lm32/lm3s_spi.c
+ * arch/arm/src/lm32/lm3s_ssi.c
*
* Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
@@ -279,6 +279,9 @@ static const struct spi_ops_s g_spiops =
.setmode = ssi_setmode,
.setbits = ssi_setbits,
.status = lm3s_spistatus, /* Provided externally by board logic */
+#ifdef CONFIG_SPI_CMDDATA
+ .cmddata = lm3s_spicmddata,
+#endif
.send = ssi_send,
#ifdef CONFIG_SPI_EXCHANGE
.exchange = ssi_exchange,
diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_internal.h b/nuttx/arch/arm/src/lpc17xx/lpc17_internal.h
index 41fe549b4..2c684767c 100755
--- a/nuttx/arch/arm/src/lpc17xx/lpc17_internal.h
+++ b/nuttx/arch/arm/src/lpc17xx/lpc17_internal.h
@@ -555,22 +555,26 @@ EXTERN int lpc17_dumpgpio(uint16_t pinset, const char *msg);
EXTERN void lpc17_clrpend(int irq);
/************************************************************************************
- * Name: lpc17_spi/ssp0/ssp1select and lpc17_spi/ssp0/ssp1status
+ * Name: lpc17_spi/ssp0/ssp1select, lpc17_spi/ssp0/ssp1status, and
+ * lpc17_spi/ssp0/ssp1cmddata
*
* Description:
- * The external functions, lpc17_spi/ssp0/ssp1select and lpc17_spi/ssp0/ssp1status
- * must be provided by board-specific logic. They are implementations of the select
- * and status methods of the SPI interface defined by struct spi_ops_s (see
- * include/nuttx/spi.h). All other methods (including up_spiinitialize())
- * are provided by common LPC17xx logic. To use this common SPI logic on your
- * board:
+ * These external functions must be provided by board-specific logic. They are
+ * implementations of the select, status, and cmddata methods of the SPI interface
+ * defined by struct spi_ops_s (see include/nuttx/spi.h). All other methods
+ * including up_spiinitialize()) are provided by common LPC17xx logic. To use
+ * this common SPI logic on your board:
*
* 1. Provide logic in lpc17_boardinitialize() to configure SPI/SSP chip select
* pins.
* 2. Provide lpc17_spi/ssp0/ssp1select() and lpc17_spi/ssp0/ssp1status() functions
* in your board-specific logic. These functions will perform chip selection
* and status operations using GPIOs in the way your board is configured.
- * 3. Add a calls to up_spiinitialize() in your low level application
+ * 2. If CONFIG_SPI_CMDDATA is defined in the NuttX configuration, provide
+ * lpc17_spi/ssp0/ssp1cmddata() functions in your board-specific logic. These
+ * functions will perform cmd/data selection operations using GPIOs in the way
+ * your board is configured.
+ * 3. Add a call to up_spiinitialize() in your low level application
* initialization logic
* 4. The handle returned by up_spiinitialize() may then be used to bind the
* SPI driver to higher level logic (e.g., calling
@@ -585,14 +589,23 @@ enum spi_dev_e;
#ifdef CONFIG_LPC17_SPI
EXTERN void lpc17_spiselect(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
EXTERN uint8_t lpc17_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+#ifdef CONFIG_SPI_CMDDATA
+EXTERN int lpc17_spicmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+#endif
#endif
#ifdef CONFIG_LPC17_SSP0
EXTERN void lpc17_ssp0select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
EXTERN uint8_t lpc17_ssp0status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+#ifdef CONFIG_SPI_CMDDATA
+EXTERN int lpc17_ssp0cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+#endif
#endif
#ifdef CONFIG_LPC17_SSP1
EXTERN void lpc17_ssp1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
EXTERN uint8_t lpc17_ssp1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+#ifdef CONFIG_SPI_CMDDATA
+EXTERN int lpc17_ssp1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+#endif
#endif
/****************************************************************************
diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_spi.c b/nuttx/arch/arm/src/lpc17xx/lpc17_spi.c
index 0525879b9..e5cc2b3e3 100755
--- a/nuttx/arch/arm/src/lpc17xx/lpc17_spi.c
+++ b/nuttx/arch/arm/src/lpc17xx/lpc17_spi.c
@@ -147,6 +147,9 @@ static const struct spi_ops_s g_spiops =
.setmode = spi_setmode,
.setbits = spi_setbits,
.status = lpc17_spistatus,
+#ifdef CONFIG_SPI_CMDDATA
+ .cmddata = lpc17_spicmddata,
+#endif
.send = spi_send,
.sndblock = spi_sndblock,
.recvblock = spi_recvblock,
diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_ssp.c b/nuttx/arch/arm/src/lpc17xx/lpc17_ssp.c
index e0331f09e..4512cbd28 100755
--- a/nuttx/arch/arm/src/lpc17xx/lpc17_ssp.c
+++ b/nuttx/arch/arm/src/lpc17xx/lpc17_ssp.c
@@ -171,6 +171,9 @@ static const struct spi_ops_s g_spi0ops =
.setmode = ssp_setmode,
.setbits = ssp_setbits,
.status = lpc17_ssp0status,
+#ifdef CONFIG_SPI_CMDDATA
+ .cmddata = lpc17_ssp0cmddata,
+#endif
.send = ssp_send,
.sndblock = ssp_sndblock,
.recvblock = ssp_recvblock,
@@ -198,6 +201,9 @@ static const struct spi_ops_s g_spi1ops =
.setmode = ssp_setmode,
.setbits = ssp_setbits,
.status = lpc17_ssp1status,
+#ifdef CONFIG_SPI_CMDDATA
+ .cmddata = lpc17_ssp1cmddata,
+#endif
.send = ssp_send,
.sndblock = ssp_sndblock,
.recvblock = ssp_recvblock,
diff --git a/nuttx/arch/arm/src/lpc313x/lpc313x_internal.h b/nuttx/arch/arm/src/lpc313x/lpc313x_internal.h
index ab8e3caf9..6fdbe9b37 100755
--- a/nuttx/arch/arm/src/lpc313x/lpc313x_internal.h
+++ b/nuttx/arch/arm/src/lpc313x/lpc313x_internal.h
@@ -173,21 +173,25 @@ EXTERN void lpc313x_clockconfig(void);
* Name: lpc313x_spiselect and lpc313x_spistatus
*
* Description:
- * The external functions, lpc313x_spiselect and lpc313x_spistatus must be
- * provided by board-specific logic. They are implementations of the select
- * and status methods of the SPI interface defined by struct spi_ops_s (see
- * include/nuttx/spi.h). All other methods (including up_spiinitialize())
- * are provided by common LPC313X logic. To use this common SPI logic on your
- * board:
+ * The external functions, lpc313x_spiselect, lpc313x_spistatus, and
+ * lpc313x_spicmddata must be provided by board-specific logic. These are
+ * implementations of the select, status, and cmddata methods of the SPI interface
+ * defined by struct spi_ops_s (see include/nuttx/spi.h). All other methods
+ * (including up_spiinitialize()) are provided by common LPC313X logic. To use
+ * this common SPI logic on your board:
*
* 1. Provide logic in lpc313x_boardinitialize() to configure SPI chip select
* pins.
* 2. Provide lpc313x_spiselect() and lpc313x_spistatus() functions in your
* board-specific logic. These functions will perform chip selection and
* status operations using GPIOs in the way your board is configured.
- * 3. Add a calls to up_spiinitialize() in your low level application
+ * 3. If CONFIG_SPI_CMDDATA is selected in your NuttX configuration, provide
+ * the lpc313x_spicmddata() function in your board-specific logic. This
+ * function will perform cmd/data selection operations using GPIOs in the
+ * way your board is configured.
+ * 4. Add a calls to up_spiinitialize() in your low level application
* initialization logic
- * 4. The handle returned by up_spiinitialize() may then be used to bind the
+ * 5. The handle returned by up_spiinitialize() may then be used to bind the
* SPI driver to higher level logic (e.g., calling
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to
* the SPI MMC/SD driver).
@@ -198,6 +202,9 @@ struct spi_dev_s;
enum spi_dev_e;
EXTERN void lpc313x_spiselect(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
EXTERN uint8_t lpc313x_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+#ifdef CONFIG_SPI_CMDDATA
+EXTERN int lpc313x_spicmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+#endif
/************************************************************************************
* Name: lpc313x_usbpullup
diff --git a/nuttx/arch/arm/src/lpc313x/lpc313x_spi.c b/nuttx/arch/arm/src/lpc313x/lpc313x_spi.c
index a089c5543..af4c9ce09 100644
--- a/nuttx/arch/arm/src/lpc313x/lpc313x_spi.c
+++ b/nuttx/arch/arm/src/lpc313x/lpc313x_spi.c
@@ -145,6 +145,9 @@ static const struct spi_ops_s g_spiops =
.setmode = spi_setmode,
.setbits = spi_setbits,
.status = spi_status,
+#ifdef CONFIG_SPI_CMDDATA
+ .cmddata = lpc313x_spicmddata,
+#endif
.send = spi_send,
#ifdef CONFIG_SPI_EXCHANGE
.exchange = spi_exchange,
diff --git a/nuttx/arch/arm/src/stm32/stm32_internal.h b/nuttx/arch/arm/src/stm32/stm32_internal.h
index d7e40ba63..9c13f04ef 100755
--- a/nuttx/arch/arm/src/stm32/stm32_internal.h
+++ b/nuttx/arch/arm/src/stm32/stm32_internal.h
@@ -1,7 +1,7 @@
/************************************************************************************
* arch/arm/src/stm32/stm32_internal.h
*
- * Copyright (C) 2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -445,21 +445,25 @@ EXTERN int stm32_ethinitialize(int intf);
* Name: stm32_spi1/2/3select and stm32_spi1/2/3status
*
* Description:
- * The external functions, stm32_spi1/2/3select and stm32_spi1/2/3status must be
- * provided by board-specific logic. They are implementations of the select
- * and status methods of the SPI interface defined by struct spi_ops_s (see
- * include/nuttx/spi.h). All other methods (including up_spiinitialize())
- * are provided by common STM32 logic. To use this common SPI logic on your
- * board:
+ * The external functions, stm32_spi1/2/3select, stm32_spi1/2/3status, and
+ * stm32_spi1/2/3cmddata must be provided by board-specific logic. These are
+ * implementations of the select, status, and cmddata methods of the SPI interface
+ * defined by struct spi_ops_s (see include/nuttx/spi.h). All other methods
+ * (including up_spiinitialize()) are provided by common STM32 logic. To use this
+ * common SPI logic on your board:
*
* 1. Provide logic in stm32_boardinitialize() to configure SPI chip select
* pins.
* 2. Provide stm32_spi1/2/3select() and stm32_spi1/2/3status() functions in your
* board-specific logic. These functions will perform chip selection and
* status operations using GPIOs in the way your board is configured.
- * 3. Add a calls to up_spiinitialize() in your low level application
+ * 3. If CONFIG_SPI_CMDDATA is defined in your NuttX configuration file, then
+ * provide stm32_spi1/2/3cmddata() functions in your board-specific logic.
+ * These functions will perform cmd/data selection operations using GPIOs in the
+ * way your board is configured.
+ * 4. Add a calls to up_spiinitialize() in your low level application
* initialization logic
- * 4. The handle returned by up_spiinitialize() may then be used to bind the
+ * 5. The handle returned by up_spiinitialize() may then be used to bind the
* SPI driver to higher level logic (e.g., calling
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to
* the SPI MMC/SD driver).
@@ -470,10 +474,13 @@ struct spi_dev_s;
enum spi_dev_e;
EXTERN void stm32_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
EXTERN uint8_t stm32_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+EXTERN int stm32_spi1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
EXTERN void stm32_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
EXTERN uint8_t stm32_spi2status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+EXTERN int stm32_spi2cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
EXTERN void stm32_spi3select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
EXTERN uint8_t stm32_spi3status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+EXTERN int stm32_spi3cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
/************************************************************************************
* Name: stm32_usbpullup
diff --git a/nuttx/arch/arm/src/stm32/stm32_spi.c b/nuttx/arch/arm/src/stm32/stm32_spi.c
index 4605f8a30..5e28ee879 100755
--- a/nuttx/arch/arm/src/stm32/stm32_spi.c
+++ b/nuttx/arch/arm/src/stm32/stm32_spi.c
@@ -209,6 +209,9 @@ static const struct spi_ops_s g_sp1iops =
.setmode = spi_setmode,
.setbits = spi_setbits,
.status = stm32_spi1status,
+#ifdef CONFIG_SPI_CMDDATA
+ .cmddata = stm32_spi1cmddata,
+#endif
.send = spi_send,
#ifdef CONFIG_SPI_EXCHANGE
.exchange = spi_exchange,
@@ -245,6 +248,9 @@ static const struct spi_ops_s g_sp2iops =
.setmode = spi_setmode,
.setbits = spi_setbits,
.status = stm32_spi2status,
+#ifdef CONFIG_SPI_CMDDATA
+ .cmddata = stm32_spi2cmddata,
+#endif
.send = spi_send,
#ifdef CONFIG_SPI_EXCHANGE
.exchange = spi_exchange,
@@ -281,6 +287,9 @@ static const struct spi_ops_s g_sp3iops =
.setmode = spi_setmode,
.setbits = spi_setbits,
.status = stm32_spi3status,
+#ifdef CONFIG_SPI_CMDDATA
+ .cmddata = stm32_spi3cmddata,
+#endif
.send = spi_send,
#ifdef CONFIG_SPI_EXCHANGE
.exchange = spi_exchange,
diff --git a/nuttx/arch/z80/src/ez80/ez80_spi.c b/nuttx/arch/z80/src/ez80/ez80_spi.c
index d701d5548..0c238f663 100755
--- a/nuttx/arch/z80/src/ez80/ez80_spi.c
+++ b/nuttx/arch/z80/src/ez80/ez80_spi.c
@@ -94,6 +94,9 @@ static const struct spi_ops_s g_spiops =
spi_setmode,
NULL, /* Variable number of bits not implemented */
ez80_spistatus, /* Provided externally by board logic */
+#ifdef CONFIG_SPI_CMDDATA
+ ez80_spicmddata,
+#endif
spi_send,
spi_sndblock,
spi_recvblock,
diff --git a/nuttx/arch/z80/src/ez80/ez80f91_spi.h b/nuttx/arch/z80/src/ez80/ez80f91_spi.h
index 9e697cbbe..e27df2693 100644
--- a/nuttx/arch/z80/src/ez80/ez80f91_spi.h
+++ b/nuttx/arch/z80/src/ez80/ez80f91_spi.h
@@ -2,7 +2,7 @@
* arch/z80/src/ez80/ez80f91_spi.h
* arch/z80/src/chip/ez80f91_spi.h
*
- * Copyright (C) 2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -99,23 +99,28 @@ extern "C" {
* Public Functions
************************************************************************************/
-/* The external functions, ez80_spiselect and ez80_spistatus must be provided by
- * board-specific logic. The are implementations of the select and status methods
- * SPI interface defined by struct spi_ops_s (see include/nuttx/spi.h). All other
- * methods (including up_spiinitialize()) are provided by common logic. To use this
- * common SPI logic on your board:
+/* The external functions, ez80_spiselect, ez80_spistatus, ans ez80_spicmddata must
+ * be provided by board-specific logic. These are implementations of the select,
+ * status, and cmddata methods of the SPI interface defined by struct spi_ops_s (see
+ * include/nuttx/spi.h). All other methods (including up_spiinitialize()) are
+ * provided by common logic. To use this common SPI logic on your board:
*
* 1. Provide ez80_spiselect() and ez80_spistatus() functions in your board-specific
* logic. This function will perform chip selection and status operations using
* GPIOs in the way your board is configured.
- * 2. Add a call to up_spiinitialize() in your low level initialization logic
- * 3. The handle returned by up_spiinitialize() may then be used to bind the
+ * 2. If CONFIG_SPI_CMDDATA is defined in your NuttX configuration, provide the
+ * ez80_spiscmddata() function in your board-specific logic. This function will
+ * perform cmd/data selection operations using GPIOs in the way your board is
+ * configured.
+ * 3. Add a call to up_spiinitialize() in your low level initialization logic
+ * 4. The handle returned by up_spiinitialize() may then be used to bind the
* SPI driver to higher level logic (e.g., calling mmcsd_spislotinitialize(),
* for example, will bind the SPI driver to the SPI MMC/SD driver).
*/
EXTERN void ez80_spiselect(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
EXTERN uint8_t ez80_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+EXTERN int ez80_spicmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
#undef EXTERN
#ifdef __cplusplus
diff --git a/nuttx/configs/mcu123-lpc214x/src/up_spi.c b/nuttx/configs/mcu123-lpc214x/src/up_spi.c
index d8ae8baf8..0c32fc6db 100644
--- a/nuttx/configs/mcu123-lpc214x/src/up_spi.c
+++ b/nuttx/configs/mcu123-lpc214x/src/up_spi.c
@@ -129,6 +129,9 @@ static int spi_lock(FAR struct spi_dev_s *dev, bool lock);
static void spi_select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev, uint32_t frequency);
static uint8_t spi_status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+#ifdef CONFIG_SPI_CMDDATA
+static int spi_cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+#endif
static uint16_t spi_send(FAR struct spi_dev_s *dev, uint16_t ch);
static void spi_sndblock(FAR struct spi_dev_s *dev, FAR const void *buffer, size_t nwords);
static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, size_t nwords);
@@ -145,6 +148,9 @@ static const struct spi_ops_s g_spiops =
.select = spi_select,
.setfrequency = spi_setfrequency,
.status = spi_status,
+#ifdef CONFIG_SPI_CMDDATA
+ .cmddata = spi_cmddata,
+#endif
.send = spi_send,
.sndblock = spi_sndblock,
.recvblock = spi_recvblock,
@@ -311,6 +317,38 @@ static uint8_t spi_status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
}
/****************************************************************************
+ * Name: spi_cmddata
+ *
+ * Description:
+ * Some devices require and additional out-of-band bit to specify if the
+ * next word sent to the device is a command or data. This is typical, for
+ * example, in "9-bit" displays where the 9th bit is the CMD/DATA bit.
+ * This function provides selection of command or data.
+ *
+ * This "latches" the CMD/DATA state. It does not have to be called before
+ * every word is transferred; only when the CMD/DATA state changes. This
+ * method is required if CONFIG_SPI_CMDDATA is selected in the NuttX
+ * configuration
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * cmd - TRUE: The following word is a command; FALSE: the following words
+ * are data.
+ *
+ * Returned Value:
+ * OK unless an error occurs. Then a negated errno value is returned
+ *
+ ****************************************************************************/
+
+ #ifdef CONFIG_SPI_CMDDATA
+static int spi_cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
+{
+# error "spi_cmddata not implemented"
+ return -ENOSYS;
+}
+#endif
+
+/****************************************************************************
* Name: spi_send
*
* Description:
diff --git a/nuttx/configs/olimex-strp711/src/up_spi.c b/nuttx/configs/olimex-strp711/src/up_spi.c
index 5ca35b72e..bbd046df7 100644
--- a/nuttx/configs/olimex-strp711/src/up_spi.c
+++ b/nuttx/configs/olimex-strp711/src/up_spi.c
@@ -396,6 +396,9 @@ static int spi_lock(FAR struct spi_dev_s *dev, bool lock);
static void spi_select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev, uint32_t frequency);
static uint8_t spi_status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+#ifdef CONFIG_SPI_CMDDATA
+static int spi_cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+#endif
static uint16_t spi_send(FAR struct spi_dev_s *dev, uint16_t wd);
static void spi_sndblock(FAR struct spi_dev_s *dev, FAR const void *buffer, size_t buflen);
static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, size_t buflen);
@@ -412,6 +415,9 @@ static const struct spi_ops_s g_spiops =
.select = spi_select,
.setfrequency = spi_setfrequency,
.status = spi_status,
+#ifdef CONFIG_SPI_CMDDATA
+ .cmddata = spi_cmddata,
+#endif
.send = spi_send,
.sndblock = spi_sndblock,
.recvblock = spi_recvblock,
@@ -703,6 +709,38 @@ static uint8_t spi_status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
}
/****************************************************************************
+ * Name: spi_cmddata
+ *
+ * Description:
+ * Some devices require and additional out-of-band bit to specify if the
+ * next word sent to the device is a command or data. This is typical, for
+ * example, in "9-bit" displays where the 9th bit is the CMD/DATA bit.
+ * This function provides selection of command or data.
+ *
+ * This "latches" the CMD/DATA state. It does not have to be called before
+ * every word is transferred; only when the CMD/DATA state changes. This
+ * method is required if CONFIG_SPI_CMDDATA is selected in the NuttX
+ * configuration
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * cmd - TRUE: The following word is a command; FALSE: the following words
+ * are data.
+ *
+ * Returned Value:
+ * OK unless an error occurs. Then a negated errno value is returned
+ *
+ ****************************************************************************/
+
+ #ifdef CONFIG_SPI_CMDDATA
+static int spi_cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
+{
+# error "spi_cmddata not implemented"
+ return -ENOSYS;
+}
+#endif
+
+/****************************************************************************
* Name: spi_send
*
* Description:
diff --git a/nuttx/include/nuttx/spi.h b/nuttx/include/nuttx/spi.h
index 12d9b0aee..a29fd0a78 100644
--- a/nuttx/include/nuttx/spi.h
+++ b/nuttx/include/nuttx/spi.h
@@ -188,6 +188,34 @@
#define SPI_STATUS_WRPROTECTED 0x02 /* Bit 1=1: MMC/SD card write protected */
/****************************************************************************
+ * Name: SPI_CMDDATA
+ *
+ * Description:
+ * Some devices require and additional out-of-band bit to specify if the
+ * next word sent to the device is a command or data. This is typical, for
+ * example, in "9-bit" displays where the 9th bit is the CMD/DATA bit.
+ * This function provides selection of command or data.
+ *
+ * This "latches" the CMD/DATA state. It does not have to be called before
+ * every word is transferred; only when the CMD/DATA state changes. This
+ * method is required if CONFIG_SPI_CMDDATA is selected in the NuttX
+ * configuration
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * cmd - TRUE: The following word is a command; FALSE: the following words
+ * are data.
+ *
+ * Returned Value:
+ * OK unless an error occurs. Then a negated errno value is returned
+ *
+ ****************************************************************************/
+
+#ifndef CONFIG_SPI_CMDDATA
+# define SPI_CMDDATA(d,id,cmd) ((d)->ops->cmddata(d,id,cmd))
+#endif
+
+/****************************************************************************
* Name: SPI_SEND
*
* Description:
@@ -348,6 +376,9 @@ struct spi_ops_s
void (*setmode)(FAR struct spi_dev_s *dev, enum spi_mode_e mode);
void (*setbits)(FAR struct spi_dev_s *dev, int nbits);
uint8_t (*status)(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+#ifndef CONFIG_SPI_CMDDATA
+ int (*cmddata)(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+#endif
uint16_t (*send)(FAR struct spi_dev_s *dev, uint16_t wd);
#ifdef CONFIG_SPI_EXCHANGE
void (*exchange)(FAR struct spi_dev_s *dev, FAR const void *txbuffer,