slave debug

Dependencies:   mbed-rtos mbed

Fork of master_working_1_2_reset_test by green rosh

Revision:
4:7992ea5e41ed
Parent:
3:7a895e0fdd45
diff -r 7a895e0fdd45 -r 7992ea5e41ed main.cpp
--- a/main.cpp	Fri Dec 19 18:00:32 2014 +0000
+++ b/main.cpp	Tue Jan 20 16:12:54 2015 +0000
@@ -17,6 +17,11 @@
 
 Mail<i2c_data,16> i2c_data_receive;
 Mail<i2c_data,16> i2c_data_send;
+unsigned char* data_reg = (unsigned char*)0x40067004;
+unsigned char* status_reg = (unsigned char*)0x40067003;
+unsigned char* c1_reg = (unsigned char*)0x40067002;
+unsigned char* c2_reg = (unsigned char*)0x40067005;
+unsigned char* freq_reg = (unsigned char*)0x40067001;
 
 Thread * ptr_t_i2c;
 void FUNC_I2C_MASTER_FSLAVE(char * data,int length)
@@ -55,16 +60,20 @@
                     
              }*/
             //wait(0.5); 
-            while(ack0)
+            while(ack0 )
             {
-                //printf("2 master clk freq setup and addressing slave\n\r");
+                //printf("\n\r %x \n",addr);
                 
-                master.start();                                 //initiating the data transfer
-                ack0 =  master.read(addr,data,length);
+                                               //initiating the data transfer
+                ack0 =  master.read(addr|1,data,length);
+                //printf("\nready to receive\n");
+                  
             }
-            if(!ack0 && data_ready ==1)
+          
+            if(!ack0 )
             {
                     printf("\n master has read %c from slave\n\r",*data);
+                    printf("\n \r %d %d %d %d %d\n",*data_reg,*status_reg,*c1_reg,*c2_reg,*freq_reg);
                     loopvariable0=false;
             }
                 //master.stop();
@@ -120,7 +129,7 @@
                 while(write2slave && interrupt ==1)
                 {                
                 printf("master clk freq setup and addressing slave\n\r");
-                master.start();                                 //initiating the data transfer
+                //master.start();                                 //initiating the data transfer
                 master_status_write = (bool) master.write(addr|0x00,writedata,1);
                 if(master_status_write==0)
                     {
@@ -128,6 +137,7 @@
                     write2slave=false;
                     }
                 i2c_data_send.free(i2c_data_s);
+                 printf("\n \r %d %d %d %d %d\n",*data_reg,*status_reg,*c1_reg,*c2_reg,*freq_reg);
                 }
             }
 }
@@ -136,9 +146,11 @@
 
 int main()
 {   
+    int i= 0;
     ptr_t_i2c = new Thread(T_I2C_MASTER_FSLAVE);
     data_ready.rise(&FUNC_INT);
     printf("\nstarted master\n"); 
+    //master.start();  
     while(1)
     { 
       FUNC_MASTER_WRITE();