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

Detailed Description

Functions

uint32_t spifiGetAddrFromBlock (const SPIFI_HANDLE_T *pHandle, uint32_t blockNum)
 Returns the starting address of a block number. More...
 
uint32_t spifiGetAddrFromSubBlock (const SPIFI_HANDLE_T *pHandle, uint32_t subBlockNum)
 Returns the starting address of a sub-block number. More...
 
uint32_t spifiGetBlockFromAddr (const SPIFI_HANDLE_T *pHandle, uint32_t addr)
 Returns the block number the passed address is located in. More...
 
uint32_t spifiGetSubBlockFromAddr (const SPIFI_HANDLE_T *pHandle, uint32_t addr)
 Returns the sub-block number the passed address is located in. More...
 
uint32_t spifiGetSubBlockFromBlock (const SPIFI_HANDLE_T *pHandle, uint32_t blockNum)
 Returns the first sub-block for a block. More...
 
SPIFI_ERR_T spifiProgram (const SPIFI_HANDLE_T *pHandle, uint32_t addr, const uint32_t *writeBuff, uint32_t bytes)
 Program the device with the passed buffer. More...
 
SPIFI_ERR_T spifiRead (const SPIFI_HANDLE_T *pHandle, uint32_t addr, uint32_t *readBuff, uint32_t bytes)
 Read the device into the passed buffer. More...
 
SPIFI_ERR_T spifiErase (const SPIFI_HANDLE_T *pHandle, uint32_t firstBlock, uint32_t numBlocks)
 Erase multiple blocks. More...
 
SPIFI_ERR_T spifiEraseByAddr (const SPIFI_HANDLE_T *pHandle, uint32_t firstAddr, uint32_t lastAddr)
 Erase multiple blocks by address range. More...
 

Function Documentation

SPIFI_ERR_T spifiErase ( const SPIFI_HANDLE_T pHandle,
uint32_t  firstBlock,
uint32_t  numBlocks 
)

Erase multiple blocks.

Parameters
pHandle: Pointer to a LPCSPIFILIB device handle
firstBlock: First block number to erase
numBlocks: Number of blocks to erase
Returns
A SPIFI_ERR_xxx error code (SPIFI_ERR_NONE is no errors)
Note
If any of the specified params are invalid, the operation is aborted before any sectors are erased. This function only works in blocking mode.
SPIFI_ERR_T spifiEraseByAddr ( const SPIFI_HANDLE_T pHandle,
uint32_t  firstAddr,
uint32_t  lastAddr 
)

Erase multiple blocks by address range.

Parameters
pHandle: Pointer to a LPCSPIFILIB device handle
firstAddr: Starting address range for block erase
lastAddr: Ending address range for block erase
Returns
A SPIFI_ERR_xxx error code (SPIFI_ERR_NONE is no errors)
Note
This function will erase blocks inside the passed address range if and only if the address range is valid. This function only works in blocking mode.
uint32_t spifiGetAddrFromBlock ( const SPIFI_HANDLE_T pHandle,
uint32_t  blockNum 
)

Returns the starting address of a block number.

Parameters
pHandle: Pointer to a LPCSPIFILIB device handle
blockNum: Block number fo get starting address for
Returns
The starting address for the block, or 0xFFFFFFFF if the block number if invalid
uint32_t spifiGetAddrFromSubBlock ( const SPIFI_HANDLE_T pHandle,
uint32_t  subBlockNum 
)

Returns the starting address of a sub-block number.

Parameters
pHandle: Pointer to a LPCSPIFILIB device handle
subBlockNum: Sub-block number fo get starting address for
Returns
The starting address for the sub-block, or 0xFFFFFFFF if the block number if invalid
uint32_t spifiGetBlockFromAddr ( const SPIFI_HANDLE_T pHandle,
uint32_t  addr 
)

Returns the block number the passed address is located in.

Parameters
pHandle: Pointer to a LPCSPIFILIB device handle
addr: Address to get block number for
Returns
The block number the passed address is in, 0xFFFFFFFF is the address is invalid
uint32_t spifiGetSubBlockFromAddr ( const SPIFI_HANDLE_T pHandle,
uint32_t  addr 
)

Returns the sub-block number the passed address is located in.

Parameters
pHandle: Pointer to a LPCSPIFILIB device handle
addr: Address to get sub-block number for
Returns
The sub-block number the passed address is in, 0xFFFFFFFF is the address is invalid
uint32_t spifiGetSubBlockFromBlock ( const SPIFI_HANDLE_T pHandle,
uint32_t  blockNum 
)

Returns the first sub-block for a block.

Parameters
pHandle: Pointer to a LPCSPIFILIB device handle
blockNum: Block number to get first sub-block for
Returns
The first sub-block number in passed block, 0xFFFFFFFF if the block number if invalid
SPIFI_ERR_T spifiProgram ( const SPIFI_HANDLE_T pHandle,
uint32_t  addr,
const uint32_t *  writeBuff,
uint32_t  bytes 
)

Program the device with the passed buffer.

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
Returns
A SPIFI_ERR_xxx error code (SPIFI_ERR_NONE is no errors)
Note
This function has no size limit. This function only works in blocking mode.
SPIFI_ERR_T spifiRead ( const SPIFI_HANDLE_T pHandle,
uint32_t  addr,
uint32_t *  readBuff,
uint32_t  bytes 
)

Read the device into the passed buffer.

Parameters
pHandle: Pointer to a LPCSPIFILIB device handle
addr: LPCSPIFILIB device address to start read at
readBuff: Address of buffer to read into, must be 32-bit aligned
bytes: Number of bytes to read
Returns
A SPIFI_ERR_xxx error code (SPIFI_ERR_NONE is no errors)
Note
This function has no size limit. Optionally, the device can be placed into memory mode and accessed directly via memory mapped reads without using this function. This function only works in blocking mode.