Simple version of COM_MNG_TMTC_CODE for IITMSAT.

Dependencies:   mbed-rtos mbed FreescaleIAP SimpleDMA

Committer:
aniruddhv
Date:
Thu Mar 24 04:04:33 2016 +0000
Revision:
137:489a93a04d6b
Parent:
95:42d6747900cb
Child:
144:4c20fcc105ce
Updated POWER_ON_TX, POWER_OFF_TX

Who changed what in which revision?

UserRevisionLine numberNew contents of line
aniruddhv 137:489a93a04d6b 1 #define SET_BCN_STANDBY ( tm_ptr ){\
aniruddhv 137:489a93a04d6b 2 Base_tc *beacon_tc = new Short_tc;\
aniruddhv 137:489a93a04d6b 3 beacon_tc->next_TC = NULL;\
aniruddhv 137:489a93a04d6b 4 PUTshort_or_long(beacon_tc,0);\
aniruddhv 137:489a93a04d6b 5 PUTcrc_pass(beacon_tc,0x1);\
aniruddhv 137:489a93a04d6b 6 PUTexec_status(beacon_tc,0);\
aniruddhv 137:489a93a04d6b 7 beacon_tc->TC_string[0] = 0x01;\
aniruddhv 137:489a93a04d6b 8 beacon_tc->TC_string[1] = 0x41;\
aniruddhv 137:489a93a04d6b 9 beacon_tc->TC_string[2] = 0x65;\
aniruddhv 137:489a93a04d6b 10 beacon_tc->TC_string[3] = 0x11;\
aniruddhv 137:489a93a04d6b 11 beacon_tc->TC_string[4] = 0x00;\
aniruddhv 137:489a93a04d6b 12 beacon_tc->TC_string[5] = 0;\
aniruddhv 137:489a93a04d6b 13 beacon_tc->TC_string[6] = 0;\
aniruddhv 137:489a93a04d6b 14 beacon_tc->TC_string[7] = 0;\
aniruddhv 137:489a93a04d6b 15 beacon_tc->TC_string[8] = 0;\
aniruddhv 137:489a93a04d6b 16 uint16_t crc16 = crc16_gen(beacon_tc->TC_string, 9);\
aniruddhv 137:489a93a04d6b 17 beacon_tc->TC_string[9] = (crc16 & 0xFF00)>>8;\
aniruddhv 137:489a93a04d6b 18 beacon_tc->TC_string[10] = (crc16 & 0x00FF);\
aniruddhv 137:489a93a04d6b 19 tm_ptr = FCTN_CDMS_RLY_TMTC(beacon_tc);\
aniruddhv 137:489a93a04d6b 20 }
aniruddhv 137:489a93a04d6b 21
aniruddhv 137:489a93a04d6b 22 #define reset_bae {\
aniruddhv 137:489a93a04d6b 23 Base_tc *reset_BAE = new Short_tc;\
aniruddhv 137:489a93a04d6b 24 reset_BAE->next_TC = NULL;\
aniruddhv 137:489a93a04d6b 25 PUTshort_or_long(reset_BAE,0);\
aniruddhv 137:489a93a04d6b 26 PUTcrc_pass(reset_BAE,0x1);\
aniruddhv 137:489a93a04d6b 27 PUTexec_status(reset_BAE,0);\
aniruddhv 137:489a93a04d6b 28 reset_BAE->TC_string[0] = 0x01;\
aniruddhv 137:489a93a04d6b 29 reset_BAE->TC_string[1] = 0x81;\
aniruddhv 137:489a93a04d6b 30 reset_BAE->TC_string[2] = 0x81;\
aniruddhv 137:489a93a04d6b 31 reset_BAE->TC_string[3] = 0x33;\
aniruddhv 137:489a93a04d6b 32 reset_BAE->TC_string[4] = 0;\
aniruddhv 137:489a93a04d6b 33 reset_BAE->TC_string[5] = 0;\
aniruddhv 137:489a93a04d6b 34 reset_BAE->TC_string[6] = 0;\
aniruddhv 137:489a93a04d6b 35 reset_BAE->TC_string[7] = 0;\
aniruddhv 137:489a93a04d6b 36 reset_BAE->TC_string[8] = 0;\
aniruddhv 137:489a93a04d6b 37 uint16_t crc16 = crc16_gen(reset_BAE->TC_string, 9);\
aniruddhv 137:489a93a04d6b 38 reset_BAE->TC_string[9] = (crc16 & 0xFF00)>>8;\
aniruddhv 137:489a93a04d6b 39 reset_BAE->TC_string[10] = (crc16 & 0x00FF);\
aniruddhv 137:489a93a04d6b 40 Base_tm *tm_ptr = new Short_tm;\
aniruddhv 137:489a93a04d6b 41 tm_ptr = FCTN_CDMS_RLY_TMTC(reset_BAE);\
aniruddhv 137:489a93a04d6b 42 /*DELETE THE TM AFTER USE*/\
aniruddhv 137:489a93a04d6b 43 obosc_tm_current = tm_ptr;\
aniruddhv 137:489a93a04d6b 44 int overCount = 0;\
aniruddhv 137:489a93a04d6b 45 while( obosc_tm_current != NULL ){\
aniruddhv 137:489a93a04d6b 46 if( (overCount < TM_OVERFLOW_CONSTANT) ){\
aniruddhv 137:489a93a04d6b 47 Base_tm *temp = obosc_tm_current->next_TM;\
aniruddhv 137:489a93a04d6b 48 delete obosc_tm_current;\
aniruddhv 137:489a93a04d6b 49 obosc_tm_current = temp;\
aniruddhv 137:489a93a04d6b 50 ++overCount;\
aniruddhv 137:489a93a04d6b 51 }\
aniruddhv 137:489a93a04d6b 52 else{\
aniruddhv 137:489a93a04d6b 53 /*PENDING: RESET CDMS: MEMORY LEAK FOUND*/\
aniruddhv 137:489a93a04d6b 54 break;\
aniruddhv 137:489a93a04d6b 55 }\
aniruddhv 137:489a93a04d6b 56 }\
aniruddhv 137:489a93a04d6b 57 }
aniruddhv 137:489a93a04d6b 58
aniruddhv 137:489a93a04d6b 59 #define power_off_bae {\
aniruddhv 137:489a93a04d6b 60 Base_tc *power_off_BAE = new Short_tc;\
aniruddhv 137:489a93a04d6b 61 power_off_BAE->next_TC = NULL;\
aniruddhv 137:489a93a04d6b 62 PUTshort_or_long(power_off_BAE,0);\
aniruddhv 137:489a93a04d6b 63 PUTcrc_pass(power_off_BAE,0x1);\
aniruddhv 137:489a93a04d6b 64 PUTexec_status(power_off_BAE,0);\
aniruddhv 137:489a93a04d6b 65 power_off_BAE->TC_string[0] = 0x01;\
aniruddhv 137:489a93a04d6b 66 power_off_BAE->TC_string[1] = 0x81;\
aniruddhv 137:489a93a04d6b 67 power_off_BAE->TC_string[2] = 0x81;\
aniruddhv 137:489a93a04d6b 68 power_off_BAE->TC_string[3] = 0x23;\
aniruddhv 137:489a93a04d6b 69 power_off_BAE->TC_string[4] = 0;\
aniruddhv 137:489a93a04d6b 70 power_off_BAE->TC_string[5] = 0;\
aniruddhv 137:489a93a04d6b 71 power_off_BAE->TC_string[6] = 0;\
aniruddhv 137:489a93a04d6b 72 power_off_BAE->TC_string[7] = 0;\
aniruddhv 137:489a93a04d6b 73 power_off_BAE->TC_string[8] = 0;\
aniruddhv 137:489a93a04d6b 74 uint16_t crc16 = crc16_gen(power_off_BAE->TC_string, 9);\
aniruddhv 137:489a93a04d6b 75 power_off_BAE->TC_string[9] = (crc16 & 0xFF00)>>8;\
aniruddhv 137:489a93a04d6b 76 power_off_BAE->TC_string[10] = (crc16 & 0x00FF);\
aniruddhv 137:489a93a04d6b 77 Base_tm *tm_ptr = new Short_tm;\
aniruddhv 137:489a93a04d6b 78 tm_ptr = FCTN_CDMS_RLY_TMTC(power_off_BAE);\
aniruddhv 137:489a93a04d6b 79 /*DELETE THE TM AFTER USE*/\
aniruddhv 137:489a93a04d6b 80 obosc_tm_current = tm_ptr;\
aniruddhv 137:489a93a04d6b 81 int overCount = 0;\
aniruddhv 137:489a93a04d6b 82 while( obosc_tm_current != NULL ){\
aniruddhv 137:489a93a04d6b 83 if( (overCount < TM_OVERFLOW_CONSTANT) ){\
aniruddhv 137:489a93a04d6b 84 Base_tm *temp = obosc_tm_current->next_TM;\
aniruddhv 137:489a93a04d6b 85 delete obosc_tm_current;\
aniruddhv 137:489a93a04d6b 86 obosc_tm_current = temp;\
aniruddhv 137:489a93a04d6b 87 ++overCount;\
aniruddhv 137:489a93a04d6b 88 }\
aniruddhv 137:489a93a04d6b 89 else{\
aniruddhv 137:489a93a04d6b 90 /*PENDING: RESET CDMS: MEMORY LEAK FOUND*/\
aniruddhv 137:489a93a04d6b 91 break;\
aniruddhv 137:489a93a04d6b 92 }\
aniruddhv 137:489a93a04d6b 93 }\
aniruddhv 137:489a93a04d6b 94 }
aniruddhv 137:489a93a04d6b 95
shreeshas95 4:104dd82c99b8 96 #define COM_POWER_ON_TX {\
aniruddhv 137:489a93a04d6b 97 if (DEBUG)\
aniruddhv 137:489a93a04d6b 98 gPC.puts("Inside COM_POWER_ON_TX\r\n");\
shreeshas95 4:104dd82c99b8 99 if( !(gFLAGS & COM_TX_FLAG) ){\
shreeshas95 4:104dd82c99b8 100 gFLAGS = gFLAGS | COM_TX_FLAG;\
aniruddhv 137:489a93a04d6b 101 if( gFLAGS & BAE_SW_EN_FLAG ){\
aniruddhv 137:489a93a04d6b 102 /*WARNING: INFINITE WHILE LOOP POSSIBLE: if standby ack received and bcn tx main status = 0*/\
aniruddhv 137:489a93a04d6b 103 bool retryFlag = true;\
aniruddhv 137:489a93a04d6b 104 while( retryFlag == true ){\
aniruddhv 137:489a93a04d6b 105 Base_tm *tm_ptr = new Short_tm;\
aniruddhv 137:489a93a04d6b 106 SET_BCN_STANDBY ( tm_ptr );\
aniruddhv 137:489a93a04d6b 107 uint8_t standbyAck = (tm_ptr & 0xEF);\
aniruddhv 137:489a93a04d6b 108 if( standbyAck == 0xE0 ){\
aniruddhv 137:489a93a04d6b 109 /*ACK RECCEIVED*/\
aniruddhv 137:489a93a04d6b 110 uint8_t bcn_main_status = 0xFF;\
aniruddhv 137:489a93a04d6b 111 /*PENDING: BEACON TX MAIN STATUS from tm_ptr*/\
aniruddhv 137:489a93a04d6b 112 if( bcn_main_status ){\
shreeshas95 4:104dd82c99b8 113 retryFlag = false;\
aniruddhv 137:489a93a04d6b 114 /*PENDING: SWITCH RELAY TO COM_TX*/\
aniruddhv 137:489a93a04d6b 115 gFLAGS = gFLAGS & (~RF_SW_STATUS_FLAG);\
aniruddhv 137:489a93a04d6b 116 }\
aniruddhv 137:489a93a04d6b 117 else{\
aniruddhv 137:489a93a04d6b 118 gCOM_MNG_TMTC_THREAD->wait(5000);\
shreeshas95 4:104dd82c99b8 119 }\
shreeshas95 4:104dd82c99b8 120 }\
shreeshas95 4:104dd82c99b8 121 else{\
aniruddhv 137:489a93a04d6b 122 reset_bae;\
aniruddhv 137:489a93a04d6b 123 Base_tm *tm_ptr2 = new Short_tm;\
aniruddhv 137:489a93a04d6b 124 SET_BCN_STANDBY ( tm_ptr2 );\
aniruddhv 137:489a93a04d6b 125 uint8_t standbyAck2 = (tm_ptr2 & 0xEF);\
aniruddhv 137:489a93a04d6b 126 if( standbyAck2 == 0xEF ){\
aniruddhv 137:489a93a04d6b 127 uint8_t bcn_main_status = 0xFF;\
aniruddhv 137:489a93a04d6b 128 /*PENDING: BEACON TX MAIN STATUS from tm_ptr2*/\
aniruddhv 137:489a93a04d6b 129 if( bcn_main_status = 0xFF ){\
aniruddhv 137:489a93a04d6b 130 retryFlag = false;\
aniruddhv 137:489a93a04d6b 131 /*PENDING: SWITCH RF RELAY TO COM TX*/\
aniruddhv 137:489a93a04d6b 132 gFLAGS = gFLAGS & (~RF_SW_STATUS_FLAG);\
aniruddhv 137:489a93a04d6b 133 }\
aniruddhv 137:489a93a04d6b 134 else{\
aniruddhv 137:489a93a04d6b 135 gCOM_MNG_TMTC_THREAD->wait(5000);\
aniruddhv 137:489a93a04d6b 136 }\
aniruddhv 137:489a93a04d6b 137 }\
aniruddhv 137:489a93a04d6b 138 else{\
aniruddhv 137:489a93a04d6b 139 retryFlag = false;\
aniruddhv 137:489a93a04d6b 140 power_off_bae;\
aniruddhv 137:489a93a04d6b 141 gFLAGS = gFLAGS | COM_AUTO_POWER_OFF_BAE_FLAG;\
aniruddhv 137:489a93a04d6b 142 gFLAGS = gFLAGS & (~BAE_SW_EN_FLAG);\
aniruddhv 137:489a93a04d6b 143 /*PENDING: SWITCH RF RELAY TO COM TX*/\
aniruddhv 137:489a93a04d6b 144 gFLAGS = gFLAGS & (~RF_SW_STATUS_FLAG);\
aniruddhv 137:489a93a04d6b 145 }\
aniruddhv 137:489a93a04d6b 146 /*DELETE THE TM AFTER USE*/\
aniruddhv 137:489a93a04d6b 147 obosc_tm_current = tm_ptr2;\
aniruddhv 137:489a93a04d6b 148 int overCount = 0;\
aniruddhv 137:489a93a04d6b 149 while( obosc_tm_current != NULL ){\
aniruddhv 137:489a93a04d6b 150 if( (overCount < TM_OVERFLOW_CONSTANT) ){\
aniruddhv 137:489a93a04d6b 151 Base_tm *temp = obosc_tm_current->next_TM;\
aniruddhv 137:489a93a04d6b 152 delete obosc_tm_current;\
aniruddhv 137:489a93a04d6b 153 obosc_tm_current = temp;\
aniruddhv 137:489a93a04d6b 154 ++overCount;\
aniruddhv 137:489a93a04d6b 155 }\
aniruddhv 137:489a93a04d6b 156 else{\
aniruddhv 137:489a93a04d6b 157 /*PENDING: RESET CDMS: MEMORY LEAK FOUND*/\
aniruddhv 137:489a93a04d6b 158 break;\
aniruddhv 137:489a93a04d6b 159 }\
aniruddhv 137:489a93a04d6b 160 }\
aniruddhv 137:489a93a04d6b 161 }\
aniruddhv 137:489a93a04d6b 162 /*DELETE THE TM AFTER USE*/\
aniruddhv 137:489a93a04d6b 163 obosc_tm_current = tm_ptr;\
aniruddhv 137:489a93a04d6b 164 int overCount = 0;\
aniruddhv 137:489a93a04d6b 165 while( obosc_tm_current != NULL ){\
aniruddhv 137:489a93a04d6b 166 if( (overCount < TM_OVERFLOW_CONSTANT) ){\
aniruddhv 137:489a93a04d6b 167 Base_tm *temp = obosc_tm_current->next_TM;\
aniruddhv 137:489a93a04d6b 168 delete obosc_tm_current;\
aniruddhv 137:489a93a04d6b 169 obosc_tm_current = temp;\
aniruddhv 137:489a93a04d6b 170 ++overCount;\
aniruddhv 137:489a93a04d6b 171 }\
aniruddhv 137:489a93a04d6b 172 else{\
aniruddhv 137:489a93a04d6b 173 /*PENDING: RESET CDMS: MEMORY LEAK FOUND*/\
aniruddhv 137:489a93a04d6b 174 break;\
aniruddhv 137:489a93a04d6b 175 }\
shreeshas95 4:104dd82c99b8 176 }\
shreeshas95 4:104dd82c99b8 177 }\
shreeshas95 4:104dd82c99b8 178 }\
aniruddhv 137:489a93a04d6b 179 else{\
aniruddhv 137:489a93a04d6b 180 power_off_bae;\
aniruddhv 137:489a93a04d6b 181 gFLAGS = gFLAGS & (~BAE_SW_EN_FLAG);\
aniruddhv 137:489a93a04d6b 182 /*PENDING: SWITCH RF RELAY TO COM TX*/\
aniruddhv 137:489a93a04d6b 183 gFLAGS = gFLAGS & (~RF_SW_STATUS_FLAG);\
aniruddhv 137:489a93a04d6b 184 }\
shreeshas95 4:104dd82c99b8 185 }\
shreeshas95 4:104dd82c99b8 186 /*PENDING: POWER ON COM_TX*/\
aniruddhv 137:489a93a04d6b 187 /*power_on_com_tx_pin = 1;*/\
shreeshas95 5:ab276a17ca07 188 uint8_t adfConfigPass = 0xFF;\
shreeshas95 4:104dd82c99b8 189 for( int i = 0 ; i < COM_TX_CONFIG_LIMIT ; ++i ){\
shreeshas95 4:104dd82c99b8 190 /*PENDING: CONFIGURE ADF*/\
shreeshas95 4:104dd82c99b8 191 if( adfConfigPass == 0xFF ){\
shreeshas95 4:104dd82c99b8 192 break;\
shreeshas95 4:104dd82c99b8 193 }\
shreeshas95 4:104dd82c99b8 194 }\
shreeshas95 4:104dd82c99b8 195 if( adfConfigPass == 0xFF ){\
shreeshas95 4:104dd82c99b8 196 /*adf successfully configured*/\
shreeshas95 4:104dd82c99b8 197 /*CALL SIGN*/\
shreeshas95 4:104dd82c99b8 198 Base_tm *power_on_tm = NULL;\
shreeshas95 4:104dd82c99b8 199 Base_tm *power_on_tm_head = NULL;\
shreeshas95 4:104dd82c99b8 200 get_call_sign( power_on_tm_head );\
shreeshas95 4:104dd82c99b8 201 power_on_tm = power_on_tm_head;\
shreeshas95 4:104dd82c99b8 202 /*ACK L1*/\
shreeshas95 4:104dd82c99b8 203 get_ack_l1(power_on_tm->next_TM);\
shreeshas95 4:104dd82c99b8 204 int overFlowCountADF = 0;\
shreeshas95 4:104dd82c99b8 205 while( power_on_tm->next_TM != NULL ){\
shreeshas95 4:104dd82c99b8 206 if( overFlowCountADF < TM_OVERFLOW_CONSTANT ){\
shreeshas95 4:104dd82c99b8 207 power_on_tm = power_on_tm->next_TM;\
shreeshas95 4:104dd82c99b8 208 ++overFlowCountADF;\
shreeshas95 4:104dd82c99b8 209 }\
shreeshas95 4:104dd82c99b8 210 else{\
shreeshas95 4:104dd82c99b8 211 /*PENDING: RESET CDMS*/\
shreeshas95 4:104dd82c99b8 212 break;\
shreeshas95 4:104dd82c99b8 213 }\
shreeshas95 4:104dd82c99b8 214 }\
shreeshas95 4:104dd82c99b8 215 get_tc_list(power_on_tm->next_TM, 0x00);\
aniruddhv 69:20f09a0c3fd2 216 /*Call Sign, ACK_L1, TC_LIST*/\
ee12b079 90:df55a5f68331 217 /*snd_tm.head_pointer(power_on_tm_head);*/\
ee12b079 95:42d6747900cb 218 /*transmit_adf;*/\
shreeshas95 5:ab276a17ca07 219 /*deleting the telemetry*/\
shreeshas95 4:104dd82c99b8 220 power_on_tm = power_on_tm_head;\
shreeshas95 4:104dd82c99b8 221 overFlowCountADF = 0;\
shreeshas95 4:104dd82c99b8 222 while( power_on_tm != NULL ){\
shreeshas95 4:104dd82c99b8 223 if( overFlowCountADF < TM_OVERFLOW_CONSTANT ){\
shreeshas95 4:104dd82c99b8 224 Base_tm *temp = power_on_tm->next_TM;\
shreeshas95 4:104dd82c99b8 225 delete power_on_tm;\
shreeshas95 4:104dd82c99b8 226 power_on_tm = temp;\
shreeshas95 4:104dd82c99b8 227 ++overFlowCountADF;\
shreeshas95 4:104dd82c99b8 228 }\
shreeshas95 4:104dd82c99b8 229 else{\
shreeshas95 4:104dd82c99b8 230 /*PENDING: RESET CDMS*/\
shreeshas95 4:104dd82c99b8 231 break;\
shreeshas95 4:104dd82c99b8 232 }\
shreeshas95 4:104dd82c99b8 233 }\
aniruddhv 137:489a93a04d6b 234 if(/*NOT Transmitted succesfully*/){\
aniruddhv 137:489a93a04d6b 235 COM_POWER_OFF_TX;\
aniruddhv 137:489a93a04d6b 236 /*PENDING: CDMS HK MAIN*/\
aniruddhv 137:489a93a04d6b 237 uint8_t ackReceived = 0x00;\
aniruddhv 137:489a93a04d6b 238 /*PENDING: BCN TX MAIN*/\
aniruddhv 137:489a93a04d6b 239 if( ackReceived == 0xFF ){\
aniruddhv 137:489a93a04d6b 240 gCOM_MNG_TMTC_THREAD->wait(5000);\
aniruddhv 137:489a93a04d6b 241 /*PENDING: RESET CDMS*/\
aniruddhv 137:489a93a04d6b 242 }\
aniruddhv 137:489a93a04d6b 243 else{\
aniruddhv 137:489a93a04d6b 244 /*PENDING: RESET CDMS*/\
aniruddhv 137:489a93a04d6b 245 }\
aniruddhv 137:489a93a04d6b 246 }\
shreeshas95 4:104dd82c99b8 247 }\
shreeshas95 4:104dd82c99b8 248 else{\
shreeshas95 4:104dd82c99b8 249 /*PENDING: COM_POWER OFF TX*/\
shreeshas95 4:104dd82c99b8 250 /*PENDING: CDMS HK MAIN*/\
shreeshas95 4:104dd82c99b8 251 uint8_t ackReceived = 0x00;\
shreeshas95 4:104dd82c99b8 252 /*PENDING: BCN TX MAIN*/\
shreeshas95 4:104dd82c99b8 253 if( ackReceived == 0xFF ){\
shreeshas95 4:104dd82c99b8 254 gCOM_MNG_TMTC_THREAD->wait(5000);\
shreeshas95 4:104dd82c99b8 255 /*PENDING: RESET CDMS*/\
shreeshas95 4:104dd82c99b8 256 }\
shreeshas95 4:104dd82c99b8 257 else{\
shreeshas95 4:104dd82c99b8 258 /*PENDING: RESET CDMS*/\
shreeshas95 4:104dd82c99b8 259 }\
shreeshas95 4:104dd82c99b8 260 }\
aniruddhv 12:ffdb29353058 261 /*gPC.puts("COMPLETED COM_POWER_ON_TX\r\n");*/\
shreeshas95 4:104dd82c99b8 262 }