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