i2c

Dependencies:   mbed

Fork of Serial_HelloWorld_Mbed by mbed official

Files at this revision

API Documentation at this revision

Comitter:
Andreus
Date:
Fri Mar 27 14:52:54 2015 +0000
Parent:
1:560b8ced44df
Commit message:
Test

Changed in this revision

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 560b8ced44df -r 24f2636c2915 main.cpp
--- a/main.cpp	Sun Sep 21 05:44:05 2014 +0000
+++ b/main.cpp	Fri Mar 27 14:52:54 2015 +0000
@@ -1,10 +1,42 @@
 #include "mbed.h"
  
 Serial pc(USBTX, USBRX); // tx, rx
- 
+I2C i2c(p28, p27);
+const int addr_r = 0xA9; //Read of EEPROM 10101001
+const int addr_w = 0xA8; //Write of EEPROM 10101000
+//const int freq = 300000;
+
+
 int main() {
-    pc.printf("Hello World!\n\r");
-    while(1) {
-        pc.putc(pc.getc() + 1); // echo input back to terminal
-    }
+    pc.printf("EEPROM operation util\n\r");
+    char cmd[] = "aahello!!!";
+    cmd[0]=0xAA;
+    cmd[1]=0x12;
+    char buffer[8];
+
+
+    //i2c.frequency(freq);
+    pc.printf("Selection of i2c offset ");
+    if(i2c.write(addr_w,cmd,2,true)==0) {pc.printf("succeed"); } 
+    else pc.printf ("failed");
+    i2c.read(addr_r, buffer, 8, false);
+ /*   pc.printf("\n\rread 8 bytes: %s\n\r", buffer);
+    wait(0.5);
+    pc.printf("trying to write: %s ",cmd);
+    if(i2c.write(addr_w,cmd,10,false)) printf("succeed"); 
+    else printf ("failed");
+    wait(0.5);
+    pc.printf("Selection of i2c offset ");
+    if(i2c.write(addr_r,cmd,2,true)==0) {printf("succeed"); }
+    else printf ("failed");
+    i2c.read(addr_r, buffer, 8, true);
+    i2c.stop();
+    pc.printf("\n\rread 8 bytes: %s\n\r", buffer);
+  */  
+    
+    
+    
+    while(1)
+    {
+    }    
 }
\ No newline at end of file
diff -r 560b8ced44df -r 24f2636c2915 mbed.bld
--- a/mbed.bld	Sun Sep 21 05:44:05 2014 +0000
+++ b/mbed.bld	Fri Mar 27 14:52:54 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/487b796308b0
\ No newline at end of file