lab eeprom

Dependencies:   eeprom mbed

Files at this revision

API Documentation at this revision

Comitter:
bi18rdbi18rd
Date:
Sun Nov 08 13:50:57 2015 +0000
Parent:
4:3a9d307d26e2
Commit message:
reverse to Potiwat original;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 3a9d307d26e2 -r eb65bd646089 main.cpp
--- a/main.cpp	Sun Nov 08 13:39:24 2015 +0000
+++ b/main.cpp	Sun Nov 08 13:50:57 2015 +0000
@@ -1,50 +1,43 @@
+
 #include "mbed.h"
 #include "eeprom.h"
+
 EEPROM memory(I2C_SDA,I2C_SCL,0);
 
-BusIn inbutton(D8,D7,D6,D5,D4,D3,D2);
-BusOut led(A1,A0,D13,D12,D11,D10,D9);
-
-DigitalIn selectmode(PB_7);
-
-DigitalIn trigger(PC_13);
-
 int main()
 {
-    int i=1,j=1,check=0,oldtrigger=0,currenttrigger;
-    int8_t data_dummy;
-    int8_t data;
-    
-    while(1)
-    {
-        currenttrigger=trigger;
-        
-    if(selectmode==0 && oldtrigger==0 && currenttrigger==1) //0 is write mode
-    {
-        if(check==1){i=1;j=1;check=0;}
-        data_dummy=inbutton;
-        
-        memory.write(i,(int8_t)data_dummy);
-        wait_ms(1);
-        i++;
-    }
-    
-    if(selectmode==1 && oldtrigger==0 && currenttrigger==1)
-    {   
-        check=1;
-        if(j<i) 
-        {
-            memory.read(j,data);
-            wait_ms(1); 
-            led = data;
-            wait(1);
-            
-            j++;
-        } 
-        else
-        {led=0;}
-    }
-        oldtrigger=currenttrigger;
-    }
-    
+
+    int8_t data_dummy='r';
+    int8_t data[4];
+    float x=0.0f,j=9785.26844;
+    int16_t y=0x3321,z;
+
+    memory.write(1,(int8_t)data_dummy);
+    wait_ms(1);
+
+    memory.write(2,(int8_t)'c');
+    wait_ms(1);
+    memory.read(1,data,2);
+    wait_ms(1);
+
+
+    memory.write(10,j);
+    wait_ms(1);
+
+    memory.read(10,x);
+    wait_ms(1);
+
+
+    memory.write(1,(int16_t)y);
+    wait_ms(1);
+    memory.read(1,z);
+    wait_ms(1);
+
+    printf("read[1] = %c\n",data[0]);
+    printf("read[2] = %c\n",data[1]);
+
+    printf("float = %f\n",x);
+
+    printf("int16 =%d\n",z);
+
 }
\ No newline at end of file