working version

Dependencies:   mbed mbed-rtos SimpleDMA FreescaleIAP eeprom

Fork of CDMS_CODE_FM_28JAN2017 by samp Srinivasan

Committer:
samp1234
Date:
Tue Feb 21 06:30:56 2017 +0000
Revision:
353:e1803e801e20
Parent:
352:022c513aee03
Child:
354:eb6c863756a8
with all final changes

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"
chaithanyarss 351:a89a46894ec0 4 #include "eeprom.h"
ee12b079 98:fd99ddc0e0a1 5
ee12b079 99:efde3df6cd94 6 #define DEBUG 1
ee12b079 98:fd99ddc0e0a1 7
shreeshas95 101:bece931236a2 8 #include "SimpleDMA.h"
shreeshas95 101:bece931236a2 9 #include "dmaSPIslave.h"
shreeshas95 0:f016e9e8d48b 10 #include "rtos.h"
shreeshas95 1:a0055b3280c8 11 #include "mbed_debug.h"
aniruddhv 262:752c8689944a 12 void rx_read();
shreeshas95 0:f016e9e8d48b 13 #include "Structures.h"
shreeshas95 103:b55559925dc1 14 #include "pinconfig.h"
shreeshas95 0:f016e9e8d48b 15 #include "DefinitionsAndGlobals.h"
shreeshas95 0:f016e9e8d48b 16 #include "crc.h"
shreeshas95 103:b55559925dc1 17 #include "i2c.h"
chaithanyarss 351:a89a46894ec0 18 #include "EEPROM.h"
shreeshas95 1:a0055b3280c8 19 #include "COM_SND_TM_functions.h"
ee12b079 210:f4acf895b598 20 #include "cdms_rtc.h"
ee12b079 300:609c3e4240c9 21 #include "COM_SND_TM.h"
ee12b079 99:efde3df6cd94 22 #include "cdms_sd.h"
krishanprajapat 117:bfdc807f3d3c 23 #include "common_functions.h"
ee12b079 210:f4acf895b598 24 #include "RESET_functions.h"
ee12b079 289:9bd62b69874c 25 #include "CDMS_PL.h"
ee12b079 210:f4acf895b598 26 #include "CDMS_HK.h"
shreeshas95 1:a0055b3280c8 27 #include "adf.h"
shreeshas95 0:f016e9e8d48b 28 #include "COM_RCV_TC.h"
ee12b079 210:f4acf895b598 29 #include "FMS_all.h"
chaithanyarss 261:1e54415b34d3 30 #include "Compression.h"
shreeshas95 0:f016e9e8d48b 31 #include "COM_MNG_TMTC.h"
aniruddhv 262:752c8689944a 32 #include "COM_POWER_OFF_TX.h"
shreeshas95 4:104dd82c99b8 33 #include "COM_POWER_ON_TX.h"
aniruddhv 262:752c8689944a 34 #include "OBSRS.h"
shreeshas95 0:f016e9e8d48b 35 #include "ThreadsAndFunctions.h"
samp1234 352:022c513aee03 36 //#include "TEST_PL.h"
shreeshas95 0:f016e9e8d48b 37
shreeshas95 0:f016e9e8d48b 38 int main()
prasanthbj05 267:783c248a6207 39 {
samp1234 352:022c513aee03 40
ee12b079 285:fe33b39dd267 41 //RELAY SWITCHING
ee12b079 284:5bfd48ce169d 42
ee12b079 285:fe33b39dd267 43
ee12b079 285:fe33b39dd267 44 RF_SW_CNTRL_BCN = 1;
ee12b079 285:fe33b39dd267 45 Thread::wait(25);
ee12b079 285:fe33b39dd267 46 RF_SW_CNTRL_BCN = 0;
ee12b079 284:5bfd48ce169d 47 PYLD_DFF = 1;
ee12b079 284:5bfd48ce169d 48
ee12b079 284:5bfd48ce169d 49 for(int i= 0; i< 10 ; i++)
ee12b079 284:5bfd48ce169d 50 {PYLD_DFF_CLK = !PYLD_DFF_CLK;
ee12b079 284:5bfd48ce169d 51 wait_us(10);}
ee12b079 284:5bfd48ce169d 52
ee12b079 185:3b3cd96a7811 53 CDMS_I2C_GPIO = 0;
ee12b079 210:f4acf895b598 54 PL_I2C_GPIO = 0;
ee12b079 162:48fda0b8d573 55
shreeshas95 0:f016e9e8d48b 56 RX1M.baud(1200);
shreeshas95 0:f016e9e8d48b 57 gRX_HEAD_DATA_NODE = new COM_RX_DATA_NODE;
shreeshas95 0:f016e9e8d48b 58 gRX_HEAD_DATA_NODE->next_node = NULL;
shreeshas95 0:f016e9e8d48b 59 gRX_CURRENT_DATA_NODE = gRX_HEAD_DATA_NODE;
shreeshas95 2:2caf2a9a13aa 60 gRX_COUNT = 0;
shreeshas95 0:f016e9e8d48b 61 RX1M.attach(&rx_read, Serial::RxIrq);
shreeshas95 0:f016e9e8d48b 62
samp1234 311:af5ab655ba00 63 gPC.baud(1200);//changed for bypassing COM
samp1234 311:af5ab655ba00 64
shreeshas95 0:f016e9e8d48b 65
ee12b079 288:aa93d6652381 66 //Base_tm *tm_ptr = NULL;
ee12b079 288:aa93d6652381 67 //SET_BCN_STANDBY(tm_ptr);
ee12b079 288:aa93d6652381 68 //gPC.puts("set Bcn off\r\n");
ee12b079 285:fe33b39dd267 69
shreeshas95 0:f016e9e8d48b 70 // COMMON SPI
shreeshas95 0:f016e9e8d48b 71 spi.format(8,0);
chaithanyarss 261:1e54415b34d3 72 spi.frequency(500000);
samp1234 352:022c513aee03 73 SD_CARD_fromuC_ENA3 = 0;
samp1234 352:022c513aee03 74 SD_CARD_fromISO_ENA4 = 0;
spacelab 308:7c3872365d58 75 SD_SW_EN_DS = 0;
spacelab 308:7c3872365d58 76 wait(1);
samp1234 352:022c513aee03 77 SD_CARD_fromuC_ENA3 = 1;
samp1234 352:022c513aee03 78 SD_CARD_fromISO_ENA4 = 1;
spacelab 308:7c3872365d58 79 SD_SW_EN_DS = 1;
samp1234 352:022c513aee03 80
spacelab 308:7c3872365d58 81 wait(1);
shreeshas95 0:f016e9e8d48b 82 // SD CARD
ee12b079 86:a26f5f22631d 83 cs_sd = 1;
shreeshas95 2:2caf2a9a13aa 84 gCS_RTC = 1;
ee12b079 90:df55a5f68331 85 gCS_ADF = 1;
ee12b079 93:4d76de54a699 86
samp1234 353:e1803e801e20 87 // CDMS_RTC_DISABLE = 1;
chaithanyarss 324:c0a5228cc666 88
ee12b079 274:5c02ff05f3da 89 FCTN_CDMS_INIT_RTC();/* rtc initialization*/
spacelab 308:7c3872365d58 90 FCTN_CDMS_SD_INIT();/* sd card initialization*/
samp1234 352:022c513aee03 91 INIT_EEPROM(); // added by samp
samp1234 352:022c513aee03 92
chaithanyarss 324:c0a5228cc666 93 CDMS_RESET_COUNTER++;
chaithanyarss 351:a89a46894ec0 94 WRITE_TO_EEPROM(7,CDMS_RESET_COUNTER);
chaithanyarss 324:c0a5228cc666 95 TIME_LATEST_CDSMS_RESET = FCTN_CDMS_RD_RTC() >> 7;
chaithanyarss 351:a89a46894ec0 96 WRITE_TO_EEPROM(8,TIME_LATEST_CDSMS_RESET);
samp1234 353:e1803e801e20 97
chaithanyarss 333:cddef120cae3 98 uint8_t test[512];
samp1234 352:022c513aee03 99
chaithanyarss 331:1943be3fd178 100 for(int i =0; i<512; i++)
chaithanyarss 331:1943be3fd178 101 test[i] = 0;
samp1234 352:022c513aee03 102 disk_write(test,8000);
samp1234 353:e1803e801e20 103
chaithanyarss 327:5a967a66c10f 104 //SD_MNG_SECT = SD_LIB_BLK_CURRENT;
chaithanyarss 326:e424f70b86c0 105 FCTN_SD_MNGR();
chaithanyarss 324:c0a5228cc666 106
ee12b079 113:b8991d9e3b6c 107 #if DEBUG
ee12b079 113:b8991d9e3b6c 108 gPC.puts("welcome to mng_tmtc\r\n");
ee12b079 113:b8991d9e3b6c 109 #endif
ee12b079 113:b8991d9e3b6c 110
ee12b079 246:565458eefd94 111 #if DEBUG
ee12b079 246:565458eefd94 112 gPC.puts("allocating threads\r\n");
ee12b079 246:565458eefd94 113 #endif
ee12b079 185:3b3cd96a7811 114
ee12b079 338:d63eb331a67d 115 //DMA iobject decalaration
ee12b079 338:d63eb331a67d 116 gPAY_SPI = new dmaSPISlave(PAY_SPI_MOSI, PAY_SPI_MISO, PAY_SPI_CLK, PAY_SPI_CS);
ee12b079 338:d63eb331a67d 117
aniruddhv 264:f7d8f9f361e3 118 // COM_POWER_ON_TX();
aniruddhv 264:f7d8f9f361e3 119
shreeshas95 0:f016e9e8d48b 120 // COM_MNG_TMTC THREAD
ee12b079 268:ded5306a1fd1 121 gCOM_MNG_TMTC_THREAD = new Thread(COM_MNG_TMTC_FUN);
spacelab 308:7c3872365d58 122 gCOM_MNG_TMTC_THREAD->set_priority(osPriorityRealtime);
ee12b079 246:565458eefd94 123
ee12b079 246:565458eefd94 124 gHK_THREAD = new Thread(FCTN_CDMS_HK_MAIN);
samp1234 346:204497974293 125 // gHK_THREAD->set_priority(osPriorityHigh);
samp1234 346:204497974293 126 gHK_THREAD->set_priority(osPriorityNormal);
ee12b079 246:565458eefd94 127
ee12b079 113:b8991d9e3b6c 128 gSCIENCE_THREAD = new Thread(SCIENCE_FUN);
spacelab 308:7c3872365d58 129 gSCIENCE_THREAD->set_priority(osPriorityHigh);
ee12b079 246:565458eefd94 130
ee12b079 99:efde3df6cd94 131 #if DEBUG
prasanthbj05 266:ae588e75cfa4 132 gPC.puts("completed allocating threads\r\n");
prasanthbj05 267:783c248a6207 133 #endif
ee12b079 246:565458eefd94 134
ee12b079 170:286ef9dad36a 135 master.frequency(400000);
ee12b079 246:565458eefd94 136
ee12b079 271:72529b247333 137 HK_counter = new RtosTimer(hk_isr, osTimerPeriodic,(void * )NULL);
spacelab 308:7c3872365d58 138 gHK_THREAD->signal_set(HK_SIGNAL);
samp1234 352:022c513aee03 139 HK_counter->stop();
samp1234 352:022c513aee03 140 wait_ms(0.1);
samp1234 346:204497974293 141 HK_counter->start(10000);
samp1234 352:022c513aee03 142 // HK_counter->start(10000);
ee12b079 253:fd6696d91e74 143
aniruddhv 262:752c8689944a 144 sys_reset_cdms_timer = new RtosTimer(sys_pwr_reset, osTimerPeriodic, (void * )NULL);
ee12b079 268:ded5306a1fd1 145 sys_reset_cdms_timer->start(cdms_reset_timeout);
aniruddhv 262:752c8689944a 146
chaithanyarss 303:b49b486a7107 147 //PL_wo_dma = new RtosTimer(payload_isr_fun_dma, osTimerPeriodic,(void * )NULL);
chaithanyarss 303:b49b486a7107 148 //PL_wo_dma->start(6000);
ee12b079 300:609c3e4240c9 149 //gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);
ee12b079 203:424308159a56 150
chaithanyarss 261:1e54415b34d3 151 /*Timeout flipper;
chaithanyarss 261:1e54415b34d3 152 flipper.attach(BAE_TC,31);*/
ee12b079 203:424308159a56 153
ee12b079 232:b1458c1e9199 154 /*while(1){
chaithanyarss 228:335da5b0d3e4 155 gPC.printf("PL_TC sending\r\n");
ee12b079 199:9f03d6ca94c9 156
chaithanyarss 228:335da5b0d3e4 157 Base_tm *tm_ptr = new Long_tm;
chaithanyarss 228:335da5b0d3e4 158 PL_TC(tm_ptr);
chaithanyarss 228:335da5b0d3e4 159 wait(1);
chaithanyarss 228:335da5b0d3e4 160 }
ee12b079 232:b1458c1e9199 161 gPC.printf("PL_TC sent");*/
chaithanyarss 290:3159ff1081a2 162 //test_pl_main();
shreeshas95 0:f016e9e8d48b 163 while(true){
ee12b079 97:717c7908c822 164 Thread::wait(osWaitForever);
ee12b079 96:4ca92f9775e0 165 gLEDG = !gLEDG;
shreeshas95 0:f016e9e8d48b 166 }
shreeshas95 0:f016e9e8d48b 167 }