CDMS code for testing sbc
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE by
main.cpp@109:78f2912e3473, 2016-01-26 (annotated)
- Committer:
- ee12b079
- Date:
- Tue Jan 26 14:15:04 2016 +0000
- Revision:
- 109:78f2912e3473
- Parent:
- 101:bece931236a2
- Child:
- 110:e5091ab345de
DMA working..to be tested thoruohgly;
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 | |
shreeshas95 | 101:bece931236a2 | 5 | #include "SimpleDMA.h" |
shreeshas95 | 101:bece931236a2 | 6 | #include "dmaSPIslave.h" |
shreeshas95 | 0:f016e9e8d48b | 7 | #include "rtos.h" |
shreeshas95 | 1:a0055b3280c8 | 8 | #include "mbed_debug.h" |
shreeshas95 | 0:f016e9e8d48b | 9 | |
shreeshas95 | 0:f016e9e8d48b | 10 | #include "Structures.h" |
shreeshas95 | 0:f016e9e8d48b | 11 | #include "DefinitionsAndGlobals.h" |
shreeshas95 | 0:f016e9e8d48b | 12 | #include "crc.h" |
shreeshas95 | 1:a0055b3280c8 | 13 | #include "COM_SND_TM_functions.h" |
shreeshas95 | 1:a0055b3280c8 | 14 | #include "COM_SND_TM.h" |
ee12b079 | 99:efde3df6cd94 | 15 | #include "cdms_sd.h" |
ee12b079 | 86:a26f5f22631d | 16 | #include "OBSRS.h" |
shreeshas95 | 1:a0055b3280c8 | 17 | #include "adf.h" |
shreeshas95 | 0:f016e9e8d48b | 18 | #include "COM_RCV_TC.h" |
shreeshas95 | 0:f016e9e8d48b | 19 | #include "COM_MNG_TMTC.h" |
shreeshas95 | 4:104dd82c99b8 | 20 | #include "COM_POWER_ON_TX.h" |
shreeshas95 | 4:104dd82c99b8 | 21 | #include "COM_POWER_OFF_TX.h" |
ee12b079 | 96:4ca92f9775e0 | 22 | #include "Compression.h" |
shreeshas95 | 0:f016e9e8d48b | 23 | #include "ThreadsAndFunctions.h" |
shreeshas95 | 0:f016e9e8d48b | 24 | |
shreeshas95 | 0:f016e9e8d48b | 25 | int main() |
shreeshas95 | 0:f016e9e8d48b | 26 | { |
shreeshas95 | 101:bece931236a2 | 27 | #if DEBUG |
shreeshas95 | 101:bece931236a2 | 28 | gPC.puts("welcome to mng_tmtc\r\n"); |
shreeshas95 | 101:bece931236a2 | 29 | #endif |
ee12b079 | 97:717c7908c822 | 30 | //gLEDR = 1; |
ee12b079 | 96:4ca92f9775e0 | 31 | |
shreeshas95 | 0:f016e9e8d48b | 32 | // ******************INITIALISATIONS START****************** |
shreeshas95 | 0:f016e9e8d48b | 33 | // COM RX |
shreeshas95 | 0:f016e9e8d48b | 34 | RX1M.baud(1200); |
shreeshas95 | 0:f016e9e8d48b | 35 | gRX_HEAD_DATA_NODE = new COM_RX_DATA_NODE; |
shreeshas95 | 0:f016e9e8d48b | 36 | gRX_HEAD_DATA_NODE->next_node = NULL; |
shreeshas95 | 0:f016e9e8d48b | 37 | gRX_CURRENT_DATA_NODE = gRX_HEAD_DATA_NODE; |
shreeshas95 | 2:2caf2a9a13aa | 38 | gRX_COUNT = 0; |
shreeshas95 | 2:2caf2a9a13aa | 39 | // gRX_CURRENT_PTR = gRX_CURRENT_DATA_NODE->values; |
shreeshas95 | 0:f016e9e8d48b | 40 | RX1M.attach(&rx_read, Serial::RxIrq); |
shreeshas95 | 0:f016e9e8d48b | 41 | |
shreeshas95 | 0:f016e9e8d48b | 42 | // DEBUG |
ee12b079 | 88:b9beee1a7a3e | 43 | //gPC.puts("welcome to mng_tm_tc\r\n"); |
aniruddhv | 52:0bd68655c651 | 44 | gPC.baud(1200); |
shreeshas95 | 0:f016e9e8d48b | 45 | |
shreeshas95 | 0:f016e9e8d48b | 46 | // COMMON SPI |
shreeshas95 | 0:f016e9e8d48b | 47 | spi.format(8,0); |
shreeshas95 | 0:f016e9e8d48b | 48 | spi.frequency(1000000); |
shreeshas95 | 0:f016e9e8d48b | 49 | |
shreeshas95 | 0:f016e9e8d48b | 50 | // SD CARD |
ee12b079 | 86:a26f5f22631d | 51 | cs_sd = 1; |
shreeshas95 | 2:2caf2a9a13aa | 52 | gCS_RTC = 1; |
ee12b079 | 90:df55a5f68331 | 53 | gCS_ADF = 1; |
ee12b079 | 93:4d76de54a699 | 54 | |
ee12b079 | 98:fd99ddc0e0a1 | 55 | //FCTN_CDMS_INIT_RTC();/* rtc initialization*/ |
ee12b079 | 109:78f2912e3473 | 56 | #if USE_SD |
ee12b079 | 99:efde3df6cd94 | 57 | FCTN_CDMS_SD_INIT();/* sd card initialization*/ |
ee12b079 | 109:78f2912e3473 | 58 | #endif |
ee12b079 | 93:4d76de54a699 | 59 | |
shreeshas95 | 0:f016e9e8d48b | 60 | // initialise_card(); |
shreeshas95 | 0:f016e9e8d48b | 61 | // int result= initialise_card(); |
shreeshas95 | 0:f016e9e8d48b | 62 | // disk_initialize(); |
shreeshas95 | 0:f016e9e8d48b | 63 | |
shreeshas95 | 0:f016e9e8d48b | 64 | // COM_TX |
shreeshas95 | 0:f016e9e8d48b | 65 | // *********************THE TEST |
shreeshas95 | 0:f016e9e8d48b | 66 | // cs_adf=1; |
shreeshas95 | 0:f016e9e8d48b | 67 | // *********************THE TEST |
shreeshas95 | 0:f016e9e8d48b | 68 | |
shreeshas95 | 0:f016e9e8d48b | 69 | // COM_MNG_TMTC THREAD |
shreeshas95 | 0:f016e9e8d48b | 70 | gCOM_MNG_TMTC_THREAD = new Thread(COM_MNG_TMTC_FUN); |
shreeshas95 | 0:f016e9e8d48b | 71 | gCOM_MNG_TMTC_THREAD->set_priority(osPriorityAboveNormal); |
ee12b079 | 99:efde3df6cd94 | 72 | #if DEBUG |
ee12b079 | 94:611c066467a1 | 73 | gPC.puts("allocating threads\r\n"); |
ee12b079 | 99:efde3df6cd94 | 74 | #endif |
ee12b079 | 96:4ca92f9775e0 | 75 | gSCIENCE_THREAD = new Thread(SCIENCE_FUN); |
ee12b079 | 94:611c066467a1 | 76 | // gPC.puts("step one complete\r\n"); |
ee12b079 | 96:4ca92f9775e0 | 77 | gSCIENCE_THREAD->set_priority(osPriorityBelowNormal); |
ee12b079 | 99:efde3df6cd94 | 78 | #if DEBUG |
ee12b079 | 94:611c066467a1 | 79 | gPC.puts("competed allocating threads\r\n"); |
ee12b079 | 99:efde3df6cd94 | 80 | #endif |
shreeshas95 | 0:f016e9e8d48b | 81 | // *******************INITIALISATIONS END******************** |
shreeshas95 | 0:f016e9e8d48b | 82 | |
ee12b079 | 94:611c066467a1 | 83 | /*Calculating Stack used*/ |
ee12b079 | 94:611c066467a1 | 84 | |
ee12b079 | 96:4ca92f9775e0 | 85 | int state; |
ee12b079 | 96:4ca92f9775e0 | 86 | /*while (true) { |
ee12b079 | 96:4ca92f9775e0 | 87 | Thread::wait(500); |
ee12b079 | 96:4ca92f9775e0 | 88 | state = gSCIENCE_THREAD->get_state(); |
ee12b079 | 96:4ca92f9775e0 | 89 | //gPC.printf("Thread state %d\r\n", state); |
ee12b079 | 96:4ca92f9775e0 | 90 | if(state == Thread::Inactive) |
ee12b079 | 96:4ca92f9775e0 | 91 | {delete gSCIENCE_THREAD; |
ee12b079 | 96:4ca92f9775e0 | 92 | break;} |
ee12b079 | 96:4ca92f9775e0 | 93 | }*/ |
ee12b079 | 96:4ca92f9775e0 | 94 | |
ee12b079 | 96:4ca92f9775e0 | 95 | |
ee12b079 | 96:4ca92f9775e0 | 96 | |
shreeshas95 | 0:f016e9e8d48b | 97 | while(true){ |
ee12b079 | 97:717c7908c822 | 98 | Thread::wait(osWaitForever); |
ee12b079 | 96:4ca92f9775e0 | 99 | //state = gCOM_MNG_TMTC_THREAD->get_state() + '0'; |
ee12b079 | 96:4ca92f9775e0 | 100 | gLEDG = !gLEDG; |
ee12b079 | 96:4ca92f9775e0 | 101 | //gPC.putc(state); |
shreeshas95 | 0:f016e9e8d48b | 102 | } |
shreeshas95 | 0:f016e9e8d48b | 103 | } |