Repository for CDMS code

Dependencies:   SimpleDMA mbed-rtos mbed eeprom

Fork of COM_MNG_TMTC_SIMPLE by Shreesha S

Revision:
315:f9a30c8cbe96
Parent:
313:5d06a08baf0e
Child:
327:5a967a66c10f
diff -r 9f1b654a0b54 -r f9a30c8cbe96 CDMS_HK.h
--- a/CDMS_HK.h	Wed Dec 07 06:38:22 2016 +0000
+++ b/CDMS_HK.h	Thu Dec 08 10:12:15 2016 +0000
@@ -16,6 +16,7 @@
 AnalogIn TempInput(PIN27);          // Input from Current Multiplexer
 AnalogIn CDMS_temp_sensor(PIN53);
 AnalogIn COMRX_RSSI_volatge(PIN70);
+AnalogIn EPS_BTRY_VOLT (PIN54);
 
 
 DigitalOut SelectLinec3 (PIN79); // MSB of Select Lines
@@ -81,6 +82,7 @@
     uint8_t CDMS_quant[20];
     CDMS_quant[1]= (uint8_t)quant_data.CDMS_temp_quant;
     CDMS_quant[2]= (uint8_t)RSSI_volatge;
+    CDMS_quant[3]= (uint8_t)(EPS_BTRY_VOLT*33*(62.0/11));
     for(int i=0; i<16; i++) {
         CDMS_quant[i+4]= (uint8_t)quant_data.temp_quant[i];
     }
@@ -116,8 +118,9 @@
     
     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;
-    //gPC.printf("0x%d\n",time);
+        CDMS_HEALTH_DATA[i] = time >> (i-124)*8;
+    gPC.printf("0x%d\n",time);
+    gPC.printf("HK ARCH TIME TAGGED");
     FCTN_SD_MNGR();                                 //Adding FSC & TMID to TM frame
     CDMS_HK_FRAME[0] = 0x20;
     CDMS_HK_FRAME[1] = FSC_CURRENT[4]+1;
@@ -209,7 +212,7 @@
     beacon_array[7] = SD_FAULTCOUNT;
     beacon_array[8] = RTC_FAULTCOUNT >> 8;
     beacon_array[9] = RTC_FAULTCOUNT;
-    beacon_array[10] = (((SD_STATUS == DEVICE_DISABLED || SD_STATUS == DEVICE_OC_FAULT)?1:0)<<7)|(RTC_STATUS <<6)|(COM_RX_STATUS<<3)|(V_C_PGOOD<<2)|(COMRX_OC_FAULT<<1)|(COM_TX_OC_FAULT);
+    beacon_array[10] = (((SD_STATUS == DEVICE_DISABLED || SD_STATUS == DEVICE_OC_FAULT)?1:0)<<7)|(RTC_STATUS <<6)|(COM_RX_STATUS<<3)|(0<<2)|(COMRX_OC_FAULT<<1)|(COM_TX_OC_FAULT);
     beacon_array[11] = (COM_RX_CNTRL <<7)|(COM_TX_CNTRL);
     beacon_array[12] = CDMS_HK_MAIN_COUNTER >>8;
     beacon_array[13] = CDMS_HK_MAIN_COUNTER;
@@ -270,8 +273,8 @@
         for (int i = 4; i < 16; ++i) {
             min_max_data.temp_min[i] = saveMin(min_max_data.temp_min[i],quant_data.temp_quant[i]);
             min_max_data.temp_max[i] = saveMax(min_max_data.temp_max[i],quant_data.temp_quant[i]);
-    //        gPC.printf("\Max reading, iteration = %d, %d \n",min_max_data.temp_max[i], i);
-     //       gPC.printf("\Min reading, iteration = %d, %d \n",min_max_data.temp_min[i], i);
+            //gPC.printf("\rMax reading, iteration = %d, %d \n",min_max_data.temp_max[i], i);
+            //gPC.printf("\rMin reading, iteration = %d, %d \n",min_max_data.temp_min[i], i);
         }
 
         min_max_data.CDMS_temp_min = saveMin(min_max_data.CDMS_temp_min,quant_data.CDMS_temp_quant);
@@ -314,12 +317,11 @@
     for(Iteration=0; Iteration<16; Iteration++) {
 
         if(Iteration<4)
-            {actual_data.temp_actual[Iteration]=actual_data.temp_actual[Iteration]*3.3*2;
-         //   gPC.printf("\rVoltage reading, iteration = %f, %d \n",actual_data.temp_actual[Iteration], Iteration);
-          //  wait_ms(1);
+        {
+            actual_data.temp_actual[Iteration]=actual_data.temp_actual[Iteration]*3.3*2*10;
         }
         else if(Iteration<14)
-           {
+        {
             resistance=24000*actual_data.temp_actual[Iteration]*3.3/(3.3-actual_data.temp_actual[Iteration]*3.3);
            
             if(actual_data.temp_actual[Iteration]*3.3<1.47)      //Document says 1.378 .Pls Check
@@ -351,6 +353,7 @@
 
 void FUNC_CDMS_GPIO_STATUS()       //Polls the status of Input GPIO PINS
 {
+    /*
     //V_A_PGOOD //TRZ EN
     GPIO_STATUS=(V_A_PGOOD)?(GPIO_STATUS)|((uint16_t)(0x1<<15)):(GPIO_STATUS)&(~((uint16_t)(0x1<<15)));
     //V_B_PGOOD_1 //3V3BPGOOD //$
@@ -359,27 +362,34 @@
     GPIO_STATUS=(V_B_PGOOD_2)?(GPIO_STATUS)|((uint16_t)(0x1<<13)):(GPIO_STATUS)&(~((uint16_t)(0x1<<13)));
     //V_C_PGOOD //3V3CPGOOD //$
     GPIO_STATUS=(V_C_PGOOD)?(GPIO_STATUS)|((uint16_t)(0x1<<12)):(GPIO_STATUS)&(~((uint16_t)(0x1<<12)));
+    */
+    
     //COMRX_OC_FAULT //$
     GPIO_STATUS=(COMRX_OC_FAULT)?(GPIO_STATUS)|((uint16_t)(0x1<<11)):(GPIO_STATUS)&(~((uint16_t)(0x1<<11)));
     // COMTX_OC_FAULT //$
     GPIO_STATUS=(COM_TX_OC_FAULT)?(GPIO_STATUS)|((uint16_t)(0x1<<10)):(GPIO_STATUS)&(~((uint16_t)(0x1<<10)));
+    // CDMS_SD_OC_FAULT
+    GPIO_STATUS=(SD_OC_FAULT)?(GPIO_STATUS)|((uint16_t)(0x1<<9)):(GPIO_STATUS)&(~((uint16_t)(0x1<<9)));
     //BAE_OC_FAULT //$
-    GPIO_STATUS=(BAE_OC_FAULT)?(GPIO_STATUS)|((uint16_t)(0x1<<9)):(GPIO_STATUS)&(~((uint16_t)(0x1<<9)));
-  
+    GPIO_STATUS=(BAE_OC_FAULT)?(GPIO_STATUS)|((uint16_t)(0x1<<8)):(GPIO_STATUS)&(~((uint16_t)(0x1<<8)));
+    
+    /*
     //PL_GPIO_1_STATUS //$
     GPIO_STATUS=(PL_GPIO_1_STATUS)?(GPIO_STATUS)|((uint16_t)(0x1<<8)):(GPIO_STATUS)&(~((uint16_t)(0x1<<8)));
     //PL_GPIO_2_STATUS //$
     GPIO_STATUS=(PL_GPIO_2_STATUS)?(GPIO_STATUS)|((uint16_t)(0x1<<7)):(GPIO_STATUS)&(~((uint16_t)(0x1<<7)));
     //PL_GPIO_3_STATUS //$
     GPIO_STATUS=(PL_GPIO_3_STATUS)?(GPIO_STATUS)|((uint16_t)(0x1<<6)):(GPIO_STATUS)&(~((uint16_t)(0x1<<6)));
+    */
+    
     //PL_BEE_SW_OC_FAULT //to be verified
-    GPIO_STATUS=(PL_BEE_SW_OC_FAULT)?(GPIO_STATUS)|((uint16_t)(0x1<<5)):(GPIO_STATUS)&(~((uint16_t)(0x1<<5)));
+    GPIO_STATUS=(PL_BEE_SW_OC_FAULT)?(GPIO_STATUS)|((uint16_t)(0x1<<4)):(GPIO_STATUS)&(~((uint16_t)(0x1<<4)));
     //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)));
+    GPIO_STATUS=(PL_EPS_LATCH_SW_OC_FAULT)?(GPIO_STATUS)|((uint16_t)(0x1<<3)):(GPIO_STATUS)&(~((uint16_t)(0x1<<3)));
     //EPS_V_C_EN_STATUS
-    GPIO_STATUS=(COM_RX_CNTRL)?(GPIO_STATUS)|((uint16_t)(0x1<<3)):(GPIO_STATUS)&(~((uint16_t)(0x1<<3)));
+    GPIO_STATUS=(COM_RX_CNTRL)?(GPIO_STATUS)|((uint16_t)(0x1<<2)):(GPIO_STATUS)&(~((uint16_t)(0x1<<2)));
     //EPS_V_D_EN_STATUS
-    GPIO_STATUS=(COM_TX_CNTRL)?(GPIO_STATUS)|((uint16_t)(0x1<<2)):(GPIO_STATUS)&(~((uint16_t)(0x1<<2)));
+    GPIO_STATUS=(COM_TX_CNTRL)?(GPIO_STATUS)|((uint16_t)(0x1<<1)):(GPIO_STATUS)&(~((uint16_t)(0x1<<1)));
   //  gPC.printf("%04x\n",GPIO_STATUS);
    gPC.printf("\rBAE_OC STATE = %04x \n",GPIO_STATUS);
 }
@@ -583,4 +593,5 @@
     for(int i = 0; i<4; i++)
         CDMS_RAM[79+i] = FSC_LAST[5] >> (3-i)*8;
     CDMS_RAM[83] = 0x00;
+    gPC.printf("\n\r%d %d %d %d %d",FSC_CURRENT[1],FSC_CURRENT[2],FSC_CURRENT[3],FSC_CURRENT[4],FSC_CURRENT[5]);
 }
\ No newline at end of file