Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE by
COM_POWER_ON_TX.h
00001 #define STANDBY_PRCS(tm_ptr){\ 00002 Base_tc *stdby_tc = new Long_tc;\ 00003 stdby_tc->next_TC = NULL;\ 00004 PUTshort_or_long(stdby_tc,LONG_TC_CODE);\ 00005 PUTcrc_pass(stdby_tc,0x1);\ 00006 PUTexec_status(stdby_tc,0);\ 00007 stdby_tc->TC_string[0] = 0x01;\ 00008 stdby_tc->TC_string[1] = 0x41;\ 00009 stdby_tc->TC_string[2] = 0x81;\ 00010 stdby_tc->TC_string[3] = 0x40;\ 00011 stdby_tc->TC_string[4] = 0;\ 00012 stdby_tc->TC_string[5] = 0;\ 00013 stdby_tc->TC_string[6] = 0;\ 00014 stdby_tc->TC_string[7] = 0;\ 00015 stdby_tc->TC_string[8] = 0;\ 00016 uint16_t crc16 = crc16_gen(stdby_tc->TC_string, 9);\ 00017 stdby_tc->TC_string[9] = (crc16 & 0xFF00)>>8;\ 00018 stdby_tc->TC_string[10] = (crc16 & 0x00FF);\ 00019 for(int i = 11; i < 135; i++){\ 00020 stdby_tc->TC_string[i] = 0;\ 00021 }\ 00022 tm_ptr = FCTN_CDMS_RLY_TMTC(stdby_tc);\ 00023 delete stdby_tc;\ 00024 } 00025 00026 #define SET_BCN_STANDBY(tm_ptr){\ 00027 Base_tc *beacon_tc = new Long_tc;\ 00028 beacon_tc->next_TC = NULL;\ 00029 PUTshort_or_long(beacon_tc,LONG_TC_CODE);\ 00030 PUTcrc_pass(beacon_tc,0x1);\ 00031 PUTexec_status(beacon_tc,0);\ 00032 beacon_tc->TC_string[0] = 0x01;\ 00033 beacon_tc->TC_string[1] = BCN_APID_SOURCE;\ 00034 beacon_tc->TC_string[2] = BCN_SERVICE;\ 00035 beacon_tc->TC_string[3] = 0xE2;\ 00036 beacon_tc->TC_string[4] = 0x01;\ 00037 beacon_tc->TC_string[5] = 0;\ 00038 beacon_tc->TC_string[6] = 0;\ 00039 beacon_tc->TC_string[7] = 0;\ 00040 beacon_tc->TC_string[8] = 0;\ 00041 uint16_t crc16 = crc16_gen(beacon_tc->TC_string, 9);\ 00042 beacon_tc->TC_string[9] = (crc16 & 0xFF00)>>8;\ 00043 beacon_tc->TC_string[10] = (crc16 & 0x00FF);\ 00044 for(int i = 11; i < 135; i++){\ 00045 beacon_tc->TC_string[i] = 0;\ 00046 }\ 00047 tm_ptr = FCTN_CDMS_RLY_TMTC(beacon_tc);\ 00048 delete beacon_tc;\ 00049 } 00050 00051 #define P_CDMS_HK_MAIN {\ 00052 Base_tc *hk_main_ptr = new Short_tc;\ 00053 hk_main_ptr->next_TC = NULL;\ 00054 PUTshort_or_long(hk_main_ptr,SHORT_TC_CODE);\ 00055 PUTcrc_pass(hk_main_ptr,0x1);\ 00056 PUTexec_status(hk_main_ptr,0);\ 00057 hk_main_ptr->TC_string[0] = 0x01;\ 00058 hk_main_ptr->TC_string[1] = 0x81;\ 00059 hk_main_ptr->TC_string[2] = 0x81;\ 00060 hk_main_ptr->TC_string[3] = 0x04;\ 00061 hk_main_ptr->TC_string[4] = 0;\ 00062 hk_main_ptr->TC_string[5] = 0;\ 00063 hk_main_ptr->TC_string[6] = 0;\ 00064 hk_main_ptr->TC_string[7] = 0;\ 00065 hk_main_ptr->TC_string[8] = 0;\ 00066 uint16_t crc16 = crc16_gen(hk_main_ptr->TC_string, 9);\ 00067 hk_main_ptr->TC_string[9] = (crc16 & 0xFF00)>>8;\ 00068 hk_main_ptr->TC_string[10] = (crc16 & 0x00FF);\ 00069 Base_tm *tm_ptr = NULL;\ 00070 tm_ptr = FCTN_CDMS_RLY_TMTC(hk_main_ptr);\ 00071 delete hk_main_ptr;\ 00072 /*DELETE THE TM AFTER USE*/\ 00073 Base_tm *del_tm = tm_ptr;\ 00074 int overCount = 0;\ 00075 while( del_tm != NULL ){\ 00076 if( (overCount < TM_OVERFLOW_CONSTANT) ){\ 00077 Base_tm *temp = del_tm->next_TM;\ 00078 delete del_tm;\ 00079 del_tm = temp;\ 00080 ++overCount;\ 00081 }\ 00082 else{\ 00083 RESET_CDMS;\ 00084 break;\ 00085 }\ 00086 }\ 00087 } 00088 00089 #define P_BCN_TX_MAIN(tm_ptr) {\ 00090 Base_tc *bcn_tx_main_ptr = new Long_tc;\ 00091 bcn_tx_main_ptr->next_TC = NULL;\ 00092 PUTshort_or_long(bcn_tx_main_ptr,LONG_TC_CODE);\ 00093 PUTcrc_pass(bcn_tx_main_ptr,0x1);\ 00094 PUTexec_status(bcn_tx_main_ptr,0);\ 00095 bcn_tx_main_ptr->TC_string[0] = 0x01;\ 00096 bcn_tx_main_ptr->TC_string[1] = 0x41;\ 00097 bcn_tx_main_ptr->TC_string[2] = 0x81;\ 00098 bcn_tx_main_ptr->TC_string[3] = 0x07;\ 00099 bcn_tx_main_ptr->TC_string[4] = 0;\ 00100 bcn_tx_main_ptr->TC_string[5] = 0;\ 00101 bcn_tx_main_ptr->TC_string[6] = 0;\ 00102 bcn_tx_main_ptr->TC_string[7] = 0;\ 00103 bcn_tx_main_ptr->TC_string[8] = 0;\ 00104 uint16_t crc16 = crc16_gen(bcn_tx_main_ptr->TC_string, 9);\ 00105 bcn_tx_main_ptr->TC_string[9] = (crc16 & 0xFF00)>>8;\ 00106 bcn_tx_main_ptr->TC_string[10] = (crc16 & 0x00FF);\ 00107 for(int i = 11; i < 135; i++){\ 00108 bcn_tx_main_ptr->TC_string[i] = 0;\ 00109 }\ 00110 tm_ptr = FCTN_CDMS_RLY_TMTC(bcn_tx_main_ptr);\ 00111 delete bcn_tx_main_ptr;\ 00112 } 00113 00114 void COM_POWER_ON_TX() { 00115 //gPC.puts("Inside COM_POWER_ON_TX\r\n"); 00116 if( !(gFLAGS & COM_TX_FLAG) ){ 00117 gFLAGS = gFLAGS | COM_TX_FLAG; 00118 //gPC.puts("Inside COM_TX_FLAG\r\n"); 00119 gFLAGS = gFLAGS | BAE_SW_EN_FLAG ; 00120 if( gFLAGS & BAE_SW_EN_FLAG ){ 00121 /*WARNING: INFINITE WHILE LOOP POSSIBLE: if standby ack received and bcn tx main status = 0*/ 00122 bool retryFlag = true; 00123 while( retryFlag == true ){ 00124 Base_tm *tm_ptr = NULL; 00125 gPC.puts("setting Bcn off\r\n"); 00126 wait(1); 00127 SET_BCN_STANDBY(tm_ptr); 00128 //gPC.puts("set Bcn off\r\n"); 00129 uint8_t bcn_main_status = (tm_ptr->TM_string[2] & 0xEF); 00130 gPC.printf("bcn_main_status = 0x%02X\r\n",bcn_main_status); 00131 if(( bcn_main_status == 0xC0 )||( bcn_main_status ==0xA0 )){ 00132 /*ACK RECCEIVED*/ 00133 if( bcn_main_status == 0xA0 ){ 00134 gPC.puts("A0\r\n"); 00135 retryFlag = false; 00136 RF_SW_CNTRL_TX = 1; 00137 Thread::wait(25); 00138 RF_SW_CNTRL_TX = 0; 00139 gFLAGS = gFLAGS | RF_SW_STATUS_FLAG;/*RF_SW_STATUS_FLAG set to RF_COM_TX*/ 00140 } 00141 else{ 00142 gPC.puts("waiting for bcn off\r\n"); 00143 Thread::wait(5000); 00144 } 00145 } 00146 else{ 00147 gPC.puts("not A0\r\n"); 00148 SW_RST_BAE(); 00149 wait_ms(100); 00150 Base_tm *tm_ptr2 = NULL; 00151 gPC.puts("settin bcn off\r\n"); 00152 SET_BCN_STANDBY(tm_ptr2); 00153 //gPC.puts("bcn off\r\n"); 00154 uint8_t standbyAck2 = 0; 00155 uint8_t bcn_main_status2 = (tm_ptr2->TM_string[2] & 0xEF); 00156 if( ( bcn_main_status2 == 0xC0 )||( bcn_main_status2 == 0xA0 ) ){ 00157 if( bcn_main_status2 == 0xA0 ){ 00158 gPC.puts("ack = A0\r\n"); 00159 retryFlag = false; 00160 RF_SW_CNTRL_TX = 1; 00161 Thread::wait(25); 00162 RF_SW_CNTRL_TX = 0; 00163 gFLAGS = gFLAGS | RF_SW_STATUS_FLAG;/*RF_SW_STATUS_FLAG set to RF_COM_TX*/ 00164 } 00165 else{ 00166 gPC.puts("ack = C0\r\n"); 00167 Thread::wait(5000); 00168 } 00169 } 00170 else{ 00171 gPC.puts("sw off BAE\r\n"); 00172 retryFlag = false; 00173 SW_OFF_BAE(); 00174 gPC.puts("swd off BAE\r\n"); 00175 gFLAGS = gFLAGS | COM_AUTO_POWER_OFF_BAE_FLAG; 00176 RF_SW_CNTRL_TX = 1; 00177 Thread::wait(25); 00178 RF_SW_CNTRL_TX = 0; 00179 gFLAGS = gFLAGS | RF_SW_STATUS_FLAG;/*RF_SW_STATUS_FLAG set to RF_COM_TX*/ 00180 } 00181 /*DELETE THE TM AFTER USE*/ 00182 Base_tm *del_tm = tm_ptr2; 00183 int overCount = 0; 00184 while( del_tm != NULL ){ 00185 if( (overCount < TM_OVERFLOW_CONSTANT) ){ 00186 Base_tm *temp = del_tm->next_TM; 00187 delete del_tm; 00188 del_tm = temp; 00189 ++overCount; 00190 } 00191 else{ 00192 RESET_CDMS; 00193 break; 00194 } 00195 } 00196 } 00197 /*DELETE THE TM AFTER USE*/ 00198 Base_tm *del_tm = tm_ptr; 00199 int overCount = 0; 00200 while( del_tm != NULL ){ 00201 if( (overCount < TM_OVERFLOW_CONSTANT) ){ 00202 Base_tm *temp = del_tm->next_TM; 00203 delete del_tm; 00204 del_tm = temp; 00205 ++overCount; 00206 } 00207 else{ 00208 RESET_CDMS; 00209 break; 00210 } 00211 } 00212 } 00213 } 00214 else{ 00215 gPC.puts("RF_SW_CNTRL_TX\r\n"); 00216 RF_SW_CNTRL_TX = 1; 00217 Thread::wait(25); 00218 RF_SW_CNTRL_TX = 0; 00219 gFLAGS = gFLAGS | RF_SW_STATUS_FLAG;/*RF_SW_STATUS_FLAG set to RF_COM_TX*/ 00220 } 00221 } 00222 gPC.puts("swd off BAE\r\n"); 00223 COM_TX_CNTRL = 1; 00224 uint8_t adfConfigPass = 0xFF; 00225 for( int i = 0 ; i < COM_TX_CONFIG_LIMIT ; ++i ){ 00226 /*PENDING: CONFIGURE ADF and set adfConfigPass*/ 00227 if( adfConfigPass == 0xFF ){ 00228 break; 00229 } 00230 } 00231 if( adfConfigPass == 0xFF ){ 00232 /*adf successfully configured*/ 00233 gFLAGS = gFLAGS | COM_TX_STATUS_FLAG; 00234 /*CALL SIGN*/ 00235 Base_tm *power_on_tm = NULL; 00236 Base_tm *power_on_tm_head = NULL; 00237 get_call_sign( power_on_tm_head ); 00238 power_on_tm = power_on_tm_head; 00239 /*ACK L1*/ 00240 get_ack_l1(power_on_tm->next_TM); 00241 int overFlowCountADF = 0; 00242 while( power_on_tm->next_TM != NULL ){ 00243 if( overFlowCountADF < TM_OVERFLOW_CONSTANT ){ 00244 power_on_tm = power_on_tm->next_TM; 00245 ++overFlowCountADF; 00246 } 00247 else{ 00248 RESET_CDMS; 00249 break; 00250 } 00251 } 00252 get_tc_list(power_on_tm->next_TM, 0x00); 00253 /*Call Sign, ACK_L1, TC_LIST*/ 00254 /*snd_tm.head_pointer(power_on_tm_head);*/ 00255 /*transmit_adf();*/ 00256 uint8_t transmissionPass = 0xFF; 00257 /*PENDING: get acknowledgement of transmission*/ 00258 /*deleting the telemetry*/ 00259 power_on_tm = power_on_tm_head; 00260 overFlowCountADF = 0; 00261 while( power_on_tm != NULL ){ 00262 if( overFlowCountADF < TM_OVERFLOW_CONSTANT ){ 00263 Base_tm *temp = power_on_tm->next_TM; 00264 delete power_on_tm; 00265 power_on_tm = temp; 00266 ++overFlowCountADF; 00267 } 00268 else{ 00269 RESET_CDMS; 00270 break; 00271 } 00272 } 00273 if( transmissionPass == 0 ){ 00274 /*NOT Transmitted succesfully*/ 00275 COM_POWER_OFF_TX; 00276 P_CDMS_HK_MAIN; 00277 Base_tm *ptr_tm = NULL; 00278 STANDBY_PRCS(ptr_tm); 00279 uint8_t standbyACK = 0x00; 00280 uint8_t bcn_main_status = (ptr_tm->TM_string[2] & 0xEF); 00281 if(( bcn_main_status == 0xC0 )||( bcn_main_status ==0xA0 )){ 00282 standbyACK = 1; 00283 } 00284 if(standbyACK == 1){ 00285 uint8_t ackReceived = 0x00; 00286 Base_tm *tm_ptr = NULL; 00287 P_BCN_TX_MAIN(tm_ptr); 00288 uint8_t ackcode = tm_ptr->TM_string[2] & 0xEF; 00289 if( (ackcode == 0xA0) || (ackcode == 0xC0)) 00290 ackReceived = 0xFF; 00291 /*DELETE THE TM AFTER USE*/ 00292 Base_tm *del_tm = tm_ptr; 00293 int overCount = 0; 00294 while( del_tm != NULL ){ 00295 if( (overCount < TM_OVERFLOW_CONSTANT) ){ 00296 Base_tm *temp = del_tm->next_TM; 00297 delete del_tm; 00298 del_tm = temp; 00299 ++overCount; 00300 } 00301 else{ 00302 RESET_CDMS; 00303 break; 00304 } 00305 } 00306 if( ackReceived == 0xFF ){ 00307 Thread::wait(5000); 00308 } 00309 } 00310 /*DELETE THE TM AFTER USE*/ 00311 Base_tm *del_tm = ptr_tm; 00312 int overCount = 0; 00313 while( del_tm != NULL ){ 00314 if( (overCount < TM_OVERFLOW_CONSTANT) ){ 00315 Base_tm *temp = del_tm->next_TM; 00316 delete del_tm; 00317 del_tm = temp; 00318 ++overCount; 00319 } 00320 else{ 00321 RESET_CDMS; 00322 break; 00323 } 00324 } 00325 RESET_CDMS_TC; 00326 } 00327 } 00328 else{ 00329 /*ADF not configured*/ 00330 gFLAGS = gFLAGS & (~COM_TX_STATUS_FLAG); 00331 COM_POWER_OFF_TX; 00332 P_CDMS_HK_MAIN; 00333 Base_tm *ptr_tm = NULL; 00334 STANDBY_PRCS(ptr_tm); 00335 uint8_t standbyACK = 0x00; 00336 uint8_t bcn_main_status = (ptr_tm->TM_string[2] & 0xEF); 00337 if(( bcn_main_status == 0xC0 )||( bcn_main_status ==0xA0 )){ 00338 standbyACK = 1; 00339 } 00340 if(standbyACK == 1){ 00341 uint8_t ackReceived = 0x00; 00342 Base_tm *tm_ptr = NULL; 00343 P_BCN_TX_MAIN(tm_ptr); 00344 uint8_t ackcode = tm_ptr->TM_string[2] & 0xEF; 00345 if( (ackcode == 0xA0) || (ackcode == 0xC0)) 00346 ackReceived = 0xFF; 00347 /*DELETE THE TM AFTER USE*/ 00348 Base_tm *del_tm = tm_ptr; 00349 int overCount = 0; 00350 while( del_tm != NULL ){ 00351 if( (overCount < TM_OVERFLOW_CONSTANT) ){ 00352 Base_tm *temp = del_tm->next_TM; 00353 delete del_tm; 00354 del_tm = temp; 00355 ++overCount; 00356 } 00357 else{ 00358 RESET_CDMS; 00359 break; 00360 } 00361 } 00362 if( ackReceived == 0xFF ){ 00363 Thread::wait(5000); 00364 } 00365 } 00366 /*DELETE THE TM AFTER USE*/ 00367 Base_tm *del_tm = ptr_tm; 00368 int overCount = 0; 00369 while( del_tm != NULL ){ 00370 if( (overCount < TM_OVERFLOW_CONSTANT) ){ 00371 Base_tm *temp = del_tm->next_TM; 00372 delete del_tm; 00373 del_tm = temp; 00374 ++overCount; 00375 } 00376 else{ 00377 RESET_CDMS; 00378 break; 00379 } 00380 } 00381 RESET_CDMS_TC; 00382 } 00383 gPC.puts("COMPLETED COM_POWER_ON_TX\r\n"); 00384 }
Generated on Tue Jul 26 2022 00:15:16 by
1.7.2
