v2 i2c slave sending 4 bit sensor data to master

Dependencies:   mbed

Fork of xslave by Chaitanya Viswa

Revision:
1:255616146873
Parent:
0:acc1f8a1b321
--- a/slave.cpp	Sat Jul 05 06:38:13 2014 +0000
+++ b/slave.cpp	Mon Jul 07 07:28:35 2014 +0000
@@ -22,14 +22,14 @@
 
 
 
-void FUNC_I2C_SLAVE_MAIN(int slave_address,int iterations)
+void FUNC_I2C_SLAVE_MAIN(int iterations)
 {
     wait(0.5);
     screen.printf("\nSlave entered\n");
     slave.address(slave_address);                           //assigning slave address
-    int Switch_Variable;
-    int ReadAddressed=1;
-    int WriteGeneral=3;
+    char Switch_Variable;
+    
+    
     int loopvariable1=1;
     int loopvariable2=0;
     int loopvariable3=1;
@@ -48,7 +48,7 @@
       switch(Switch_Variable)
       {
       
-       case 1:    while(loopvariable3)
+       case '1':    while(loopvariable3)
                   {
                      if(slave.receive()==ReadAddressed)             //check if slave is addressed to read 
                    {
@@ -78,7 +78,7 @@
                     }//while(loopvariable3)
                   
                   break;
-         case 2 : screen.printf(" telecommand 2\n");
+         case '2' : screen.printf(" telecommand 2\n");
                   break;         
                  
         }//switch case ends