registry flash read/ write

Dependencies:   FreescaleIAP mbed

Fork of testregistr by Team Fox

Revision:
0:d665f794e35e
Child:
1:7db8a959df19
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed May 20 19:02:16 2015 +0000
@@ -0,0 +1,29 @@
+#include "mbed.h"
+#include "FreescaleIAP.h"
+
+Serial pc(USBTX,USBRX);
+ 
+int main() {
+    pc.printf("Starting\r\n"); 
+     //int* adress = (int*)flash_size(); 
+     pc.printf("value at 3fc00 is %d\r\n",flash_size());
+     pc.printf("value at 3fc00 is %d\r\n",SECTOR_SIZE);
+    int address = flash_size() - SECTOR_SIZE;           //Write in last sector
+    pc.printf("Starting %x \r\n",address); 
+    int *data = (int*)address;
+    pc.printf("Starting\r\n"); 
+    erase_sector(address);
+    //int numbers[10] = {0, 1, 10, 100, 1000, 10000, 1000000, 10000000, 100000000, 1000000000};
+    int numbers[5]={26,50,1,0,4};
+    program_flash(address, (char*)&numbers, 20);        //10 integers of 4 bytes each: 40 bytes length
+    pc.printf("Resulting flash: \r\n");
+    for (int i = 0; i<5; i++)
+        printf("%d\r\n", data[i]);
+    
+    pc.printf("Done\r\n\n");
+    pc.printf("value at %x\r\n",address); 
+        
+ 
+    //while (true) {
+    //}
+}
\ No newline at end of file