working version
Dependencies: mbed mbed-rtos SimpleDMA FreescaleIAP eeprom
Fork of CDMS_CODE_FM_28JAN2017 by
Diff: main.cpp
- Revision:
- 357:f3d48d62e00e
- Parent:
- 356:197c93dc2012
--- a/main.cpp Sat Feb 10 09:06:26 2018 +0000 +++ b/main.cpp Sun Apr 03 15:35:53 2022 +0000 @@ -1,7 +1,7 @@ // TESTING PUSH PULL IN MAIN CPP #include "mbed.h" -//#include "eeprom.h" +#include "eeprom.h" #define DEBUG 1 @@ -15,8 +15,8 @@ #include "DefinitionsAndGlobals.h" #include "crc.h" #include "i2c.h" -//#include "EEPROM.h" -#include "Flash.h" +#include "EEPROM.h" +//#include "Flash.h" #include "COM_SND_TM_functions.h" #include "cdms_rtc.h" #include "COM_SND_TM.h" @@ -61,7 +61,7 @@ gRX_COUNT = 0; RX1M.attach(&rx_read, Serial::RxIrq); - gPC.baud(1200);//changed for bypassing COM + gPC.baud(1200);//changed for bypassing COM //Base_tm *tm_ptr = NULL; @@ -71,10 +71,13 @@ // COMMON SPI spi.format(8,0); spi.frequency(500000); - FLASH_INI(); + + //FLASH_INI(); + INIT_EEPROM(); //changed Mar 2018 + RESET_WATCHDOG(); if ((BAE_STATUS & 0x03) == 0x03) {SW_OFF_BAE();} - uint8_t sd_stat_temp = SD_STATUS & 0x03; //Joel + uint8_t sd_stat_temp = SD_STATUS & 0x03; SD_CARD_fromuC_ENA3 = 0; SD_CARD_fromISO_ENA4 = 0; SD_SW_EN_DS = 0; @@ -89,16 +92,45 @@ gCS_RTC = 1; gCS_ADF = 1; - //CDMS_RTC_DISABLE = 1; + FCTN_CDMS_SD_INIT();/* sd card initialization*/ + + CDMS_RTC_DISABLE = 1; + //RTC_INIT_STATUS = test_buffer if((CDMS_RTC_DISABLE & 0x01) == 1) { CDMS_RTC_ON(); } if((RTC_INIT_STATUS & 0x01) != 1) //Joel - { + { FCTN_CDMS_INIT_RTC();/* rtc initialization*/ - } - FCTN_CDMS_SD_INIT();/* sd card initialization*/ + + //INIT_40mins + + /*BAE_SW_EN_DS = 0; //DISABLE BAE + SD_SW_EN_DS = 0; //DISABLE SD + uint64_t ini_time = FCTN_CDMS_RD_RTC(); + uint32_t T_check_ini = (((ini_time >> 7)& 0x00000FC0)>>6); + uint32_t T_diff = T_check_ini; + + expired=0; + Ticker Sftw_Timer; + gPC.printf("\rGoing to start Ticker\n"); + Sftw_Timer.attach(&int_acq1, 2500.0); + + while (T_check_ini - T_diff < T_INI) + { + RESET_WATCHDOG(); + wait_ms(10000); + ini_time = FCTN_CDMS_RD_RTC(); + T_check_ini = (((ini_time >> 7)& 0x00000FC0)>>6); + gPC.printf("ini_time %d",T_check_ini); + if (expired == 1) + break; + } + BAE_SW_EN_DS = 1; //ENABLE BAE + SD_SW_EN_DS = 1; //ENABLE SD*/ + } + if(sd_stat_temp == DEVICE_DISABLED) { SD_STATUS = sd_stat_temp; @@ -109,19 +141,27 @@ { SD_STATUS = sd_stat_temp; } - // INIT_EEPROM(); // added by samp + CDMS_RESET_COUNTER+=1; - FCTN_CDMS_WR_FLASH(7,CDMS_RESET_COUNTER); + WRITE_TO_EEPROM(7,CDMS_RESET_COUNTER); gPC.printf("\n\r%d\n",CDMS_RESET_COUNTER); TIME_LATEST_CDSMS_RESET = FCTN_CDMS_RD_RTC() >> 7; - FCTN_CDMS_WR_FLASH(8,TIME_LATEST_CDSMS_RESET); + //FCTN_CDMS_WR_FLASH(8,TIME_LATEST_CDSMS_RESET); + WRITE_TO_EEPROM(8,TIME_LATEST_CDSMS_RESET); // gPC.printf("%d \n", READ_FROM_EERPOM(8)); - //uint8_t test[512]; + uint8_t test[512]; - //for(int i =0; i<512; i++) - // test[i] = 0; - //disk_write(test,80000); + for(int i =0; i<512; i++) + test[i] = 0; + test[2] = 0xF; + test[3] = 0xA0; + test[10] = 0xF; + test[11] = 0xA0; + test[18] = 0xF; + test[19] = 0xA0; + + disk_write(test,80000); SD_MNG_SECT = SD_LIB_BLK_CURRENT; @@ -145,8 +185,8 @@ gCOM_MNG_TMTC_THREAD->set_priority(osPriorityRealtime); gHK_THREAD = new Thread(FCTN_CDMS_HK_MAIN); - // gHK_THREAD->set_priority(osPriorityHigh); - gHK_THREAD->set_priority(osPriorityNormal); + //gHK_THREAD->set_priority(osPriorityHigh); + gHK_THREAD->set_priority(osPriorityNormal); gSCIENCE_THREAD = new Thread(SCIENCE_FUN); gSCIENCE_THREAD->set_priority(osPriorityHigh); @@ -158,18 +198,17 @@ master.frequency(400000); HK_counter = new RtosTimer(hk_isr, osTimerPeriodic,(void * )NULL); - gHK_THREAD->signal_set(HK_SIGNAL); - HK_counter->stop(); - wait_ms(0.1); - HK_counter->start(10000); - // HK_counter->start(10000); - - sys_reset_cdms_timer = new RtosTimer(sys_pwr_reset, osTimerPeriodic, (void * )NULL); - sys_reset_cdms_timer->start(cdms_reset_timeout); - + //gHK_THREAD->signal_set(HK_SIGNAL); + HK_counter->stop(); + wait_ms(0.1); + HK_counter->start(10000); +// HK_counter->start(10000); +// //PL_wo_dma = new RtosTimer(payload_isr_fun_dma, osTimerPeriodic,(void * )NULL); + //gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL); + //PL_wo_dma->stop(); + //wait_ms(0.1); //PL_wo_dma->start(6000); - //gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL); /*Timeout flipper; flipper.attach(BAE_TC,31);*/