To fix the hang problem
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE by
COM_POWER_OFF_TX.h@213:867de6d350fa, 2016-07-03 (annotated)
- Committer:
- aniruddhv
- Date:
- Sun Jul 03 09:26:42 2016 +0000
- Revision:
- 213:867de6d350fa
- Parent:
- 12:ffdb29353058
- 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 RESET_CDMS {\ |
aniruddhv | 213:867de6d350fa | 2 | Base_tc *RESET_tc = new Short_tc;\ |
aniruddhv | 213:867de6d350fa | 3 | RESET_tc->next_TC = NULL;\ |
aniruddhv | 213:867de6d350fa | 4 | PUTshort_or_long(RESET_tc,SHORT_TC_CODE);\ |
aniruddhv | 213:867de6d350fa | 5 | PUTcrc_pass(RESET_tc,0x1);\ |
aniruddhv | 213:867de6d350fa | 6 | PUTexec_status(RESET_tc,0);\ |
aniruddhv | 213:867de6d350fa | 7 | RESET_tc->TC_string[0] = 0x01;\ |
aniruddhv | 213:867de6d350fa | 8 | RESET_tc->TC_string[1] = 0x81;\ |
aniruddhv | 213:867de6d350fa | 9 | RESET_tc->TC_string[2] = 0x81;\ |
aniruddhv | 213:867de6d350fa | 10 | RESET_tc->TC_string[3] = 0x38;\ |
aniruddhv | 213:867de6d350fa | 11 | RESET_tc->TC_string[4] = 0;\ |
aniruddhv | 213:867de6d350fa | 12 | RESET_tc->TC_string[5] = 0;\ |
aniruddhv | 213:867de6d350fa | 13 | RESET_tc->TC_string[6] = 0;\ |
aniruddhv | 213:867de6d350fa | 14 | RESET_tc->TC_string[7] = 0;\ |
aniruddhv | 213:867de6d350fa | 15 | RESET_tc->TC_string[8] = 0;\ |
aniruddhv | 213:867de6d350fa | 16 | uint16_t crc16 = crc16_gen(RESET_tc->TC_string, 9);\ |
aniruddhv | 213:867de6d350fa | 17 | RESET_tc->TC_string[9] = (crc16 & 0xFF00)>>8;\ |
aniruddhv | 213:867de6d350fa | 18 | RESET_tc->TC_string[10] = (crc16 & 0x00FF);\ |
aniruddhv | 213:867de6d350fa | 19 | Base_tm *tm_ptr = NULL;\ |
aniruddhv | 213:867de6d350fa | 20 | tm_ptr = FCTN_CDMS_RLY_TMTC(RESET_tc);\ |
aniruddhv | 213:867de6d350fa | 21 | delete RESET_tc;\ |
aniruddhv | 213:867de6d350fa | 22 | /*DELETE THE TM AFTER USE*/\ |
aniruddhv | 213:867de6d350fa | 23 | Base_tm *del_tm = tm_ptr;\ |
aniruddhv | 213:867de6d350fa | 24 | while( del_tm != NULL ){\ |
aniruddhv | 213:867de6d350fa | 25 | Base_tm *temp = del_tm->next_TM;\ |
aniruddhv | 213:867de6d350fa | 26 | delete del_tm;\ |
aniruddhv | 213:867de6d350fa | 27 | del_tm = temp;\ |
aniruddhv | 213:867de6d350fa | 28 | }\ |
aniruddhv | 213:867de6d350fa | 29 | } |
aniruddhv | 213:867de6d350fa | 30 | |
aniruddhv | 213:867de6d350fa | 31 | #define power_on_bae {\ |
aniruddhv | 213:867de6d350fa | 32 | Base_tc *power_on_BAE = new Short_tc;\ |
aniruddhv | 213:867de6d350fa | 33 | power_on_BAE->next_TC = NULL;\ |
aniruddhv | 213:867de6d350fa | 34 | PUTshort_or_long(power_on_BAE,SHORT_TC_CODE);\ |
aniruddhv | 213:867de6d350fa | 35 | PUTcrc_pass(power_on_BAE,0x1);\ |
aniruddhv | 213:867de6d350fa | 36 | PUTexec_status(power_on_BAE,0);\ |
aniruddhv | 213:867de6d350fa | 37 | power_on_BAE->TC_string[0] = 0x01;\ |
aniruddhv | 213:867de6d350fa | 38 | power_on_BAE->TC_string[1] = BAE_APID_SOURCE;\ |
aniruddhv | 213:867de6d350fa | 39 | power_on_BAE->TC_string[2] = BAE_SERVICE;\ |
aniruddhv | 213:867de6d350fa | 40 | power_on_BAE->TC_string[3] = BAE_POWER_ON_PID;\ |
aniruddhv | 213:867de6d350fa | 41 | power_on_BAE->TC_string[4] = 0;\ |
aniruddhv | 213:867de6d350fa | 42 | power_on_BAE->TC_string[5] = 0;\ |
aniruddhv | 213:867de6d350fa | 43 | power_on_BAE->TC_string[6] = 0;\ |
aniruddhv | 213:867de6d350fa | 44 | power_on_BAE->TC_string[7] = 0;\ |
aniruddhv | 213:867de6d350fa | 45 | power_on_BAE->TC_string[8] = 0;\ |
aniruddhv | 213:867de6d350fa | 46 | uint16_t crc16 = crc16_gen(power_on_BAE->TC_string, 9);\ |
aniruddhv | 213:867de6d350fa | 47 | power_on_BAE->TC_string[9] = (crc16 & 0xFF00)>>8;\ |
aniruddhv | 213:867de6d350fa | 48 | power_on_BAE->TC_string[10] = (crc16 & 0x00FF);\ |
aniruddhv | 213:867de6d350fa | 49 | Base_tm *tm_ptr = NULL;\ |
aniruddhv | 213:867de6d350fa | 50 | tm_ptr = FCTN_CDMS_RLY_TMTC(power_on_BAE);\ |
aniruddhv | 213:867de6d350fa | 51 | delete power_on_BAE;\ |
aniruddhv | 213:867de6d350fa | 52 | /*DELETE THE TM AFTER USE*/\ |
aniruddhv | 213:867de6d350fa | 53 | Base_tm *del_tm = tm_ptr;\ |
aniruddhv | 213:867de6d350fa | 54 | int overCount = 0;\ |
aniruddhv | 213:867de6d350fa | 55 | while( del_tm != NULL ){\ |
aniruddhv | 213:867de6d350fa | 56 | if( (overCount < TM_OVERFLOW_CONSTANT) ){\ |
aniruddhv | 213:867de6d350fa | 57 | Base_tm *temp = del_tm->next_TM;\ |
aniruddhv | 213:867de6d350fa | 58 | delete del_tm;\ |
aniruddhv | 213:867de6d350fa | 59 | del_tm = temp;\ |
aniruddhv | 213:867de6d350fa | 60 | ++overCount;\ |
aniruddhv | 213:867de6d350fa | 61 | }\ |
aniruddhv | 213:867de6d350fa | 62 | else{\ |
aniruddhv | 213:867de6d350fa | 63 | RESET_CDMS;\ |
aniruddhv | 213:867de6d350fa | 64 | break;\ |
aniruddhv | 213:867de6d350fa | 65 | }\ |
aniruddhv | 213:867de6d350fa | 66 | }\ |
aniruddhv | 213:867de6d350fa | 67 | } |
aniruddhv | 213:867de6d350fa | 68 | |
aniruddhv | 213:867de6d350fa | 69 | #define resume_bcn {\ |
aniruddhv | 213:867de6d350fa | 70 | Base_tc *beacon_tc = new Long_tc;\ |
aniruddhv | 213:867de6d350fa | 71 | beacon_tc->next_TC = NULL;\ |
aniruddhv | 213:867de6d350fa | 72 | PUTshort_or_long(beacon_tc,LONG_TC_CODE);\ |
aniruddhv | 213:867de6d350fa | 73 | PUTcrc_pass(beacon_tc,0x1);\ |
aniruddhv | 213:867de6d350fa | 74 | PUTexec_status(beacon_tc,0);\ |
aniruddhv | 213:867de6d350fa | 75 | beacon_tc->TC_string[0] = 0x01;\ |
aniruddhv | 213:867de6d350fa | 76 | beacon_tc->TC_string[1] = BCN_APID_SOURCE;\ |
aniruddhv | 213:867de6d350fa | 77 | beacon_tc->TC_string[2] = BCN_SERVICE;\ |
aniruddhv | 213:867de6d350fa | 78 | beacon_tc->TC_string[3] = 0xE2;\ |
aniruddhv | 213:867de6d350fa | 79 | beacon_tc->TC_string[4] = 0x00;\ |
aniruddhv | 213:867de6d350fa | 80 | beacon_tc->TC_string[5] = 0;\ |
aniruddhv | 213:867de6d350fa | 81 | beacon_tc->TC_string[6] = 0;\ |
aniruddhv | 213:867de6d350fa | 82 | beacon_tc->TC_string[7] = 0;\ |
aniruddhv | 213:867de6d350fa | 83 | beacon_tc->TC_string[8] = 0;\ |
aniruddhv | 213:867de6d350fa | 84 | uint16_t crc16 = crc16_gen(beacon_tc->TC_string, 9);\ |
aniruddhv | 213:867de6d350fa | 85 | beacon_tc->TC_string[9] = (crc16 & 0xFF00)>>8;\ |
aniruddhv | 213:867de6d350fa | 86 | beacon_tc->TC_string[10] = (crc16 & 0x00FF);\ |
aniruddhv | 213:867de6d350fa | 87 | for(int i = 11; i < 135; i++){\ |
aniruddhv | 213:867de6d350fa | 88 | beacon_tc->TC_string[i] = 0;\ |
aniruddhv | 213:867de6d350fa | 89 | }\ |
aniruddhv | 213:867de6d350fa | 90 | Base_tm *tm_ptr = NULL;\ |
aniruddhv | 213:867de6d350fa | 91 | tm_ptr = FCTN_CDMS_RLY_TMTC(beacon_tc);\ |
aniruddhv | 213:867de6d350fa | 92 | delete beacon_tc;\ |
aniruddhv | 213:867de6d350fa | 93 | /*DELETE THE TM AFTER USE*/\ |
aniruddhv | 213:867de6d350fa | 94 | Base_tm *del_tm = tm_ptr;\ |
aniruddhv | 213:867de6d350fa | 95 | int overCount = 0;\ |
aniruddhv | 213:867de6d350fa | 96 | while( del_tm != NULL ){\ |
aniruddhv | 213:867de6d350fa | 97 | if( (overCount < TM_OVERFLOW_CONSTANT) ){\ |
aniruddhv | 213:867de6d350fa | 98 | Base_tm *temp = del_tm->next_TM;\ |
aniruddhv | 213:867de6d350fa | 99 | delete del_tm;\ |
aniruddhv | 213:867de6d350fa | 100 | del_tm = temp;\ |
aniruddhv | 213:867de6d350fa | 101 | ++overCount;\ |
aniruddhv | 213:867de6d350fa | 102 | }\ |
aniruddhv | 213:867de6d350fa | 103 | else{\ |
aniruddhv | 213:867de6d350fa | 104 | RESET_CDMS;\ |
aniruddhv | 213:867de6d350fa | 105 | break;\ |
aniruddhv | 213:867de6d350fa | 106 | }\ |
aniruddhv | 213:867de6d350fa | 107 | }\ |
aniruddhv | 213:867de6d350fa | 108 | } |
aniruddhv | 213:867de6d350fa | 109 | |
shreeshas95 | 4:104dd82c99b8 | 110 | #define COM_POWER_OFF_TX {\ |
aniruddhv | 12:ffdb29353058 | 111 | /*gPC.puts("Inside COM_POWER_OFF_TX\r\n");*/\ |
aniruddhv | 213:867de6d350fa | 112 | COM_TX_CNTRL = 0;\ |
shreeshas95 | 4:104dd82c99b8 | 113 | RX1M.attach(&rx_read, Serial::RxIrq);\ |
shreeshas95 | 4:104dd82c99b8 | 114 | gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\ |
aniruddhv | 213:867de6d350fa | 115 | RF_SW_CNTRL_BCN = 1;\ |
aniruddhv | 213:867de6d350fa | 116 | Thread::wait(25);\ |
aniruddhv | 213:867de6d350fa | 117 | RF_SW_CNTRL_BCN = 0;\ |
aniruddhv | 213:867de6d350fa | 118 | gFLAGS = gFLAGS | RF_SW_STATUS_FLAG;\ |
aniruddhv | 213:867de6d350fa | 119 | if( gFLAGS & COM_AUTO_POWER_OFF_BAE_FLAG ){\ |
aniruddhv | 213:867de6d350fa | 120 | power_on_bae;\ |
aniruddhv | 213:867de6d350fa | 121 | gFLAGS = gFLAGS | BAE_SW_EN_FLAG;\ |
aniruddhv | 213:867de6d350fa | 122 | gFLAGS & (~COM_AUTO_POWER_OFF_BAE_FLAG);\ |
aniruddhv | 213:867de6d350fa | 123 | resume_bcn;\ |
aniruddhv | 213:867de6d350fa | 124 | }\ |
aniruddhv | 213:867de6d350fa | 125 | else{\ |
aniruddhv | 213:867de6d350fa | 126 | if( gFLAGS & BAE_SW_EN_FLAG ){\ |
aniruddhv | 213:867de6d350fa | 127 | resume_bcn;\ |
aniruddhv | 213:867de6d350fa | 128 | }\ |
aniruddhv | 213:867de6d350fa | 129 | }\ |
shreeshas95 | 4:104dd82c99b8 | 130 | gFLAGS = gFLAGS & (~COM_PA_HOT_FLAG);\ |
aniruddhv | 213:867de6d350fa | 131 | gFLAGS = gFLAGS & (~COM_PA_OC_FLAG);\ |
shreeshas95 | 4:104dd82c99b8 | 132 | gCOM_PA_COOLING_TIMEOUT.detach();\ |
shreeshas95 | 4:104dd82c99b8 | 133 | gFLAGS = gFLAGS & (~COM_TX_FLAG);\ |
aniruddhv | 213:867de6d350fa | 134 | gFLAGS = gFLAGS & (~COM_SESSION_TIMEOUT_FLAG);\ |
aniruddhv | 213:867de6d350fa | 135 | /*gPC.puts("completed com_power_off tx\r\n");*/\ |
shreeshas95 | 4:104dd82c99b8 | 136 | } |