publishing to check changes in cdms code

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE_samp_23SEP_DMA_flag by samp Srinivasan

Revision:
255:642ea552ac77
Parent:
251:c766afa330a3
diff -r c766afa330a3 -r 642ea552ac77 CDMS_HK.h
--- a/CDMS_HK.h	Mon Jul 11 12:30:41 2016 +0000
+++ b/CDMS_HK.h	Mon Jul 11 14:33:02 2016 +0000
@@ -1,5 +1,3 @@
-
-
 void FCTN_CDMS_HK_MAIN();
 void FCTN_CDMS_HK();
 void VERIFY_COMRX();
@@ -41,8 +39,8 @@
 {
     while(1)
     {
+    gHK_THREAD->signal_wait(HK_SIGNAL);
     gPC.printf("Entering HK thread");
-    gHK_THREAD->signal_wait(HK_SIGNAL);
 
     gMutex.lock();
 
@@ -56,29 +54,28 @@
     HANDLE_HW_FAULTS();
     FUNC_CDMS_GPIO_STATUS(); //yet to be done
 
-    uint8_t CDMS_quant[19];
+    uint8_t CDMS_quant[20];
+    CDMS_quant[1]= (uint8_t)quant_data.CDMS_temp_quant;
+    CDMS_quant[2]= (uint8_t)RSSI_volatge;
     for(int i=0; i<16; i++) {
-        CDMS_quant[i]= (uint8_t)quant_data.temp_quant[i];
+        CDMS_quant[i+4]= (uint8_t)quant_data.temp_quant[i];
     }
-    CDMS_quant[16]= (uint8_t)RSSI_volatge;
-    CDMS_quant[17]= (uint8_t)quant_data.CDMS_temp_quant;
     minMaxHkData();
 
-    uint64_t time = FCTN_CDMS_RD_RTC();             //Reading Time from RTC
-    gPC.printf("0x%08X \n",time);
-    time = time>>7;
-    uint32_t HK_time = (uint32_t)time;
-    for(int i = 0; i<4; i++)
-        CDMS_HEALTH_DATA[i] = HK_time >> i;
+    CDMS_HEALTH_DATA[1] = GPIO_STATUS;            //Reading GPIO Pins
+    CDMS_HEALTH_DATA[0] = GPIO_STATUS >> 8;
+    COLLECT_CDMS_RAM();
+    for(int i = 0;i<84;i++)
+        CDMS_HEALTH_DATA[2+i] = CDMS_RAM[i];                  //Reading RAM parameters
+    for(int i = 0;i<20;i++)                                   //Collecting Data from Temp sensors
+        CDMS_HEALTH_DATA[86+i] = CDMS_quant[i];
 
-    // Here: Have to FIT flash data.
-    for(int i = 0; i<19; i++)                       //Collecting Data from Temp sensors
-        CDMS_HEALTH_DATA[i+24] = CDMS_quant[i];
+    // Here: Have to FIT flash data.    
+    
+    uint64_t time = FCTN_CDMS_RD_RTC() >> 7;             //Reading Time from RTC
+    for(int i = 124; i<128; i++)
+        CDMS_HEALTH_DATA[i] = time >> i*8;
 
-    COLLECT_CDMS_RAM();                             //Reading RAM parameters
-
-    CDMS_HEALTH_DATA[126] = GPIO_STATUS;            //Reading GPIO Pins
-    CDMS_HEALTH_DATA[127] = GPIO_STATUS >> 8;
     FCTN_SD_MNGR();                                 //Adding FSC & TMID to TM frame
     CDMS_HK_FRAME[0] = 0x20;
     CDMS_HK_FRAME[1] = FSC_CURRENT[4]+1;
@@ -91,7 +88,7 @@
     uint16_t crc = crc16_gen(CDMS_HK_FRAME,132);      /*Adding CRC to TM frame*/
     CDMS_HK_FRAME[133] = crc;
     CDMS_HK_FRAME[132] = crc >> 8;
-    
+
     exor(CDMS_HK_FRAME);
     CDMS_HEALTH.convolutionEncode(CDMS_HK_FRAME , convoluted_CDMS_HK);
     CDMS_HEALTH.convolutionEncode(CDMS_HK_FRAME + 67, convoluted_CDMS_HK + 135);
@@ -100,7 +97,7 @@
     for(int i=0; i<288; i++)
         CDMS_HEALTH_FINAL[i] = interleave_CDMS_HK[i];
 
-    //SD_WRITE(CDMS_HEALTH_FINAL,FSC_CURRENT[4]+1,4);
+    SD_WRITE(CDMS_HEALTH_FINAL,FSC_CURRENT[4]+1,4);
     gPC.printf("\rCompleted CDMS HK\n");
 
     /*---------------------------------- BAE HK --------------------------------------------*/
@@ -115,7 +112,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[i] = time >> i;
             BAE_HK_FRAME[0] = 0x28;
             BAE_HK_FRAME[1] = FSC_CURRENT[5]+1;
             BAE_HK_FRAME[2] = (FSC_CURRENT[5]+1) >> 8;
@@ -280,6 +277,10 @@
     GPIO_STATUS=(PL_BEE_SW_OC_FAULT)?(GPIO_STATUS)||((uint16_t)(0x1<<5)):(GPIO_STATUS)&(~((uint16_t)(0x1<<5)));
     //PL_EPS_LATCH_SW_OC_FAULT // to be verified
     GPIO_STATUS=(PL_EPS_LATCH_SW_OC_FAULT)?(GPIO_STATUS)||((uint16_t)(0x1<<4)):(GPIO_STATUS)&(~((uint16_t)(0x1<<4)));
+    //EPS_V_C_EN_STATUS
+    GPIO_STATUS=(EPS_V_C_EN_STATUS)?(GPIO_STATUS)||((uint16_t)(0x1<<3)):(GPIO_STATUS)&(~((uint16_t)(0x1<<3)));
+    //EPS_V_D_EN_STATUS
+    GPIO_STATUS=(EPS_V_D_EN_STATUS)?(GPIO_STATUS)||((uint16_t)(0x1<<2)):(GPIO_STATUS)&(~((uint16_t)(0x1<<2)));
     
 }
 
@@ -398,72 +399,56 @@
 
 void COLLECT_CDMS_RAM()
 {
-    /*--------------------Current FSC's---------------------*/
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+43] = FSC_LAST[5] >> (i*8);
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+47] = FSC_CURRENT[5] >> (i*8);
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+51] = FSC_LAST[4] >> (i*8);
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+55] = FSC_CURRENT[4] >> (i*8);
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+59] = FSC_LAST[3] >> (i*8);
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+63] = FSC_CURRENT[3] >> (i*8);
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+67] = FSC_LAST[2] >> (i*8);
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+71] = FSC_CURRENT[2] >> (i*8);
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+75] = FSC_LAST[1] >> (i*8);
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+79] = FSC_CURRENT[1] >> (i*8);
-    /*---------------------Latest Time----------------------*/
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+83] = TIME_LATEST_SPI_SPEED >> (i*8);
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+87] = TIME_LATEST_SD_RD >> (i*8);
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+91] = TIME_LATEST_SD_WR >> (i*8);
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+95] = TIME_LATEST_I2C_SPEED >> (i*8);
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+99] = TIME_LATEST_I2C_BAE >> (i*8);
-    for(int i=0; i<4; i++)
-        CDMS_HEALTH_DATA[i+103] = TIME_LATEST_RTC >> (i*8);
-    for(int i=0; i<2; i++)
-        CDMS_HEALTH_DATA[i+107] = COMRX_RESET_COUNTER >> (i*8);
-    for(int i=0; i<2; i++)
-        CDMS_HEALTH_DATA[i+107] = PL_RCV_SC_DATA_COUNTER >> (i*8);
-    for(int i=0; i<2; i++)
-        CDMS_HEALTH_DATA[i+111] = PL_MAIN_COUNTER >> (i*8);
-    for(int i=0; i<2; i++)
-        CDMS_HEALTH_DATA[i+113] = CDMS_HK_MAIN_COUNTER >> (i*8);
-    for(int i=0; i<2; i++)
-        CDMS_HEALTH_DATA[i+115] = CDMS_I2C_ERR_BAE_COUNTER >> (i*8);
-    for(int i=0; i<2; i++)
-        CDMS_HEALTH_DATA[i+117] = CDMS_I2C_ERR_SPEED_COUNTER >> (i*8);
-    CDMS_HEALTH_DATA[120] = CDMS_HEALTH_DATA[120] | CDMS_STANDBY_PL << 7;
-    CDMS_HEALTH_DATA[120] = CDMS_HEALTH_DATA[120] | ((CDMS_INIT_STATUS << 6) & 0x40);
-    CDMS_HEALTH_DATA[120] = CDMS_HEALTH_DATA[120] | ((CDMS_HK_MAIN_STATUS << 5) & 0x20);
-    CDMS_HEALTH_DATA[120] = CDMS_HEALTH_DATA[120] | ((CDMS_HK_STATUS << 3) & 0x18);
-    CDMS_HEALTH_DATA[120] = CDMS_HEALTH_DATA[120] | ((COMRX_STATUS << 2) & 0x04);
-    CDMS_HEALTH_DATA[120] = CDMS_HEALTH_DATA[120] | ((CDMS_RTC_BL << 1) & 0x02);
-    CDMS_HEALTH_DATA[120] = CDMS_HEALTH_DATA[120] & 0xFE;
-
-    CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | PL_RCV_SC_DATA_STATUS << 7;
-    CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | ((COM_SESSION << 6) & 0x40);
-    CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | ((COM_RX << 5) & 0x20);
-    CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | ((RF_SW_STATUS << 4) & 0x10);
-    CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | ((COM_TX << 3) & 0x08);
-    CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | ((COM_TX_STATUS << 2) & 0x04);
-    CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | ((COM_MNG_TMTC << 1) & 0x02);
-    CDMS_HEALTH_DATA[121] = CDMS_HEALTH_DATA[121] | (CDMS_STANDBY_HK & 0x01);
-
-    CDMS_HEALTH_DATA[122] = CDMS_HEALTH_DATA[122] | PL_INIT_STATUS << 7;
-    CDMS_HEALTH_DATA[122] = CDMS_HEALTH_DATA[122] | ((PL_MAIN_STATUS << 6) & 0x40);
-    CDMS_HEALTH_DATA[122] = CDMS_HEALTH_DATA[122] | ((PL_LOW_POWER << 5) & 0x20);
-    CDMS_HEALTH_DATA[122] = CDMS_HEALTH_DATA[122] | ((PL_STATE << 3) & 0x18);
-    CDMS_HEALTH_DATA[122] = CDMS_HEALTH_DATA[122] | (PL_STATUS & 0x07);
+    CDMS_RAM[0] = ((PL_INIT_STATUS<<7)&0x80)|((PL_MAIN_STATUS<<6)&0x40)|((PL_LOW_POWER<<5)&0x20)|((PL_STATE<<3)&0x18)|(PL_STATUS&0x07);
+    CDMS_RAM[1] = ((PL_RCV_SC_DATA_STATUS<<7)&0x80)|((COM_SESSION<<6)&0x40)|((COM_RX<<5)&0x20)|((RF_SW_STATUS<<4)&0x10)|((COM_TX<<3)&0x08)|((COM_TX_STATUS<<2)&0x04)|((COM_MNG_TMTC<<1)&0x02)|(EN_CDMS_HK&0x01);
+    CDMS_RAM[2] = ((EN_PL<<7)&0x80)|((EN_RCV_SC<<6)&0x40)|((CDMS_INIT_STATUS<<5)&0x20)|((CDMS_HK_MAIN_STATUS<<4)&0x10)|((CDMS_HK_STATUS<<2)&0x0C)|((COM_RX_STATUS<<1)&0x02)|(CDMS_RTC_BL&0x01);
+    CDMS_RAM[3] = CDMS_I2C_ERR_SPEED_COUNTER >> 8;
+    CDMS_RAM[4] = CDMS_I2C_ERR_SPEED_COUNTER;
+    CDMS_RAM[5] = CDMS_I2C_ERR_BAE_COUNTER >> 8;
+    CDMS_RAM[6] = CDMS_I2C_ERR_BAE_COUNTER;
+    CDMS_RAM[7] = CDMS_HK_MAIN_COUNTER >> 8;
+    CDMS_RAM[8] = CDMS_HK_MAIN_COUNTER;
+    CDMS_RAM[9] = PL_MAIN_COUNTER >> 8;
+    CDMS_RAM[10] = PL_MAIN_COUNTER;
+    CDMS_RAM[11] = PL_RCV_SC_DATA_COUNTER >> 8;
+    CDMS_RAM[12] = PL_RCV_SC_DATA_COUNTER;
+    CDMS_RAM[13] = COMRX_RESET_COUNTER >> 8;
+    CDMS_RAM[14] = COMRX_RESET_COUNTER;
+    CDMS_RAM[15] = CDMS_WR_SD_FAULT_COUNTER >> 8;
+    CDMS_RAM[16] = CDMS_WR_SD_FAULT_COUNTER;
+    CDMS_RAM[17] = SD_LIB_WRITES >> 8;
+    CDMS_RAM[18] = SD_LIB_WRITES;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[19+i] = TIME_LATEST_RTC >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[23+i] = TIME_LATEST_I2C_BAE >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[27+i] = TIME_LATEST_I2C_SPEED >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[31+i] = TIME_LATEST_SD_WR >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[35+i] = TIME_LATEST_SD_RD >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[39+i] = TIME_LATEST_SPI_SPEED >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[43+i] = FSC_CURRENT[1] >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[47+i] = FSC_LAST[1] >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[51+i] = FSC_CURRENT[2] >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[55+i] = FSC_LAST[2] >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[59+i] = FSC_CURRENT[3] >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[63+i] = FSC_LAST[3] >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[67+i] = FSC_CURRENT[4] >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[71+i] = FSC_LAST[4] >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[75+i] = FSC_CURRENT[5] >> i*8;
+    for(int i = 0; i<4; i++)
+        CDMS_RAM[79+i] = FSC_LAST[5] >> i*8;
+    CDMS_RAM[83] = 0x00;
 }
\ No newline at end of file