rwiteandread

Dependencies:   mbed Flash

Revision:
0:c2e4e593b284
diff -r 000000000000 -r c2e4e593b284 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jun 25 10:22:06 2020 +0000
@@ -0,0 +1,37 @@
+#include "mbed.h"
+#include "flashwrapper.h"
+
+int main()
+{   
+   typedef struct
+   {
+    float a;
+    uint32_t b;
+    uint16_t c;
+    uint8_t d;       
+    }bab_t;
+   
+   char q=sizeof(bab_t)/sizeof(uint32_t);
+   typedef union {
+    bab_t a;    
+    uint32_t b[sizeof(bab_t)/sizeof(uint32_t)/*+другие структуры так же*/];
+    }RW_t;
+    
+    RW_t bufer;    
+    
+    bufer.a.a=0.67;
+    bufer.a.b=5000000;
+    bufer.a.c=60000;
+    bufer.a.d=150;    
+   
+   flashWrite(0,bufer.b,q);
+   for(int i=0;i<q;i++)
+   {bufer.b[i]=flashRead(i*4);}
+   
+   printf("Value = %f\r\n",bufer.a.a);
+   printf("Value = %d\r\n",bufer.a.b);
+   printf("Value = %d\r\n",bufer.a.c);
+   printf("Value = %d\r\n",bufer.a.d);
+   
+   
+}
\ No newline at end of file