TI-RTOS Drivers  tidrivers_tivac_2_16_00_08
Data Structures | Macros | Typedefs | Enumerations | Variables
SPITivaDMA.h File Reference

Detailed Description

SPI driver implementation for a TivaSPIcontroller using the micro DMA controller.

============================================================================

The SPI header file should be included in an application as follows:

Refer to SPI.h for a complete description of APIs & example of use.

This SPI driver implementation is designed to operate on a Tiva SPI controller using a micro DMA controller.

SPI Chip Select

This SPI controller supports a hardware chip select pin. Refer to the device's user manual on how this hardware chip select pin behaves in regards to the SPI frame format.

Chip select type SPI_MASTER mode SPI_SLAVE mode
Hardware chip select No action is needed by the application to select the peripheral. See the device documentation on it's chip select requirements.
Software chip select The application is responsible to ensure that correct SPI slave is selected before performing a SPI_transfer(). See the device documentation on it's chip select requirements.

DMA Interrupts

This driver is designed to operation on a micro DMA. The micro DMA generates IRQ on the perpheral's interrupt vector. This implementation automatically installs a DMA aware Hwi (interrupt) to service the assigned micro DMA channels.

Scratch Buffers

A uint32_t scratch buffer is used to allow SPI_transfers where txBuf or rxBuf are NULL. Rather than requiring txBuf or rxBuf to have a dummy buffer of size of the transfer count, a single DMA accessible uint32_t scratch buffer is used. When rxBuf is NULL, the uDMA will transfer all the SPI data receives into the scratch buffer as a "bit-bucket". When rxBuf is NULL, the scratch buffer is initialized to defaultTxBufValue so the uDMA will send some known value. Each SPI driver instance should uses its own scratch buffer.

SPI data frames

SPI data frames can be any size from 4-bits to 16-bits. If the dataSize in SPI_Params is greater that 8-bits, then the SPITivaDMA driver implementation will assume that the SPI_Transaction txBuf and rxBuf point to an array of 16-bit uint16_t elements.

dataSize buffer element size
4-8 bits uint8_t
9-16 bits uint16_t

DMA transfer size limit

The Tiva micro DMA contoller only supports data transfers of upto 1024 data frames. A data frame can be 4 to 16 bits in length.

DMA accessible memory

As this driver uses uDMA to transfer data/from data buffers, it is the responsibility of the application to ensure that theses buffers reside in memory that is accessible by the DMA.

For example, on Concerto devices local SRAM C0 and C1 are NOT accessible the DMA.


#include <stdint.h>
#include <ti/drivers/SPI.h>
#include <ti/sysbios/knl/Semaphore.h>
#include <ti/sysbios/family/arm/m3/Hwi.h>
Include dependency graph for SPITivaDMA.h:

Go to the source code of this file.

Data Structures

struct  SPITivaDMA_HWAttrs
 SPITivaDMA Hardware attributes. More...
 
struct  SPITivaDMA_Object
 SPITivaDMA Object. More...
 

Macros

#define ti_sysbios_family_arm_m3_Hwi__nolocalnames
 

Typedefs

typedef unsigned long SPIBaseAddrType
 
typedef unsigned long SPIDataType
 
typedef enum SPITivaDMA_FrameSize SPITivaDMA_FrameSize
 SPITivaDMA data frame size is used to determine how to configure the DMA data transfers. This field is to be only used internally. More...
 
typedef struct SPITivaDMA_HWAttrs SPITivaDMA_HWAttrs
 SPITivaDMA Hardware attributes. More...
 
typedef struct SPITivaDMA_Object SPITivaDMA_Object
 SPITivaDMA Object. More...
 
typedef struct SPITivaDMA_ObjectSPITivaDMA_Handle
 

Enumerations

enum  SPITivaDMA_FrameSize {
  SPITivaDMA_8bit = 0,
  SPITivaDMA_16bit = 1
}
 SPITivaDMA data frame size is used to determine how to configure the DMA data transfers. This field is to be only used internally. More...
 

Variables

const SPI_FxnTable SPITivaDMA_fxnTable
 

Macro Definition Documentation

#define ti_sysbios_family_arm_m3_Hwi__nolocalnames

Typedef Documentation

typedef unsigned long SPIBaseAddrType
typedef unsigned long SPIDataType

SPITivaDMA data frame size is used to determine how to configure the DMA data transfers. This field is to be only used internally.

SPITivaDMA_8bit: txBuf and rxBuf are arrays of uint8_t elements SPITivaDMA_16bit: txBuf and rxBuf are arrays of uint16_t elements

SPITivaDMA Hardware attributes.

These fields, with the exception of intPriority, are used by driverlib APIs and therefore must be populated by driverlib macro definitions. For TivaWare these definitions are found in:

  • inc/hw_memmap.h
  • inc/hw_ints.h
  • driverlib/udma.h

intPriority is the SPI peripheral's interrupt priority, as defined by the underlying OS. It is passed unmodified to the underlying OS's interrupt handler creation code, so you need to refer to the OS documentation for usage. For example, for SYS/BIOS applications, refer to the ti.sysbios.family.arm.m3.Hwi documentation for SYS/BIOS usage of interrupt priorities. If the driver uses the ti.drivers.ports interface instead of making OS calls directly, then the HwiP port handles the interrupt priority in an OS specific way. In the case of the SYS/BIOS port, intPriority is passed unmodified to Hwi_create().

A sample structure is shown below:

1 uint32_t spiTivaDMAscratchBuf;
2 const SPITivaDMA_HWAttrs spiTivaDMAobjects[] = {
3  {
4  .baseAddr = SSI0_BASE,
5  .intNum = INT_SSI0,
6  .intPriority = (~0),
7  .scratchBufPtr = &spiTivaDMAscratchBuf,
8  .defaultTxBufValue = 0,
9  .rxChannelIndex = UDMA_CHANNEL_SSI0RX,
10  .txChannelIndex = UDMA_CHANNEL_SSI0TX,
11  .channelMappingFxn = uDMAChannelAssign,
12  .rxChannelMappingFxnArg = UDMA_CH10_SSI0RX,
13  .txChannelMappingFxnArg = UDMA_CH11_SSI0TX
14  },
15 };

SPITivaDMA Object.

The application must not access any member variables of this structure!

Enumeration Type Documentation

SPITivaDMA data frame size is used to determine how to configure the DMA data transfers. This field is to be only used internally.

SPITivaDMA_8bit: txBuf and rxBuf are arrays of uint8_t elements SPITivaDMA_16bit: txBuf and rxBuf are arrays of uint16_t elements

Enumerator
SPITivaDMA_8bit 
SPITivaDMA_16bit 

Variable Documentation

const SPI_FxnTable SPITivaDMA_fxnTable
Copyright 2016, Texas Instruments Incorporated