![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
CDMS_CODE_samp_23SEP_DMA_flag
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE_samp_23SEP_DMA by
Diff: COM_POWER_ON_TX.h
- Revision:
- 212:3d13a06bcd3a
- Parent:
- 211:77bee0cbebfe
diff -r 77bee0cbebfe -r 3d13a06bcd3a COM_POWER_ON_TX.h --- a/COM_POWER_ON_TX.h Sat Jun 18 09:07:28 2016 +0000 +++ b/COM_POWER_ON_TX.h Sun Jul 03 05:37:25 2016 +0000 @@ -1,7 +1,32 @@ +#define STANDBY_PRCS(tm_ptr){\ + Base_tc *stdby_tc = new Long_tc;\ + stdby_tc->next_TC = NULL;\ + PUTshort_or_long(stdby_tc,LONG_TC_CODE);\ + PUTcrc_pass(stdby_tc,0x1);\ + PUTexec_status(stdby_tc,0);\ + stdby_tc->TC_string[0] = 0x01;\ + stdby_tc->TC_string[1] = 0x41;\ + stdby_tc->TC_string[2] = 0x81;\ + stdby_tc->TC_string[3] = 0x40;\ + stdby_tc->TC_string[4] = 0x01;\ + stdby_tc->TC_string[5] = 0x01;\ + stdby_tc->TC_string[6] = 0x01;\ + stdby_tc->TC_string[7] = 0;\ + stdby_tc->TC_string[8] = 0;\ + uint16_t crc16 = crc16_gen(stdby_tc->TC_string, 9);\ + stdby_tc->TC_string[9] = (crc16 & 0xFF00)>>8;\ + stdby_tc->TC_string[10] = (crc16 & 0x00FF);\ + for(int i = 11; i < 135; i++){\ + stdby_tc->TC_string[i] = 0;\ + }\ + tm_ptr = FCTN_CDMS_RLY_TMTC(stdby_tc);\ + delete stdby_tc;\ +} + #define SET_BCN_STANDBY(tm_ptr){\ - Base_tc *beacon_tc = new Short_tc;\ + Base_tc *beacon_tc = new Long_tc;\ beacon_tc->next_TC = NULL;\ - PUTshort_or_long(beacon_tc,SHORT_TC_CODE);\ + PUTshort_or_long(beacon_tc,LONG_TC_CODE);\ PUTcrc_pass(beacon_tc,0x1);\ PUTexec_status(beacon_tc,0);\ beacon_tc->TC_string[0] = 0x01;\ @@ -16,6 +41,9 @@ uint16_t crc16 = crc16_gen(beacon_tc->TC_string, 9);\ beacon_tc->TC_string[9] = (crc16 & 0xFF00)>>8;\ beacon_tc->TC_string[10] = (crc16 & 0x00FF);\ + for(int i = 11; i < 135; i++){\ + beacon_tc->TC_string[i] = 0;\ + }\ tm_ptr = FCTN_CDMS_RLY_TMTC(beacon_tc);\ delete beacon_tc;\ } @@ -38,7 +66,7 @@ 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 = new Short_tm;\ + Base_tm *tm_ptr = NULL;\ tm_ptr = FCTN_CDMS_RLY_TMTC(reset_BAE);\ delete reset_BAE;\ /*DELETE THE TM AFTER USE*/\ @@ -76,8 +104,8 @@ 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 = new Short_tm;\ - tm_ptr = FCTN_CDMS_RLY_TMTC(power_off_BAE);\ + 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;\ @@ -114,8 +142,8 @@ uint16_t crc16 = crc16_gen(hk_main_ptr->TC_string, 9);\ hk_main_ptr->TC_string[9] = (crc16 & 0xFF00)>>8;\ hk_main_ptr->TC_string[10] = (crc16 & 0x00FF);\ - Base_tm *tm_ptr = new Short_tm;\ - tm_ptr = FCTN_CDMS_RLY_TMTC(hk_main_ptr);\ + Base_tm *tm_ptr = NULL;\ + tm_ptr = FCTN_CDMS_RLY_TMTC(hk_main_ptr);\ delete hk_main_ptr;\ /*DELETE THE TM AFTER USE*/\ Base_tm *del_tm = tm_ptr;\ @@ -135,9 +163,9 @@ } #define P_BCN_TX_MAIN(tm_ptr) {\ - Base_tc *bcn_tx_main_ptr = new Short_tc;\ + Base_tc *bcn_tx_main_ptr = new Long_tc;\ bcn_tx_main_ptr->next_TC = NULL;\ - PUTshort_or_long(bcn_tx_main_ptr,SHORT_TC_CODE);\ + PUTshort_or_long(bcn_tx_main_ptr,LONG_TC_CODE);\ PUTcrc_pass(bcn_tx_main_ptr,0x1);\ PUTexec_status(bcn_tx_main_ptr,0);\ bcn_tx_main_ptr->TC_string[0] = 0x01;\ @@ -152,6 +180,9 @@ uint16_t crc16 = crc16_gen(bcn_tx_main_ptr->TC_string, 9);\ bcn_tx_main_ptr->TC_string[9] = (crc16 & 0xFF00)>>8;\ bcn_tx_main_ptr->TC_string[10] = (crc16 & 0x00FF);\ + for(int i = 11; i < 135; i++){\ + bcn_tx_main_ptr->TC_string[i] = 0;\ + }\ tm_ptr = FCTN_CDMS_RLY_TMTC(bcn_tx_main_ptr);\ delete bcn_tx_main_ptr;\ } @@ -165,15 +196,12 @@ /*WARNING: INFINITE WHILE LOOP POSSIBLE: if standby ack received and bcn tx main status = 0*/ bool retryFlag = true; while( retryFlag == true ){ - Base_tm *tm_ptr = new Short_tm; + Base_tm *tm_ptr = NULL; SET_BCN_STANDBY(tm_ptr); - uint8_t standbyAck = 0; uint8_t bcn_main_status = (tm_ptr->TM_string[2] & 0xEF); - if(( bcn_main_status == 0xC0 )||( bcn_main_status ==0xA0 )) - standbyAck = 1; - if( /*standbyAck*/ true ){ + if(( bcn_main_status == 0xC0 )||( bcn_main_status ==0xA0 )){ /*ACK RECCEIVED*/ - if( /*bcn_main_status == 0xA0*/ true ){ + if( bcn_main_status == 0xA0 ){ retryFlag = false; RF_SW_CNTRL_TX = 1; Thread::wait(25); @@ -186,13 +214,11 @@ } else{ reset_bae; - Base_tm *tm_ptr2 = new Short_tm; + Base_tm *tm_ptr2 = NULL; SET_BCN_STANDBY(tm_ptr2); uint8_t standbyAck2 = 0; uint8_t bcn_main_status2 = (tm_ptr2->TM_string[2] & 0xEF); - if( ( bcn_main_status2 == 0xC0 )||( bcn_main_status2 == 0xA0 ) ) - standbyAck2 = 1; - if( standbyAck2 ){ + if( ( bcn_main_status2 == 0xC0 )||( bcn_main_status2 == 0xA0 ) ){ if( bcn_main_status2 == 0xA0 ){ retryFlag = false; RF_SW_CNTRL_TX = 1; @@ -202,7 +228,7 @@ } else{ Thread::wait(5000); - }\ + } } else{ retryFlag = false; @@ -248,18 +274,16 @@ } } else{ - power_off_bae; - gFLAGS = gFLAGS & (~BAE_SW_EN_FLAG); RF_SW_CNTRL_TX = 1; Thread::wait(25); RF_SW_CNTRL_TX = 0; gFLAGS = gFLAGS & (~RF_SW_STATUS_FLAG);/*RF_SW_STATUS_FLAG set to RF_COM_TX*/ } } - //COM_TX_CNTRL = 1; + COM_TX_CNTRL = 1; uint8_t adfConfigPass = 0xFF; for( int i = 0 ; i < COM_TX_CONFIG_LIMIT ; ++i ){ - /*PENDING: CONFIGURE ADF*/ + /*PENDING: CONFIGURE ADF and set adfConfigPass*/ if( adfConfigPass == 0xFF ){ break; } @@ -310,19 +334,76 @@ /*NOT Transmitted succesfully*/ COM_POWER_OFF_TX; P_CDMS_HK_MAIN; + Base_tm *ptr_tm = NULL; + STANDBY_PRCS(ptr_tm); + uint8_t standbyACK = 0x00; + uint8_t bcn_main_status = (ptr_tm->TM_string[2] & 0xEF); + if(( bcn_main_status == 0xC0 )||( bcn_main_status ==0xA0 )){ + standbyACK = 1; + } + if(standbyACK == 1){ + uint8_t ackReceived = 0x00; + Base_tm *tm_ptr = NULL; + P_BCN_TX_MAIN(tm_ptr); + uint8_t ackcode = tm_ptr->TM_string[2] & 0xEF; + if( (ackcode == 0xA0) || (ackcode == 0xC0)) + ackReceived = 0xFF; + /*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; + } + } + if( ackReceived == 0xFF ){ + Thread::wait(5000); + } + } + /*DELETE THE TM AFTER USE*/ + Base_tm *del_tm = ptr_tm; + 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; + } + } + RESET_CDMS; + } + } + else{ + /*ADF not configured*/ + gFLAGS = gFLAGS & (~COM_TX_STATUS_FLAG); + COM_POWER_OFF_TX; + P_CDMS_HK_MAIN; + Base_tm *ptr_tm = NULL; + STANDBY_PRCS(ptr_tm); + uint8_t standbyACK = 0x00; + uint8_t bcn_main_status = (ptr_tm->TM_string[2] & 0xEF); + if(( bcn_main_status == 0xC0 )||( bcn_main_status ==0xA0 )){ + standbyACK = 1; + } + if(standbyACK == 1){ uint8_t ackReceived = 0x00; - Base_tm *tm_ptr = new Short_tm; + Base_tm *tm_ptr = NULL; P_BCN_TX_MAIN(tm_ptr); uint8_t ackcode = tm_ptr->TM_string[2] & 0xEF; if( (ackcode == 0xA0) || (ackcode == 0xC0)) ackReceived = 0xFF; - if( ackReceived == 0xFF ){ - Thread::wait(5000); - RESET_CDMS; - } - else{ - RESET_CDMS; - } /*DELETE THE TM AFTER USE*/ Base_tm *del_tm = tm_ptr; int overCount = 0; @@ -338,28 +419,12 @@ break; } } - } - } - else{ - /*ADF not configured*/ - gFLAGS = gFLAGS & (~COM_TX_STATUS_FLAG); - COM_POWER_OFF_TX; - P_CDMS_HK_MAIN; - uint8_t ackReceived = 0x00; - Base_tm *tm_ptr = new Short_tm; - P_BCN_TX_MAIN(tm_ptr); - uint8_t ackcode = tm_ptr->TM_string[2] & 0xEF; - if( (ackcode == 0xA0) || (ackcode == 0xC0)) - ackReceived = 0xFF; - if( ackReceived == 0xFF ){ - Thread::wait(5000); - RESET_CDMS; - } - else{ - RESET_CDMS; + if( ackReceived == 0xFF ){ + Thread::wait(5000); + } } /*DELETE THE TM AFTER USE*/ - Base_tm *del_tm = tm_ptr; + Base_tm *del_tm = ptr_tm; int overCount = 0; while( del_tm != NULL ){ if( (overCount < TM_OVERFLOW_CONSTANT) ){ @@ -373,6 +438,7 @@ break; } } + RESET_CDMS; } /*gPC.puts("COMPLETED COM_POWER_ON_TX\r\n");*/ } \ No newline at end of file