Nut/OS  5.0.5
API Reference
XgLpc17xxIap

Defines

#define FLASH_CHIP_BASE   0x00000000
 Base address of the flash memory chip.
#define FLASH_CONF_SECTOR   0x00078000
 Address offset of the configuration sector.
#define FLASH_CONF_SIZE   256
 Size of the configuration area.
#define IAP_Call   iap_entry

Typedefs

typedef void(* IAP )(uint32_t *cmd, uint32_t *result)
typedef uint32_t flashdat_t
typedef unsigned long flashadr_t
typedef volatile flashdat_tflashptr_t

Functions

uint32_t Lpc17xxIapGetSectorNr (uint32_t addr)
 Get Sector Number.
IAP_STATUS_CODE Lpc17xxIapSectorRead (uint32_t addr, void *data, size_t len)
 Read data from flash memory.
IAP_STATUS_CODE Lpc17xxIapSectorWrite (uint32_t dest, void *source, IAP_WRITE_SIZE size)
 Write data to flash.
IAP_STATUS_CODE Lpc17xxIapSectorErase (uint32_t start_sec, uint32_t end_sec)
 Erase sector(s)
IAP_STATUS_CODE Lpc17xxIapSectorBlankCheck (uint32_t start_sec, uint32_t end_sec, uint32_t *first_nblank_off, uint32_t *first_nblank_val)
 Blank check sector(s)
IAP_STATUS_CODE Lpc17xxIapReadBootCodeVersion (uint8_t *major, uint8_t *minor)
 Read boot code version. The version is interpreted as <major>.<minor>.
IAP_STATUS_CODE Lpc17xxIapReadDeviceSerialNumber (uint32_t *uid)
 Read Device serial number.
int Lpc17xxIapParamRead (unsigned int pos, void *data, size_t len)
 Load configuration parameters from embedded flash memory.
int Lpc17xxIapParamWrite (unsigned int pos, const void *data, size_t len)
 Store configuration parameters in embedded flash memory.

Variables

IAP iap_entry = (IAP) IAP_LOCATION

Define Documentation

#define FLASH_CHIP_BASE   0x00000000

Base address of the flash memory chip.

Referenced by Lpc17xxIapSectorRead(), and ShowHardwareConfiguration().

#define FLASH_CONF_SECTOR   0x00078000

Address offset of the configuration sector.

Referenced by Lpc17xxIapParamRead(), and Lpc17xxIapParamWrite().

#define FLASH_CONF_SIZE   256

Size of the configuration area.

During write operations a buffer with this size is allocated from heap and may cause memory problems with large sectors. Thus, this value may be less than the size of the configuration sector, in which case the rest of the sector is unused.

Currently only 1 sector can be used for system configurations.

Referenced by Lpc17xxIapParamWrite().


Typedef Documentation

typedef void(* IAP)(uint32_t *cmd, uint32_t *result)
typedef unsigned long flashadr_t
typedef volatile flashdat_t* flashptr_t

Function Documentation

uint32_t Lpc17xxIapGetSectorNr ( uint32_t  addr)

Get Sector Number.

IAP API.

Parameters:
addrSector address
Returns:
sector number

Referenced by Lpc17xxIapSectorWrite().

IAP_STATUS_CODE Lpc17xxIapSectorRead ( uint32_t  addr,
void *  data,
size_t  len 
)

Read data from flash memory.

Parameters:
addrStart location within the chip, starting at 0.
dataPoints to a buffer that receives the data.
lenNumber of bytes to read.
Returns:
Always CMD_SUCCESS.

References CMD_SUCCESS, DST_ADDR_ERROR, FLASH_CHIP_BASE, memcpy(), and NULL.

Referenced by Lpc17xxIapParamRead(), and Lpc17xxIapParamWrite().

Here is the call graph for this function:

IAP_STATUS_CODE Lpc17xxIapSectorWrite ( uint32_t  dest,
void *  source,
IAP_WRITE_SIZE  size 
)

Write data to flash.

Parameters:
destdestination buffer (in Flash memory) (must be 256 byte aligned).
sourcesource buffer (in RAM) (should be word aligned)
sizethe write size.
Returns:
CMD_SUCCESS. SRC_ADDR_ERROR/DST_ADDR_ERROR SRC_ADDR_NOT_MAPPED/DST_ADDR_NOT_MAPPED COUNT_ERROR/SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION BUSY

References IAP_COMMAND_Type::cmd, CMD_SUCCESS, IAP_Call, IAP_COPY_RAM2FLASH, Lpc17xxIapGetSectorNr(), NUT_HWCLK_CPU, NutArchClockGet(), IAP_COMMAND_Type::param, and IAP_COMMAND_Type::status.

Referenced by Lpc17xxIapParamWrite().

Here is the call graph for this function:

IAP_STATUS_CODE Lpc17xxIapSectorErase ( uint32_t  start_sec,
uint32_t  end_sec 
)

Erase sector(s)

Parameters:
start_secNumber of start sector
end_secNumber of end sector
Returns:
CMD_SUCCESS, INVALID_SECTOR, SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION, BUSY

References IAP_COMMAND_Type::cmd, CMD_SUCCESS, IAP_Call, IAP_ERASE, NUT_HWCLK_CPU, NutArchClockGet(), IAP_COMMAND_Type::param, and IAP_COMMAND_Type::status.

Here is the call graph for this function:

IAP_STATUS_CODE Lpc17xxIapSectorBlankCheck ( uint32_t  start_sec,
uint32_t  end_sec,
uint32_t first_nblank_off,
uint32_t first_nblank_val 
)

Blank check sector(s)

Parameters:
start_secNumber of start sector
end_sec Number of end sector
first_nblank_offThe offset of the first non-blank word
first_nblank_valThe value of the first non-blank word
Returns:
CMD_SUCCESS, INVALID_SECTOR, SECTOR_NOT_BLANK, BUSY

References IAP_COMMAND_Type::cmd, IAP_BLANK_CHECK, IAP_Call, NULL, IAP_COMMAND_Type::param, IAP_COMMAND_Type::result, SECTOR_NOT_BLANK, and IAP_COMMAND_Type::status.

IAP_STATUS_CODE Lpc17xxIapReadBootCodeVersion ( uint8_t major,
uint8_t minor 
)

Read boot code version. The version is interpreted as <major>.<minor>.

Parameters:
majorReturns major version number
minorReturns minor version number
Returns:
CMD_SUCCESS

References IAP_COMMAND_Type::cmd, CMD_SUCCESS, IAP_Call, IAP_READ_BOOT_VER, NULL, IAP_COMMAND_Type::result, and IAP_COMMAND_Type::status.

IAP_STATUS_CODE Lpc17xxIapReadDeviceSerialNumber ( uint32_t uid)

Read Device serial number.

Parameters:
uidSerial number
Returns:
CMD_SUCCESS

References IAP_COMMAND_Type::cmd, CMD_SUCCESS, IAP_Call, IAP_READ_SERIAL_NUMBER, NULL, IAP_COMMAND_Type::result, and IAP_COMMAND_Type::status.

int Lpc17xxIapParamRead ( unsigned int  pos,
void *  data,
size_t  len 
)

Load configuration parameters from embedded flash memory.

Applications should call NutNvMemLoad().

Parameters:
posStart location within configuration sector.
dataPoints to a buffer that receives the contents.
lenNumber of bytes to read.
Returns:
Always 0.

References FLASH_CONF_SECTOR, and Lpc17xxIapSectorRead().

Referenced by NutNvMemLoad().

Here is the call graph for this function:

int Lpc17xxIapParamWrite ( unsigned int  pos,
const void *  data,
size_t  len 
)

Store configuration parameters in embedded flash memory.

Applications should call NutNvMemSave().

Parameters:
posStart location within configuration sector.
dataPoints to a buffer that contains the bytes to store.
lenNumber of bytes to store.
Returns:
0 on success or -1 in case of an error.

References CMD_SUCCESS, FLASH_CONF_SECTOR, FLASH_CONF_SIZE, free(), Lpc17xxIapSectorRead(), Lpc17xxIapSectorWrite(), malloc(), memcmp(), memcpy(), NULL, and rc.

Referenced by NutNvMemSave().

Here is the call graph for this function:


Variable Documentation

IAP iap_entry = (IAP) IAP_LOCATION