
UM10800
All information provided in this document is subject to legal disclaimers.
© NXP Semiconductors N.V. 2016. All rights reserved.
User manual
Rev. 1.2 — 5 October 2016
409 of 487
NXP Semiconductors
UM10800
Chapter 28: LPC82x SPI API ROM driver routines
Configure the DMA transfer using the DMA API. The handle to the DMA instance returned
by the DMA API is used by the SPI DMA for the SPI transfer.
typedef struct {
uint32_t dma_txd_num; // SPI TX DMA channel number.
uint32_t dma_rxd_num; // SPI RX DMA channel number. In order to do a SPI RX
// DMA, a SPI TX DMA is also needed to generated SPI
// clock.
DMA_HANDLE_T hDMA; // DMA handle
} SPI_DMA_CFG_T;
28.4.8.5 CALLBK_T
The callback is either invoked in the SPI interrupt handler or the DMA interrupt handler
depending on the driver mode.
typedef void (*CALLBK_T) (ErrorCode_t error_code, uint32_t num_transfer );
error_code
: SPI error code
num_transfer
: In interrupt mode, this parameter indicates the number of SPI frames. In
DMA mode, this parameter is always zero.
In interrupt mode, error code and number of transfers will be passed to the callback.
In DMA mode, the callback indicates the completion of the DMA transfer.
In master mode, the
frame_size
parameter must be set so that the EOT (End of the
transfer) bit in the SPICTL register is set to assert the SPI slave select line.
28.4.8.6 SPI_DMA_REQ_T
When the driver mode is DMA, the following DMA set-up callback is invoked:
typedef ErrorCode_t (*SPI_DMA_REQ_T) (SPI_HANDLE_T handle, SPI_DMA_CFG_T *dma_cfg);
To set up the DMA channel, the source address, destination address, DMA transfer
length, DMA request information must be retrieved from the driver structure which has
been originally passed from the SPI_PARAM_T structure.
28.5 Functional description
28.5.1 Example (no DMA)
Send and receive characters in interrupt mode. Use the SPI API as follows:
1. Assign the SCK, MOSI, MISO, and SSEL0 functions to pins in the switch matrix and
set up the system clock.
2. Global defines:
#define rom_drivers_ptr (* (ROM **) 0x03000200)
SPID_API_T * pSpiApi ; //define pointer to type API function addr table
SPI_HANDLE_T* spi_handle; //handle to SPI API
SPI_PARAM_T param;