diff --git a/arch/arm/src/imx/chip.h b/arch/arm/src/imx/chip.h index 00272ccdb8d4e65b71975ee3f471065e3d763b12..c8a6615d7e0523e600e7d9ea0ed9b4f9ef4b9def 100644 --- a/arch/arm/src/imx/chip.h +++ b/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/arch/arm/src/imx/imx_cspi.h b/arch/arm/src/imx/imx_cspi.h index e0d97f2d4413657f478d3a3c4e4af9bfcfad83ed..421b6a4e31f8b18f8a1877d5ae67c08118171839 100755 --- a/arch/arm/src/imx/imx_cspi.h +++ b/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/arch/arm/src/imx/imx_memorymap.h b/arch/arm/src/imx/imx_memorymap.h index d656b2f808f297c8bb0bd4e4bea8281cbec43c53..0b7603befba70ab6aee093e8423ee583a6b40bd5 100644 --- a/arch/arm/src/imx/imx_memorymap.h +++ b/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/arch/arm/src/imx/imx_spi.c b/arch/arm/src/imx/imx_spi.c index 578e274cd24d80a834b596dc0a2e9c0fe6e7ecc9..e07cd5d32e005887721ac92a8b01d4b7713714cb 100755 --- a/arch/arm/src/imx/imx_spi.c +++ b/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/arch/arm/src/imx/imx_system.h b/arch/arm/src/imx/imx_system.h index fe575cf4149762430781ec28b10d96e7eb1203d5..a3a4b4c54993c1252f3f3c3359ba3301351e492c 100755 --- a/arch/arm/src/imx/imx_system.h +++ b/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/arch/arm/src/lm3s/lm3s_internal.h b/arch/arm/src/lm3s/lm3s_internal.h index 38a079743bafd95165d23c27221c2579e7ca4714..43bcf2d6f57524f312305af1a4e85441c7d3b1ab 100644 --- a/arch/arm/src/lm3s/lm3s_internal.h +++ b/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/arch/arm/src/lm3s/lm3s_ssi.c b/arch/arm/src/lm3s/lm3s_ssi.c index 8c3929ad72893e8e2ef63b66686c882dbf79eead..3b6abab2c91870d90fba0fc1997133c55d59c8f7 100755 --- a/arch/arm/src/lm3s/lm3s_ssi.c +++ b/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/arch/arm/src/lpc17xx/lpc17_internal.h b/arch/arm/src/lpc17xx/lpc17_internal.h index 41fe549b4b6e984a19a330ad94eed8fab1b268f4..2c684767c87199d9290cd62d29a83e34988f2065 100755 --- a/arch/arm/src/lpc17xx/lpc17_internal.h +++ b/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/arch/arm/src/lpc17xx/lpc17_spi.c b/arch/arm/src/lpc17xx/lpc17_spi.c index 0525879b90fdbbda116ca26d476c4cfbfb428e46..e5cc2b3e3fc2e99c0f8d11da25d8a016d1daff11 100755 --- a/arch/arm/src/lpc17xx/lpc17_spi.c +++ b/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/arch/arm/src/lpc17xx/lpc17_ssp.c b/arch/arm/src/lpc17xx/lpc17_ssp.c index e0331f09ea957a844f56da47d07eaa756e736306..4512cbd285a75aaa4fd4b32cd217bd7bbdf224f1 100755 --- a/arch/arm/src/lpc17xx/lpc17_ssp.c +++ b/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/arch/arm/src/lpc313x/lpc313x_internal.h b/arch/arm/src/lpc313x/lpc313x_internal.h index ab8e3caf9ae85f23d0892da9bc60ed9ea35ec438..6fdbe9b377a10c72d54f48f96abe72afd1b7c068 100755 --- a/arch/arm/src/lpc313x/lpc313x_internal.h +++ b/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/arch/arm/src/lpc313x/lpc313x_spi.c b/arch/arm/src/lpc313x/lpc313x_spi.c index a089c5543cda4810335c4e436c7d5aa08408e4d4..af4c9ce09e060c047a7c0686c136daf5ac04fa92 100644 --- a/arch/arm/src/lpc313x/lpc313x_spi.c +++ b/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/arch/arm/src/stm32/stm32_internal.h b/arch/arm/src/stm32/stm32_internal.h index d7e40ba63e6f6860655a100e59174920ef0f10fb..9c13f04ef2069bb4f1d37b7f412d6250365992bb 100755 --- a/arch/arm/src/stm32/stm32_internal.h +++ b/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/arch/arm/src/stm32/stm32_spi.c b/arch/arm/src/stm32/stm32_spi.c index 4605f8a30610f8c72fe3b2cbf967371c07d71f11..5e28ee8792ad5c82562dae1e4fe324e52ec1328c 100755 --- a/arch/arm/src/stm32/stm32_spi.c +++ b/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/arch/z80/src/ez80/ez80_spi.c b/arch/z80/src/ez80/ez80_spi.c index d701d5548432fba50332c38b53d23643b95ea74a..0c238f663e33eeb6ab06602fa8981297f247e4d8 100755 --- a/arch/z80/src/ez80/ez80_spi.c +++ b/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/arch/z80/src/ez80/ez80f91_spi.h b/arch/z80/src/ez80/ez80f91_spi.h index 9e697cbbea9850392cfe7db0875e096c917b0cc7..e27df2693abd712be3f644e2369308239aef67cf 100644 --- a/arch/z80/src/ez80/ez80f91_spi.h +++ b/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/configs/mcu123-lpc214x/src/up_spi.c b/configs/mcu123-lpc214x/src/up_spi.c index d8ae8baf8cdaadfb8143bcf3fa3db40d27a63c6d..0c32fc6db225a850387400ca77c5c96376fc9b56 100644 --- a/configs/mcu123-lpc214x/src/up_spi.c +++ b/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, @@ -310,6 +316,38 @@ static uint8_t spi_status(FAR struct spi_dev_s *dev, enum spi_dev_e devid) return SPI_STATUS_PRESENT; } +/**************************************************************************** + * 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 * diff --git a/configs/olimex-strp711/src/up_spi.c b/configs/olimex-strp711/src/up_spi.c index 5ca35b72e64c68797e6f725578bba85822ee7efc..bbd046df7078e9f868be97c75dae29683bf76b91 100644 --- a/configs/olimex-strp711/src/up_spi.c +++ b/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, @@ -702,6 +708,38 @@ static uint8_t spi_status(FAR struct spi_dev_s *dev, enum spi_dev_e devid) return ret; } +/**************************************************************************** + * 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 * diff --git a/include/nuttx/spi.h b/include/nuttx/spi.h index 12d9b0aee716baa95ec7bfa35ee04ebb3b394d05..a29fd0a78afaf52b15fb3e8637407454b7b4bbb7 100644 --- a/include/nuttx/spi.h +++ b/include/nuttx/spi.h @@ -187,6 +187,34 @@ #define SPI_STATUS_PRESENT 0x01 /* Bit 0=1: MMC/SD card present */ #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 * @@ -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,