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
Diff: main.cpp
- Revision:
- 8:8273c1727a6a
- Parent:
- 7:41156dd69ab5
- Child:
- 9:ae7747b119c1
--- a/main.cpp Sun Apr 10 11:36:00 2016 +0000
+++ b/main.cpp Mon Apr 11 03:12:47 2016 +0000
@@ -51,23 +51,7 @@
#define MEM_SIZE 256
-#if defined(TARGET_NUCLEO_L152RE)
-#define TARGET_SECTOR (0x00060000/FLASH_PAGE_SIZE)
-struct {
- char* operator[](int sector) {
- return (char*)(sector * FLASH_PAGE_SIZE);
- }
-} sector_start_adress;
-#elif defined(TARGET_NUCLEO_F401RE)||defined(TARGET_NUCLEO_F411RE)||defined(TARGET_NUCLEO_F446RE)
-#define TARGET_SECTOR 3
-struct {
- char* operator[](int sector) {
- static const uint32_t base[8] = {0x00000, 0x04000, 0x08000, 0xc000, 0x10000, 0x20000, 0x40000, 0x60000};
- return (char*)base[sector];
- }
-} sector_start_adress;
-
-#elif defined(TARGET_LPC176X)
+#if defined(TARGET_LPC176X)
#define TARGET_SECTOR 29 // use sector 29 as target sector if it is on LPC1768
#elif defined(TARGET_LPC11UXX) || defined(TARGET_LPC11XX)
#define TARGET_SECTOR 7 // use sector 7 as target sector if it is on LPC11U24
@@ -75,6 +59,24 @@
#define TARGET_EEPROM_ADDRESS 64
#elif defined(TARGET_LPC81X) || defined(TARGET_LPC82X)
#define TARGET_SECTOR 15 // use sector 15 as target sector if it is on LPC812
+
+#elif defined(TARGET_NUCLEO_L152RE)||defined(TARGET_NUCLEO_F042K6)||defined(TARGET_NUCLEO_F103RB)
+#define TARGET_SECTOR (0x7800/FLASH_PAGE_SIZE)
+struct {
+ char* operator[](int sector) const {
+ return reinterpret_cast<char*>(FLASH_BASE + sector * FLASH_PAGE_SIZE);
+ }
+} sector_start_adress;
+
+#elif defined(TARGET_NUCLEO_F401RE)||defined(TARGET_NUCLEO_F411RE)||defined(TARGET_NUCLEO_F446RE)
+#define TARGET_SECTOR 3
+struct {
+ char* operator[](int sector) const {
+ static const uint32_t offset[8] = {0x00000, 0x04000, 0x08000, 0xc000, 0x10000, 0x20000, 0x40000, 0x60000};
+ return reinterpret_cast<char*>(FLASH_BASE + offset[sector]);
+ }
+} sector_start_adress;
+
#endif
void memdump( char *p, int n );
