Backport SPI driver enhancements from SAMA5 to SAM3/4

This commit is contained in:
Gregory Nutt 2014-03-13 10:34:35 -06:00
parent 6bc43d49c2
commit 1c1e821b34
5 changed files with 41 additions and 37 deletions

View File

@ -107,14 +107,14 @@ void weak_function sam_spiinitialize(void)
}
/****************************************************************************
* Name: sam_spiselect, sam_spistatus, and sam_spicmddata
* Name: sam_spi0select, sam_spi0status, and sam_spic0mddata
*
* Description:
* These external functions must be provided by board-specific logic. They
* include:
*
* o sam_spiselect is a functions tomanage the board-specific chip selects
* o sam_spistatus and sam_spicmddata: Implementations of the status
* o sam_spi0select is a functions tomanage the board-specific chip selects
* o sam_spi0status and sam_spic0mddata: Implementations of the status
* and cmddata methods of the SPI interface defined by struct spi_ops_
* (see include/nuttx/spi/spi.h). All other methods including
* up_spiinitialize()) are provided by common SAM3/4 logic.
@ -123,11 +123,11 @@ void weak_function sam_spiinitialize(void)
*
* 1. Provide logic in sam_boardinitialize() to configure SPI chip select
* pins.
* 2. Provide sam_spiselect() and sam_spistatus() functions in your board-
* 2. Provide sam_spi0select() and sam_spi0status() functions in your board-
* specific logic. These functions will perform chip selection and
* status operations using GPIOs in the way your board is configured.
* 2. If CONFIG_SPI_CMDDATA is defined in the NuttX configuration, provide
* sam_spicmddata() functions in your board-specific logic. This
* sam_spic0mddata() functions 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 application
@ -140,7 +140,7 @@ void weak_function sam_spiinitialize(void)
****************************************************************************/
/****************************************************************************
* Name: sam_spiselect
* Name: sam_spi0select
*
* Description:
* PIO chip select pins may be programmed by the board specific logic in
@ -164,7 +164,7 @@ void weak_function sam_spiinitialize(void)
*
****************************************************************************/
void sam_spiselect(enum spi_dev_e devid, bool selected)
void sam_spi0select(enum spi_dev_e devid, bool selected)
{
/* The touchscreen chip select is implemented as a GPIO OUTPUT that must
* be controlled by this function. This is because the ADS7843E driver
@ -183,7 +183,7 @@ void sam_spiselect(enum spi_dev_e devid, bool selected)
}
/****************************************************************************
* Name: sam_spistatus
* Name: sam_spi0status
*
* Description:
* Return status information associated with the SPI device.
@ -196,7 +196,7 @@ void sam_spiselect(enum spi_dev_e devid, bool selected)
*
****************************************************************************/
uint8_t sam_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
uint8_t sam_spi0status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
{
return 0;
}

View File

@ -40,7 +40,7 @@ CFLAGS += -I$(TOPDIR)/sched
ASRCS =
AOBJS = $(ASRCS:.S=$(OBJEXT))
CSRCS = sam_boot.c sam_leds.c sam_buttons.c sam_spi.c sam_usbdev.c
CSRCS = sam_boot.c sam_leds.c sam_buttons.c sam_usbdev.c
ifeq ($(CONFIG_HAVE_CXXINITIALIZE),y)
CSRCS += sam_cxxinitialize.c
@ -58,6 +58,10 @@ ifeq ($(CONFIG_SAM34_HSMCI),y)
CSRCS += sam_mmcsd.c
endif
ifeq ($(CONFIG_SAM34_SPI0),y)
CSRCS += sam_spi.c
endif
ifeq ($(CONFIG_USBMSC),y)
CSRCS += sam_usbmsc.c
endif

View File

@ -268,9 +268,9 @@
* it low throughout the SPI transfer.
*/
#define GPIO_TSC_NPCS2 (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_SET | \
GPIO_PORT_PIOA | GPIO_PIN11)
#define TSC_CSNUM 0
#define GPIO_TSC_CS (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_SET | \
GPIO_PORT_PIOA | GPIO_PIN11)
#define TSC_CSNUM 0
/************************************************************************************
* Public Types

View File

@ -53,7 +53,7 @@
#include "sam_spi.h"
#include "sam4e-ek.h"
#if defined(CONFIG_SAM34_SPI0) || defined(CONFIG_SAM34_SPI1)
#if defined(CONFIG_SAM34_SPI0)
/************************************************************************************
* Definitions
@ -99,22 +99,22 @@ void weak_function sam_spiinitialize(void)
* ZigBee support.
*/
/* The touchscreen connects using NPCS2 (PC14). */
/* The touchscreen connects using NPCS0 (PA11). */
#if defined(CONFIG_INPUT) && defined(CONFIG_INPUT_ADS7843E)
sam_configgpio(GPIO_TSC_NPCS2);
sam_configgpio(GPIO_TSC_CS);
#endif
}
/****************************************************************************
* Name: sam_spiselect, sam_spistatus, and sam_spicmddata
* Name: sam_spi0select, sam_spi0status, and sam_spic0mddata
*
* Description:
* These external functions must be provided by board-specific logic. They
* include:
*
* o sam_spiselect is a functions tomanage the board-specific chip selects
* o sam_spistatus and sam_spicmddata: Implementations of the status
* o sam_spi0select is a functions tomanage the board-specific chip selects
* o sam_spi0status and sam_spic0mddata: Implementations of the status
* and cmddata methods of the SPI interface defined by struct spi_ops_
* (see include/nuttx/spi/spi.h). All other methods including
* up_spiinitialize()) are provided by common SAM3/4 logic.
@ -123,11 +123,11 @@ void weak_function sam_spiinitialize(void)
*
* 1. Provide logic in sam_boardinitialize() to configure SPI chip select
* pins.
* 2. Provide sam_spiselect() and sam_spistatus() functions in your board-
* 2. Provide sam_spi0select() and sam_spi0status() functions in your board-
* specific logic. These functions will perform chip selection and
* status operations using GPIOs in the way your board is configured.
* 2. If CONFIG_SPI_CMDDATA is defined in the NuttX configuration, provide
* sam_spicmddata() functions in your board-specific logic. This
* sam_spic0mddata() functions 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 application
@ -140,7 +140,7 @@ void weak_function sam_spiinitialize(void)
****************************************************************************/
/****************************************************************************
* Name: sam_spiselect
* Name: sam_spi0select
*
* Description:
* PIO chip select pins may be programmed by the board specific logic in
@ -164,7 +164,7 @@ void weak_function sam_spiinitialize(void)
*
****************************************************************************/
void sam_spiselect(enum spi_dev_e devid, bool selected)
void sam_spi0select(enum spi_dev_e devid, bool selected)
{
/* The touchscreen chip select is implemented as a GPIO OUTPUT that must
* be controlled by this function. This is because the ADS7843E driver
@ -177,13 +177,13 @@ void sam_spiselect(enum spi_dev_e devid, bool selected)
#if defined(CONFIG_INPUT) && defined(CONFIG_INPUT_ADS7843E)
if (devid == SPIDEV_TOUCHSCREEN)
{
sam_gpiowrite(GPIO_TSC_NPCS2, !selected);
sam_gpiowrite(GPIO_TSC_CS, !selected);
}
#endif
}
/****************************************************************************
* Name: sam_spistatus
* Name: sam_spi0status
*
* Description:
* Return status information associated with the SPI device.
@ -196,7 +196,7 @@ void sam_spiselect(enum spi_dev_e devid, bool selected)
*
****************************************************************************/
uint8_t sam_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
uint8_t sam_spi0status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
{
return 0;
}

View File

@ -115,14 +115,14 @@ void weak_function sam_spiinitialize(void)
}
/****************************************************************************
* Name: sam_spiselect, sam_spistatus, and sam_spicmddata
* Name: sam_spi0select, sam_spi0status, and sam_spic0mddata
*
* Description:
* These external functions must be provided by board-specific logic. They
* include:
*
* o sam_spiselect is a functions tomanage the board-specific chip selects
* o sam_spistatus and sam_spicmddata: Implementations of the status
* o sam_spi0select is a functions tomanage the board-specific chip selects
* o sam_spi0status and sam_spic0mddata: Implementations of the status
* and cmddata methods of the SPI interface defined by struct spi_ops_
* (see include/nuttx/spi/spi.h). All other methods including
* up_spiinitialize()) are provided by common SAM3/4 logic.
@ -131,11 +131,11 @@ void weak_function sam_spiinitialize(void)
*
* 1. Provide logic in sam_boardinitialize() to configure SPI chip select
* pins.
* 2. Provide sam_spiselect() and sam_spistatus() functions in your board-
* 2. Provide sam_spi0select() and sam_spi0status() functions in your board-
* specific logic. These functions will perform chip selection and
* status operations using GPIOs in the way your board is configured.
* 2. If CONFIG_SPI_CMDDATA is defined in the NuttX configuration, provide
* sam_spicmddata() functions in your board-specific logic. This
* sam_spic0mddata() functions 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 application
@ -148,7 +148,7 @@ void weak_function sam_spiinitialize(void)
****************************************************************************/
/****************************************************************************
* Name: sam_spiselect
* Name: sam_spi0select
*
* Description:
* PIO chip select pins may be programmed by the board specific logic in
@ -172,7 +172,7 @@ void weak_function sam_spiinitialize(void)
*
****************************************************************************/
void sam_spiselect(enum spi_dev_e devid, bool selected)
void sam_spi0select(enum spi_dev_e devid, bool selected)
{
#ifdef CONFIG_SAM4L_XPLAINED_IOMODULE
/* Select/de-select the SD card */
@ -202,7 +202,7 @@ void sam_spiselect(enum spi_dev_e devid, bool selected)
}
/****************************************************************************
* Name: sam_spistatus
* Name: sam_spi0status
*
* Description:
* Return status information associated with the SPI device.
@ -215,7 +215,7 @@ void sam_spiselect(enum spi_dev_e devid, bool selected)
*
****************************************************************************/
uint8_t sam_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
uint8_t sam_spi0status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
{
uint8_t ret = 0;
@ -239,7 +239,7 @@ uint8_t sam_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
#endif /* CONFIG_SAM34_SPI0 */
/****************************************************************************
* Name: sam_spicmddata
* Name: sam_spic0mddata
*
* Description:
* Some SPI devices require an additional control to determine if the SPI
@ -263,7 +263,7 @@ uint8_t sam_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
****************************************************************************/
#ifdef CONFIG_SPI_CMDDATA
int sam_spicmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
int sam_spic0mddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd)
{
#ifdef CONFIG_SAM4L_XPLAINED_OLED1MODULE
if (devid == SPIDEV_DISPLAY)