rwiteandread

Dependencies:   mbed Flash

main.cpp

Committer:
nikmaos
Date:
2020-06-25
Revision:
0:c2e4e593b284

File content as of revision 0:c2e4e593b284:

#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);
   
   
}