LPCOpen Platform  v1.03
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
LPC17xx/40xx SPIFI Flash programmer example

Detailed Description

Example description
This example demonstrates programming of the SPI flash using the SPIFI interface. The program can be run in two ways, the first and the default is having USE_SPIFI_LIB defined so that the code makes use of the functions provided by the spifi_*.lib. The second one is having USE_SPIFI_LIB not defined which will make direct calls to the boot ROM function pointers and will not use any library calls.
By default the program writes 256 bytes of data starting from hex 00 to hex FF to SPIFI_WRITE_SECTOR_OFFSET

UART needs to be setup prior to running the example as the example produces the output to the UART console. If LED1 is ON then the programming is successful, if LED2 is ON then the programming has failed.

Special connection requirements
There are no special connection requirements for this example.

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' LPC4088 Developer's Kit

Submitting LPCOpen issues:
Community support for LPCOpen

Functions

static int verify_spifi_data (const uint8_t *buff, int size)
 
static void prepare_write_data (uint8_t *buff, int size)
 
int main (void)
 Main entry point.
 

Variables

static uint8_t data_buffer [PROG_SIZE]
 
static SPIFIobj spifi_obj
 

Macro Definition Documentation

#define spifi_rom_init (   x)

Definition at line 63 of file flash_config.h.

#define SPIFI_WRITE_SECTOR_ADDRESS   (SPIFLASH_BASE_ADDRESS + SPIFI_WRITE_SECTOR_OFFSET)

Definition at line 61 of file flash_config.h.

#define SPIFI_WRITE_SECTOR_OFFSET   0x40000

Offset of the sector to which the data to be written

Definition at line 60 of file flash_config.h.

#define USE_SPIFI_LIB

Macro that enables calling of spifi functions using the library, disabling this will directly call the functions in boot rom using bootROM function pointers.

Definition at line 44 of file flash_config.h.

Function Documentation

int main ( void  )

Main entry point.

Main program body.

Returns
Nothing

Definition at line 111 of file main.c.

static void prepare_write_data ( uint8_t *  buff,
int  size 
)
static

Definition at line 95 of file main.c.

static int verify_spifi_data ( const uint8_t *  buff,
int  size 
)
static

Definition at line 83 of file main.c.

Variable Documentation

uint8_t data_buffer[PROG_SIZE]
static

Definition at line 71 of file main.c.

SPIFIobj spifi_obj
static

Definition at line 72 of file main.c.