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@3:8d9d440c1a2c, 2015-10-26 (annotated)
- Committer:
- soulx
- Date:
- Mon Oct 26 16:44:20 2015 +0000
- Revision:
- 3:8d9d440c1a2c
- Parent:
- 2:27acee628363
- Child:
- 4:3a9d307d26e2
eeprom must wait a litte time for write and read
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| soulx | 0:8b5e53600ba0 | 1 | #include "mbed.h" | 
| soulx | 0:8b5e53600ba0 | 2 | #include "eeprom.h" | 
| soulx | 0:8b5e53600ba0 | 3 | |
| soulx | 0:8b5e53600ba0 | 4 | |
| soulx | 0:8b5e53600ba0 | 5 | |
| soulx | 3:8d9d440c1a2c | 6 | EEPROM memory(I2C_SDA,I2C_SCL,0); | 
| soulx | 0:8b5e53600ba0 | 7 | int main() | 
| soulx | 0:8b5e53600ba0 | 8 | { | 
| soulx | 3:8d9d440c1a2c | 9 | |
| soulx | 3:8d9d440c1a2c | 10 | |
| soulx | 3:8d9d440c1a2c | 11 | int8_t data_dummy='r'; | 
| soulx | 3:8d9d440c1a2c | 12 | int8_t data[4]; | 
| soulx | 3:8d9d440c1a2c | 13 | float x=0.0f,j=9785.26844; | 
| soulx | 3:8d9d440c1a2c | 14 | int16_t y=0x3321,z; | 
| soulx | 3:8d9d440c1a2c | 15 | |
| soulx | 3:8d9d440c1a2c | 16 | |
| soulx | 3:8d9d440c1a2c | 17 | memory.write(1,(int8_t)data_dummy); | 
| soulx | 3:8d9d440c1a2c | 18 | wait_ms(1); | 
| soulx | 3:8d9d440c1a2c | 19 | |
| soulx | 3:8d9d440c1a2c | 20 | memory.write(2,(int8_t)'c'); | 
| soulx | 3:8d9d440c1a2c | 21 | wait_ms(1); | 
| soulx | 0:8b5e53600ba0 | 22 | memory.read(1,data,2); | 
| soulx | 3:8d9d440c1a2c | 23 | wait_ms(1); | 
| soulx | 3:8d9d440c1a2c | 24 | |
| soulx | 3:8d9d440c1a2c | 25 | |
| soulx | 3:8d9d440c1a2c | 26 | memory.write(10,j); | 
| soulx | 3:8d9d440c1a2c | 27 | wait_ms(1); | 
| soulx | 3:8d9d440c1a2c | 28 | |
| soulx | 3:8d9d440c1a2c | 29 | memory.read(10,x); | 
| soulx | 3:8d9d440c1a2c | 30 | wait_ms(1); | 
| soulx | 3:8d9d440c1a2c | 31 | |
| soulx | 3:8d9d440c1a2c | 32 | |
| soulx | 3:8d9d440c1a2c | 33 | memory.write(1,(int16_t)y); | 
| soulx | 3:8d9d440c1a2c | 34 | wait_ms(1); | 
| soulx | 3:8d9d440c1a2c | 35 | memory.read(1,z); | 
| soulx | 3:8d9d440c1a2c | 36 | wait_ms(1); | 
| soulx | 3:8d9d440c1a2c | 37 | |
| soulx | 3:8d9d440c1a2c | 38 | printf("read[1] = %c\n",data[0]); | 
| soulx | 0:8b5e53600ba0 | 39 | printf("read[2] = %c\n",data[1]); | 
| soulx | 0:8b5e53600ba0 | 40 | |
| soulx | 3:8d9d440c1a2c | 41 | printf("float = %f\n",x); | 
| soulx | 3:8d9d440c1a2c | 42 | |
| soulx | 2:27acee628363 | 43 | printf("int16 =%d\n",z); | 
| soulx | 2:27acee628363 | 44 | |
| soulx | 3:8d9d440c1a2c | 45 | |
| soulx | 0:8b5e53600ba0 | 46 | } |