registry flash read/ write

Dependencies:   FreescaleIAP mbed

Fork of testregistr by Team Fox

Files at this revision

API Documentation at this revision

Comitter:
raizel_varun
Date:
Tue Jun 16 08:36:57 2015 +0000
Parent:
2:f20b253b3a0c
Commit message:
registry flash read / write

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r f20b253b3a0c -r ad384b346c28 main.cpp
--- a/main.cpp	Sun Jun 07 07:47:39 2015 +0000
+++ b/main.cpp	Tue Jun 16 08:36:57 2015 +0000
@@ -4,6 +4,9 @@
 Serial pc(USBTX,USBRX);
  
 int main() {
+ float var0,var1,var2,var3,var4,var5,var6,var7,var8,var9;
+ float dumar[10]={var0,var1,var2,var3,var4,var5,var6,var7,var8,var9};
+    
     pc.printf("Starting\r\n"); 
      int* adress = (int*)(0x0003fc08+4); 
    //  pc.printf("value at 3fc00 is %d\r\n",*adress);
@@ -12,28 +15,55 @@
     int address = flash_size() - (SECTOR_SIZE);           //Write in last sector(simply use 256-xkb of file)
                      
     pc.printf("Starting %x \r\n",address); 
-    int *data = (int*)address;
+    char *data = (char*)address;
     pc.printf("Starting\r\n"); 
     erase_sector(address);//cant erase the program
-    int numbers = 56;
+    char numbers = 'd';
     int i;
     
    // for(i=0;i<2560;i++){
     //numbers[i]=((3*i)+1);}
     Timer t;
     t.start();
-    program_flash(address, (char*)&numbers, 4);        //10 integers of 4 bytes each: 40 bytes length
+    program_flash(address, (char*)&numbers,4);        //10 integers of 4 bytes each: 40 bytes length
     //printf("heloooooooooooooooooooooooo");
     t.stop();
     pc.printf("Resulting flash: \r\n");
-    for (i =0 ; i<240; i++)
-        printf("%d,%d\r\n",i, data[i]); 
+    for (i =0 ; i<5;i++)
+        printf("%d,%c\r\n",i, data[i]); 
         
     pc.printf("Done %f\r\n\n",t.read());
     pc.printf("value at %x\r\n",address); 
     t.reset();
-        
+
  
     //while (true) {
     //}
-}
\ No newline at end of file
+}
+
+uint8_t RD_FLASH(int ad1,int ad2)
+{
+  for(int i = 0;i < a; i++)
+    g_flashd[i] = data[i];//read in to ram , can do othr functions  now in g_flashd
+  
+  
+ }
+ 
+extern int a;
+extern int g_flashd[a]; 
+ 
+uint8_t WR_FLASH(int ad, int value)
+{  for(int i = 0;i < a; i++)
+    g_flashd[i] = data[i];
+    g_flashd[ad-address] = value;//change data in ram, if wanted can change multiple variables
+    erase_sector(address);
+    program_flash(address, (char*)&g_flashd,(a*4));
+    
+ }   
+    
+    
+     
+
+
+
+