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@10:374723606fc9, 2018-11-06 (annotated)
- Committer:
- Pitiwut
- Date:
- Tue Nov 06 07:13:07 2018 +0000
- Revision:
- 10:374723606fc9
- Parent:
- 9:70102b54bfcd
- Child:
- 11:8d8c3e003153
edit#2;
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| bi18rdbi18rd | 5:eb65bd646089 | 1 | |
| soulx | 0:8b5e53600ba0 | 2 | #include "mbed.h" | 
| soulx | 0:8b5e53600ba0 | 3 | #include "eeprom.h" | 
| bi18rdbi18rd | 5:eb65bd646089 | 4 | |
| Pitiwut | 10:374723606fc9 | 5 | EEPROM memory(PB_9,PB_8,0); | 
| soulx | 0:8b5e53600ba0 | 6 | |
| soulx | 0:8b5e53600ba0 | 7 | int main() | 
| soulx | 0:8b5e53600ba0 | 8 | { | 
| Pitiwut | 8:1628d2c67f5e | 9 | //// Initial data to write ///// | 
| Pitiwut | 8:1628d2c67f5e | 10 | int8_t data_dummy = 'r'; | 
| Pitiwut | 8:1628d2c67f5e | 11 | int8_t data[4]; | 
| Pitiwut | 8:1628d2c67f5e | 12 | float x = 0.0f; | 
| Pitiwut | 8:1628d2c67f5e | 13 | float j = 9785.26844; | 
| bi18rdbi18rd | 5:eb65bd646089 | 14 | |
| Pitiwut | 8:1628d2c67f5e | 15 | //// Write data to Address 1 and 2 | 
| Pitiwut | 9:70102b54bfcd | 16 | memory.write(0x0001,(int8_t)data_dummy); | 
| bi18rdbi18rd | 5:eb65bd646089 | 17 | wait_ms(1); | 
| Pitiwut | 9:70102b54bfcd | 18 | memory.write(0x0002,(int8_t)'c'); | 
| bi18rdbi18rd | 5:eb65bd646089 | 19 | wait_ms(1); | 
| Pitiwut | 8:1628d2c67f5e | 20 | |
| Pitiwut | 8:1628d2c67f5e | 21 | /// Read data from address 1 to 4, and store in data array | 
| Pitiwut | 8:1628d2c67f5e | 22 | memory.read(1,data,4); | 
| bi18rdbi18rd | 5:eb65bd646089 | 23 | wait_ms(1); | 
| Pitiwut | 8:1628d2c67f5e | 24 | |
| Pitiwut | 8:1628d2c67f5e | 25 | printf("read[1] = %c\n",data[0]); | 
| Pitiwut | 8:1628d2c67f5e | 26 | printf("read[2] = %c\n",data[1]); | 
| Pitiwut | 8:1628d2c67f5e | 27 | printf("read[3] = %c\n",data[2]); | 
| Pitiwut | 8:1628d2c67f5e | 28 | printf("read[4] = %c\n",data[3]); | 
| bi18rdbi18rd | 5:eb65bd646089 | 29 | |
| Pitiwut | 8:1628d2c67f5e | 30 | //// Write float data | 
| Pitiwut | 9:70102b54bfcd | 31 | memory.write(0x000A,j); | 
| bi18rdbi18rd | 5:eb65bd646089 | 32 | wait_ms(1); | 
| bi18rdbi18rd | 5:eb65bd646089 | 33 | |
| Pitiwut | 8:1628d2c67f5e | 34 | //// Read float data, and store to x | 
| Pitiwut | 9:70102b54bfcd | 35 | memory.read(0x000A,x); | 
| bi18rdbi18rd | 5:eb65bd646089 | 36 | wait_ms(1); | 
| Pitiwut | 8:1628d2c67f5e | 37 | |
| bi18rdbi18rd | 5:eb65bd646089 | 38 | printf("float = %f\n",x); | 
| bi18rdbi18rd | 5:eb65bd646089 | 39 | |
| soulx | 0:8b5e53600ba0 | 40 | } |