Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 1:061996a0c455, committed 2020-06-25
- Comitter:
- nikmaos
- Date:
- Thu Jun 25 11:41:43 2020 +0000
- Parent:
- 0:c2e4e593b284
- Commit message:
- Commented
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Jun 25 10:22:06 2020 +0000
+++ b/main.cpp Thu Jun 25 11:41:43 2020 +0000
@@ -3,6 +3,7 @@
int main()
{
+ /*Определение типа данных для хранения в ОЗУ*/
typedef struct
{
float a;
@@ -11,27 +12,32 @@
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;
+ }exchanger_t;
- RW_t bufer;
-
+ /*Создаём экземпляр обменника данных*/
+ exchanger_t bufer;
+ /*Инициализируем*/
bufer.a.a=0.67;
- bufer.a.b=5000000;
+ bufer.a.b=5000000;
bufer.a.c=60000;
bufer.a.d=150;
-
+ /*Записываем и считываем обратно*/
+ char q=sizeof(bab_t)/sizeof(uint32_t);
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);
+ printf("Value = %d\r\n",bufer.a.d);
}
\ No newline at end of file