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:
Wed Jul 06 07:24:28 2016 +0000
Parent:
229:42624b9a08b4
Commit message:
BAE HK data is collected successfully through I2C

Changed in this revision

CDMS_HK.h Show annotated file Show diff for this revision Revisions of this file
DefinitionsAndGlobals.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
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/CDMS_HK.h	Tue Jul 05 09:35:50 2016 +0000
+++ b/CDMS_HK.h	Wed Jul 06 07:24:28 2016 +0000
@@ -27,7 +27,7 @@
 {
     gPC.printf("Entering HK thread");
     unsigned char CDMS_HK_FRAME[134] = {0};
-    char BAE_HK[128] = {0};
+    char BAE_HK[134] = {0};
     uint8_t convoluted_CDMS_HK[270];
     uint8_t interleave_CDMS_HK[288];
     uint8_t CDMS_HEALTH_FINAL[512] = {0};
@@ -92,38 +92,45 @@
         CDMS_HEALTH_FINAL[i] = interleave_CDMS_HK[i];
 
     SD_WRITE(CDMS_HEALTH_FINAL,FSC_CURRENT[4]+1,4);
-    gPC.printf("Completed CDMS HK\n");
+    gPC.printf("\rCompleted CDMS HK\n");
 
     /*---------------------------------- BAE HK --------------------------------------------*/
 
 
     BAE_HK_I2C = FCTN_I2C_READ(BAE_HK,134);
-    gPC.printf("Entering BAE thread\n");
+    gPC.printf("\rEntering BAE HK\n");
     if(BAE_HK_I2C == 0) {
-        TIME_LATEST_I2C_BAE = FCTN_CDMS_RD_RTC() >> 7;
+        crc = crc16_gen((unsigned char *)BAE_HK,132);
+        if(crc == ((uint16_t)BAE_HK[132] << 8) | (uint16_t)BAE_HK[133]){
+            TIME_LATEST_I2C_BAE = FCTN_CDMS_RD_RTC() >> 7;
+            for(int i = 0; i<15; i++)
+                gPC.printf("\r 0x%02X\n",BAE_HK[i]);
+            for(int i = 0; i<4; i++)
+            BAE_HK[i] = HK_time >> i;
+            BAE_HK_FRAME[0] = 0x28;
+            BAE_HK_FRAME[1] = FSC_CURRENT[5]+1;
+            BAE_HK_FRAME[2] = (FSC_CURRENT[5]+1) >> 8;
+            BAE_HK_FRAME[3] = (FSC_CURRENT[5]+1) >> 16;
+            for(int i = 0; i<128; i++)                       /*Adding actual CDMS Health data to TM frame*/
+                BAE_HK_FRAME[4+i] = BAE_HK[i];
+            crc = crc16_gen(BAE_HK_FRAME,132);               /*Adding CRC to TM frame*/
+            BAE_HK_FRAME[133] = crc;
+            BAE_HK_FRAME[132] = crc >> 8;
+            BAE_HEALTH.convolutionEncode(BAE_HK_FRAME , convoluted_BAE_HK);
+            BAE_HEALTH.convolutionEncode(BAE_HK_FRAME + 67, convoluted_BAE_HK + 135);
+            interleave(convoluted_BAE_HK ,  interleave_BAE_HK);
+            interleave(convoluted_BAE_HK +135, interleave_BAE_HK + 144);
+            for(int i=0; i<288; i++)
+                BAE_HEALTH_FINAL[i] = interleave_BAE_HK[i];
+            SD_WRITE(BAE_HEALTH_FINAL,FSC_CURRENT[5]+1,5);
+        }
+        
     } else {
-        for(int i = 0; i<128; i++)
+        gPC.printf("\rBAE HK data not recieved through I2C\n");
+        for(int i = 0; i<134; i++)
             BAE_HK[i] = 0;
     }
-    for(int i = 0; i<4; i++)
-        BAE_HK[i] = HK_time >> i;
-    BAE_HK_FRAME[0] = 0x28;
-    BAE_HK_FRAME[1] = FSC_CURRENT[5]+1;
-    BAE_HK_FRAME[2] = (FSC_CURRENT[5]+1) >> 8;
-    BAE_HK_FRAME[3] = (FSC_CURRENT[5]+1) >> 16;
-    for(int i = 0; i<128; i++)                       /*Adding actual CDMS Health data to TM frame*/
-        BAE_HK_FRAME[4+i] = BAE_HK[i];
-    crc = crc16_gen(BAE_HK_FRAME,132);               /*Adding CRC to TM frame*/
-    BAE_HK_FRAME[133] = crc;
-    BAE_HK_FRAME[132] = crc >> 8;
-    BAE_HEALTH.convolutionEncode(BAE_HK_FRAME , convoluted_BAE_HK);
-    BAE_HEALTH.convolutionEncode(BAE_HK_FRAME + 67, convoluted_BAE_HK + 135);
-    interleave(convoluted_BAE_HK ,  interleave_BAE_HK);
-    interleave(convoluted_BAE_HK +135, interleave_BAE_HK + 144);
-    for(int i=0; i<288; i++)
-        BAE_HEALTH_FINAL[i] = interleave_BAE_HK[i];
-    SD_WRITE(BAE_HEALTH_FINAL,FSC_CURRENT[5]+1,5);
-    gPC.printf("Completed BAE HK\n");
+    gPC.printf("\rCompleted BAE HK\n");
 
     /*----------------------------------Beacon message--------------------------------------*/
     unsigned char SC_HK_LBM_0[135];
@@ -135,7 +142,7 @@
     SC_HK_LBM_0[132] = crc;
     SC_HK_LBM_0[133] = crc >> 8;
     FCTN_I2C_WRITE((char *)SC_HK_LBM_0,135);
-    gPC.printf("Completed Beacon\n");
+    gPC.printf("\rCompleted Beacon\n");
 }
 
 int quantiz(float start,float step,float x)
--- a/DefinitionsAndGlobals.h	Tue Jul 05 09:35:50 2016 +0000
+++ b/DefinitionsAndGlobals.h	Wed Jul 06 07:24:28 2016 +0000
@@ -31,8 +31,8 @@
     DigitalOut PL_I2C_GPIO(PTC1);
             
 //I2C - CDMS to BAE
-    DigitalIn BAE_I2C_GPIO(PIN67);
-    DigitalOut CDMS_I2C_GPIO(PIN39);
+    DigitalIn BAE_I2C_GPIO(PIN67);//PTB21 from bae to cdms
+    DigitalOut CDMS_I2C_GPIO(PIN39);//PTA5 from cdms to bae 
 
 // TC LIST
     #define TCL_STATE_INCOMPLETE 0x00
@@ -272,7 +272,7 @@
 DigitalOut PYLD_EPS_DFF_PWR (PIN64);
 DigitalOut PYLD_EPS_DFF_PWR_CLK (PIN40);
 
-DigitalOut RESET_TO_BAE(PIN93);
+DigitalOut RESET_TO_BAE(PIN93,1);
 DigitalOut RESET_TO_PYLD(PIN21);
 
 //SD HK
--- a/FMS_all.h	Tue Jul 05 09:35:50 2016 +0000
+++ b/FMS_all.h	Wed Jul 06 07:24:28 2016 +0000
@@ -34,7 +34,7 @@
 
 void RST_HK_COUNTER();
 uint8_t CDMS_RD_SD_HK(uint8_t *);
-uint8_t CDMS_RD_RTC(uint64_t *);
+void CDMS_RD_RTC(uint64_t *);
 void CDMS_CALIB_RTC();
 void CDMS_RESET();
 
@@ -46,7 +46,7 @@
 
 void P_PL_MAIN()
 {
-    FCTN_CDMS_PL_MAIN((void *)NULL);
+   // FCTN_CDMS_PL_MAIN((void *)NULL);
 }
 
 void P_COM_INIT()
@@ -242,12 +242,24 @@
     return ACK;
 }
 
+void CDMS_RD_RTC(uint64_t *time)
+{
+    *time = FCTN_CDMS_RD_RTC();
+}
+
+void CDMS_CALIB_RTC()
+{
+    
+}
+
 void CDMS_RESET()
 {
     NVIC_SystemReset();    
 }
 
-void CDMS_INTERNAL_RESET()
+/*
+//void CDMS_INTERNAL_RESET()
 {
     
-}
\ No newline at end of file
+}
+*/
\ No newline at end of file
--- a/main.cpp	Tue Jul 05 09:35:50 2016 +0000
+++ b/main.cpp	Wed Jul 06 07:24:28 2016 +0000
@@ -107,7 +107,7 @@
     
     // DEBUG
     //gPC.puts("welcome to mng_tm_tc\r\n");
-    gPC.baud(115200);//changed for bypassing COM
+    gPC.baud(9600);//changed for bypassing COM
     
     // COMMON SPI
     spi.format(8,0);
@@ -152,7 +152,7 @@
     
     
     
-    while(1){
+    /*while(1){
     gPC.printf("PL_TC sending\r\n");
     
     Base_tm *tm_ptr = new Long_tm;
@@ -160,7 +160,7 @@
     wait(1);
     }
     gPC.printf("PL_TC sent");
-    
+    */
     // *******************INITIALISATIONS END********************
     
     FCTN_CDMS_HK_MAIN((void *)NULL);