EEPROM demo

Dependencies:   mbed 24LCxx_I2C

Files at this revision

API Documentation at this revision

Comitter:
zhangyx
Date:
Sun Dec 30 04:11:35 2018 +0000
Commit message:
initial

Changed in this revision

24LCxx_I2C.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 8292b7e3c0c9 24LCxx_I2C.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/24LCxx_I2C.lib	Sun Dec 30 04:11:35 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/zhangyx/code/24LCxx_I2C/#d1d30d49e7ce
diff -r 000000000000 -r 8292b7e3c0c9 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Dec 30 04:11:35 2018 +0000
@@ -0,0 +1,27 @@
+#include "mbed.h"
+#include "24LCxx_I2C.h"
+
+Serial pc(PA_9, PA_10);
+DigitalOut led(PD_2);
+C24LCXX_I2C eep(PB_7,PB_6,0); // SDA, SCL, 0
+
+int main()
+{
+    unsigned char writeData, readData;
+
+    pc.printf("Hello World !\n");
+    
+    for(int i = 0; i < 128; i++){
+        writeData = i+1;
+        eep.Write(i, writeData); // 向地址 i 写入值 writeData
+    }
+    
+    
+    for(int i = 0; i < 128; i++){
+        eep.Read(i, &readData); // 从地址 i 读取值到 readData
+        
+        pc.printf("%d @ %d\n", readData, i);
+    }
+
+    return 0;
+}
diff -r 000000000000 -r 8292b7e3c0c9 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Dec 30 04:11:35 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc
\ No newline at end of file