
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
405 of 487
NXP Semiconductors
UM10800
Chapter 28: LPC82x SPI API ROM driver routines
28.4 API description
The SPI API contains functions to send and receive data via any of the SPI interfaces in
master and slave modes.
The following structure has to be defined to use the SPI API:
typedef struct { // index of all the SPI driver functions
uint32_t (*spi_get_mem_size)(void);
SPI_HANDLE_T (*spi_setup)(uint32_t base_addr, uint8_t *ram);
void (*spi_init)(SPI_HANDLE_T handle, SPI_CONFIG_T *set);
uint32_t (*spi_master_transfer)(SPI_HANDLE_T handle, SPI_PARAM_T * param);
uint32_t (*spi_slave_transfer)(SPI_HANDLE_T handle, SPI_PARAM_T * param);
//--interrupt functions--//
void (*spi_isr)(SPI_HANDLE_T handle);
} SPID_API_T ;
28.4.1 SPI get memory size
28.4.2 SPI setup
Table 356. SPI API calls
API call
Description
Reference
uint32_t spi_get_mem_size(void);
Memory size for one SPI instance
SPI_HANDLE_T* spi_setup(uint32_t base_addr, uint8_t *ram);
Set up SPI instance and return
handle
uint32_t spi_init(SPI_HANDLE_T* handle, SPI_CONFIG set);
Set up SPI operating mode
uint32_t spi_master_transfer(SPI_HANDLE_T* handle, SPI_PARAM_T param);
Send or receive data in master
mode
uint8_t spi_slave_transfer(SPI_HANDLE_T* handle, SPI_PARAM_T param);
Send or receive data in slave mode
void spi_isr(SPI_HANDLE_T* handle);
Interrupt service routine
Table 357. spi_get_mem_size
Routine
spi_get_mem_size
Prototype
uint32_t spi_get_mem_size(void);
Input parameter
None.
Return
Memory size in bytes.
Description
Get the memory size needed by one SPI instance.
Table 358. spi_setup
Routine
spi_setup
Prototype
SPI_HANDLE_T* spi_setup(uint32_t base_addr, uint8_t *ram);
Input parameter
base_addr: Register base address for this SPI block.
ram: Pointer to the memory space for SPI instance; the memory size is
obtained from the spi_get_mem_size() function.
Return
The handle to corresponding SPI instance.
Description
Set up SPI instance with provided memory and return the handle to this
instance.