Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of IAP_internal_flash_write by
Revision 2:c22f0c87fee6, committed 2012-11-26
- Comitter:
- okano
- Date:
- Mon Nov 26 06:03:39 2012 +0000
- Parent:
- 1:a85b51eeb446
- Child:
- 3:63a0993315e5
- Commit message:
- sample code for IAP class library for LPC1768 and LPC11U24. EEPROM access sample added
Changed in this revision
| IAP.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/IAP.lib Mon Nov 26 04:02:14 2012 +0000 +++ b/IAP.lib Mon Nov 26 06:03:39 2012 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/okano/code/IAP/#ada7fb504504 +http://mbed.org/users/okano/code/IAP/#ff906ad52cf9
--- a/main.cpp Mon Nov 26 04:02:14 2012 +0000
+++ b/main.cpp Mon Nov 26 06:03:39 2012 +0000
@@ -38,6 +38,8 @@
* revision 1.1 12-Mar-2010 chaged: to make possible to reserve flash area for user
* it can be set by USER_FLASH_AREA_START and USER_FLASH_AREA_SIZE in IAP.h
* revision 2.0 26-Nov.2012 LPC11U24 code added
+ * revision 2.1 26-Nov-2012 EEPROM access code imported from Suga koubou san's (http://mbed.org/users/okini3939/) library
+ * http://mbed.org/users/okini3939/code/M0_EEPROM_test/
*/
#include "mbed.h"
@@ -49,6 +51,7 @@
#define TARGET_SECTOR 29 // use sector 29 as target sector if it is on LPC1768
#elif defined(TARGET_LPC11U24)
#define TARGET_SECTOR 7 // use sector 7 as target sector if it is on LPC11U24
+#define TARGET_EEPROM_ADDRESS 64
#endif
void memdump( char *p, int n );
@@ -111,6 +114,25 @@
printf( "showing the flash contents...\r\n" );
memdump( sector_start_adress[ TARGET_SECTOR ], MEM_SIZE * 3 );
+
+#if defined(TARGET_LPC11U24) // SAMPLE OF EEPROM ACCESS (LPC11U24 only)
+ printf( "IAP: EEPROM writing test\r\n" );
+ char mem2[ MEM_SIZE ];
+
+ r = iap.write_eeprom( mem, (char*)TARGET_EEPROM_ADDRESS, MEM_SIZE );
+ printf( "copied: SRAM(0x%08X)->EEPROM(0x%08X) for %d bytes. (result=0x%08X)\r\n", mem, TARGET_EEPROM_ADDRESS, MEM_SIZE, r );
+
+ r = iap.read_eeprom( (char*)TARGET_EEPROM_ADDRESS, mem2, MEM_SIZE );
+ printf( "copied: EEPROM(0x%08X)->SRAM(0x%08X) for %d bytes. (result=0x%08X)\r\n", TARGET_EEPROM_ADDRESS, mem, MEM_SIZE, r );
+
+ // compare
+ r = memcmp(mem, mem2, MEM_SIZE);
+ printf( "compare result = \"%s\"\r\n", r ? "FAILED" : "OK" );
+
+ printf( "showing the EEPROM contents...\r\n" );
+ memdump( mem2, MEM_SIZE );
+#endif
+
}
