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