CDMS code for testing sbc

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE by shubham c

Committer:
krishanprajapat
Date:
Wed Feb 03 11:23:26 2016 +0000
Revision:
106:cd10ac5ad10e
Parent:
105:5ce0337e7c15
included common_functions.h

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
krishanprajapat 106:cd10ac5ad10e 12
shreeshas95 0:f016e9e8d48b 13 #include "Structures.h"
shreeshas95 103:b55559925dc1 14 #include "pinconfig.h"
shreeshas95 0:f016e9e8d48b 15 #include "DefinitionsAndGlobals.h"
shreeshas95 0:f016e9e8d48b 16 #include "crc.h"
shreeshas95 103:b55559925dc1 17 #include "i2c.h"
krishanprajapat 106:cd10ac5ad10e 18 #include "common_functions.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"
shreeshas95 103:b55559925dc1 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"
shreeshas95 4:104dd82c99b8 27 #include "COM_POWER_ON_TX.h"
shreeshas95 4:104dd82c99b8 28 #include "COM_POWER_OFF_TX.h"
ee12b079 96:4ca92f9775e0 29 #include "Compression.h"
shreeshas95 0:f016e9e8d48b 30 #include "ThreadsAndFunctions.h"
shreeshas95 0:f016e9e8d48b 31
shreeshas95 105:5ce0337e7c15 32 //void set_sig(){gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);}
shreeshas95 0:f016e9e8d48b 33 int main()
shreeshas95 0:f016e9e8d48b 34 {
shreeshas95 101:bece931236a2 35 #if DEBUG
shreeshas95 101:bece931236a2 36 gPC.puts("welcome to mng_tmtc\r\n");
shreeshas95 101:bece931236a2 37 #endif
ee12b079 97:717c7908c822 38 //gLEDR = 1;
ee12b079 96:4ca92f9775e0 39
shreeshas95 0:f016e9e8d48b 40 // ******************INITIALISATIONS START******************
shreeshas95 0:f016e9e8d48b 41 // COM RX
shreeshas95 0:f016e9e8d48b 42 RX1M.baud(1200);
shreeshas95 0:f016e9e8d48b 43 gRX_HEAD_DATA_NODE = new COM_RX_DATA_NODE;
shreeshas95 0:f016e9e8d48b 44 gRX_HEAD_DATA_NODE->next_node = NULL;
shreeshas95 0:f016e9e8d48b 45 gRX_CURRENT_DATA_NODE = gRX_HEAD_DATA_NODE;
shreeshas95 2:2caf2a9a13aa 46 gRX_COUNT = 0;
shreeshas95 2:2caf2a9a13aa 47 // gRX_CURRENT_PTR = gRX_CURRENT_DATA_NODE->values;
shreeshas95 0:f016e9e8d48b 48 RX1M.attach(&rx_read, Serial::RxIrq);
shreeshas95 0:f016e9e8d48b 49
shreeshas95 0:f016e9e8d48b 50 // DEBUG
ee12b079 88:b9beee1a7a3e 51 //gPC.puts("welcome to mng_tm_tc\r\n");
aniruddhv 52:0bd68655c651 52 gPC.baud(1200);
shreeshas95 0:f016e9e8d48b 53
shreeshas95 0:f016e9e8d48b 54 // COMMON SPI
shreeshas95 0:f016e9e8d48b 55 spi.format(8,0);
shreeshas95 0:f016e9e8d48b 56 spi.frequency(1000000);
shreeshas95 0:f016e9e8d48b 57
shreeshas95 0:f016e9e8d48b 58 // SD CARD
ee12b079 86:a26f5f22631d 59 cs_sd = 1;
shreeshas95 2:2caf2a9a13aa 60 gCS_RTC = 1;
ee12b079 90:df55a5f68331 61 gCS_ADF = 1;
ee12b079 93:4d76de54a699 62
ee12b079 98:fd99ddc0e0a1 63 //FCTN_CDMS_INIT_RTC();/* rtc initialization*/
shreeshas95 105:5ce0337e7c15 64 // FCTN_CDMS_SD_INIT();/* sd card initialization*/
ee12b079 93:4d76de54a699 65
shreeshas95 0:f016e9e8d48b 66 // initialise_card();
shreeshas95 0:f016e9e8d48b 67 // int result= initialise_card();
shreeshas95 0:f016e9e8d48b 68 // disk_initialize();
shreeshas95 0:f016e9e8d48b 69
shreeshas95 0:f016e9e8d48b 70 // COM_TX
shreeshas95 0:f016e9e8d48b 71 // *********************THE TEST
shreeshas95 0:f016e9e8d48b 72 // cs_adf=1;
shreeshas95 0:f016e9e8d48b 73 // *********************THE TEST
shreeshas95 0:f016e9e8d48b 74
shreeshas95 0:f016e9e8d48b 75 // COM_MNG_TMTC THREAD
shreeshas95 0:f016e9e8d48b 76 gCOM_MNG_TMTC_THREAD = new Thread(COM_MNG_TMTC_FUN);
shreeshas95 0:f016e9e8d48b 77 gCOM_MNG_TMTC_THREAD->set_priority(osPriorityAboveNormal);
ee12b079 99:efde3df6cd94 78 #if DEBUG
ee12b079 94:611c066467a1 79 gPC.puts("allocating threads\r\n");
ee12b079 99:efde3df6cd94 80 #endif
shreeshas95 105:5ce0337e7c15 81 // gSCIENCE_THREAD = new Thread(SCIENCE_FUN);
ee12b079 94:611c066467a1 82 // gPC.puts("step one complete\r\n");
shreeshas95 105:5ce0337e7c15 83 // gSCIENCE_THREAD->set_priority(osPriorityBelowNormal);
ee12b079 99:efde3df6cd94 84 #if DEBUG
ee12b079 94:611c066467a1 85 gPC.puts("competed allocating threads\r\n");
ee12b079 99:efde3df6cd94 86 #endif
shreeshas95 104:a50ae79ca36e 87
shreeshas95 0:f016e9e8d48b 88 // *******************INITIALISATIONS END********************
shreeshas95 0:f016e9e8d48b 89
shreeshas95 104:a50ae79ca36e 90 RtosTimer gCDMS_HK_TIMER(FCTN_CDMS_HK_MAIN, osTimerPeriodic);
shreeshas95 105:5ce0337e7c15 91 gCDMS_HK_TIMER.start(5000);
shreeshas95 104:a50ae79ca36e 92
ee12b079 97:717c7908c822 93 /*starting the thread with signal*/
shreeshas95 105:5ce0337e7c15 94 // set_sig();
ee12b079 97:717c7908c822 95
ee12b079 94:611c066467a1 96 /*Calculating Stack used*/
ee12b079 94:611c066467a1 97
ee12b079 96:4ca92f9775e0 98 int state;
ee12b079 96:4ca92f9775e0 99 /*while (true) {
ee12b079 96:4ca92f9775e0 100 Thread::wait(500);
ee12b079 96:4ca92f9775e0 101 state = gSCIENCE_THREAD->get_state();
ee12b079 96:4ca92f9775e0 102 //gPC.printf("Thread state %d\r\n", state);
ee12b079 96:4ca92f9775e0 103 if(state == Thread::Inactive)
ee12b079 96:4ca92f9775e0 104 {delete gSCIENCE_THREAD;
ee12b079 96:4ca92f9775e0 105 break;}
ee12b079 96:4ca92f9775e0 106 }*/
ee12b079 96:4ca92f9775e0 107
ee12b079 96:4ca92f9775e0 108
ee12b079 96:4ca92f9775e0 109
shreeshas95 0:f016e9e8d48b 110 while(true){
ee12b079 97:717c7908c822 111 Thread::wait(osWaitForever);
ee12b079 96:4ca92f9775e0 112 //state = gCOM_MNG_TMTC_THREAD->get_state() + '0';
ee12b079 96:4ca92f9775e0 113 gLEDG = !gLEDG;
ee12b079 96:4ca92f9775e0 114 //gPC.putc(state);
shreeshas95 0:f016e9e8d48b 115 }
shreeshas95 0:f016e9e8d48b 116 }