LPCOpen SPIFI FLASH Library (LPCSPIFILIB)
Documentation for the LPCSPIFILIB library
Classes | Macros | Typedefs | Enumerations
LPCSPIFILIB device driver API functions

Detailed Description

Classes

struct  SPIFI_FAM_NODE
 LPCSPIFILIB family data. More...
 
struct  SPIFI_FAM_DESC
 LPCSPIFILIB family descriptor, used to describe devices to non-device specific functions. More...
 
struct  SPIFI_DEV_NODE
 Register device data node. More...
 
struct  SPIFI_FAM_FX
 Device specific function pointers. More...
 
struct  SPIFI_DEVICE_ID
 Device identification data. More...
 
struct  SPIFI_DEVICE_DATA
 Register device data. More...
 
struct  SPIFI_HANDLE
 LPCSPIFILIB device handle, used with all device and info functions. More...
 
struct  SPIFI_INFODATA
 Common data applicable to all devices. More...
 
struct  SPIFI_DEV_ENUMERATOR
 Context for enumerating devices. More...
 

Macros

#define SPIFI_CAP_DUAL_READ   (1 << 0)
 Possible device capabilities returned from getInfo() More...
 
#define SPIFI_CAP_DUAL_WRITE   (1 << 1)
 
#define SPIFI_CAP_QUAD_READ   (1 << 2)
 
#define SPIFI_CAP_QUAD_WRITE   (1 << 3)
 
#define SPIFI_CAP_FULLLOCK   (1 << 4)
 
#define SPIFI_CAP_BLOCKLOCK   (1 << 5)
 
#define SPIFI_CAP_SUBBLKERASE   (1 << 6)
 
#define SPIFI_CAP_NOBLOCK   (1 << 16)
 
#define SPIFI_OPT_USE_DUAL   (3 << 0)
 Possible driver options, may not be supported by all drivers. More...
 
#define SPIFI_OPT_USE_QUAD   (3 << 2)
 
#define SPIFI_OPT_NOBLOCK   (1 << 16)
 
#define SPIFI_STAT_BUSY   (1 << 0)
 Possible device statuses returned from getInfo() More...
 
#define SPIFI_STAT_ISWP   (1 << 1)
 
#define SPIFI_STAT_FULLLOCK   (1 << 2)
 
#define SPIFI_STAT_PARTLOCK   (1 << 3)
 
#define SPIFI_STAT_PROGERR   (1 << 4)
 
#define SPIFI_STAT_ERASEERR   (1 << 5)
 
#define SPIFI_INFO_QUADREAD_CLOCK   SPIFI_INFO_MAX_HSREAD_CLOCK
 SPIFI_INFO_QUADREAD_CLOCK Depricated! Do NOT use for new development.
 
#define SPIFI_INFO_QUADPROG_CLOCK   SPIFI_INFO_MAX_HSPROG_CLOCK
 SPIFI_INFO_QUADPROG_CLOCK Depricated! Do NOT use for new development.
 

Typedefs

typedef struct SPIFI_FAM_NODE SPIFI_FAM_NODE_T
 LPCSPIFILIB family data.
 
typedef struct SPIFI_FAM_DESC SPIFI_FAM_DESC_T
 LPCSPIFILIB family descriptor, used to describe devices to non-device specific functions.
 
typedef struct SPIFI_DEV_NODE SPIFI_DEV_NODE_T
 Register device data node.
 
typedef SPIFI_ERR_T(* deviceInitDeInitFx )(const struct SPIFI_HANDLE *, uint32_t)
 
typedef void(* devClearStatusFx )(const struct SPIFI_HANDLE *)
 
typedef uint32_t(* devGetStatusFx )(const struct SPIFI_HANDLE *)
 
typedef void(* devSetStatusFx )(const struct SPIFI_HANDLE *, uint32_t)
 
typedef SPIFI_ERR_T(* devSetOptsFx )(const struct SPIFI_HANDLE *, uint32_t, uint32_t)
 
typedef void(* devGetReadCmdFx )(const struct SPIFI_HANDLE *, uint8_t, uint32_t *, uint32_t *)
 
typedef void(* devGetWriteCmdFx )(const struct SPIFI_HANDLE *, uint32_t *)
 
typedef struct SPIFI_FAM_FX SPIFI_FAM_FX_T
 Device specific function pointers.
 
typedef struct SPIFI_DEVICE_ID SPIFI_DEVICE_ID_T
 Device identification data.
 
typedef struct SPIFI_DEVICE_DATA SPIFI_DEVICE_DATA_T
 Register device data.
 
typedef struct SPIFI_HANDLE SPIFI_HANDLE_T
 LPCSPIFILIB device handle, used with all device and info functions.
 
typedef struct SPIFI_INFODATA SPIFI_INFODATA_T
 Common data applicable to all devices.
 
typedef struct SPIFI_DEV_ENUMERATOR SPIFI_DEV_ENUMERATOR_T
 Context for enumerating devices.
 

Enumerations

enum  SPIFI_ERR_T {
  SPIFI_ERR_NONE = 0, SPIFI_ERR_BUSY, SPIFI_ERR_GEN, SPIFI_ERR_NOTSUPPORTED,
  SPIFI_ERR_ALIGNERR, SPIFI_ERR_LOCKED, SPIFI_ERR_PROGERR, SPIFI_ERR_ERASEERR,
  SPIFI_ERR_NOTBLANK, SPIFI_ERR_PAGESIZE, SPIFI_ERR_VAL, SPIFI_ERR_RANGE,
  SPIFI_ERR_MEMMODE
}
 Possible error codes that can be returned from functions. More...
 
enum  SPIFI_INFO_ID_T {
  SPIFI_INFO_BASE_ADDRESS = 0, SPIFI_INFO_DEVSIZE, SPIFI_INFO_ERASE_BLOCKS, SPIFI_INFO_ERASE_BLOCKSIZE,
  SPIFI_INFO_ERASE_SUBBLOCKS, SPIFI_INFO_ERASE_SUBBLOCKSIZE, SPIFI_INFO_PAGESIZE, SPIFI_INFO_MAXREADSIZE,
  SPIFI_INFO_MAXCLOCK, SPIFI_INFO_MAX_READ_CLOCK, SPIFI_INFO_MAX_HSREAD_CLOCK, SPIFI_INFO_MAX_PROG_CLOCK,
  SPIFI_INFO_MAX_HSPROG_CLOCK, SPIFI_INFO_CAPS, SPIFI_INFO_STATUS, SPIFI_INFO_STATUS_RETAIN,
  SPIFI_INFO_OPTIONS, SPIFI_INFO_LASTINDEX
}
 Possible info lookup requests. More...
 
enum  SPIFI_PCMD_LOCK_UNLOCK_T { SPIFI_PCMD_UNLOCK_DEVICE = 0, SPIFI_PCMD_LOCK_DEVICE, SPIFI_PCMD_UNLOCK_BLOCK, SPIFI_PCMD_LOCK_BLOCK }
 Possible device specific lock / un-lock commands. More...
 
enum  SPIFI_PCMD_SUBBLK_T { SPIFI_PCMD_ADDR_TO_SUB_BLOCK = 0, SPIFI_PCMD_SUB_BLOCK_TO_ADDR, SPIFI_PCMD_BLOCK_TO_SUB_BLOCK }
 Possible device specific sub-block commands. More...
 
enum  SPIFI_DEVFX_T {
  FX_spifiDeviceDataInitDeinit = 0, FX_spifiDeviceDataInitDeinitS25FL164K, FX_spifiDeviceDataClearStatusNone, FX_spifiDeviceDataClearStatusS25FL032P,
  FX_spifiDeviceDataGetStatusS25FL032P, FX_spifiDeviceDataGetStatusS25FL164K, FX_spifiDeviceDataGetStatusMX25L3235E, FX_spifiDeviceDataGetStatusW25Q80BV,
  FX_spifiDeviceDataSetStatusS25FL032P, FX_spifiDeviceDataSetStatusS25FL164K, FX_spifiDeviceDataSetStatusMX25L3235E, FX_spifiDeviceDataSetOptsQuadModeBit9,
  FX_spifiDeviceDataSetOptsQuadModeBit6, FX_spifiDeviceInitReadCommand, FX_spifiDeviceInitWriteCommand, FX_spifiDeviceInitWriteCommandMacronix
}
 Enumeration of device specific functions. More...
 

Macro Definition Documentation

#define SPIFI_CAP_BLOCKLOCK   (1 << 5)

Individual block device lock supported

#define SPIFI_CAP_DUAL_READ   (1 << 0)

Possible device capabilities returned from getInfo()

Supports DUAL read mode

#define SPIFI_CAP_DUAL_WRITE   (1 << 1)

Supports DUAL write mode

#define SPIFI_CAP_FULLLOCK   (1 << 4)

Full device lock supported

#define SPIFI_CAP_NOBLOCK   (1 << 16)

Non-blocking mode supported

#define SPIFI_CAP_QUAD_READ   (1 << 2)

Supports QUAD read mode

#define SPIFI_CAP_QUAD_WRITE   (1 << 3)

Supports QUAD write mode

#define SPIFI_CAP_SUBBLKERASE   (1 << 6)

Sub-block erase supported

#define SPIFI_OPT_NOBLOCK   (1 << 16)

Will not block on program and erase operations, poll device status manually

#define SPIFI_OPT_USE_DUAL   (3 << 0)

Possible driver options, may not be supported by all drivers.

Enable DUAL read / write if option is supported

#define SPIFI_OPT_USE_QUAD   (3 << 2)

Enable QUAD read / write if option is supported

#define SPIFI_STAT_BUSY   (1 << 0)

Possible device statuses returned from getInfo()

Device is busy erasing or programming

#define SPIFI_STAT_ERASEERR   (1 << 5)

Device status shows a erase error (non-blocking mode only)

#define SPIFI_STAT_FULLLOCK   (1 << 2)

Device is fully locked

#define SPIFI_STAT_ISWP   (1 << 1)

Device is write protected (software or hardware)

#define SPIFI_STAT_PARTLOCK   (1 << 3)

Device is partially locked (device specific)

#define SPIFI_STAT_PROGERR   (1 << 4)

Device status shows a program error (non-blocking mode only)

Typedef Documentation

typedef void(* devClearStatusFx)(const struct SPIFI_HANDLE *)

Fx* to clear status

typedef void(* devGetReadCmdFx)(const struct SPIFI_HANDLE *, uint8_t, uint32_t *, uint32_t *)

Fx* to return read commandReg value

typedef uint32_t(* devGetStatusFx)(const struct SPIFI_HANDLE *)

Fx* to get status

typedef void(* devGetWriteCmdFx)(const struct SPIFI_HANDLE *, uint32_t *)

Fx* to return write commandReg value

typedef SPIFI_ERR_T(* deviceInitDeInitFx)(const struct SPIFI_HANDLE *, uint32_t)

Fx* to handle init / de-init

typedef SPIFI_ERR_T(* devSetOptsFx)(const struct SPIFI_HANDLE *, uint32_t, uint32_t)

Fx* to set options

typedef void(* devSetStatusFx)(const struct SPIFI_HANDLE *, uint32_t)

Fx* to set status

Enumeration Type Documentation

Enumeration of device specific functions.

Enumerator
FX_spifiDeviceDataInitDeinit 

Generic device init / de-init function

FX_spifiDeviceDataInitDeinitS25FL164K 

S25FL164K specific device init / de-init function

FX_spifiDeviceDataClearStatusNone 

General do nothing I.e no status bits to clear

FX_spifiDeviceDataClearStatusS25FL032P 

S25FL032P (and similar) clear status bits function

FX_spifiDeviceDataGetStatusS25FL032P 

S25FL032P (and similar) get status function

FX_spifiDeviceDataGetStatusS25FL164K 

S25FL164K (and similar) get status function

FX_spifiDeviceDataGetStatusMX25L3235E 

MX25L3235E (and similar) get status function

FX_spifiDeviceDataGetStatusW25Q80BV 

W25Q80BV (and similar) get status function

FX_spifiDeviceDataSetStatusS25FL032P 

S25FL032P (and similar) set status function

FX_spifiDeviceDataSetStatusS25FL164K 

S25FL164K (and similar) set status function

FX_spifiDeviceDataSetStatusMX25L3235E 

MX25L3235E (and similar) set sttus function

FX_spifiDeviceDataSetOptsQuadModeBit9 

Set bit 9 when enabling Quad mode

FX_spifiDeviceDataSetOptsQuadModeBit6 

Set bit 6 when enabling Quad mode

FX_spifiDeviceInitReadCommand 

General return cmdReg value for read

FX_spifiDeviceInitWriteCommand 

General return cmdReg value for write

FX_spifiDeviceInitWriteCommandMacronix 

Macronix return cmdReg value for write

Possible error codes that can be returned from functions.

Enumerator
SPIFI_ERR_NONE 

No error

SPIFI_ERR_BUSY 

Device is busy

SPIFI_ERR_GEN 

General error

SPIFI_ERR_NOTSUPPORTED 

Capability not supported

SPIFI_ERR_ALIGNERR 

Attempted to do an operation on an unaligned section of the device

SPIFI_ERR_LOCKED 

Device was locked and a program/erase operation was attempted

SPIFI_ERR_PROGERR 

Error programming device (blocking mode only)

SPIFI_ERR_ERASEERR 

Erase error (blocking mode only)

SPIFI_ERR_NOTBLANK 

Program operation on block that is not blank

SPIFI_ERR_PAGESIZE 

PageProgram write size exceeds page size

SPIFI_ERR_VAL 

Program operation failed validation or readback compare

SPIFI_ERR_RANGE 

Range error, bad block number, address out of range, etc.

SPIFI_ERR_MEMMODE 

Library calls not allowed while in memory mode.

Possible info lookup requests.

Enumerator
SPIFI_INFO_BASE_ADDRESS 

Device physical memory address

SPIFI_INFO_DEVSIZE 

Device size in Bytes

SPIFI_INFO_ERASE_BLOCKS 

Number of erase blocks

SPIFI_INFO_ERASE_BLOCKSIZE 

Size of erase blocks

SPIFI_INFO_ERASE_SUBBLOCKS 

Number of erase sub-blocks

SPIFI_INFO_ERASE_SUBBLOCKSIZE 

Size of erase sub-blocks

SPIFI_INFO_PAGESIZE 

Size of a page, page write size limit

SPIFI_INFO_MAXREADSIZE 

Maximum read size, read size limit in bytes

SPIFI_INFO_MAXCLOCK 

Maximum device speed in Hz

SPIFI_INFO_MAX_READ_CLOCK 

Maximum device speed for read cmd in Hz

SPIFI_INFO_MAX_HSREAD_CLOCK 

Maximum device speed for quad / dual read cmd in Hz

SPIFI_INFO_MAX_PROG_CLOCK 

Maximum device speed for program cmd in Hz

SPIFI_INFO_MAX_HSPROG_CLOCK 

Maximum device speed for quad program cmd in Hz

SPIFI_INFO_CAPS 

Device capabilities, OR'ed SPIFI_CAP_* values

SPIFI_INFO_STATUS 

Or'ed SPIFI_STAT_xxx values. Any persistent hardware bits will be cleared

SPIFI_INFO_STATUS_RETAIN 

Or'ed SPIFI_STAT_xxx values. Any persistent hardware bits will be retained

SPIFI_INFO_OPTIONS 

Device capabilities, Or'ed SPIFI_OPT_* values

Possible device specific lock / un-lock commands.

Enumerator
SPIFI_PCMD_UNLOCK_DEVICE 

unlock device

SPIFI_PCMD_LOCK_DEVICE 

lock device

SPIFI_PCMD_UNLOCK_BLOCK 

unlock specified block

SPIFI_PCMD_LOCK_BLOCK 

lock specified block

Possible device specific sub-block commands.

Enumerator
SPIFI_PCMD_ADDR_TO_SUB_BLOCK 

Convert address to a sub-block

SPIFI_PCMD_SUB_BLOCK_TO_ADDR 

Convert sub-block to address

SPIFI_PCMD_BLOCK_TO_SUB_BLOCK 

Convert block to sub-block