CDMS_CODE_samp_23SEP_DMA_flag

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE_samp_23SEP_DMA by iitm sat

Committer:
ee12b079
Date:
Tue Jul 05 11:52:47 2016 +0000
Revision:
232:b1458c1e9199
Parent:
228:335da5b0d3e4
Child:
238:4abbc6a3a641
Child:
243:29625f5fc745
Child:
248:407ab7e337cd
Testing BAE TCs, not printing TM

Who changed what in which revision?

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