![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
for frequency correction testing
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE by
main.cpp@267:783c248a6207, 2016-07-16 (annotated)
- Committer:
- prasanthbj05
- Date:
- Sat Jul 16 16:04:14 2016 +0000
- Revision:
- 267:783c248a6207
- Parent:
- 266:ae588e75cfa4
- Child:
- 268:ded5306a1fd1
Compression code changed according to modified beacon format.;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ee12b079 | 181:834d02830729 | 1 | |
shreeshas95 | 7:fcd26c28411d | 2 | // TESTING PUSH PULL IN MAIN CPP |
shreeshas95 | 7:fcd26c28411d | 3 | |
shreeshas95 | 0:f016e9e8d48b | 4 | #include "mbed.h" |
ee12b079 | 98:fd99ddc0e0a1 | 5 | |
ee12b079 | 99:efde3df6cd94 | 6 | #define DEBUG 1 |
ee12b079 | 98:fd99ddc0e0a1 | 7 | |
shreeshas95 | 101:bece931236a2 | 8 | #include "SimpleDMA.h" |
shreeshas95 | 101:bece931236a2 | 9 | #include "dmaSPIslave.h" |
shreeshas95 | 0:f016e9e8d48b | 10 | #include "rtos.h" |
shreeshas95 | 1:a0055b3280c8 | 11 | #include "mbed_debug.h" |
aniruddhv | 262:752c8689944a | 12 | void rx_read(); |
shreeshas95 | 0:f016e9e8d48b | 13 | #include "Structures.h" |
shreeshas95 | 103:b55559925dc1 | 14 | #include "pinconfig.h" |
shreeshas95 | 0:f016e9e8d48b | 15 | #include "DefinitionsAndGlobals.h" |
shreeshas95 | 0:f016e9e8d48b | 16 | #include "crc.h" |
shreeshas95 | 103:b55559925dc1 | 17 | #include "i2c.h" |
shreeshas95 | 1:a0055b3280c8 | 18 | #include "COM_SND_TM_functions.h" |
shreeshas95 | 1:a0055b3280c8 | 19 | #include "COM_SND_TM.h" |
ee12b079 | 210:f4acf895b598 | 20 | #include "cdms_rtc.h" |
ee12b079 | 99:efde3df6cd94 | 21 | #include "cdms_sd.h" |
krishanprajapat | 117:bfdc807f3d3c | 22 | #include "common_functions.h" |
ee12b079 | 210:f4acf895b598 | 23 | #include "RESET_functions.h" |
ee12b079 | 210:f4acf895b598 | 24 | #include "CDMS_HK.h" |
shreeshas95 | 1:a0055b3280c8 | 25 | #include "adf.h" |
shreeshas95 | 0:f016e9e8d48b | 26 | #include "COM_RCV_TC.h" |
ee12b079 | 259:066a7abd2a5f | 27 | #include "Flash.h" |
chaithanyarss | 257:7d404e9dc9e2 | 28 | #include "CDMS_PL.h" |
ee12b079 | 210:f4acf895b598 | 29 | #include "FMS_all.h" |
chaithanyarss | 261:1e54415b34d3 | 30 | #include "Compression.h" |
shreeshas95 | 0:f016e9e8d48b | 31 | #include "COM_MNG_TMTC.h" |
aniruddhv | 262:752c8689944a | 32 | #include "COM_POWER_OFF_TX.h" |
shreeshas95 | 4:104dd82c99b8 | 33 | #include "COM_POWER_ON_TX.h" |
aniruddhv | 262:752c8689944a | 34 | #include "OBSRS.h" |
shreeshas95 | 0:f016e9e8d48b | 35 | #include "ThreadsAndFunctions.h" |
ee12b079 | 210:f4acf895b598 | 36 | #include "TEST_PL.h" |
shreeshas95 | 0:f016e9e8d48b | 37 | |
ee12b079 | 185:3b3cd96a7811 | 38 | #define PL_TC(tm_ptr){\ |
chaithanyarss | 227:335da5b0d3e4 | 39 | Base_tc *beacon_tc = new Long_tc;\ |
ee12b079 | 185:3b3cd96a7811 | 40 | beacon_tc->next_TC = NULL;\ |
chaithanyarss | 227:335da5b0d3e4 | 41 | PUTshort_or_long(beacon_tc,LONG_TC_CODE);\ |
ee12b079 | 185:3b3cd96a7811 | 42 | PUTcrc_pass(beacon_tc,0x1);\ |
ee12b079 | 185:3b3cd96a7811 | 43 | PUTexec_status(beacon_tc,0);\ |
ee12b079 | 185:3b3cd96a7811 | 44 | beacon_tc->TC_string[0] = 0x01;\ |
chaithanyarss | 227:335da5b0d3e4 | 45 | beacon_tc->TC_string[1] = 0x60;\ |
ee12b079 | 185:3b3cd96a7811 | 46 | beacon_tc->TC_string[2] = 0x81;\ |
chaithanyarss | 227:335da5b0d3e4 | 47 | beacon_tc->TC_string[3] = 0x21;\ |
ee12b079 | 185:3b3cd96a7811 | 48 | beacon_tc->TC_string[4] = 0x00;\ |
ee12b079 | 185:3b3cd96a7811 | 49 | beacon_tc->TC_string[5] = 0;\ |
ee12b079 | 185:3b3cd96a7811 | 50 | beacon_tc->TC_string[6] = 0;\ |
ee12b079 | 185:3b3cd96a7811 | 51 | beacon_tc->TC_string[7] = 0;\ |
ee12b079 | 185:3b3cd96a7811 | 52 | beacon_tc->TC_string[8] = 0;\ |
ee12b079 | 185:3b3cd96a7811 | 53 | uint16_t crc16 = crc16_gen(beacon_tc->TC_string, 9);\ |
ee12b079 | 185:3b3cd96a7811 | 54 | beacon_tc->TC_string[9] = (crc16 & 0xFF00)>>8;\ |
ee12b079 | 185:3b3cd96a7811 | 55 | beacon_tc->TC_string[10] = (crc16 & 0x00FF);\ |
chaithanyarss | 227:335da5b0d3e4 | 56 | for(int i = 11; i<135;i++) beacon_tc->TC_string[i] = 0;\ |
ee12b079 | 185:3b3cd96a7811 | 57 | tm_ptr = FCTN_CDMS_RLY_TMTC(beacon_tc);\ |
prasanthbj05 | 266:ae588e75cfa4 | 58 | delete PL_TC;\ |
prasanthbj05 | 266:ae588e75cfa4 | 59 | Base_tm *temp;\ |
prasanthbj05 | 266:ae588e75cfa4 | 60 | temp = tm_ptr;\ |
prasanthbj05 | 266:ae588e75cfa4 | 61 | while(tm_ptr!=NULL)\ |
prasanthbj05 | 266:ae588e75cfa4 | 62 | {\ |
prasanthbj05 | 266:ae588e75cfa4 | 63 | temp = temp->next_TM;\ |
prasanthbj05 | 266:ae588e75cfa4 | 64 | delete tm_ptr;\ |
prasanthbj05 | 266:ae588e75cfa4 | 65 | tm_ptr = temp;\ |
prasanthbj05 | 266:ae588e75cfa4 | 66 | }\ |
ee12b079 | 185:3b3cd96a7811 | 67 | } |
ee12b079 | 199:9f03d6ca94c9 | 68 | #define OBSRS_TC(tm_ptr){\ |
ee12b079 | 199:9f03d6ca94c9 | 69 | Base_tc *beacon_tc = new Short_tc;\ |
ee12b079 | 199:9f03d6ca94c9 | 70 | beacon_tc->next_TC = NULL;\ |
ee12b079 | 199:9f03d6ca94c9 | 71 | PUTshort_or_long(beacon_tc,SHORT_TC_CODE);\ |
ee12b079 | 199:9f03d6ca94c9 | 72 | PUTcrc_pass(beacon_tc,0x1);\ |
ee12b079 | 199:9f03d6ca94c9 | 73 | PUTexec_status(beacon_tc,0);\ |
ee12b079 | 199:9f03d6ca94c9 | 74 | beacon_tc->TC_string[0] = 0x01;\ |
ee12b079 | 199:9f03d6ca94c9 | 75 | beacon_tc->TC_string[1] = 0x20;\ |
ee12b079 | 199:9f03d6ca94c9 | 76 | beacon_tc->TC_string[2] = 0xf2;\ |
ee12b079 | 199:9f03d6ca94c9 | 77 | beacon_tc->TC_string[3] = 0x00;\ |
ee12b079 | 199:9f03d6ca94c9 | 78 | beacon_tc->TC_string[4] = 0x00;\ |
ee12b079 | 199:9f03d6ca94c9 | 79 | beacon_tc->TC_string[5] = 0;\ |
ee12b079 | 199:9f03d6ca94c9 | 80 | beacon_tc->TC_string[6] = 2;\ |
ee12b079 | 199:9f03d6ca94c9 | 81 | beacon_tc->TC_string[7] = 0;\ |
ee12b079 | 199:9f03d6ca94c9 | 82 | beacon_tc->TC_string[8] = 2;\ |
ee12b079 | 199:9f03d6ca94c9 | 83 | uint16_t crc16 = crc16_gen(beacon_tc->TC_string, 9);\ |
ee12b079 | 199:9f03d6ca94c9 | 84 | beacon_tc->TC_string[9] = (crc16 & 0xFF00)>>8;\ |
ee12b079 | 199:9f03d6ca94c9 | 85 | beacon_tc->TC_string[10] = (crc16 & 0x00FF);\ |
ee12b079 | 199:9f03d6ca94c9 | 86 | Base_tm *tm_ptr_head = NULL;\ |
ee12b079 | 199:9f03d6ca94c9 | 87 | get_call_sign(tm_ptr_head);\ |
ee12b079 | 199:9f03d6ca94c9 | 88 | Base_tm *put_tm_here = NULL;\ |
ee12b079 | 199:9f03d6ca94c9 | 89 | /*execute_obsrs(current_TC, put_tm_here)*/\ |
ee12b079 | 199:9f03d6ca94c9 | 90 | /*read_TC(current_TC);*/\ |
ee12b079 | 199:9f03d6ca94c9 | 91 | execute_OBSRS_TC(beacon_tc);\ |
ee12b079 | 199:9f03d6ca94c9 | 92 | gPC.puts("enter_adf\r\n");\ |
ee12b079 | 199:9f03d6ca94c9 | 93 | transmit_adf;\ |
ee12b079 | 199:9f03d6ca94c9 | 94 | gPC.puts("exit_adf\r\n");\ |
ee12b079 | 199:9f03d6ca94c9 | 95 | } |
ee12b079 | 249:565458eefd94 | 96 | |
chaithanyarss | 261:1e54415b34d3 | 97 | #define BAE_tc(tm_ptr) {\ |
chaithanyarss | 261:1e54415b34d3 | 98 | Base_tc *bae_tc = new Long_tc;\ |
chaithanyarss | 261:1e54415b34d3 | 99 | bae_tc->next_TC = NULL;\ |
chaithanyarss | 261:1e54415b34d3 | 100 | PUTshort_or_long(bae_tc,0);\ |
chaithanyarss | 261:1e54415b34d3 | 101 | PUTcrc_pass(bae_tc,0x1);\ |
chaithanyarss | 261:1e54415b34d3 | 102 | PUTexec_status(bae_tc,0);\ |
chaithanyarss | 261:1e54415b34d3 | 103 | bae_tc->TC_string[0] = 0x01;\ |
chaithanyarss | 261:1e54415b34d3 | 104 | bae_tc->TC_string[1] = 0x71;\ |
chaithanyarss | 261:1e54415b34d3 | 105 | bae_tc->TC_string[2] = 0x81;\ |
chaithanyarss | 261:1e54415b34d3 | 106 | bae_tc->TC_string[3] = 0x32;\ |
chaithanyarss | 261:1e54415b34d3 | 107 | bae_tc->TC_string[4] = 0;\ |
chaithanyarss | 261:1e54415b34d3 | 108 | bae_tc->TC_string[5] = 0;\ |
chaithanyarss | 261:1e54415b34d3 | 109 | bae_tc->TC_string[6] = 0;\ |
chaithanyarss | 261:1e54415b34d3 | 110 | bae_tc->TC_string[7] = 0;\ |
prasanthbj05 | 266:ae588e75cfa4 | 111 | bae_tc->TC_string[8] = 0;\ |
chaithanyarss | 261:1e54415b34d3 | 112 | uint16_t crc16 = crc16_gen(bae_tc->TC_string, 9);\ |
chaithanyarss | 261:1e54415b34d3 | 113 | bae_tc->TC_string[9] = (uint8_t)(crc16 & 0xFF00)>>8;\ |
chaithanyarss | 261:1e54415b34d3 | 114 | bae_tc->TC_string[10] = (uint8_t)(crc16 & 0x00FF);\ |
chaithanyarss | 261:1e54415b34d3 | 115 | for(uint8_t i=11;i<135;i++)\ |
chaithanyarss | 261:1e54415b34d3 | 116 | bae_tc->TC_string[i] = 0;\ |
chaithanyarss | 261:1e54415b34d3 | 117 | tm_ptr = FCTN_CDMS_RLY_TMTC(bae_tc);\ |
chaithanyarss | 261:1e54415b34d3 | 118 | delete bae_tc;\ |
chaithanyarss | 261:1e54415b34d3 | 119 | Base_tm *temp;\ |
chaithanyarss | 261:1e54415b34d3 | 120 | temp = tm_ptr;\ |
chaithanyarss | 261:1e54415b34d3 | 121 | while(tm_ptr!=NULL)\ |
chaithanyarss | 261:1e54415b34d3 | 122 | {\ |
chaithanyarss | 261:1e54415b34d3 | 123 | temp = temp->next_TM;\ |
chaithanyarss | 261:1e54415b34d3 | 124 | delete tm_ptr;\ |
prasanthbj05 | 266:ae588e75cfa4 | 125 | tm_ptr = temp;\ |
chaithanyarss | 261:1e54415b34d3 | 126 | }\ |
chaithanyarss | 261:1e54415b34d3 | 127 | } |
chaithanyarss | 261:1e54415b34d3 | 128 | |
chaithanyarss | 261:1e54415b34d3 | 129 | void BAE_TC(); |
chaithanyarss | 261:1e54415b34d3 | 130 | void BAE_TC() |
chaithanyarss | 261:1e54415b34d3 | 131 | { |
chaithanyarss | 261:1e54415b34d3 | 132 | Base_tm *tm_ptr = new Long_tm; |
chaithanyarss | 261:1e54415b34d3 | 133 | BAE_tc(tm_ptr); |
chaithanyarss | 261:1e54415b34d3 | 134 | } |
chaithanyarss | 261:1e54415b34d3 | 135 | |
prasanthbj05 | 267:783c248a6207 | 136 | uint8_t test_srp[]= { |
prasanthbj05 | 267:783c248a6207 | 137 | |
prasanthbj05 | 267:783c248a6207 | 138 | }; |
chaithanyarss | 261:1e54415b34d3 | 139 | |
shreeshas95 | 0:f016e9e8d48b | 140 | int main() |
prasanthbj05 | 267:783c248a6207 | 141 | { |
ee12b079 | 185:3b3cd96a7811 | 142 | CDMS_I2C_GPIO = 0; |
ee12b079 | 210:f4acf895b598 | 143 | PL_I2C_GPIO = 0; |
ee12b079 | 162:48fda0b8d573 | 144 | |
shreeshas95 | 0:f016e9e8d48b | 145 | RX1M.baud(1200); |
shreeshas95 | 0:f016e9e8d48b | 146 | gRX_HEAD_DATA_NODE = new COM_RX_DATA_NODE; |
shreeshas95 | 0:f016e9e8d48b | 147 | gRX_HEAD_DATA_NODE->next_node = NULL; |
shreeshas95 | 0:f016e9e8d48b | 148 | gRX_CURRENT_DATA_NODE = gRX_HEAD_DATA_NODE; |
shreeshas95 | 2:2caf2a9a13aa | 149 | gRX_COUNT = 0; |
shreeshas95 | 0:f016e9e8d48b | 150 | RX1M.attach(&rx_read, Serial::RxIrq); |
shreeshas95 | 0:f016e9e8d48b | 151 | |
prasanthbj05 | 267:783c248a6207 | 152 | gPC.baud(9600);//changed for bypassing COM |
shreeshas95 | 0:f016e9e8d48b | 153 | |
shreeshas95 | 0:f016e9e8d48b | 154 | // COMMON SPI |
shreeshas95 | 0:f016e9e8d48b | 155 | spi.format(8,0); |
chaithanyarss | 261:1e54415b34d3 | 156 | spi.frequency(500000); |
shreeshas95 | 0:f016e9e8d48b | 157 | |
shreeshas95 | 0:f016e9e8d48b | 158 | // SD CARD |
ee12b079 | 86:a26f5f22631d | 159 | cs_sd = 1; |
shreeshas95 | 2:2caf2a9a13aa | 160 | gCS_RTC = 1; |
ee12b079 | 90:df55a5f68331 | 161 | gCS_ADF = 1; |
ee12b079 | 93:4d76de54a699 | 162 | |
aniruddhv | 263:3b872778b8c7 | 163 | //FCTN_CDMS_INIT_RTC();/* rtc initialization*/ |
aniruddhv | 263:3b872778b8c7 | 164 | //FCTN_CDMS_SD_INIT();/* sd card initialization*/ |
shreeshas95 | 0:f016e9e8d48b | 165 | |
ee12b079 | 196:c51bf4993f75 | 166 | |
chaithanyarss | 257:7d404e9dc9e2 | 167 | //uint8_t test[512] = {0}; |
chaithanyarss | 257:7d404e9dc9e2 | 168 | //disk_write(test,7000); //to be used only just before launch |
ee12b079 | 196:c51bf4993f75 | 169 | |
ee12b079 | 113:b8991d9e3b6c | 170 | #if DEBUG |
ee12b079 | 113:b8991d9e3b6c | 171 | gPC.puts("welcome to mng_tmtc\r\n"); |
ee12b079 | 113:b8991d9e3b6c | 172 | #endif |
ee12b079 | 113:b8991d9e3b6c | 173 | |
ee12b079 | 249:565458eefd94 | 174 | #if DEBUG |
ee12b079 | 249:565458eefd94 | 175 | gPC.puts("allocating threads\r\n"); |
ee12b079 | 249:565458eefd94 | 176 | #endif |
ee12b079 | 185:3b3cd96a7811 | 177 | |
aniruddhv | 264:f7d8f9f361e3 | 178 | // COM_POWER_ON_TX(); |
aniruddhv | 264:f7d8f9f361e3 | 179 | |
shreeshas95 | 0:f016e9e8d48b | 180 | // COM_MNG_TMTC THREAD |
prasanthbj05 | 267:783c248a6207 | 181 | /*gCOM_MNG_TMTC_THREAD = new Thread(COM_MNG_TMTC_FUN); |
ee12b079 | 162:48fda0b8d573 | 182 | gCOM_MNG_TMTC_THREAD->set_priority(osPriorityHigh); |
ee12b079 | 249:565458eefd94 | 183 | |
ee12b079 | 249:565458eefd94 | 184 | gHK_THREAD = new Thread(FCTN_CDMS_HK_MAIN); |
ee12b079 | 249:565458eefd94 | 185 | gHK_THREAD->set_priority(osPriorityAboveNormal); |
ee12b079 | 249:565458eefd94 | 186 | |
ee12b079 | 113:b8991d9e3b6c | 187 | gSCIENCE_THREAD = new Thread(SCIENCE_FUN); |
prasanthbj05 | 267:783c248a6207 | 188 | gSCIENCE_THREAD->set_priority(osPriorityAboveNormal);*/ |
ee12b079 | 249:565458eefd94 | 189 | |
ee12b079 | 99:efde3df6cd94 | 190 | #if DEBUG |
prasanthbj05 | 266:ae588e75cfa4 | 191 | gPC.puts("completed allocating threads\r\n"); |
prasanthbj05 | 267:783c248a6207 | 192 | #endif |
ee12b079 | 249:565458eefd94 | 193 | |
ee12b079 | 170:286ef9dad36a | 194 | master.frequency(400000); |
ee12b079 | 249:565458eefd94 | 195 | |
prasanthbj05 | 267:783c248a6207 | 196 | /*HK_counter = new RtosTimer(hk_isr, osTimerPeriodic,(void * )NULL); |
chaithanyarss | 261:1e54415b34d3 | 197 | HK_counter->start(10000); |
ee12b079 | 255:fd6696d91e74 | 198 | |
aniruddhv | 262:752c8689944a | 199 | sys_reset_cdms_timer = new RtosTimer(sys_pwr_reset, osTimerPeriodic, (void * )NULL); |
prasanthbj05 | 267:783c248a6207 | 200 | sys_reset_cdms_timer->start(cdms_reset_timeout);*/ |
aniruddhv | 262:752c8689944a | 201 | |
chaithanyarss | 261:1e54415b34d3 | 202 | /*PL_wo_dma = new RtosTimer(payload_isr_fun_dma, osTimerPeriodic,(void * )NULL); |
chaithanyarss | 261:1e54415b34d3 | 203 | PL_wo_dma->start(6000);*/ |
ee12b079 | 246:29625f5fc745 | 204 | //gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL); |
ee12b079 | 203:424308159a56 | 205 | |
chaithanyarss | 261:1e54415b34d3 | 206 | /*Timeout flipper; |
chaithanyarss | 261:1e54415b34d3 | 207 | flipper.attach(BAE_TC,31);*/ |
ee12b079 | 203:424308159a56 | 208 | |
ee12b079 | 232:b1458c1e9199 | 209 | /*while(1){ |
chaithanyarss | 227:335da5b0d3e4 | 210 | gPC.printf("PL_TC sending\r\n"); |
ee12b079 | 199:9f03d6ca94c9 | 211 | |
chaithanyarss | 227:335da5b0d3e4 | 212 | Base_tm *tm_ptr = new Long_tm; |
chaithanyarss | 227:335da5b0d3e4 | 213 | PL_TC(tm_ptr); |
chaithanyarss | 227:335da5b0d3e4 | 214 | wait(1); |
chaithanyarss | 227:335da5b0d3e4 | 215 | } |
ee12b079 | 232:b1458c1e9199 | 216 | gPC.printf("PL_TC sent");*/ |
ee12b079 | 199:9f03d6ca94c9 | 217 | |
shreeshas95 | 0:f016e9e8d48b | 218 | while(true){ |
ee12b079 | 97:717c7908c822 | 219 | Thread::wait(osWaitForever); |
ee12b079 | 96:4ca92f9775e0 | 220 | gLEDG = !gLEDG; |
shreeshas95 | 0:f016e9e8d48b | 221 | } |
shreeshas95 | 0:f016e9e8d48b | 222 | } |