rwiteandread

Dependencies:   mbed Flash

Files at this revision

API Documentation at this revision

Comitter:
nikmaos
Date:
Thu Jun 25 10:22:06 2020 +0000
Commit message:
Structure writing and reading.

Changed in this revision

Flash.lib Show annotated file Show diff for this revision Revisions of this file
flashwrapper (2).h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r c2e4e593b284 Flash.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Flash.lib	Thu Jun 25 10:22:06 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/engeen-center/code/Flash/#0f5e5690b713
diff -r 000000000000 -r c2e4e593b284 flashwrapper (2).h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flashwrapper (2).h	Thu Jun 25 10:22:06 2020 +0000
@@ -0,0 +1,17 @@
+/*
+ * flashwrapper.h
+ *
+ *  Created on: 25 дек. 2018 г.
+ *      Author: spookee
+ */
+
+#pragma once
+
+#include "stdint.h"
+
+
+uint32_t flashRead(uint32_t address);
+void flashWrite(uint32_t address, uint32_t *p_data, uint16_t size);
+
+
+
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
diff -r 000000000000 -r c2e4e593b284 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Jun 25 10:22:06 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file