IAP support library, used to provide non-volatile storage on the C027 board.
This small library provides IAP provides support for read/write to FLASh on the LPC1768 platform. The code here is taken from:
http://developer.mbed.org/users/okano/code/IAP/
All rights remain with Tedd OKANO, etc.
IapApi.h@0:c258b7b02be5, 2015-05-22 (annotated)
- Committer:
- RobMeades
- Date:
- Fri May 22 11:41:02 2015 +0000
- Revision:
- 0:c258b7b02be5
Initial commit of IAP support (for non-volatile storate) to mbed cloud.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
RobMeades | 0:c258b7b02be5 | 1 | /** IAP provides support for read/write to FLASh on the LPC1768 platform. The code here is taken from: |
RobMeades | 0:c258b7b02be5 | 2 | * |
RobMeades | 0:c258b7b02be5 | 3 | * http://developer.mbed.org/users/okano/code/IAP/ |
RobMeades | 0:c258b7b02be5 | 4 | * |
RobMeades | 0:c258b7b02be5 | 5 | * All rights remain with Tedd OKANO, etc. |
RobMeades | 0:c258b7b02be5 | 6 | */ |
RobMeades | 0:c258b7b02be5 | 7 | |
RobMeades | 0:c258b7b02be5 | 8 | /** IAP : internal Flash memory access library |
RobMeades | 0:c258b7b02be5 | 9 | * |
RobMeades | 0:c258b7b02be5 | 10 | * The internal Flash memory access is described in the LPC1768 and LPC11U24 usermanual. |
RobMeades | 0:c258b7b02be5 | 11 | * http://www.nxp.com/documents/user_manual/UM10360.pdf |
RobMeades | 0:c258b7b02be5 | 12 | * http://www.nxp.com/documents/user_manual/UM10462.pdf |
RobMeades | 0:c258b7b02be5 | 13 | * |
RobMeades | 0:c258b7b02be5 | 14 | * LPC1768 -- |
RobMeades | 0:c258b7b02be5 | 15 | * Chapter 2: "LPC17xx Memory map" |
RobMeades | 0:c258b7b02be5 | 16 | * Chapter 32: "LPC17xx Flash memory interface and programming" |
RobMeades | 0:c258b7b02be5 | 17 | * refering Rev. 01 - 4 January 2010 |
RobMeades | 0:c258b7b02be5 | 18 | * |
RobMeades | 0:c258b7b02be5 | 19 | * LPC11U24 -- |
RobMeades | 0:c258b7b02be5 | 20 | * Chapter 2: "LPC11Uxx Memory mapping" |
RobMeades | 0:c258b7b02be5 | 21 | * Chapter 20: "LPC11Uxx Flash programming firmware" |
RobMeades | 0:c258b7b02be5 | 22 | * refering Rev. 03 - 16 July 2012 |
RobMeades | 0:c258b7b02be5 | 23 | * |
RobMeades | 0:c258b7b02be5 | 24 | * Released under the MIT License: http://mbed.org/license/mit |
RobMeades | 0:c258b7b02be5 | 25 | * |
RobMeades | 0:c258b7b02be5 | 26 | * revision 1.0 09-Mar-2010 1st release |
RobMeades | 0:c258b7b02be5 | 27 | * revision 1.1 12-Mar-2010 chaged: to make possible to reserve flash area for user |
RobMeades | 0:c258b7b02be5 | 28 | * it can be set by USER_FLASH_AREA_START and USER_FLASH_AREA_SIZE in IAP.h |
RobMeades | 0:c258b7b02be5 | 29 | * revision 2.0 26-Nov-2012 LPC11U24 code added |
RobMeades | 0:c258b7b02be5 | 30 | * revision 2.1 26-Nov-2012 EEPROM access code imported from Suga koubou san's (http://mbed.org/users/okini3939/) library |
RobMeades | 0:c258b7b02be5 | 31 | * http://mbed.org/users/okini3939/code/M0_EEPROM_test/ |
RobMeades | 0:c258b7b02be5 | 32 | * revision 3.0 09-Jan-2015 LPC812 and LPC824 support added |
RobMeades | 0:c258b7b02be5 | 33 | * revision 3.1 13-Jan-2015 LPC1114 support added |
RobMeades | 0:c258b7b02be5 | 34 | * revision 3.1.1 16-Jan-2015 Target MCU name changed for better compatibility across the platforms |
RobMeades | 0:c258b7b02be5 | 35 | */ |
RobMeades | 0:c258b7b02be5 | 36 | |
RobMeades | 0:c258b7b02be5 | 37 | |
RobMeades | 0:c258b7b02be5 | 38 | #ifndef MBED_IAP |
RobMeades | 0:c258b7b02be5 | 39 | #define MBED_IAP |
RobMeades | 0:c258b7b02be5 | 40 | |
RobMeades | 0:c258b7b02be5 | 41 | #include "mbed.h" |
RobMeades | 0:c258b7b02be5 | 42 | |
RobMeades | 0:c258b7b02be5 | 43 | #if defined(TARGET_LPC176X) |
RobMeades | 0:c258b7b02be5 | 44 | |
RobMeades | 0:c258b7b02be5 | 45 | #define FLASH_SECTOR(startAddress) (((startAddress) <= FLASH_SECTOR_15 ? \ |
RobMeades | 0:c258b7b02be5 | 46 | ((startAddress) / FLASH_SECTOR_SIZE_0_TO_15) : \ |
RobMeades | 0:c258b7b02be5 | 47 | (((startAddress) - FLASH_SECTOR_16) / FLASH_SECTOR_SIZE_16_TO_29) + 16)) |
RobMeades | 0:c258b7b02be5 | 48 | |
RobMeades | 0:c258b7b02be5 | 49 | #define USER_FLASH_AREA_START FLASH_SECTOR_29 |
RobMeades | 0:c258b7b02be5 | 50 | #define USER_FLASH_AREA_SIZE (FLASH_SECTOR_SIZE_16_TO_29 * 1) |
RobMeades | 0:c258b7b02be5 | 51 | |
RobMeades | 0:c258b7b02be5 | 52 | /* |
RobMeades | 0:c258b7b02be5 | 53 | * memory map information is available in next URL also. |
RobMeades | 0:c258b7b02be5 | 54 | * http://mbed.org/projects/libraries/svn/mbed/trunk/LPC1768/LPC17xx.h |
RobMeades | 0:c258b7b02be5 | 55 | */ |
RobMeades | 0:c258b7b02be5 | 56 | |
RobMeades | 0:c258b7b02be5 | 57 | /** Table for start adress of sectors |
RobMeades | 0:c258b7b02be5 | 58 | * |
RobMeades | 0:c258b7b02be5 | 59 | * LPC1768 internal flash memory sector numbers and addresses |
RobMeades | 0:c258b7b02be5 | 60 | * |
RobMeades | 0:c258b7b02be5 | 61 | * LPC1768 flash memory are and sector number/size |
RobMeades | 0:c258b7b02be5 | 62 | * Table 568 "Sectors in a LPC17xx device", Section 5. "Sector numbers", usermanual |
RobMeades | 0:c258b7b02be5 | 63 | * |
RobMeades | 0:c258b7b02be5 | 64 | * 0x00000000 - 0x0007FFFF flash (29 sectors) |
RobMeades | 0:c258b7b02be5 | 65 | * |
RobMeades | 0:c258b7b02be5 | 66 | * Sector0: 0x00000000 - 0x00000FFF 4K |
RobMeades | 0:c258b7b02be5 | 67 | * Sector1: 0x00001000 - 0x00001FFF 4K |
RobMeades | 0:c258b7b02be5 | 68 | * Sector2: 0x00002000 - 0x00002FFF 4K |
RobMeades | 0:c258b7b02be5 | 69 | * Sector3: 0x00003000 - 0x00003FFF 4K |
RobMeades | 0:c258b7b02be5 | 70 | * Sector4: 0x00004000 - 0x00004FFF 4K |
RobMeades | 0:c258b7b02be5 | 71 | * Sector5: 0x00005000 - 0x00005FFF 4K |
RobMeades | 0:c258b7b02be5 | 72 | * Sector6: 0x00006000 - 0x00006FFF 4K |
RobMeades | 0:c258b7b02be5 | 73 | * Sector7: 0x00007000 - 0x00007FFF 4K |
RobMeades | 0:c258b7b02be5 | 74 | * Sector8: 0x00008000 - 0x00008FFF 4K |
RobMeades | 0:c258b7b02be5 | 75 | * Sector9: 0x00009000 - 0x00009FFF 4K |
RobMeades | 0:c258b7b02be5 | 76 | * Sector10: 0x0000A000 - 0x0000AFFF 4K |
RobMeades | 0:c258b7b02be5 | 77 | * Sector11: 0x0000B000 - 0x0000BFFF 4K |
RobMeades | 0:c258b7b02be5 | 78 | * Sector12: 0x0000C000 - 0x0000CFFF 4K |
RobMeades | 0:c258b7b02be5 | 79 | * Sector13: 0x0000D000 - 0x0000DFFF 4K |
RobMeades | 0:c258b7b02be5 | 80 | * Sector14: 0x0000E000 - 0x0000EFFF 4K |
RobMeades | 0:c258b7b02be5 | 81 | * Sector15: 0x0000F000 - 0x0000FFFF 4K |
RobMeades | 0:c258b7b02be5 | 82 | * |
RobMeades | 0:c258b7b02be5 | 83 | * Sector16: 0x00010000 - 0x00017FFF 32K |
RobMeades | 0:c258b7b02be5 | 84 | * Sector17: 0x00018000 - 0x0001FFFF 32K |
RobMeades | 0:c258b7b02be5 | 85 | * Sector18: 0x00020000 - 0x00027FFF 32K |
RobMeades | 0:c258b7b02be5 | 86 | * Sector19: 0x00028000 - 0x0002FFFF 32K |
RobMeades | 0:c258b7b02be5 | 87 | * Sector20: 0x00030000 - 0x00037FFF 32K |
RobMeades | 0:c258b7b02be5 | 88 | * Sector21: 0x00038000 - 0x0003FFFF 32K |
RobMeades | 0:c258b7b02be5 | 89 | * Sector22: 0x00040000 - 0x00047FFF 32K |
RobMeades | 0:c258b7b02be5 | 90 | * Sector23: 0x00048000 - 0x0004FFFF 32K |
RobMeades | 0:c258b7b02be5 | 91 | * Sector24: 0x00050000 - 0x00057FFF 32K |
RobMeades | 0:c258b7b02be5 | 92 | * Sector25: 0x00058000 - 0x0005FFFF 32K |
RobMeades | 0:c258b7b02be5 | 93 | * Sector26: 0x00060000 - 0x00067FFF 32K |
RobMeades | 0:c258b7b02be5 | 94 | * Sector27: 0x00068000 - 0x0006FFFF 32K |
RobMeades | 0:c258b7b02be5 | 95 | * Sector28: 0x00070000 - 0x00077FFF 32K |
RobMeades | 0:c258b7b02be5 | 96 | * Sector29: 0x00078000 - 0x0007FFFF 32K |
RobMeades | 0:c258b7b02be5 | 97 | */ |
RobMeades | 0:c258b7b02be5 | 98 | |
RobMeades | 0:c258b7b02be5 | 99 | #define FLASH_SECTOR_0 0x00000000 |
RobMeades | 0:c258b7b02be5 | 100 | #define FLASH_SECTOR_1 0x00001000 |
RobMeades | 0:c258b7b02be5 | 101 | #define FLASH_SECTOR_2 0x00002000 |
RobMeades | 0:c258b7b02be5 | 102 | #define FLASH_SECTOR_3 0x00003000 |
RobMeades | 0:c258b7b02be5 | 103 | #define FLASH_SECTOR_4 0x00004000 |
RobMeades | 0:c258b7b02be5 | 104 | #define FLASH_SECTOR_5 0x00005000 |
RobMeades | 0:c258b7b02be5 | 105 | #define FLASH_SECTOR_6 0x00006000 |
RobMeades | 0:c258b7b02be5 | 106 | #define FLASH_SECTOR_7 0x00007000 |
RobMeades | 0:c258b7b02be5 | 107 | #define FLASH_SECTOR_8 0x00008000 |
RobMeades | 0:c258b7b02be5 | 108 | #define FLASH_SECTOR_9 0x00009000 |
RobMeades | 0:c258b7b02be5 | 109 | #define FLASH_SECTOR_10 0x0000A000 |
RobMeades | 0:c258b7b02be5 | 110 | #define FLASH_SECTOR_11 0x0000B000 |
RobMeades | 0:c258b7b02be5 | 111 | #define FLASH_SECTOR_12 0x0000C000 |
RobMeades | 0:c258b7b02be5 | 112 | #define FLASH_SECTOR_13 0x0000D000 |
RobMeades | 0:c258b7b02be5 | 113 | #define FLASH_SECTOR_14 0x0000E000 |
RobMeades | 0:c258b7b02be5 | 114 | #define FLASH_SECTOR_15 0x0000F000 |
RobMeades | 0:c258b7b02be5 | 115 | #define FLASH_SECTOR_16 0x00010000 |
RobMeades | 0:c258b7b02be5 | 116 | #define FLASH_SECTOR_17 0x00018000 |
RobMeades | 0:c258b7b02be5 | 117 | #define FLASH_SECTOR_18 0x00020000 |
RobMeades | 0:c258b7b02be5 | 118 | #define FLASH_SECTOR_19 0x00028000 |
RobMeades | 0:c258b7b02be5 | 119 | #define FLASH_SECTOR_20 0x00030000 |
RobMeades | 0:c258b7b02be5 | 120 | #define FLASH_SECTOR_21 0x00038000 |
RobMeades | 0:c258b7b02be5 | 121 | #define FLASH_SECTOR_22 0x00040000 |
RobMeades | 0:c258b7b02be5 | 122 | #define FLASH_SECTOR_23 0x00048000 |
RobMeades | 0:c258b7b02be5 | 123 | #define FLASH_SECTOR_24 0x00050000 |
RobMeades | 0:c258b7b02be5 | 124 | #define FLASH_SECTOR_25 0x00058000 |
RobMeades | 0:c258b7b02be5 | 125 | #define FLASH_SECTOR_26 0x00060000 |
RobMeades | 0:c258b7b02be5 | 126 | #define FLASH_SECTOR_27 0x00068000 |
RobMeades | 0:c258b7b02be5 | 127 | #define FLASH_SECTOR_28 0x00070000 |
RobMeades | 0:c258b7b02be5 | 128 | #define FLASH_SECTOR_29 0x00078000 |
RobMeades | 0:c258b7b02be5 | 129 | #define FLASH_SECTOR_SIZE_0_TO_15 ( 4 * 1024) |
RobMeades | 0:c258b7b02be5 | 130 | #define FLASH_SECTOR_SIZE_16_TO_29 (32 * 1024) |
RobMeades | 0:c258b7b02be5 | 131 | |
RobMeades | 0:c258b7b02be5 | 132 | static char * sector_start_adress[] = { |
RobMeades | 0:c258b7b02be5 | 133 | (char *)FLASH_SECTOR_0, |
RobMeades | 0:c258b7b02be5 | 134 | (char *)FLASH_SECTOR_1, |
RobMeades | 0:c258b7b02be5 | 135 | (char *)FLASH_SECTOR_2, |
RobMeades | 0:c258b7b02be5 | 136 | (char *)FLASH_SECTOR_3, |
RobMeades | 0:c258b7b02be5 | 137 | (char *)FLASH_SECTOR_4, |
RobMeades | 0:c258b7b02be5 | 138 | (char *)FLASH_SECTOR_5, |
RobMeades | 0:c258b7b02be5 | 139 | (char *)FLASH_SECTOR_6, |
RobMeades | 0:c258b7b02be5 | 140 | (char *)FLASH_SECTOR_7, |
RobMeades | 0:c258b7b02be5 | 141 | (char *)FLASH_SECTOR_8, |
RobMeades | 0:c258b7b02be5 | 142 | (char *)FLASH_SECTOR_9, |
RobMeades | 0:c258b7b02be5 | 143 | (char *)FLASH_SECTOR_10, |
RobMeades | 0:c258b7b02be5 | 144 | (char *)FLASH_SECTOR_11, |
RobMeades | 0:c258b7b02be5 | 145 | (char *)FLASH_SECTOR_12, |
RobMeades | 0:c258b7b02be5 | 146 | (char *)FLASH_SECTOR_13, |
RobMeades | 0:c258b7b02be5 | 147 | (char *)FLASH_SECTOR_14, |
RobMeades | 0:c258b7b02be5 | 148 | (char *)FLASH_SECTOR_15, |
RobMeades | 0:c258b7b02be5 | 149 | (char *)FLASH_SECTOR_16, |
RobMeades | 0:c258b7b02be5 | 150 | (char *)FLASH_SECTOR_17, |
RobMeades | 0:c258b7b02be5 | 151 | (char *)FLASH_SECTOR_18, |
RobMeades | 0:c258b7b02be5 | 152 | (char *)FLASH_SECTOR_19, |
RobMeades | 0:c258b7b02be5 | 153 | (char *)FLASH_SECTOR_20, |
RobMeades | 0:c258b7b02be5 | 154 | (char *)FLASH_SECTOR_21, |
RobMeades | 0:c258b7b02be5 | 155 | (char *)FLASH_SECTOR_22, |
RobMeades | 0:c258b7b02be5 | 156 | (char *)FLASH_SECTOR_23, |
RobMeades | 0:c258b7b02be5 | 157 | (char *)FLASH_SECTOR_24, |
RobMeades | 0:c258b7b02be5 | 158 | (char *)FLASH_SECTOR_25, |
RobMeades | 0:c258b7b02be5 | 159 | (char *)FLASH_SECTOR_26, |
RobMeades | 0:c258b7b02be5 | 160 | (char *)FLASH_SECTOR_27, |
RobMeades | 0:c258b7b02be5 | 161 | (char *)FLASH_SECTOR_28, |
RobMeades | 0:c258b7b02be5 | 162 | (char *)FLASH_SECTOR_29 |
RobMeades | 0:c258b7b02be5 | 163 | }; |
RobMeades | 0:c258b7b02be5 | 164 | |
RobMeades | 0:c258b7b02be5 | 165 | #elif defined(TARGET_LPC11UXX) || defined(TARGET_LPC11XX) |
RobMeades | 0:c258b7b02be5 | 166 | |
RobMeades | 0:c258b7b02be5 | 167 | #define USER_FLASH_AREA_START FLASH_SECTOR_7 |
RobMeades | 0:c258b7b02be5 | 168 | #define USER_FLASH_AREA_SIZE (FLASH_SECTOR_SIZE * 1) |
RobMeades | 0:c258b7b02be5 | 169 | |
RobMeades | 0:c258b7b02be5 | 170 | /** Table for start adress of sectors |
RobMeades | 0:c258b7b02be5 | 171 | * |
RobMeades | 0:c258b7b02be5 | 172 | * LPC11U24 internal flash memory sector numbers and addresses |
RobMeades | 0:c258b7b02be5 | 173 | * |
RobMeades | 0:c258b7b02be5 | 174 | * LPC11U24 flash memory are and sector number/size |
RobMeades | 0:c258b7b02be5 | 175 | * Table 334 "LPC11U1x/2x flash sectors", Section 20. "Sector numbers", usermanual |
RobMeades | 0:c258b7b02be5 | 176 | * |
RobMeades | 0:c258b7b02be5 | 177 | * 0x00000000 - 0x00007FFF flash (8 sectors) |
RobMeades | 0:c258b7b02be5 | 178 | * |
RobMeades | 0:c258b7b02be5 | 179 | * Sector0: 0x00000000 - 0x00000FFF 4K |
RobMeades | 0:c258b7b02be5 | 180 | * Sector1: 0x00001000 - 0x00001FFF 4K |
RobMeades | 0:c258b7b02be5 | 181 | * Sector2: 0x00002000 - 0x00002FFF 4K |
RobMeades | 0:c258b7b02be5 | 182 | * Sector3: 0x00003000 - 0x00003FFF 4K |
RobMeades | 0:c258b7b02be5 | 183 | * Sector4: 0x00004000 - 0x00004FFF 4K |
RobMeades | 0:c258b7b02be5 | 184 | * Sector5: 0x00005000 - 0x00005FFF 4K |
RobMeades | 0:c258b7b02be5 | 185 | * Sector6: 0x00006000 - 0x00006FFF 4K |
RobMeades | 0:c258b7b02be5 | 186 | * Sector7: 0x00007000 - 0x00007FFF 4K |
RobMeades | 0:c258b7b02be5 | 187 | */ |
RobMeades | 0:c258b7b02be5 | 188 | |
RobMeades | 0:c258b7b02be5 | 189 | #define FLASH_SECTOR_0 0x00000000 |
RobMeades | 0:c258b7b02be5 | 190 | #define FLASH_SECTOR_1 0x00001000 |
RobMeades | 0:c258b7b02be5 | 191 | #define FLASH_SECTOR_2 0x00002000 |
RobMeades | 0:c258b7b02be5 | 192 | #define FLASH_SECTOR_3 0x00003000 |
RobMeades | 0:c258b7b02be5 | 193 | #define FLASH_SECTOR_4 0x00004000 |
RobMeades | 0:c258b7b02be5 | 194 | #define FLASH_SECTOR_5 0x00005000 |
RobMeades | 0:c258b7b02be5 | 195 | #define FLASH_SECTOR_6 0x00006000 |
RobMeades | 0:c258b7b02be5 | 196 | #define FLASH_SECTOR_7 0x00007000 |
RobMeades | 0:c258b7b02be5 | 197 | #define FLASH_SECTOR_SIZE (4 * 1024) |
RobMeades | 0:c258b7b02be5 | 198 | |
RobMeades | 0:c258b7b02be5 | 199 | static char * sector_start_adress[] = { |
RobMeades | 0:c258b7b02be5 | 200 | (char *)FLASH_SECTOR_0, |
RobMeades | 0:c258b7b02be5 | 201 | (char *)FLASH_SECTOR_1, |
RobMeades | 0:c258b7b02be5 | 202 | (char *)FLASH_SECTOR_2, |
RobMeades | 0:c258b7b02be5 | 203 | (char *)FLASH_SECTOR_3, |
RobMeades | 0:c258b7b02be5 | 204 | (char *)FLASH_SECTOR_4, |
RobMeades | 0:c258b7b02be5 | 205 | (char *)FLASH_SECTOR_5, |
RobMeades | 0:c258b7b02be5 | 206 | (char *)FLASH_SECTOR_6, |
RobMeades | 0:c258b7b02be5 | 207 | (char *)FLASH_SECTOR_7, |
RobMeades | 0:c258b7b02be5 | 208 | }; |
RobMeades | 0:c258b7b02be5 | 209 | |
RobMeades | 0:c258b7b02be5 | 210 | #elif defined(TARGET_LPC81X) || defined(TARGET_LPC82X) |
RobMeades | 0:c258b7b02be5 | 211 | |
RobMeades | 0:c258b7b02be5 | 212 | #define USER_FLASH_AREA_START FLASH_SECTOR_15 |
RobMeades | 0:c258b7b02be5 | 213 | #define USER_FLASH_AREA_SIZE (FLASH_SECTOR_SIZE * 1) |
RobMeades | 0:c258b7b02be5 | 214 | |
RobMeades | 0:c258b7b02be5 | 215 | /** Table for start adress of sectors |
RobMeades | 0:c258b7b02be5 | 216 | * |
RobMeades | 0:c258b7b02be5 | 217 | * LPC812/LPC824 internal flash memory sector numbers and addresses |
RobMeades | 0:c258b7b02be5 | 218 | * |
RobMeades | 0:c258b7b02be5 | 219 | * 0x00000000 - 0x00003FFF flash (16 sectors for LPC812) |
RobMeades | 0:c258b7b02be5 | 220 | * 0x00000000 - 0x00007FFF flash (32 sectors for LPC824) |
RobMeades | 0:c258b7b02be5 | 221 | * |
RobMeades | 0:c258b7b02be5 | 222 | * Sector0: 0x00000000 - 0x000003FF 1K |
RobMeades | 0:c258b7b02be5 | 223 | * Sector1: 0x00000400 - 0x000007FF 1K |
RobMeades | 0:c258b7b02be5 | 224 | * Sector2: 0x00000800 - 0x00000BFF 1K |
RobMeades | 0:c258b7b02be5 | 225 | * Sector3: 0x00000C00 - 0x00000FFF 1K |
RobMeades | 0:c258b7b02be5 | 226 | * Sector4: 0x00001000 - 0x000013FF 1K |
RobMeades | 0:c258b7b02be5 | 227 | * Sector5: 0x00001400 - 0x000017FF 1K |
RobMeades | 0:c258b7b02be5 | 228 | * Sector6: 0x00001800 - 0x00001BFF 1K |
RobMeades | 0:c258b7b02be5 | 229 | * Sector7: 0x00001C00 - 0x00001FFF 1K |
RobMeades | 0:c258b7b02be5 | 230 | * Sector8: 0x00002000 - 0x000023FF 1K |
RobMeades | 0:c258b7b02be5 | 231 | * Sector9: 0x00002400 - 0x000027FF 1K |
RobMeades | 0:c258b7b02be5 | 232 | * Sector10: 0x00002800 - 0x00002BFF 1K |
RobMeades | 0:c258b7b02be5 | 233 | * Sector11: 0x00002C00 - 0x00002FFF 1K |
RobMeades | 0:c258b7b02be5 | 234 | * Sector12: 0x00003000 - 0x000033FF 1K |
RobMeades | 0:c258b7b02be5 | 235 | * Sector13: 0x00003400 - 0x000037FF 1K |
RobMeades | 0:c258b7b02be5 | 236 | * Sector14: 0x00003800 - 0x00003BFF 1K |
RobMeades | 0:c258b7b02be5 | 237 | * Sector15: 0x00003C00 - 0x00003FFF 1K |
RobMeades | 0:c258b7b02be5 | 238 | * Sector16: 0x00004000 - 0x000043FF 1K (LPC824 only) |
RobMeades | 0:c258b7b02be5 | 239 | * Sector17: 0x00004400 - 0x000047FF 1K (LPC824 only) |
RobMeades | 0:c258b7b02be5 | 240 | * Sector18: 0x00004800 - 0x00004BFF 1K (LPC824 only) |
RobMeades | 0:c258b7b02be5 | 241 | * Sector19: 0x00004C00 - 0x00004FFF 1K (LPC824 only) |
RobMeades | 0:c258b7b02be5 | 242 | * Sector20: 0x00005000 - 0x000053FF 1K (LPC824 only) |
RobMeades | 0:c258b7b02be5 | 243 | * Sector21: 0x00005400 - 0x000057FF 1K (LPC824 only) |
RobMeades | 0:c258b7b02be5 | 244 | * Sector22: 0x00005800 - 0x00005BFF 1K (LPC824 only) |
RobMeades | 0:c258b7b02be5 | 245 | * Sector23: 0x00005C00 - 0x00005FFF 1K (LPC824 only) |
RobMeades | 0:c258b7b02be5 | 246 | * Sector24: 0x00006000 - 0x000063FF 1K (LPC824 only) |
RobMeades | 0:c258b7b02be5 | 247 | * Sector25: 0x00006400 - 0x000067FF 1K (LPC824 only) |
RobMeades | 0:c258b7b02be5 | 248 | * Sector26: 0x00006800 - 0x00006BFF 1K (LPC824 only) |
RobMeades | 0:c258b7b02be5 | 249 | * Sector27: 0x00006C00 - 0x00006FFF 1K (LPC824 only) |
RobMeades | 0:c258b7b02be5 | 250 | * Sector28: 0x00007000 - 0x000073FF 1K (LPC824 only) |
RobMeades | 0:c258b7b02be5 | 251 | * Sector29: 0x00007400 - 0x000077FF 1K (LPC824 only) |
RobMeades | 0:c258b7b02be5 | 252 | * Sector30: 0x00007800 - 0x00007BFF 1K (LPC824 only) |
RobMeades | 0:c258b7b02be5 | 253 | * Sector31: 0x00007C00 - 0x00007FFF 1K (LPC824 only) |
RobMeades | 0:c258b7b02be5 | 254 | */ |
RobMeades | 0:c258b7b02be5 | 255 | |
RobMeades | 0:c258b7b02be5 | 256 | #define FLASH_SECTOR_0 0x00000000 |
RobMeades | 0:c258b7b02be5 | 257 | #define FLASH_SECTOR_1 0x00000400 |
RobMeades | 0:c258b7b02be5 | 258 | #define FLASH_SECTOR_2 0x00000800 |
RobMeades | 0:c258b7b02be5 | 259 | #define FLASH_SECTOR_3 0x00000C00 |
RobMeades | 0:c258b7b02be5 | 260 | #define FLASH_SECTOR_4 0x00001000 |
RobMeades | 0:c258b7b02be5 | 261 | #define FLASH_SECTOR_5 0x00001400 |
RobMeades | 0:c258b7b02be5 | 262 | #define FLASH_SECTOR_6 0x00001800 |
RobMeades | 0:c258b7b02be5 | 263 | #define FLASH_SECTOR_7 0x00001C00 |
RobMeades | 0:c258b7b02be5 | 264 | #define FLASH_SECTOR_8 0x00002000 |
RobMeades | 0:c258b7b02be5 | 265 | #define FLASH_SECTOR_9 0x00002400 |
RobMeades | 0:c258b7b02be5 | 266 | #define FLASH_SECTOR_10 0x00002800 |
RobMeades | 0:c258b7b02be5 | 267 | #define FLASH_SECTOR_11 0x00002C00 |
RobMeades | 0:c258b7b02be5 | 268 | #define FLASH_SECTOR_12 0x00003000 |
RobMeades | 0:c258b7b02be5 | 269 | #define FLASH_SECTOR_13 0x00003400 |
RobMeades | 0:c258b7b02be5 | 270 | #define FLASH_SECTOR_14 0x00003800 |
RobMeades | 0:c258b7b02be5 | 271 | #define FLASH_SECTOR_15 0x00003C00 |
RobMeades | 0:c258b7b02be5 | 272 | #define FLASH_SECTOR_16 0x00004000 // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 273 | #define FLASH_SECTOR_17 0x00004400 // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 274 | #define FLASH_SECTOR_18 0x00004800 // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 275 | #define FLASH_SECTOR_19 0x00004C00 // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 276 | #define FLASH_SECTOR_20 0x00005000 // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 277 | #define FLASH_SECTOR_21 0x00005400 // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 278 | #define FLASH_SECTOR_22 0x00005800 // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 279 | #define FLASH_SECTOR_23 0x00005C00 // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 280 | #define FLASH_SECTOR_24 0x00006000 // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 281 | #define FLASH_SECTOR_25 0x00006400 // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 282 | #define FLASH_SECTOR_26 0x00006800 // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 283 | #define FLASH_SECTOR_27 0x00006C00 // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 284 | #define FLASH_SECTOR_28 0x00007000 // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 285 | #define FLASH_SECTOR_29 0x00007400 // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 286 | #define FLASH_SECTOR_30 0x00007800 // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 287 | #define FLASH_SECTOR_31 0x00007C00 // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 288 | #define FLASH_SECTOR_SIZE (1 * 1024) |
RobMeades | 0:c258b7b02be5 | 289 | |
RobMeades | 0:c258b7b02be5 | 290 | static char * sector_start_adress[] = { |
RobMeades | 0:c258b7b02be5 | 291 | (char *)FLASH_SECTOR_0, |
RobMeades | 0:c258b7b02be5 | 292 | (char *)FLASH_SECTOR_1, |
RobMeades | 0:c258b7b02be5 | 293 | (char *)FLASH_SECTOR_2, |
RobMeades | 0:c258b7b02be5 | 294 | (char *)FLASH_SECTOR_3, |
RobMeades | 0:c258b7b02be5 | 295 | (char *)FLASH_SECTOR_4, |
RobMeades | 0:c258b7b02be5 | 296 | (char *)FLASH_SECTOR_5, |
RobMeades | 0:c258b7b02be5 | 297 | (char *)FLASH_SECTOR_6, |
RobMeades | 0:c258b7b02be5 | 298 | (char *)FLASH_SECTOR_7, |
RobMeades | 0:c258b7b02be5 | 299 | (char *)FLASH_SECTOR_8, |
RobMeades | 0:c258b7b02be5 | 300 | (char *)FLASH_SECTOR_9, |
RobMeades | 0:c258b7b02be5 | 301 | (char *)FLASH_SECTOR_10, |
RobMeades | 0:c258b7b02be5 | 302 | (char *)FLASH_SECTOR_11, |
RobMeades | 0:c258b7b02be5 | 303 | (char *)FLASH_SECTOR_12, |
RobMeades | 0:c258b7b02be5 | 304 | (char *)FLASH_SECTOR_13, |
RobMeades | 0:c258b7b02be5 | 305 | (char *)FLASH_SECTOR_14, |
RobMeades | 0:c258b7b02be5 | 306 | (char *)FLASH_SECTOR_15, |
RobMeades | 0:c258b7b02be5 | 307 | (char *)FLASH_SECTOR_16, // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 308 | (char *)FLASH_SECTOR_17, // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 309 | (char *)FLASH_SECTOR_18, // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 310 | (char *)FLASH_SECTOR_19, // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 311 | (char *)FLASH_SECTOR_20, // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 312 | (char *)FLASH_SECTOR_21, // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 313 | (char *)FLASH_SECTOR_22, // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 314 | (char *)FLASH_SECTOR_23, // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 315 | (char *)FLASH_SECTOR_24, // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 316 | (char *)FLASH_SECTOR_25, // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 317 | (char *)FLASH_SECTOR_26, // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 318 | (char *)FLASH_SECTOR_27, // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 319 | (char *)FLASH_SECTOR_28, // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 320 | (char *)FLASH_SECTOR_29, // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 321 | (char *)FLASH_SECTOR_30, // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 322 | (char *)FLASH_SECTOR_31 // for LPC824 only |
RobMeades | 0:c258b7b02be5 | 323 | }; |
RobMeades | 0:c258b7b02be5 | 324 | |
RobMeades | 0:c258b7b02be5 | 325 | #endif |
RobMeades | 0:c258b7b02be5 | 326 | |
RobMeades | 0:c258b7b02be5 | 327 | /** Error code by IAP routine |
RobMeades | 0:c258b7b02be5 | 328 | * |
RobMeades | 0:c258b7b02be5 | 329 | * Table 588 "ISP Return Codes Summary", Section 7.15 "ISP Return Codes", usermanual |
RobMeades | 0:c258b7b02be5 | 330 | */ |
RobMeades | 0:c258b7b02be5 | 331 | |
RobMeades | 0:c258b7b02be5 | 332 | enum error_code { |
RobMeades | 0:c258b7b02be5 | 333 | CMD_SUCCESS, |
RobMeades | 0:c258b7b02be5 | 334 | INVALID_COMMAND, |
RobMeades | 0:c258b7b02be5 | 335 | SRC_ADDR_ERROR, |
RobMeades | 0:c258b7b02be5 | 336 | DST_ADDR_ERROR, |
RobMeades | 0:c258b7b02be5 | 337 | SRC_ADDR_NOT_MAPPED, |
RobMeades | 0:c258b7b02be5 | 338 | DST_ADDR_NOT_MAPPED, |
RobMeades | 0:c258b7b02be5 | 339 | COUNT_ERROR, |
RobMeades | 0:c258b7b02be5 | 340 | INVALID_SECTOR, |
RobMeades | 0:c258b7b02be5 | 341 | SECTOR_NOT_BLANK, |
RobMeades | 0:c258b7b02be5 | 342 | SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION, |
RobMeades | 0:c258b7b02be5 | 343 | COMPARE_ERROR, |
RobMeades | 0:c258b7b02be5 | 344 | BUSY, |
RobMeades | 0:c258b7b02be5 | 345 | PARAM_ERROR, |
RobMeades | 0:c258b7b02be5 | 346 | ADDR_ERROR, |
RobMeades | 0:c258b7b02be5 | 347 | ADDR_NOT_MAPPED, |
RobMeades | 0:c258b7b02be5 | 348 | CMD_LOCKED, |
RobMeades | 0:c258b7b02be5 | 349 | INVALID_CODE, |
RobMeades | 0:c258b7b02be5 | 350 | INVALID_BAUD_RATE, |
RobMeades | 0:c258b7b02be5 | 351 | INVALID_STOP_BIT, |
RobMeades | 0:c258b7b02be5 | 352 | CODE_READ_PROTECTION_ENABLED |
RobMeades | 0:c258b7b02be5 | 353 | }; |
RobMeades | 0:c258b7b02be5 | 354 | |
RobMeades | 0:c258b7b02be5 | 355 | |
RobMeades | 0:c258b7b02be5 | 356 | |
RobMeades | 0:c258b7b02be5 | 357 | /* |
RobMeades | 0:c258b7b02be5 | 358 | * IAP routine entry |
RobMeades | 0:c258b7b02be5 | 359 | * |
RobMeades | 0:c258b7b02be5 | 360 | * "IAP commands" |
RobMeades | 0:c258b7b02be5 | 361 | */ |
RobMeades | 0:c258b7b02be5 | 362 | |
RobMeades | 0:c258b7b02be5 | 363 | #define IAP_LOCATION 0x1fff1ff1 |
RobMeades | 0:c258b7b02be5 | 364 | typedef void (*IAP_call)(unsigned int [], unsigned int []); |
RobMeades | 0:c258b7b02be5 | 365 | |
RobMeades | 0:c258b7b02be5 | 366 | |
RobMeades | 0:c258b7b02be5 | 367 | /** IAP class |
RobMeades | 0:c258b7b02be5 | 368 | * |
RobMeades | 0:c258b7b02be5 | 369 | * Interface for internal flash memory access |
RobMeades | 0:c258b7b02be5 | 370 | */ |
RobMeades | 0:c258b7b02be5 | 371 | |
RobMeades | 0:c258b7b02be5 | 372 | class IAP |
RobMeades | 0:c258b7b02be5 | 373 | { |
RobMeades | 0:c258b7b02be5 | 374 | public: |
RobMeades | 0:c258b7b02be5 | 375 | |
RobMeades | 0:c258b7b02be5 | 376 | /** Constructor for IAP |
RobMeades | 0:c258b7b02be5 | 377 | * |
RobMeades | 0:c258b7b02be5 | 378 | */ |
RobMeades | 0:c258b7b02be5 | 379 | IAP() : iap_entry( reinterpret_cast<IAP_call>(IAP_LOCATION) ), cclk_kHz( SystemCoreClock / 1000 ) {} |
RobMeades | 0:c258b7b02be5 | 380 | |
RobMeades | 0:c258b7b02be5 | 381 | /** Read part identification number |
RobMeades | 0:c258b7b02be5 | 382 | * |
RobMeades | 0:c258b7b02be5 | 383 | * @return device ID |
RobMeades | 0:c258b7b02be5 | 384 | * @see read_serial() |
RobMeades | 0:c258b7b02be5 | 385 | */ |
RobMeades | 0:c258b7b02be5 | 386 | int read_ID( void ); |
RobMeades | 0:c258b7b02be5 | 387 | |
RobMeades | 0:c258b7b02be5 | 388 | /** Read device serial number |
RobMeades | 0:c258b7b02be5 | 389 | * |
RobMeades | 0:c258b7b02be5 | 390 | * @return device serial number |
RobMeades | 0:c258b7b02be5 | 391 | * @see read_ID() |
RobMeades | 0:c258b7b02be5 | 392 | */ |
RobMeades | 0:c258b7b02be5 | 393 | int read_serial( void ); |
RobMeades | 0:c258b7b02be5 | 394 | |
RobMeades | 0:c258b7b02be5 | 395 | /** Blank check sector(s) |
RobMeades | 0:c258b7b02be5 | 396 | * |
RobMeades | 0:c258b7b02be5 | 397 | * @param start a Start Sector Number |
RobMeades | 0:c258b7b02be5 | 398 | * @param end an End Sector Number (should be greater than or equal to start sector number). |
RobMeades | 0:c258b7b02be5 | 399 | * @return error code: CMD_SUCCESS | BUSY | SECTOR_NOT_BLANK | INVALID_SECTOR |
RobMeades | 0:c258b7b02be5 | 400 | */ |
RobMeades | 0:c258b7b02be5 | 401 | int blank_check( int start, int end ); |
RobMeades | 0:c258b7b02be5 | 402 | |
RobMeades | 0:c258b7b02be5 | 403 | /** Erase Sector(s) |
RobMeades | 0:c258b7b02be5 | 404 | * |
RobMeades | 0:c258b7b02be5 | 405 | * @param start a Start Sector Number |
RobMeades | 0:c258b7b02be5 | 406 | * @param end an End Sector Number (should be greater than or equal to start sector number). |
RobMeades | 0:c258b7b02be5 | 407 | * @return error code: CMD_SUCCESS | BUSY | SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION | INVALID_SECTOR |
RobMeades | 0:c258b7b02be5 | 408 | */ |
RobMeades | 0:c258b7b02be5 | 409 | int erase( int start, int end ); |
RobMeades | 0:c258b7b02be5 | 410 | |
RobMeades | 0:c258b7b02be5 | 411 | /** Prepare sector(s) for write operation |
RobMeades | 0:c258b7b02be5 | 412 | * |
RobMeades | 0:c258b7b02be5 | 413 | * @param start a Start Sector Number |
RobMeades | 0:c258b7b02be5 | 414 | * @param end an End Sector Number (should be greater than or equal to start sector number). |
RobMeades | 0:c258b7b02be5 | 415 | * @return error code: CMD_SUCCESS | BUSY | INVALID_SECTOR |
RobMeades | 0:c258b7b02be5 | 416 | */ |
RobMeades | 0:c258b7b02be5 | 417 | int prepare( int start, int end ); |
RobMeades | 0:c258b7b02be5 | 418 | |
RobMeades | 0:c258b7b02be5 | 419 | /** Copy RAM to Flash |
RobMeades | 0:c258b7b02be5 | 420 | * |
RobMeades | 0:c258b7b02be5 | 421 | * @param source_addr Source RAM address from which data bytes are to be read. This address should be a word boundary. |
RobMeades | 0:c258b7b02be5 | 422 | * @param target_addr Destination flash address where data bytes are to be written. This address should be a 256 byte boundary. |
RobMeades | 0:c258b7b02be5 | 423 | * @param size Number of bytes to be written. Should be 256 | 512 | 1024 | 4096. |
RobMeades | 0:c258b7b02be5 | 424 | * @return error code: CMD_SUCCESS | SRC_ADDR_ERROR (Address not a word boundary) | DST_ADDR_ERROR (Address not on correct boundary) | SRC_ADDR_NOT_MAPPED | DST_ADDR_NOT_MAPPED | COUNT_ERROR (Byte count is not 256 | 512 | 1024 | 4096) | SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION | BUSY |
RobMeades | 0:c258b7b02be5 | 425 | */ |
RobMeades | 0:c258b7b02be5 | 426 | int write( char *source_addr, char *target_addr, int size ); |
RobMeades | 0:c258b7b02be5 | 427 | |
RobMeades | 0:c258b7b02be5 | 428 | /** Compare <address1> <address2> <no of bytes> |
RobMeades | 0:c258b7b02be5 | 429 | * |
RobMeades | 0:c258b7b02be5 | 430 | * @param source_addr Starting flash or RAM address of data bytes to be compared. This address should be a word boundary. |
RobMeades | 0:c258b7b02be5 | 431 | * @param target_addr Starting flash or RAM address of data bytes to be compared. This address should be a word boundary. |
RobMeades | 0:c258b7b02be5 | 432 | * @param size Number of bytes to be compared; should be a multiple of 4. |
RobMeades | 0:c258b7b02be5 | 433 | * @return error code: CMD_SUCCESS | COMPARE_ERROR | COUNT_ERROR (Byte count is not a multiple of 4) | ADDR_ERROR | ADDR_NOT_MAPPED |
RobMeades | 0:c258b7b02be5 | 434 | */ |
RobMeades | 0:c258b7b02be5 | 435 | int compare( char *source_addr, char *target_addr, int size ); |
RobMeades | 0:c258b7b02be5 | 436 | |
RobMeades | 0:c258b7b02be5 | 437 | /** Read Boot code version number |
RobMeades | 0:c258b7b02be5 | 438 | * |
RobMeades | 0:c258b7b02be5 | 439 | * @return 2 bytes of boot code version number |
RobMeades | 0:c258b7b02be5 | 440 | */ |
RobMeades | 0:c258b7b02be5 | 441 | int read_BootVer( void ); |
RobMeades | 0:c258b7b02be5 | 442 | |
RobMeades | 0:c258b7b02be5 | 443 | /** Get user reserved flash start address |
RobMeades | 0:c258b7b02be5 | 444 | * |
RobMeades | 0:c258b7b02be5 | 445 | * @return start address of user reserved flash memory |
RobMeades | 0:c258b7b02be5 | 446 | * @see reserved_flash_area_size() |
RobMeades | 0:c258b7b02be5 | 447 | */ |
RobMeades | 0:c258b7b02be5 | 448 | |
RobMeades | 0:c258b7b02be5 | 449 | char *reserved_flash_area_start( void ); |
RobMeades | 0:c258b7b02be5 | 450 | |
RobMeades | 0:c258b7b02be5 | 451 | /** Get user reserved flash size |
RobMeades | 0:c258b7b02be5 | 452 | * |
RobMeades | 0:c258b7b02be5 | 453 | * @return size of user reserved flash memory |
RobMeades | 0:c258b7b02be5 | 454 | * @see reserved_flash_area_start() |
RobMeades | 0:c258b7b02be5 | 455 | */ |
RobMeades | 0:c258b7b02be5 | 456 | int reserved_flash_area_size( void ); |
RobMeades | 0:c258b7b02be5 | 457 | |
RobMeades | 0:c258b7b02be5 | 458 | #if defined(TARGET_LPC11UXX) |
RobMeades | 0:c258b7b02be5 | 459 | |
RobMeades | 0:c258b7b02be5 | 460 | /** Copy RAM to EEPROM (LPC11U24) |
RobMeades | 0:c258b7b02be5 | 461 | * |
RobMeades | 0:c258b7b02be5 | 462 | * @param source_addr Source RAM address from which data bytes are to be read. |
RobMeades | 0:c258b7b02be5 | 463 | * @param target_addr Destination EEPROM address where data bytes are to be written. |
RobMeades | 0:c258b7b02be5 | 464 | * @param size Number of bytes to be written. |
RobMeades | 0:c258b7b02be5 | 465 | * @return error code: CMD_SUCCESS | SRC_ADDR_NOT_MAPPED | DST_ADDR_NOT_MAPPED |
RobMeades | 0:c258b7b02be5 | 466 | * Remark: The top 64 bytes of the EEPROM memory are reserved and cannot be written to. |
RobMeades | 0:c258b7b02be5 | 467 | */ |
RobMeades | 0:c258b7b02be5 | 468 | int write_eeprom( char *source_addr, char *target_addr, int size ); |
RobMeades | 0:c258b7b02be5 | 469 | |
RobMeades | 0:c258b7b02be5 | 470 | /** Copy EEPROM to RAM (LPC11U24) |
RobMeades | 0:c258b7b02be5 | 471 | * |
RobMeades | 0:c258b7b02be5 | 472 | * @param source_addr Source EEPROM address from which data bytes are to be read. |
RobMeades | 0:c258b7b02be5 | 473 | * @param target_addr Destination RAM address where data bytes are to be written. |
RobMeades | 0:c258b7b02be5 | 474 | * @param size Number of bytes to be written. |
RobMeades | 0:c258b7b02be5 | 475 | * @return error code: CMD_SUCCESS | SRC_ADDR_NOT_MAPPED | DST_ADDR_NOT_MAPPED |
RobMeades | 0:c258b7b02be5 | 476 | * Remark: The top 64 bytes of the EEPROM memory are reserved and cannot be written to. |
RobMeades | 0:c258b7b02be5 | 477 | */ |
RobMeades | 0:c258b7b02be5 | 478 | int read_eeprom( char *source_addr, char *target_addr, int size ); |
RobMeades | 0:c258b7b02be5 | 479 | |
RobMeades | 0:c258b7b02be5 | 480 | #elif defined(TARGET_LPC81X) || defined(TARGET_LPC82X) |
RobMeades | 0:c258b7b02be5 | 481 | |
RobMeades | 0:c258b7b02be5 | 482 | /** Erase page(s) (LPC812, LPC824) |
RobMeades | 0:c258b7b02be5 | 483 | * |
RobMeades | 0:c258b7b02be5 | 484 | * @param start Start page number. |
RobMeades | 0:c258b7b02be5 | 485 | * @param end End page number (should be greater than or equal to start page). |
RobMeades | 0:c258b7b02be5 | 486 | * @return error code: CMD_SUCCESS | BUSY | SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION | INVALID_SECTOR |
RobMeades | 0:c258b7b02be5 | 487 | */ |
RobMeades | 0:c258b7b02be5 | 488 | int erase_page( int start, int end ); |
RobMeades | 0:c258b7b02be5 | 489 | |
RobMeades | 0:c258b7b02be5 | 490 | #endif |
RobMeades | 0:c258b7b02be5 | 491 | |
RobMeades | 0:c258b7b02be5 | 492 | private: |
RobMeades | 0:c258b7b02be5 | 493 | IAP_call iap_entry; |
RobMeades | 0:c258b7b02be5 | 494 | unsigned int IAP_command[ 5 ]; |
RobMeades | 0:c258b7b02be5 | 495 | unsigned int IAP_result[ 5 ]; |
RobMeades | 0:c258b7b02be5 | 496 | int cclk_kHz; |
RobMeades | 0:c258b7b02be5 | 497 | } |
RobMeades | 0:c258b7b02be5 | 498 | ; |
RobMeades | 0:c258b7b02be5 | 499 | |
RobMeades | 0:c258b7b02be5 | 500 | #endif // #ifndef MBED_IAP |