working version

Dependencies:   mbed mbed-rtos SimpleDMA FreescaleIAP eeprom

Fork of CDMS_CODE_FM_28JAN2017 by samp Srinivasan

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