
Compression code changed and RLY_TMTC pointers managed
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE by
main.cpp@226:a37ba29a7ae9, 2016-07-04 (annotated)
- Committer:
- chaithanyarss
- Date:
- Mon Jul 04 17:07:14 2016 +0000
- Revision:
- 226:a37ba29a7ae9
- Parent:
- 224:3ac1f91e0ebc
Testing BAE commands through main
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shreeshas95 | 7:fcd26c28411d | 1 | // TESTING PUSH PULL IN MAIN CPP |
shreeshas95 | 0:f016e9e8d48b | 2 | #include "mbed.h" |
ee12b079 | 98:fd99ddc0e0a1 | 3 | |
ee12b079 | 99:efde3df6cd94 | 4 | #define DEBUG 1 |
ee12b079 | 98:fd99ddc0e0a1 | 5 | |
shreeshas95 | 101:bece931236a2 | 6 | #include "SimpleDMA.h" |
shreeshas95 | 101:bece931236a2 | 7 | #include "dmaSPIslave.h" |
shreeshas95 | 0:f016e9e8d48b | 8 | #include "rtos.h" |
shreeshas95 | 1:a0055b3280c8 | 9 | #include "mbed_debug.h" |
shreeshas95 | 0:f016e9e8d48b | 10 | |
shreeshas95 | 0:f016e9e8d48b | 11 | #include "Structures.h" |
shreeshas95 | 103:b55559925dc1 | 12 | #include "pinconfig.h" |
shreeshas95 | 0:f016e9e8d48b | 13 | #include "DefinitionsAndGlobals.h" |
shreeshas95 | 0:f016e9e8d48b | 14 | #include "crc.h" |
chaithanyarss | 226:a37ba29a7ae9 | 15 | #include "cdms_rtc.h" |
chaithanyarss | 226:a37ba29a7ae9 | 16 | #include "cdms_sd.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" |
chaithanyarss | 226:a37ba29a7ae9 | 20 | #include "Flash.h" |
chaithanyarss | 226:a37ba29a7ae9 | 21 | #include "FMS_all.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" |
ee12b079 | 86:a26f5f22631d | 25 | #include "OBSRS.h" |
shreeshas95 | 1:a0055b3280c8 | 26 | #include "adf.h" |
shreeshas95 | 0:f016e9e8d48b | 27 | #include "COM_RCV_TC.h" |
ee12b079 | 210:f4acf895b598 | 28 | #include "CDMS_PL.h" |
shreeshas95 | 0:f016e9e8d48b | 29 | #include "COM_MNG_TMTC.h" |
chaithanyarss | 226:a37ba29a7ae9 | 30 | #include "COM_POWER_OFF_TX.h" |
shreeshas95 | 4:104dd82c99b8 | 31 | #include "COM_POWER_ON_TX.h" |
ee12b079 | 96:4ca92f9775e0 | 32 | #include "Compression.h" |
shreeshas95 | 0:f016e9e8d48b | 33 | #include "ThreadsAndFunctions.h" |
ee12b079 | 210:f4acf895b598 | 34 | #include "TEST_PL.h" |
shreeshas95 | 0:f016e9e8d48b | 35 | |
chaithanyarss | 226:a37ba29a7ae9 | 36 | void CDMS_INIT(); |
chaithanyarss | 226:a37ba29a7ae9 | 37 | |
ee12b079 | 185:3b3cd96a7811 | 38 | #define PL_TC(tm_ptr){\ |
chaithanyarss | 226:a37ba29a7ae9 | 39 | Base_tc *beacon_tc = new Long_tc;\ |
ee12b079 | 185:3b3cd96a7811 | 40 | beacon_tc->next_TC = NULL;\ |
ee12b079 | 185:3b3cd96a7811 | 41 | PUTshort_or_long(beacon_tc,SHORT_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;\ |
ee12b079 | 185:3b3cd96a7811 | 45 | beacon_tc->TC_string[1] = 0xE0;\ |
ee12b079 | 185:3b3cd96a7811 | 46 | beacon_tc->TC_string[2] = 0x81;\ |
ee12b079 | 185:3b3cd96a7811 | 47 | beacon_tc->TC_string[3] = 0xD0;\ |
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;\ |
chaithanyarss | 226:a37ba29a7ae9 | 53 | beacon_tc->TC_string[9] = 0x1d;\ |
chaithanyarss | 226:a37ba29a7ae9 | 54 | beacon_tc->TC_string[10] = 0xd9;\ |
chaithanyarss | 226:a37ba29a7ae9 | 55 | for(uint8_t z=11;z<135;z++)\ |
chaithanyarss | 226:a37ba29a7ae9 | 56 | {beacon_tc->TC_string[z] = 0;}\ |
ee12b079 | 185:3b3cd96a7811 | 57 | tm_ptr = FCTN_CDMS_RLY_TMTC(beacon_tc);\ |
ee12b079 | 185:3b3cd96a7811 | 58 | } |
ee12b079 | 199:9f03d6ca94c9 | 59 | #define OBSRS_TC(tm_ptr){\ |
ee12b079 | 199:9f03d6ca94c9 | 60 | Base_tc *beacon_tc = new Short_tc;\ |
ee12b079 | 199:9f03d6ca94c9 | 61 | beacon_tc->next_TC = NULL;\ |
ee12b079 | 199:9f03d6ca94c9 | 62 | PUTshort_or_long(beacon_tc,SHORT_TC_CODE);\ |
ee12b079 | 199:9f03d6ca94c9 | 63 | PUTcrc_pass(beacon_tc,0x1);\ |
ee12b079 | 199:9f03d6ca94c9 | 64 | PUTexec_status(beacon_tc,0);\ |
ee12b079 | 199:9f03d6ca94c9 | 65 | beacon_tc->TC_string[0] = 0x01;\ |
ee12b079 | 199:9f03d6ca94c9 | 66 | beacon_tc->TC_string[1] = 0x20;\ |
ee12b079 | 199:9f03d6ca94c9 | 67 | beacon_tc->TC_string[2] = 0xf2;\ |
ee12b079 | 199:9f03d6ca94c9 | 68 | beacon_tc->TC_string[3] = 0x00;\ |
ee12b079 | 199:9f03d6ca94c9 | 69 | beacon_tc->TC_string[4] = 0x00;\ |
ee12b079 | 199:9f03d6ca94c9 | 70 | beacon_tc->TC_string[5] = 0;\ |
ee12b079 | 199:9f03d6ca94c9 | 71 | beacon_tc->TC_string[6] = 2;\ |
ee12b079 | 199:9f03d6ca94c9 | 72 | beacon_tc->TC_string[7] = 0;\ |
ee12b079 | 199:9f03d6ca94c9 | 73 | beacon_tc->TC_string[8] = 2;\ |
ee12b079 | 199:9f03d6ca94c9 | 74 | uint16_t crc16 = crc16_gen(beacon_tc->TC_string, 9);\ |
ee12b079 | 199:9f03d6ca94c9 | 75 | beacon_tc->TC_string[9] = (crc16 & 0xFF00)>>8;\ |
ee12b079 | 199:9f03d6ca94c9 | 76 | beacon_tc->TC_string[10] = (crc16 & 0x00FF);\ |
ee12b079 | 199:9f03d6ca94c9 | 77 | Base_tm *tm_ptr_head = NULL;\ |
ee12b079 | 199:9f03d6ca94c9 | 78 | get_call_sign(tm_ptr_head);\ |
ee12b079 | 199:9f03d6ca94c9 | 79 | Base_tm *put_tm_here = NULL;\ |
ee12b079 | 199:9f03d6ca94c9 | 80 | /*execute_obsrs(current_TC, put_tm_here)*/\ |
ee12b079 | 199:9f03d6ca94c9 | 81 | /*read_TC(current_TC);*/\ |
ee12b079 | 199:9f03d6ca94c9 | 82 | execute_OBSRS_TC(beacon_tc);\ |
ee12b079 | 199:9f03d6ca94c9 | 83 | gPC.puts("enter_adf\r\n");\ |
ee12b079 | 199:9f03d6ca94c9 | 84 | transmit_adf;\ |
ee12b079 | 199:9f03d6ca94c9 | 85 | gPC.puts("exit_adf\r\n");\ |
ee12b079 | 199:9f03d6ca94c9 | 86 | } |
chaithanyarss | 226:a37ba29a7ae9 | 87 | |
chaithanyarss | 226:a37ba29a7ae9 | 88 | void CDMS_INIT() |
chaithanyarss | 226:a37ba29a7ae9 | 89 | { |
chaithanyarss | 226:a37ba29a7ae9 | 90 | CDMS_INIT_STATUS = 1; |
chaithanyarss | 226:a37ba29a7ae9 | 91 | |
chaithanyarss | 226:a37ba29a7ae9 | 92 | spi.format(8,0); |
chaithanyarss | 226:a37ba29a7ae9 | 93 | spi.frequency(1000000); |
chaithanyarss | 226:a37ba29a7ae9 | 94 | |
chaithanyarss | 226:a37ba29a7ae9 | 95 | cs_sd = 1; |
chaithanyarss | 226:a37ba29a7ae9 | 96 | gCS_RTC = 1; |
chaithanyarss | 226:a37ba29a7ae9 | 97 | gCS_ADF = 1; |
chaithanyarss | 226:a37ba29a7ae9 | 98 | |
chaithanyarss | 226:a37ba29a7ae9 | 99 | //FLASH_INIT(); |
chaithanyarss | 226:a37ba29a7ae9 | 100 | FCTN_CDMS_INIT_RTC(); |
chaithanyarss | 226:a37ba29a7ae9 | 101 | FCTN_CDMS_SD_INIT(); |
chaithanyarss | 226:a37ba29a7ae9 | 102 | |
chaithanyarss | 226:a37ba29a7ae9 | 103 | } |
chaithanyarss | 226:a37ba29a7ae9 | 104 | |
shreeshas95 | 0:f016e9e8d48b | 105 | int main() |
shreeshas95 | 0:f016e9e8d48b | 106 | { |
chaithanyarss | 226:a37ba29a7ae9 | 107 | |
chaithanyarss | 226:a37ba29a7ae9 | 108 | CDMS_I2C_GPIO = 0; |
chaithanyarss | 226:a37ba29a7ae9 | 109 | PL_I2C_GPIO = 0; |
chaithanyarss | 226:a37ba29a7ae9 | 110 | |
shreeshas95 | 0:f016e9e8d48b | 111 | // ******************INITIALISATIONS START****************** |
chaithanyarss | 226:a37ba29a7ae9 | 112 | |
shreeshas95 | 0:f016e9e8d48b | 113 | RX1M.baud(1200); |
shreeshas95 | 0:f016e9e8d48b | 114 | gRX_HEAD_DATA_NODE = new COM_RX_DATA_NODE; |
shreeshas95 | 0:f016e9e8d48b | 115 | gRX_HEAD_DATA_NODE->next_node = NULL; |
shreeshas95 | 0:f016e9e8d48b | 116 | gRX_CURRENT_DATA_NODE = gRX_HEAD_DATA_NODE; |
shreeshas95 | 2:2caf2a9a13aa | 117 | gRX_COUNT = 0; |
chaithanyarss | 226:a37ba29a7ae9 | 118 | //gRX_CURRENT_PTR = gRX_CURRENT_DATA_NODE->values; |
shreeshas95 | 0:f016e9e8d48b | 119 | RX1M.attach(&rx_read, Serial::RxIrq); |
chaithanyarss | 226:a37ba29a7ae9 | 120 | |
shreeshas95 | 0:f016e9e8d48b | 121 | // DEBUG |
ee12b079 | 88:b9beee1a7a3e | 122 | //gPC.puts("welcome to mng_tm_tc\r\n"); |
ee12b079 | 203:424308159a56 | 123 | gPC.baud(115200);//changed for bypassing COM |
chaithanyarss | 226:a37ba29a7ae9 | 124 | |
shreeshas95 | 0:f016e9e8d48b | 125 | |
ee12b079 | 93:4d76de54a699 | 126 | |
chaithanyarss | 226:a37ba29a7ae9 | 127 | CDMS_INIT(); |
chaithanyarss | 226:a37ba29a7ae9 | 128 | |
ee12b079 | 196:c51bf4993f75 | 129 | uint8_t test[512] = {0}; |
ee12b079 | 196:c51bf4993f75 | 130 | disk_write(test,7000); //to be used only just before launch |
chaithanyarss | 226:a37ba29a7ae9 | 131 | |
chaithanyarss | 226:a37ba29a7ae9 | 132 | #if DEBUG |
ee12b079 | 113:b8991d9e3b6c | 133 | gPC.puts("welcome to mng_tmtc\r\n"); |
chaithanyarss | 226:a37ba29a7ae9 | 134 | #endif |
chaithanyarss | 226:a37ba29a7ae9 | 135 | |
chaithanyarss | 226:a37ba29a7ae9 | 136 | |
chaithanyarss | 226:a37ba29a7ae9 | 137 | |
shreeshas95 | 0:f016e9e8d48b | 138 | // COM_MNG_TMTC THREAD |
shreeshas95 | 0:f016e9e8d48b | 139 | gCOM_MNG_TMTC_THREAD = new Thread(COM_MNG_TMTC_FUN); |
ee12b079 | 162:48fda0b8d573 | 140 | gCOM_MNG_TMTC_THREAD->set_priority(osPriorityHigh); |
chaithanyarss | 226:a37ba29a7ae9 | 141 | #if DEBUG |
ee12b079 | 94:611c066467a1 | 142 | gPC.puts("allocating threads\r\n"); |
chaithanyarss | 226:a37ba29a7ae9 | 143 | #endif |
ee12b079 | 113:b8991d9e3b6c | 144 | gSCIENCE_THREAD = new Thread(SCIENCE_FUN); |
chaithanyarss | 226:a37ba29a7ae9 | 145 | // gPC.puts("step one complete\r\n"); |
ee12b079 | 162:48fda0b8d573 | 146 | gSCIENCE_THREAD->set_priority(osPriorityAboveNormal); |
chaithanyarss | 226:a37ba29a7ae9 | 147 | #if DEBUG |
ee12b079 | 94:611c066467a1 | 148 | gPC.puts("competed allocating threads\r\n"); |
chaithanyarss | 226:a37ba29a7ae9 | 149 | #endif |
chaithanyarss | 226:a37ba29a7ae9 | 150 | |
chaithanyarss | 226:a37ba29a7ae9 | 151 | |
ee12b079 | 170:286ef9dad36a | 152 | master.frequency(400000); |
chaithanyarss | 226:a37ba29a7ae9 | 153 | //PL_wo_dma = new RtosTimer(payload_isr_fun_dma, osTimerPeriodic,(void * )NULL); |
ee12b079 | 193:f76b475d7807 | 154 | //PL_wo_dma->start(6000);// |
ee12b079 | 205:d2ac4580960d | 155 | gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL); |
chaithanyarss | 226:a37ba29a7ae9 | 156 | |
chaithanyarss | 226:a37ba29a7ae9 | 157 | |
chaithanyarss | 226:a37ba29a7ae9 | 158 | |
chaithanyarss | 226:a37ba29a7ae9 | 159 | gPC.printf("PL_TC sending\r\n"); |
chaithanyarss | 226:a37ba29a7ae9 | 160 | |
chaithanyarss | 226:a37ba29a7ae9 | 161 | Base_tm *tm_ptr = new Long_tm; |
chaithanyarss | 226:a37ba29a7ae9 | 162 | PL_TC(tm_ptr); |
chaithanyarss | 226:a37ba29a7ae9 | 163 | |
chaithanyarss | 226:a37ba29a7ae9 | 164 | gPC.printf("PL_TC sent"); |
ee12b079 | 199:9f03d6ca94c9 | 165 | |
shreeshas95 | 0:f016e9e8d48b | 166 | // *******************INITIALISATIONS END******************** |
chaithanyarss | 226:a37ba29a7ae9 | 167 | |
chaithanyarss | 224:3ac1f91e0ebc | 168 | FCTN_CDMS_HK_MAIN((void *)NULL); |
ee12b079 | 113:b8991d9e3b6c | 169 | //RtosTimer gCDMS_HK_TIMER(FCTN_CDMS_HK_MAIN, osTimerPeriodic); |
chaithanyarss | 226:a37ba29a7ae9 | 170 | //gCDMS_HK_TIMER.start(30000); |
chaithanyarss | 226:a37ba29a7ae9 | 171 | |
ee12b079 | 97:717c7908c822 | 172 | /*starting the thread with signal*/ |
ee12b079 | 193:f76b475d7807 | 173 | //set_sig(); |
ee12b079 | 193:f76b475d7807 | 174 | //payload_isr_fun(); |
chaithanyarss | 226:a37ba29a7ae9 | 175 | |
ee12b079 | 94:611c066467a1 | 176 | /*Calculating Stack used*/ |
chaithanyarss | 226:a37ba29a7ae9 | 177 | |
ee12b079 | 96:4ca92f9775e0 | 178 | int state; |
chaithanyarss | 226:a37ba29a7ae9 | 179 | /*while (true) { |
chaithanyarss | 226:a37ba29a7ae9 | 180 | Thread::wait(500); |
chaithanyarss | 226:a37ba29a7ae9 | 181 | state = gSCIENCE_THREAD->get_state(); |
chaithanyarss | 226:a37ba29a7ae9 | 182 | //gPC.printf("Thread state %d\r\n", state); |
chaithanyarss | 226:a37ba29a7ae9 | 183 | if(state == Thread::Inactive) |
ee12b079 | 96:4ca92f9775e0 | 184 | {delete gSCIENCE_THREAD; |
ee12b079 | 96:4ca92f9775e0 | 185 | break;} |
ee12b079 | 96:4ca92f9775e0 | 186 | }*/ |
chaithanyarss | 226:a37ba29a7ae9 | 187 | |
chaithanyarss | 226:a37ba29a7ae9 | 188 | while(true) { |
ee12b079 | 97:717c7908c822 | 189 | Thread::wait(osWaitForever); |
ee12b079 | 96:4ca92f9775e0 | 190 | //state = gCOM_MNG_TMTC_THREAD->get_state() + '0'; |
chaithanyarss | 226:a37ba29a7ae9 | 191 | gLEDG = !gLEDG; |
chaithanyarss | 226:a37ba29a7ae9 | 192 | //gPC.putc(state); |
shreeshas95 | 0:f016e9e8d48b | 193 | } |
shreeshas95 | 0:f016e9e8d48b | 194 | } |