Compression code changed and RLY_TMTC pointers managed

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE by shubham c

Files at this revision

API Documentation at this revision

Comitter:
chaithanyarss
Date:
Tue Jul 12 09:05:25 2016 +0000
Parent:
255:642ea552ac77
Commit message:
Tcs testing : Merging ;

Changed in this revision

COM_MNG_TMTC.h Show annotated file Show diff for this revision Revisions of this file
FMS_all.h Show annotated file Show diff for this revision Revisions of this file
--- 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 
                         {
--- a/FMS_all.h	Mon Jul 11 14:33:02 2016 +0000
+++ b/FMS_all.h	Tue Jul 12 09:05:25 2016 +0000
@@ -1,5 +1,8 @@
 
 /*===================================================FMS Functions=================================================*/
+
+void STANDBY_PRCS();
+
 //Run processes
 void P_PL_INIT();
 void P_PL_MAIN();
@@ -34,12 +37,17 @@
 void EPS_V_C_EN();
 
 void RST_HK_COUNTER();
-uint8_t CDMS_RD_SD_HK(uint8_t *);
+int8_t CDMS_RD_SD_HK(uint8_t *);
 void CDMS_RD_RTC(uint64_t *);
-void CDMS_CALIB_RTC();
+void CDMS_CALIB_RTC(uint8_t *);
 void TOTAL_RESET_WITH_CDMS();
 
 
+void STANDBY_PRCS()
+{
+    
+}
+
 void P_PL_INIT()
 {
     
@@ -207,9 +215,7 @@
 
 void SYS_PWR_RESET()  // Have to be decided with EPS team.
 {
-    /*sys_pwr_rst = 0;
-    wait_ms(10);
-    sys_pwr_rst = 1;*/
+    sys_pwr_rst = 1;
 }
 
 void EPS_V_A_EN()     // This is a reset function
@@ -231,25 +237,19 @@
     firstCount = true;
 }
 
-uint8_t CDMS_RD_SD_HK(uint8_t *sd_statusbits)
+int8_t CDMS_RD_SD_HK(uint8_t *sd_statusbits)
 {
-    uint8_t p;
-    uint8_t ACK;
+    int8_t p;
     if(SD_SW_EN_DS != DEVICE_POWERED)
     {
-        ACK = 0x89;
         SD_RD_ERROR = 1;
-        //Generate TM
+        p = 1;
     }
     else
     {
         p = disk_read_statusbits(sd_statusbits);
-        if(p == 0)
-            ACK = 0xA0;
-        else
-            ACK = 0x89;
     }
-    return ACK;
+    return p;
 }
 
 void CDMS_RD_RTC(uint64_t *time)
@@ -257,9 +257,39 @@
     *time = FCTN_CDMS_RD_RTC();
 }
 
-void CDMS_CALIB_RTC()
+void CDMS_CALIB_RTC(uint64_t *time)
 {
+    SPI_mutex.lock();
+    gCS_RTC=1;
+    spi.format(8,0);
+    spi.frequency(1000000);
+ 
+    gCS_RTC=0;
+    spi.write(0x82);
+    spi.write(time[0]);//set minutes
+    gCS_RTC=1;
+ 
+    gCS_RTC=0;
+    spi.write(0x83); 
+    spi.write(time[1] & 0x3F); //set hours
+    gCS_RTC=1;
     
+    gCS_RTC=0;
+    spi.write(0x85); 
+    spi.write(time[2] & 0x3F); //set date
+    gCS_RTC=1;
+    
+    gCS_RTC=0;
+    spi.write(0x86); 
+    spi.write(time[3] & 0x1F); //set month
+    gCS_RTC=1;
+    
+    gCS_RTC=0;
+    spi.write(0x87); 
+    spi.write(time[4]); //set year to 00(2000)
+    gCS_RTC=1;
+    gPC.puts("\n\r rtc initalised \n");
+    SPI_mutex.unlock();
 }
 
 void CDMS_RESET()