
Repository for CDMS code
Dependencies: SimpleDMA mbed-rtos mbed eeprom
Fork of COM_MNG_TMTC_SIMPLE by
Revision 218:c63cdba0550f, committed 2016-07-03
- Comitter:
- chaithanyarss
- Date:
- Sun Jul 03 15:25:24 2016 +0000
- Parent:
- 216:93505a6f8db7
- Child:
- 219:8e8396f15bc2
- Commit message:
- Flash Completed;
Changed in this revision
--- a/COM_MNG_TMTC.h Sun Jul 03 11:35:55 2016 +0000 +++ b/COM_MNG_TMTC.h Sun Jul 03 15:25:24 2016 +0000 @@ -974,7 +974,7 @@ ++modify_overflow;\ }\ else{\ - RESET_CDMS();\ + RESET_CDMS;\ break;\ }\ }\ @@ -997,7 +997,7 @@ ++modify_overflow;\ }\ else{\ - RESET_CDMS();\ + RESET_CDMS;\ break;\ }\ }\ @@ -1128,7 +1128,7 @@ ++overflowCountOBONLY;\ }\ else{\ - RESET_CDMS();\ + RESET_CDMS;\ break;\ }\ }\ @@ -1147,7 +1147,7 @@ ++overCount;\ }\ else{\ - RESET_CDMS();\ + RESET_CDMS;\ break;\ }\ }\ @@ -1214,7 +1214,7 @@ ++overflowCountExecute;\ }\ else{\ - RESET_CDMS();\ + RESET_CDMS;\ break;\ }\ }\ @@ -1249,7 +1249,7 @@ /*DETECT ACK OR NACK*/\ uint8_t temp83 = 0x00;\ uint8_t temp84 = GETpacket_seq_count(current_TC);\ - detect_ack(put_tm_here, temp83, temp84);\ + detect_ack(put_tm_here, temp83);\ if( temp83 == 0x01){\ uint16_t temp16 = TC_STATE_SUCCESSFULLY_EXECUTED;\ PUTexec_status(current_TC, temp16);\ @@ -1292,7 +1292,7 @@ ++overflowCountExecute;\ }\ else{\ - RESET_CDMS();\ + RESET_CDMS;\ break;\ }\ }\ @@ -1333,7 +1333,7 @@ ++overflowCountExecute;\ }\ else{\ - RESET_CDMS();\ + RESET_CDMS;\ break;\ }\ }\ @@ -1404,7 +1404,7 @@ ++overflowCountExecute;\ }\ else{\ - RESET_CDMS();\ + RESET_CDMS;\ break;\ }\ }\ @@ -1444,7 +1444,7 @@ ++overflowCountExecute;\ }\ else{\ - RESET_CDMS();\ + RESET_CDMS;\ break;\ }\ }\ @@ -1456,7 +1456,7 @@ ++overflowCount;\ }\ else{\ - RESET_CDMS();\ + RESET_CDMS;\ break;\ }\ }\
--- a/COM_POWER_OFF_TX.h Sun Jul 03 11:35:55 2016 +0000 +++ b/COM_POWER_OFF_TX.h Sun Jul 03 15:25:24 2016 +0000 @@ -1,70 +1,3 @@ -#define RESET_CDMS {\ - Base_tc *RESET_tc = new Short_tc;\ - RESET_tc->next_TC = NULL;\ - PUTshort_or_long(RESET_tc,SHORT_TC_CODE);\ - PUTcrc_pass(RESET_tc,0x1);\ - PUTexec_status(RESET_tc,0);\ - RESET_tc->TC_string[0] = 0x01;\ - RESET_tc->TC_string[1] = 0x81;\ - RESET_tc->TC_string[2] = 0x81;\ - RESET_tc->TC_string[3] = 0x38;\ - RESET_tc->TC_string[4] = 0;\ - RESET_tc->TC_string[5] = 0;\ - RESET_tc->TC_string[6] = 0;\ - RESET_tc->TC_string[7] = 0;\ - RESET_tc->TC_string[8] = 0;\ - uint16_t crc16 = crc16_gen(RESET_tc->TC_string, 9);\ - RESET_tc->TC_string[9] = (crc16 & 0xFF00)>>8;\ - RESET_tc->TC_string[10] = (crc16 & 0x00FF);\ - Base_tm *tm_ptr = NULL;\ - tm_ptr = FCTN_CDMS_RLY_TMTC(RESET_tc);\ - delete RESET_tc;\ - /*DELETE THE TM AFTER USE*/\ - Base_tm *del_tm = tm_ptr;\ - while( del_tm != NULL ){\ - Base_tm *temp = del_tm->next_TM;\ - delete del_tm;\ - del_tm = temp;\ - }\ -} - -#define power_on_bae {\ - Base_tc *power_on_BAE = new Short_tc;\ - power_on_BAE->next_TC = NULL;\ - PUTshort_or_long(power_on_BAE,SHORT_TC_CODE);\ - PUTcrc_pass(power_on_BAE,0x1);\ - PUTexec_status(power_on_BAE,0);\ - power_on_BAE->TC_string[0] = 0x01;\ - power_on_BAE->TC_string[1] = BAE_APID_SOURCE;\ - power_on_BAE->TC_string[2] = BAE_SERVICE;\ - power_on_BAE->TC_string[3] = BAE_POWER_ON_PID;\ - power_on_BAE->TC_string[4] = 0;\ - power_on_BAE->TC_string[5] = 0;\ - power_on_BAE->TC_string[6] = 0;\ - power_on_BAE->TC_string[7] = 0;\ - power_on_BAE->TC_string[8] = 0;\ - uint16_t crc16 = crc16_gen(power_on_BAE->TC_string, 9);\ - power_on_BAE->TC_string[9] = (crc16 & 0xFF00)>>8;\ - power_on_BAE->TC_string[10] = (crc16 & 0x00FF);\ - Base_tm *tm_ptr = NULL;\ - tm_ptr = FCTN_CDMS_RLY_TMTC(power_on_BAE);\ - delete power_on_BAE;\ - /*DELETE THE TM AFTER USE*/\ - Base_tm *del_tm = tm_ptr;\ - int overCount = 0;\ - while( del_tm != NULL ){\ - if( (overCount < TM_OVERFLOW_CONSTANT) ){\ - Base_tm *temp = del_tm->next_TM;\ - delete del_tm;\ - del_tm = temp;\ - ++overCount;\ - }\ - else{\ - RESET_CDMS;\ - break;\ - }\ - }\ -} #define resume_bcn {\ Base_tc *beacon_tc = new Long_tc;\ @@ -117,7 +50,7 @@ RF_SW_CNTRL_BCN = 0;\ gFLAGS = gFLAGS | RF_SW_STATUS_FLAG;\ if( gFLAGS & COM_AUTO_POWER_OFF_BAE_FLAG ){\ - power_on_bae;\ + BAE_SW_EN_DS = 0;\ gFLAGS = gFLAGS | BAE_SW_EN_FLAG;\ gFLAGS & (~COM_AUTO_POWER_OFF_BAE_FLAG);\ resume_bcn;\
--- a/COM_POWER_ON_TX.h Sun Jul 03 11:35:55 2016 +0000 +++ b/COM_POWER_ON_TX.h Sun Jul 03 15:25:24 2016 +0000 @@ -1,3 +1,5 @@ +extern void rx_read(); + #define STANDBY_PRCS(tm_ptr){\ Base_tc *stdby_tc = new Long_tc;\ stdby_tc->next_TC = NULL;\ @@ -48,82 +50,6 @@ delete beacon_tc;\ } -#define reset_bae {\ - Base_tc *reset_BAE = new Short_tc;\ - reset_BAE->next_TC = NULL;\ - PUTshort_or_long(reset_BAE,SHORT_TC_CODE);\ - PUTcrc_pass(reset_BAE,0x1);\ - PUTexec_status(reset_BAE,0);\ - reset_BAE->TC_string[0] = 0x01;\ - reset_BAE->TC_string[1] = BAE_APID_SOURCE;\ - reset_BAE->TC_string[2] = BAE_SERVICE;\ - reset_BAE->TC_string[3] = BAE_RESET_PID;\ - reset_BAE->TC_string[4] = 0;\ - reset_BAE->TC_string[5] = 0;\ - reset_BAE->TC_string[6] = 0;\ - reset_BAE->TC_string[7] = 0;\ - reset_BAE->TC_string[8] = 0;\ - uint16_t crc16 = crc16_gen(reset_BAE->TC_string, 9);\ - reset_BAE->TC_string[9] = (crc16 & 0xFF00)>>8;\ - reset_BAE->TC_string[10] = (crc16 & 0x00FF);\ - Base_tm *tm_ptr = NULL;\ - tm_ptr = FCTN_CDMS_RLY_TMTC(reset_BAE);\ - delete reset_BAE;\ - /*DELETE THE TM AFTER USE*/\ - Base_tm *del_tm = tm_ptr;\ - int overCount = 0;\ - while( del_tm != NULL ){\ - if( (overCount < TM_OVERFLOW_CONSTANT) ){\ - Base_tm *temp = del_tm->next_TM;\ - delete del_tm;\ - del_tm = temp;\ - ++overCount;\ - }\ - else{\ - RESET_CDMS;\ - break;\ - }\ - }\ -} - -#define power_off_bae {\ - Base_tc *power_off_BAE = new Short_tc;\ - power_off_BAE->next_TC = NULL;\ - PUTshort_or_long(power_off_BAE,SHORT_TC_CODE);\ - PUTcrc_pass(power_off_BAE,0x1);\ - PUTexec_status(power_off_BAE,0);\ - power_off_BAE->TC_string[0] = 0x01;\ - power_off_BAE->TC_string[1] = BAE_APID_SOURCE;\ - power_off_BAE->TC_string[2] = BAE_SERVICE;\ - power_off_BAE->TC_string[3] = BAE_POWER_OFF_PID;\ - power_off_BAE->TC_string[4] = 0;\ - power_off_BAE->TC_string[5] = 0;\ - power_off_BAE->TC_string[6] = 0;\ - power_off_BAE->TC_string[7] = 0;\ - power_off_BAE->TC_string[8] = 0;\ - uint16_t crc16 = crc16_gen(power_off_BAE->TC_string, 9);\ - power_off_BAE->TC_string[9] = (crc16 & 0xFF00)>>8;\ - power_off_BAE->TC_string[10] = (crc16 & 0x00FF);\ - Base_tm *tm_ptr = NULL;\ - tm_ptr = FCTN_CDMS_RLY_TMTC(power_off_BAE);\ - delete power_off_BAE;\ - /*DELETE THE TM AFTER USE*/\ - Base_tm *del_tm = tm_ptr;\ - int overCount = 0;\ - while( del_tm != NULL ){\ - if( (overCount < TM_OVERFLOW_CONSTANT) ){\ - Base_tm *temp = del_tm->next_TM;\ - delete del_tm;\ - del_tm = temp;\ - ++overCount;\ - }\ - else{\ - RESET_CDMS;\ - break;\ - }\ - }\ -} - #define P_CDMS_HK_MAIN {\ Base_tc *hk_main_ptr = new Short_tc;\ hk_main_ptr->next_TC = NULL;\ @@ -213,7 +139,7 @@ } } else{ - reset_bae; + RST_BAE(); Base_tm *tm_ptr2 = NULL; SET_BCN_STANDBY(tm_ptr2); uint8_t standbyAck2 = 0; @@ -232,7 +158,7 @@ } else{ retryFlag = false; - power_off_bae; + SW_OFF_BAE(); gFLAGS = gFLAGS | COM_AUTO_POWER_OFF_BAE_FLAG; gFLAGS = gFLAGS & (~BAE_SW_EN_FLAG); RF_SW_CNTRL_TX = 1;
--- a/DefinitionsAndGlobals.h Sun Jul 03 11:35:55 2016 +0000 +++ b/DefinitionsAndGlobals.h Sun Jul 03 15:25:24 2016 +0000 @@ -50,6 +50,7 @@ #define COM_SESSION_VALIDITY 0x0020 #define ALL_CRC_PASS_FLAG 0x0040 #define COM_PA_HOT_FLAG 0x0080 +#define COM_PA_OC_FLAG 0x8000 #define COM_TX_FLAG 0x0100 #define COM_SESSION_TIMEOUT_FLAG 0x0200 #define COM_AUTO_POWER_OFF_BAE_FLAG 0x0400 @@ -68,6 +69,7 @@ #define COM_MNG_TMTC_SIGNAL_ADF_NSD 0x02 #define COM_MNG_TMTC_SIGNAL_ADF_SD 0x03 #define SCIENCE_SIGNAL 0x04 + // COM_MNG_TMTC #define COM_PA_COOLING_TIME_LIMIT 20 #define COM_MAX_TC_LIMIT 200 @@ -265,6 +267,8 @@ DigitalOut BAE_SW_EN_DS (PIN47); DigitalOut PL_SW_EN_DS (PIN73); +#define RESET_CDMS CDMS_INTERNAL_RESET() + //SD HK uint32_t FSC_CURRENT[6]; uint32_t FSC_LAST[6]; @@ -308,17 +312,17 @@ uint8_t EPS_V_A_EN_STATUS; uint8_t BAE_SW_STATUS; uint8_t CDMS_SD_SW_STATUS; -uint8_t PL_BEE_SW_STATUS =0 ; +uint8_t PL_BEE_SW_STATUS; uint8_t PL_EPS_LATCH_SW_EN; uint8_t RTC_INIT_STATUS; uint8_t CDMS_RTC_DISABLE; -uint8_t CDMS_RESET_COUNTER; -uint8_t TIME_LATEST_CDSMS_RESET; -uint8_t COM_TC_BYTES_LIMIT; +uint16_t CDMS_RESET_COUNTER; +uint32_t TIME_LATEST_CDSMS_RESET; +uint16_t COM_TC_BYTES_LIMIT; uint8_t COM_RX_CURRENT_MAX; uint8_t COM_RX_DISABLE_TIMEOUT; uint8_t COM_PA_TMP_HIGH; uint8_t COM_PA_RECOVERY_TIMEOUT; uint8_t COM_SESSION_TIMEOUT; uint8_t COM_RSSI_MIN; -uint8_t SD_LIB_BLK_CURRENT_NMBR; \ No newline at end of file +uint16_t SD_LIB_BLK_CURRENT_NMBR; \ No newline at end of file
--- a/FMS_all.h Sun Jul 03 11:35:55 2016 +0000 +++ b/FMS_all.h Sun Jul 03 15:25:24 2016 +0000 @@ -20,7 +20,7 @@ void RST_PL_BEE(); void RST_HK_COUNTER(); uint8_t CDMS_RD_SD_HK(uint8_t *); -void RESET_CDMS(); +void CDMS_RESET(); void CDMS_INTERNAL_RESET(); void P_PL_INIT() @@ -151,12 +151,12 @@ return ACK; } -void RESET_CDMS() +void CDMS_RESET() { } void CDMS_INTERNAL_RESET() { - + NVIC_SystemReset(); } \ No newline at end of file
--- a/Flash.h Sun Jul 03 11:35:55 2016 +0000 +++ b/Flash.h Sun Jul 03 15:25:24 2016 +0000 @@ -1,91 +1,67 @@ #include "FreescaleIAP.h" -int strt_add = flash_size() - (4*SECTOR_SIZE); -uint32_t flasharray[256+(3*1024)]; +int strt_add = flash_size() - SECTOR_SIZE; // Using the last sector of flash memory char *nativeflash = (char*)strt_add; -/*Initiation of Flash*/ +void FCTN_CDMS_WR_FLASH(uint16_t ,uint32_t ); +uint32_t* FCTN_CDMS_RD_FLASH(); +uint32_t flasharray[5]; + +uint32_t INITIAL_FLASH_VALUES[5] = {0}; + void FLASH_INIT() { - uint32_t read[8]; - for(int i=0;i<8;i++) + uint32_t read[5]; + for(int i=0;i<5;i++) { - read[i] = FCTN_CDMS_RD_FLASH(i); - //printf("\n\r val is read after starting %x ",read[i]); + read[i] = nativeflash[i]; } if(read[0] == -1) - for(int j=0;j<8;j++) + for(int j=0;j<5;j++) { - FCTN_CDMS_WR_FLASH(j,ARR_INITIAL_VAL[j]); + FCTN_CDMS_WR_FLASH(j,INITIAL_FLASH_VALUES[j]); } else { - for(int j=0;j<8;j++) - { - read[j] = FCTN_CDMS_RD_FLASH(j); - } - ACS_ATS_STATUS = read[0]>>24; - ACS_TR_XY_SW_STATUS = ((uint8_t)(read[0]>>22))&0x03; - ACS_TR_Z_SW_STATUS = (read[0]>>20)&0x03; - ACS_DETUMBLING_ALGO_TYPE = (read[0]>>19)&0x01; - ACS_STATE = (read[0]>>16)&0x07; - BCN_TX_SW_STATUS = ((uint8_t)(read[0]>>14))&0x03; - BCN_SPND_TX = ((uint8_t)(read[0]>>13))&0x01; - BCN_FEN = ((uint8_t)(read[0]>>12))&0x01; - BCN_LONG_MSG_TYPE = ((uint8_t)(read[0]>>11))&0x01; - EPS_BTRY_HTR_AUTO = ((uint8_t)(read[0]>>10))&0x03;//EPS_BATTERY_HEATER_ENABLE - //now two spares in telemetry[5] - - //updating the reset counter - BAE_RESET_COUNTER = ((uint8_t)(read[0]))+1; - read[0]=(read[0]&0xffffff00) | (uint32_t)BAE_RESET_COUNTER; - FCTN_CDMS_WR_FLASH(0,read[0]); - + for(int j=0;j<5;j++) + read[j] = nativeflash[j]; - EPS_SOC_LEVEL_12 = (uint8_t)(read[1]>>24); - EPS_SOC_LEVEL_23 = (uint8_t)(read[1]>>16); - ACS_MAG_TIME_DELAY = (uint8_t)(read[1]>>8); - ACS_DEMAG_TIME_DELAY = (uint8_t)read[1]; - - EPS_BAT_TEMP_LOW = (uint8_t)(read[2]>>24); - EPS_BAT_TEMP_HIGH = (uint8_t)(read[2]>>16); - EPS_BAT_TEMP_DEFAULT = (uint8_t)(read[2]>>8); - - ACS_MM_X_COMSN = (uint16_t)(read[3]>>16); - ACS_MM_Y_COMSN = (uint16_t)read[3]; - - ACS_MG_X_COMSN = (uint16_t)(read[4]>>16); - ACS_MG_Y_COMSN = (uint16_t)read[4]; - - ACS_MM_Z_COMSN = (uint16_t)(read[5]>>16); - ACS_MG_Z_COMSN = (uint16_t)read[5]; - - ACS_Z_FIXED_MOMENT = (uint16_t)(read[6]>>16);//assignvalues - + EPS_V_A_EN_STATUS = read[0]&0x00000001; + BAE_SW_STATUS = read[0]&0x00000006; + CDMS_SD_SW_STATUS = read[0]&0x00000018; + PL_BEE_SW_STATUS = read[0]&0x00000060; + PL_EPS_LATCH_SW_EN = read[0]&0x00000080; + RTC_INIT_STATUS = read[0]&0x00000300; + CDMS_RTC_DISABLE = read[0]&0x00000400; + CDMS_RESET_COUNTER = read[0]&0xFFFF0000; + TIME_LATEST_CDSMS_RESET = read[1]&0xFFFFFFFF; + COM_TC_BYTES_LIMIT = read[2]&0x0000FFFF; + COM_RX_CURRENT_MAX = read[2]&0x00FF0000; + COM_RX_DISABLE_TIMEOUT = read[2]&0xFF000000; + COM_PA_TMP_HIGH = read[3]&0x000000FF; + COM_PA_RECOVERY_TIMEOUT = read[3]&0x0000FF00; + COM_SESSION_TIMEOUT = read[3]&0x00FF0000; + COM_RSSI_MIN = read[3]&0xFF000000; + SD_LIB_BLK_CURRENT_NMBR = read[4]&0x0000FFFF; } - } - -/*Writing to the Flash*/ -void FCTN_CDMS_WR_FLASH(uint16_t j,uint32_t block) +void FCTN_CDMS_WR_FLASH(uint16_t j,uint32_t data) // Function to write into flash { - for(int64_t i=0;i<(256+(3*1024));i++) + for(int64_t i=0;i<5;i++) { flasharray[i]=nativeflash[i]; } - flasharray[j]=block; + flasharray[j]=data; erase_sector(strt_add); - program_flash(strt_add, (char*)&flasharray,4*(256+(1024*3))); + program_flash(strt_add, (char*)flasharray,32); } -/*Reading from Flash*/ -uint32_t FCTN_CDMS_RD_FLASH(uint16_t j) +uint32_t* FCTN_CDMS_RD_FLASH() // Function to read from flash { - for(int64_t i=0;i<(256+(3*1024));i++) - { + for(int64_t i=0;i<5;i++) flasharray[i]=nativeflash[i]; - } - return flasharray[j]; + + return flasharray; } \ No newline at end of file
--- a/FreescaleIAP.lib Sun Jul 03 11:35:55 2016 +0000 +++ b/FreescaleIAP.lib Sun Jul 03 15:25:24 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/Sissors/code/FreescaleIAP/#6749f7702fa5 +http://mbed.org/users/Sissors/code/FreescaleIAP/#75fcdebc7c74
--- a/ThreadsAndFunctions.h Sun Jul 03 11:35:55 2016 +0000 +++ b/ThreadsAndFunctions.h Sun Jul 03 15:25:24 2016 +0000 @@ -277,7 +277,7 @@ /*gPC.puts("PA IS COOLED DOWN\r\n");*/ gFLAGS = gFLAGS | COM_MNG_TMTC_RUNNING_FLAG; RX1M.attach(NULL); - COM_POWER_ON_TX; + COM_POWER_ON_TX(); EXECUTE_OBOSC_ONLY; EXECUTE_TC; }
--- a/cdms_rtc.h Sun Jul 03 11:35:55 2016 +0000 +++ b/cdms_rtc.h Sun Jul 03 15:25:24 2016 +0000 @@ -1,6 +1,6 @@ void FCTN_CDMS_INIT_RTC() { - if(RTC_INIT_STATUS = 1) + if(RTC_INIT_STATUS == 1) { }
--- a/main.cpp Sun Jul 03 11:35:55 2016 +0000 +++ b/main.cpp Sun Jul 03 15:25:24 2016 +0000 @@ -17,18 +17,18 @@ #include "i2c.h" #include "COM_SND_TM_functions.h" #include "COM_SND_TM.h" +#include "Flash.h" +#include "FMS_all.h" #include "common_functions.h" #include "RESET_functions.h" #include "CDMS_HK.h" #include "OBSRS.h" #include "adf.h" #include "COM_RCV_TC.h" -#include "Flash.h" -#include "FMS_all.h" #include "CDMS_PL.h" #include "COM_MNG_TMTC.h" +#include "COM_POWER_OFF_TX.h" #include "COM_POWER_ON_TX.h" -#include "COM_POWER_OFF_TX.h" #include "Compression.h" #include "ThreadsAndFunctions.h" #include "TEST_PL.h" @@ -95,6 +95,7 @@ gCS_RTC = 1; gCS_ADF = 1; + FLASH_INIT(); FCTN_CDMS_INIT_RTC(); FCTN_CDMS_SD_INIT();