LPCOpen Platform for LPC18XX/43XX microcontrollers: CHIP: LPC18xx/43xx Flash IAP driver

| LPCOpen Platform for LPC18XX/43XX microcontrollers 18XX43XX LPCOpen Platform for the NXP LPC18XX/43XX family of Microcontrollers

- Main Page
- Modules
- Data Structures
- Files

Macros | Typedefs | Functions
CHIP: LPC18xx/43xx Flash IAP driver
LPC18xx/43xx chip specific drivers

## Detailed Description

## Macros
#define | IAP_PREWRRITE_CMD 50
#define | IAP_WRISECTOR_CMD 51
#define | IAP_ERSSECTOR_CMD 52
#define | IAP_BLANK_CHECK_SECTOR_CMD 53
#define | IAP_REPID_CMD 54
#define | IAP_READ_BOOT_CODE_CMD 55
#define | IAP_COMPARE_CMD 56
#define | IAP_REINVOKE_ISP_CMD 57
#define | IAP_READ_UID_CMD 58
#define | IAP_ERASE_PAGE_CMD 59
#define | IAP_SET_BOOT_FLASH 60
#define | IAP_EEPROM_WRITE 61
#define | IAP_EEPROM_READ 62
#define | IAP_CMD_SUCCESS 0
#define | IAP_INVALID_COMMAND 1
#define | IAP_SRC_ADDR_ERROR 2
#define | IAP_DST_ADDR_ERROR 3
#define | IAP_SRC_ADDR_NOT_MAPPED 4
#define | IAP_DST_ADDR_NOT_MAPPED 5
#define | IAP_COUNT_ERROR 6
#define | IAP_INVALID_SECTOR 7
#define | IAP_SECTOR_NOT_BLANK 8
#define | IAP_SECTOR_NOT_PREPARED 9
#define | IAP_COMPARE_ERROR 10
#define | IAP_BUSY 11
#define | IAP_PARAM_ERROR 12
#define | IAP_ADDR_ERROR 13
#define | IAP_ADDR_NOT_MAPPED 14
#define | IAP_CMD_LOCKED 15
#define | IAP_INVALID_CODE 16
#define | IAP_INVALID_BAUD_RATE 17
#define | IAP_INVALID_STOP_BIT 18
#define | IAP_CRP_ENABLED 19

## Typedefs
typedef void(* | IAP_ENTRY_T )(unsigned int[5], unsigned int[4])

## Functions
uint8_t | Chip_IAP_PreSectorForReadWrite (uint32_t strSector, uint32_t endSector, uint8_t bankNum)
| Prepare sector for write operation. More...
uint8_t | Chip_IAP_CopyRamToFlash (uint32_t dstAdd, uint32_t *srcAdd, uint32_t byteswrt)
| Copy RAM to flash. More...
uint8_t | Chip_IAP_EraseSector (uint32_t strSector, uint32_t endSector, uint8_t bankNum)
| Erase sector. More...
uint8_t | Chip_IAP_BlankCheckSector (uint32_t strSector, uint32_t endSector, uint8_t bankNum)
| Blank check a sector or multiples sector of on-chip flash memory. More...
uint32_t | Chip_IAP_ReadPID (void)
| Read part identification number. More...
uint8_t | Chip_IAP_ReadBootCode (void)
| Read boot code version number. More...
uint8_t | Chip_IAP_Compare (uint32_t dstAdd, uint32_t srcAdd, uint32_t bytescmp)
| Compare the memory contents at two locations. More...
uint8_t | Chip_IAP_ReinvokeISP (void)
| IAP reinvoke ISP to invoke the bootloader in ISP mode. More...
uint32_t | Chip_IAP_ReadUID (void)
| Read the unique ID. More...
uint8_t | Chip_IAP_ErasePage (uint32_t strPage, uint32_t endPage)
| Erase a page or multiple papers of on-chip flash memory. More...
uint8_t | Chip_IAP_SetBootFlashBank (uint8_t bankNum)
| Set active boot flash bank. More...

## Macro Definition Documentation

#define IAP_ADDR_ERROR 13

Address is not on word boundary

Definition at line 73 of file iap_18xx_43xx.h.

#define IAP_ADDR_NOT_MAPPED 14

Address is not mapped in the memory map

Definition at line 74 of file iap_18xx_43xx.h.

#define IAP_BLANK_CHECK_SECTOR_CMD 53

Blank check sector

Definition at line 48 of file iap_18xx_43xx.h.

#define IAP_BUSY 11

Flash programming hardware interface is busy

Definition at line 71 of file iap_18xx_43xx.h.

#define IAP_CMD_LOCKED 15

Command is locked

Definition at line 75 of file iap_18xx_43xx.h.

#define IAP_CMD_SUCCESS 0

Command is executed successfully

Definition at line 60 of file iap_18xx_43xx.h.

#define IAP_COMPARE_CMD 56

Compare two RAM address locations

Definition at line 51 of file iap_18xx_43xx.h.

#define IAP_COMPARE_ERROR 10

Source and destination data not equal

Definition at line 70 of file iap_18xx_43xx.h.

#define IAP_COUNT_ERROR 6

Byte count is not multiple of 4 or is not a permitted value

Definition at line 66 of file iap_18xx_43xx.h.

#define IAP_CRP_ENABLED 19

Code read protection enabled

Definition at line 79 of file iap_18xx_43xx.h.

#define IAP_DST_ADDR_ERROR 3

Destination address is not on a correct boundary

Definition at line 63 of file iap_18xx_43xx.h.

#define IAP_DST_ADDR_NOT_MAPPED 5

Destination address is not mapped in the memory map

Definition at line 65 of file iap_18xx_43xx.h.

#define IAP_EEPROM_READ 62

EEPROM READ command

Definition at line 57 of file iap_18xx_43xx.h.

#define IAP_EEPROM_WRITE 61

EEPROM Write command

Definition at line 56 of file iap_18xx_43xx.h.

#define IAP_ERASE_PAGE_CMD 59

Erase page

Definition at line 54 of file iap_18xx_43xx.h.

#define IAP_ERSSECTOR_CMD 52

Erase Sector command

Definition at line 47 of file iap_18xx_43xx.h.

#define IAP_INVALID_BAUD_RATE 17

Invalid baud rate setting

Definition at line 77 of file iap_18xx_43xx.h.

#define IAP_INVALID_CODE 16

Unlock code is invalid

Definition at line 76 of file iap_18xx_43xx.h.

#define IAP_INVALID_COMMAND 1

Invalid command

Definition at line 61 of file iap_18xx_43xx.h.

#define IAP_INVALID_SECTOR 7

Sector number is invalid or end sector number is greater than start sector number

Definition at line 67 of file iap_18xx_43xx.h.

#define IAP_INVALID_STOP_BIT 18

Invalid stop bit setting

Definition at line 78 of file iap_18xx_43xx.h.

#define IAP_PARAM_ERROR 12

nsufficient number of parameters or invalid parameter

Definition at line 72 of file iap_18xx_43xx.h.

#define IAP_PREWRRITE_CMD 50

Prepare sector for write operation command

Definition at line 45 of file iap_18xx_43xx.h.

#define IAP_READ_BOOT_CODE_CMD 55

Read Boot code version

Definition at line 50 of file iap_18xx_43xx.h.

#define IAP_READ_UID_CMD 58

Read UID

Definition at line 53 of file iap_18xx_43xx.h.

#define IAP_REINVOKE_ISP_CMD 57

Reinvoke ISP

Definition at line 52 of file iap_18xx_43xx.h.

#define IAP_REPID_CMD 54

Read PartID command

Definition at line 49 of file iap_18xx_43xx.h.

#define IAP_SECTOR_NOT_BLANK 8

Sector is not blank

Definition at line 68 of file iap_18xx_43xx.h.

#define IAP_SECTOR_NOT_PREPARED 9

Command to prepare sector for write operation was not executed

Definition at line 69 of file iap_18xx_43xx.h.

#define IAP_SET_BOOT_FLASH 60

Set active boot flash bank

Definition at line 55 of file iap_18xx_43xx.h.

#define IAP_SRC_ADDR_ERROR 2

Source address is not on word boundary

Definition at line 62 of file iap_18xx_43xx.h.

#define IAP_SRC_ADDR_NOT_MAPPED 4

Source address is not mapped in the memory map

Definition at line 64 of file iap_18xx_43xx.h.

#define IAP_WRISECTOR_CMD 51

Write Sector command

Definition at line 46 of file iap_18xx_43xx.h.

## Typedef Documentation

typedef void(* IAP_ENTRY_T)(unsigned int[5], unsigned int[4])

Definition at line 82 of file iap_18xx_43xx.h.

## Function Documentation

uint8_t Chip_IAP_BlankCheckSector | ( | uint32_t | strSector,
|  | uint32_t | endSector,
|  | uint8_t | bankNum
| ) |  |

Blank check a sector or multiples sector of on-chip flash memory.

Parameters

  strSector | : Start sector number
  endSector | : End sector number
  bankNum | : Flash Bank number

Returns
  Offset of the first non blank word location if the status code is SECTOR_NOT_BLANK

Note
  The end sector must be greater than or equal to start sector number

Definition at line 95 of file iap_18xx_43xx.c.

uint8_t Chip_IAP_Compare | ( | uint32_t | dstAdd,
|  | uint32_t | srcAdd,
|  | uint32_t | bytescmp
| ) |  |

Compare the memory contents at two locations.

Parameters

  dstAdd | : Destination of the RAM address of data bytes to be compared
  srcAdd | : Source of the RAM address of data bytes to be compared
  bytescmp | : Number of bytes to be compared

Returns
  Offset of the first mismatch of the status code is COMPARE_ERROR

Note
  The addresses should be a word boundary and number of bytes should be a multiply of 4

Definition at line 128 of file iap.c.

uint8_t Chip_IAP_CopyRamToFlash | ( | uint32_t | dstAdd,
|  | uint32_t * | srcAdd,
|  | uint32_t | byteswrt
| ) |  |

Copy RAM to flash.

Parameters

  dstAdd | : Destination flash address where data bytes are to be written
  srcAdd | : Source flash address where data bytes are to be read
  byteswrt | : Number of bytes to be written

Returns
  Status code to indicate the command is executed successfully or not

Note
  The addresses should be a 256 byte boundary and the number of bytes should be 256 | 512 | 1024 | 4096

Parameters

  dstAdd | : Destination FLASH address where data bytes are to be written
  srcAdd | : Source RAM address where data bytes are to be read
  byteswrt | : Number of bytes to be written

Returns
  Status code to indicate the command is executed successfully or not

Note
  The addresses should be a 256 byte boundary and the number of bytes should be 256 | 512 | 1024 | 4096

Definition at line 64 of file iap.c.

uint8_t Chip_IAP_ErasePage | ( | uint32_t | strPage,
|  | uint32_t | endPage
| ) |  |

Erase a page or multiple papers of on-chip flash memory.

Parameters

  strPage | : Start page number
  endPage | : End page number

Returns
  Status code to indicate the command is executed successfully or not

Note
  The page number must be greater than or equal to start page number

Definition at line 168 of file iap.c.

uint8_t Chip_IAP_EraseSector | ( | uint32_t | strSector,
|  | uint32_t | endSector,
|  | uint8_t | bankNum
| ) |  |

Erase sector.

Parameters

  strSector | : Start sector number
  endSector | : End sector number
  bankNum | : Flash Bank number

Returns
  Status code to indicate the command is executed successfully or not

Note
  The end sector must be greater than or equal to start sector number

Definition at line 80 of file iap_18xx_43xx.c.

uint8_t Chip_IAP_PreSectorForReadWrite | ( | uint32_t | strSector,
|  | uint32_t | endSector,
|  | uint8_t | bankNum
| ) |  |

Prepare sector for write operation.

Parameters

  strSector | : Start sector number
  endSector | : End sector number
  bankNum | : Flash Bank number

Returns
  Status code to indicate the command is executed successfully or not

Note
  This command must be executed before executing "Copy RAM to flash" or "Erase Sector" command. The end sector must be greater than or equal to start sector number

Definition at line 51 of file iap_18xx_43xx.c.

uint8_t Chip_IAP_ReadBootCode | ( | void |  | ) |

Read boot code version number.

Returns
  Boot code version number

Definition at line 117 of file iap.c.

uint32_t Chip_IAP_ReadPID | ( | void |  | ) |

Read part identification number.

Returns
  Part identification number

Definition at line 106 of file iap.c.

uint32_t Chip_IAP_ReadUID | ( | void |  | ) |

Read the unique ID.

Returns
  Status code to indicate the command is executed successfully or not

Definition at line 156 of file iap_18xx_43xx.c.

uint8_t Chip_IAP_ReinvokeISP | ( | void |  | ) |

IAP reinvoke ISP to invoke the bootloader in ISP mode.

Returns
  none

Definition at line 142 of file iap.c.

uint8_t Chip_IAP_SetBootFlashBank | ( | uint8_t | bankNum | ) |

Set active boot flash bank.

Parameters

  bankNum | : Flash bank number

Returns
  Status code to indicate the command is executed successfully or not

Note
  Enable booting from the indicated flash unit by inserting a valid signature and invalidating the other flash unit

Definition at line 181 of file iap_18xx_43xx.c.