Latest FM Code with EEPROM

Dependencies:   FreescaleIAP SimpleDMA eeprom mbed-rtos mbed

Fork of CDMS_QM_03MAR2017_Flash_with_obsrs by Team Fox

Revision:
256:0f9aeeaf5a1d
Parent:
255:642ea552ac77
diff -r 642ea552ac77 -r 0f9aeeaf5a1d COM_MNG_TMTC.h
--- a/COM_MNG_TMTC.h	Mon Jul 11 14:33:02 2016 +0000
+++ b/COM_MNG_TMTC.h	Tue Jul 12 09:05:25 2016 +0000
@@ -752,7 +752,7 @@
                         {                         
                             //gPC.printf("RESET_HK_COUNTER\r\n"); // call PWR_SWCH_ON function
                             
-                            RST_HK_COUNTER();
+                            STANDBY_PRCS();         //////// Need to Complete this function
 
                             ACK_L234(tm_pointer,0xA0,GETpacket_seq_count(tc_ptr));
                             return tm_ptr;                                                    
@@ -773,7 +773,7 @@
                             uint32_t time_temp = FCTN_CDMS_RD_RTC();                        //RTC_RD_EROR has to incorporated
                             tm_pointer->TM_string[0] = 0x78;     
                             tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);                                    
-                            tm_pointer->TM_string[2] = 0xA0;
+                            tm_pointer->TM_string[2] = 0xA0;    // ACK CODE
                             tm_pointer->TM_string[3] = 0x00;
                             tm_pointer->TM_string[4] = (uint8_t)((time_temp & 0xFF000000)>>24);
                             tm_pointer->TM_string[5] = (uint8_t)((time_temp & 0x00FF0000)>>16);
@@ -792,9 +792,31 @@
                         else if(GETpid(tc_ptr)==0xF0)
                         {
                             uint8_t statusbits[64];
-                            CDMS_RD_SD_HK(statusbits);
-                            ACK_L234(tm_pointer,0xC0,GETpacket_seq_count(tc_ptr));
-                            return tm_ptr;
+                            if( CDMS_RD_SD_HK(statusbits) != 0){
+                                ACK_L234(tm_pointer,0xC0,GETpacket_seq_count(tc_ptr));
+                                return tm_ptr;
+                            }
+                            else
+                            {
+                                uint32_t time_temp = FCTN_CDMS_RD_RTC();                        //RTC_RD_EROR has to incorporated
+                                tm_pointer->TM_string[0] = 0x78;     
+                                tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);                                    
+                                tm_pointer->TM_string[2] = 0xA0;    // ACK CODE
+                                tm_pointer->TM_string[3] = 0x00;
+                                for(int i=4;i<64;i++)
+                                {
+                                    tm_pointer->TM_string[i+4] = (i<68)?statusbits[i]:0x00;
+                                }
+                                for(uint8_t i=68;i<132;i++)
+                                {
+                                    tm_pointer->TM_string[i] = 0x00;
+                                }
+                                crc16 = crc16_gen(tm_ptr->TM_string,132);
+                                tm_pointer->TM_string[132] = (uint8_t)((crc16&0xFF00)>>8);
+                                tm_pointer->TM_string[133] = (uint8_t)(crc16&0x00FF);
+                                tm_pointer->next_TM = NULL;                                                                     //incomplete
+                                return tm_ptr;
+                            }
                         }                               
                         else 
                         {