0720_Lab5

Dependencies:   eeprom mbed

Files at this revision

API Documentation at this revision

Comitter:
chinetion
Date:
Sat Nov 14 06:52:39 2015 +0000
Commit message:
Finish;

Changed in this revision

eeprom.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 3ba1890a87e5 eeprom.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/eeprom.lib	Sat Nov 14 06:52:39 2015 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/FRA221_2015/code/eeprom/#c648c5e93d5e
diff -r 000000000000 -r 3ba1890a87e5 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Nov 14 06:52:39 2015 +0000
@@ -0,0 +1,42 @@
+#include "mbed.h"
+#include "eeprom.h"
+ 
+EEPROM rom(I2C_SDA,I2C_SCL,0);
+BusOut led(D2,D3,D4,D5,D6,D7,D8);
+BusIn sw(A5,A4,A3,A2,A1,A0,D9);
+DigitalIn Ck(D10),Mode(D11);
+
+uint8_t write_address=0,read_address=0,size,data[]={};
+int main() {
+     while(1){
+
+        if(Ck.read()){
+            if(Mode.read()){ //Write
+                if(read_address!=0){write_address=0;read_address=0;}
+                
+                rom.write(write_address,(uint8_t)sw.read());
+                wait_ms(1);
+                printf("Write Mode Data = %d  Address = %d\n",sw.read(),write_address);
+                
+                write_address++;
+            }
+            else{            //Read
+                if(write_address!=0){
+                    size=write_address-1;
+                    read_address=0;
+                    write_address=0;
+                    }
+                if(read_address>size){read_address=size;}
+                rom.read(read_address,data,1);
+                led=data[0];
+                printf("Read Mode Data = %d Address = %d \n",data[0],read_address);
+
+                read_address++;
+                
+                
+            }
+            while(Ck.read()){}
+            wait(0.1);
+        }
+    }
+}
diff -r 000000000000 -r 3ba1890a87e5 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Nov 14 06:52:39 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9296ab0bfc11
\ No newline at end of file