TI-RTOS Drivers  tidrivers_full_2_20_00_08
Data Structures | Typedefs | Variables
SPIUSCIBDMA.h File Reference

Detailed Description

SPI driver implementation for a USCIB peripheral 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 UCSI controller in SPI mode. It uses the APIs for a USCIB controller.

SPI Chip Select

The SPIUSCIBDMA operates the controller in 3-pin mode; therefore it is not safe to use in a multi-master SPI bus environment. It is the application's responsibility to assert and de-assert a GPIO pin for chip select purposes.

Chip select type SPI_MASTER mode SPI_SLAVE mode
Hardware chip select Not available on this peripheral.
Software chip select The application is responsible to ensure that correct SPI slave is selected before performing a SPI_transfer(). Up to the application's implementation.

DMA Interrupts

The MSP430 DMA controller uses a single interrupt vector to handle all DMA related IRQ. Because of the "shared" nature, of the DMA's ISR, this driver implementation provides a simple ISR function SPIUSCIBDMA_hwiIntFxn() which needs to be called from within the DMA's ISR. SPIUSCIBDMA_hwiIntFxn() will only service DMA channel interrupts that are associated with the SPI_Handle. Each SPIUSCIBDMA instance will require a call from within the DMA's ISR.

SPI_Handle spi0uscidma;
SPI_Handle spi1uscidma;
// As this DMA controller uses a single interrupt vector for all DMA
// channels (regardless of the triggering source), its left up to the user
// to call SPI_serviceISR() to service its associated DMA channels.
void myDMAISR(UArg arg)
{
// Services and clears its assigned DMA channel interrupts
SPI_serviceISR(spi0uscidma);
// Services and clears its assigned DMA channel interrupts
SPI_serviceISR(spi1uscidma);
// some other user application code that's not related to the SPI driver,
// but is used to service remaining DMA channels
}
spi0uscidma = SPI_open(someSPI_configIndexValue, &params);
...
spi1uscidma = SPI_open(someSPI_configIndexValue, &params);
....

SPI data frames

The USCI controller only supports 8-bit data frames.

dataSize buffer element size
8 bits uint8_t

DMA transfer size limit

The MSP430 DMA controller supports 2^16 data frames per transfer. Each SPI driver instance requires 2 DMA channels (Tx and Rx) to operate.

DMA accessible memory

Ensure that the txBuf and rxBuf (in SPI_Transaction) point to memory that is accessible by the DMA.


#include <stdint.h>
#include <ti/drivers/SPI.h>
#include <ti/sysbios/knl/Semaphore.h>
Include dependency graph for SPIUSCIBDMA.h:

Go to the source code of this file.

Data Structures

struct  SPIUSCIBDMA_HWAttrs
 SPIUSCIBDMA Hardware attributes. More...
 
struct  SPIUSCIBDMA_Object
 SPIUSCIBDMA Object. More...
 

Typedefs

typedef struct SPIUSCIBDMA_HWAttrs SPIUSCIBDMA_HWAttrs
 SPIUSCIBDMA Hardware attributes. More...
 
typedef struct SPIUSCIBDMA_Object SPIUSCIBDMA_Object
 SPIUSCIBDMA Object. More...
 
typedef struct SPIUSCIBDMA_ObjectSPIUSCIBDMA_Handle
 

Variables

const SPI_FxnTable SPIUSCIBDMA_fxnTable
 

Typedef Documentation

SPIUSCIBDMA Hardware attributes.

These fields are used by driverlib APIs and therefore must be populated by driverlib macro definitions. For MSP430Ware these definitions are found in:

  • inc/hw_memmap.h
  • usci_b_spi.h
  • dma.h

A sample structure is shown below:

1 uint8_t spiUSCIBDMAscratchBuf;
2 const SPIUSCIBDMA_HWAttrs spiUSCIBDMAHWAttrs[] = {
3  {
4  .baseAddr = USCI_B1_BASE,
5  .clockSource = USCI_B_SPI_CLOCKSOURCE_SMCLK,
6  .bitOrder = USCI_B_SPI_MSB_FIRST,
7  .scratchBufPtr = &spiUSCIBDMAscratchBuf,
8  .defaultTxBufValue = 0,
9 
10  // DMA base address
11  .dmaBaseAddr = DMA_BASE,
12  // Rx Channel
13  .rxDMAChannelIndex = DMA_CHANNEL_1,
14  .rxDMASourceTrigger = DMA_TRIGGERSOURCE_22,
15  // Tx Channel
16  .txDMAChannelIndex = DMA_CHANNEL_0,
17  .txDMASourceTrigger = DMA_TRIGGERSOURCE_23
18  },
19 };

SPIUSCIBDMA Object.

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

Variable Documentation

const SPI_FxnTable SPIUSCIBDMA_fxnTable
Copyright 2016, Texas Instruments Incorporated