Backport SPI driver enhancements from SAMA5 to SAM3/4
This commit is contained in:
parent
0bd5f23a30
commit
7e16cee6b5
@ -6988,3 +6988,9 @@
|
||||
functional (2014-3-13).
|
||||
* configs/sam4e-ek/nsh: Networking support is now enabled by default
|
||||
in the NSH configuration (2014-3-13).
|
||||
* arch/arm/src/sam34/sam_spi.c: Backported the SAMA5 SPI driver to
|
||||
the SAM3/4 architecture. The SAMA5 version supports both multiple
|
||||
SPI peripherals as needed by the SAM3A and SAM3X and also supports
|
||||
DMAC (but not PDC). The initial commit is untested and may very
|
||||
well have (temporarily) broken SPI for the SAM3/4/ family (2014-3-13).
|
||||
|
||||
|
@ -454,11 +454,13 @@ config SAM34_SMC
|
||||
config SAM34_SPI0
|
||||
bool "Serial Peripheral Interface 0 (SPI0)"
|
||||
default n
|
||||
select SPI
|
||||
|
||||
config SAM34_SPI1
|
||||
bool "Serial Peripheral Interface 1 (SPI1)"
|
||||
default n
|
||||
depends on ARCH_CHIP_SAM3X || ARCH_CHIP_SAM3A
|
||||
select SPI
|
||||
|
||||
config SAM34_SSC
|
||||
bool "Synchronous Serial Controller (SSC)"
|
||||
@ -871,6 +873,47 @@ config GPIOF_IRQ
|
||||
endif # GPIO_IRQ
|
||||
endmenu # AT91SAM3/4 GPIO Interrupt Configuration
|
||||
|
||||
if SAM34_SPI0 || SAM34_SPI1
|
||||
|
||||
menu "SPI device driver options"
|
||||
|
||||
config SAM34_SPI_DMA
|
||||
bool "SPI DMA"
|
||||
default n
|
||||
depends on (SAM34_DMAC0 && SAM34_SPI0) || (SAM34_DMAC1 && SAM34_SPI1)
|
||||
---help---
|
||||
Use DMA to improve SPI transfer performance.
|
||||
|
||||
config SAM34_SPI_DMATHRESHOLD
|
||||
int "SPI DMA threshold"
|
||||
default 4
|
||||
depends on SAM34_SPI_DMA
|
||||
---help---
|
||||
When SPI DMA is enabled, small DMA transfers will still be performed
|
||||
by polling logic. But we need a threshold value to determine what
|
||||
is small. That value is provided by SAM34_SPI_DMATHRESHOLD.
|
||||
|
||||
config SAM34_SPI_DMADEBUG
|
||||
bool "SPI DMA transfer debug"
|
||||
depends on SAM34_SPI_DMA && DEBUG && DEBUG_DMA
|
||||
default n
|
||||
---help---
|
||||
Enable special debug instrumentation analyze SPI DMA data transfers.
|
||||
This logic is as non-invasive as possible: It samples DMA
|
||||
registers at key points in the data transfer and then dumps all of
|
||||
the registers at the end of the transfer.
|
||||
|
||||
config SAM34_SPI_REGDEBUG
|
||||
bool "SPI Register level debug"
|
||||
depends on DEBUG
|
||||
default n
|
||||
---help---
|
||||
Output detailed register-level SPI device debug information.
|
||||
Requires also DEBUG.
|
||||
|
||||
endmenu # SPI device driver options
|
||||
endif # SAM34_SPI0 || SAM34_SPI1
|
||||
|
||||
if SAM34_EMAC
|
||||
|
||||
menu "AT91SAM3/4 EMAC device driver options"
|
||||
|
@ -114,4 +114,8 @@ endif
|
||||
|
||||
ifeq ($(CONFIG_SAM34_SPI0),y)
|
||||
CHIP_CSRCS += sam_spi.c
|
||||
else
|
||||
ifeq ($(CONFIG_SAM34_SPI1),y)
|
||||
CHIP_CSRCS += sam_spi.c
|
||||
endif
|
||||
endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* arch/arm/src/sam34/sam_spi.h
|
||||
*
|
||||
* Copyright (C) 2009-2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2009-2011, 2013-2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -31,14 +31,14 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_ARM_SRC_SAM34_SAM_SPI_H
|
||||
#define __ARCH_ARM_SRC_SAM34_SAM_SPI_H
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
@ -47,23 +47,53 @@
|
||||
|
||||
#include "chip.h"
|
||||
|
||||
/************************************************************************************
|
||||
* Definitions
|
||||
************************************************************************************/
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
/* The SPI port number used as an input to up_spiinitialize encodes
|
||||
* information about the SPI controller (0 or 1) and the SPI chip select
|
||||
* (0-3).
|
||||
*
|
||||
* NOTE that this is this is backward compatible with older implementations
|
||||
* that support only SPI0 and provide only the chip select number to
|
||||
* up_spiinitialize().
|
||||
*/
|
||||
|
||||
#define __SPI_CS_SHIFT (0) /* Bits 0-1: SPI chip select number */
|
||||
#define __SPI_CS_MASK (3 << __SPI_CS_SHIFT)
|
||||
# define __SPI_CS0 (0 << __SPI_CS_SHIFT)
|
||||
# define __SPI_CS1 (1 << __SPI_CS_SHIFT)
|
||||
# define __SPI_CS2 (2 << __SPI_CS_SHIFT)
|
||||
# define __SPI_CS3 (3 << __SPI_CS_SHIFT)
|
||||
#define __SPI_SPI_SHIFT (2) /* Bit 2: SPI controller number */
|
||||
#define __SPI_SPI_MASK (1 << __SPI_SPI_SHIFT)
|
||||
# define __SPI_SPI0 (0 << __SPI_SPI_SHIFT) /* SPI0 */
|
||||
# define __SPI_SPI1 (1 << __SPI_SPI_SHIFT) /* SPI1 */
|
||||
|
||||
#define SPI0_CS0 (__SPI_SPI0 | __SPI_CS0)
|
||||
#define SPI0_CS1 (__SPI_SPI0 | __SPI_CS1)
|
||||
#define SPI0_CS2 (__SPI_SPI0 | __SPI_CS2)
|
||||
#define SPI0_CS3 (__SPI_SPI0 | __SPI_CS3)
|
||||
|
||||
#define SPI1_CS0 (__SPI_SPI1 | __SPI_CS0)
|
||||
#define SPI1_CS1 (__SPI_SPI1 | __SPI_CS1)
|
||||
#define SPI1_CS2 (__SPI_SPI1 | __SPI_CS2)
|
||||
#define SPI1_CS3 (__SPI_SPI1 | __SPI_CS3)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Inline Functions
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
@ -74,33 +104,34 @@ extern "C"
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_spiselect, sam_spistatus, and sam_spicmddata
|
||||
* Name: sam_spi[0|1]select, sam_spi[0|1]status, and sam_spi[0|1]cmddata
|
||||
*
|
||||
* Description:
|
||||
* These external functions must be provided by board-specific logic. They
|
||||
* include:
|
||||
* 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
|
||||
* and cmddata methods of the SPI interface defined by struct spi_ops_
|
||||
* (see include/nuttx/spi/spi.h). All other methods including
|
||||
* o sam_spi[0|1]select is a functions tomanage the board-specific chip
|
||||
* selects
|
||||
* o sam_spi[0|1]status and sam_spi[0|1]cmddata: 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.
|
||||
*
|
||||
* To use this common SPI logic on your board:
|
||||
*
|
||||
* 1. Provide logic in sam_boardinitialize() to configure SPI chip select
|
||||
* pins.
|
||||
* 2. Provide sam_spiselect() and sam_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.
|
||||
* 2. Provide sam_spi[0|1]select() and sam_spi[0|1]status() functions in
|
||||
* our board-specific logic. These functions will perform chip selection
|
||||
* and status operations using PIOs 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
|
||||
* function will perform cmd/data selection operations using GPIOs in
|
||||
* sam_spi[0|1]cmddata() functions in your board-specific logic. This
|
||||
* function will perform cmd/data selection operations using PIOs in
|
||||
* the way your board is configured.
|
||||
* 3. Add a call to up_spiinitialize() in your low level application
|
||||
* initialization logic
|
||||
@ -116,7 +147,7 @@ struct spi_dev_s;
|
||||
enum spi_dev_e;
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_spiselect
|
||||
* Name: sam_spi[0|1]select
|
||||
*
|
||||
* Description:
|
||||
* PIO chip select pins may be programmed by the board specific logic in
|
||||
@ -126,9 +157,9 @@ enum spi_dev_e;
|
||||
* a stub.
|
||||
*
|
||||
* An alternative way to program the PIO chip select pins is as a normal
|
||||
* GPIO output. In that case, the automatic control of the CS pins is
|
||||
* PIO output. In that case, the automatic control of the CS pins is
|
||||
* bypassed and this function must provide control of the chip select.
|
||||
* NOTE: In this case, the GPIO output pin does *not* have to be the
|
||||
* NOTE: In this case, the PIO output pin does *not* have to be the
|
||||
* same as the NPCS pin normal associated with the chip select number.
|
||||
*
|
||||
* Input Parameters:
|
||||
@ -141,10 +172,15 @@ enum spi_dev_e;
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void sam_spiselect(enum spi_dev_e devid, bool selected);
|
||||
#ifdef CONFIG_SAM34_SPI0
|
||||
void sam_spi0select(enum spi_dev_e devid, bool selected);
|
||||
#endif
|
||||
#ifdef CONFIG_SAM34_SPI1
|
||||
void sam_spi1select(enum spi_dev_e devid, bool selected);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_spistatus
|
||||
* Name: sam_spi[0|1]status
|
||||
*
|
||||
* Description:
|
||||
* Return status information associated with the SPI device.
|
||||
@ -158,10 +194,15 @@ 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);
|
||||
#ifdef CONFIG_SAM34_SPI0
|
||||
uint8_t sam_spi0status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
|
||||
#endif
|
||||
#ifdef CONFIG_SAM34_SPI1
|
||||
uint8_t sam_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_spicmddata
|
||||
* Name: sam_spi[0|1]cmddata
|
||||
*
|
||||
* Description:
|
||||
* Some SPI devices require an additional control to determine if the SPI
|
||||
@ -172,7 +213,7 @@ uint8_t sam_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
|
||||
* may be configured to use 9-bit data transfers with the 9th bit
|
||||
* indicating command or data. That same hardware may be configurable,
|
||||
* instead, to use 8-bit data but to require an additional, board-
|
||||
* specific GPIO control to distinguish command and data. This function
|
||||
* specific PIO control to distinguish command and data. This function
|
||||
* would be needed in that latter case.
|
||||
*
|
||||
* Input Parameters:
|
||||
@ -185,7 +226,12 @@ 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);
|
||||
#ifdef CONFIG_SAM34_SPI0
|
||||
int sam_spi0cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
|
||||
#endif
|
||||
#ifdef CONFIG_SAM34_SPI1
|
||||
int sam_spi1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
|
||||
#endif
|
||||
#endif
|
||||
#endif /* CONFIG_SAM34_SPI0 */
|
||||
|
||||
|
@ -1310,7 +1310,7 @@ config SAMA5_CAN_REGDEBUG
|
||||
Output detailed register-level CAN device debug information.
|
||||
Requires also DEBUG.
|
||||
|
||||
endmenu # SPI device driver options
|
||||
endmenu # CAN device driver options
|
||||
endif # SAMA5_CAN0 || SAMA5_CAN1
|
||||
|
||||
if SAMA5_SPI0 || SAMA5_SPI1
|
||||
|
@ -736,6 +736,7 @@ static void spi_dma_sampledone(struct sam_spics_s *spics)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SAMA5_SPI_DMA
|
||||
static void spi_dmatimeout(int argc, uint32_t arg)
|
||||
{
|
||||
struct sam_spics_s *spics = (struct sam_spics_s *)arg;
|
||||
@ -755,6 +756,7 @@ static void spi_dmatimeout(int argc, uint32_t arg)
|
||||
|
||||
sem_post(&spics->dmawait);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: spi_rxcallback
|
||||
|
@ -1,4 +1,4 @@
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* arch/arm/src/sama5/sam_spi.h
|
||||
*
|
||||
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
||||
@ -31,14 +31,14 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_ARM_SRC_SAMA5_SAM_SPI_H
|
||||
#define __ARCH_ARM_SRC_SAMA5_SAM_SPI_H
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
@ -47,9 +47,9 @@
|
||||
|
||||
#include "chip.h"
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/* The SPI port number used as an input to up_spiinitialize encodes information
|
||||
* about the SPI controller (0 or 1) and the SPI chip select (0-3)
|
||||
@ -76,19 +76,19 @@
|
||||
#define SPI1_CS2 (__SPI_SPI1 | __SPI_CS2)
|
||||
#define SPI1_CS3 (__SPI_SPI1 | __SPI_CS3)
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Inline Functions
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
@ -99,9 +99,9 @@ extern "C"
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
************************************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_spi[0|1]select, sam_spi[0|1]status, and sam_spi[0|1]cmddata
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user