RAS

Fork of IAP by Tedd OKANO

Files at this revision

API Documentation at this revision

Comitter:
pascalreygner
Date:
Fri Aug 24 16:38:19 2018 +0000
Parent:
10:59f7e32ae397
Child:
12:91ac1391a13b
Commit message:
essai

Changed in this revision

IAP.cpp Show annotated file Show diff for this revision Revisions of this file
IAP.h Show annotated file Show diff for this revision Revisions of this file
--- a/IAP.cpp	Thu Aug 16 06:24:19 2018 +0000
+++ b/IAP.cpp	Fri Aug 24 16:38:19 2018 +0000
@@ -34,6 +34,7 @@
 
 #define     USER_FLASH_AREA_START_STR( x )      STR( x )
 #define     STR( x )                            #x
+#define     MEM_SIZE                            256
 
 unsigned char user_area[ USER_FLASH_AREA_SIZE ] __attribute__((section( ".ARM.__at_" USER_FLASH_AREA_START_STR( USER_FLASH_AREA_START ) ), zero_init));
 
@@ -178,6 +179,37 @@
     return ( USER_FLASH_AREA_SIZE );
 }
 
+// ************ Ajout PR 22/8/2018 ***********************************
+void IAP::eraseFlashSector(int numSecteur)
+{
+    prepare( numSecteur, numSecteur );
+    erase( numSecteur, numSecteur );
+}
+
+int IAP::writeFlashAd(char *data,int numSecteur,int numBlock)
+{
+    prepare(numSecteur, numSecteur );
+    int r = write( data, sector_start_adress[ numSecteur]+MEM_SIZE*numBlock, MEM_SIZE );
+    return(r);
+}
+
+void IAP::readFlashAd(char *data,int numSecteur,int numBlock)
+{
+    memcpy( data, sector_start_adress[ numSecteur]+MEM_SIZE*numBlock, MEM_SIZE );
+}
+#define FLASH_NBBLOCK 128          // nb blocks dans un secteur
+
+void IAP::copyFlashSector(int numSecteurSrc,int numSecteurDest)
+{
+    char data[MEM_SIZE];
+    eraseFlashSector(numSecteurDest);
+    for (int numBlock =0; numBlock<FLASH_NBBLOCK; numBlock++) {
+        readFlashAd(data, numSecteurSrc,numBlock);
+        writeFlashAd(data, numSecteurDest,numBlock);
+    }
+}
+// ************ Fin Ajout PR 22/8/2018 ***********************************
+
 #if defined(TARGET_LPC11UXX)
 
 int IAP::write_eeprom( char *source_addr, char *target_addr, int size )
--- a/IAP.h	Thu Aug 16 06:24:19 2018 +0000
+++ b/IAP.h	Fri Aug 24 16:38:19 2018 +0000
@@ -34,8 +34,8 @@
 #define        MBED_IAP
 
 #include    "mbed.h"
-
-#if defined(TARGET_LPC176X)
+# define TARGET_LPC1488
+#if defined(TARGET_LPC176X) || defined(TARGET_LPC1488)
 
 #define     USER_FLASH_AREA_START   FLASH_SECTOR_29
 #define     USER_FLASH_AREA_SIZE    (FLASH_SECTOR_SIZE_16_TO_29 * 1)
@@ -451,6 +451,12 @@
      *  @see       reserved_flash_area_start()
      */
     int   reserved_flash_area_size( void );
+    
+//PR 22/8/2018    
+    void eraseFlashSector(int numSecteur);
+    int writeFlashAd(char *data,int numSecteur,int numBlock);
+    void readFlashAd(char *data,int numSecteur,int numBlock);
+    void copyFlashSector(int numSecteurSrc,int numSecteurDest);
 
 #if defined(TARGET_LPC11UXX)