Repository for CDMS code

Dependencies:   SimpleDMA mbed-rtos mbed eeprom

Fork of COM_MNG_TMTC_SIMPLE by Shreesha S

Committer:
ee12b079
Date:
Tue Jun 28 09:51:56 2016 +0000
Revision:
192:f0d5fde60221
Parent:
191:0636c8391407
Child:
193:f76b475d7807
science thread with rtostimer working

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 162:48fda0b8d573 8 #define power_tx 0
ee12b079 98:fd99ddc0e0a1 9
shreeshas95 101:bece931236a2 10 #include "SimpleDMA.h"
shreeshas95 101:bece931236a2 11 #include "dmaSPIslave.h"
shreeshas95 0:f016e9e8d48b 12 #include "rtos.h"
shreeshas95 1:a0055b3280c8 13 #include "mbed_debug.h"
shreeshas95 0:f016e9e8d48b 14
shreeshas95 0:f016e9e8d48b 15 #include "Structures.h"
shreeshas95 103:b55559925dc1 16 #include "pinconfig.h"
shreeshas95 0:f016e9e8d48b 17 #include "DefinitionsAndGlobals.h"
shreeshas95 0:f016e9e8d48b 18 #include "crc.h"
shreeshas95 103:b55559925dc1 19 #include "i2c.h"
shreeshas95 1:a0055b3280c8 20 #include "COM_SND_TM_functions.h"
shreeshas95 1:a0055b3280c8 21 #include "COM_SND_TM.h"
ee12b079 99:efde3df6cd94 22 #include "cdms_sd.h"
krishanprajapat 117:bfdc807f3d3c 23 #include "common_functions.h"
ee12b079 114:9fb55057b13f 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 161:a63672bf4423 28 //#include "Flash.h"
ee12b079 161:a63672bf4423 29 #include "cdms_rtc.h"
shreeshas95 0:f016e9e8d48b 30 #include "COM_MNG_TMTC.h"
shreeshas95 4:104dd82c99b8 31 #include "COM_POWER_ON_TX.h"
shreeshas95 4:104dd82c99b8 32 #include "COM_POWER_OFF_TX.h"
ee12b079 96:4ca92f9775e0 33 #include "Compression.h"
shreeshas95 0:f016e9e8d48b 34 #include "ThreadsAndFunctions.h"
shreeshas95 0:f016e9e8d48b 35
ee12b079 185:3b3cd96a7811 36 #define PL_TC(tm_ptr){\
ee12b079 185:3b3cd96a7811 37 Base_tc *beacon_tc = new Short_tc;\
ee12b079 185:3b3cd96a7811 38 beacon_tc->next_TC = NULL;\
ee12b079 185:3b3cd96a7811 39 PUTshort_or_long(beacon_tc,SHORT_TC_CODE);\
ee12b079 185:3b3cd96a7811 40 PUTcrc_pass(beacon_tc,0x1);\
ee12b079 185:3b3cd96a7811 41 PUTexec_status(beacon_tc,0);\
ee12b079 185:3b3cd96a7811 42 beacon_tc->TC_string[0] = 0x01;\
ee12b079 185:3b3cd96a7811 43 beacon_tc->TC_string[1] = 0xE0;\
ee12b079 185:3b3cd96a7811 44 beacon_tc->TC_string[2] = 0x81;\
ee12b079 185:3b3cd96a7811 45 beacon_tc->TC_string[3] = 0xD0;\
ee12b079 185:3b3cd96a7811 46 beacon_tc->TC_string[4] = 0x00;\
ee12b079 185:3b3cd96a7811 47 beacon_tc->TC_string[5] = 0;\
ee12b079 185:3b3cd96a7811 48 beacon_tc->TC_string[6] = 0;\
ee12b079 185:3b3cd96a7811 49 beacon_tc->TC_string[7] = 0;\
ee12b079 185:3b3cd96a7811 50 beacon_tc->TC_string[8] = 0;\
ee12b079 185:3b3cd96a7811 51 uint16_t crc16 = crc16_gen(beacon_tc->TC_string, 9);\
ee12b079 185:3b3cd96a7811 52 beacon_tc->TC_string[9] = (crc16 & 0xFF00)>>8;\
ee12b079 185:3b3cd96a7811 53 beacon_tc->TC_string[10] = (crc16 & 0x00FF);\
ee12b079 185:3b3cd96a7811 54 tm_ptr = FCTN_CDMS_RLY_TMTC(beacon_tc);\
ee12b079 185:3b3cd96a7811 55 }
ee12b079 185:3b3cd96a7811 56
shreeshas95 105:5ce0337e7c15 57 //void set_sig(){gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);}
shreeshas95 0:f016e9e8d48b 58 int main()
shreeshas95 0:f016e9e8d48b 59 {
ee12b079 162:48fda0b8d573 60
ee12b079 185:3b3cd96a7811 61 CDMS_I2C_GPIO = 0;
ee12b079 185:3b3cd96a7811 62 PYLD_I2C_GPIO = 0;
ee12b079 162:48fda0b8d573 63
ee12b079 189:1140091f5cec 64 /*gPC.printf("PL_TC sending\r\n");
ee12b079 185:3b3cd96a7811 65
ee12b079 185:3b3cd96a7811 66 Base_tm *tm_ptr = new Short_tm;
ee12b079 185:3b3cd96a7811 67 PL_TC(tm_ptr);
ee12b079 185:3b3cd96a7811 68
ee12b079 189:1140091f5cec 69 gPC.printf("PL_TC sent");*/
ee12b079 185:3b3cd96a7811 70
ee12b079 97:717c7908c822 71 //gLEDR = 1;
ee12b079 96:4ca92f9775e0 72
shreeshas95 0:f016e9e8d48b 73 // ******************INITIALISATIONS START******************
shreeshas95 0:f016e9e8d48b 74 // COM RX
ee12b079 161:a63672bf4423 75
shreeshas95 0:f016e9e8d48b 76 RX1M.baud(1200);
shreeshas95 0:f016e9e8d48b 77 gRX_HEAD_DATA_NODE = new COM_RX_DATA_NODE;
shreeshas95 0:f016e9e8d48b 78 gRX_HEAD_DATA_NODE->next_node = NULL;
shreeshas95 0:f016e9e8d48b 79 gRX_CURRENT_DATA_NODE = gRX_HEAD_DATA_NODE;
shreeshas95 2:2caf2a9a13aa 80 gRX_COUNT = 0;
shreeshas95 2:2caf2a9a13aa 81 // gRX_CURRENT_PTR = gRX_CURRENT_DATA_NODE->values;
shreeshas95 0:f016e9e8d48b 82 RX1M.attach(&rx_read, Serial::RxIrq);
shreeshas95 0:f016e9e8d48b 83
shreeshas95 0:f016e9e8d48b 84 // DEBUG
ee12b079 88:b9beee1a7a3e 85 //gPC.puts("welcome to mng_tm_tc\r\n");
ee12b079 164:be3b4b760d0c 86 gPC.baud(1200);
shreeshas95 0:f016e9e8d48b 87
shreeshas95 0:f016e9e8d48b 88 // COMMON SPI
shreeshas95 0:f016e9e8d48b 89 spi.format(8,0);
shreeshas95 0:f016e9e8d48b 90 spi.frequency(1000000);
shreeshas95 0:f016e9e8d48b 91
shreeshas95 0:f016e9e8d48b 92 // SD CARD
ee12b079 86:a26f5f22631d 93 cs_sd = 1;
shreeshas95 2:2caf2a9a13aa 94 gCS_RTC = 1;
ee12b079 90:df55a5f68331 95 gCS_ADF = 1;
ee12b079 93:4d76de54a699 96
ee12b079 115:2e1144a41d76 97 FCTN_CDMS_INIT_RTC();/* rtc initialization*/
ee12b079 113:b8991d9e3b6c 98 FCTN_CDMS_SD_INIT();/* sd card initialization*/
shreeshas95 0:f016e9e8d48b 99
ee12b079 113:b8991d9e3b6c 100 #if DEBUG
ee12b079 113:b8991d9e3b6c 101 gPC.puts("welcome to mng_tmtc\r\n");
ee12b079 113:b8991d9e3b6c 102 #endif
ee12b079 113:b8991d9e3b6c 103
ee12b079 185:3b3cd96a7811 104
ee12b079 185:3b3cd96a7811 105
shreeshas95 0:f016e9e8d48b 106 // COM_MNG_TMTC THREAD
shreeshas95 0:f016e9e8d48b 107 gCOM_MNG_TMTC_THREAD = new Thread(COM_MNG_TMTC_FUN);
ee12b079 162:48fda0b8d573 108 gCOM_MNG_TMTC_THREAD->set_priority(osPriorityHigh);
ee12b079 99:efde3df6cd94 109 #if DEBUG
ee12b079 94:611c066467a1 110 gPC.puts("allocating threads\r\n");
ee12b079 99:efde3df6cd94 111 #endif
ee12b079 113:b8991d9e3b6c 112 gSCIENCE_THREAD = new Thread(SCIENCE_FUN);
ee12b079 94:611c066467a1 113 // gPC.puts("step one complete\r\n");
ee12b079 162:48fda0b8d573 114 gSCIENCE_THREAD->set_priority(osPriorityAboveNormal);
ee12b079 99:efde3df6cd94 115 #if DEBUG
ee12b079 94:611c066467a1 116 gPC.puts("competed allocating threads\r\n");
ee12b079 99:efde3df6cd94 117 #endif
shreeshas95 104:a50ae79ca36e 118
ee12b079 170:286ef9dad36a 119
ee12b079 170:286ef9dad36a 120 master.frequency(400000);
ee12b079 192:f0d5fde60221 121 PL_wo_dma = new RtosTimer(payload_isr_fun_dma, osTimerPeriodic,(void * )NULL);
ee12b079 192:f0d5fde60221 122 PL_wo_dma->start(6000);//
ee12b079 191:0636c8391407 123
ee12b079 191:0636c8391407 124
ee12b079 191:0636c8391407 125
ee12b079 170:286ef9dad36a 126
shreeshas95 0:f016e9e8d48b 127 // *******************INITIALISATIONS END********************
shreeshas95 0:f016e9e8d48b 128
ee12b079 113:b8991d9e3b6c 129 //RtosTimer gCDMS_HK_TIMER(FCTN_CDMS_HK_MAIN, osTimerPeriodic);
ee12b079 113:b8991d9e3b6c 130 //gCDMS_HK_TIMER.start(5000);
shreeshas95 104:a50ae79ca36e 131
ee12b079 97:717c7908c822 132 /*starting the thread with signal*/
shreeshas95 105:5ce0337e7c15 133 // set_sig();
ee12b079 97:717c7908c822 134
ee12b079 94:611c066467a1 135 /*Calculating Stack used*/
ee12b079 94:611c066467a1 136
ee12b079 96:4ca92f9775e0 137 int state;
ee12b079 96:4ca92f9775e0 138 /*while (true) {
ee12b079 96:4ca92f9775e0 139 Thread::wait(500);
ee12b079 96:4ca92f9775e0 140 state = gSCIENCE_THREAD->get_state();
ee12b079 96:4ca92f9775e0 141 //gPC.printf("Thread state %d\r\n", state);
ee12b079 96:4ca92f9775e0 142 if(state == Thread::Inactive)
ee12b079 96:4ca92f9775e0 143 {delete gSCIENCE_THREAD;
ee12b079 96:4ca92f9775e0 144 break;}
ee12b079 96:4ca92f9775e0 145 }*/
ee12b079 96:4ca92f9775e0 146
ee12b079 96:4ca92f9775e0 147
ee12b079 96:4ca92f9775e0 148
shreeshas95 0:f016e9e8d48b 149 while(true){
ee12b079 97:717c7908c822 150 Thread::wait(osWaitForever);
ee12b079 96:4ca92f9775e0 151 //state = gCOM_MNG_TMTC_THREAD->get_state() + '0';
ee12b079 96:4ca92f9775e0 152 gLEDG = !gLEDG;
ee12b079 96:4ca92f9775e0 153 //gPC.putc(state);
shreeshas95 0:f016e9e8d48b 154 }
shreeshas95 0:f016e9e8d48b 155 }