All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
SPI DMA Driver
SPI: Serial Peripheral Interface Driver

## Overview

This section describes the programming interface of the SPI DMA driver.

## Data Structures

struct | spi_dma_handle_t
| SPI DMA transfer handle, users should not touch the content of the handle. More...

## Typedefs

typedef void(* | spi_dma_callback_t )(SPI_Type *base, spi_dma_handle_t *handle, status_t status, void *userData)
| SPI DMA callback called at the end of transfer. More...

## DMA Transactional

void | SPI_MasterTransferCreateHandleDMA (SPI_Type *base, spi_dma_handle_t *handle, spi_dma_callback_t callback, void *userData, dma_handle_t *txHandle, dma_handle_t *rxHandle)
| Initialize the SPI master DMA handle. More...
status_t | SPI_MasterTransferDMA (SPI_Type *base, spi_dma_handle_t *handle, spi_transfer_t *xfer)
| Perform a non-blocking SPI transfer using DMA. More...
void | SPI_MasterTransferAbortDMA (SPI_Type *base, spi_dma_handle_t *handle)
| Abort a SPI transfer using DMA. More...
status_t | SPI_MasterTransferGetCountDMA (SPI_Type *base, spi_dma_handle_t *handle, size_t *count)
| Get the transferred bytes for SPI slave DMA. More...
static void | SPI_SlaveTransferCreateHandleDMA (SPI_Type *base, spi_dma_handle_t *handle, spi_dma_callback_t callback, void *userData, dma_handle_t *txHandle, dma_handle_t *rxHandle)
| Initialize the SPI slave DMA handle. More...
static status_t | SPI_SlaveTransferDMA (SPI_Type *base, spi_dma_handle_t *handle, spi_transfer_t *xfer)
| Perform a non-blocking SPI transfer using DMA. More...
static void | SPI_SlaveTransferAbortDMA (SPI_Type *base, spi_dma_handle_t *handle)
| Abort a SPI transfer using DMA. More...
static status_t | SPI_SlaveTransferGetCountDMA (SPI_Type *base, spi_dma_handle_t *handle, size_t *count)
| Get the transferred bytes for SPI slave DMA. More...

## Data Structure Documentation

struct _spi_dma_handle

### Data Fields

bool | txInProgress
| Send transfer finished.
bool | rxInProgress
| Receive transfer finished.
dma_handle_t * | txHandle
| DMA handler for SPI send.
dma_handle_t * | rxHandle
| DMA handler for SPI receive.
uint8_t | bytesPerFrame
| Bytes in a frame for SPI tranfer.
spi_dma_callback_t | callback
| Callback for SPI DMA transfer.
void * | userData
| User Data for SPI DMA callback.
uint32_t | state
| Internal state of SPI DMA transfer.
size_t | transferSize
| Bytes need to be transfer.

## Typedef Documentation

typedef void(* spi_dma_callback_t)(SPI_Type *base, spi_dma_handle_t *handle, status_t status, void *userData)

## Function Documentation

void SPI_MasterTransferCreateHandleDMA | ( | SPI_Type * | base,
|  | spi_dma_handle_t * | handle,
|  | spi_dma_callback_t | callback,
|  | void * | userData,
|  | dma_handle_t * | txHandle,
|  | dma_handle_t * | rxHandle
| ) |  |

This function initializes the SPI master DMA handle which can be used for other SPI master transactional APIs. Usually, for a specified SPI instance, user need only call this API once to get the initialized handle.

Parameters

  base | SPI peripheral base address.
  handle | SPI handle pointer.
  callback | User callback function called at the end of a transfer.
  userData | User data for callback.
  txHandle | DMA handle pointer for SPI Tx, the handle shall be static allocated by users.
  rxHandle | DMA handle pointer for SPI Rx, the handle shall be static allocated by users.

status_t SPI_MasterTransferDMA | ( | SPI_Type * | base,
|  | spi_dma_handle_t * | handle,
|  | spi_transfer_t * | xfer
| ) |  |

Note
  This interface returned immediately after transfer initiates, users should call SPI_GetTransferStatus to poll the transfer status to check whether SPI transfer finished.

Parameters

  base | SPI peripheral base address.
  handle | SPI DMA handle pointer.
  xfer | Pointer to dma transfer structure.

Return values

  kStatus_Success | Successfully start a transfer.
  kStatus_InvalidArgument | Input argument is invalid.
  kStatus_SPI_Busy | SPI is not idle, is running another transfer.

void SPI_MasterTransferAbortDMA | ( | SPI_Type * | base,
|  | spi_dma_handle_t * | handle
| ) |  |

Parameters

  base | SPI peripheral base address.
  handle | SPI DMA handle pointer.

status_t SPI_MasterTransferGetCountDMA | ( | SPI_Type * | base,
|  | spi_dma_handle_t * | handle,
|  | size_t * | count
| ) |  |

Parameters

  base | SPI peripheral base address.
  handle | SPI DMA handle pointer.
  count | Transferred bytes.

Return values

  kStatus_SPI_Success | Succeed get the transfer count.
  kStatus_NoTransferInProgress | There is not a non-blocking transaction currently in progress.

static void SPI_SlaveTransferCreateHandleDMA | ( | SPI_Type * | base,
|  | spi_dma_handle_t * | handle,
|  | spi_dma_callback_t | callback,
|  | void * | userData,
|  | dma_handle_t * | txHandle,
|  | dma_handle_t * | rxHandle
| ) |  |

inlinestatic

This function initializes the SPI slave DMA handle which can be used for other SPI master transactional APIs. Usually, for a specified SPI instance, user need only call this API once to get the initialized handle.

Parameters

  base | SPI peripheral base address.
  handle | SPI handle pointer.
  callback | User callback function called at the end of a transfer.
  userData | User data for callback.
  txHandle | DMA handle pointer for SPI Tx, the handle shall be static allocated by users.
  rxHandle | DMA handle pointer for SPI Rx, the handle shall be static allocated by users.

static status_t SPI_SlaveTransferDMA | ( | SPI_Type * | base,
|  | spi_dma_handle_t * | handle,
|  | spi_transfer_t * | xfer
| ) |  |

inlinestatic

Note
  This interface returned immediately after transfer initiates, users should call SPI_GetTransferStatus to poll the transfer status to check whether SPI transfer finished.

Parameters

  base | SPI peripheral base address.
  handle | SPI DMA handle pointer.
  xfer | Pointer to dma transfer structure.

Return values

  kStatus_Success | Successfully start a transfer.
  kStatus_InvalidArgument | Input argument is invalid.
  kStatus_SPI_Busy | SPI is not idle, is running another transfer.

static void SPI_SlaveTransferAbortDMA | ( | SPI_Type * | base,
|  | spi_dma_handle_t * | handle
| ) |  |

inlinestatic

Parameters

  base | SPI peripheral base address.
  handle | SPI DMA handle pointer.

static status_t SPI_SlaveTransferGetCountDMA | ( | SPI_Type * | base,
|  | spi_dma_handle_t * | handle,
|  | size_t * | count
| ) |  |

inlinestatic

Parameters

  base | SPI peripheral base address.
  handle | SPI DMA handle pointer.
  count | Transferred bytes.

Return values

  kStatus_SPI_Success | Succeed get the transfer count.
  kStatus_NoTransferInProgress | There is not a non-blocking transaction currently in progress.