I2C code testing

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of COM_MNG_TMTC_SIMPLE_pl123 by Siva ram

Revision:
130:d5b53088270b
Parent:
126:b7c024b5632d
Child:
131:8745e6041ebc
Child:
132:d4a4461214ad
--- a/COM_MNG_TMTC.h	Fri Feb 26 13:29:33 2016 +0000
+++ b/COM_MNG_TMTC.h	Sat Feb 27 07:12:04 2016 +0000
@@ -12,7 +12,7 @@
 
 //#include "Flash.h"
 #include "cdms_rtc.h"
-
+Timer t_pl;
 //defined in definations and globals, need to mapped with the final ones.
 //DigitalIn tm_status_4m_slv(PIN39); //I2C interrupt to CDMS from BAE
 //DigitalIn tm_status_4m_pl(PIN61); //I2C interrupt to CDMS from PL 
@@ -991,15 +991,47 @@
         {
             
             
-            
-            //printf("Telecommand is for PL\r\n");
+            uint8_t PL_TM_SIZE;
+            #if DEBUG
+            printf("Telecommand is for PL\r\n");
+            #endif
             // printf("Informing PL about TC using I2C\r\n"); //interrupt to be sent to the bae
-            // FCTN_I2C_WRITE((char*)tc_ptr->TC_string);
-            // printf("sent the Telecommand to BAE\r\n"); //packet along with crc will be sent when bae is ready
-            // wait(1); //wait time is to be optimised
-            // if(tm_status_4m_slv == 1)
-            // {
-            //     FCTN_I2C_READ((char*)tm_ptr->TM_string);
+            if(GETshort_or_long_tc(tc_ptr) == LONG_TC_CODE)
+                FCTN_I2C_WRITE_PL((char*)tc_ptr->TC_string,TC_LONG_SIZE);
+            else 
+                FCTN_I2C_WRITE_PL((char*)tc_ptr->TC_string,TC_SHORT_SIZE);
+            
+            
+            
+            while(1)
+            {
+                gLEDG = !gLEDG;
+                t_pl.start();
+                if(PYLD_I2C_Int == 1)
+                {
+                    t_pl.stop();
+                    gPC.printf("i2c_t = %d",t_pl.read_ms());
+                    if(GETservice_subtype(tc_ptr) == 0xD0 || GETservice_subtype(tc_ptr) == 0xD2 || GETservice_subtype(tc_ptr) == 0xD3) //check which all require short TM
+                    {   
+                        FCTN_I2C_READ_PL((char*)tm_pointer->TM_string,TM_LONG_SIZE);
+                        break;
+                        }
+                    else 
+                    {
+                        FCTN_I2C_READ_PL((char*)tm_pointer->TM_string,TM_SHORT_SIZE);
+                        break;
+                        }
+                    }
+                
+                
+                }
+            
+            
+                // for(int i;i<2000;i++){if(PYLD_I2C_Int=1)i=2001;}//timeout to be defined
+                 
+                 
+                 //PL should reset the i2c pin
+                 
             //     received = 1;
             // }
             // if(received == 1 )