LPCOpen SPIFI FLASH Library (LPCSPIFILIB)
Documentation for the LPCSPIFILIB library
Macros | Functions

Detailed Description

Device functions are used to perform LPCSPIFILIB device operations.

Macros

#define spifiDevGetFamilyName   spifiDevGetDeviceName
 

Functions

SPIFI_ERR_T spifiDevRegister (const SPIFI_FAM_NODE_T *pFamily, SPIFI_DEV_NODE_T *pDevData)
 Add device to family driver. More...
 
static INLINE uint32_t spifiDevGetCount (const SPIFI_FAM_NODE_T *pFamily)
 Returns the number of supported devices within a family. More...
 
const char * spifiDevEnumerateName (SPIFI_DEV_ENUMERATOR_T *pContext, uint8_t reset)
 Enumerates the friendly names of supported devices. More...
 
SPIFI_ERR_T spifiDevInit (const SPIFI_HANDLE_T *pHandle)
 Initialize a detected LPCSPIFILIB device. More...
 
SPIFI_ERR_T spifiDevDeInit (const SPIFI_HANDLE_T *pHandle)
 De-initialize a detected LPCSPIFILIB device. More...
 
SPIFI_ERR_T spifiDevSetMemMode (const SPIFI_HANDLE_T *pHandle, uint8_t enMMode)
 Sets or clears memory mode. More...
 
uint8_t spifiDevGetMemoryMode (const SPIFI_HANDLE_T *pSpifi)
 Return status of memory mode. More...
 
static INLINE SPIFI_ERR_T spifiDevUnlockDevice (const SPIFI_HANDLE_T *pHandle)
 Full LPCSPIFILIB device unlock. More...
 
static INLINE SPIFI_ERR_T spifiDevLockDevice (const SPIFI_HANDLE_T *pHandle)
 Full LPCSPIFILIB device lock. More...
 
static INLINE SPIFI_ERR_T spifiDevUnlockBlock (const SPIFI_HANDLE_T *pHandle, uint32_t block)
 Unlock a single device block. More...
 
static INLINE SPIFI_ERR_T spifiDevLockBlock (const SPIFI_HANDLE_T *pHandle, uint32_t block)
 Lock a single device block. More...
 
static INLINE SPIFI_ERR_T spifiDevEraseAll (const SPIFI_HANDLE_T *pHandle)
 Full LPCSPIFILIB device erase. More...
 
static INLINE SPIFI_ERR_T spifiDevEraseSubBlock (const SPIFI_HANDLE_T *pHandle, uint32_t blknum)
 Erase a sub-block. More...
 
static INLINE SPIFI_ERR_T spifiDevPageProgram (const SPIFI_HANDLE_T *pHandle, uint32_t addr, uint32_t *writeBuff, uint32_t bytes)
 Program up to a page of data at an address. More...
 
static INLINE SPIFI_ERR_T spifiDevRead (const SPIFI_HANDLE_T *pHandle, uint32_t addr, uint32_t *readBuff, uint32_t bytes)
 Read data from a LPCSPIFILIB device. More...
 
static INLINE void spifiDevReset (const SPIFI_HANDLE_T *pHandle)
 Reset the device. More...
 
static INLINE const char * spifiDevGetDeviceName (const SPIFI_HANDLE_T *pHandle)
 Returns a string pointer to the generic device family name. More...
 
uint32_t spifiDevGetInfo (const SPIFI_HANDLE_T *pHandle, SPIFI_INFO_ID_T infoId)
 Returns information on the device. More...
 

Macro Definition Documentation

#define spifiDevGetFamilyName   spifiDevGetDeviceName

Deprecated! Do NOT use for new development

Function Documentation

SPIFI_ERR_T spifiDevDeInit ( const SPIFI_HANDLE_T pHandle)

De-initialize a detected LPCSPIFILIB device.

Parameters
pHandle: Pointer to a LPCSPIFILIB device handle
Returns
A SPIFI_NO_* error code (SPIFI_ERR_NONE is no errors)
const char* spifiDevEnumerateName ( SPIFI_DEV_ENUMERATOR_T pContext,
uint8_t  reset 
)

Enumerates the friendly names of supported devices.

Parameters
pContext: Pointer to a SPIFI_DEV_ENUMERATOR_T context structure
reset: 0 enumerates next device, 1 resets list to beginning and returns first device
Returns
A friendly string representing the device, NULL when list has been exhausted.
static INLINE SPIFI_ERR_T spifiDevEraseAll ( const SPIFI_HANDLE_T pHandle)
static

Full LPCSPIFILIB device erase.

Parameters
pHandle: Pointer to a LPCSPIFILIB device handle
Returns
A SPIFI_NO_* error code (SPIFI_ERR_NONE is no errors)
static INLINE SPIFI_ERR_T spifiDevEraseSubBlock ( const SPIFI_HANDLE_T pHandle,
uint32_t  blknum 
)
static

Erase a sub-block.

Parameters
pHandle: Pointer to a LPCSPIFILIB device handle
blknum: Sub-block number to erase
Returns
A SPIFI_NO_* error code (SPIFI_ERR_NONE is no errors)
static INLINE uint32_t spifiDevGetCount ( const SPIFI_FAM_NODE_T pFamily)
static

Returns the number of supported devices within a family.

Parameters
pFamily: Pointer to a SPIFI_DEV_FAMILY_T family handle
Returns
The number of registered devices.
static INLINE const char* spifiDevGetDeviceName ( const SPIFI_HANDLE_T pHandle)
static

Returns a string pointer to the generic device family name.

Parameters
pHandle: Pointer to a LPCSPIFILIB device handle
Returns
a string pointer to the generic device family name
uint32_t spifiDevGetInfo ( const SPIFI_HANDLE_T pHandle,
SPIFI_INFO_ID_T  infoId 
)

Returns information on the device.

Parameters
pHandle: Pointer to a LPCSPIFILIB device handle
infoId: Info to get about the device
Returns
Return value varies per selected function
uint8_t spifiDevGetMemoryMode ( const SPIFI_HANDLE_T pSpifi)

Return status of memory mode.

Parameters
pSpifi: Base address of SPIFI controller
Returns
state of memory mode (false = off, true = on)
SPIFI_ERR_T spifiDevInit ( const SPIFI_HANDLE_T pHandle)

Initialize a detected LPCSPIFILIB device.

Parameters
pHandle: Pointer to a LPCSPIFILIB device handle
Returns
A SPIFI_NO_* error code (SPIFI_ERR_NONE is no errors)
static INLINE SPIFI_ERR_T spifiDevLockBlock ( const SPIFI_HANDLE_T pHandle,
uint32_t  block 
)
static

Lock a single device block.

Parameters
pHandle: Pointer to a LPCSPIFILIB device handle
block: Block number to lock
Returns
A SPIFI_NO_* error code (SPIFI_ERR_NONE is no errors)
static INLINE SPIFI_ERR_T spifiDevLockDevice ( const SPIFI_HANDLE_T pHandle)
static

Full LPCSPIFILIB device lock.

Parameters
pHandle: Pointer to a LPCSPIFILIB device handle
Returns
A SPIFI_NO_* error code (SPIFI_ERR_NONE is no errors)
static INLINE SPIFI_ERR_T spifiDevPageProgram ( const SPIFI_HANDLE_T pHandle,
uint32_t  addr,
uint32_t *  writeBuff,
uint32_t  bytes 
)
static

Program up to a page of data at an address.

Parameters
pHandle: Pointer to a LPCSPIFILIB device handle
addr: LPCSPIFILIB device address to start write at
writeBuff: Address of buffer to write, must be 32-bit aligned
bytes: Number of bytes to write, must not exceed page length
Returns
A SPIFI_NO_* error code (SPIFI_ERR_NONE is no errors)
Note
Only use this function to program data up to the page size.
static INLINE SPIFI_ERR_T spifiDevRead ( const SPIFI_HANDLE_T pHandle,
uint32_t  addr,
uint32_t *  readBuff,
uint32_t  bytes 
)
static

Read data from a LPCSPIFILIB device.

Parameters
pHandle: Pointer to a LPCSPIFILIB device handle
addr: LPCSPIFILIB device address to read from
readBuff: Address of buffer to fill, must be 32-bit aligned
bytes: Number of bytes to read
Returns
A SPIFI_NO_* error code (SPIFI_ERR_NONE is no errors)
Note
Maximum read size is limited to the max single read size
SPIFI_ERR_T spifiDevRegister ( const SPIFI_FAM_NODE_T pFamily,
SPIFI_DEV_NODE_T pDevData 
)

Add device to family driver.

Parameters
pFamily: Pointer to a SPIFI_DEV_FAMILY_T family handle
pDevData: Pointer to a persistent SPIFI_DEV_DATA_T device structure
Returns
A SPIFI_ERR_T error code (SPIFI_ERR_NONE for no errors)
Note
This function MUST be called prior to spifiGetHandleMemSize() or spifiInitDevice()
static INLINE void spifiDevReset ( const SPIFI_HANDLE_T pHandle)
static

Reset the device.

Parameters
pHandle: Pointer to a LPCSPIFILIB device handle
Returns
Nothing
Note
Will set the device into read mode
SPIFI_ERR_T spifiDevSetMemMode ( const SPIFI_HANDLE_T pHandle,
uint8_t  enMMode 
)

Sets or clears memory mode.

Parameters
pHandle: Pointer to a LPCSPIFILIB device handle
enMMode: true to enable memory mode, false to disable
Returns
A SPIFI_NO_* error code (SPIFI_ERR_NONE is no errors)
Note
Enter memory mode to enable direct read access for Execute in place code and memory mapped data. Memory mode must be disabled for most operations.
static INLINE SPIFI_ERR_T spifiDevUnlockBlock ( const SPIFI_HANDLE_T pHandle,
uint32_t  block 
)
static

Unlock a single device block.

Parameters
pHandle: Pointer to a LPCSPIFILIB device handle
block: Block number to unlock
Returns
A SPIFI_NO_* error code (SPIFI_ERR_NONE is no errors)
static INLINE SPIFI_ERR_T spifiDevUnlockDevice ( const SPIFI_HANDLE_T pHandle)
static

Full LPCSPIFILIB device unlock.

Parameters
pHandle: Pointer to a LPCSPIFILIB device handle
Returns
A SPIFI_NO_* error code (SPIFI_ERR_NONE is no errors)