Repository for CDMS code

Dependencies:   SimpleDMA mbed-rtos mbed eeprom

Fork of COM_MNG_TMTC_SIMPLE by Shreesha S

Committer:
ee12b079
Date:
Thu Jun 30 10:51:38 2016 +0000
Revision:
197:1369ef45b49e
Parent:
196:c51bf4993f75
Child:
199:9f03d6ca94c9
latest revision (before sdcard testing) ready to be tested bypassing COM

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