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