
Compression code changed and RLY_TMTC pointers managed
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE by
main.cpp@151:e6c7d4f87704, 2016-04-02 (annotated)
- Committer:
- ee12b079
- Date:
- Sat Apr 02 20:31:31 2016 +0000
- Revision:
- 151:e6c7d4f87704
- Parent:
- 136:8074893cd24e
- Child:
- 152:8e4155426581
TC transmission is successful, TM failed
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 | 151:e6c7d4f87704 | 8 | #define SDCARD 0 |
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 | 151:e6c7d4f87704 | 40 | CDMS_I2C_GPIO = 0; |
ee12b079 | 151:e6c7d4f87704 | 41 | |
ee12b079 | 97:717c7908c822 | 42 | //gLEDR = 1; |
ee12b079 | 96:4ca92f9775e0 | 43 | |
shreeshas95 | 0:f016e9e8d48b | 44 | // ******************INITIALISATIONS START****************** |
shreeshas95 | 0:f016e9e8d48b | 45 | // COM RX |
shreeshas95 | 0:f016e9e8d48b | 46 | RX1M.baud(1200); |
shreeshas95 | 0:f016e9e8d48b | 47 | gRX_HEAD_DATA_NODE = new COM_RX_DATA_NODE; |
shreeshas95 | 0:f016e9e8d48b | 48 | gRX_HEAD_DATA_NODE->next_node = NULL; |
shreeshas95 | 0:f016e9e8d48b | 49 | gRX_CURRENT_DATA_NODE = gRX_HEAD_DATA_NODE; |
shreeshas95 | 2:2caf2a9a13aa | 50 | gRX_COUNT = 0; |
shreeshas95 | 2:2caf2a9a13aa | 51 | // gRX_CURRENT_PTR = gRX_CURRENT_DATA_NODE->values; |
shreeshas95 | 0:f016e9e8d48b | 52 | RX1M.attach(&rx_read, Serial::RxIrq); |
shreeshas95 | 0:f016e9e8d48b | 53 | |
ee12b079 | 136:8074893cd24e | 54 | #if I2c |
ee12b079 | 130:d5b53088270b | 55 | //I2C to Payload (depends on pl interrupt design) |
ee12b079 | 132:d4a4461214ad | 56 | PYLD_I2C_Int.rise(&isr_pyldtm); |
ee12b079 | 151:e6c7d4f87704 | 57 | |
ee12b079 | 136:8074893cd24e | 58 | #endif |
ee12b079 | 151:e6c7d4f87704 | 59 | master.frequency(100000); |
shreeshas95 | 0:f016e9e8d48b | 60 | // DEBUG |
ee12b079 | 88:b9beee1a7a3e | 61 | //gPC.puts("welcome to mng_tm_tc\r\n"); |
ee12b079 | 136:8074893cd24e | 62 | gPC.baud(115200); |
shreeshas95 | 0:f016e9e8d48b | 63 | |
shreeshas95 | 0:f016e9e8d48b | 64 | // COMMON SPI |
shreeshas95 | 0:f016e9e8d48b | 65 | spi.format(8,0); |
shreeshas95 | 0:f016e9e8d48b | 66 | spi.frequency(1000000); |
shreeshas95 | 0:f016e9e8d48b | 67 | |
shreeshas95 | 0:f016e9e8d48b | 68 | // SD CARD |
ee12b079 | 86:a26f5f22631d | 69 | cs_sd = 1; |
shreeshas95 | 2:2caf2a9a13aa | 70 | gCS_RTC = 1; |
ee12b079 | 90:df55a5f68331 | 71 | gCS_ADF = 1; |
ee12b079 | 93:4d76de54a699 | 72 | |
ee12b079 | 98:fd99ddc0e0a1 | 73 | //FCTN_CDMS_INIT_RTC();/* rtc initialization*/ |
ee12b079 | 132:d4a4461214ad | 74 | #if SDCARD |
ee12b079 | 113:b8991d9e3b6c | 75 | FCTN_CDMS_SD_INIT();/* sd card initialization*/ |
ee12b079 | 132:d4a4461214ad | 76 | #endif |
shreeshas95 | 0:f016e9e8d48b | 77 | |
ee12b079 | 113:b8991d9e3b6c | 78 | #if DEBUG |
ee12b079 | 113:b8991d9e3b6c | 79 | gPC.puts("welcome to mng_tmtc\r\n"); |
ee12b079 | 113:b8991d9e3b6c | 80 | #endif |
ee12b079 | 113:b8991d9e3b6c | 81 | |
shreeshas95 | 0:f016e9e8d48b | 82 | // COM_MNG_TMTC THREAD |
shreeshas95 | 0:f016e9e8d48b | 83 | gCOM_MNG_TMTC_THREAD = new Thread(COM_MNG_TMTC_FUN); |
shreeshas95 | 0:f016e9e8d48b | 84 | gCOM_MNG_TMTC_THREAD->set_priority(osPriorityAboveNormal); |
ee12b079 | 99:efde3df6cd94 | 85 | #if DEBUG |
ee12b079 | 94:611c066467a1 | 86 | gPC.puts("allocating threads\r\n"); |
ee12b079 | 99:efde3df6cd94 | 87 | #endif |
ee12b079 | 132:d4a4461214ad | 88 | #if SDCARD |
ee12b079 | 113:b8991d9e3b6c | 89 | gSCIENCE_THREAD = new Thread(SCIENCE_FUN); |
ee12b079 | 94:611c066467a1 | 90 | // gPC.puts("step one complete\r\n"); |
ee12b079 | 113:b8991d9e3b6c | 91 | gSCIENCE_THREAD->set_priority(osPriorityBelowNormal); |
ee12b079 | 132:d4a4461214ad | 92 | #endif |
ee12b079 | 126:b7c024b5632d | 93 | |
ee12b079 | 99:efde3df6cd94 | 94 | #if DEBUG |
ee12b079 | 94:611c066467a1 | 95 | gPC.puts("competed allocating threads\r\n"); |
ee12b079 | 99:efde3df6cd94 | 96 | #endif |
ee12b079 | 132:d4a4461214ad | 97 | |
shreeshas95 | 0:f016e9e8d48b | 98 | // *******************INITIALISATIONS END******************** |
shreeshas95 | 0:f016e9e8d48b | 99 | |
ee12b079 | 113:b8991d9e3b6c | 100 | //RtosTimer gCDMS_HK_TIMER(FCTN_CDMS_HK_MAIN, osTimerPeriodic); |
ee12b079 | 113:b8991d9e3b6c | 101 | //gCDMS_HK_TIMER.start(5000); |
shreeshas95 | 104:a50ae79ca36e | 102 | |
ee12b079 | 97:717c7908c822 | 103 | /*starting the thread with signal*/ |
shreeshas95 | 105:5ce0337e7c15 | 104 | // set_sig(); |
ee12b079 | 97:717c7908c822 | 105 | |
ee12b079 | 94:611c066467a1 | 106 | /*Calculating Stack used*/ |
ee12b079 | 94:611c066467a1 | 107 | |
ee12b079 | 96:4ca92f9775e0 | 108 | int state; |
ee12b079 | 96:4ca92f9775e0 | 109 | /*while (true) { |
ee12b079 | 96:4ca92f9775e0 | 110 | Thread::wait(500); |
ee12b079 | 96:4ca92f9775e0 | 111 | state = gSCIENCE_THREAD->get_state(); |
ee12b079 | 96:4ca92f9775e0 | 112 | //gPC.printf("Thread state %d\r\n", state); |
ee12b079 | 96:4ca92f9775e0 | 113 | if(state == Thread::Inactive) |
ee12b079 | 96:4ca92f9775e0 | 114 | {delete gSCIENCE_THREAD; |
ee12b079 | 96:4ca92f9775e0 | 115 | break;} |
ee12b079 | 96:4ca92f9775e0 | 116 | }*/ |
ee12b079 | 136:8074893cd24e | 117 | #if I2c |
ee12b079 | 132:d4a4461214ad | 118 | int i =0 ; |
ee12b079 | 132:d4a4461214ad | 119 | char test[1] ; |
ee12b079 | 132:d4a4461214ad | 120 | test[0] = 7; |
ee12b079 | 132:d4a4461214ad | 121 | while(1) |
ee12b079 | 132:d4a4461214ad | 122 | { |
ee12b079 | 132:d4a4461214ad | 123 | |
ee12b079 | 132:d4a4461214ad | 124 | wait(5); |
ee12b079 | 132:d4a4461214ad | 125 | printf("Wriring to I2C\n"); |
ee12b079 | 132:d4a4461214ad | 126 | master.write(addr_pl|0x00,test,1); |
ee12b079 | 132:d4a4461214ad | 127 | |
ee12b079 | 132:d4a4461214ad | 128 | if(rcv_isr == 1) |
ee12b079 | 132:d4a4461214ad | 129 | { |
ee12b079 | 132:d4a4461214ad | 130 | for(i = 0; i < 134 ; i++) |
ee12b079 | 132:d4a4461214ad | 131 | { |
ee12b079 | 132:d4a4461214ad | 132 | printf("%d\r\n",PL_I2C_DATA[i]); |
ee12b079 | 132:d4a4461214ad | 133 | } |
ee12b079 | 132:d4a4461214ad | 134 | rcv_isr = 0; |
ee12b079 | 132:d4a4461214ad | 135 | } |
ee12b079 | 132:d4a4461214ad | 136 | |
ee12b079 | 132:d4a4461214ad | 137 | } |
ee12b079 | 136:8074893cd24e | 138 | #endif |
shreeshas95 | 0:f016e9e8d48b | 139 | while(true){ |
ee12b079 | 97:717c7908c822 | 140 | Thread::wait(osWaitForever); |
ee12b079 | 96:4ca92f9775e0 | 141 | //state = gCOM_MNG_TMTC_THREAD->get_state() + '0'; |
ee12b079 | 96:4ca92f9775e0 | 142 | gLEDG = !gLEDG; |
ee12b079 | 96:4ca92f9775e0 | 143 | //gPC.putc(state); |
shreeshas95 | 0:f016e9e8d48b | 144 | } |
shreeshas95 | 0:f016e9e8d48b | 145 | } |