lab6

Dependencies:   eeprom mbed

Fork of Nucleo_eeprom by FRA221_2017

Files at this revision

API Documentation at this revision

Comitter:
csggreen
Date:
Fri Nov 24 04:04:27 2017 +0000
Parent:
7:8faeff100e3a
Commit message:
lab6;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 8faeff100e3a -r ad8113b969ae main.cpp
--- a/main.cpp	Sun Oct 29 16:05:01 2017 +0000
+++ b/main.cpp	Fri Nov 24 04:04:27 2017 +0000
@@ -1,45 +1,40 @@
 
 #include "mbed.h"
 #include "eeprom.h"
-
+Serial pc(D1, D0);
 EEPROM memory(I2C_SDA,I2C_SCL,0);
 //EEPROM abc(I2C_SDA,I2C_SCL,1);
 
+BusIn gsswitch(D9,D10,D11,D12,D13,A0,A1);
+BusOut gsled(D2,D3,D4,D5,D6,D7,D8);
+DigitalIn switchmenu(A3);
+DigitalIn switchop(A4);
+
 int main()
 {
-
-    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);
-
+while(1){
+   int8_t dummy,data;
+    if(switchmenu==1){
+        if(switchop==1){
+            while(switchop==1){
+                dummy=gsswitch.read();
+                memory.write(1,(int8_t)dummy);
+                wait_ms(1);
+            //pc.printf("%x\n",dummy);
+            }
+       }
+    }
+    if(switchmenu==0){
+        if(switchop==1){
+            while(switchop==1){
+                memory.read(1,data);
+                gsled.write(data);
+                wait_ms(1);
+            //pc.printf("%x\n",data);
+            }
+        }
+    }
+   
+   }
+   
 }
\ No newline at end of file