| 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
Macros | Functions | Variables
LPC17xx/40xx SSP example
Peripheral examples

## Detailed Description

Example description
This example describes how to use SSP in POLLING, INTERRUPT or DMA mode. It is needed to connect 2 hardware boards, one for Master and one for Slave.

     SSP configuration:<br>
         - CPHA = 0: data is sampled on the first clock edge of SCK.<br>
         - CPOL = 0: SCK is active high.<br>
         - Sample rate = 400kHz.<br>
         - DSS = 8: 8 bits per transfer.<br>
         - FRF= 0: SPI Frame format.<br>
     After initialize transmit buffer, SPI master/slave will transfer a number of bytes
     to SPI slave/master and receive data concurrently.<br>
     After a transfer completed, receive and transmit buffer will be compared and
     the result will be print out via UART port.<br>
     This example supports 3 transfer modes: POLLING mode, INTERRUPT mode and DMA mode.<br>

- Connect UART port on the master board and slave board to COM ports on your PC.
- Configure terminal program on the PC per the above Serial display configuration
- Configure hardware, connect master board and slave board as below
- Build and run the example. Following guidance on terminals of master and slave to do test.

Special connection requirements
How to run: hardware configuration

- Embedded Artists' LPC1788 Developer's Kit
  - SSP0 connection:
  - P0.15: SSP0_SCK J5.19
  - P0.16: SSP0_SSEL J3.24
  - P0.17: SSP0_MISO J5.20
  - P0.18: SSP0_MOSI J3.23
  - SSP1 connection:
  - P0.7: SSP1_SCK J5.17
  - P0.6 : SSP1_SSEL J3.18
  - P0.8: SSP1_MISO J3.19
  - P0.9: SSP1_MOSI J5.18
- Embedded Artists' LPC4088 Developer's Kit
  - SSP1 connection:
  - P0.7: SSP1_SCK J5.17
  - P0.6: SSP1_SSEL J3.18
  - P0.8: SSP1_MISO J3.19
  - P0.9: SSP1_MOSI J5.18
  - SSP2 connection:
  - P5.2: SSP2_SCK J5.19
  - P5.3: SSP2_SSEL J3.24
  - P5.1: SSP2_MISO J5.20
  - P5.0: SSP2_MOSI J3.23
    Remove jumpers on JP24~JP27 when SSP1 is used.
- LPCXpresso LPC1769:
  - SSP0 connection:
  - P2.1: SSP1_SCK
  - P2.2: SSP1_SSEL
  - P2.0: SSP1_MISO
  - P0.7: SSP1_MOSI
  - SSP1 connection:
  - P2.11: SSP1_SCK
  - P0.2: SSP1_SSEL
  - P0.8: SSP1_MISO
  - P0.9: SSP1_MOSI
    Need to connect with base board for using RS232/UART port.

Common ground must be connected together between two boards.

Build procedures:
LPC17xx/40xx example quickstart for Keil uVision4
LPC17xx/40xx example quickstart for IAR EWARM
LPC17xx/40xx example quickstart for Code Red Xpresso

Supported boards and board setup:
Embedded Artists' LPC1788 Developer's Kit
Embedded Artists' LPC4088 Developer's Kit
NXP Xpresso LPC1769 board

Submitting LPCOpen issues:
Community support for LPCOpen

## Macros
#define | LPC_SSP LPC_SSP1
#define | SSP_IRQ SSP1_IRQn
#define | LPC_GPDMA_SSP_TX GPDMA_CONN_SSP1_Tx
#define | LPC_GPDMA_SSP_RX GPDMA_CONN_SSP1_Rx
#define | SSPIRQHANDLER SSP1_IRQHandler
#define | BUFFER_SIZE (0x100)
#define | SSP_DATA_BITS (SSP_BITS_8)
#define | SSP_DATA_BIT_NUM(databits) (databits + 1)
#define | SSP_DATA_BYTES(databits) (((databits) > SSP_BITS_8) ? 2 : 1)
#define | SSP_LO_BYTE_MSK(databits)
#define | SSP_HI_BYTE_MSK(databits)
#define | SSP_MODE_SEL (0x31)
#define | SSP_TRANSFER_MODE_SEL (0x32)
#define | SSP_MASTER_MODE_SEL (0x31)
#define | SSP_SLAVE_MODE_SEL (0x32)
#define | SSP_POLLING_SEL (0x31)
#define | SSP_INTERRUPT_SEL (0x32)
#define | SSP_DMA_SEL (0x33)

## Functions
static void | Buffer_Init (void)
static uint8_t | Buffer_Verify (void)
static void | appSSPTest (void)
static void | appSSPSelectModeMenu (void)
static void | appSSPMainMenu (void)
void | SSPIRQHANDLER (void)
| SSP interrupt handler sub-routine.
void | DMA_IRQHandler (void)
| DMA interrupt handler sub-routine. Set the waiting flag when transfer is successful.
int | main (void)
| Main routine for SSP example.

## Variables
static uint8_t | Tx_Buf [BUFFER_SIZE]
static uint8_t | Rx_Buf [BUFFER_SIZE]
static SSP_ConfigFormat | ssp_format
static Chip_SSP_DATA_SETUP_T | xf_setup
static volatile uint8_t | isXferCompleted = 0
static uint8_t | dmaChSSPTx
static uint8_t | dmaChSSPRx
static volatile uint8_t | isDmaTxfCompleted = 0
static volatile uint8_t | isDmaRxfCompleted = 0

## Macro Definition Documentation

#define BUFFER_SIZE (0x100)

Definition at line 123 of file ssp.c.

#define LPC_GPDMA_SSP_RX GPDMA_CONN_SSP1_Rx

Definition at line 120 of file ssp.c.

#define LPC_GPDMA_SSP_TX GPDMA_CONN_SSP1_Tx

Definition at line 119 of file ssp.c.

#define LPC_SSP LPC_SSP1

Definition at line 117 of file ssp.c.

#define SSP_DATA_BIT_NUM | ( |  | databits | ) | (databits + 1)

Definition at line 125 of file ssp.c.

#define SSP_DATA_BITS (SSP_BITS_8)

Definition at line 124 of file ssp.c.

#define SSP_DATA_BYTES | ( |  | databits | ) | (((databits) > SSP_BITS_8) ? 2 : 1)

Definition at line 126 of file ssp.c.

#define SSP_DMA_SEL (0x33)

Definition at line 138 of file ssp.c.

#define SSP_HI_BYTE_MSK | ( |  | databits | ) |

Value:
((SSP_DATA_BYTES(databits) > 1) ? (0xFF >> \
(16 - SSP_DATA_BIT_NUM(databits))) : 0)

Definition at line 129 of file ssp.c.

#define SSP_INTERRUPT_SEL (0x32)

Definition at line 137 of file ssp.c.

#define SSP_IRQ SSP1_IRQn

Definition at line 118 of file ssp.c.

#define SSP_LO_BYTE_MSK | ( |  | databits | ) |

Value:
((SSP_DATA_BYTES(databits) > 1) ? 0xFF : (0xFF >> \
(8 - SSP_DATA_BIT_NUM(databits))))

Definition at line 127 of file ssp.c.

#define SSP_MASTER_MODE_SEL (0x31)

Definition at line 134 of file ssp.c.

#define SSP_MODE_SEL (0x31)

Definition at line 132 of file ssp.c.

#define SSP_POLLING_SEL (0x31)

Definition at line 136 of file ssp.c.

#define SSP_SLAVE_MODE_SEL (0x32)

Definition at line 135 of file ssp.c.

#define SSP_TRANSFER_MODE_SEL (0x32)

Definition at line 133 of file ssp.c.

#define SSPIRQHANDLER SSP1_IRQHandler

Definition at line 121 of file ssp.c.

## Function Documentation

static void appSSPMainMenu | ( | void |  | ) |
| static

Definition at line 365 of file ssp.c.

static void appSSPSelectModeMenu | ( | void |  | ) |
| static

Definition at line 329 of file ssp.c.

static void appSSPTest | ( | void |  | ) |
| static

Definition at line 225 of file ssp.c.

static void Buffer_Init | ( | void |  | ) |
| static

Definition at line 184 of file ssp.c.

static uint8_t Buffer_Verify | ( | void |  | ) |
| static

Definition at line 196 of file ssp.c.

void DMA_IRQHandler | ( | void |  | ) |

DMA interrupt handler sub-routine. Set the waiting flag when transfer is successful.

Returns
  Nothing

Definition at line 425 of file ssp.c.

int main | ( | void |  | ) |

Main routine for SSP example.

Main program body.

Returns
  Nothing

Definition at line 440 of file ssp.c.

void SSPIRQHANDLER | ( | void |  | ) |

SSP interrupt handler sub-routine.

Returns
  Nothing

Definition at line 403 of file ssp.c.

## Variable Documentation

uint8_t dmaChSSPRx
| static

Definition at line 149 of file ssp.c.

uint8_t dmaChSSPTx
| static

Definition at line 149 of file ssp.c.

volatile uint8_t isDmaRxfCompleted = 0
| static

Definition at line 151 of file ssp.c.

volatile uint8_t isDmaTxfCompleted = 0
| static

Definition at line 150 of file ssp.c.

volatile uint8_t isXferCompleted = 0
| static

Definition at line 148 of file ssp.c.

uint8_t Rx_Buf[BUFFER_SIZE]
| static

Definition at line 144 of file ssp.c.

SSP_ConfigFormat ssp_format
| static

Definition at line 146 of file ssp.c.

uint8_t Tx_Buf[BUFFER_SIZE]
| static

Definition at line 141 of file ssp.c.

Chip_SSP_DATA_SETUP_T xf_setup
| static

Definition at line 147 of file ssp.c.