| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Typedefs | Functions
CHIP: LPC8xx SPI driver
LPC8xx chip specific drivers

## Detailed Description

This driver provides SPI support for the device. The driver requires the following IP drivers:
IP: SPI register block and driver (002)

## Data Structures
struct | CHIP_SPI_DATA_SETUP_T
| SPI data setup structure. More...

## Typedefs
typedef IP_SPI_CONFIG_T | SPI_CONFIG_T
typedef IP_SPI_DELAY_CONFIG_T | SPI_DELAY_CONFIG_T

## Functions
void | Chip_SPI_Init (LPC_SPI_T *pSPI, SPI_CONFIG_T *pConfig)
| Initialize the SPI.
uint32_t | Chip_SPI_CalClkRateDivider (LPC_SPI_T *pSPI, uint32_t bitRate)
| Calculate the divider for SPI clock.
STATIC INLINE void | Chip_SPI_DelayConfig (LPC_SPI_T *pSPI, SPI_DELAY_CONFIG_T *pConfig)
| Config SPI Delay parameters.
void | Chip_SPI_DeInit (LPC_SPI_T *pSPI)
| Disable SPI operation.
void | Chip_SPI_Int_Cmd (LPC_SPI_T *pSPI, uint32_t IntMask, FunctionalState NewState)
| Enable/Disable SPI interrupt.
STATIC INLINE void | Chip_SPI_Enable (IP_SPI_002_T *pSPI)
| Enable SPI peripheral.
STATIC INLINE void | Chip_SPI_Disable (IP_SPI_002_T *pSPI)
| Disable SPI peripheral.
STATIC INLINE void | Chip_SPI_EnableLoopBack (LPC_SPI_T *pSPI)
| Enable loopback mode.
STATIC INLINE void | Chip_SPI_DisableLoopBack (LPC_SPI_T *pSPI)
| Disable loopback mode.
STATIC INLINE uint32_t | Chip_SPI_GetStatus (LPC_SPI_T *pSPI)
| Get the current status of SPI controller.
STATIC INLINE void | Chip_SPI_SendFirstFrame_RxIgnore (LPC_SPI_T *pSPI, uint16_t Data, uint8_t DataSize)
| Send the first Frame of a transfer (Rx Ignore)
STATIC INLINE void | Chip_SPI_SendFirstFrame (LPC_SPI_T *pSPI, uint16_t Data, uint8_t DataSize)
| Send the first Frame of a transfer.
STATIC INLINE void | Chip_SPI_SendMidFrame (LPC_SPI_T *pSPI, uint16_t Data)
| Send the middle Frame of a transfer.
STATIC INLINE void | Chip_SPI_SendLastFrame_RxIgnore (LPC_SPI_T *pSPI, uint16_t Data, uint8_t DataSize)
| Send the last Frame of a transfer (Rx Ignore)
STATIC INLINE void | Chip_SPI_SendLastFrame (LPC_SPI_T *pSPI, uint16_t Data, uint8_t DataSize)
| Send the last Frame of a transfer.
STATIC INLINE uint16_t | Chip_SPI_ReceiveFrame (LPC_SPI_T *pSPI)
| Read data received.
Status | Chip_SPI_Int_RWFrames (LPC_SPI_T *pSPI, CHIP_SPI_DATA_SETUP_T *xf_setup)
| SPI Interrupt Read/Write.
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, CHIP_SPI_DATA_SETUP_T *pXfSetup)
| SPI Polling Write in blocking mode.
uint32_t | Chip_SPI_ReadFrames_Blocking (LPC_SPI_T *pSPI, CHIP_SPI_DATA_SETUP_T *pXfSetup)
| SPI Polling Read in blocking mode.

## Typedef Documentation

typedef IP_SPI_CONFIG_T SPI_CONFIG_T

Definition at line 47 of file spi_8xx.h.

typedef IP_SPI_DELAY_CONFIG_T SPI_DELAY_CONFIG_T

Definition at line 48 of file spi_8xx.h.

## Function Documentation

uint32_t Chip_SPI_CalClkRateDivider | ( | LPC_SPI_T * | pSPI,
|  | uint32_t | bitRate
| ) |  |

Calculate the divider for SPI clock.

Parameters

  pSPI | : The base of SPI peripheral on the chip
  bitRate | : Expected clock rate

Returns
  Divider value

Definition at line 95 of file spi_8xx.c.

void Chip_SPI_DeInit | ( | LPC_SPI_T * | pSPI | ) |

Disable SPI operation.

Parameters

  pSPI | : The base of SPI peripheral on the chip

Returns
  Nothing

Note
  The SPI controller is disabled

Disable SPI operation.

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 void Chip_SPI_DelayConfig | ( | LPC_SPI_T * | pSPI,
|  | SPI_DELAY_CONFIG_T * | pConfig
| ) |  |

Config SPI Delay parameters.

Parameters

  pSPI | : The base of SPI peripheral on the chip
  pConfig | : SPI Delay Configure Struct

Returns
  Nothing

Note
  The SPI controller is disabled

Definition at line 85 of file spi_8xx.h.

STATIC INLINE void Chip_SPI_Disable | ( | IP_SPI_002_T * | pSPI | ) |

Disable SPI peripheral.

Parameters

  pSPI | : The base of SPI peripheral on the chip

Returns
  Nothing

Definition at line 122 of file spi_8xx.h.

STATIC INLINE void Chip_SPI_DisableLoopBack | ( | LPC_SPI_T * | pSPI | ) |

Disable loopback mode.

Parameters

  pSPI | : The base of SPI peripheral on the chip

Returns
  Nothing

Note
  Serial input is taken from the serial output (MOSI or MISO) rather than the serial input pin

Definition at line 146 of file spi_8xx.h.

STATIC INLINE void Chip_SPI_Enable | ( | IP_SPI_002_T * | pSPI | ) |

Enable SPI peripheral.

Parameters

  pSPI | : The base of SPI peripheral on the chip

Returns
  Nothing

Definition at line 112 of file spi_8xx.h.

STATIC INLINE void Chip_SPI_EnableLoopBack | ( | LPC_SPI_T * | pSPI | ) |

Enable loopback mode.

Parameters

  pSPI | : The base of SPI peripheral on the chip

Returns
  Nothing

Note
  Serial input is taken from the serial output (MOSI or MISO) rather than the serial input pin

Definition at line 134 of file spi_8xx.h.

STATIC INLINE uint32_t Chip_SPI_GetStatus | ( | LPC_SPI_T * | pSPI | ) |

Get the current status of SPI controller.

Parameters

  pSPI | : The base of SPI peripheral on the chip

Returns
  SPI Status (Or-ed bit value of SPI_STAT_*)

Definition at line 156 of file spi_8xx.h.

void Chip_SPI_Init | ( | LPC_SPI_T * | pSPI,
|  | SPI_CONFIG_T * | pConfig
| ) |  |

Initialize the SPI.

Parameters

  pSPI | : The base SPI peripheral on the chip
  pConfig | : SPI Configuration

Returns
  Nothing

Definition at line 109 of file spi_8xx.c.

void Chip_SPI_Int_Cmd | ( | LPC_SPI_T * | pSPI,
|  | uint32_t | IntMask,
|  | FunctionalState | NewState
| ) |  |

Enable/Disable SPI interrupt.

Parameters

  pSPI | : The base SPI peripheral on the chip
  IntMask | : Interrupt mask
  NewState | : ENABLE or DISABLE interrupt

Returns
  Nothing

Definition at line 142 of file spi_8xx.c.

Status Chip_SPI_Int_RWFrames | ( | LPC_SPI_T * | pSPI,
|  | CHIP_SPI_DATA_SETUP_T * | xf_setup
| ) |  |

SPI Interrupt Read/Write.

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

Definition at line 232 of file spi_8xx.c.

uint32_t Chip_SPI_ReadFrames_Blocking | ( | LPC_SPI_T * | pSPI,
|  | CHIP_SPI_DATA_SETUP_T * | pXfSetup
| ) |  |

SPI Polling Read 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 read

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

Definition at line 206 of file spi_8xx.c.

STATIC INLINE uint16_t Chip_SPI_ReceiveFrame | ( | LPC_SPI_T * | pSPI | ) |

Read data received.

Parameters

  pSPI | : The base of SPI peripheral on the chip

Returns
  Receive data

Definition at line 231 of file spi_8xx.h.

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.

STATIC INLINE void Chip_SPI_SendFirstFrame | ( | LPC_SPI_T * | pSPI,
|  | uint16_t | Data,
|  | uint8_t | DataSize
| ) |  |

Send the first Frame of a transfer.

Parameters

  pSPI | : The base of SPI peripheral on the chip
  Data | : Transmit data
  DataSize | : Data Size (1-16)

Returns
  Nothing

Definition at line 183 of file spi_8xx.h.

STATIC INLINE void Chip_SPI_SendFirstFrame_RxIgnore | ( | LPC_SPI_T * | pSPI,
|  | uint16_t | Data,
|  | uint8_t | DataSize
| ) |  |

Send the first Frame of a transfer (Rx Ignore)

Parameters

  pSPI | : The base of SPI peripheral on the chip
  Data | : Transmit data
  DataSize | : Data Size (1-16)

Returns
  Nothing

Definition at line 168 of file spi_8xx.h.

STATIC INLINE void Chip_SPI_SendLastFrame | ( | LPC_SPI_T * | pSPI,
|  | uint16_t | Data,
|  | uint8_t | DataSize
| ) |  |

Send the last Frame of a transfer.

Parameters

  pSPI | : The base of SPI peripheral on the chip
  Data | : Transmit data
  DataSize | : Data Size (1-16)

Returns
  Nothing

Definition at line 221 of file spi_8xx.h.

STATIC INLINE void Chip_SPI_SendLastFrame_RxIgnore | ( | LPC_SPI_T * | pSPI,
|  | uint16_t | Data,
|  | uint8_t | DataSize
| ) |  |

Send the last Frame of a transfer (Rx Ignore)

Parameters

  pSPI | : The base of SPI peripheral on the chip
  Data | : Transmit data
  DataSize | : Data Size (1-16)

Returns
  Nothing

Definition at line 206 of file spi_8xx.h.

STATIC INLINE void Chip_SPI_SendMidFrame | ( | LPC_SPI_T * | pSPI,
|  | uint16_t | Data
| ) |  |

Send the middle Frame of a transfer.

Parameters

  pSPI | : The base of SPI peripheral on the chip
  Data | : Transmit data

Returns
  Nothing

Definition at line 194 of file spi_8xx.h.

uint32_t Chip_SPI_WriteFrames_Blocking | ( | LPC_SPI_T * | pSPI,
|  | CHIP_SPI_DATA_SETUP_T * | pXfSetup
| ) |  |

SPI Polling 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. First, a writing operation will send the needed data. After that, a dummy reading operation is generated to clear data buffer

Definition at line 181 of file spi_8xx.c.