CDMS_CODE_samp_23SEP_DMA_flag

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE_samp_23SEP_DMA by iitm sat

Committer:
chaithanyarss
Date:
Mon Jul 04 13:53:20 2016 +0000
Revision:
223:7c802e1ccd30
Parent:
220:2aeab83212e6
All thread added, testing TCs

Who changed what in which revision?

UserRevisionLine numberNew 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"
chaithanyarss 215:570251b23c7b 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 215:570251b23c7b 15 #include "cdms_rtc.h"
chaithanyarss 215:570251b23c7b 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 218:c63cdba0550f 20 #include "Flash.h"
chaithanyarss 218:c63cdba0550f 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"
chaithanyarss 215:570251b23c7b 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 218:c63cdba0550f 30 #include "COM_POWER_OFF_TX.h"
chaithanyarss 215:570251b23c7b 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 215:570251b23c7b 36 void CDMS_INIT();
chaithanyarss 215:570251b23c7b 37
ee12b079 185:3b3cd96a7811 38 #define PL_TC(tm_ptr){\
ee12b079 185:3b3cd96a7811 39 Base_tc *beacon_tc = new Short_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;\
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);\
ee12b079 185:3b3cd96a7811 56 tm_ptr = FCTN_CDMS_RLY_TMTC(beacon_tc);\
ee12b079 185:3b3cd96a7811 57 }
ee12b079 199:9f03d6ca94c9 58 #define OBSRS_TC(tm_ptr){\
ee12b079 199:9f03d6ca94c9 59 Base_tc *beacon_tc = new Short_tc;\
ee12b079 199:9f03d6ca94c9 60 beacon_tc->next_TC = NULL;\
ee12b079 199:9f03d6ca94c9 61 PUTshort_or_long(beacon_tc,SHORT_TC_CODE);\
ee12b079 199:9f03d6ca94c9 62 PUTcrc_pass(beacon_tc,0x1);\
ee12b079 199:9f03d6ca94c9 63 PUTexec_status(beacon_tc,0);\
ee12b079 199:9f03d6ca94c9 64 beacon_tc->TC_string[0] = 0x01;\
ee12b079 199:9f03d6ca94c9 65 beacon_tc->TC_string[1] = 0x20;\
ee12b079 199:9f03d6ca94c9 66 beacon_tc->TC_string[2] = 0xf2;\
ee12b079 199:9f03d6ca94c9 67 beacon_tc->TC_string[3] = 0x00;\
ee12b079 199:9f03d6ca94c9 68 beacon_tc->TC_string[4] = 0x00;\
ee12b079 199:9f03d6ca94c9 69 beacon_tc->TC_string[5] = 0;\
ee12b079 199:9f03d6ca94c9 70 beacon_tc->TC_string[6] = 2;\
ee12b079 199:9f03d6ca94c9 71 beacon_tc->TC_string[7] = 0;\
ee12b079 199:9f03d6ca94c9 72 beacon_tc->TC_string[8] = 2;\
ee12b079 199:9f03d6ca94c9 73 uint16_t crc16 = crc16_gen(beacon_tc->TC_string, 9);\
ee12b079 199:9f03d6ca94c9 74 beacon_tc->TC_string[9] = (crc16 & 0xFF00)>>8;\
ee12b079 199:9f03d6ca94c9 75 beacon_tc->TC_string[10] = (crc16 & 0x00FF);\
ee12b079 199:9f03d6ca94c9 76 Base_tm *tm_ptr_head = NULL;\
ee12b079 199:9f03d6ca94c9 77 get_call_sign(tm_ptr_head);\
ee12b079 199:9f03d6ca94c9 78 Base_tm *put_tm_here = NULL;\
ee12b079 199:9f03d6ca94c9 79 /*execute_obsrs(current_TC, put_tm_here)*/\
ee12b079 199:9f03d6ca94c9 80 /*read_TC(current_TC);*/\
ee12b079 199:9f03d6ca94c9 81 execute_OBSRS_TC(beacon_tc);\
ee12b079 199:9f03d6ca94c9 82 gPC.puts("enter_adf\r\n");\
ee12b079 199:9f03d6ca94c9 83 transmit_adf;\
ee12b079 199:9f03d6ca94c9 84 gPC.puts("exit_adf\r\n");\
ee12b079 199:9f03d6ca94c9 85 }
chaithanyarss 215:570251b23c7b 86
chaithanyarss 215:570251b23c7b 87 void CDMS_INIT()
chaithanyarss 215:570251b23c7b 88 {
chaithanyarss 215:570251b23c7b 89 CDMS_INIT_STATUS = 1;
chaithanyarss 215:570251b23c7b 90
chaithanyarss 215:570251b23c7b 91 spi.format(8,0);
chaithanyarss 215:570251b23c7b 92 spi.frequency(1000000);
chaithanyarss 215:570251b23c7b 93
chaithanyarss 215:570251b23c7b 94 cs_sd = 1;
chaithanyarss 215:570251b23c7b 95 gCS_RTC = 1;
chaithanyarss 215:570251b23c7b 96 gCS_ADF = 1;
chaithanyarss 215:570251b23c7b 97
chaithanyarss 218:c63cdba0550f 98 FLASH_INIT();
chaithanyarss 215:570251b23c7b 99 FCTN_CDMS_INIT_RTC();
chaithanyarss 215:570251b23c7b 100 FCTN_CDMS_SD_INIT();
chaithanyarss 215:570251b23c7b 101
chaithanyarss 215:570251b23c7b 102 }
chaithanyarss 215:570251b23c7b 103
shreeshas95 0:f016e9e8d48b 104 int main()
shreeshas95 0:f016e9e8d48b 105 {
chaithanyarss 215:570251b23c7b 106
chaithanyarss 215:570251b23c7b 107 CDMS_I2C_GPIO = 0;
chaithanyarss 215:570251b23c7b 108 PL_I2C_GPIO = 0;
chaithanyarss 215:570251b23c7b 109
shreeshas95 0:f016e9e8d48b 110 // ******************INITIALISATIONS START******************
chaithanyarss 215:570251b23c7b 111
shreeshas95 0:f016e9e8d48b 112 RX1M.baud(1200);
shreeshas95 0:f016e9e8d48b 113 gRX_HEAD_DATA_NODE = new COM_RX_DATA_NODE;
shreeshas95 0:f016e9e8d48b 114 gRX_HEAD_DATA_NODE->next_node = NULL;
shreeshas95 0:f016e9e8d48b 115 gRX_CURRENT_DATA_NODE = gRX_HEAD_DATA_NODE;
shreeshas95 2:2caf2a9a13aa 116 gRX_COUNT = 0;
chaithanyarss 215:570251b23c7b 117 //gRX_CURRENT_PTR = gRX_CURRENT_DATA_NODE->values;
shreeshas95 0:f016e9e8d48b 118 RX1M.attach(&rx_read, Serial::RxIrq);
chaithanyarss 215:570251b23c7b 119
shreeshas95 0:f016e9e8d48b 120 // DEBUG
ee12b079 88:b9beee1a7a3e 121 //gPC.puts("welcome to mng_tm_tc\r\n");
ee12b079 203:424308159a56 122 gPC.baud(115200);//changed for bypassing COM
chaithanyarss 215:570251b23c7b 123
shreeshas95 0:f016e9e8d48b 124
ee12b079 93:4d76de54a699 125
chaithanyarss 220:2aeab83212e6 126 CDMS_INIT();
chaithanyarss 215:570251b23c7b 127
ee12b079 196:c51bf4993f75 128 uint8_t test[512] = {0};
ee12b079 196:c51bf4993f75 129 disk_write(test,7000); //to be used only just before launch
chaithanyarss 215:570251b23c7b 130
chaithanyarss 215:570251b23c7b 131 #if DEBUG
ee12b079 113:b8991d9e3b6c 132 gPC.puts("welcome to mng_tmtc\r\n");
chaithanyarss 215:570251b23c7b 133 #endif
chaithanyarss 215:570251b23c7b 134
chaithanyarss 215:570251b23c7b 135
chaithanyarss 215:570251b23c7b 136
shreeshas95 0:f016e9e8d48b 137 // COM_MNG_TMTC THREAD
shreeshas95 0:f016e9e8d48b 138 gCOM_MNG_TMTC_THREAD = new Thread(COM_MNG_TMTC_FUN);
ee12b079 162:48fda0b8d573 139 gCOM_MNG_TMTC_THREAD->set_priority(osPriorityHigh);
chaithanyarss 215:570251b23c7b 140 #if DEBUG
ee12b079 94:611c066467a1 141 gPC.puts("allocating threads\r\n");
chaithanyarss 215:570251b23c7b 142 #endif
ee12b079 113:b8991d9e3b6c 143 gSCIENCE_THREAD = new Thread(SCIENCE_FUN);
chaithanyarss 215:570251b23c7b 144 // gPC.puts("step one complete\r\n");
ee12b079 162:48fda0b8d573 145 gSCIENCE_THREAD->set_priority(osPriorityAboveNormal);
chaithanyarss 215:570251b23c7b 146 #if DEBUG
ee12b079 94:611c066467a1 147 gPC.puts("competed allocating threads\r\n");
chaithanyarss 215:570251b23c7b 148 #endif
chaithanyarss 215:570251b23c7b 149
chaithanyarss 215:570251b23c7b 150
ee12b079 170:286ef9dad36a 151 master.frequency(400000);
chaithanyarss 223:7c802e1ccd30 152 //PL_wo_dma = new RtosTimer(payload_isr_fun_dma, osTimerPeriodic,(void * )NULL);
ee12b079 193:f76b475d7807 153 //PL_wo_dma->start(6000);//
ee12b079 205:d2ac4580960d 154 gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);
chaithanyarss 215:570251b23c7b 155
chaithanyarss 215:570251b23c7b 156
chaithanyarss 215:570251b23c7b 157
ee12b079 205:d2ac4580960d 158 /*gPC.printf("PL_TC sending\r\n");
chaithanyarss 215:570251b23c7b 159
ee12b079 199:9f03d6ca94c9 160 Base_tm *tm_ptr = new Short_tm;
ee12b079 199:9f03d6ca94c9 161 OBSRS_TC(tm_ptr);
chaithanyarss 215:570251b23c7b 162
ee12b079 199:9f03d6ca94c9 163 gPC.printf("PL_TC sent");
ee12b079 205:d2ac4580960d 164 */
shreeshas95 0:f016e9e8d48b 165 // *******************INITIALISATIONS END********************
chaithanyarss 215:570251b23c7b 166
chaithanyarss 223:7c802e1ccd30 167 FCTN_CDMS_HK_MAIN((void *)NULL);
chaithanyarss 223:7c802e1ccd30 168 //RtosTimer gCDMS_HK_TIMER(FCTN_CDMS_HK_MAIN, osTimerPeriodic);
chaithanyarss 223:7c802e1ccd30 169 //gCDMS_HK_TIMER.start(30000);
chaithanyarss 215:570251b23c7b 170
ee12b079 97:717c7908c822 171 /*starting the thread with signal*/
ee12b079 193:f76b475d7807 172 //set_sig();
ee12b079 193:f76b475d7807 173 //payload_isr_fun();
chaithanyarss 215:570251b23c7b 174
ee12b079 94:611c066467a1 175 /*Calculating Stack used*/
chaithanyarss 215:570251b23c7b 176
ee12b079 96:4ca92f9775e0 177 int state;
chaithanyarss 215:570251b23c7b 178 /*while (true) {
chaithanyarss 215:570251b23c7b 179 Thread::wait(500);
chaithanyarss 215:570251b23c7b 180 state = gSCIENCE_THREAD->get_state();
chaithanyarss 215:570251b23c7b 181 //gPC.printf("Thread state %d\r\n", state);
chaithanyarss 215:570251b23c7b 182 if(state == Thread::Inactive)
ee12b079 96:4ca92f9775e0 183 {delete gSCIENCE_THREAD;
ee12b079 96:4ca92f9775e0 184 break;}
ee12b079 96:4ca92f9775e0 185 }*/
chaithanyarss 215:570251b23c7b 186
chaithanyarss 215:570251b23c7b 187 while(true) {
ee12b079 97:717c7908c822 188 Thread::wait(osWaitForever);
ee12b079 96:4ca92f9775e0 189 //state = gCOM_MNG_TMTC_THREAD->get_state() + '0';
chaithanyarss 215:570251b23c7b 190 gLEDG = !gLEDG;
chaithanyarss 215:570251b23c7b 191 //gPC.putc(state);
shreeshas95 0:f016e9e8d48b 192 }
shreeshas95 0:f016e9e8d48b 193 }