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