SPI Library for 240x320 TFT LCD with ILI9320, ILI9325 and ILI9328 chip
Dependents: KL25Z_ILI9320_Demo Mini-DK
Other LCD drivers
05-30-2014
Device initialization for ILI9325 and ILI9328 has been added to the library.
The library will auto-detect what driver chip is connected (ILI9320, ILI9325 or ILI9328) and use the appropriate init sequence.
Please use the Issues tab to report any problems.
SPI TFT library for LPC1768, LPC11U24 and KL25Z
Loading fonts
When using this libary, don't forget to load the TFT_FONTS library from Peter Drescher at http://mbed.org/users/dreschpe/code/TFT_fonts/
KL25Z : limitations
The filetoflash function (see below) is not available.
Writing to the LCD is a little slower as the KL25Z only supports 8-bit SPI communication.
LPC1768 and LPC11U24 : filetoflash (SD to CPU flash)
This library contains a function to copy an image from the SD card to the CPU flash memory.
It allows you to use an image as background without speed loss when writing other text and graphics.
By default, this option is enabled.
It can be disabled by adding following instruction BEFORE you load the library:
#define NO_FLASH_BUFFER
Since the flash memory has limited write endurance, DO NOT use this feature when you intend to read multiple images from the SD card (eg: when used as a photo frame).
Sample code
#include "mbed.h" // SPI TFT demo // NOTES // - Connect the LCD reset pin to the reset pin of the CPU board or connect a // separate reset circuit to the LCD reset pin (pull-up 10k to 3v3 + 100nf capacitor to GND). // - When using the mbed LPC1768 board, following hardware modifications are needed: // Connect the LCD reset pin to the nR input. // Connect a 100nF capacitor between the nR input and GND. // Connect a pushbutton parallel to the 100nF capacitor. // Use the new pushbutton as the reset button (instead of the LPC1768 on-board reset button). #define NO_FLASH_BUFFER // Do not use CPU flash for storing bitmaps #include "SPI_TFT_ILI9320.h" #include "Arial12x12.h" #include "Arial24x23.h" #include "Arial28x28.h" #include "font_big.h" SPI_TFT TFT(p11, p12, p13, p14,"TFT"); //mosi, miso, clk, cs int main (void) { TFT.claim(stdout); // send stdout to the TFT display // Disable stdout buffering, allows us to omit \n with printf. // More info at http://www.cplusplus.com/reference/cstdio/setvbuf/ setvbuf ( stdout , NULL , _IONBF , NULL ); TFT.background(Black); // set background to black TFT.foreground(White); // set chars to white TFT.cls(); // clear the screen TFT.set_font((unsigned char*) Arial12x12); // select the font TFT.locate(0,0); printf("ILI9320 SPI TFT library\n"); printf("Simple demo\n"); }
Demo code LPC1768 (Mini-DK board)
Import programLPC1768_Mini-DK
LPC1768 Mini-DK board with 2.8" SPI TFT and SPI touch
Demo code FRDM-KL25Z board
Import programKL25Z_ILI9320_Demo
KL25Z driving an ILI9320 LCD board with touch panel (HY28A-LCDB SPI)
IAP/IAP.h@3:a016fe71ed72, 2014-03-18 (annotated)
- Committer:
- frankvnk
- Date:
- Tue Mar 18 18:59:54 2014 +0000
- Revision:
- 3:a016fe71ed72
- Parent:
- 0:630b4da97968
Added KL25Z
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
frankvnk | 0:630b4da97968 | 1 | /** IAP : internal Flash memory access library |
frankvnk | 0:630b4da97968 | 2 | * |
frankvnk | 0:630b4da97968 | 3 | * The internal Flash memory access is described in the LPC1768 and LPC11U24 usermanual. |
frankvnk | 0:630b4da97968 | 4 | * http://www.nxp.com/documents/user_manual/UM10360.pdf |
frankvnk | 0:630b4da97968 | 5 | * http://www.nxp.com/documents/user_manual/UM10462.pdf |
frankvnk | 0:630b4da97968 | 6 | * |
frankvnk | 0:630b4da97968 | 7 | * LPC1768 -- |
frankvnk | 0:630b4da97968 | 8 | * Chapter 2: "LPC17xx Memory map" |
frankvnk | 0:630b4da97968 | 9 | * Chapter 32: "LPC17xx Flash memory interface and programming" |
frankvnk | 0:630b4da97968 | 10 | * refering Rev. 01 - 4 January 2010 |
frankvnk | 0:630b4da97968 | 11 | * |
frankvnk | 0:630b4da97968 | 12 | * LPC11U24 -- |
frankvnk | 0:630b4da97968 | 13 | * Chapter 2: "LPC11Uxx Memory mapping" |
frankvnk | 0:630b4da97968 | 14 | * Chapter 20: "LPC11Uxx Flash programming firmware" |
frankvnk | 0:630b4da97968 | 15 | * refering Rev. 03 - 16 July 2012 |
frankvnk | 0:630b4da97968 | 16 | * |
frankvnk | 0:630b4da97968 | 17 | * Released under the MIT License: http://mbed.org/license/mit |
frankvnk | 0:630b4da97968 | 18 | * |
frankvnk | 0:630b4da97968 | 19 | * revision 1.0 09-Mar-2010 1st release |
frankvnk | 0:630b4da97968 | 20 | * revision 1.1 12-Mar-2010 chaged: to make possible to reserve flash area for user |
frankvnk | 0:630b4da97968 | 21 | * it can be set by USER_FLASH_AREA_START and USER_FLASH_AREA_SIZE in IAP.h |
frankvnk | 0:630b4da97968 | 22 | * revision 2.0 26-Nov.2012 LPC11U24 code added |
frankvnk | 0:630b4da97968 | 23 | * revision 2.1 26-Nov-2012 EEPROM access code imported from Suga koubou san's (http://mbed.org/users/okini3939/) library |
frankvnk | 0:630b4da97968 | 24 | * http://mbed.org/users/okini3939/code/M0_EEPROM_test/ |
frankvnk | 0:630b4da97968 | 25 | */ |
frankvnk | 3:a016fe71ed72 | 26 | #if defined(TARGET_LPC11U24) || defined(TARGET_LPC1768) |
frankvnk | 0:630b4da97968 | 27 | |
frankvnk | 0:630b4da97968 | 28 | #ifndef MBED_IAP |
frankvnk | 0:630b4da97968 | 29 | #define MBED_IAP |
frankvnk | 0:630b4da97968 | 30 | |
frankvnk | 0:630b4da97968 | 31 | #include "mbed.h" |
frankvnk | 0:630b4da97968 | 32 | |
frankvnk | 0:630b4da97968 | 33 | #if defined(TARGET_LPC1768) |
frankvnk | 0:630b4da97968 | 34 | |
frankvnk | 0:630b4da97968 | 35 | #define USER_FLASH_AREA_START FLASH_SECTOR_25 |
frankvnk | 0:630b4da97968 | 36 | #define USER_FLASH_AREA_SIZE (FLASH_SECTOR_SIZE_16_TO_29 * 5) |
frankvnk | 0:630b4da97968 | 37 | |
frankvnk | 0:630b4da97968 | 38 | /* |
frankvnk | 0:630b4da97968 | 39 | * memory map information is available in next URL also. |
frankvnk | 0:630b4da97968 | 40 | * http://mbed.org/projects/libraries/svn/mbed/trunk/LPC1768/LPC17xx.h |
frankvnk | 0:630b4da97968 | 41 | */ |
frankvnk | 0:630b4da97968 | 42 | |
frankvnk | 0:630b4da97968 | 43 | /** Table for start adress of sectors |
frankvnk | 0:630b4da97968 | 44 | * |
frankvnk | 0:630b4da97968 | 45 | * LPC1768 internal flash memory sector numbers and addresses |
frankvnk | 0:630b4da97968 | 46 | * |
frankvnk | 0:630b4da97968 | 47 | * LPC1768 flash memory are and sector number/size |
frankvnk | 0:630b4da97968 | 48 | * Table 568 "Sectors in a LPC17xx device", Section 5. "Sector numbers", usermanual |
frankvnk | 0:630b4da97968 | 49 | * |
frankvnk | 0:630b4da97968 | 50 | * 0x00000000 - 0x0007FFFF flash (29 sectors) |
frankvnk | 0:630b4da97968 | 51 | * |
frankvnk | 0:630b4da97968 | 52 | * Sector0: 0x00000000 - 0x00000FFF 4K |
frankvnk | 0:630b4da97968 | 53 | * Sector1: 0x00001000 - 0x00001FFF 4K |
frankvnk | 0:630b4da97968 | 54 | * Sector2: 0x00002000 - 0x00002FFF 4K |
frankvnk | 0:630b4da97968 | 55 | * Sector3: 0x00003000 - 0x00003FFF 4K |
frankvnk | 0:630b4da97968 | 56 | * Sector4: 0x00004000 - 0x00004FFF 4K |
frankvnk | 0:630b4da97968 | 57 | * Sector5: 0x00005000 - 0x00005FFF 4K |
frankvnk | 0:630b4da97968 | 58 | * Sector6: 0x00006000 - 0x00006FFF 4K |
frankvnk | 0:630b4da97968 | 59 | * Sector7: 0x00007000 - 0x00007FFF 4K |
frankvnk | 0:630b4da97968 | 60 | * Sector8: 0x00008000 - 0x00008FFF 4K |
frankvnk | 0:630b4da97968 | 61 | * Sector9: 0x00009000 - 0x00009FFF 4K |
frankvnk | 0:630b4da97968 | 62 | * Sector10: 0x0000A000 - 0x0000AFFF 4K |
frankvnk | 0:630b4da97968 | 63 | * Sector11: 0x0000B000 - 0x0000BFFF 4K |
frankvnk | 0:630b4da97968 | 64 | * Sector12: 0x0000C000 - 0x0000CFFF 4K |
frankvnk | 0:630b4da97968 | 65 | * Sector13: 0x0000D000 - 0x0000DFFF 4K |
frankvnk | 0:630b4da97968 | 66 | * Sector14: 0x0000E000 - 0x0000EFFF 4K |
frankvnk | 0:630b4da97968 | 67 | * Sector15: 0x0000F000 - 0x0000FFFF 4K |
frankvnk | 0:630b4da97968 | 68 | * |
frankvnk | 0:630b4da97968 | 69 | * Sector16: 0x00010000 - 0x00017FFF 32K |
frankvnk | 0:630b4da97968 | 70 | * Sector17: 0x00018000 - 0x0001FFFF 32K |
frankvnk | 0:630b4da97968 | 71 | * Sector18: 0x00020000 - 0x00027FFF 32K |
frankvnk | 0:630b4da97968 | 72 | * Sector19: 0x00028000 - 0x0002FFFF 32K |
frankvnk | 0:630b4da97968 | 73 | * Sector20: 0x00030000 - 0x00037FFF 32K |
frankvnk | 0:630b4da97968 | 74 | * Sector21: 0x00038000 - 0x0003FFFF 32K |
frankvnk | 0:630b4da97968 | 75 | * Sector22: 0x00040000 - 0x00047FFF 32K |
frankvnk | 0:630b4da97968 | 76 | * Sector23: 0x00048000 - 0x0004FFFF 32K |
frankvnk | 0:630b4da97968 | 77 | * Sector24: 0x00050000 - 0x00057FFF 32K |
frankvnk | 0:630b4da97968 | 78 | * Sector25: 0x00058000 - 0x0005FFFF 32K |
frankvnk | 0:630b4da97968 | 79 | * Sector26: 0x00060000 - 0x00067FFF 32K |
frankvnk | 0:630b4da97968 | 80 | * Sector27: 0x00068000 - 0x0006FFFF 32K |
frankvnk | 0:630b4da97968 | 81 | * Sector28: 0x00070000 - 0x00077FFF 32K |
frankvnk | 0:630b4da97968 | 82 | * Sector29: 0x00078000 - 0x0007FFFF 32K |
frankvnk | 0:630b4da97968 | 83 | */ |
frankvnk | 0:630b4da97968 | 84 | |
frankvnk | 0:630b4da97968 | 85 | #define FLASH_SECTOR_0 0x00000000 |
frankvnk | 0:630b4da97968 | 86 | #define FLASH_SECTOR_1 0x00001000 |
frankvnk | 0:630b4da97968 | 87 | #define FLASH_SECTOR_2 0x00002000 |
frankvnk | 0:630b4da97968 | 88 | #define FLASH_SECTOR_3 0x00003000 |
frankvnk | 0:630b4da97968 | 89 | #define FLASH_SECTOR_4 0x00004000 |
frankvnk | 0:630b4da97968 | 90 | #define FLASH_SECTOR_5 0x00005000 |
frankvnk | 0:630b4da97968 | 91 | #define FLASH_SECTOR_6 0x00006000 |
frankvnk | 0:630b4da97968 | 92 | #define FLASH_SECTOR_7 0x00007000 |
frankvnk | 0:630b4da97968 | 93 | #define FLASH_SECTOR_8 0x00008000 |
frankvnk | 0:630b4da97968 | 94 | #define FLASH_SECTOR_9 0x00009000 |
frankvnk | 0:630b4da97968 | 95 | #define FLASH_SECTOR_10 0x0000A000 |
frankvnk | 0:630b4da97968 | 96 | #define FLASH_SECTOR_11 0x0000B000 |
frankvnk | 0:630b4da97968 | 97 | #define FLASH_SECTOR_12 0x0000C000 |
frankvnk | 0:630b4da97968 | 98 | #define FLASH_SECTOR_13 0x0000D000 |
frankvnk | 0:630b4da97968 | 99 | #define FLASH_SECTOR_14 0x0000E000 |
frankvnk | 0:630b4da97968 | 100 | #define FLASH_SECTOR_15 0x0000F000 |
frankvnk | 0:630b4da97968 | 101 | #define FLASH_SECTOR_16 0x00010000 |
frankvnk | 0:630b4da97968 | 102 | #define FLASH_SECTOR_17 0x00018000 |
frankvnk | 0:630b4da97968 | 103 | #define FLASH_SECTOR_18 0x00020000 |
frankvnk | 0:630b4da97968 | 104 | #define FLASH_SECTOR_19 0x00028000 |
frankvnk | 0:630b4da97968 | 105 | #define FLASH_SECTOR_20 0x00030000 |
frankvnk | 0:630b4da97968 | 106 | #define FLASH_SECTOR_21 0x00038000 |
frankvnk | 0:630b4da97968 | 107 | #define FLASH_SECTOR_22 0x00040000 |
frankvnk | 0:630b4da97968 | 108 | #define FLASH_SECTOR_23 0x00048000 |
frankvnk | 0:630b4da97968 | 109 | #define FLASH_SECTOR_24 0x00050000 |
frankvnk | 0:630b4da97968 | 110 | #define FLASH_SECTOR_25 0x00058000 |
frankvnk | 0:630b4da97968 | 111 | #define FLASH_SECTOR_26 0x00060000 |
frankvnk | 0:630b4da97968 | 112 | #define FLASH_SECTOR_27 0x00068000 |
frankvnk | 0:630b4da97968 | 113 | #define FLASH_SECTOR_28 0x00070000 |
frankvnk | 0:630b4da97968 | 114 | #define FLASH_SECTOR_29 0x00078000 |
frankvnk | 0:630b4da97968 | 115 | #define FLASH_SECTOR_SIZE_0_TO_15 ( 4 * 1024) |
frankvnk | 0:630b4da97968 | 116 | #define FLASH_SECTOR_SIZE_16_TO_29 (32 * 1024) |
frankvnk | 0:630b4da97968 | 117 | |
frankvnk | 0:630b4da97968 | 118 | static char * sector_start_adress[] = { |
frankvnk | 0:630b4da97968 | 119 | (char *)FLASH_SECTOR_0, |
frankvnk | 0:630b4da97968 | 120 | (char *)FLASH_SECTOR_1, |
frankvnk | 0:630b4da97968 | 121 | (char *)FLASH_SECTOR_2, |
frankvnk | 0:630b4da97968 | 122 | (char *)FLASH_SECTOR_3, |
frankvnk | 0:630b4da97968 | 123 | (char *)FLASH_SECTOR_4, |
frankvnk | 0:630b4da97968 | 124 | (char *)FLASH_SECTOR_5, |
frankvnk | 0:630b4da97968 | 125 | (char *)FLASH_SECTOR_6, |
frankvnk | 0:630b4da97968 | 126 | (char *)FLASH_SECTOR_7, |
frankvnk | 0:630b4da97968 | 127 | (char *)FLASH_SECTOR_8, |
frankvnk | 0:630b4da97968 | 128 | (char *)FLASH_SECTOR_9, |
frankvnk | 0:630b4da97968 | 129 | (char *)FLASH_SECTOR_10, |
frankvnk | 0:630b4da97968 | 130 | (char *)FLASH_SECTOR_11, |
frankvnk | 0:630b4da97968 | 131 | (char *)FLASH_SECTOR_12, |
frankvnk | 0:630b4da97968 | 132 | (char *)FLASH_SECTOR_13, |
frankvnk | 0:630b4da97968 | 133 | (char *)FLASH_SECTOR_14, |
frankvnk | 0:630b4da97968 | 134 | (char *)FLASH_SECTOR_15, |
frankvnk | 0:630b4da97968 | 135 | (char *)FLASH_SECTOR_16, |
frankvnk | 0:630b4da97968 | 136 | (char *)FLASH_SECTOR_17, |
frankvnk | 0:630b4da97968 | 137 | (char *)FLASH_SECTOR_18, |
frankvnk | 0:630b4da97968 | 138 | (char *)FLASH_SECTOR_19, |
frankvnk | 0:630b4da97968 | 139 | (char *)FLASH_SECTOR_20, |
frankvnk | 0:630b4da97968 | 140 | (char *)FLASH_SECTOR_21, |
frankvnk | 0:630b4da97968 | 141 | (char *)FLASH_SECTOR_22, |
frankvnk | 0:630b4da97968 | 142 | (char *)FLASH_SECTOR_23, |
frankvnk | 0:630b4da97968 | 143 | (char *)FLASH_SECTOR_24, |
frankvnk | 0:630b4da97968 | 144 | (char *)FLASH_SECTOR_25, |
frankvnk | 0:630b4da97968 | 145 | (char *)FLASH_SECTOR_26, |
frankvnk | 0:630b4da97968 | 146 | (char *)FLASH_SECTOR_27, |
frankvnk | 0:630b4da97968 | 147 | (char *)FLASH_SECTOR_28, |
frankvnk | 0:630b4da97968 | 148 | (char *)FLASH_SECTOR_29 |
frankvnk | 0:630b4da97968 | 149 | }; |
frankvnk | 0:630b4da97968 | 150 | |
frankvnk | 0:630b4da97968 | 151 | #elif defined(TARGET_LPC11U24) |
frankvnk | 0:630b4da97968 | 152 | |
frankvnk | 0:630b4da97968 | 153 | #define USER_FLASH_AREA_START FLASH_SECTOR_7 |
frankvnk | 0:630b4da97968 | 154 | #define USER_FLASH_AREA_SIZE (FLASH_SECTOR_SIZE * 1) |
frankvnk | 0:630b4da97968 | 155 | |
frankvnk | 0:630b4da97968 | 156 | /** Table for start adress of sectors |
frankvnk | 0:630b4da97968 | 157 | * |
frankvnk | 0:630b4da97968 | 158 | * LPC11U24 internal flash memory sector numbers and addresses |
frankvnk | 0:630b4da97968 | 159 | * |
frankvnk | 0:630b4da97968 | 160 | * LPC11U24 flash memory are and sector number/size |
frankvnk | 0:630b4da97968 | 161 | * Table 334 "LPC11U1x/2x flash sectors", Section 20. "Sector numbers", usermanual |
frankvnk | 0:630b4da97968 | 162 | * |
frankvnk | 0:630b4da97968 | 163 | * 0x00000000 - 0x00007FFF flash (8 sectors) |
frankvnk | 0:630b4da97968 | 164 | * |
frankvnk | 0:630b4da97968 | 165 | * Sector0: 0x00000000 - 0x00000FFF 4K |
frankvnk | 0:630b4da97968 | 166 | * Sector1: 0x00001000 - 0x00001FFF 4K |
frankvnk | 0:630b4da97968 | 167 | * Sector2: 0x00002000 - 0x00002FFF 4K |
frankvnk | 0:630b4da97968 | 168 | * Sector3: 0x00003000 - 0x00003FFF 4K |
frankvnk | 0:630b4da97968 | 169 | * Sector4: 0x00004000 - 0x00004FFF 4K |
frankvnk | 0:630b4da97968 | 170 | * Sector5: 0x00005000 - 0x00005FFF 4K |
frankvnk | 0:630b4da97968 | 171 | * Sector6: 0x00006000 - 0x00006FFF 4K |
frankvnk | 0:630b4da97968 | 172 | * Sector7: 0x00007000 - 0x00007FFF 4K |
frankvnk | 0:630b4da97968 | 173 | */ |
frankvnk | 0:630b4da97968 | 174 | |
frankvnk | 0:630b4da97968 | 175 | #define FLASH_SECTOR_0 0x00000000 |
frankvnk | 0:630b4da97968 | 176 | #define FLASH_SECTOR_1 0x00001000 |
frankvnk | 0:630b4da97968 | 177 | #define FLASH_SECTOR_2 0x00002000 |
frankvnk | 0:630b4da97968 | 178 | #define FLASH_SECTOR_3 0x00003000 |
frankvnk | 0:630b4da97968 | 179 | #define FLASH_SECTOR_4 0x00004000 |
frankvnk | 0:630b4da97968 | 180 | #define FLASH_SECTOR_5 0x00005000 |
frankvnk | 0:630b4da97968 | 181 | #define FLASH_SECTOR_6 0x00006000 |
frankvnk | 0:630b4da97968 | 182 | #define FLASH_SECTOR_7 0x00007000 |
frankvnk | 0:630b4da97968 | 183 | #define FLASH_SECTOR_SIZE (4 * 1024) |
frankvnk | 0:630b4da97968 | 184 | |
frankvnk | 0:630b4da97968 | 185 | static char * sector_start_adress[] = { |
frankvnk | 0:630b4da97968 | 186 | (char *)FLASH_SECTOR_0, |
frankvnk | 0:630b4da97968 | 187 | (char *)FLASH_SECTOR_1, |
frankvnk | 0:630b4da97968 | 188 | (char *)FLASH_SECTOR_2, |
frankvnk | 0:630b4da97968 | 189 | (char *)FLASH_SECTOR_3, |
frankvnk | 0:630b4da97968 | 190 | (char *)FLASH_SECTOR_4, |
frankvnk | 0:630b4da97968 | 191 | (char *)FLASH_SECTOR_5, |
frankvnk | 0:630b4da97968 | 192 | (char *)FLASH_SECTOR_6, |
frankvnk | 0:630b4da97968 | 193 | (char *)FLASH_SECTOR_7, |
frankvnk | 0:630b4da97968 | 194 | }; |
frankvnk | 0:630b4da97968 | 195 | |
frankvnk | 0:630b4da97968 | 196 | #endif |
frankvnk | 0:630b4da97968 | 197 | |
frankvnk | 0:630b4da97968 | 198 | |
frankvnk | 0:630b4da97968 | 199 | /** Error code by IAP routine |
frankvnk | 0:630b4da97968 | 200 | * |
frankvnk | 0:630b4da97968 | 201 | * Table 588 "ISP Return Codes Summary", Section 7.15 "ISP Return Codes", usermanual |
frankvnk | 0:630b4da97968 | 202 | */ |
frankvnk | 0:630b4da97968 | 203 | |
frankvnk | 0:630b4da97968 | 204 | enum error_code |
frankvnk | 0:630b4da97968 | 205 | { |
frankvnk | 0:630b4da97968 | 206 | CMD_SUCCESS, |
frankvnk | 0:630b4da97968 | 207 | INVALID_COMMAND, |
frankvnk | 0:630b4da97968 | 208 | SRC_ADDR_ERROR, |
frankvnk | 0:630b4da97968 | 209 | DST_ADDR_ERROR, |
frankvnk | 0:630b4da97968 | 210 | SRC_ADDR_NOT_MAPPED, |
frankvnk | 0:630b4da97968 | 211 | DST_ADDR_NOT_MAPPED, |
frankvnk | 0:630b4da97968 | 212 | COUNT_ERROR, |
frankvnk | 0:630b4da97968 | 213 | INVALID_SECTOR, |
frankvnk | 0:630b4da97968 | 214 | SECTOR_NOT_BLANK, |
frankvnk | 0:630b4da97968 | 215 | SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION, |
frankvnk | 0:630b4da97968 | 216 | COMPARE_ERROR, |
frankvnk | 0:630b4da97968 | 217 | BUSY, |
frankvnk | 0:630b4da97968 | 218 | PARAM_ERROR, |
frankvnk | 0:630b4da97968 | 219 | ADDR_ERROR, |
frankvnk | 0:630b4da97968 | 220 | ADDR_NOT_MAPPED, |
frankvnk | 0:630b4da97968 | 221 | CMD_LOCKED, |
frankvnk | 0:630b4da97968 | 222 | INVALID_CODE, |
frankvnk | 0:630b4da97968 | 223 | INVALID_BAUD_RATE, |
frankvnk | 0:630b4da97968 | 224 | INVALID_STOP_BIT, |
frankvnk | 0:630b4da97968 | 225 | CODE_READ_PROTECTION_ENABLED |
frankvnk | 0:630b4da97968 | 226 | }; |
frankvnk | 0:630b4da97968 | 227 | |
frankvnk | 0:630b4da97968 | 228 | |
frankvnk | 0:630b4da97968 | 229 | |
frankvnk | 0:630b4da97968 | 230 | /* |
frankvnk | 0:630b4da97968 | 231 | * IAP routine entry |
frankvnk | 0:630b4da97968 | 232 | * |
frankvnk | 0:630b4da97968 | 233 | * "IAP commands" |
frankvnk | 0:630b4da97968 | 234 | */ |
frankvnk | 0:630b4da97968 | 235 | |
frankvnk | 0:630b4da97968 | 236 | #define IAP_LOCATION 0x1fff1ff1 |
frankvnk | 0:630b4da97968 | 237 | typedef void (*IAP_call)(unsigned int [], unsigned int []); |
frankvnk | 0:630b4da97968 | 238 | |
frankvnk | 0:630b4da97968 | 239 | /** IAP class |
frankvnk | 0:630b4da97968 | 240 | * |
frankvnk | 0:630b4da97968 | 241 | * Interface for internal flash memory access |
frankvnk | 0:630b4da97968 | 242 | */ |
frankvnk | 0:630b4da97968 | 243 | |
frankvnk | 0:630b4da97968 | 244 | |
frankvnk | 0:630b4da97968 | 245 | class IAP { |
frankvnk | 0:630b4da97968 | 246 | public: |
frankvnk | 0:630b4da97968 | 247 | |
frankvnk | 0:630b4da97968 | 248 | /* |
frankvnk | 0:630b4da97968 | 249 | * SystemCoreClock ??? : |
frankvnk | 0:630b4da97968 | 250 | * http://mbed.org/forum/mbed/topic/229/ |
frankvnk | 0:630b4da97968 | 251 | * http://mbed.org/users/simon/programs/SystemCoreClock/16mhsh/ |
frankvnk | 0:630b4da97968 | 252 | */ |
frankvnk | 0:630b4da97968 | 253 | |
frankvnk | 0:630b4da97968 | 254 | |
frankvnk | 0:630b4da97968 | 255 | /** Constructor for IAP |
frankvnk | 0:630b4da97968 | 256 | * |
frankvnk | 0:630b4da97968 | 257 | */ |
frankvnk | 0:630b4da97968 | 258 | |
frankvnk | 0:630b4da97968 | 259 | IAP() : iap_entry( reinterpret_cast<IAP_call>(IAP_LOCATION) ), cclk_kHz( SystemCoreClock / 1000 ) {} |
frankvnk | 0:630b4da97968 | 260 | int read_ID( void ); |
frankvnk | 0:630b4da97968 | 261 | int read_serial( void ); |
frankvnk | 0:630b4da97968 | 262 | int blank_check( int start, int end ); |
frankvnk | 0:630b4da97968 | 263 | int erase( int start, int end ); |
frankvnk | 0:630b4da97968 | 264 | int prepare( int start, int end ); |
frankvnk | 0:630b4da97968 | 265 | int write( char *source_addr, char *target_addr, int size ); |
frankvnk | 0:630b4da97968 | 266 | int compare( char *source_addr, char *target_addr, int size ); |
frankvnk | 0:630b4da97968 | 267 | int read_BootVer( void ); |
frankvnk | 0:630b4da97968 | 268 | |
frankvnk | 0:630b4da97968 | 269 | char *reserved_flash_area_start( void ); |
frankvnk | 0:630b4da97968 | 270 | int reserved_flash_area_size( void ); |
frankvnk | 0:630b4da97968 | 271 | |
frankvnk | 0:630b4da97968 | 272 | #if defined(TARGET_LPC11U24) |
frankvnk | 0:630b4da97968 | 273 | int write_eeprom( char *source_addr, char *target_addr, int size ); |
frankvnk | 0:630b4da97968 | 274 | int read_eeprom( char *source_addr, char *target_addr, int size ); |
frankvnk | 0:630b4da97968 | 275 | #endif |
frankvnk | 0:630b4da97968 | 276 | |
frankvnk | 0:630b4da97968 | 277 | private: |
frankvnk | 0:630b4da97968 | 278 | IAP_call iap_entry; |
frankvnk | 0:630b4da97968 | 279 | unsigned int IAP_command[ 5 ]; |
frankvnk | 0:630b4da97968 | 280 | unsigned int IAP_result[ 5 ]; |
frankvnk | 0:630b4da97968 | 281 | int cclk_kHz; |
frankvnk | 0:630b4da97968 | 282 | |
frankvnk | 0:630b4da97968 | 283 | //int cpu_clock( void ); |
frankvnk | 0:630b4da97968 | 284 | } |
frankvnk | 0:630b4da97968 | 285 | ; |
frankvnk | 0:630b4da97968 | 286 | |
frankvnk | 0:630b4da97968 | 287 | #endif // #ifndef MBED_IAP |
frankvnk | 3:a016fe71ed72 | 288 | #endif // TARGET_LPC1768 - TARGET_LPC11U24 |