Repository for CDMS code

Dependencies:   SimpleDMA mbed-rtos mbed eeprom

Fork of COM_MNG_TMTC_SIMPLE by Shreesha S

Committer:
ee12b079
Date:
Mon Apr 04 10:44:44 2016 +0000
Revision:
152:8e4155426581
Parent:
151:e6c7d4f87704
Child:
157:e808cdb56239
Testing i2c for bae : TC_TM, i2c in main();

Who changed what in which revision?

UserRevisionLine numberNew 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 130:d5b53088270b 7 #define DEBUG 1
ee12b079 151:e6c7d4f87704 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 151:e6c7d4f87704 40 CDMS_I2C_GPIO = 0;
ee12b079 151:e6c7d4f87704 41
ee12b079 97:717c7908c822 42 //gLEDR = 1;
ee12b079 96:4ca92f9775e0 43
shreeshas95 0:f016e9e8d48b 44 // ******************INITIALISATIONS START******************
shreeshas95 0:f016e9e8d48b 45 // COM RX
shreeshas95 0:f016e9e8d48b 46 RX1M.baud(1200);
shreeshas95 0:f016e9e8d48b 47 gRX_HEAD_DATA_NODE = new COM_RX_DATA_NODE;
shreeshas95 0:f016e9e8d48b 48 gRX_HEAD_DATA_NODE->next_node = NULL;
shreeshas95 0:f016e9e8d48b 49 gRX_CURRENT_DATA_NODE = gRX_HEAD_DATA_NODE;
shreeshas95 2:2caf2a9a13aa 50 gRX_COUNT = 0;
shreeshas95 2:2caf2a9a13aa 51 // gRX_CURRENT_PTR = gRX_CURRENT_DATA_NODE->values;
shreeshas95 0:f016e9e8d48b 52 RX1M.attach(&rx_read, Serial::RxIrq);
shreeshas95 0:f016e9e8d48b 53
ee12b079 136:8074893cd24e 54 #if I2c
ee12b079 130:d5b53088270b 55 //I2C to Payload (depends on pl interrupt design)
ee12b079 132:d4a4461214ad 56 PYLD_I2C_Int.rise(&isr_pyldtm);
ee12b079 151:e6c7d4f87704 57
ee12b079 136:8074893cd24e 58 #endif
ee12b079 151:e6c7d4f87704 59 master.frequency(100000);
shreeshas95 0:f016e9e8d48b 60 // DEBUG
ee12b079 88:b9beee1a7a3e 61 //gPC.puts("welcome to mng_tm_tc\r\n");
ee12b079 136:8074893cd24e 62 gPC.baud(115200);
shreeshas95 0:f016e9e8d48b 63
shreeshas95 0:f016e9e8d48b 64 // COMMON SPI
ee12b079 152:8e4155426581 65 // spi.format(8,0);
ee12b079 152:8e4155426581 66 // spi.frequency(1000000);
ee12b079 152:8e4155426581 67 //
ee12b079 152:8e4155426581 68 // // SD CARD
ee12b079 152:8e4155426581 69 // cs_sd = 1;
ee12b079 152:8e4155426581 70 // gCS_RTC = 1;
ee12b079 152:8e4155426581 71 // gCS_ADF = 1;
ee12b079 152:8e4155426581 72 //
ee12b079 152:8e4155426581 73 // //FCTN_CDMS_INIT_RTC();/* rtc initialization*/
ee12b079 152:8e4155426581 74 // #if SDCARD
ee12b079 152:8e4155426581 75 // FCTN_CDMS_SD_INIT();/* sd card initialization*/
ee12b079 152:8e4155426581 76 // #endif
ee12b079 152:8e4155426581 77 //
ee12b079 152:8e4155426581 78 // #if DEBUG
ee12b079 152:8e4155426581 79 // gPC.puts("welcome to mng_tmtc\r\n");
ee12b079 152:8e4155426581 80 // #endif
ee12b079 152:8e4155426581 81 //
ee12b079 152:8e4155426581 82 // // COM_MNG_TMTC THREAD
ee12b079 152:8e4155426581 83 // gCOM_MNG_TMTC_THREAD = new Thread(COM_MNG_TMTC_FUN);
ee12b079 152:8e4155426581 84 // gCOM_MNG_TMTC_THREAD->set_priority(osPriorityAboveNormal);
ee12b079 152:8e4155426581 85 // #if DEBUG
ee12b079 152:8e4155426581 86 // gPC.puts("allocating threads\r\n");
ee12b079 152:8e4155426581 87 // #endif
ee12b079 152:8e4155426581 88 // #if SDCARD
ee12b079 152:8e4155426581 89 // gSCIENCE_THREAD = new Thread(SCIENCE_FUN);
ee12b079 152:8e4155426581 90 // // gPC.puts("step one complete\r\n");
ee12b079 152:8e4155426581 91 // gSCIENCE_THREAD->set_priority(osPriorityBelowNormal);
ee12b079 152:8e4155426581 92 // #endif
ee12b079 152:8e4155426581 93 //
ee12b079 152:8e4155426581 94 // #if DEBUG
ee12b079 152:8e4155426581 95 // gPC.puts("competed allocating threads\r\n");
ee12b079 152:8e4155426581 96 // #endif
ee12b079 152:8e4155426581 97 //
shreeshas95 0:f016e9e8d48b 98 // *******************INITIALISATIONS END********************
shreeshas95 0:f016e9e8d48b 99
ee12b079 113:b8991d9e3b6c 100 //RtosTimer gCDMS_HK_TIMER(FCTN_CDMS_HK_MAIN, osTimerPeriodic);
ee12b079 113:b8991d9e3b6c 101 //gCDMS_HK_TIMER.start(5000);
ee12b079 152:8e4155426581 102
ee12b079 152:8e4155426581 103 uint8_t TC[11] = {0x1, 0x60, 0x81, 0x21, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1d, 0xd9};
ee12b079 152:8e4155426581 104 uint8_t TM[134];
ee12b079 152:8e4155426581 105 FCTN_I2C_WRITE((char*)TC,TC_SHORT_SIZE);
ee12b079 152:8e4155426581 106
ee12b079 152:8e4155426581 107 wait(1); //TimeOut instead of wait
ee12b079 152:8e4155426581 108 if(BAE_I2C_GPIO == 1)
ee12b079 152:8e4155426581 109 {
ee12b079 152:8e4155426581 110
ee12b079 152:8e4155426581 111 //printf("receiving...\r\n");
ee12b079 152:8e4155426581 112 FCTN_I2C_READ((char*)TM,TM_LONG_SIZE);
ee12b079 152:8e4155426581 113 //printf("%s", tm_pointer->TM_string);
ee12b079 152:8e4155426581 114 }
ee12b079 152:8e4155426581 115 else
ee12b079 152:8e4155426581 116 {
ee12b079 152:8e4155426581 117 gPC.printf("bae_INTR NOT HIGH");
ee12b079 152:8e4155426581 118 }
ee12b079 152:8e4155426581 119
shreeshas95 0:f016e9e8d48b 120 while(true){
ee12b079 97:717c7908c822 121 Thread::wait(osWaitForever);
ee12b079 96:4ca92f9775e0 122 //state = gCOM_MNG_TMTC_THREAD->get_state() + '0';
ee12b079 96:4ca92f9775e0 123 gLEDG = !gLEDG;
ee12b079 96:4ca92f9775e0 124 //gPC.putc(state);
shreeshas95 0:f016e9e8d48b 125 }
shreeshas95 0:f016e9e8d48b 126 }