
Compression code changed and RLY_TMTC pointers managed
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE by
main.cpp@158:6afad8428e82, 2016-04-13 (annotated)
- Committer:
- ee12b079
- Date:
- Wed Apr 13 14:25:48 2016 +0000
- Revision:
- 158:6afad8428e82
- Parent:
- 136:8074893cd24e
- Child:
- 159:9951e803975f
Testing with PL
Who changed what in which revision?
User | Revision | Line number | New 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 | 132:d4a4461214ad | 5 | uint8_t rcv_isr = 0; // flag for interrupt |
ee12b079 | 132:d4a4461214ad | 6 | |
ee12b079 | 130:d5b53088270b | 7 | #define DEBUG 1 |
ee12b079 | 136:8074893cd24e | 8 | #define SDCARD 1 |
ee12b079 | 136:8074893cd24e | 9 | #define I2C_PL 0 |
ee12b079 | 136:8074893cd24e | 10 | |
ee12b079 | 98:fd99ddc0e0a1 | 11 | |
shreeshas95 | 101:bece931236a2 | 12 | #include "SimpleDMA.h" |
shreeshas95 | 101:bece931236a2 | 13 | #include "dmaSPIslave.h" |
shreeshas95 | 0:f016e9e8d48b | 14 | #include "rtos.h" |
shreeshas95 | 1:a0055b3280c8 | 15 | #include "mbed_debug.h" |
shreeshas95 | 0:f016e9e8d48b | 16 | |
shreeshas95 | 0:f016e9e8d48b | 17 | #include "Structures.h" |
shreeshas95 | 103:b55559925dc1 | 18 | #include "pinconfig.h" |
shreeshas95 | 0:f016e9e8d48b | 19 | #include "DefinitionsAndGlobals.h" |
shreeshas95 | 0:f016e9e8d48b | 20 | #include "crc.h" |
ee12b079 | 130:d5b53088270b | 21 | #include "i2c.h" |
shreeshas95 | 1:a0055b3280c8 | 22 | #include "COM_SND_TM_functions.h" |
shreeshas95 | 1:a0055b3280c8 | 23 | #include "COM_SND_TM.h" |
ee12b079 | 99:efde3df6cd94 | 24 | #include "cdms_sd.h" |
ee12b079 | 114:9fb55057b13f | 25 | //#include "CDMS_HK.h" |
ee12b079 | 86:a26f5f22631d | 26 | #include "OBSRS.h" |
shreeshas95 | 1:a0055b3280c8 | 27 | #include "adf.h" |
shreeshas95 | 0:f016e9e8d48b | 28 | #include "COM_RCV_TC.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);} |
ee12b079 | 132:d4a4461214ad | 36 | |
ee12b079 | 132:d4a4461214ad | 37 | |
shreeshas95 | 0:f016e9e8d48b | 38 | int main() |
shreeshas95 | 0:f016e9e8d48b | 39 | { |
ee12b079 | 97:717c7908c822 | 40 | //gLEDR = 1; |
ee12b079 | 96:4ca92f9775e0 | 41 | |
shreeshas95 | 0:f016e9e8d48b | 42 | // ******************INITIALISATIONS START****************** |
shreeshas95 | 0:f016e9e8d48b | 43 | // COM RX |
ee12b079 | 158:6afad8428e82 | 44 | RX1M.baud(115200); |
shreeshas95 | 0:f016e9e8d48b | 45 | gRX_HEAD_DATA_NODE = new COM_RX_DATA_NODE; |
shreeshas95 | 0:f016e9e8d48b | 46 | gRX_HEAD_DATA_NODE->next_node = NULL; |
shreeshas95 | 0:f016e9e8d48b | 47 | gRX_CURRENT_DATA_NODE = gRX_HEAD_DATA_NODE; |
shreeshas95 | 2:2caf2a9a13aa | 48 | gRX_COUNT = 0; |
shreeshas95 | 2:2caf2a9a13aa | 49 | // gRX_CURRENT_PTR = gRX_CURRENT_DATA_NODE->values; |
shreeshas95 | 0:f016e9e8d48b | 50 | RX1M.attach(&rx_read, Serial::RxIrq); |
shreeshas95 | 0:f016e9e8d48b | 51 | |
ee12b079 | 130:d5b53088270b | 52 | //I2C to Payload (depends on pl interrupt design) |
ee12b079 | 132:d4a4461214ad | 53 | PYLD_I2C_Int.rise(&isr_pyldtm); |
ee12b079 | 158:6afad8428e82 | 54 | master.frequency(400000); |
ee12b079 | 126:b7c024b5632d | 55 | |
shreeshas95 | 0:f016e9e8d48b | 56 | // DEBUG |
ee12b079 | 88:b9beee1a7a3e | 57 | //gPC.puts("welcome to mng_tm_tc\r\n"); |
ee12b079 | 136:8074893cd24e | 58 | gPC.baud(115200); |
shreeshas95 | 0:f016e9e8d48b | 59 | |
shreeshas95 | 0:f016e9e8d48b | 60 | // COMMON SPI |
shreeshas95 | 0:f016e9e8d48b | 61 | spi.format(8,0); |
shreeshas95 | 0:f016e9e8d48b | 62 | spi.frequency(1000000); |
shreeshas95 | 0:f016e9e8d48b | 63 | |
shreeshas95 | 0:f016e9e8d48b | 64 | // SD CARD |
ee12b079 | 86:a26f5f22631d | 65 | cs_sd = 1; |
shreeshas95 | 2:2caf2a9a13aa | 66 | gCS_RTC = 1; |
ee12b079 | 90:df55a5f68331 | 67 | gCS_ADF = 1; |
ee12b079 | 93:4d76de54a699 | 68 | |
ee12b079 | 98:fd99ddc0e0a1 | 69 | //FCTN_CDMS_INIT_RTC();/* rtc initialization*/ |
ee12b079 | 132:d4a4461214ad | 70 | #if SDCARD |
ee12b079 | 113:b8991d9e3b6c | 71 | FCTN_CDMS_SD_INIT();/* sd card initialization*/ |
ee12b079 | 132:d4a4461214ad | 72 | #endif |
shreeshas95 | 0:f016e9e8d48b | 73 | |
ee12b079 | 113:b8991d9e3b6c | 74 | #if DEBUG |
ee12b079 | 113:b8991d9e3b6c | 75 | gPC.puts("welcome to mng_tmtc\r\n"); |
ee12b079 | 113:b8991d9e3b6c | 76 | #endif |
ee12b079 | 113:b8991d9e3b6c | 77 | |
shreeshas95 | 0:f016e9e8d48b | 78 | // COM_MNG_TMTC THREAD |
shreeshas95 | 0:f016e9e8d48b | 79 | gCOM_MNG_TMTC_THREAD = new Thread(COM_MNG_TMTC_FUN); |
shreeshas95 | 0:f016e9e8d48b | 80 | gCOM_MNG_TMTC_THREAD->set_priority(osPriorityAboveNormal); |
ee12b079 | 99:efde3df6cd94 | 81 | #if DEBUG |
ee12b079 | 94:611c066467a1 | 82 | gPC.puts("allocating threads\r\n"); |
ee12b079 | 99:efde3df6cd94 | 83 | #endif |
ee12b079 | 132:d4a4461214ad | 84 | #if SDCARD |
ee12b079 | 113:b8991d9e3b6c | 85 | gSCIENCE_THREAD = new Thread(SCIENCE_FUN); |
ee12b079 | 94:611c066467a1 | 86 | // gPC.puts("step one complete\r\n"); |
ee12b079 | 113:b8991d9e3b6c | 87 | gSCIENCE_THREAD->set_priority(osPriorityBelowNormal); |
ee12b079 | 132:d4a4461214ad | 88 | #endif |
ee12b079 | 126:b7c024b5632d | 89 | |
ee12b079 | 99:efde3df6cd94 | 90 | #if DEBUG |
ee12b079 | 94:611c066467a1 | 91 | gPC.puts("competed allocating threads\r\n"); |
ee12b079 | 99:efde3df6cd94 | 92 | #endif |
ee12b079 | 132:d4a4461214ad | 93 | |
shreeshas95 | 0:f016e9e8d48b | 94 | // *******************INITIALISATIONS END******************** |
shreeshas95 | 0:f016e9e8d48b | 95 | |
ee12b079 | 113:b8991d9e3b6c | 96 | //RtosTimer gCDMS_HK_TIMER(FCTN_CDMS_HK_MAIN, osTimerPeriodic); |
ee12b079 | 113:b8991d9e3b6c | 97 | //gCDMS_HK_TIMER.start(5000); |
shreeshas95 | 104:a50ae79ca36e | 98 | |
ee12b079 | 97:717c7908c822 | 99 | /*starting the thread with signal*/ |
shreeshas95 | 105:5ce0337e7c15 | 100 | // set_sig(); |
ee12b079 | 97:717c7908c822 | 101 | |
ee12b079 | 94:611c066467a1 | 102 | /*Calculating Stack used*/ |
ee12b079 | 94:611c066467a1 | 103 | |
ee12b079 | 96:4ca92f9775e0 | 104 | int state; |
ee12b079 | 96:4ca92f9775e0 | 105 | /*while (true) { |
ee12b079 | 96:4ca92f9775e0 | 106 | Thread::wait(500); |
ee12b079 | 96:4ca92f9775e0 | 107 | state = gSCIENCE_THREAD->get_state(); |
ee12b079 | 96:4ca92f9775e0 | 108 | //gPC.printf("Thread state %d\r\n", state); |
ee12b079 | 96:4ca92f9775e0 | 109 | if(state == Thread::Inactive) |
ee12b079 | 96:4ca92f9775e0 | 110 | {delete gSCIENCE_THREAD; |
ee12b079 | 96:4ca92f9775e0 | 111 | break;} |
ee12b079 | 96:4ca92f9775e0 | 112 | }*/ |
ee12b079 | 158:6afad8428e82 | 113 | |
shreeshas95 | 0:f016e9e8d48b | 114 | while(true){ |
ee12b079 | 97:717c7908c822 | 115 | Thread::wait(osWaitForever); |
ee12b079 | 96:4ca92f9775e0 | 116 | //state = gCOM_MNG_TMTC_THREAD->get_state() + '0'; |
ee12b079 | 96:4ca92f9775e0 | 117 | gLEDG = !gLEDG; |
ee12b079 | 96:4ca92f9775e0 | 118 | //gPC.putc(state); |
shreeshas95 | 0:f016e9e8d48b | 119 | } |
shreeshas95 | 0:f016e9e8d48b | 120 | } |