Repository for CDMS code

Dependencies:   SimpleDMA mbed-rtos mbed eeprom

Fork of COM_MNG_TMTC_SIMPLE by Shreesha S

Committer:
chaithanyarss
Date:
Wed Jun 29 13:59:21 2016 +0000
Revision:
187:2c7263530c57
Parent:
144:4c20fcc105ce
Child:
206:fba4aeebf004
SD card finalized code

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
shreeshas95 0:f016e9e8d48b 3 #include "mbed.h"
ee12b079 98:fd99ddc0e0a1 4
ee12b079 99:efde3df6cd94 5 #define DEBUG 1
ee12b079 98:fd99ddc0e0a1 6
shreeshas95 101:bece931236a2 7 #include "SimpleDMA.h"
shreeshas95 101:bece931236a2 8 #include "dmaSPIslave.h"
shreeshas95 0:f016e9e8d48b 9 #include "rtos.h"
shreeshas95 1:a0055b3280c8 10 #include "mbed_debug.h"
shreeshas95 0:f016e9e8d48b 11
shreeshas95 0:f016e9e8d48b 12 #include "Structures.h"
shreeshas95 103:b55559925dc1 13 #include "pinconfig.h"
shreeshas95 0:f016e9e8d48b 14 #include "DefinitionsAndGlobals.h"
aniruddhv 144:4c20fcc105ce 15 void rx_read();
shreeshas95 0:f016e9e8d48b 16 #include "crc.h"
shreeshas95 103:b55559925dc1 17 #include "i2c.h"
shreeshas95 1:a0055b3280c8 18 #include "COM_SND_TM_functions.h"
shreeshas95 1:a0055b3280c8 19 #include "COM_SND_TM.h"
ee12b079 99:efde3df6cd94 20 #include "cdms_sd.h"
krishanprajapat 117:bfdc807f3d3c 21 #include "common_functions.h"
ee12b079 114:9fb55057b13f 22 //#include "CDMS_HK.h"
ee12b079 86:a26f5f22631d 23 #include "OBSRS.h"
shreeshas95 1:a0055b3280c8 24 #include "adf.h"
shreeshas95 0:f016e9e8d48b 25 #include "COM_RCV_TC.h"
shreeshas95 0:f016e9e8d48b 26 #include "COM_MNG_TMTC.h"
aniruddhv 144:4c20fcc105ce 27 #include "COM_POWER_OFF_TX.h"
shreeshas95 4:104dd82c99b8 28 #include "COM_POWER_ON_TX.h"
ee12b079 96:4ca92f9775e0 29 #include "Compression.h"
shreeshas95 0:f016e9e8d48b 30 #include "ThreadsAndFunctions.h"
shreeshas95 0:f016e9e8d48b 31
chaithanyarss 187:2c7263530c57 32 DigitalOut SD_SW_EN_DS (PIN97);
chaithanyarss 187:2c7263530c57 33
shreeshas95 105:5ce0337e7c15 34 //void set_sig(){gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);}
shreeshas95 0:f016e9e8d48b 35 int main()
shreeshas95 0:f016e9e8d48b 36 {
ee12b079 97:717c7908c822 37 //gLEDR = 1;
ee12b079 96:4ca92f9775e0 38
shreeshas95 0:f016e9e8d48b 39 // ******************INITIALISATIONS START******************
shreeshas95 0:f016e9e8d48b 40 // COM RX
shreeshas95 0:f016e9e8d48b 41 RX1M.baud(1200);
shreeshas95 0:f016e9e8d48b 42 gRX_HEAD_DATA_NODE = new COM_RX_DATA_NODE;
shreeshas95 0:f016e9e8d48b 43 gRX_HEAD_DATA_NODE->next_node = NULL;
shreeshas95 0:f016e9e8d48b 44 gRX_CURRENT_DATA_NODE = gRX_HEAD_DATA_NODE;
shreeshas95 2:2caf2a9a13aa 45 gRX_COUNT = 0;
shreeshas95 2:2caf2a9a13aa 46 // gRX_CURRENT_PTR = gRX_CURRENT_DATA_NODE->values;
shreeshas95 0:f016e9e8d48b 47 RX1M.attach(&rx_read, Serial::RxIrq);
shreeshas95 0:f016e9e8d48b 48
chaithanyarss 187:2c7263530c57 49 gPC.baud(9600);
shreeshas95 0:f016e9e8d48b 50
shreeshas95 0:f016e9e8d48b 51 // COMMON SPI
shreeshas95 0:f016e9e8d48b 52 spi.format(8,0);
shreeshas95 0:f016e9e8d48b 53 spi.frequency(1000000);
shreeshas95 0:f016e9e8d48b 54
shreeshas95 0:f016e9e8d48b 55 // SD CARD
ee12b079 86:a26f5f22631d 56 cs_sd = 1;
shreeshas95 2:2caf2a9a13aa 57 gCS_RTC = 1;
ee12b079 90:df55a5f68331 58 gCS_ADF = 1;
ee12b079 93:4d76de54a699 59
chaithanyarss 187:2c7263530c57 60 FCTN_CDMS_INIT_RTC(); /* rtc initialization*/
chaithanyarss 187:2c7263530c57 61 FCTN_CDMS_SD_INIT(); /*sd card initialization*/
chaithanyarss 187:2c7263530c57 62 uint8_t test[512];
chaithanyarss 187:2c7263530c57 63 uint8_t data[512];
chaithanyarss 187:2c7263530c57 64 for(int i=0;i<512;i++)
chaithanyarss 187:2c7263530c57 65 data[i] = i%100;
chaithanyarss 187:2c7263530c57 66 for(int i=0;i<512;i++)
chaithanyarss 187:2c7263530c57 67 test[i] = 1;
chaithanyarss 187:2c7263530c57 68 disk_write(test,7000);
chaithanyarss 187:2c7263530c57 69 disk_read(test,7000);
chaithanyarss 187:2c7263530c57 70 uint32_t fsc = FCTN_SD_MNGR(3);
chaithanyarss 187:2c7263530c57 71 if(SD_WRITE(data,fsc,3) == 0)
chaithanyarss 187:2c7263530c57 72 {
chaithanyarss 187:2c7263530c57 73 SD_READ(test,fsc,3);
chaithanyarss 187:2c7263530c57 74 for(int i=0;i<15;i++)
chaithanyarss 187:2c7263530c57 75 {
chaithanyarss 187:2c7263530c57 76 gPC.printf("\r0x%02X 0x%02X\n",data[i],test[i]);
chaithanyarss 187:2c7263530c57 77 }
chaithanyarss 187:2c7263530c57 78 }
chaithanyarss 187:2c7263530c57 79
shreeshas95 0:f016e9e8d48b 80
ee12b079 134:4694fc291ce1 81 if (DEBUG)
chaithanyarss 187:2c7263530c57 82 gPC.puts("\rwelcome to mng_22tmtc\r\n");
chaithanyarss 187:2c7263530c57 83
ee12b079 134:4694fc291ce1 84
shreeshas95 0:f016e9e8d48b 85 // COM_MNG_TMTC THREAD
shreeshas95 0:f016e9e8d48b 86 gCOM_MNG_TMTC_THREAD = new Thread(COM_MNG_TMTC_FUN);
shreeshas95 0:f016e9e8d48b 87 gCOM_MNG_TMTC_THREAD->set_priority(osPriorityAboveNormal);
ee12b079 134:4694fc291ce1 88 if (DEBUG)
ee12b079 134:4694fc291ce1 89 gPC.puts("allocating threads\r\n");
ee12b079 113:b8991d9e3b6c 90 gSCIENCE_THREAD = new Thread(SCIENCE_FUN);
ee12b079 94:611c066467a1 91 // gPC.puts("step one complete\r\n");
ee12b079 113:b8991d9e3b6c 92 gSCIENCE_THREAD->set_priority(osPriorityBelowNormal);
ee12b079 134:4694fc291ce1 93 if (DEBUG)
ee12b079 134:4694fc291ce1 94 gPC.puts("competed allocating threads\r\n");
ee12b079 134:4694fc291ce1 95
shreeshas95 0:f016e9e8d48b 96 // *******************INITIALISATIONS END********************
shreeshas95 0:f016e9e8d48b 97
ee12b079 113:b8991d9e3b6c 98 //RtosTimer gCDMS_HK_TIMER(FCTN_CDMS_HK_MAIN, osTimerPeriodic);
ee12b079 113:b8991d9e3b6c 99 //gCDMS_HK_TIMER.start(5000);
shreeshas95 104:a50ae79ca36e 100
ee12b079 97:717c7908c822 101 /*starting the thread with signal*/
shreeshas95 105:5ce0337e7c15 102 // set_sig();
ee12b079 97:717c7908c822 103
ee12b079 94:611c066467a1 104 /*Calculating Stack used*/
ee12b079 94:611c066467a1 105
ee12b079 96:4ca92f9775e0 106 int state;
ee12b079 96:4ca92f9775e0 107 /*while (true) {
ee12b079 96:4ca92f9775e0 108 Thread::wait(500);
ee12b079 96:4ca92f9775e0 109 state = gSCIENCE_THREAD->get_state();
ee12b079 96:4ca92f9775e0 110 //gPC.printf("Thread state %d\r\n", state);
ee12b079 96:4ca92f9775e0 111 if(state == Thread::Inactive)
ee12b079 96:4ca92f9775e0 112 {delete gSCIENCE_THREAD;
ee12b079 96:4ca92f9775e0 113 break;}
ee12b079 96:4ca92f9775e0 114 }*/
ee12b079 96:4ca92f9775e0 115
ee12b079 96:4ca92f9775e0 116
ee12b079 96:4ca92f9775e0 117
shreeshas95 0:f016e9e8d48b 118 while(true){
ee12b079 97:717c7908c822 119 Thread::wait(osWaitForever);
ee12b079 96:4ca92f9775e0 120 //state = gCOM_MNG_TMTC_THREAD->get_state() + '0';
ee12b079 96:4ca92f9775e0 121 gLEDG = !gLEDG;
ee12b079 96:4ca92f9775e0 122 //gPC.putc(state);
shreeshas95 0:f016e9e8d48b 123 }
shreeshas95 0:f016e9e8d48b 124 }