cdms_i2c_hardware_test
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of standaloneworkingi2c_cdms by
main.cpp@104:b55559925dc1, 2016-01-29 (annotated)
- Committer:
- shreeshas95
- Date:
- Fri Jan 29 17:36:10 2016 +0000
- Revision:
- 104:b55559925dc1
- Parent:
- 101:bece931236a2
- Child:
- 105:a50ae79ca36e
Integrated HK : YET TO BE TESTED
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shreeshas95 | 8:fcd26c28411d | 1 | // TESTING PUSH PULL IN MAIN CPP |
shreeshas95 | 8:fcd26c28411d | 2 | |
shreeshas95 | 0:f016e9e8d48b | 3 | #include "mbed.h" |
ee12b079 | 95:fd99ddc0e0a1 | 4 | |
ee12b079 | 96:efde3df6cd94 | 5 | #define DEBUG 1 |
ee12b079 | 95:fd99ddc0e0a1 | 6 | |
shreeshas95 | 101:bece931236a2 | 7 | #include "SimpleDMA.h" |
shreeshas95 | 101:bece931236a2 | 8 | #include "dmaSPIslave.h" |
shreeshas95 | 0:f016e9e8d48b | 9 | #include "rtos.h" |
shreeshas95 | 1:a0055b3280c8 | 10 | #include "mbed_debug.h" |
shreeshas95 | 0:f016e9e8d48b | 11 | |
shreeshas95 | 0:f016e9e8d48b | 12 | #include "Structures.h" |
shreeshas95 | 104:b55559925dc1 | 13 | #include "pinconfig.h" |
shreeshas95 | 0:f016e9e8d48b | 14 | #include "DefinitionsAndGlobals.h" |
shreeshas95 | 0:f016e9e8d48b | 15 | #include "crc.h" |
shreeshas95 | 104:b55559925dc1 | 16 | #include "i2c.h" |
shreeshas95 | 1:a0055b3280c8 | 17 | #include "COM_SND_TM_functions.h" |
shreeshas95 | 1:a0055b3280c8 | 18 | #include "COM_SND_TM.h" |
ee12b079 | 96:efde3df6cd94 | 19 | #include "cdms_sd.h" |
shreeshas95 | 104:b55559925dc1 | 20 | #include "CDMS_HK.h" |
ee12b079 | 83:a26f5f22631d | 21 | #include "OBSRS.h" |
shreeshas95 | 1:a0055b3280c8 | 22 | #include "adf.h" |
shreeshas95 | 0:f016e9e8d48b | 23 | #include "COM_RCV_TC.h" |
shreeshas95 | 0:f016e9e8d48b | 24 | #include "COM_MNG_TMTC.h" |
shreeshas95 | 4:104dd82c99b8 | 25 | #include "COM_POWER_ON_TX.h" |
shreeshas95 | 4:104dd82c99b8 | 26 | #include "COM_POWER_OFF_TX.h" |
ee12b079 | 93:4ca92f9775e0 | 27 | #include "Compression.h" |
shreeshas95 | 0:f016e9e8d48b | 28 | #include "ThreadsAndFunctions.h" |
shreeshas95 | 0:f016e9e8d48b | 29 | |
ee12b079 | 94:717c7908c822 | 30 | void set_sig(){gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);} |
shreeshas95 | 0:f016e9e8d48b | 31 | int main() |
shreeshas95 | 0:f016e9e8d48b | 32 | { |
shreeshas95 | 101:bece931236a2 | 33 | #if DEBUG |
shreeshas95 | 101:bece931236a2 | 34 | gPC.puts("welcome to mng_tmtc\r\n"); |
shreeshas95 | 101:bece931236a2 | 35 | #endif |
ee12b079 | 94:717c7908c822 | 36 | //gLEDR = 1; |
ee12b079 | 93:4ca92f9775e0 | 37 | |
shreeshas95 | 0:f016e9e8d48b | 38 | // ******************INITIALISATIONS START****************** |
shreeshas95 | 0:f016e9e8d48b | 39 | // COM RX |
shreeshas95 | 0:f016e9e8d48b | 40 | RX1M.baud(1200); |
shreeshas95 | 0:f016e9e8d48b | 41 | gRX_HEAD_DATA_NODE = new COM_RX_DATA_NODE; |
shreeshas95 | 0:f016e9e8d48b | 42 | gRX_HEAD_DATA_NODE->next_node = NULL; |
shreeshas95 | 0:f016e9e8d48b | 43 | gRX_CURRENT_DATA_NODE = gRX_HEAD_DATA_NODE; |
shreeshas95 | 2:2caf2a9a13aa | 44 | gRX_COUNT = 0; |
shreeshas95 | 2:2caf2a9a13aa | 45 | // gRX_CURRENT_PTR = gRX_CURRENT_DATA_NODE->values; |
shreeshas95 | 0:f016e9e8d48b | 46 | RX1M.attach(&rx_read, Serial::RxIrq); |
shreeshas95 | 0:f016e9e8d48b | 47 | |
shreeshas95 | 0:f016e9e8d48b | 48 | // DEBUG |
ee12b079 | 85:b9beee1a7a3e | 49 | //gPC.puts("welcome to mng_tm_tc\r\n"); |
aniruddhv | 52:0bd68655c651 | 50 | gPC.baud(1200); |
shreeshas95 | 0:f016e9e8d48b | 51 | |
shreeshas95 | 0:f016e9e8d48b | 52 | // COMMON SPI |
shreeshas95 | 0:f016e9e8d48b | 53 | spi.format(8,0); |
shreeshas95 | 0:f016e9e8d48b | 54 | spi.frequency(1000000); |
shreeshas95 | 0:f016e9e8d48b | 55 | |
shreeshas95 | 0:f016e9e8d48b | 56 | // SD CARD |
ee12b079 | 83:a26f5f22631d | 57 | cs_sd = 1; |
shreeshas95 | 2:2caf2a9a13aa | 58 | gCS_RTC = 1; |
ee12b079 | 87:df55a5f68331 | 59 | gCS_ADF = 1; |
ee12b079 | 90:4d76de54a699 | 60 | |
ee12b079 | 95:fd99ddc0e0a1 | 61 | //FCTN_CDMS_INIT_RTC();/* rtc initialization*/ |
ee12b079 | 96:efde3df6cd94 | 62 | FCTN_CDMS_SD_INIT();/* sd card initialization*/ |
ee12b079 | 90:4d76de54a699 | 63 | |
shreeshas95 | 0:f016e9e8d48b | 64 | // initialise_card(); |
shreeshas95 | 0:f016e9e8d48b | 65 | // int result= initialise_card(); |
shreeshas95 | 0:f016e9e8d48b | 66 | // disk_initialize(); |
shreeshas95 | 0:f016e9e8d48b | 67 | |
shreeshas95 | 0:f016e9e8d48b | 68 | // COM_TX |
shreeshas95 | 0:f016e9e8d48b | 69 | // *********************THE TEST |
shreeshas95 | 0:f016e9e8d48b | 70 | // cs_adf=1; |
shreeshas95 | 0:f016e9e8d48b | 71 | // *********************THE TEST |
shreeshas95 | 0:f016e9e8d48b | 72 | |
shreeshas95 | 0:f016e9e8d48b | 73 | // COM_MNG_TMTC THREAD |
shreeshas95 | 0:f016e9e8d48b | 74 | gCOM_MNG_TMTC_THREAD = new Thread(COM_MNG_TMTC_FUN); |
shreeshas95 | 0:f016e9e8d48b | 75 | gCOM_MNG_TMTC_THREAD->set_priority(osPriorityAboveNormal); |
ee12b079 | 96:efde3df6cd94 | 76 | #if DEBUG |
ee12b079 | 91:611c066467a1 | 77 | gPC.puts("allocating threads\r\n"); |
ee12b079 | 96:efde3df6cd94 | 78 | #endif |
ee12b079 | 93:4ca92f9775e0 | 79 | gSCIENCE_THREAD = new Thread(SCIENCE_FUN); |
ee12b079 | 91:611c066467a1 | 80 | // gPC.puts("step one complete\r\n"); |
ee12b079 | 93:4ca92f9775e0 | 81 | gSCIENCE_THREAD->set_priority(osPriorityBelowNormal); |
ee12b079 | 96:efde3df6cd94 | 82 | #if DEBUG |
ee12b079 | 91:611c066467a1 | 83 | gPC.puts("competed allocating threads\r\n"); |
ee12b079 | 96:efde3df6cd94 | 84 | #endif |
shreeshas95 | 0:f016e9e8d48b | 85 | // *******************INITIALISATIONS END******************** |
shreeshas95 | 0:f016e9e8d48b | 86 | |
ee12b079 | 94:717c7908c822 | 87 | /*starting the thread with signal*/ |
ee12b079 | 95:fd99ddc0e0a1 | 88 | set_sig(); |
ee12b079 | 94:717c7908c822 | 89 | |
ee12b079 | 94:717c7908c822 | 90 | |
ee12b079 | 91:611c066467a1 | 91 | /*Calculating Stack used*/ |
ee12b079 | 91:611c066467a1 | 92 | |
ee12b079 | 93:4ca92f9775e0 | 93 | int state; |
ee12b079 | 93:4ca92f9775e0 | 94 | /*while (true) { |
ee12b079 | 93:4ca92f9775e0 | 95 | Thread::wait(500); |
ee12b079 | 93:4ca92f9775e0 | 96 | state = gSCIENCE_THREAD->get_state(); |
ee12b079 | 93:4ca92f9775e0 | 97 | //gPC.printf("Thread state %d\r\n", state); |
ee12b079 | 93:4ca92f9775e0 | 98 | if(state == Thread::Inactive) |
ee12b079 | 93:4ca92f9775e0 | 99 | {delete gSCIENCE_THREAD; |
ee12b079 | 93:4ca92f9775e0 | 100 | break;} |
ee12b079 | 93:4ca92f9775e0 | 101 | }*/ |
ee12b079 | 93:4ca92f9775e0 | 102 | |
ee12b079 | 93:4ca92f9775e0 | 103 | |
ee12b079 | 93:4ca92f9775e0 | 104 | |
shreeshas95 | 0:f016e9e8d48b | 105 | while(true){ |
ee12b079 | 94:717c7908c822 | 106 | Thread::wait(osWaitForever); |
ee12b079 | 93:4ca92f9775e0 | 107 | //state = gCOM_MNG_TMTC_THREAD->get_state() + '0'; |
ee12b079 | 93:4ca92f9775e0 | 108 | gLEDG = !gLEDG; |
ee12b079 | 93:4ca92f9775e0 | 109 | //gPC.putc(state); |
shreeshas95 | 0:f016e9e8d48b | 110 | } |
shreeshas95 | 0:f016e9e8d48b | 111 | } |