FRA221-2018
/
Nucleo_eeprom
Nucleo_eeprom
Fork of Nucleo_eeprom by
main.cpp@1:8b005d040c91, 2015-08-25 (annotated)
- Committer:
- soulx
- Date:
- Tue Aug 25 12:02:49 2015 +0000
- Revision:
- 1:8b005d040c91
- Parent:
- 0:8b5e53600ba0
- Child:
- 2:27acee628363
edit add float
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 | EEPROM memory(I2C_SDA,I2C_SCL,EEPROM_Address); |
soulx | 0:8b5e53600ba0 | 6 | |
soulx | 0:8b5e53600ba0 | 7 | int main() |
soulx | 0:8b5e53600ba0 | 8 | { |
soulx | 0:8b5e53600ba0 | 9 | char value='A'; |
soulx | 0:8b5e53600ba0 | 10 | char data[2]; |
soulx | 0:8b5e53600ba0 | 11 | memory.write(1,value); |
soulx | 0:8b5e53600ba0 | 12 | memory.write(2,'a'); |
soulx | 0:8b5e53600ba0 | 13 | memory.read(1,data,2); |
soulx | 0:8b5e53600ba0 | 14 | printf("read[1] = %c\n",data[0]); |
soulx | 0:8b5e53600ba0 | 15 | printf("read[2] = %c\n",data[1]); |
soulx | 0:8b5e53600ba0 | 16 | |
soulx | 1:8b005d040c91 | 17 | float x=0.0f; |
soulx | 1:8b005d040c91 | 18 | memory.write(10,1.23f); |
soulx | 1:8b005d040c91 | 19 | memory.read(10,x); |
soulx | 1:8b005d040c91 | 20 | printf("float = %f\n",x); |
soulx | 1:8b005d040c91 | 21 | |
soulx | 0:8b5e53600ba0 | 22 | } |