Repository for CDMS code
Dependencies: SimpleDMA mbed-rtos mbed eeprom
Fork of COM_MNG_TMTC_SIMPLE by
main.cpp@159:9951e803975f, 2016-04-13 (annotated)
- Committer:
- ee12b079
- Date:
- Wed Apr 13 19:38:09 2016 +0000
- Revision:
- 159:9951e803975f
- Parent:
- 158:6afad8428e82
interfaced with pl, i2c working with double interrupt theory
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 | 159:9951e803975f | 8 | #define SDCARD 0 |
ee12b079 | 136:8074893cd24e | 9 | |
ee12b079 | 98:fd99ddc0e0a1 | 10 | |
shreeshas95 | 101:bece931236a2 | 11 | #include "SimpleDMA.h" |
shreeshas95 | 101:bece931236a2 | 12 | #include "dmaSPIslave.h" |
shreeshas95 | 0:f016e9e8d48b | 13 | #include "rtos.h" |
shreeshas95 | 1:a0055b3280c8 | 14 | #include "mbed_debug.h" |
shreeshas95 | 0:f016e9e8d48b | 15 | |
shreeshas95 | 0:f016e9e8d48b | 16 | #include "Structures.h" |
shreeshas95 | 103:b55559925dc1 | 17 | #include "pinconfig.h" |
shreeshas95 | 0:f016e9e8d48b | 18 | #include "DefinitionsAndGlobals.h" |
shreeshas95 | 0:f016e9e8d48b | 19 | #include "crc.h" |
ee12b079 | 130:d5b53088270b | 20 | #include "i2c.h" |
shreeshas95 | 1:a0055b3280c8 | 21 | #include "COM_SND_TM_functions.h" |
shreeshas95 | 1:a0055b3280c8 | 22 | #include "COM_SND_TM.h" |
ee12b079 | 99:efde3df6cd94 | 23 | #include "cdms_sd.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" |
shreeshas95 | 0:f016e9e8d48b | 28 | #include "COM_MNG_TMTC.h" |
shreeshas95 | 4:104dd82c99b8 | 29 | #include "COM_POWER_ON_TX.h" |
shreeshas95 | 4:104dd82c99b8 | 30 | #include "COM_POWER_OFF_TX.h" |
ee12b079 | 96:4ca92f9775e0 | 31 | #include "Compression.h" |
shreeshas95 | 0:f016e9e8d48b | 32 | #include "ThreadsAndFunctions.h" |
shreeshas95 | 0:f016e9e8d48b | 33 | |
shreeshas95 | 105:5ce0337e7c15 | 34 | //void set_sig(){gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);} |
ee12b079 | 132:d4a4461214ad | 35 | |
ee12b079 | 132:d4a4461214ad | 36 | |
shreeshas95 | 0:f016e9e8d48b | 37 | int main() |
shreeshas95 | 0:f016e9e8d48b | 38 | { |
ee12b079 | 97:717c7908c822 | 39 | //gLEDR = 1; |
ee12b079 | 96:4ca92f9775e0 | 40 | |
shreeshas95 | 0:f016e9e8d48b | 41 | // ******************INITIALISATIONS START****************** |
shreeshas95 | 0:f016e9e8d48b | 42 | // COM RX |
ee12b079 | 158:6afad8428e82 | 43 | RX1M.baud(115200); |
shreeshas95 | 0:f016e9e8d48b | 44 | gRX_HEAD_DATA_NODE = new COM_RX_DATA_NODE; |
shreeshas95 | 0:f016e9e8d48b | 45 | gRX_HEAD_DATA_NODE->next_node = NULL; |
shreeshas95 | 0:f016e9e8d48b | 46 | gRX_CURRENT_DATA_NODE = gRX_HEAD_DATA_NODE; |
shreeshas95 | 2:2caf2a9a13aa | 47 | gRX_COUNT = 0; |
shreeshas95 | 2:2caf2a9a13aa | 48 | // gRX_CURRENT_PTR = gRX_CURRENT_DATA_NODE->values; |
shreeshas95 | 0:f016e9e8d48b | 49 | RX1M.attach(&rx_read, Serial::RxIrq); |
shreeshas95 | 0:f016e9e8d48b | 50 | |
ee12b079 | 130:d5b53088270b | 51 | //I2C to Payload (depends on pl interrupt design) |
ee12b079 | 132:d4a4461214ad | 52 | PYLD_I2C_Int.rise(&isr_pyldtm); |
ee12b079 | 158:6afad8428e82 | 53 | master.frequency(400000); |
ee12b079 | 126:b7c024b5632d | 54 | |
shreeshas95 | 0:f016e9e8d48b | 55 | // DEBUG |
ee12b079 | 88:b9beee1a7a3e | 56 | //gPC.puts("welcome to mng_tm_tc\r\n"); |
ee12b079 | 136:8074893cd24e | 57 | gPC.baud(115200); |
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 | 98:fd99ddc0e0a1 | 68 | //FCTN_CDMS_INIT_RTC();/* rtc initialization*/ |
ee12b079 | 132:d4a4461214ad | 69 | #if SDCARD |
ee12b079 | 113:b8991d9e3b6c | 70 | FCTN_CDMS_SD_INIT();/* sd card initialization*/ |
ee12b079 | 132:d4a4461214ad | 71 | #endif |
shreeshas95 | 0:f016e9e8d48b | 72 | |
ee12b079 | 113:b8991d9e3b6c | 73 | #if DEBUG |
ee12b079 | 113:b8991d9e3b6c | 74 | gPC.puts("welcome to mng_tmtc\r\n"); |
ee12b079 | 113:b8991d9e3b6c | 75 | #endif |
ee12b079 | 113:b8991d9e3b6c | 76 | |
shreeshas95 | 0:f016e9e8d48b | 77 | // COM_MNG_TMTC THREAD |
shreeshas95 | 0:f016e9e8d48b | 78 | gCOM_MNG_TMTC_THREAD = new Thread(COM_MNG_TMTC_FUN); |
shreeshas95 | 0:f016e9e8d48b | 79 | gCOM_MNG_TMTC_THREAD->set_priority(osPriorityAboveNormal); |
ee12b079 | 99:efde3df6cd94 | 80 | #if DEBUG |
ee12b079 | 94:611c066467a1 | 81 | gPC.puts("allocating threads\r\n"); |
ee12b079 | 99:efde3df6cd94 | 82 | #endif |
ee12b079 | 132:d4a4461214ad | 83 | #if SDCARD |
ee12b079 | 113:b8991d9e3b6c | 84 | gSCIENCE_THREAD = new Thread(SCIENCE_FUN); |
ee12b079 | 94:611c066467a1 | 85 | // gPC.puts("step one complete\r\n"); |
ee12b079 | 113:b8991d9e3b6c | 86 | gSCIENCE_THREAD->set_priority(osPriorityBelowNormal); |
ee12b079 | 132:d4a4461214ad | 87 | #endif |
ee12b079 | 126:b7c024b5632d | 88 | |
ee12b079 | 99:efde3df6cd94 | 89 | #if DEBUG |
ee12b079 | 94:611c066467a1 | 90 | gPC.puts("competed allocating threads\r\n"); |
ee12b079 | 99:efde3df6cd94 | 91 | #endif |
ee12b079 | 132:d4a4461214ad | 92 | |
shreeshas95 | 0:f016e9e8d48b | 93 | // *******************INITIALISATIONS END******************** |
shreeshas95 | 0:f016e9e8d48b | 94 | |
ee12b079 | 113:b8991d9e3b6c | 95 | //RtosTimer gCDMS_HK_TIMER(FCTN_CDMS_HK_MAIN, osTimerPeriodic); |
ee12b079 | 113:b8991d9e3b6c | 96 | //gCDMS_HK_TIMER.start(5000); |
shreeshas95 | 104:a50ae79ca36e | 97 | |
ee12b079 | 97:717c7908c822 | 98 | /*starting the thread with signal*/ |
shreeshas95 | 105:5ce0337e7c15 | 99 | // set_sig(); |
ee12b079 | 97:717c7908c822 | 100 | |
ee12b079 | 94:611c066467a1 | 101 | /*Calculating Stack used*/ |
ee12b079 | 94:611c066467a1 | 102 | |
ee12b079 | 96:4ca92f9775e0 | 103 | int state; |
ee12b079 | 96:4ca92f9775e0 | 104 | /*while (true) { |
ee12b079 | 96:4ca92f9775e0 | 105 | Thread::wait(500); |
ee12b079 | 96:4ca92f9775e0 | 106 | state = gSCIENCE_THREAD->get_state(); |
ee12b079 | 96:4ca92f9775e0 | 107 | //gPC.printf("Thread state %d\r\n", state); |
ee12b079 | 96:4ca92f9775e0 | 108 | if(state == Thread::Inactive) |
ee12b079 | 96:4ca92f9775e0 | 109 | {delete gSCIENCE_THREAD; |
ee12b079 | 96:4ca92f9775e0 | 110 | break;} |
ee12b079 | 96:4ca92f9775e0 | 111 | }*/ |
ee12b079 | 158:6afad8428e82 | 112 | |
shreeshas95 | 0:f016e9e8d48b | 113 | while(true){ |
ee12b079 | 97:717c7908c822 | 114 | Thread::wait(osWaitForever); |
ee12b079 | 96:4ca92f9775e0 | 115 | //state = gCOM_MNG_TMTC_THREAD->get_state() + '0'; |
ee12b079 | 96:4ca92f9775e0 | 116 | gLEDG = !gLEDG; |
ee12b079 | 96:4ca92f9775e0 | 117 | //gPC.putc(state); |
shreeshas95 | 0:f016e9e8d48b | 118 | } |
shreeshas95 | 0:f016e9e8d48b | 119 | } |