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