Repository for CDMS code

Dependencies:   SimpleDMA mbed-rtos mbed eeprom

Fork of COM_MNG_TMTC_SIMPLE by Shreesha S

Committer:
chaithanyarss
Date:
Mon Jul 04 20:27:37 2016 +0000
Revision:
227:05e929bdd4dc
Parent:
224:3ac1f91e0ebc
comparing with standalone;

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 227:05e929bdd4dc 40 Base_tc *beacon_tc = new Long_tc;\
ee12b079 185:3b3cd96a7811 41 beacon_tc->next_TC = NULL;\
ee12b079 185:3b3cd96a7811 42 PUTshort_or_long(beacon_tc,SHORT_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 227:05e929bdd4dc 46 beacon_tc->TC_string[1] = 0x60;\
ee12b079 185:3b3cd96a7811 47 beacon_tc->TC_string[2] = 0x81;\
chaithanyarss 227:05e929bdd4dc 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;\
chaithanyarss 227:05e929bdd4dc 54 beacon_tc->TC_string[9] = 0x1d;\
chaithanyarss 227:05e929bdd4dc 55 beacon_tc->TC_string[10] = 0xd9;\
chaithanyarss 227:05e929bdd4dc 56 for(uint8_t z=11;z<135;z++){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 }
shreeshas95 105:5ce0337e7c15 87 //void set_sig(){gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);}
shreeshas95 0:f016e9e8d48b 88 int main()
shreeshas95 0:f016e9e8d48b 89 {
ee12b079 162:48fda0b8d573 90
ee12b079 185:3b3cd96a7811 91 CDMS_I2C_GPIO = 0;
ee12b079 210:f4acf895b598 92 PL_I2C_GPIO = 0;
ee12b079 162:48fda0b8d573 93
ee12b079 97:717c7908c822 94 //gLEDR = 1;
ee12b079 96:4ca92f9775e0 95
shreeshas95 0:f016e9e8d48b 96 // ******************INITIALISATIONS START******************
shreeshas95 0:f016e9e8d48b 97 // COM RX
ee12b079 161:a63672bf4423 98
shreeshas95 0:f016e9e8d48b 99 RX1M.baud(1200);
shreeshas95 0:f016e9e8d48b 100 gRX_HEAD_DATA_NODE = new COM_RX_DATA_NODE;
shreeshas95 0:f016e9e8d48b 101 gRX_HEAD_DATA_NODE->next_node = NULL;
shreeshas95 0:f016e9e8d48b 102 gRX_CURRENT_DATA_NODE = gRX_HEAD_DATA_NODE;
shreeshas95 2:2caf2a9a13aa 103 gRX_COUNT = 0;
shreeshas95 2:2caf2a9a13aa 104 // gRX_CURRENT_PTR = gRX_CURRENT_DATA_NODE->values;
shreeshas95 0:f016e9e8d48b 105 RX1M.attach(&rx_read, Serial::RxIrq);
shreeshas95 0:f016e9e8d48b 106
shreeshas95 0:f016e9e8d48b 107 // DEBUG
ee12b079 88:b9beee1a7a3e 108 //gPC.puts("welcome to mng_tm_tc\r\n");
chaithanyarss 227:05e929bdd4dc 109 gPC.baud(9600);//changed for bypassing COM
shreeshas95 0:f016e9e8d48b 110
shreeshas95 0:f016e9e8d48b 111 // COMMON SPI
shreeshas95 0:f016e9e8d48b 112 spi.format(8,0);
shreeshas95 0:f016e9e8d48b 113 spi.frequency(1000000);
shreeshas95 0:f016e9e8d48b 114
shreeshas95 0:f016e9e8d48b 115 // SD CARD
ee12b079 86:a26f5f22631d 116 cs_sd = 1;
shreeshas95 2:2caf2a9a13aa 117 gCS_RTC = 1;
ee12b079 90:df55a5f68331 118 gCS_ADF = 1;
ee12b079 93:4d76de54a699 119
ee12b079 115:2e1144a41d76 120 FCTN_CDMS_INIT_RTC();/* rtc initialization*/
ee12b079 203:424308159a56 121 FCTN_CDMS_SD_INIT();/* sd card initialization*/
shreeshas95 0:f016e9e8d48b 122
ee12b079 196:c51bf4993f75 123
ee12b079 196:c51bf4993f75 124 uint8_t test[512] = {0};
ee12b079 196:c51bf4993f75 125 disk_write(test,7000); //to be used only just before launch
ee12b079 196:c51bf4993f75 126
ee12b079 113:b8991d9e3b6c 127 #if DEBUG
ee12b079 113:b8991d9e3b6c 128 gPC.puts("welcome to mng_tmtc\r\n");
ee12b079 113:b8991d9e3b6c 129 #endif
ee12b079 113:b8991d9e3b6c 130
ee12b079 185:3b3cd96a7811 131
ee12b079 185:3b3cd96a7811 132
shreeshas95 0:f016e9e8d48b 133 // COM_MNG_TMTC THREAD
shreeshas95 0:f016e9e8d48b 134 gCOM_MNG_TMTC_THREAD = new Thread(COM_MNG_TMTC_FUN);
ee12b079 162:48fda0b8d573 135 gCOM_MNG_TMTC_THREAD->set_priority(osPriorityHigh);
ee12b079 99:efde3df6cd94 136 #if DEBUG
ee12b079 94:611c066467a1 137 gPC.puts("allocating threads\r\n");
ee12b079 99:efde3df6cd94 138 #endif
ee12b079 113:b8991d9e3b6c 139 gSCIENCE_THREAD = new Thread(SCIENCE_FUN);
ee12b079 94:611c066467a1 140 // gPC.puts("step one complete\r\n");
ee12b079 162:48fda0b8d573 141 gSCIENCE_THREAD->set_priority(osPriorityAboveNormal);
ee12b079 99:efde3df6cd94 142 #if DEBUG
ee12b079 94:611c066467a1 143 gPC.puts("competed allocating threads\r\n");
ee12b079 99:efde3df6cd94 144 #endif
shreeshas95 104:a50ae79ca36e 145
ee12b079 170:286ef9dad36a 146
ee12b079 170:286ef9dad36a 147 master.frequency(400000);
chaithanyarss 227:05e929bdd4dc 148 //PL_wo_dma = new RtosTimer(payload_isr_fun_dma, osTimerPeriodic,(void * )NULL);
ee12b079 193:f76b475d7807 149 //PL_wo_dma->start(6000);//
chaithanyarss 227:05e929bdd4dc 150 //gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);
ee12b079 203:424308159a56 151
chaithanyarss 227:05e929bdd4dc 152 while(1)
chaithanyarss 227:05e929bdd4dc 153 {
chaithanyarss 227:05e929bdd4dc 154 CDMS_I2C_GPIO = ~CDMS_I2C_GPIO;
chaithanyarss 227:05e929bdd4dc 155 wait(2);
chaithanyarss 227:05e929bdd4dc 156 }
ee12b079 193:f76b475d7807 157
chaithanyarss 227:05e929bdd4dc 158 while(1)
chaithanyarss 227:05e929bdd4dc 159 {
chaithanyarss 227:05e929bdd4dc 160 wait(5);
chaithanyarss 227:05e929bdd4dc 161 gPC.printf("PL_TC sending\r\n");
chaithanyarss 227:05e929bdd4dc 162 Base_tm *tm_ptr = new Long_tm;
chaithanyarss 227:05e929bdd4dc 163 PL_TC(tm_ptr);
chaithanyarss 227:05e929bdd4dc 164 }
ee12b079 199:9f03d6ca94c9 165
chaithanyarss 227:05e929bdd4dc 166 //gPC.printf("PL_TC sent");
ee12b079 199:9f03d6ca94c9 167
shreeshas95 0:f016e9e8d48b 168 // *******************INITIALISATIONS END********************
shreeshas95 0:f016e9e8d48b 169
chaithanyarss 224:3ac1f91e0ebc 170 FCTN_CDMS_HK_MAIN((void *)NULL);
ee12b079 113:b8991d9e3b6c 171 //RtosTimer gCDMS_HK_TIMER(FCTN_CDMS_HK_MAIN, osTimerPeriodic);
ee12b079 113:b8991d9e3b6c 172 //gCDMS_HK_TIMER.start(5000);
shreeshas95 104:a50ae79ca36e 173
ee12b079 97:717c7908c822 174 /*starting the thread with signal*/
ee12b079 193:f76b475d7807 175 //set_sig();
ee12b079 193:f76b475d7807 176 //payload_isr_fun();
ee12b079 97:717c7908c822 177
ee12b079 94:611c066467a1 178 /*Calculating Stack used*/
ee12b079 94:611c066467a1 179
ee12b079 96:4ca92f9775e0 180 int state;
ee12b079 96:4ca92f9775e0 181 /*while (true) {
ee12b079 96:4ca92f9775e0 182 Thread::wait(500);
ee12b079 96:4ca92f9775e0 183 state = gSCIENCE_THREAD->get_state();
ee12b079 96:4ca92f9775e0 184 //gPC.printf("Thread state %d\r\n", state);
ee12b079 96:4ca92f9775e0 185 if(state == Thread::Inactive)
ee12b079 96:4ca92f9775e0 186 {delete gSCIENCE_THREAD;
ee12b079 96:4ca92f9775e0 187 break;}
ee12b079 96:4ca92f9775e0 188 }*/
ee12b079 96:4ca92f9775e0 189
ee12b079 96:4ca92f9775e0 190
ee12b079 96:4ca92f9775e0 191
shreeshas95 0:f016e9e8d48b 192 while(true){
ee12b079 97:717c7908c822 193 Thread::wait(osWaitForever);
ee12b079 96:4ca92f9775e0 194 //state = gCOM_MNG_TMTC_THREAD->get_state() + '0';
ee12b079 96:4ca92f9775e0 195 gLEDG = !gLEDG;
ee12b079 96:4ca92f9775e0 196 //gPC.putc(state);
shreeshas95 0:f016e9e8d48b 197 }
shreeshas95 0:f016e9e8d48b 198 }