Nikolai Trushnikov
/
FlashExample
rwiteandread
Revision 0:c2e4e593b284, committed 2020-06-25
- Comitter:
- nikmaos
- Date:
- Thu Jun 25 10:22:06 2020 +0000
- Commit message:
- Structure writing and reading.
Changed in this revision
--- /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
--- /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); + + +
--- /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
--- /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