LPCOpen Platform
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
IP: SPIFI register block and driver

Modules

 IP: SPIFI configuration options
 
 IP: SPIFI programming options
 

Functions

void cancel_mem_mode (SPIFIobj *obj)
 
int32_t checkAd (SPIFIobj *obj, SPIFIopers *opers)
 
int32_t setProt (SPIFIobj *obj, SPIFIopers *opers, char *change, char *saveProt)
 
int32_t check_block (SPIFIobj *obj, char *source, SPIFIopers *opers, uint32_t check_program)
 
int32_t send_erase_cmd (SPIFIobj *obj, uint8_t op, uint32_t addr)
 
uint32_t ck_erase (SPIFIobj *obj, uint32_t *addr, uint32_t length)
 
int32_t prog_block (SPIFIobj *obj, char *source, SPIFIopers *opers, uint32_t *left_in_page)
 
uint32_t ck_prog (SPIFIobj *obj, char *source, char *dest, uint32_t length)
 
void setSize (SPIFIobj *obj, int32_t value)
 
int32_t setDev (SPIFIobj *obj, uint32_t opts, uint32_t mem_cmd, uint32_t prog_cmd)
 
uint32_t cmd (uc op, uc addrLen, uc intLen, uint16_t len)
 
uint32_t readAd (SPIFIobj *obj, uint32_t cmd, uint32_t addr)
 
void send04 (SPIFIobj *obj, uc op, uc len, uint32_t value)
 
void wren_sendAd (SPIFIobj *obj, uint32_t cmd, uint32_t addr, uint32_t value)
 
int32_t write_stat (SPIFIobj *obj, uc len, uint16_t value)
 
int32_t wait_busy (SPIFIobj *obj, uc prog_or_erase)
 
STATIC INLINE int32_t IP_SPIFI_Init (SPIFIobj *obj, uint32_t csHigh, uint32_t options, uint32_t mhz)
 This call sends the standardized Read JEDEC ID command to the attached serial Flash device. If it responds, it is set up for reading in ARM memory space.
 
STATIC INLINE int32_t IP_SPIFI_Program (SPIFIobj *obj, char *source, SPIFIopers *opers)
 This call programs opers.length bytes in the serial flash. An IP_SPIFI_Program call with source equal to opers.dest and opers.options not including S_FORCE_ERASE can be used to protect or unprotect sectors depending on the value of opers.protect.
 
STATIC INLINE int32_t IP_SPIFI_Erase (SPIFIobj *obj, SPIFIopers *opers)
 This call erases opers.length bytes in the serial flash.
 
STATIC INLINE void IP_SPIFI_CancelMemMode (SPIFIobj *obj)
 : This function disables the memory mapping of the external QSPI flash.
 
STATIC INLINE void IP_SPIFI_SetMemMode (SPIFIobj *obj)
 
STATIC INLINE int32_t IP_SPIFI_checkAd (SPIFIobj *obj, SPIFIopers *opers)
 
STATIC INLINE int32_t IP_SPIFI_setProt (SPIFIobj *obj, SPIFIopers *opers, char *change, char *saveProt)
 
STATIC INLINE int32_t IP_SPIFI_CheckBlock (SPIFIobj *obj, char *source, SPIFIopers *opers, uint32_t check_program)
 
STATIC INLINE int32_t IP_SPIFI_SendEraseCmd (SPIFIobj *obj, uint8_t op, uint32_t addr)
 
STATIC INLINE uint32_t IP_SPIFI_CkErase (SPIFIobj *obj, uint32_t *addr, uint32_t length)
 
STATIC INLINE int32_t IP_SPIFI_ProgBlock (SPIFIobj *obj, char *source, SPIFIopers *opers, uint32_t *left_in_page)
 
STATIC INLINE uint32_t IP_SPIFI_CkProg (SPIFIobj *obj, char *source, char *dest, uint32_t length)
 
STATIC INLINE void IP_SPIFI_SetSize (SPIFIobj *obj, int32_t value)
 
STATIC INLINE int32_t IP_SPIFI_SetDev (SPIFIobj *obj, uint32_t opts, uint32_t mem_cmd, uint32_t prog_cmd)
 
STATIC INLINE uint32_t IP_SPIFI_Cmd (uc op, uc addrLen, uc intLen, uint16_t len)
 
STATIC INLINE uint32_t IP_SPIFI_ReadAd (SPIFIobj *obj, uint32_t cmd, uint32_t addr)
 
STATIC INLINE void IP_SPIFI_Send04 (SPIFIobj *obj, uc op, uc len, uint32_t value)
 
STATIC INLINE void IP_SPIFI_WrEnSendAd (SPIFIobj *obj, uint32_t cmd, uint32_t addr, uint32_t value)
 
STATIC INLINE int32_t IP_SPIFI_WriteStat (SPIFIobj *obj, uc len, uint16_t value)
 
STATIC INLINE int32_t IP_SPIFI_WaitBusy (SPIFIobj *obj, uc prog_or_erase)
 

Variables

void(* set_mem_mode )(SPIFIobj *obj)
 
#define LONGEST_PROT   68
 
#define NULL   ((void *) 0)
 
#define S_MODE3   1
 
#define S_MODE0   0
 
#define S_MINIMAL   2
 
#define S_MAXIMAL   0
 
#define S_RCVCLK   0x80
 
#define S_INTCLK   0
 
#define S_FULLCLK   0x40
 
#define S_HALFCLK   0
 
#define S_DUAL   0x100
 
enum  { RWPROT = 1 }
 
enum  inst_type { stat_inst, block_erase, prog_inst, chip_erase }
 
typedef uint8_t uc
 

Detailed Description

Macro Definition Documentation

#define LONGEST_PROT   68

Definition at line 50 of file spifi_rom_api.h.

#define NULL   ((void *) 0)

Definition at line 55 of file spifi_rom_api.h.

#define S_DUAL   0x100

If the connected device can operate in dual mode (2 bits per clock), dual mode will be used, else SPI mode.

Definition at line 150 of file spifi_rom_api.h.

#define S_FULLCLK   0x40

Data from the serial flash is sampled on falling edges on the SCL output, allowing a full clock period for the serial flash to present each bit or group of bits.

Definition at line 142 of file spifi_rom_api.h.

#define S_HALFCLK   0

Data from the serial flash is sampled on rising edges of the SCL output, as in classic SPI applications. Suitable for slower clock rates. (default)

Definition at line 146 of file spifi_rom_api.h.

#define S_INTCLK   0

Data is sampled using the internal clock from which the SCL pin is driven. (default)

Definition at line 137 of file spifi_rom_api.h.

#define S_MAXIMAL   0

The fastest read operation provided by the device will be used. (default)

Definition at line 128 of file spifi_rom_api.h.

#define S_MINIMAL   2

SPI mode and the slowest, most basic/compatible read operation will be used.

Definition at line 125 of file spifi_rom_api.h.

#define S_MODE0   0

SCL is low when a frame/command is not in progress. (default)

Definition at line 122 of file spifi_rom_api.h.

#define S_MODE3   1

The SCL output is high when a frame/command is not in progress. Note that S_MODE3+S_FULLCLK+S_RCVCLK will not work. Use S_MODE0 or S_INTCLK.

Definition at line 119 of file spifi_rom_api.h.

#define S_RCVCLK   0x80

Data is sampled using the SCL clock fed back from the pin. This allows more time for the serial flash to present each bit or group of bits, but when used with S_FULLCLK can endanger hold time for data from the flash.

Definition at line 134 of file spifi_rom_api.h.

Typedef Documentation

typedef uint8_t uc

Definition at line 52 of file spifi_rom_api.h.

Enumeration Type Documentation

anonymous enum
Enumerator:
RWPROT 

Definition at line 66 of file spifi_rom_api.h.

enum inst_type

instruction classes for wait_busy

Enumerator:
stat_inst 
block_erase 
prog_inst 
chip_erase 

Definition at line 108 of file spifi_rom_api.h.

Function Documentation

void cancel_mem_mode ( SPIFIobj obj)
int32_t check_block ( SPIFIobj obj,
char *  source,
SPIFIopers opers,
uint32_t  check_program 
)
int32_t checkAd ( SPIFIobj obj,
SPIFIopers opers 
)
uint32_t ck_erase ( SPIFIobj obj,
uint32_t addr,
uint32_t  length 
)
uint32_t ck_prog ( SPIFIobj obj,
char *  source,
char *  dest,
uint32_t  length 
)
uint32_t cmd ( uc  op,
uc  addrLen,
uc  intLen,
uint16_t  len 
)
STATIC INLINE void IP_SPIFI_CancelMemMode ( SPIFIobj obj)

: This function disables the memory mapping of the external QSPI flash.

Parameters
obj: Pointer to initialized SPIFIobj structure (from IP_SPIFI_Init)
Returns
No return value

Definition at line 128 of file spifi_001.h.

STATIC INLINE int32_t IP_SPIFI_checkAd ( SPIFIobj obj,
SPIFIopers opers 
)

Definition at line 139 of file spifi_001.h.

STATIC INLINE int32_t IP_SPIFI_CheckBlock ( SPIFIobj obj,
char *  source,
SPIFIopers opers,
uint32_t  check_program 
)

Definition at line 149 of file spifi_001.h.

STATIC INLINE uint32_t IP_SPIFI_CkErase ( SPIFIobj obj,
uint32_t addr,
uint32_t  length 
)

Definition at line 160 of file spifi_001.h.

STATIC INLINE uint32_t IP_SPIFI_CkProg ( SPIFIobj obj,
char *  source,
char *  dest,
uint32_t  length 
)

Definition at line 171 of file spifi_001.h.

STATIC INLINE uint32_t IP_SPIFI_Cmd ( uc  op,
uc  addrLen,
uc  intLen,
uint16_t  len 
)

Definition at line 188 of file spifi_001.h.

STATIC INLINE int32_t IP_SPIFI_Erase ( SPIFIobj obj,
SPIFIopers opers 
)

This call erases opers.length bytes in the serial flash.

Parameters
obj: Pointer to initialized SPIFIobj structure (from IP_SPIFI_Init)
opers: specifies erasing options
Returns
A return value of zero indicates success. Non-zero error codes indicate various error states.

Definition at line 118 of file spifi_001.h.

STATIC INLINE int32_t IP_SPIFI_Init ( SPIFIobj obj,
uint32_t  csHigh,
uint32_t  options,
uint32_t  mhz 
)

This call sends the standardized Read JEDEC ID command to the attached serial Flash device. If it responds, it is set up for reading in ARM memory space.

Parameters
obj: Pointer to uninitialized SPIFIobj structure
csHigh: Value that is one less than the minimum number of clock cycles with the CS pin high, that the SPIFI should maintain between commands. Compute this from the SPIFI clock period and the minimum high time of CS from the serial flash data sheet: csHigh = ceiling( min CS high / SPIFI clock period) - 1
options: contains bits controlling the SPIFI behavior. See IP: SPIFI configuration options
mhz: should be the serial clock divided by 1000000.
Returns
A return value of zero indicates success. Non-zero error codes indicate various error states.

Definition at line 90 of file spifi_001.h.

STATIC INLINE int32_t IP_SPIFI_ProgBlock ( SPIFIobj obj,
char *  source,
SPIFIopers opers,
uint32_t left_in_page 
)

Definition at line 165 of file spifi_001.h.

STATIC INLINE int32_t IP_SPIFI_Program ( SPIFIobj obj,
char *  source,
SPIFIopers opers 
)

This call programs opers.length bytes in the serial flash. An IP_SPIFI_Program call with source equal to opers.dest and opers.options not including S_FORCE_ERASE can be used to protect or unprotect sectors depending on the value of opers.protect.

Parameters
obj: Pointer to initialized SPIFIobj structure (from IP_SPIFI_Init)
source: is the address of the data to be programmed
opers: specifies programming and erasing options
Returns
A return value of zero indicates success. Non-zero error codes indicate various error states.

Definition at line 106 of file spifi_001.h.

STATIC INLINE uint32_t IP_SPIFI_ReadAd ( SPIFIobj obj,
uint32_t  cmd,
uint32_t  addr 
)

Definition at line 193 of file spifi_001.h.

STATIC INLINE void IP_SPIFI_Send04 ( SPIFIobj obj,
uc  op,
uc  len,
uint32_t  value 
)

Definition at line 198 of file spifi_001.h.

STATIC INLINE int32_t IP_SPIFI_SendEraseCmd ( SPIFIobj obj,
uint8_t  op,
uint32_t  addr 
)

Definition at line 155 of file spifi_001.h.

STATIC INLINE int32_t IP_SPIFI_SetDev ( SPIFIobj obj,
uint32_t  opts,
uint32_t  mem_cmd,
uint32_t  prog_cmd 
)

Definition at line 182 of file spifi_001.h.

STATIC INLINE void IP_SPIFI_SetMemMode ( SPIFIobj obj)

Definition at line 133 of file spifi_001.h.

STATIC INLINE int32_t IP_SPIFI_setProt ( SPIFIobj obj,
SPIFIopers opers,
char *  change,
char *  saveProt 
)

Definition at line 144 of file spifi_001.h.

STATIC INLINE void IP_SPIFI_SetSize ( SPIFIobj obj,
int32_t  value 
)

Definition at line 177 of file spifi_001.h.

STATIC INLINE int32_t IP_SPIFI_WaitBusy ( SPIFIobj obj,
uc  prog_or_erase 
)

Definition at line 213 of file spifi_001.h.

STATIC INLINE void IP_SPIFI_WrEnSendAd ( SPIFIobj obj,
uint32_t  cmd,
uint32_t  addr,
uint32_t  value 
)

Definition at line 203 of file spifi_001.h.

STATIC INLINE int32_t IP_SPIFI_WriteStat ( SPIFIobj obj,
uc  len,
uint16_t  value 
)

Definition at line 208 of file spifi_001.h.

int32_t prog_block ( SPIFIobj obj,
char *  source,
SPIFIopers opers,
uint32_t left_in_page 
)
uint32_t readAd ( SPIFIobj obj,
uint32_t  cmd,
uint32_t  addr 
)
void send04 ( SPIFIobj obj,
uc  op,
uc  len,
uint32_t  value 
)
int32_t send_erase_cmd ( SPIFIobj obj,
uint8_t  op,
uint32_t  addr 
)
int32_t setDev ( SPIFIobj obj,
uint32_t  opts,
uint32_t  mem_cmd,
uint32_t  prog_cmd 
)
int32_t setProt ( SPIFIobj obj,
SPIFIopers opers,
char *  change,
char *  saveProt 
)
void setSize ( SPIFIobj obj,
int32_t  value 
)
int32_t wait_busy ( SPIFIobj obj,
uc  prog_or_erase 
)
void wren_sendAd ( SPIFIobj obj,
uint32_t  cmd,
uint32_t  addr,
uint32_t  value 
)
int32_t write_stat ( SPIFIobj obj,
uc  len,
uint16_t  value 
)

Variable Documentation

void(* set_mem_mode)(SPIFIobj *obj)