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.
main.cpp
- Committer:
- Pitiwut
- Date:
- 2018-11-06
- Revision:
- 10:374723606fc9
- Parent:
- 9:70102b54bfcd
- Child:
- 11:8d8c3e003153
File content as of revision 10:374723606fc9:
#include "mbed.h"
#include "eeprom.h"
EEPROM memory(PB_9,PB_8,0);
int main()
{
//// Initial data to write /////
int8_t data_dummy = 'r';
int8_t data[4];
float x = 0.0f;
float j = 9785.26844;
//// Write data to Address 1 and 2
memory.write(0x0001,(int8_t)data_dummy);
wait_ms(1);
memory.write(0x0002,(int8_t)'c');
wait_ms(1);
/// Read data from address 1 to 4, and store in data array
memory.read(1,data,4);
wait_ms(1);
printf("read[1] = %c\n",data[0]);
printf("read[2] = %c\n",data[1]);
printf("read[3] = %c\n",data[2]);
printf("read[4] = %c\n",data[3]);
//// Write float data
memory.write(0x000A,j);
wait_ms(1);
//// Read float data, and store to x
memory.read(0x000A,x);
wait_ms(1);
printf("float = %f\n",x);
}