
Compression code changed and RLY_TMTC pointers managed
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE by
main.cpp@186:eb19a02f83d6, 2016-06-17 (annotated)
- Committer:
- ee12b079
- Date:
- Fri Jun 17 13:41:43 2016 +0000
- Revision:
- 186:eb19a02f83d6
- Parent:
- 185:3b3cd96a7811
Testing spi ..
Who changed what in which revision?
User | Revision | Line number | New 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 | |
shreeshas95 | 105:5ce0337e7c15 | 36 | //void set_sig(){gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);} |
shreeshas95 | 0:f016e9e8d48b | 37 | int main() |
shreeshas95 | 0:f016e9e8d48b | 38 | { |
ee12b079 | 162:48fda0b8d573 | 39 | |
ee12b079 | 185:3b3cd96a7811 | 40 | CDMS_I2C_GPIO = 0; |
ee12b079 | 185:3b3cd96a7811 | 41 | PYLD_I2C_GPIO = 0; |
ee12b079 | 97:717c7908c822 | 42 | //gLEDR = 1; |
ee12b079 | 96:4ca92f9775e0 | 43 | |
shreeshas95 | 0:f016e9e8d48b | 44 | // ******************INITIALISATIONS START****************** |
shreeshas95 | 0:f016e9e8d48b | 45 | // COM RX |
ee12b079 | 161:a63672bf4423 | 46 | |
shreeshas95 | 0:f016e9e8d48b | 47 | RX1M.baud(1200); |
shreeshas95 | 0:f016e9e8d48b | 48 | gRX_HEAD_DATA_NODE = new COM_RX_DATA_NODE; |
shreeshas95 | 0:f016e9e8d48b | 49 | gRX_HEAD_DATA_NODE->next_node = NULL; |
shreeshas95 | 0:f016e9e8d48b | 50 | gRX_CURRENT_DATA_NODE = gRX_HEAD_DATA_NODE; |
shreeshas95 | 2:2caf2a9a13aa | 51 | gRX_COUNT = 0; |
shreeshas95 | 2:2caf2a9a13aa | 52 | // gRX_CURRENT_PTR = gRX_CURRENT_DATA_NODE->values; |
shreeshas95 | 0:f016e9e8d48b | 53 | RX1M.attach(&rx_read, Serial::RxIrq); |
shreeshas95 | 0:f016e9e8d48b | 54 | |
shreeshas95 | 0:f016e9e8d48b | 55 | // DEBUG |
ee12b079 | 88:b9beee1a7a3e | 56 | //gPC.puts("welcome to mng_tm_tc\r\n"); |
ee12b079 | 164:be3b4b760d0c | 57 | gPC.baud(1200); |
shreeshas95 | 0:f016e9e8d48b | 58 | |
shreeshas95 | 0:f016e9e8d48b | 59 | // COMMON SPI |
shreeshas95 | 0:f016e9e8d48b | 60 | spi.format(8,0); |
shreeshas95 | 0:f016e9e8d48b | 61 | spi.frequency(1000000); |
shreeshas95 | 0:f016e9e8d48b | 62 | |
shreeshas95 | 0:f016e9e8d48b | 63 | // SD CARD |
ee12b079 | 86:a26f5f22631d | 64 | cs_sd = 1; |
shreeshas95 | 2:2caf2a9a13aa | 65 | gCS_RTC = 1; |
ee12b079 | 90:df55a5f68331 | 66 | gCS_ADF = 1; |
ee12b079 | 93:4d76de54a699 | 67 | |
ee12b079 | 115:2e1144a41d76 | 68 | FCTN_CDMS_INIT_RTC();/* rtc initialization*/ |
ee12b079 | 113:b8991d9e3b6c | 69 | FCTN_CDMS_SD_INIT();/* sd card initialization*/ |
shreeshas95 | 0:f016e9e8d48b | 70 | |
ee12b079 | 113:b8991d9e3b6c | 71 | #if DEBUG |
ee12b079 | 113:b8991d9e3b6c | 72 | gPC.puts("welcome to mng_tmtc\r\n"); |
ee12b079 | 113:b8991d9e3b6c | 73 | #endif |
ee12b079 | 113:b8991d9e3b6c | 74 | |
ee12b079 | 185:3b3cd96a7811 | 75 | |
ee12b079 | 185:3b3cd96a7811 | 76 | |
shreeshas95 | 0:f016e9e8d48b | 77 | // COM_MNG_TMTC THREAD |
shreeshas95 | 0:f016e9e8d48b | 78 | gCOM_MNG_TMTC_THREAD = new Thread(COM_MNG_TMTC_FUN); |
ee12b079 | 162:48fda0b8d573 | 79 | gCOM_MNG_TMTC_THREAD->set_priority(osPriorityHigh); |
ee12b079 | 99:efde3df6cd94 | 80 | #if DEBUG |
ee12b079 | 94:611c066467a1 | 81 | gPC.puts("allocating threads\r\n"); |
ee12b079 | 99:efde3df6cd94 | 82 | #endif |
ee12b079 | 113:b8991d9e3b6c | 83 | gSCIENCE_THREAD = new Thread(SCIENCE_FUN); |
ee12b079 | 94:611c066467a1 | 84 | // gPC.puts("step one complete\r\n"); |
ee12b079 | 162:48fda0b8d573 | 85 | gSCIENCE_THREAD->set_priority(osPriorityAboveNormal); |
ee12b079 | 99:efde3df6cd94 | 86 | #if DEBUG |
ee12b079 | 94:611c066467a1 | 87 | gPC.puts("competed allocating threads\r\n"); |
ee12b079 | 99:efde3df6cd94 | 88 | #endif |
shreeshas95 | 104:a50ae79ca36e | 89 | |
ee12b079 | 170:286ef9dad36a | 90 | |
ee12b079 | 170:286ef9dad36a | 91 | master.frequency(400000); |
ee12b079 | 170:286ef9dad36a | 92 | |
ee12b079 | 186:eb19a02f83d6 | 93 | Base_tm *tm_ptr = new Short_tm; |
ee12b079 | 186:eb19a02f83d6 | 94 | INIT_SCIENCE_PL(tm_ptr); |
ee12b079 | 186:eb19a02f83d6 | 95 | /*DELETE THE TM AFTER USE*/\ |
ee12b079 | 186:eb19a02f83d6 | 96 | Base_tm *del_tm = tm_ptr;\ |
ee12b079 | 186:eb19a02f83d6 | 97 | int overCount = 0;\ |
ee12b079 | 186:eb19a02f83d6 | 98 | while( del_tm != NULL ){\ |
ee12b079 | 186:eb19a02f83d6 | 99 | if( (overCount < TM_OVERFLOW_CONSTANT) ){\ |
ee12b079 | 186:eb19a02f83d6 | 100 | Base_tm *temp = del_tm->next_TM;\ |
ee12b079 | 186:eb19a02f83d6 | 101 | delete del_tm;\ |
ee12b079 | 186:eb19a02f83d6 | 102 | del_tm = temp;\ |
ee12b079 | 186:eb19a02f83d6 | 103 | ++overCount;\ |
ee12b079 | 186:eb19a02f83d6 | 104 | }\ |
ee12b079 | 186:eb19a02f83d6 | 105 | else{\ |
ee12b079 | 186:eb19a02f83d6 | 106 | break;\ |
ee12b079 | 186:eb19a02f83d6 | 107 | }\ |
ee12b079 | 186:eb19a02f83d6 | 108 | }\ |
ee12b079 | 186:eb19a02f83d6 | 109 | |
ee12b079 | 186:eb19a02f83d6 | 110 | gPC.puts("waiting for PL data\r\n"); |
ee12b079 | 186:eb19a02f83d6 | 111 | |
shreeshas95 | 0:f016e9e8d48b | 112 | // *******************INITIALISATIONS END******************** |
shreeshas95 | 0:f016e9e8d48b | 113 | |
ee12b079 | 113:b8991d9e3b6c | 114 | //RtosTimer gCDMS_HK_TIMER(FCTN_CDMS_HK_MAIN, osTimerPeriodic); |
ee12b079 | 113:b8991d9e3b6c | 115 | //gCDMS_HK_TIMER.start(5000); |
shreeshas95 | 104:a50ae79ca36e | 116 | |
ee12b079 | 97:717c7908c822 | 117 | /*starting the thread with signal*/ |
shreeshas95 | 105:5ce0337e7c15 | 118 | // set_sig(); |
ee12b079 | 97:717c7908c822 | 119 | |
ee12b079 | 94:611c066467a1 | 120 | /*Calculating Stack used*/ |
ee12b079 | 94:611c066467a1 | 121 | |
ee12b079 | 96:4ca92f9775e0 | 122 | int state; |
ee12b079 | 96:4ca92f9775e0 | 123 | /*while (true) { |
ee12b079 | 96:4ca92f9775e0 | 124 | Thread::wait(500); |
ee12b079 | 96:4ca92f9775e0 | 125 | state = gSCIENCE_THREAD->get_state(); |
ee12b079 | 96:4ca92f9775e0 | 126 | //gPC.printf("Thread state %d\r\n", state); |
ee12b079 | 96:4ca92f9775e0 | 127 | if(state == Thread::Inactive) |
ee12b079 | 96:4ca92f9775e0 | 128 | {delete gSCIENCE_THREAD; |
ee12b079 | 96:4ca92f9775e0 | 129 | break;} |
ee12b079 | 96:4ca92f9775e0 | 130 | }*/ |
ee12b079 | 96:4ca92f9775e0 | 131 | |
ee12b079 | 96:4ca92f9775e0 | 132 | |
ee12b079 | 96:4ca92f9775e0 | 133 | |
shreeshas95 | 0:f016e9e8d48b | 134 | while(true){ |
ee12b079 | 97:717c7908c822 | 135 | Thread::wait(osWaitForever); |
ee12b079 | 96:4ca92f9775e0 | 136 | //state = gCOM_MNG_TMTC_THREAD->get_state() + '0'; |
ee12b079 | 96:4ca92f9775e0 | 137 | gLEDG = !gLEDG; |
ee12b079 | 96:4ca92f9775e0 | 138 | //gPC.putc(state); |
shreeshas95 | 0:f016e9e8d48b | 139 | } |
shreeshas95 | 0:f016e9e8d48b | 140 | } |