To fix the hang problem
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE by
COM_POWER_ON_TX.h@169:451b54864992, 2016-04-22 (annotated)
- Committer:
- aniruddhv
- Date:
- Fri Apr 22 13:13:42 2016 +0000
- Revision:
- 169:451b54864992
- Parent:
- 160:ef280e6dda44
- Child:
- 187:2c7263530c57
- Child:
- 211:77bee0cbebfe
commented out BAE commands
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
aniruddhv | 144:4c20fcc105ce | 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 | 144:4c20fcc105ce | 4 | PUTshort_or_long(beacon_tc,SHORT_TC_CODE);\ |
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 | 144:4c20fcc105ce | 8 | beacon_tc->TC_string[1] = BCN_APID_SOURCE;\ |
aniruddhv | 144:4c20fcc105ce | 9 | beacon_tc->TC_string[2] = BCN_SERVICE;\ |
aniruddhv | 160:ef280e6dda44 | 10 | beacon_tc->TC_string[3] = 0xE2;\ |
aniruddhv | 160:ef280e6dda44 | 11 | beacon_tc->TC_string[4] = 0x01;\ |
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 | 144:4c20fcc105ce | 25 | PUTshort_or_long(reset_BAE,SHORT_TC_CODE);\ |
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 | 144:4c20fcc105ce | 29 | reset_BAE->TC_string[1] = BAE_APID_SOURCE;\ |
aniruddhv | 144:4c20fcc105ce | 30 | reset_BAE->TC_string[2] = BAE_SERVICE;\ |
aniruddhv | 144:4c20fcc105ce | 31 | reset_BAE->TC_string[3] = BAE_RESET_PID;\ |
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 | 144:4c20fcc105ce | 43 | Base_tm *del_tm = tm_ptr;\ |
aniruddhv | 137:489a93a04d6b | 44 | int overCount = 0;\ |
aniruddhv | 144:4c20fcc105ce | 45 | while( del_tm != NULL ){\ |
aniruddhv | 137:489a93a04d6b | 46 | if( (overCount < TM_OVERFLOW_CONSTANT) ){\ |
aniruddhv | 144:4c20fcc105ce | 47 | Base_tm *temp = del_tm->next_TM;\ |
aniruddhv | 144:4c20fcc105ce | 48 | delete del_tm;\ |
aniruddhv | 144:4c20fcc105ce | 49 | del_tm = temp;\ |
aniruddhv | 137:489a93a04d6b | 50 | ++overCount;\ |
aniruddhv | 137:489a93a04d6b | 51 | }\ |
aniruddhv | 137:489a93a04d6b | 52 | else{\ |
aniruddhv | 155:ca7365c03fd7 | 53 | RESET_CDMS;\ |
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 | 144:4c20fcc105ce | 62 | PUTshort_or_long(power_off_BAE,SHORT_TC_CODE);\ |
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 | 144:4c20fcc105ce | 66 | power_off_BAE->TC_string[1] = BAE_APID_SOURCE;\ |
aniruddhv | 144:4c20fcc105ce | 67 | power_off_BAE->TC_string[2] = BAE_SERVICE;\ |
aniruddhv | 144:4c20fcc105ce | 68 | power_off_BAE->TC_string[3] = BAE_POWER_OFF_PID;\ |
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 | 144:4c20fcc105ce | 80 | Base_tm *del_tm = tm_ptr;\ |
aniruddhv | 137:489a93a04d6b | 81 | int overCount = 0;\ |
aniruddhv | 144:4c20fcc105ce | 82 | while( del_tm != NULL ){\ |
aniruddhv | 137:489a93a04d6b | 83 | if( (overCount < TM_OVERFLOW_CONSTANT) ){\ |
aniruddhv | 144:4c20fcc105ce | 84 | Base_tm *temp = del_tm->next_TM;\ |
aniruddhv | 144:4c20fcc105ce | 85 | delete del_tm;\ |
aniruddhv | 144:4c20fcc105ce | 86 | del_tm = temp;\ |
aniruddhv | 144:4c20fcc105ce | 87 | ++overCount;\ |
aniruddhv | 144:4c20fcc105ce | 88 | }\ |
aniruddhv | 144:4c20fcc105ce | 89 | else{\ |
aniruddhv | 155:ca7365c03fd7 | 90 | RESET_CDMS;\ |
aniruddhv | 144:4c20fcc105ce | 91 | break;\ |
aniruddhv | 144:4c20fcc105ce | 92 | }\ |
aniruddhv | 144:4c20fcc105ce | 93 | }\ |
aniruddhv | 144:4c20fcc105ce | 94 | } |
aniruddhv | 144:4c20fcc105ce | 95 | |
aniruddhv | 144:4c20fcc105ce | 96 | #define P_CDMS_HK_MAIN {\ |
aniruddhv | 144:4c20fcc105ce | 97 | Base_tc *hk_main_ptr = new Short_tc;\ |
aniruddhv | 144:4c20fcc105ce | 98 | hk_main_ptr->next_TC = NULL;\ |
aniruddhv | 144:4c20fcc105ce | 99 | PUTshort_or_long(hk_main_ptr,SHORT_TC_CODE);\ |
aniruddhv | 144:4c20fcc105ce | 100 | PUTcrc_pass(hk_main_ptr,0x1);\ |
aniruddhv | 144:4c20fcc105ce | 101 | PUTexec_status(hk_main_ptr,0);\ |
aniruddhv | 144:4c20fcc105ce | 102 | hk_main_ptr->TC_string[0] = 0x01;\ |
aniruddhv | 144:4c20fcc105ce | 103 | hk_main_ptr->TC_string[1] = 0x81;\ |
aniruddhv | 144:4c20fcc105ce | 104 | hk_main_ptr->TC_string[2] = 0x81;\ |
aniruddhv | 144:4c20fcc105ce | 105 | hk_main_ptr->TC_string[3] = 0x04;\ |
aniruddhv | 144:4c20fcc105ce | 106 | hk_main_ptr->TC_string[4] = 0;\ |
aniruddhv | 144:4c20fcc105ce | 107 | hk_main_ptr->TC_string[5] = 0;\ |
aniruddhv | 144:4c20fcc105ce | 108 | hk_main_ptr->TC_string[6] = 0;\ |
aniruddhv | 144:4c20fcc105ce | 109 | hk_main_ptr->TC_string[7] = 0;\ |
aniruddhv | 144:4c20fcc105ce | 110 | hk_main_ptr->TC_string[8] = 0;\ |
aniruddhv | 144:4c20fcc105ce | 111 | uint16_t crc16 = crc16_gen(hk_main_ptr->TC_string, 9);\ |
aniruddhv | 144:4c20fcc105ce | 112 | hk_main_ptr->TC_string[9] = (crc16 & 0xFF00)>>8;\ |
aniruddhv | 144:4c20fcc105ce | 113 | hk_main_ptr->TC_string[10] = (crc16 & 0x00FF);\ |
aniruddhv | 144:4c20fcc105ce | 114 | Base_tm *tm_ptr = new Short_tm;\ |
aniruddhv | 155:ca7365c03fd7 | 115 | tm_ptr = FCTN_CDMS_RLY_TMTC(hk_main_ptr);\ |
aniruddhv | 144:4c20fcc105ce | 116 | /*DELETE THE TM AFTER USE*/\ |
aniruddhv | 144:4c20fcc105ce | 117 | Base_tm *del_tm = tm_ptr;\ |
aniruddhv | 144:4c20fcc105ce | 118 | int overCount = 0;\ |
aniruddhv | 144:4c20fcc105ce | 119 | while( del_tm != NULL ){\ |
aniruddhv | 144:4c20fcc105ce | 120 | if( (overCount < TM_OVERFLOW_CONSTANT) ){\ |
aniruddhv | 144:4c20fcc105ce | 121 | Base_tm *temp = del_tm->next_TM;\ |
aniruddhv | 144:4c20fcc105ce | 122 | delete del_tm;\ |
aniruddhv | 144:4c20fcc105ce | 123 | del_tm = temp;\ |
aniruddhv | 137:489a93a04d6b | 124 | ++overCount;\ |
aniruddhv | 137:489a93a04d6b | 125 | }\ |
aniruddhv | 137:489a93a04d6b | 126 | else{\ |
aniruddhv | 155:ca7365c03fd7 | 127 | RESET_CDMS;\ |
aniruddhv | 137:489a93a04d6b | 128 | break;\ |
aniruddhv | 137:489a93a04d6b | 129 | }\ |
aniruddhv | 137:489a93a04d6b | 130 | }\ |
aniruddhv | 137:489a93a04d6b | 131 | } |
aniruddhv | 137:489a93a04d6b | 132 | |
aniruddhv | 144:4c20fcc105ce | 133 | #define P_BCN_TX_MAIN(tm_ptr) {\ |
aniruddhv | 144:4c20fcc105ce | 134 | Base_tc *bcn_tx_main_ptr = new Short_tc;\ |
aniruddhv | 144:4c20fcc105ce | 135 | bcn_tx_main_ptr->next_TC = NULL;\ |
aniruddhv | 144:4c20fcc105ce | 136 | PUTshort_or_long(bcn_tx_main_ptr,SHORT_TC_CODE);\ |
aniruddhv | 144:4c20fcc105ce | 137 | PUTcrc_pass(bcn_tx_main_ptr,0x1);\ |
aniruddhv | 144:4c20fcc105ce | 138 | PUTexec_status(bcn_tx_main_ptr,0);\ |
aniruddhv | 144:4c20fcc105ce | 139 | bcn_tx_main_ptr->TC_string[0] = 0x01;\ |
aniruddhv | 144:4c20fcc105ce | 140 | bcn_tx_main_ptr->TC_string[1] = 0x41;\ |
aniruddhv | 144:4c20fcc105ce | 141 | bcn_tx_main_ptr->TC_string[2] = 0x81;\ |
aniruddhv | 144:4c20fcc105ce | 142 | bcn_tx_main_ptr->TC_string[3] = 0x07;\ |
aniruddhv | 144:4c20fcc105ce | 143 | bcn_tx_main_ptr->TC_string[4] = 0;\ |
aniruddhv | 144:4c20fcc105ce | 144 | bcn_tx_main_ptr->TC_string[5] = 0;\ |
aniruddhv | 144:4c20fcc105ce | 145 | bcn_tx_main_ptr->TC_string[6] = 0;\ |
aniruddhv | 144:4c20fcc105ce | 146 | bcn_tx_main_ptr->TC_string[7] = 0;\ |
aniruddhv | 144:4c20fcc105ce | 147 | bcn_tx_main_ptr->TC_string[8] = 0;\ |
aniruddhv | 144:4c20fcc105ce | 148 | uint16_t crc16 = crc16_gen(bcn_tx_main_ptr->TC_string, 9);\ |
aniruddhv | 144:4c20fcc105ce | 149 | bcn_tx_main_ptr->TC_string[9] = (crc16 & 0xFF00)>>8;\ |
aniruddhv | 144:4c20fcc105ce | 150 | bcn_tx_main_ptr->TC_string[10] = (crc16 & 0x00FF);\ |
aniruddhv | 155:ca7365c03fd7 | 151 | tm_ptr = FCTN_CDMS_RLY_TMTC(bcn_tx_main_ptr);\ |
aniruddhv | 144:4c20fcc105ce | 152 | } |
aniruddhv | 144:4c20fcc105ce | 153 | |
aniruddhv | 144:4c20fcc105ce | 154 | void COM_POWER_ON_TX() { |
aniruddhv | 144:4c20fcc105ce | 155 | if (DEBUG) |
aniruddhv | 144:4c20fcc105ce | 156 | gPC.puts("Inside COM_POWER_ON_TX\r\n"); |
aniruddhv | 144:4c20fcc105ce | 157 | if( !(gFLAGS & COM_TX_FLAG) ){ |
aniruddhv | 144:4c20fcc105ce | 158 | gFLAGS = gFLAGS | COM_TX_FLAG; |
aniruddhv | 144:4c20fcc105ce | 159 | if( gFLAGS & BAE_SW_EN_FLAG ){ |
aniruddhv | 144:4c20fcc105ce | 160 | /*WARNING: INFINITE WHILE LOOP POSSIBLE: if standby ack received and bcn tx main status = 0*/ |
aniruddhv | 144:4c20fcc105ce | 161 | bool retryFlag = true; |
aniruddhv | 144:4c20fcc105ce | 162 | while( retryFlag == true ){ |
aniruddhv | 144:4c20fcc105ce | 163 | Base_tm *tm_ptr = new Short_tm; |
aniruddhv | 144:4c20fcc105ce | 164 | SET_BCN_STANDBY(tm_ptr); |
aniruddhv | 144:4c20fcc105ce | 165 | uint8_t standbyAck = 0; |
aniruddhv | 156:f661cf9e02d1 | 166 | uint8_t bcn_main_status = (tm_ptr->TM_string[2] & 0xEF); |
aniruddhv | 156:f661cf9e02d1 | 167 | if(( bcn_main_status == 0xC0 )||( bcn_main_status ==0xA0 )) |
aniruddhv | 144:4c20fcc105ce | 168 | standbyAck = 1; |
aniruddhv | 169:451b54864992 | 169 | if( /*standbyAck*/ true ){ |
aniruddhv | 144:4c20fcc105ce | 170 | /*ACK RECCEIVED*/ |
aniruddhv | 169:451b54864992 | 171 | if( /*bcn_main_status == 0xA0*/ true ){ |
aniruddhv | 144:4c20fcc105ce | 172 | retryFlag = false; |
aniruddhv | 144:4c20fcc105ce | 173 | RF_SW_CNTRL_TX = 1; |
aniruddhv | 144:4c20fcc105ce | 174 | Thread::wait(25); |
aniruddhv | 144:4c20fcc105ce | 175 | RF_SW_CNTRL_TX = 0; |
aniruddhv | 156:f661cf9e02d1 | 176 | gFLAGS = gFLAGS & (~RF_SW_STATUS_FLAG);/*RF_SW_STATUS_FLAG set to RF_COM_TX*/ |
aniruddhv | 144:4c20fcc105ce | 177 | } |
aniruddhv | 144:4c20fcc105ce | 178 | else{ |
aniruddhv | 144:4c20fcc105ce | 179 | Thread::wait(5000); |
aniruddhv | 144:4c20fcc105ce | 180 | } |
aniruddhv | 144:4c20fcc105ce | 181 | } |
aniruddhv | 144:4c20fcc105ce | 182 | else{ |
aniruddhv | 144:4c20fcc105ce | 183 | reset_bae; |
aniruddhv | 144:4c20fcc105ce | 184 | Base_tm *tm_ptr2 = new Short_tm; |
aniruddhv | 144:4c20fcc105ce | 185 | SET_BCN_STANDBY(tm_ptr2); |
aniruddhv | 144:4c20fcc105ce | 186 | uint8_t standbyAck2 = 0; |
aniruddhv | 156:f661cf9e02d1 | 187 | uint8_t bcn_main_status2 = (tm_ptr2->TM_string[2] & 0xEF); |
aniruddhv | 156:f661cf9e02d1 | 188 | if( ( bcn_main_status2 == 0xC0 )||( bcn_main_status2 == 0xA0 ) ) |
aniruddhv | 144:4c20fcc105ce | 189 | standbyAck2 = 1; |
aniruddhv | 144:4c20fcc105ce | 190 | if( standbyAck2 ){ |
aniruddhv | 156:f661cf9e02d1 | 191 | if( bcn_main_status2 == 0xA0 ){ |
aniruddhv | 144:4c20fcc105ce | 192 | retryFlag = false; |
aniruddhv | 144:4c20fcc105ce | 193 | RF_SW_CNTRL_TX = 1; |
aniruddhv | 144:4c20fcc105ce | 194 | Thread::wait(25); |
aniruddhv | 144:4c20fcc105ce | 195 | RF_SW_CNTRL_TX = 0; |
aniruddhv | 144:4c20fcc105ce | 196 | gFLAGS = gFLAGS & (~RF_SW_STATUS_FLAG); |
aniruddhv | 144:4c20fcc105ce | 197 | } |
aniruddhv | 144:4c20fcc105ce | 198 | else{ |
aniruddhv | 144:4c20fcc105ce | 199 | Thread::wait(5000); |
aniruddhv | 144:4c20fcc105ce | 200 | }\ |
aniruddhv | 144:4c20fcc105ce | 201 | } |
aniruddhv | 144:4c20fcc105ce | 202 | else{ |
aniruddhv | 144:4c20fcc105ce | 203 | retryFlag = false; |
aniruddhv | 144:4c20fcc105ce | 204 | power_off_bae; |
aniruddhv | 144:4c20fcc105ce | 205 | gFLAGS = gFLAGS | COM_AUTO_POWER_OFF_BAE_FLAG; |
aniruddhv | 144:4c20fcc105ce | 206 | gFLAGS = gFLAGS & (~BAE_SW_EN_FLAG); |
aniruddhv | 144:4c20fcc105ce | 207 | RF_SW_CNTRL_TX = 1; |
aniruddhv | 144:4c20fcc105ce | 208 | Thread::wait(25); |
aniruddhv | 144:4c20fcc105ce | 209 | RF_SW_CNTRL_TX = 0; |
aniruddhv | 156:f661cf9e02d1 | 210 | gFLAGS = gFLAGS & (~RF_SW_STATUS_FLAG);/*RF_SW_STATUS_FLAG set to RF_COM_TX*/ |
aniruddhv | 144:4c20fcc105ce | 211 | } |
aniruddhv | 144:4c20fcc105ce | 212 | /*DELETE THE TM AFTER USE*/ |
aniruddhv | 144:4c20fcc105ce | 213 | Base_tm *del_tm = tm_ptr2; |
aniruddhv | 144:4c20fcc105ce | 214 | int overCount = 0; |
aniruddhv | 144:4c20fcc105ce | 215 | while( del_tm != NULL ){ |
aniruddhv | 144:4c20fcc105ce | 216 | if( (overCount < TM_OVERFLOW_CONSTANT) ){ |
aniruddhv | 144:4c20fcc105ce | 217 | Base_tm *temp = del_tm->next_TM; |
aniruddhv | 144:4c20fcc105ce | 218 | delete del_tm; |
aniruddhv | 144:4c20fcc105ce | 219 | del_tm = temp; |
aniruddhv | 144:4c20fcc105ce | 220 | ++overCount; |
aniruddhv | 144:4c20fcc105ce | 221 | } |
aniruddhv | 144:4c20fcc105ce | 222 | else{ |
aniruddhv | 155:ca7365c03fd7 | 223 | RESET_CDMS; |
aniruddhv | 144:4c20fcc105ce | 224 | break; |
aniruddhv | 144:4c20fcc105ce | 225 | } |
aniruddhv | 144:4c20fcc105ce | 226 | } |
aniruddhv | 144:4c20fcc105ce | 227 | } |
aniruddhv | 144:4c20fcc105ce | 228 | /*DELETE THE TM AFTER USE*/ |
aniruddhv | 144:4c20fcc105ce | 229 | Base_tm *del_tm = tm_ptr; |
aniruddhv | 144:4c20fcc105ce | 230 | int overCount = 0; |
aniruddhv | 144:4c20fcc105ce | 231 | while( del_tm != NULL ){ |
aniruddhv | 144:4c20fcc105ce | 232 | if( (overCount < TM_OVERFLOW_CONSTANT) ){ |
aniruddhv | 144:4c20fcc105ce | 233 | Base_tm *temp = del_tm->next_TM; |
aniruddhv | 144:4c20fcc105ce | 234 | delete del_tm; |
aniruddhv | 144:4c20fcc105ce | 235 | del_tm = temp; |
aniruddhv | 144:4c20fcc105ce | 236 | ++overCount; |
aniruddhv | 144:4c20fcc105ce | 237 | } |
aniruddhv | 144:4c20fcc105ce | 238 | else{ |
aniruddhv | 155:ca7365c03fd7 | 239 | RESET_CDMS; |
aniruddhv | 144:4c20fcc105ce | 240 | break; |
aniruddhv | 144:4c20fcc105ce | 241 | } |
aniruddhv | 144:4c20fcc105ce | 242 | } |
aniruddhv | 144:4c20fcc105ce | 243 | } |
aniruddhv | 144:4c20fcc105ce | 244 | } |
aniruddhv | 144:4c20fcc105ce | 245 | else{ |
aniruddhv | 144:4c20fcc105ce | 246 | power_off_bae; |
aniruddhv | 144:4c20fcc105ce | 247 | gFLAGS = gFLAGS & (~BAE_SW_EN_FLAG); |
aniruddhv | 144:4c20fcc105ce | 248 | RF_SW_CNTRL_TX = 1; |
aniruddhv | 144:4c20fcc105ce | 249 | Thread::wait(25); |
aniruddhv | 144:4c20fcc105ce | 250 | RF_SW_CNTRL_TX = 0; |
aniruddhv | 156:f661cf9e02d1 | 251 | gFLAGS = gFLAGS & (~RF_SW_STATUS_FLAG);/*RF_SW_STATUS_FLAG set to RF_COM_TX*/ |
aniruddhv | 144:4c20fcc105ce | 252 | } |
aniruddhv | 144:4c20fcc105ce | 253 | } |
aniruddhv | 169:451b54864992 | 254 | //COM_TX_CNTRL = 1; |
aniruddhv | 144:4c20fcc105ce | 255 | uint8_t adfConfigPass = 0xFF; |
aniruddhv | 144:4c20fcc105ce | 256 | for( int i = 0 ; i < COM_TX_CONFIG_LIMIT ; ++i ){ |
aniruddhv | 144:4c20fcc105ce | 257 | /*PENDING: CONFIGURE ADF*/ |
aniruddhv | 144:4c20fcc105ce | 258 | if( adfConfigPass == 0xFF ){ |
aniruddhv | 144:4c20fcc105ce | 259 | break; |
aniruddhv | 144:4c20fcc105ce | 260 | } |
aniruddhv | 144:4c20fcc105ce | 261 | } |
aniruddhv | 144:4c20fcc105ce | 262 | if( adfConfigPass == 0xFF ){ |
aniruddhv | 144:4c20fcc105ce | 263 | /*adf successfully configured*/ |
aniruddhv | 155:ca7365c03fd7 | 264 | gFLAGS = gFLAGS | COM_TX_STATUS_FLAG; |
aniruddhv | 144:4c20fcc105ce | 265 | /*CALL SIGN*/ |
aniruddhv | 144:4c20fcc105ce | 266 | Base_tm *power_on_tm = NULL; |
aniruddhv | 144:4c20fcc105ce | 267 | Base_tm *power_on_tm_head = NULL; |
aniruddhv | 144:4c20fcc105ce | 268 | get_call_sign( power_on_tm_head ); |
aniruddhv | 144:4c20fcc105ce | 269 | power_on_tm = power_on_tm_head; |
aniruddhv | 144:4c20fcc105ce | 270 | /*ACK L1*/ |
aniruddhv | 144:4c20fcc105ce | 271 | get_ack_l1(power_on_tm->next_TM); |
aniruddhv | 144:4c20fcc105ce | 272 | int overFlowCountADF = 0; |
aniruddhv | 144:4c20fcc105ce | 273 | while( power_on_tm->next_TM != NULL ){ |
aniruddhv | 144:4c20fcc105ce | 274 | if( overFlowCountADF < TM_OVERFLOW_CONSTANT ){ |
aniruddhv | 144:4c20fcc105ce | 275 | power_on_tm = power_on_tm->next_TM; |
aniruddhv | 144:4c20fcc105ce | 276 | ++overFlowCountADF; |
aniruddhv | 144:4c20fcc105ce | 277 | } |
aniruddhv | 144:4c20fcc105ce | 278 | else{ |
aniruddhv | 155:ca7365c03fd7 | 279 | RESET_CDMS; |
aniruddhv | 144:4c20fcc105ce | 280 | break; |
aniruddhv | 144:4c20fcc105ce | 281 | } |
aniruddhv | 144:4c20fcc105ce | 282 | } |
aniruddhv | 144:4c20fcc105ce | 283 | get_tc_list(power_on_tm->next_TM, 0x00); |
aniruddhv | 144:4c20fcc105ce | 284 | /*Call Sign, ACK_L1, TC_LIST*/ |
aniruddhv | 169:451b54864992 | 285 | snd_tm.head_pointer(power_on_tm_head); |
aniruddhv | 169:451b54864992 | 286 | transmit_adf; |
aniruddhv | 156:f661cf9e02d1 | 287 | uint8_t transmissionPass = 0xFF; |
aniruddhv | 156:f661cf9e02d1 | 288 | /*PENDING: get acknowledgement of transmission*/ |
aniruddhv | 144:4c20fcc105ce | 289 | /*deleting the telemetry*/ |
aniruddhv | 144:4c20fcc105ce | 290 | power_on_tm = power_on_tm_head; |
aniruddhv | 144:4c20fcc105ce | 291 | overFlowCountADF = 0; |
aniruddhv | 144:4c20fcc105ce | 292 | while( power_on_tm != NULL ){ |
aniruddhv | 144:4c20fcc105ce | 293 | if( overFlowCountADF < TM_OVERFLOW_CONSTANT ){ |
aniruddhv | 144:4c20fcc105ce | 294 | Base_tm *temp = power_on_tm->next_TM; |
aniruddhv | 144:4c20fcc105ce | 295 | delete power_on_tm; |
aniruddhv | 144:4c20fcc105ce | 296 | power_on_tm = temp; |
aniruddhv | 144:4c20fcc105ce | 297 | ++overFlowCountADF; |
aniruddhv | 144:4c20fcc105ce | 298 | } |
aniruddhv | 144:4c20fcc105ce | 299 | else{ |
aniruddhv | 155:ca7365c03fd7 | 300 | RESET_CDMS; |
aniruddhv | 144:4c20fcc105ce | 301 | break; |
aniruddhv | 144:4c20fcc105ce | 302 | } |
aniruddhv | 144:4c20fcc105ce | 303 | } |
aniruddhv | 156:f661cf9e02d1 | 304 | if( transmissionPass == 0 ){ |
aniruddhv | 156:f661cf9e02d1 | 305 | /*NOT Transmitted succesfully*/ |
aniruddhv | 144:4c20fcc105ce | 306 | COM_POWER_OFF_TX; |
aniruddhv | 144:4c20fcc105ce | 307 | P_CDMS_HK_MAIN; |
aniruddhv | 144:4c20fcc105ce | 308 | uint8_t ackReceived = 0x00; |
aniruddhv | 156:f661cf9e02d1 | 309 | Base_tm *tm_ptr = new Short_tm; |
aniruddhv | 144:4c20fcc105ce | 310 | P_BCN_TX_MAIN(tm_ptr); |
aniruddhv | 156:f661cf9e02d1 | 311 | uint8_t ackcode = tm_ptr->TM_string[2] & 0xEF; |
aniruddhv | 156:f661cf9e02d1 | 312 | if( (ackcode == 0xA0) || (ackcode == 0xC0)) |
aniruddhv | 156:f661cf9e02d1 | 313 | ackReceived = 0xFF; |
aniruddhv | 144:4c20fcc105ce | 314 | if( ackReceived == 0xFF ){ |
aniruddhv | 144:4c20fcc105ce | 315 | Thread::wait(5000); |
aniruddhv | 155:ca7365c03fd7 | 316 | RESET_CDMS; |
aniruddhv | 144:4c20fcc105ce | 317 | } |
aniruddhv | 144:4c20fcc105ce | 318 | else{ |
aniruddhv | 155:ca7365c03fd7 | 319 | RESET_CDMS; |
aniruddhv | 144:4c20fcc105ce | 320 | } |
aniruddhv | 144:4c20fcc105ce | 321 | /*DELETE THE TM AFTER USE*/ |
aniruddhv | 144:4c20fcc105ce | 322 | Base_tm *del_tm = tm_ptr; |
aniruddhv | 144:4c20fcc105ce | 323 | int overCount = 0; |
aniruddhv | 144:4c20fcc105ce | 324 | while( del_tm != NULL ){ |
aniruddhv | 144:4c20fcc105ce | 325 | if( (overCount < TM_OVERFLOW_CONSTANT) ){ |
aniruddhv | 144:4c20fcc105ce | 326 | Base_tm *temp = del_tm->next_TM; |
aniruddhv | 144:4c20fcc105ce | 327 | delete del_tm; |
aniruddhv | 144:4c20fcc105ce | 328 | del_tm = temp; |
aniruddhv | 144:4c20fcc105ce | 329 | ++overCount; |
aniruddhv | 144:4c20fcc105ce | 330 | } |
aniruddhv | 144:4c20fcc105ce | 331 | else{ |
aniruddhv | 155:ca7365c03fd7 | 332 | RESET_CDMS; |
aniruddhv | 144:4c20fcc105ce | 333 | break; |
aniruddhv | 144:4c20fcc105ce | 334 | } |
aniruddhv | 144:4c20fcc105ce | 335 | } |
aniruddhv | 144:4c20fcc105ce | 336 | } |
aniruddhv | 144:4c20fcc105ce | 337 | } |
aniruddhv | 144:4c20fcc105ce | 338 | else{ |
aniruddhv | 155:ca7365c03fd7 | 339 | /*ADF not configured*/ |
aniruddhv | 155:ca7365c03fd7 | 340 | gFLAGS = gFLAGS & (~COM_TX_STATUS_FLAG); |
aniruddhv | 144:4c20fcc105ce | 341 | COM_POWER_OFF_TX; |
aniruddhv | 144:4c20fcc105ce | 342 | P_CDMS_HK_MAIN; |
aniruddhv | 144:4c20fcc105ce | 343 | uint8_t ackReceived = 0x00; |
aniruddhv | 156:f661cf9e02d1 | 344 | Base_tm *tm_ptr = new Short_tm; |
aniruddhv | 144:4c20fcc105ce | 345 | P_BCN_TX_MAIN(tm_ptr); |
aniruddhv | 156:f661cf9e02d1 | 346 | uint8_t ackcode = tm_ptr->TM_string[2] & 0xEF; |
aniruddhv | 156:f661cf9e02d1 | 347 | if( (ackcode == 0xA0) || (ackcode == 0xC0)) |
aniruddhv | 156:f661cf9e02d1 | 348 | ackReceived = 0xFF; |
aniruddhv | 144:4c20fcc105ce | 349 | if( ackReceived == 0xFF ){ |
aniruddhv | 144:4c20fcc105ce | 350 | Thread::wait(5000); |
aniruddhv | 155:ca7365c03fd7 | 351 | RESET_CDMS; |
aniruddhv | 144:4c20fcc105ce | 352 | } |
aniruddhv | 144:4c20fcc105ce | 353 | else{ |
aniruddhv | 155:ca7365c03fd7 | 354 | RESET_CDMS; |
aniruddhv | 144:4c20fcc105ce | 355 | } |
aniruddhv | 144:4c20fcc105ce | 356 | /*DELETE THE TM AFTER USE*/ |
aniruddhv | 144:4c20fcc105ce | 357 | Base_tm *del_tm = tm_ptr; |
aniruddhv | 144:4c20fcc105ce | 358 | int overCount = 0; |
aniruddhv | 144:4c20fcc105ce | 359 | while( del_tm != NULL ){ |
aniruddhv | 144:4c20fcc105ce | 360 | if( (overCount < TM_OVERFLOW_CONSTANT) ){ |
aniruddhv | 144:4c20fcc105ce | 361 | Base_tm *temp = del_tm->next_TM; |
aniruddhv | 144:4c20fcc105ce | 362 | delete del_tm; |
aniruddhv | 144:4c20fcc105ce | 363 | del_tm = temp; |
aniruddhv | 144:4c20fcc105ce | 364 | ++overCount; |
aniruddhv | 144:4c20fcc105ce | 365 | } |
aniruddhv | 144:4c20fcc105ce | 366 | else{ |
aniruddhv | 155:ca7365c03fd7 | 367 | RESET_CDMS; |
aniruddhv | 144:4c20fcc105ce | 368 | break; |
aniruddhv | 144:4c20fcc105ce | 369 | } |
aniruddhv | 144:4c20fcc105ce | 370 | } |
aniruddhv | 144:4c20fcc105ce | 371 | } |
aniruddhv | 144:4c20fcc105ce | 372 | /*gPC.puts("COMPLETED COM_POWER_ON_TX\r\n");*/ |
shreeshas95 | 4:104dd82c99b8 | 373 | } |