SPI Library for 240x320 TFT LCD with ILI9320, ILI9325 and ILI9328 chip

Dependencies:   BurstSPI

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)

Committer:
frankvnk
Date:
Fri Jan 11 16:10:06 2013 +0000
Revision:
0:630b4da97968
Child:
3:a016fe71ed72
Extracted from Mini-DK to create separate library

Who changed what in which revision?

UserRevisionLine numberNew 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 0:630b4da97968 26
frankvnk 0:630b4da97968 27 #include "mbed.h"
frankvnk 0:630b4da97968 28 #include "IAP.h"
frankvnk 0:630b4da97968 29
frankvnk 0:630b4da97968 30 #define USER_FLASH_AREA_START_STR( x ) STR( x )
frankvnk 0:630b4da97968 31 #define STR( x ) #x
frankvnk 0:630b4da97968 32
frankvnk 0:630b4da97968 33 unsigned char user_area[ USER_FLASH_AREA_SIZE ] __attribute__((section( ".ARM.__at_" USER_FLASH_AREA_START_STR( USER_FLASH_AREA_START ) ), zero_init));
frankvnk 0:630b4da97968 34
frankvnk 0:630b4da97968 35
frankvnk 0:630b4da97968 36 /*
frankvnk 0:630b4da97968 37 * Reserve of flash area is explained by Igor. Please refer next URL
frankvnk 0:630b4da97968 38 * http://mbed.org/users/okano/notebook/iap-in-application-programming-internal-flash-eras/?page=1#comment-271
frankvnk 0:630b4da97968 39 */
frankvnk 0:630b4da97968 40
frankvnk 0:630b4da97968 41 //unsigned char user_area[ size ] __attribute__((section(".ARM.__at_0x78000"), zero_init));
frankvnk 0:630b4da97968 42
frankvnk 0:630b4da97968 43 /*
frankvnk 0:630b4da97968 44 * IAP command codes
frankvnk 0:630b4da97968 45 * Table 589. "IAP Command Summary", Chapter 8. "IAP commands", usermanual
frankvnk 0:630b4da97968 46 */
frankvnk 0:630b4da97968 47
frankvnk 0:630b4da97968 48 enum command_code
frankvnk 0:630b4da97968 49 {
frankvnk 0:630b4da97968 50 IAPCommand_Prepare_sector_for_write_operation = 50,
frankvnk 0:630b4da97968 51 IAPCommand_Copy_RAM_to_Flash,
frankvnk 0:630b4da97968 52 IAPCommand_Erase_sector,
frankvnk 0:630b4da97968 53 IAPCommand_Blank_check_sector,
frankvnk 0:630b4da97968 54 IAPCommand_Read_part_ID,
frankvnk 0:630b4da97968 55 IAPCommand_Read_Boot_Code_version,
frankvnk 0:630b4da97968 56 IAPCommand_Compare,
frankvnk 0:630b4da97968 57 IAPCommand_Reinvoke_ISP,
frankvnk 0:630b4da97968 58 IAPCommand_Read_device_serial_number,
frankvnk 0:630b4da97968 59 #if defined(TARGET_LPC11U24)
frankvnk 0:630b4da97968 60 IAPCommand_EEPROM_Write = 61,
frankvnk 0:630b4da97968 61 IAPCommand_EEPROM_Read,
frankvnk 0:630b4da97968 62 #endif
frankvnk 0:630b4da97968 63 };
frankvnk 0:630b4da97968 64
frankvnk 0:630b4da97968 65
frankvnk 0:630b4da97968 66 /** Read part identification number
frankvnk 0:630b4da97968 67 *
frankvnk 0:630b4da97968 68 * @return device ID
frankvnk 0:630b4da97968 69 * @see read_serial()
frankvnk 0:630b4da97968 70 */
frankvnk 0:630b4da97968 71
frankvnk 0:630b4da97968 72 int IAP::read_ID( void ) {
frankvnk 0:630b4da97968 73 IAP_command[ 0 ] = IAPCommand_Read_part_ID;
frankvnk 0:630b4da97968 74
frankvnk 0:630b4da97968 75 iap_entry( IAP_command, IAP_result );
frankvnk 0:630b4da97968 76
frankvnk 0:630b4da97968 77 // return ( (int)IAP_result[ 0 ] );
frankvnk 0:630b4da97968 78 return ( (int)IAP_result[ 1 ] ); // to return the number itself (this command always returns CMD_SUCCESS)
frankvnk 0:630b4da97968 79 }
frankvnk 0:630b4da97968 80
frankvnk 0:630b4da97968 81
frankvnk 0:630b4da97968 82 /** Read device serial number
frankvnk 0:630b4da97968 83 *
frankvnk 0:630b4da97968 84 * @return device serial number
frankvnk 0:630b4da97968 85 * @see read_ID()
frankvnk 0:630b4da97968 86 */
frankvnk 0:630b4da97968 87
frankvnk 0:630b4da97968 88 int IAP::read_serial( void ) {
frankvnk 0:630b4da97968 89 IAP_command[ 0 ] = IAPCommand_Read_device_serial_number;
frankvnk 0:630b4da97968 90
frankvnk 0:630b4da97968 91 iap_entry( IAP_command, IAP_result );
frankvnk 0:630b4da97968 92
frankvnk 0:630b4da97968 93 // return ( (int)IAP_result[ 0 ] );
frankvnk 0:630b4da97968 94 return ( (int)IAP_result[ 1 ] ); // to return the number itself (this command always returns CMD_SUCCESS)
frankvnk 0:630b4da97968 95 }
frankvnk 0:630b4da97968 96
frankvnk 0:630b4da97968 97
frankvnk 0:630b4da97968 98 /** Blank check sector(s)
frankvnk 0:630b4da97968 99 *
frankvnk 0:630b4da97968 100 * @param start a Start Sector Number
frankvnk 0:630b4da97968 101 * @param end an End Sector Number (should be greater than or equal to start sector number).
frankvnk 0:630b4da97968 102 * @return error code: CMD_SUCCESS | BUSY | SECTOR_NOT_BLANK | INVALID_SECTOR
frankvnk 0:630b4da97968 103 */
frankvnk 0:630b4da97968 104
frankvnk 0:630b4da97968 105 int IAP::blank_check( int start, int end ) {
frankvnk 0:630b4da97968 106 IAP_command[ 0 ] = IAPCommand_Blank_check_sector;
frankvnk 0:630b4da97968 107 IAP_command[ 1 ] = (unsigned int)start; // Start Sector Number
frankvnk 0:630b4da97968 108 IAP_command[ 2 ] = (unsigned int)end; // End Sector Number (should be greater than or equal to start sector number)
frankvnk 0:630b4da97968 109
frankvnk 0:630b4da97968 110 iap_entry( IAP_command, IAP_result );
frankvnk 0:630b4da97968 111
frankvnk 0:630b4da97968 112 return ( (int)IAP_result[ 0 ] );
frankvnk 0:630b4da97968 113 }
frankvnk 0:630b4da97968 114
frankvnk 0:630b4da97968 115
frankvnk 0:630b4da97968 116 /** Erase Sector(s)
frankvnk 0:630b4da97968 117 *
frankvnk 0:630b4da97968 118 * @param start a Start Sector Number
frankvnk 0:630b4da97968 119 * @param end an End Sector Number (should be greater than or equal to start sector number).
frankvnk 0:630b4da97968 120 * @return error code: CMD_SUCCESS | BUSY | SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION | INVALID_SECTOR
frankvnk 0:630b4da97968 121 */
frankvnk 0:630b4da97968 122
frankvnk 0:630b4da97968 123 int IAP::erase( int start, int end ) {
frankvnk 0:630b4da97968 124 IAP_command[ 0 ] = IAPCommand_Erase_sector;
frankvnk 0:630b4da97968 125 IAP_command[ 1 ] = (unsigned int)start; // Start Sector Number
frankvnk 0:630b4da97968 126 IAP_command[ 2 ] = (unsigned int)end; // End Sector Number (should be greater than or equal to start sector number)
frankvnk 0:630b4da97968 127 IAP_command[ 3 ] = cclk_kHz; // CPU Clock Frequency (CCLK) in kHz
frankvnk 0:630b4da97968 128
frankvnk 0:630b4da97968 129 iap_entry( IAP_command, IAP_result );
frankvnk 0:630b4da97968 130
frankvnk 0:630b4da97968 131 return ( (int)IAP_result[ 0 ] );
frankvnk 0:630b4da97968 132 }
frankvnk 0:630b4da97968 133
frankvnk 0:630b4da97968 134
frankvnk 0:630b4da97968 135 /** Prepare sector(s) for write operation
frankvnk 0:630b4da97968 136 *
frankvnk 0:630b4da97968 137 * @param start a Start Sector Number
frankvnk 0:630b4da97968 138 * @param end an End Sector Number (should be greater than or equal to start sector number).
frankvnk 0:630b4da97968 139 * @return error code: CMD_SUCCESS | BUSY | INVALID_SECTOR
frankvnk 0:630b4da97968 140 */
frankvnk 0:630b4da97968 141
frankvnk 0:630b4da97968 142 int IAP::prepare( int start, int end ) {
frankvnk 0:630b4da97968 143 IAP_command[ 0 ] = IAPCommand_Prepare_sector_for_write_operation;
frankvnk 0:630b4da97968 144 IAP_command[ 1 ] = (unsigned int)start; // Start Sector Number
frankvnk 0:630b4da97968 145 IAP_command[ 2 ] = (unsigned int)end; // End Sector Number (should be greater than or equal to start sector number).
frankvnk 0:630b4da97968 146
frankvnk 0:630b4da97968 147 iap_entry( IAP_command, IAP_result );
frankvnk 0:630b4da97968 148
frankvnk 0:630b4da97968 149 return ( (int)IAP_result[ 0 ] );
frankvnk 0:630b4da97968 150 }
frankvnk 0:630b4da97968 151
frankvnk 0:630b4da97968 152
frankvnk 0:630b4da97968 153 /** Copy RAM to Flash
frankvnk 0:630b4da97968 154 *
frankvnk 0:630b4da97968 155 * @param source_addr Source RAM address from which data bytes are to be read. This address should be a word boundary.
frankvnk 0:630b4da97968 156 * @param target_addr Destination flash address where data bytes are to be written. This address should be a 256 byte boundary.
frankvnk 0:630b4da97968 157 * @param size Number of bytes to be written. Should be 256 | 512 | 1024 | 4096.
frankvnk 0:630b4da97968 158 * @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
frankvnk 0:630b4da97968 159 */
frankvnk 0:630b4da97968 160
frankvnk 0:630b4da97968 161 int IAP::write( char *source_addr, char *target_addr, int size ) {
frankvnk 0:630b4da97968 162 IAP_command[ 0 ] = IAPCommand_Copy_RAM_to_Flash;
frankvnk 0:630b4da97968 163 IAP_command[ 1 ] = (unsigned int)target_addr; // Destination flash address where data bytes are to be written. This address should be a 256 byte boundary.
frankvnk 0:630b4da97968 164 IAP_command[ 2 ] = (unsigned int)source_addr; // Source RAM address from which data bytes are to be read. This address should be a word boundary.
frankvnk 0:630b4da97968 165 IAP_command[ 3 ] = size; // Number of bytes to be written. Should be 256 | 512 | 1024 | 4096.
frankvnk 0:630b4da97968 166 IAP_command[ 4 ] = cclk_kHz; // CPU Clock Frequency (CCLK) in kHz.
frankvnk 0:630b4da97968 167
frankvnk 0:630b4da97968 168 iap_entry( IAP_command, IAP_result );
frankvnk 0:630b4da97968 169
frankvnk 0:630b4da97968 170 return ( (int)IAP_result[ 0 ] );
frankvnk 0:630b4da97968 171 }
frankvnk 0:630b4da97968 172
frankvnk 0:630b4da97968 173
frankvnk 0:630b4da97968 174 /** Compare <address1> <address2> <no of bytes>
frankvnk 0:630b4da97968 175 *
frankvnk 0:630b4da97968 176 * @param source_addr Starting flash or RAM address of data bytes to be compared. This address should be a word boundary.
frankvnk 0:630b4da97968 177 * @param target_addr Starting flash or RAM address of data bytes to be compared. This address should be a word boundary.
frankvnk 0:630b4da97968 178 * @param size Number of bytes to be compared; should be a multiple of 4.
frankvnk 0:630b4da97968 179 * @return error code: CMD_SUCCESS | COMPARE_ERROR | COUNT_ERROR (Byte count is not a multiple of 4) | ADDR_ERROR | ADDR_NOT_MAPPED
frankvnk 0:630b4da97968 180 */
frankvnk 0:630b4da97968 181
frankvnk 0:630b4da97968 182 int IAP::compare( char *source_addr, char *target_addr, int size ) {
frankvnk 0:630b4da97968 183 IAP_command[ 0 ] = IAPCommand_Compare;
frankvnk 0:630b4da97968 184 IAP_command[ 1 ] = (unsigned int)target_addr; // Starting flash or RAM address of data bytes to be compared. This address should be a word boundary.
frankvnk 0:630b4da97968 185 IAP_command[ 2 ] = (unsigned int)source_addr; // Starting flash or RAM address of data bytes to be compared. This address should be a word boundary.
frankvnk 0:630b4da97968 186 IAP_command[ 3 ] = size; // Number of bytes to be compared; should be a multiple of 4.
frankvnk 0:630b4da97968 187
frankvnk 0:630b4da97968 188 iap_entry( IAP_command, IAP_result );
frankvnk 0:630b4da97968 189
frankvnk 0:630b4da97968 190 return ( (int)IAP_result[ 0 ] );
frankvnk 0:630b4da97968 191 }
frankvnk 0:630b4da97968 192
frankvnk 0:630b4da97968 193 /** Compare <address1> <address2> <no of bytes>
frankvnk 0:630b4da97968 194 *
frankvnk 0:630b4da97968 195 * @param source_addr Starting flash or RAM address of data bytes to be compared. This address should be a word boundary.
frankvnk 0:630b4da97968 196 * @param target_addr Starting flash or RAM address of data bytes to be compared. This address should be a word boundary.
frankvnk 0:630b4da97968 197 * @param size Number of bytes to be compared; should be a multiple of 4.
frankvnk 0:630b4da97968 198 * @return error code: CMD_SUCCESS | COMPARE_ERROR | COUNT_ERROR (Byte count is not a multiple of 4) | ADDR_ERROR | ADDR_NOT_MAPPED
frankvnk 0:630b4da97968 199 */
frankvnk 0:630b4da97968 200
frankvnk 0:630b4da97968 201 int IAP::read_BootVer(void) {
frankvnk 0:630b4da97968 202 IAP_command[0] = IAPCommand_Read_Boot_Code_version;
frankvnk 0:630b4da97968 203 IAP_result[1] = 0; // not sure if in high or low bits.
frankvnk 0:630b4da97968 204 iap_entry(IAP_command, IAP_result);
frankvnk 0:630b4da97968 205 return ((int)IAP_result[1]);
frankvnk 0:630b4da97968 206 }
frankvnk 0:630b4da97968 207
frankvnk 0:630b4da97968 208 /** Get user reserved flash start address
frankvnk 0:630b4da97968 209 *
frankvnk 0:630b4da97968 210 * @return start address of user reserved flash memory
frankvnk 0:630b4da97968 211 * @see reserved_flash_area_size()
frankvnk 0:630b4da97968 212 */
frankvnk 0:630b4da97968 213
frankvnk 0:630b4da97968 214 char * IAP::reserved_flash_area_start( void )
frankvnk 0:630b4da97968 215 {
frankvnk 0:630b4da97968 216 return ( (char *)USER_FLASH_AREA_START );
frankvnk 0:630b4da97968 217 }
frankvnk 0:630b4da97968 218
frankvnk 0:630b4da97968 219
frankvnk 0:630b4da97968 220 /** Get user reserved flash size
frankvnk 0:630b4da97968 221 *
frankvnk 0:630b4da97968 222 * @return size of user reserved flash memory
frankvnk 0:630b4da97968 223 * @see reserved_flash_area_start()
frankvnk 0:630b4da97968 224 */
frankvnk 0:630b4da97968 225
frankvnk 0:630b4da97968 226 int IAP::reserved_flash_area_size( void )
frankvnk 0:630b4da97968 227 {
frankvnk 0:630b4da97968 228 return ( USER_FLASH_AREA_SIZE );
frankvnk 0:630b4da97968 229 }
frankvnk 0:630b4da97968 230
frankvnk 0:630b4da97968 231 #if defined(TARGET_LPC11U24)
frankvnk 0:630b4da97968 232 /** Copy RAM to EEPROM (LPC11U24)
frankvnk 0:630b4da97968 233 *
frankvnk 0:630b4da97968 234 * @param source_addr Source RAM address from which data bytes are to be read.
frankvnk 0:630b4da97968 235 * @param target_addr Destination EEPROM address where data bytes are to be written.
frankvnk 0:630b4da97968 236 * @param size Number of bytes to be written.
frankvnk 0:630b4da97968 237 * @return error code: CMD_SUCCESS | SRC_ADDR_NOT_MAPPED | DST_ADDR_NOT_MAPPED
frankvnk 0:630b4da97968 238 * Remark: The top 64 bytes of the EEPROM memory are reserved and cannot be written to.
frankvnk 0:630b4da97968 239 */
frankvnk 0:630b4da97968 240 int IAP::write_eeprom( char *source_addr, char *target_addr, int size ) {
frankvnk 0:630b4da97968 241 IAP_command[ 0 ] = IAPCommand_EEPROM_Write;
frankvnk 0:630b4da97968 242 IAP_command[ 1 ] = (unsigned int)target_addr; // Destination EEPROM address where data bytes are to be written. This address should be a 256 byte boundary.
frankvnk 0:630b4da97968 243 IAP_command[ 2 ] = (unsigned int)source_addr; // Source RAM address from which data bytes are to be read. This address should be a word boundary.
frankvnk 0:630b4da97968 244 IAP_command[ 3 ] = size; // Number of bytes to be written. Should be 256 | 512 | 1024 | 4096.
frankvnk 0:630b4da97968 245 IAP_command[ 4 ] = cclk_kHz; // CPU Clock Frequency (CCLK) in kHz.
frankvnk 0:630b4da97968 246
frankvnk 0:630b4da97968 247 iap_entry( IAP_command, IAP_result );
frankvnk 0:630b4da97968 248
frankvnk 0:630b4da97968 249 return ( (int)IAP_result[ 0 ] );
frankvnk 0:630b4da97968 250 }
frankvnk 0:630b4da97968 251
frankvnk 0:630b4da97968 252 /** Copy EEPROM to RAM (LPC11U24)
frankvnk 0:630b4da97968 253 *
frankvnk 0:630b4da97968 254 * @param source_addr Source EEPROM address from which data bytes are to be read.
frankvnk 0:630b4da97968 255 * @param target_addr Destination RAM address where data bytes are to be written.
frankvnk 0:630b4da97968 256 * @param size Number of bytes to be written.
frankvnk 0:630b4da97968 257 * @return error code: CMD_SUCCESS | SRC_ADDR_NOT_MAPPED | DST_ADDR_NOT_MAPPED
frankvnk 0:630b4da97968 258 * Remark: The top 64 bytes of the EEPROM memory are reserved and cannot be written to.
frankvnk 0:630b4da97968 259 */
frankvnk 0:630b4da97968 260 int IAP::read_eeprom( char *source_addr, char *target_addr, int size ) {
frankvnk 0:630b4da97968 261 IAP_command[ 0 ] = IAPCommand_EEPROM_Read;
frankvnk 0:630b4da97968 262 IAP_command[ 1 ] = (unsigned int)source_addr; // Source EEPROM address from which data bytes are to be read. This address should be a word boundary.
frankvnk 0:630b4da97968 263 IAP_command[ 2 ] = (unsigned int)target_addr; // Destination RAM address where data bytes are to be written. This address should be a 256 byte boundary.
frankvnk 0:630b4da97968 264 IAP_command[ 3 ] = size; // Number of bytes to be written. Should be 256 | 512 | 1024 | 4096.
frankvnk 0:630b4da97968 265 IAP_command[ 4 ] = cclk_kHz; // CPU Clock Frequency (CCLK) in kHz.
frankvnk 0:630b4da97968 266
frankvnk 0:630b4da97968 267 iap_entry( IAP_command, IAP_result );
frankvnk 0:630b4da97968 268
frankvnk 0:630b4da97968 269 return ( (int)IAP_result[ 0 ] );
frankvnk 0:630b4da97968 270 }
frankvnk 0:630b4da97968 271 #endif