To fix the hang problem

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:
Fri Dec 30 13:31:44 2016 +0000
Parent:
332:7d2431ce979f
Child:
336:4b4e5d4faf6d
Commit message:
Corrected MAX-MIN, corrected bae sw on after telecommand, ; Magesh added some correction.

Changed in this revision

CDMS_HK.h Show annotated file Show diff for this revision Revisions of this file
COM_POWER_OFF_TX.h Show annotated file Show diff for this revision Revisions of this file
COM_POWER_ON_TX.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
ThreadsAndFunctions.h Show annotated file Show diff for this revision Revisions of this file
adf.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	Wed Dec 28 04:25:18 2016 +0000
+++ b/CDMS_HK.h	Fri Dec 30 13:31:44 2016 +0000
@@ -15,7 +15,7 @@
 
 AnalogIn TempInput(PIN27);          // Input from Current Multiplexer
 AnalogIn CDMS_temp_sensor(PIN53);
-AnalogIn COMRX_RSSI_volatge(PIN70);
+AnalogIn COMRX_RSSI_VOLTAGE(PIN70);
 AnalogIn EPS_BTRY_VOLT (PIN54);
 
 DigitalOut SelectLinec3 (PIN79); // MSB of Select Lines
@@ -67,7 +67,7 @@
         CDMS_HK_MAIN_COUNTER++;
 
         FCTN_CDMS_HK();         //collects temperatures
-        RSSI_volatge = COMRX_RSSI_volatge.read() * 3.3;//to be checked
+        RSSI_VOLTAGE = COMRX_RSSI_VOLTAGE.read() * 3.3;//to be checked
         //VERIFY_COMRX();
         VERIFY_RTC();
         HANDLE_HW_FAULTS();
@@ -76,7 +76,7 @@
         uint8_t CDMS_quant[20];
         CDMS_quant[0]= COM_ADF_TMP+40;
         CDMS_quant[1]= (uint8_t)quant_data.CDMS_temp_quant;
-        CDMS_quant[2]= (uint8_t)RSSI_volatge;
+        CDMS_quant[2]= (uint8_t)(RSSI_VOLTAGE*10);
         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];
@@ -220,7 +220,7 @@
         beacon_array[19] = TIME_LATEST_SPI_SPEED >>16;
         beacon_array[20] = TIME_LATEST_SPI_SPEED >>8;
         beacon_array[21] = TIME_LATEST_SPI_SPEED;
-        beacon_array[22] = (uint8_t)RSSI_volatge;
+        beacon_array[22] = (uint8_t)(RSSI_VOLTAGE*10);
 
         // Add SC bits
         crc = crc16_gen(beacon_array,132);
@@ -258,8 +258,14 @@
 
 void minMaxHkData()
 {
+    MAX_COM_ADF_TMP = (MAX_COM_ADF_TMP < COM_ADF_TMP)?COM_ADF_TMP:MAX_COM_ADF_TMP;
+    MIN_COM_ADF_TMP = (MIN_COM_ADF_TMP > COM_ADF_TMP)?COM_ADF_TMP:MIN_COM_ADF_TMP;
+    
+    MAX_RSSI_VOLTAGE = (MAX_RSSI_VOLTAGE < RSSI_VOLTAGE)?RSSI_VOLTAGE:MAX_RSSI_VOLTAGE;
+    MIN_RSSI_VOLTAGE = (MIN_RSSI_VOLTAGE > RSSI_VOLTAGE)?RSSI_VOLTAGE:MIN_RSSI_VOLTAGE;
+    
     if(firstCount==true) {
-        for (int i = 4; i < 16; ++i) {
+        for (int i = 0; i < 16; ++i) {
             min_max_data.temp_min[i] = quant_data.temp_quant[i];
             min_max_data.temp_max[i] = quant_data.temp_quant[i];
         }
@@ -267,11 +273,9 @@
         min_max_data.CDMS_temp_min=quant_data.CDMS_temp_quant;
         min_max_data.CDMS_temp_max=quant_data.CDMS_temp_quant;
     } else {
-        for (int i = 4; i < 16; ++i) {
+        for (int i = 0; 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("\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);
@@ -391,12 +395,12 @@
 void VERIFY_COMRX()
 {
     //COMRX_OC_FAULT //$
-    if(COMRX_OC_FAULT==0 && RSSI_volatge > 0.4) {
+    if(COMRX_OC_FAULT==0 && RSSI_VOLTAGE > 0.4) {
         COMRX_STATUS = COMRX_ALIVE;
     } else {
         //RESET_COMRX();
         COMRX_RESET_COUNTER++;
-        if(COMRX_OC_FAULT==0 && RSSI_volatge > 0.4)
+        if(COMRX_OC_FAULT==0 && RSSI_VOLTAGE > 0.4)
             COMRX_STATUS = COMRX_ALIVE;
         else
             COMRX_STATUS = COMRX_DEAD;
--- a/COM_POWER_OFF_TX.h	Wed Dec 28 04:25:18 2016 +0000
+++ b/COM_POWER_OFF_TX.h	Fri Dec 30 13:31:44 2016 +0000
@@ -80,7 +80,7 @@
     gFLAGS = gFLAGS & (~RF_SW_STATUS_FLAG);/*RF_SW_STATUS_FLAG set to RF_COM_BCN*/\
     if( gFLAGS & COM_AUTO_POWER_OFF_BAE_FLAG ){\
         /*gPC.puts("powering on bae\r\n")*/;\
-        SW_ON_BAE;\
+        SW_ON_BAE();\
         gFLAGS & (~COM_AUTO_POWER_OFF_BAE_FLAG);\
         gPC.puts("resumning bcn\r\n");\
         resume_bcn;\
--- a/COM_POWER_ON_TX.h	Wed Dec 28 04:25:18 2016 +0000
+++ b/COM_POWER_ON_TX.h	Fri Dec 30 13:31:44 2016 +0000
@@ -146,6 +146,7 @@
                 else{
                     gPC.puts("not A0\r\n");
                     SW_RST_BAE();
+                    wait_ms(100);
                     Base_tm *tm_ptr2 = NULL;
                     gPC.puts("settin bcn off\r\n");
                     SET_BCN_STANDBY(tm_ptr2);
--- a/DefinitionsAndGlobals.h	Wed Dec 28 04:25:18 2016 +0000
+++ b/DefinitionsAndGlobals.h	Fri Dec 30 13:31:44 2016 +0000
@@ -267,13 +267,17 @@
 uint16_t PL_FAULTCOUNT = 0;
 bool BAE_HK_I2C;
 uint8_t RTC_STATUS;
-float RSSI_volatge;
+float RSSI_VOLTAGE;
 uint8_t COM_ADF_TMP = 0;
 uint8_t COM_PA_IC_TMP = 0;
 
 CDMS_HK_actual actual_data;
 CDMS_HK_quant quant_data;
 CDMS_HK_min_max min_max_data;
+uint8_t MAX_COM_ADF_TMP;
+uint8_t MIN_COM_ADF_TMP;
+float MAX_RSSI_VOLTAGE;
+float MIN_RSSI_VOLTAGE;
 bool firstCount=true;
 
 //GPIO PINS
--- a/FMS_all.h	Wed Dec 28 04:25:18 2016 +0000
+++ b/FMS_all.h	Fri Dec 30 13:31:44 2016 +0000
@@ -215,6 +215,7 @@
     BAE_SW_EN_DS = 0;
     wait_ms(10);
     BAE_SW_EN_DS = 1;
+    wait_ms(100);
     BAE_STATUS = DEVICE_POWERED;
     FCTN_CDMS_WR_FLASH(1,DEVICE_POWERED);
     gPC.printf("rst bae\n");
@@ -353,16 +354,22 @@
 
 void FCTN_CDMS_MAX_MIN(Base_tm *tm_pointer)
 { 
-    for(int i=0;i<16;i++)
-    {
-        //tm_pointer->TM_string[i] = 0;
-        tm_pointer->TM_string[i+7] = (uint8_t)min_max_data.temp_max[i];
-    }
+    tm_pointer->TM_string[4] = MAX_COM_ADF_TMP+40;
+    tm_pointer->TM_string[6] = (uint8_t)(MAX_RSSI_VOLTAGE*10);
     
     for(int i=0;i<16;i++)
     {
         //tm_pointer->TM_string[i] = 0;
-        tm_pointer->TM_string[i+26] = (uint8_t)min_max_data.temp_min[i];
+        tm_pointer->TM_string[i+7] = (uint8_t)(min_max_data.temp_max[i]);
+    }
+    
+    tm_pointer->TM_string[23] = MIN_COM_ADF_TMP+40;
+    tm_pointer->TM_string[25] = (uint8_t)(MIN_RSSI_VOLTAGE*10);
+    
+    for(int i=0;i<16;i++)
+    {
+        //tm_pointer->TM_string[i] = 0;
+        tm_pointer->TM_string[i+26] = (uint8_t)(min_max_data.temp_min[i]);
     }
 
     tm_pointer->TM_string[42] = GPIO_STATUS>>8;
--- a/ThreadsAndFunctions.h	Wed Dec 28 04:25:18 2016 +0000
+++ b/ThreadsAndFunctions.h	Fri Dec 30 13:31:44 2016 +0000
@@ -181,7 +181,7 @@
             }
         }
         else if( gFLAGS & NEW_TC_RECEIVED ){
-            gPC.puts("NEW TC RECEIVED\r\n");
+            gPC.puts("\n\n\rNEW TC RECEIVED\r\n");
             /*Thread::wait(2000);*/
             gFLAGS = gFLAGS & (~NEW_TC_RECEIVED);
             gFLAGS = gFLAGS | COM_MNG_TMTC_RUNNING_FLAG;
--- a/adf.h	Wed Dec 28 04:25:18 2016 +0000
+++ b/adf.h	Fri Dec 30 13:31:44 2016 +0000
@@ -11,7 +11,7 @@
 bool buffer_state;
 bool finish_write_data;
 uint8_t signal = 0x00;
-unsigned char bbram_buffer[66]={0x19,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x00,0xFB,0xC2,0x10,0xC0,0x00,0x30,0x31,0x07,0x00,0x01,0x00,/*PA Level Byte*/0x57/*PA Parameters*/,0x00,0x0B,0x37,0x00,0x00,0x40,0x0C,0x00,0x05,0x00,0x00,0x18,0x12,0x34,0x56,0x20,0x10,0xC4,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0xE0,0x00,0x10,0x04,0x00,0x00,0x00,0x00,0x00};
+unsigned char bbram_buffer[66]={0x19,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x00,0xFB,0xC2,0x10,0xC0,0x00,0x30,0x31,0x07,0x00,0x01,0x00,/*PA Level Byte*/0x57/*PA Parameters*/,0x08/*GMSK_modulation*/,0x0B,0x37,0x00,0x00,0x40,0x0C,0x00,0x05,0x00,0x00,0x18,0x12,0x34,0x56,0x20,0x10,0xC4,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0xE0,0x00,0x10,0x04,0x00,0x00,0x00,0x00,0x00};
 bool data_irq_err=0;
 bool data_err= false;
 unsigned char temp_byte=0x00;
--- a/main.cpp	Wed Dec 28 04:25:18 2016 +0000
+++ b/main.cpp	Fri Dec 30 13:31:44 2016 +0000
@@ -88,14 +88,12 @@
     TIME_LATEST_CDSMS_RESET = FCTN_CDMS_RD_RTC() >> 7;
     FCTN_CDMS_WR_FLASH(8,TIME_LATEST_CDSMS_RESET);
     
-    /*uint8_t test[512];
+    uint8_t test[512];
     for(int i =0; i<512; i++)
         test[i] = 0;
-    disk_write(test,80000);*/
+    disk_write(test,80000);
     //SD_MNG_SECT = SD_LIB_BLK_CURRENT;
     FCTN_SD_MNGR();
-    
-    
 
     #if DEBUG
     gPC.puts("welcome to mng_tmtc\r\n");