Repository for CDMS code

Dependencies:   SimpleDMA mbed-rtos mbed eeprom

Fork of COM_MNG_TMTC_SIMPLE by Shreesha S

Committer:
ee12b079
Date:
Mon Apr 18 12:18:53 2016 +0000
Revision:
164:be3b4b760d0c
Parent:
162:48fda0b8d573
Child:
170:286ef9dad36a
Working Code : OBSRS and MMS cheked with GS using actual CDMS Hardware

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shreeshas95 7:fcd26c28411d 1 // TESTING PUSH PULL IN MAIN CPP
shreeshas95 7:fcd26c28411d 2
krishanprajapat 150:fa3940954b1e 3
shreeshas95 0:f016e9e8d48b 4 #include "mbed.h"
ee12b079 98:fd99ddc0e0a1 5
ee12b079 99:efde3df6cd94 6 #define DEBUG 1
ee12b079 162:48fda0b8d573 7 #define power_tx 0
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
shreeshas95 105:5ce0337e7c15 35 //void set_sig(){gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);}
shreeshas95 0:f016e9e8d48b 36 int main()
shreeshas95 0:f016e9e8d48b 37 {
ee12b079 162:48fda0b8d573 38
ee12b079 162:48fda0b8d573 39
ee12b079 162:48fda0b8d573 40 CDMS_I2C_GPIO = 0;
ee12b079 97:717c7908c822 41 //gLEDR = 1;
ee12b079 96:4ca92f9775e0 42
shreeshas95 0:f016e9e8d48b 43 // ******************INITIALISATIONS START******************
shreeshas95 0:f016e9e8d48b 44 // COM RX
ee12b079 161:a63672bf4423 45
shreeshas95 0:f016e9e8d48b 46 RX1M.baud(1200);
shreeshas95 0:f016e9e8d48b 47 gRX_HEAD_DATA_NODE = new COM_RX_DATA_NODE;
shreeshas95 0:f016e9e8d48b 48 gRX_HEAD_DATA_NODE->next_node = NULL;
shreeshas95 0:f016e9e8d48b 49 gRX_CURRENT_DATA_NODE = gRX_HEAD_DATA_NODE;
shreeshas95 2:2caf2a9a13aa 50 gRX_COUNT = 0;
shreeshas95 2:2caf2a9a13aa 51 // gRX_CURRENT_PTR = gRX_CURRENT_DATA_NODE->values;
shreeshas95 0:f016e9e8d48b 52 RX1M.attach(&rx_read, Serial::RxIrq);
shreeshas95 0:f016e9e8d48b 53
shreeshas95 0:f016e9e8d48b 54 // DEBUG
ee12b079 88:b9beee1a7a3e 55 //gPC.puts("welcome to mng_tm_tc\r\n");
ee12b079 164:be3b4b760d0c 56 gPC.baud(1200);
shreeshas95 0:f016e9e8d48b 57
shreeshas95 0:f016e9e8d48b 58 // COMMON SPI
shreeshas95 0:f016e9e8d48b 59 spi.format(8,0);
shreeshas95 0:f016e9e8d48b 60 spi.frequency(1000000);
shreeshas95 0:f016e9e8d48b 61
shreeshas95 0:f016e9e8d48b 62 // SD CARD
ee12b079 86:a26f5f22631d 63 cs_sd = 1;
shreeshas95 2:2caf2a9a13aa 64 gCS_RTC = 1;
ee12b079 90:df55a5f68331 65 gCS_ADF = 1;
ee12b079 93:4d76de54a699 66
ee12b079 115:2e1144a41d76 67 FCTN_CDMS_INIT_RTC();/* rtc initialization*/
ee12b079 113:b8991d9e3b6c 68 FCTN_CDMS_SD_INIT();/* sd card initialization*/
shreeshas95 0:f016e9e8d48b 69
ee12b079 113:b8991d9e3b6c 70 #if DEBUG
ee12b079 113:b8991d9e3b6c 71 gPC.puts("welcome to mng_tmtc\r\n");
ee12b079 113:b8991d9e3b6c 72 #endif
ee12b079 113:b8991d9e3b6c 73
shreeshas95 0:f016e9e8d48b 74 // COM_MNG_TMTC THREAD
shreeshas95 0:f016e9e8d48b 75 gCOM_MNG_TMTC_THREAD = new Thread(COM_MNG_TMTC_FUN);
ee12b079 162:48fda0b8d573 76 gCOM_MNG_TMTC_THREAD->set_priority(osPriorityHigh);
ee12b079 99:efde3df6cd94 77 #if DEBUG
ee12b079 94:611c066467a1 78 gPC.puts("allocating threads\r\n");
ee12b079 99:efde3df6cd94 79 #endif
ee12b079 113:b8991d9e3b6c 80 gSCIENCE_THREAD = new Thread(SCIENCE_FUN);
ee12b079 94:611c066467a1 81 // gPC.puts("step one complete\r\n");
ee12b079 162:48fda0b8d573 82 gSCIENCE_THREAD->set_priority(osPriorityAboveNormal);
ee12b079 99:efde3df6cd94 83 #if DEBUG
ee12b079 94:611c066467a1 84 gPC.puts("competed allocating threads\r\n");
ee12b079 99:efde3df6cd94 85 #endif
shreeshas95 104:a50ae79ca36e 86
shreeshas95 0:f016e9e8d48b 87 // *******************INITIALISATIONS END********************
shreeshas95 0:f016e9e8d48b 88
ee12b079 113:b8991d9e3b6c 89 //RtosTimer gCDMS_HK_TIMER(FCTN_CDMS_HK_MAIN, osTimerPeriodic);
ee12b079 113:b8991d9e3b6c 90 //gCDMS_HK_TIMER.start(5000);
shreeshas95 104:a50ae79ca36e 91
ee12b079 97:717c7908c822 92 /*starting the thread with signal*/
shreeshas95 105:5ce0337e7c15 93 // set_sig();
ee12b079 97:717c7908c822 94
ee12b079 94:611c066467a1 95 /*Calculating Stack used*/
ee12b079 94:611c066467a1 96
ee12b079 96:4ca92f9775e0 97 int state;
ee12b079 96:4ca92f9775e0 98 /*while (true) {
ee12b079 96:4ca92f9775e0 99 Thread::wait(500);
ee12b079 96:4ca92f9775e0 100 state = gSCIENCE_THREAD->get_state();
ee12b079 96:4ca92f9775e0 101 //gPC.printf("Thread state %d\r\n", state);
ee12b079 96:4ca92f9775e0 102 if(state == Thread::Inactive)
ee12b079 96:4ca92f9775e0 103 {delete gSCIENCE_THREAD;
ee12b079 96:4ca92f9775e0 104 break;}
ee12b079 96:4ca92f9775e0 105 }*/
ee12b079 96:4ca92f9775e0 106
ee12b079 96:4ca92f9775e0 107
ee12b079 96:4ca92f9775e0 108
shreeshas95 0:f016e9e8d48b 109 while(true){
ee12b079 97:717c7908c822 110 Thread::wait(osWaitForever);
ee12b079 96:4ca92f9775e0 111 //state = gCOM_MNG_TMTC_THREAD->get_state() + '0';
ee12b079 96:4ca92f9775e0 112 gLEDG = !gLEDG;
ee12b079 96:4ca92f9775e0 113 //gPC.putc(state);
shreeshas95 0:f016e9e8d48b 114 }
shreeshas95 0:f016e9e8d48b 115 }