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:
Thu Jul 07 17:13:00 2016 +0000
Revision:
238:4abbc6a3a641
Parent:
232:b1458c1e9199
Child:
239:a3a012a0fecc
RTOSTimer for HK thread added

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 }
ee12b079 238:4abbc6a3a641 88
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
shreeshas95 0:f016e9e8d48b 95 RX1M.baud(1200);
shreeshas95 0:f016e9e8d48b 96 gRX_HEAD_DATA_NODE = new COM_RX_DATA_NODE;
shreeshas95 0:f016e9e8d48b 97 gRX_HEAD_DATA_NODE->next_node = NULL;
shreeshas95 0:f016e9e8d48b 98 gRX_CURRENT_DATA_NODE = gRX_HEAD_DATA_NODE;
shreeshas95 2:2caf2a9a13aa 99 gRX_COUNT = 0;
shreeshas95 0:f016e9e8d48b 100 RX1M.attach(&rx_read, Serial::RxIrq);
shreeshas95 0:f016e9e8d48b 101
ee12b079 203:424308159a56 102 gPC.baud(115200);//changed for bypassing COM
shreeshas95 0:f016e9e8d48b 103
shreeshas95 0:f016e9e8d48b 104 // COMMON SPI
shreeshas95 0:f016e9e8d48b 105 spi.format(8,0);
shreeshas95 0:f016e9e8d48b 106 spi.frequency(1000000);
shreeshas95 0:f016e9e8d48b 107
shreeshas95 0:f016e9e8d48b 108 // SD CARD
ee12b079 86:a26f5f22631d 109 cs_sd = 1;
shreeshas95 2:2caf2a9a13aa 110 gCS_RTC = 1;
ee12b079 90:df55a5f68331 111 gCS_ADF = 1;
ee12b079 93:4d76de54a699 112
ee12b079 115:2e1144a41d76 113 FCTN_CDMS_INIT_RTC();/* rtc initialization*/
ee12b079 203:424308159a56 114 FCTN_CDMS_SD_INIT();/* sd card initialization*/
shreeshas95 0:f016e9e8d48b 115
ee12b079 196:c51bf4993f75 116
ee12b079 196:c51bf4993f75 117 uint8_t test[512] = {0};
ee12b079 196:c51bf4993f75 118 disk_write(test,7000); //to be used only just before launch
ee12b079 196:c51bf4993f75 119
ee12b079 113:b8991d9e3b6c 120 #if DEBUG
ee12b079 113:b8991d9e3b6c 121 gPC.puts("welcome to mng_tmtc\r\n");
ee12b079 113:b8991d9e3b6c 122 #endif
ee12b079 113:b8991d9e3b6c 123
ee12b079 238:4abbc6a3a641 124 #if DEBUG
ee12b079 238:4abbc6a3a641 125 gPC.puts("allocating threads\r\n");
ee12b079 238:4abbc6a3a641 126 #endif
ee12b079 185:3b3cd96a7811 127
shreeshas95 0:f016e9e8d48b 128 // COM_MNG_TMTC THREAD
shreeshas95 0:f016e9e8d48b 129 gCOM_MNG_TMTC_THREAD = new Thread(COM_MNG_TMTC_FUN);
ee12b079 162:48fda0b8d573 130 gCOM_MNG_TMTC_THREAD->set_priority(osPriorityHigh);
ee12b079 238:4abbc6a3a641 131
ee12b079 238:4abbc6a3a641 132 gHK_THREAD = new Thread(FCTN_CDMS_HK_MAIN);
ee12b079 238:4abbc6a3a641 133 gHK_THREAD->set_priority(osPriorityAboveNormal);
ee12b079 238:4abbc6a3a641 134
ee12b079 113:b8991d9e3b6c 135 gSCIENCE_THREAD = new Thread(SCIENCE_FUN);
ee12b079 162:48fda0b8d573 136 gSCIENCE_THREAD->set_priority(osPriorityAboveNormal);
ee12b079 238:4abbc6a3a641 137
ee12b079 99:efde3df6cd94 138 #if DEBUG
ee12b079 94:611c066467a1 139 gPC.puts("competed allocating threads\r\n");
ee12b079 99:efde3df6cd94 140 #endif
shreeshas95 104:a50ae79ca36e 141
ee12b079 170:286ef9dad36a 142
ee12b079 238:4abbc6a3a641 143
ee12b079 170:286ef9dad36a 144 master.frequency(400000);
ee12b079 238:4abbc6a3a641 145
ee12b079 238:4abbc6a3a641 146 HK_counter = new RtosTimer(hk_isr, osTimerPeriodic,(void * )NULL);
ee12b079 238:4abbc6a3a641 147 HK_counter->start(10000);
ee12b079 238:4abbc6a3a641 148
ee12b079 238:4abbc6a3a641 149 //PL_wo_dma = new RtosTimer(payload_isr_fun_dma, osTimerPeriodic,(void * )NULL);
ee12b079 193:f76b475d7807 150 //PL_wo_dma->start(6000);//
ee12b079 238:4abbc6a3a641 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 while(true){
ee12b079 97:717c7908c822 165 Thread::wait(osWaitForever);
ee12b079 96:4ca92f9775e0 166 gLEDG = !gLEDG;
shreeshas95 0:f016e9e8d48b 167 }
shreeshas95 0:f016e9e8d48b 168 }