slave debug

Dependencies:   mbed-rtos mbed

Fork of slave_working1_1_reset_test by green rosh

Files at this revision

API Documentation at this revision

Comitter:
sakthipriya
Date:
Tue Jan 20 16:12:18 2015 +0000
Parent:
9:baf5de5828c9
Commit message:
slave debug

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Dec 19 17:59:00 2014 +0000
+++ b/main.cpp	Tue Jan 20 16:12:18 2015 +0000
@@ -21,25 +21,43 @@
 
 Mail<i2c_data,16> i2c_data_receive;
 Mail<i2c_data,16> i2c_data_send;
- 
+         
 
+int receive_status =0;
 void FUNC_I2C_WRITE2CDMS(char *data, int length=1)
 {
        int slave_status = 1;
-   
+ //  printf("\nData is %c\n\r",*data);  
+         
+    slave.address(0x20);
+    unsigned char* add_reg = (unsigned char*)0x40067000;
+    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;     
     while(slave_status && interrupt ==1)
-    {                 
-            slave.address(0x20);
-            if(slave.receive()==1)
+    {        
+          //wait(2);
+            receive_status = slave.receive();
+            
+            if( receive_status==1)
             {
+               // printf("\nslave receive b4: \n");
                 slave_status=slave.write(data,length);
-               
+               // printf("\nData sent to CDMS is %c\n\r",*data);
+              // printf("\n\r write"); 
+                //printf("\nslave receive after: %d \n",slave.receive());
                 
             }
-            else if(slave.receive()==3 || slave.receive()==2)
+            else if( receive_status==3 ||  receive_status==2)
             {
                 slave_status=slave.read(data,length);
+               // printf("\n\r read");
             }
+            //printf("\n \r done while loop %d \n",slave.receive());
+            //printf("\n\r ahoy drhghhhhhhhhhhh\n");
+             printf("\n\r %d %d %d %d %d \n",*data_reg,*status_reg,*c1_reg,*c2_reg,*freq_reg);
             
     }
             printf("\ndone\n\r");
@@ -74,6 +92,7 @@
             {
                 i2c_data *i2c_data_s = (i2c_data*)evt.value.p;
                 data_send = i2c_data_s -> data;
+                //printf("\n1.Data is %c\n\r",data_send);
                 FUNC_I2C_WRITE2CDMS(&data_send);
                 printf("\nData sent to CDMS is %c\n\r",data_send);
                 i2c_data_send.free(i2c_data_s);