LPCOpen Platform  v1.03
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
CHIP: LPC17xx/40xx SPI driver

Detailed Description

Data Structures

struct  CHIP_SPI_CONFIG_FORMAT_T
 
struct  CHIP_SPI_DATA_SETUP_T
 SPI data setup structure. More...
 

Macros

#define CHIP_SPI_CLOCK_MODE_T   IP_SPI_CLOCK_MODE_T
 
#define CHIP_SPI_MODE_T   IP_SPI_MODE_T
 
#define CHIP_SPI_DATA_ORDER_T   IP_SPI_DATA_ORDER_T
 
#define CHIP_SPI_BITS_T   IP_SPI_BITS_T
 

Typedefs

typedef void(* CHIP_SPI_CALLBACK_T )(void)
 

Functions

STATIC INLINE uint32_t Chip_SPI_GetStatus (LPC_SPI_T *pSPI)
 Get the current status of SPI controller.
 
void Chip_SPI_Int_FlushData (LPC_SPI_T *pSPI)
 Clean all data in RX FIFO of SPI.
 
Status Chip_SPI_Int_RWFrames8Bits (LPC_SPI_T *pSPI, CHIP_SPI_DATA_SETUP_T *xf_setup)
 SPI Interrupt Read/Write with 8-bit frame width.
 
Status Chip_SPI_Int_RWFrames16Bits (LPC_SPI_T *pSPI, CHIP_SPI_DATA_SETUP_T *xf_setup)
 SPI Interrupt Read/Write with 16-bit frame width.
 
uint32_t Chip_SPI_RWFrames_Blocking (LPC_SPI_T *pSPI, CHIP_SPI_DATA_SETUP_T *pXfSetup)
 SPI Polling Read/Write in blocking mode.
 
uint32_t Chip_SPI_WriteFrames_Blocking (LPC_SPI_T *pSPI, uint8_t *buffer, uint32_t buffer_len)
 SPI Polling Write in blocking mode.
 
uint32_t Chip_SPI_ReadFrames_Blocking (LPC_SPI_T *pSPI, uint8_t *buffer, uint32_t buffer_len)
 SPI Polling Read in blocking mode.
 
void Chip_SPI_Init (LPC_SPI_T *pSPI)
 Initialize the SPI.
 
void Chip_SPI_DeInit (LPC_SPI_T *pSPI)
 Deinitialise the SPI.
 
STATIC INLINE void Chip_SPI_SetMode (LPC_SPI_T *pSPI, CHIP_SPI_MODE_T mode)
 Set the SPI operating modes, master or slave.
 
void Chip_SPI_SetBitRate (LPC_SPI_T *pSPI, uint32_t bitRate)
 Set the clock frequency for SPI interface.
 
STATIC INLINE void Chip_SPI_SetFormat (LPC_SPI_T *pSPI, CHIP_SPI_CONFIG_FORMAT_T *format)
 Set up the SPI frame format.
 
STATIC INLINE void Chip_SPI_Int_Enable (LPC_SPI_T *pSPI)
 Enable SPI interrupt.
 
STATIC INLINE void Chip_SPI_Int_Disable (LPC_SPI_T *pSPI)
 Disable SPI interrupt.
 

Macro Definition Documentation

#define CHIP_SPI_BITS_T   IP_SPI_BITS_T

Definition at line 47 of file spi_17xx_40xx.h.

#define CHIP_SPI_CLOCK_MODE_T   IP_SPI_CLOCK_MODE_T

Definition at line 44 of file spi_17xx_40xx.h.

#define CHIP_SPI_DATA_ORDER_T   IP_SPI_DATA_ORDER_T

Definition at line 46 of file spi_17xx_40xx.h.

#define CHIP_SPI_MODE_T   IP_SPI_MODE_T

Definition at line 45 of file spi_17xx_40xx.h.

Typedef Documentation

typedef void(* CHIP_SPI_CALLBACK_T)(void)

SPI callback function type

Definition at line 50 of file spi_17xx_40xx.h.

Function Documentation

void Chip_SPI_DeInit ( LPC_SPI_T pSPI)

Deinitialise the SPI.

Parameters
pSPI: The base of SPI peripheral on the chip
Returns
Nothing
Note
The SPI controller is disabled

Definition at line 128 of file spi_8xx.c.

STATIC INLINE uint32_t Chip_SPI_GetStatus ( LPC_SPI_T pSPI)

Get the current status of SPI controller.

Returns
SPI controller status (Or-ed value of SPI_SR_*)

Definition at line 78 of file spi_17xx_40xx.h.

void Chip_SPI_Init ( LPC_SPI_T pSPI)

Initialize the SPI.

Parameters
pSPI: The base SPI peripheral on the chip
Returns
Nothing
STATIC INLINE void Chip_SPI_Int_Disable ( LPC_SPI_T pSPI)

Disable SPI interrupt.

Parameters
pSPI: The base SPI peripheral on the chip
Returns
Nothing

Definition at line 205 of file spi_17xx_40xx.h.

STATIC INLINE void Chip_SPI_Int_Enable ( LPC_SPI_T pSPI)

Enable SPI interrupt.

Parameters
pSPI: The base SPI peripheral on the chip
Returns
Nothing

Definition at line 195 of file spi_17xx_40xx.h.

void Chip_SPI_Int_FlushData ( LPC_SPI_T pSPI)

Clean all data in RX FIFO of SPI.

Parameters
pSPI: The base SPI peripheral on the chip
Returns
Nothing
Status Chip_SPI_Int_RWFrames16Bits ( LPC_SPI_T pSPI,
CHIP_SPI_DATA_SETUP_T xf_setup 
)

SPI Interrupt Read/Write with 16-bit frame width.

Parameters
pSPI: The base SPI peripheral on the chip
xf_setup: Pointer to a SPI_DATA_SETUP_T structure that contains specified information about transmit/receive data configuration
Returns
SUCCESS or ERROR
Status Chip_SPI_Int_RWFrames8Bits ( LPC_SPI_T pSPI,
CHIP_SPI_DATA_SETUP_T xf_setup 
)

SPI Interrupt Read/Write with 8-bit frame width.

Parameters
pSPI: The base SPI peripheral on the chip
xf_setup: Pointer to a SPI_DATA_SETUP_T structure that contains specified information about transmit/receive data configuration
Returns
SUCCESS or ERROR
uint32_t Chip_SPI_ReadFrames_Blocking ( LPC_SPI_T pSPI,
uint8_t *  buffer,
uint32_t  buffer_len 
)

SPI Polling Read in blocking mode.

Parameters
pSPI: The base SPI peripheral on the chip
buffer: Buffer address
buffer_len: The length of buffer
Returns
Actual data length has been transferred
Note
This function can be used in both master and slave mode. First, a dummy writing operation is generated to clear data buffer. After that, a reading operation will receive the needed data
uint32_t Chip_SPI_RWFrames_Blocking ( LPC_SPI_T pSPI,
CHIP_SPI_DATA_SETUP_T pXfSetup 
)

SPI Polling Read/Write in blocking mode.

Parameters
pSPI: The base SPI peripheral on the chip
pXfSetup: Pointer to a SPI_DATA_SETUP_T structure that contains specified information about transmit/receive data configuration
Returns
Actual data length has been transferred
Note
This function can be used in both master and slave mode. It starts with writing phase and after that, a reading phase is generated to read any data available in RX_FIFO. All needed information is prepared through xf_setup param.

Definition at line 153 of file spi_8xx.c.

void Chip_SPI_SetBitRate ( LPC_SPI_T pSPI,
uint32_t  bitRate 
)

Set the clock frequency for SPI interface.

Parameters
pSPI: The base SPI peripheral on the chip
bitRate: The SPI bit rate
Returns
Nothing
STATIC INLINE void Chip_SPI_SetFormat ( LPC_SPI_T pSPI,
CHIP_SPI_CONFIG_FORMAT_T format 
)

Set up the SPI frame format.

Parameters
pSPI: The base SPI peripheral on the chip
format: Pointer to Frame format structure
Returns
Nothing

Definition at line 185 of file spi_17xx_40xx.h.

STATIC INLINE void Chip_SPI_SetMode ( LPC_SPI_T pSPI,
CHIP_SPI_MODE_T  mode 
)

Set the SPI operating modes, master or slave.

Parameters
pSPI: The base SPI peripheral on the chip
mode: master mode/slave mode
Returns
Nothing

Definition at line 166 of file spi_17xx_40xx.h.

uint32_t Chip_SPI_WriteFrames_Blocking ( LPC_SPI_T pSPI,
uint8_t *  buffer,
uint32_t  buffer_len 
)

SPI Polling Write in blocking mode.

Parameters
pSPI: The base SPI peripheral on the chip
buffer: Buffer address
buffer_len: Buffer length
Returns
Actual data length has been transferred
Note
This function can be used in both master and slave mode. First, a writing operation will send the needed data. After that, a dummy reading operation is generated to clear data buffer