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