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