working version

Dependencies:   mbed mbed-rtos SimpleDMA FreescaleIAP eeprom

Fork of CDMS_CODE_FM_28JAN2017 by samp Srinivasan

Revision:
356:197c93dc2012
Parent:
354:eb6c863756a8
Child:
357:f3d48d62e00e
--- a/COM_MNG_TMTC.h	Tue Mar 28 08:50:07 2017 +0000
+++ b/COM_MNG_TMTC.h	Sat Feb 10 09:06:26 2018 +0000
@@ -385,9 +385,11 @@
                 }
                 if(BAE_I2C_GPIO == 1)
                 {
-                    //gPC.printf("BAE_I2C_GPIO is high\r\n");
+                    gPC.printf("BAE_I2C_GPIO is high\r\n");
                     Base_tm *tm_ptr = new Long_tm;
+                                    gPC.printf("en");
                     y=FCTN_I2C_READ((char*)tm_ptr->TM_string,TM_LONG_SIZE);
+                                    gPC.printf("ex");
                     if(y==0)
                     {
                         TIME_LATEST_I2C_BAE = FCTN_CDMS_RD_RTC() >> 7;
@@ -405,7 +407,7 @@
                         return tm_ptr_short;
                     }
                 }
-                else if(BAE_I2C_GPIO == 0)
+                else
                 {
                     gPC.printf("BAE_I2C_GPIO is not high\r\n");                    
                     Base_tm *tm_ptr_short = new Short_tm;
@@ -927,9 +929,9 @@
                             
                             if(tc_ptr->TC_string[4] == 0x00 || tc_ptr->TC_string[4] == 0x01)
                             EN_PL = tc_ptr->TC_string[4];
-                            else if(tc_ptr->TC_string[5] == 0x00 || tc_ptr->TC_string[5] == 0x01)
+                            if(tc_ptr->TC_string[5] == 0x00 || tc_ptr->TC_string[5] == 0x01)        //was else if changed to if to match the flowcharts - J
                             EN_CDMS_HK = tc_ptr->TC_string[5];
-                            else if(tc_ptr->TC_string[6] == 0x00 || tc_ptr->TC_string[6] == 0x01)
+                            if(tc_ptr->TC_string[6] == 0x00 || tc_ptr->TC_string[6] == 0x01)
                             EN_RCV_SC = tc_ptr->TC_string[6];
                             
                             Base_tm *tm_ptr_short = new Short_tm;
@@ -949,19 +951,22 @@
                         {          
                             //gPC.printf("TC_CDMS_RD_RTC\r\n"); // call PWR_SWCH_ON function
                             
-                            uint32_t time_temp = FCTN_CDMS_RD_RTC();                        //RTC_RD_EROR has to incorporated
+                            uint64_t time_temp = FCTN_CDMS_RD_RTC();                        //RTC_RD_EROR has to incorporated
                             Base_tm *tm_ptr = new Long_tm;
                             tm_ptr->TM_string[0] = 0x78;     
                             tm_ptr->TM_string[1] = GETpacket_seq_count(tc_ptr);                                    
                             tm_ptr->TM_string[2] = 0xA0;
                             tm_ptr->TM_string[3] = 0x00;
-                            tm_ptr->TM_string[4] = (uint8_t)((time_temp & 0xFF000000)>>24);
-                            tm_ptr->TM_string[5] = (uint8_t)((time_temp & 0x00FF0000)>>16);
-                            tm_ptr->TM_string[6] = (uint8_t)((time_temp & 0x0000FF00)>>8);
-                            tm_ptr->TM_string[7] = (uint8_t)((time_temp & 0x000000FF));
-                            for(uint8_t i=0;i<124;i++)
+                            tm_ptr->TM_string[4] = (uint8_t)((time_temp & 0x600000000)>>33);
+                            tm_ptr->TM_string[5] = (uint8_t)((time_temp & 0x1E0000000)>>29);
+                            tm_ptr->TM_string[6] = (uint8_t)((time_temp & 0x01F000000)>>24);
+                            tm_ptr->TM_string[7] = (uint8_t)((time_temp & 0x000F80000)>>19);
+                            tm_ptr->TM_string[8] = (uint8_t)((time_temp & 0x00007E000)>>13);
+                            tm_ptr->TM_string[9] = (uint8_t)((time_temp & 0x000001F80)>>7);
+                            tm_ptr->TM_string[10] = (uint8_t)((time_temp & 0x00000007F));
+                            for(uint8_t i=0;i<121;i++)
                             {
-                                tm_ptr->TM_string[i+8] = 0x00;
+                                tm_ptr->TM_string[i+11] = 0x00;
                             }
                             crc16 = crc16_gen(tm_ptr->TM_string,132);
                             tm_ptr->TM_string[132] = (uint8_t)((crc16&0xFF00)>>8);
@@ -1000,9 +1005,9 @@
                                 return tm_ptr;
                             }
                         }
-                        else if(GETpid(tc_ptr)==0xF1)
+                        else if(GETpid(tc_ptr)==0xF2)
                         {
-                            CDMS_CALIB_RTC((uint64_t)(tc_ptr->TC_string[4])<<32 + (uint64_t)(tc_ptr->TC_string[5])<<24 + (uint64_t)(tc_ptr->TC_string[5])<<16 + (uint64_t)(tc_ptr->TC_string[6])<<8  +(uint64_t)(tc_ptr->TC_string[7]));
+                            CDMS_CALIB_RTC(((uint32_t)(tc_ptr->TC_string[5])<<24) + ((uint32_t)(tc_ptr->TC_string[6])<<16) + ((uint32_t)(tc_ptr->TC_string[7])<<8) + ((uint32_t)(tc_ptr->TC_string[8])));
                             Base_tm *tm_ptr_short = new Short_tm;
                             ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
                             return tm_ptr_short;
@@ -1162,10 +1167,11 @@
                 TIME_LATEST_I2C_SPEED = FCTN_CDMS_RD_RTC() >> 7;
                 //wait(0.2);
                 int poll=0;
-                while(poll<2000 && PL_I2C_Intr==0)
+                //gPC.printf("\n\r%d",PL_I2C_Intr);
+                while(poll<12000 && PL_I2C_Intr==0)
                 {
-                 // gPC.printf("\n\rPL_I2C_Intr is low");
-                    wait_us(10);
+                    //gPC.printf("\n\rPL_I2C_Intr is low");
+                    wait_us(500);
                     poll+=1;
                 }    
             if(PL_I2C_Intr == 1)
@@ -1447,6 +1453,12 @@
         /*gLEDR = !gLEDR;*/\
         Base_tc* current_TC = gHEAD_NODE_TCL;\
         int overflowCount = 0;\
+        P_COM_HK;\
+        if( gFLAGS & COM_PA_HOT_FLAG ){\
+        gPC.printf("PA HOT");\
+        execute_psc = PSC_START_VALUE;\
+        continue;\
+        }\
         while(current_TC != NULL){\
             if( overflowCount < TCL_OVERFLOW_CONSTANT ){\
                 if( (GETcrc_pass(current_TC) == 1) && (GETpacket_seq_count(current_TC) == execute_psc) ){\
@@ -1683,6 +1695,7 @@
             gPC.printf("completed or session timed out: %x\r\n", gMASTER_STATE);\
         /*COMPLETED EXECUTION OF TC*/\
         gMASTER_STATE = TCL_STATE_COMPLETED;\
+        gPC.printf("\n flags2 = %u \n", gFLAGS);\
         COM_POWER_OFF_TX;\
         reset_all;\
         /*ENABLE THREADS*/\