Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed mbed-rtos SimpleDMA FreescaleIAP eeprom
Fork of CDMS_CODE_FM_28JAN2017 by
main.cpp
00001 // TESTING PUSH PULL IN MAIN CPP 00002 00003 #include "mbed.h" 00004 #include "eeprom.h" 00005 00006 #define DEBUG 1 00007 00008 #include "SimpleDMA.h" 00009 #include "dmaSPIslave.h" 00010 #include "rtos.h" 00011 #include "mbed_debug.h" 00012 void rx_read(); 00013 #include "Structures.h" 00014 #include "pinconfig.h" 00015 #include "DefinitionsAndGlobals.h" 00016 #include "crc.h" 00017 #include "i2c.h" 00018 #include "EEPROM.h" 00019 //#include "Flash.h" 00020 #include "COM_SND_TM_functions.h" 00021 #include "cdms_rtc.h" 00022 #include "COM_SND_TM.h" 00023 #include "cdms_sd.h" 00024 #include "common_functions.h" 00025 #include "RESET_functions.h" 00026 #include "CDMS_PL.h" 00027 #include "CDMS_HK.h" 00028 #include "adf.h" 00029 #include "COM_RCV_TC.h" 00030 #include "FMS_all.h" 00031 #include "Compression.h" 00032 #include "COM_MNG_TMTC.h" 00033 #include "COM_POWER_OFF_TX.h" 00034 #include "COM_POWER_ON_TX.h" 00035 #include "OBSRS.h" 00036 #include "ThreadsAndFunctions.h" 00037 //#include "TEST_PL.h" 00038 00039 int main() 00040 { 00041 00042 //RELAY SWITCHING 00043 00044 00045 RF_SW_CNTRL_BCN = 1; 00046 Thread::wait(25); 00047 RF_SW_CNTRL_BCN = 0; 00048 PYLD_DFF = 1; 00049 00050 for(int i= 0; i< 10 ; i++) 00051 {PYLD_DFF_CLK = !PYLD_DFF_CLK; 00052 wait_us(10);} 00053 00054 CDMS_I2C_GPIO = 0; 00055 PL_I2C_GPIO = 0; 00056 00057 RX1M.baud(1200); 00058 gRX_HEAD_DATA_NODE = new COM_RX_DATA_NODE; 00059 gRX_HEAD_DATA_NODE->next_node = NULL; 00060 gRX_CURRENT_DATA_NODE = gRX_HEAD_DATA_NODE; 00061 gRX_COUNT = 0; 00062 RX1M.attach(&rx_read, Serial::RxIrq); 00063 00064 gPC.baud(1200);//changed for bypassing COM 00065 00066 00067 //Base_tm *tm_ptr = NULL; 00068 //SET_BCN_STANDBY(tm_ptr); 00069 //gPC.puts("set Bcn off\r\n"); 00070 00071 // COMMON SPI 00072 spi.format(8,0); 00073 spi.frequency(500000); 00074 00075 //FLASH_INI(); 00076 INIT_EEPROM(); //changed Mar 2018 00077 RESET_WATCHDOG(); 00078 if ((BAE_STATUS & 0x03) == 0x03) 00079 {SW_OFF_BAE();} 00080 uint8_t sd_stat_temp = SD_STATUS & 0x03; 00081 SD_CARD_fromuC_ENA3 = 0; 00082 SD_CARD_fromISO_ENA4 = 0; 00083 SD_SW_EN_DS = 0; 00084 wait(1); 00085 SD_CARD_fromuC_ENA3 = 1; 00086 SD_CARD_fromISO_ENA4 = 1; 00087 SD_SW_EN_DS = 1; 00088 00089 wait(1); 00090 // SD CARD 00091 cs_sd = 1; 00092 gCS_RTC = 1; 00093 gCS_ADF = 1; 00094 00095 FCTN_CDMS_SD_INIT();/* sd card initialization*/ 00096 00097 CDMS_RTC_DISABLE = 1; 00098 //RTC_INIT_STATUS = test_buffer 00099 if((CDMS_RTC_DISABLE & 0x01) == 1) 00100 { 00101 CDMS_RTC_ON(); 00102 } 00103 if((RTC_INIT_STATUS & 0x01) != 1) //Joel 00104 { 00105 FCTN_CDMS_INIT_RTC();/* rtc initialization*/ 00106 00107 //INIT_40mins 00108 00109 /*BAE_SW_EN_DS = 0; //DISABLE BAE 00110 SD_SW_EN_DS = 0; //DISABLE SD 00111 uint64_t ini_time = FCTN_CDMS_RD_RTC(); 00112 uint32_t T_check_ini = (((ini_time >> 7)& 0x00000FC0)>>6); 00113 uint32_t T_diff = T_check_ini; 00114 00115 expired=0; 00116 Ticker Sftw_Timer; 00117 gPC.printf("\rGoing to start Ticker\n"); 00118 Sftw_Timer.attach(&int_acq1, 2500.0); 00119 00120 while (T_check_ini - T_diff < T_INI) 00121 { 00122 RESET_WATCHDOG(); 00123 wait_ms(10000); 00124 ini_time = FCTN_CDMS_RD_RTC(); 00125 T_check_ini = (((ini_time >> 7)& 0x00000FC0)>>6); 00126 gPC.printf("ini_time %d",T_check_ini); 00127 if (expired == 1) 00128 break; 00129 } 00130 BAE_SW_EN_DS = 1; //ENABLE BAE 00131 SD_SW_EN_DS = 1; //ENABLE SD*/ 00132 } 00133 00134 if(sd_stat_temp == DEVICE_DISABLED) 00135 { 00136 SD_STATUS = sd_stat_temp; 00137 // SD_STATUS = 0x03; 00138 SD_SW_EN_DS = 0; 00139 } 00140 else if(sd_stat_temp == DEVICE_OC_FAULT) 00141 { 00142 SD_STATUS = sd_stat_temp; 00143 } 00144 00145 CDMS_RESET_COUNTER+=1; 00146 WRITE_TO_EEPROM(7,CDMS_RESET_COUNTER); 00147 gPC.printf("\n\r%d\n",CDMS_RESET_COUNTER); 00148 TIME_LATEST_CDSMS_RESET = FCTN_CDMS_RD_RTC() >> 7; 00149 //FCTN_CDMS_WR_FLASH(8,TIME_LATEST_CDSMS_RESET); 00150 WRITE_TO_EEPROM(8,TIME_LATEST_CDSMS_RESET); 00151 00152 // gPC.printf("%d \n", READ_FROM_EERPOM(8)); 00153 uint8_t test[512]; 00154 00155 for(int i =0; i<512; i++) 00156 test[i] = 0; 00157 test[2] = 0xF; 00158 test[3] = 0xA0; 00159 test[10] = 0xF; 00160 test[11] = 0xA0; 00161 test[18] = 0xF; 00162 test[19] = 0xA0; 00163 00164 disk_write(test,80000); 00165 00166 SD_MNG_SECT = SD_LIB_BLK_CURRENT; 00167 00168 FCTN_SD_MNGR(); 00169 00170 #if DEBUG 00171 gPC.puts("welcome to mng_tmtc\r\n"); 00172 #endif 00173 00174 #if DEBUG 00175 gPC.puts("allocating threads\r\n"); 00176 #endif 00177 00178 //DMA iobject decalaration 00179 gPAY_SPI = new dmaSPISlave(PAY_SPI_MOSI, PAY_SPI_MISO, PAY_SPI_CLK, PAY_SPI_CS); 00180 00181 // COM_POWER_ON_TX(); 00182 00183 // COM_MNG_TMTC THREAD 00184 gCOM_MNG_TMTC_THREAD = new Thread(COM_MNG_TMTC_FUN); 00185 gCOM_MNG_TMTC_THREAD->set_priority(osPriorityRealtime); 00186 00187 gHK_THREAD = new Thread(FCTN_CDMS_HK_MAIN); 00188 //gHK_THREAD->set_priority(osPriorityHigh); 00189 gHK_THREAD->set_priority(osPriorityNormal); 00190 00191 gSCIENCE_THREAD = new Thread(SCIENCE_FUN); 00192 gSCIENCE_THREAD->set_priority(osPriorityHigh); 00193 00194 #if DEBUG 00195 gPC.puts("completed allocating threads\r\n"); 00196 #endif 00197 00198 master.frequency(400000); 00199 00200 HK_counter = new RtosTimer(hk_isr, osTimerPeriodic,(void * )NULL); 00201 //gHK_THREAD->signal_set(HK_SIGNAL); 00202 HK_counter->stop(); 00203 wait_ms(0.1); 00204 HK_counter->start(10000); 00205 // HK_counter->start(10000); 00206 // 00207 //PL_wo_dma = new RtosTimer(payload_isr_fun_dma, osTimerPeriodic,(void * )NULL); 00208 //gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL); 00209 //PL_wo_dma->stop(); 00210 //wait_ms(0.1); 00211 //PL_wo_dma->start(6000); 00212 00213 /*Timeout flipper; 00214 flipper.attach(BAE_TC,31);*/ 00215 00216 /*while(1){ 00217 gPC.printf("PL_TC sending\r\n"); 00218 00219 Base_tm *tm_ptr = new Long_tm; 00220 PL_TC(tm_ptr); 00221 wait(1); 00222 } 00223 gPC.printf("PL_TC sent");*/ 00224 //test_pl_main(); 00225 while(true){ 00226 Thread::wait(osWaitForever); 00227 gLEDG = !gLEDG; 00228 } 00229 }
Generated on Tue Jul 12 2022 15:50:06 by
