cdms_i2c_hardware_test

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of standaloneworkingi2c_cdms by Team Fox

Committer:
shreeshas95
Date:
Tue Jan 26 13:15:01 2016 +0000
Revision:
101:bece931236a2
Parent:
96:efde3df6cd94
Child:
102:78f2912e3473
Child:
104:b55559925dc1
Made changes in science thread, and globals for DMA

Who changed what in which revision?

UserRevisionLine numberNew 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 0:f016e9e8d48b 13 #include "DefinitionsAndGlobals.h"
shreeshas95 0:f016e9e8d48b 14 #include "crc.h"
shreeshas95 1:a0055b3280c8 15 #include "COM_SND_TM_functions.h"
shreeshas95 1:a0055b3280c8 16 #include "COM_SND_TM.h"
ee12b079 96:efde3df6cd94 17 #include "cdms_sd.h"
ee12b079 83:a26f5f22631d 18 #include "OBSRS.h"
shreeshas95 1:a0055b3280c8 19 #include "adf.h"
shreeshas95 0:f016e9e8d48b 20 #include "COM_RCV_TC.h"
shreeshas95 0:f016e9e8d48b 21 #include "COM_MNG_TMTC.h"
shreeshas95 4:104dd82c99b8 22 #include "COM_POWER_ON_TX.h"
shreeshas95 4:104dd82c99b8 23 #include "COM_POWER_OFF_TX.h"
ee12b079 93:4ca92f9775e0 24 #include "Compression.h"
shreeshas95 0:f016e9e8d48b 25 #include "ThreadsAndFunctions.h"
shreeshas95 0:f016e9e8d48b 26
ee12b079 94:717c7908c822 27 void set_sig(){gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);}
shreeshas95 0:f016e9e8d48b 28 int main()
shreeshas95 0:f016e9e8d48b 29 {
shreeshas95 101:bece931236a2 30 #if DEBUG
shreeshas95 101:bece931236a2 31 gPC.puts("welcome to mng_tmtc\r\n");
shreeshas95 101:bece931236a2 32 #endif
ee12b079 94:717c7908c822 33 //gLEDR = 1;
ee12b079 93:4ca92f9775e0 34
shreeshas95 0:f016e9e8d48b 35 // ******************INITIALISATIONS START******************
shreeshas95 0:f016e9e8d48b 36 // COM RX
shreeshas95 0:f016e9e8d48b 37 RX1M.baud(1200);
shreeshas95 0:f016e9e8d48b 38 gRX_HEAD_DATA_NODE = new COM_RX_DATA_NODE;
shreeshas95 0:f016e9e8d48b 39 gRX_HEAD_DATA_NODE->next_node = NULL;
shreeshas95 0:f016e9e8d48b 40 gRX_CURRENT_DATA_NODE = gRX_HEAD_DATA_NODE;
shreeshas95 2:2caf2a9a13aa 41 gRX_COUNT = 0;
shreeshas95 2:2caf2a9a13aa 42 // gRX_CURRENT_PTR = gRX_CURRENT_DATA_NODE->values;
shreeshas95 0:f016e9e8d48b 43 RX1M.attach(&rx_read, Serial::RxIrq);
shreeshas95 0:f016e9e8d48b 44
shreeshas95 0:f016e9e8d48b 45 // DEBUG
ee12b079 85:b9beee1a7a3e 46 //gPC.puts("welcome to mng_tm_tc\r\n");
aniruddhv 52:0bd68655c651 47 gPC.baud(1200);
shreeshas95 0:f016e9e8d48b 48
shreeshas95 0:f016e9e8d48b 49 // COMMON SPI
shreeshas95 0:f016e9e8d48b 50 spi.format(8,0);
shreeshas95 0:f016e9e8d48b 51 spi.frequency(1000000);
shreeshas95 0:f016e9e8d48b 52
shreeshas95 0:f016e9e8d48b 53 // SD CARD
ee12b079 83:a26f5f22631d 54 cs_sd = 1;
shreeshas95 2:2caf2a9a13aa 55 gCS_RTC = 1;
ee12b079 87:df55a5f68331 56 gCS_ADF = 1;
ee12b079 90:4d76de54a699 57
ee12b079 95:fd99ddc0e0a1 58 //FCTN_CDMS_INIT_RTC();/* rtc initialization*/
ee12b079 96:efde3df6cd94 59 FCTN_CDMS_SD_INIT();/* sd card initialization*/
ee12b079 90:4d76de54a699 60
shreeshas95 0:f016e9e8d48b 61 // initialise_card();
shreeshas95 0:f016e9e8d48b 62 // int result= initialise_card();
shreeshas95 0:f016e9e8d48b 63 // disk_initialize();
shreeshas95 0:f016e9e8d48b 64
shreeshas95 0:f016e9e8d48b 65 // COM_TX
shreeshas95 0:f016e9e8d48b 66 // *********************THE TEST
shreeshas95 0:f016e9e8d48b 67 // cs_adf=1;
shreeshas95 0:f016e9e8d48b 68 // *********************THE TEST
shreeshas95 0:f016e9e8d48b 69
shreeshas95 0:f016e9e8d48b 70 // COM_MNG_TMTC THREAD
shreeshas95 0:f016e9e8d48b 71 gCOM_MNG_TMTC_THREAD = new Thread(COM_MNG_TMTC_FUN);
shreeshas95 0:f016e9e8d48b 72 gCOM_MNG_TMTC_THREAD->set_priority(osPriorityAboveNormal);
ee12b079 96:efde3df6cd94 73 #if DEBUG
ee12b079 91:611c066467a1 74 gPC.puts("allocating threads\r\n");
ee12b079 96:efde3df6cd94 75 #endif
ee12b079 93:4ca92f9775e0 76 gSCIENCE_THREAD = new Thread(SCIENCE_FUN);
ee12b079 91:611c066467a1 77 // gPC.puts("step one complete\r\n");
ee12b079 93:4ca92f9775e0 78 gSCIENCE_THREAD->set_priority(osPriorityBelowNormal);
ee12b079 96:efde3df6cd94 79 #if DEBUG
ee12b079 91:611c066467a1 80 gPC.puts("competed allocating threads\r\n");
ee12b079 96:efde3df6cd94 81 #endif
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 }