Compression code changed and RLY_TMTC pointers managed

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE by shubham c

Files at this revision

API Documentation at this revision

Comitter:
chaithanyarss
Date:
Mon Jul 04 13:53:20 2016 +0000
Parent:
220:2aeab83212e6
Commit message:
All thread added, testing TCs

Changed in this revision

CDMS_HK.h Show annotated file Show diff for this revision Revisions of this file
DefinitionsAndGlobals.h Show annotated file Show diff for this revision Revisions of this file
RESET_functions.h Show annotated file Show diff for this revision Revisions of this file
ThreadsAndFunctions.h Show annotated file Show diff for this revision Revisions of this file
cdms_rtc.h Show annotated file Show diff for this revision Revisions of this file
cdms_sd.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/CDMS_HK.h	Mon Jul 04 05:24:35 2016 +0000
+++ b/CDMS_HK.h	Mon Jul 04 13:53:20 2016 +0000
@@ -13,8 +13,6 @@
 void minMaxHkData();
 void COLLECT_CDMS_RAM();
 
-Serial hk_cdms(USBTX, USBRX);
-
 AnalogIn TempInput(PIN27);          // Input from Current Multiplexer
 AnalogIn CDMS_temp_sensor(PIN53);
 AnalogIn COMRX_RSSI_volatge(PIN70);
@@ -27,7 +25,7 @@
 
 void FCTN_CDMS_HK_MAIN(void const *args)
 {
-
+    gPC.printf("Entering HK thread");
     unsigned char CDMS_HK_FRAME[134] = {0};
     char BAE_HK[128] = {0};
     uint8_t convoluted_CDMS_HK[270];
@@ -57,6 +55,7 @@
     minMaxHkData();
 
     uint64_t time = FCTN_CDMS_RD_RTC();             //Reading Time from RTC
+    gPC.printf("0x%08X \n",time);
     time = time>>7;
     uint32_t HK_time = (uint32_t)time;
     for(int i = 0; i<4; i++)
@@ -70,7 +69,6 @@
 
     CDMS_HEALTH_DATA[126] = GPIO_STATUS;            //Reading GPIO Pins
     CDMS_HEALTH_DATA[127] = GPIO_STATUS >> 8;
-
     FCTN_SD_MNGR();                                 //Adding FSC & TMID to TM frame
     CDMS_HK_FRAME[0] = 0x20;
     CDMS_HK_FRAME[1] = FSC_CURRENT[4]+1;
@@ -94,16 +92,15 @@
         CDMS_HEALTH_FINAL[i] = interleave_CDMS_HK[i];
 
     SD_WRITE(CDMS_HEALTH_FINAL,FSC_CURRENT[4]+1,4);
-    hk_cdms.printf("CDMS hk succesfully completed\r\n");
-
+    gPC.printf("Completed CDMS HK\n");
 
     /*---------------------------------- BAE HK --------------------------------------------*/
 
 
     BAE_HK_I2C = FCTN_I2C_READ(BAE_HK,134);
+    gPC.printf("Entering BAE thread\n");
     if(BAE_HK_I2C == 0) {
         TIME_LATEST_I2C_BAE = FCTN_CDMS_RD_RTC() >> 7;
-        hk_cdms.printf("Bae hk data received");
     } else {
         for(int i = 0; i<128; i++)
             BAE_HK[i] = 0;
@@ -126,7 +123,7 @@
     for(int i=0; i<288; i++)
         BAE_HEALTH_FINAL[i] = interleave_BAE_HK[i];
     SD_WRITE(BAE_HEALTH_FINAL,FSC_CURRENT[5]+1,5);
-    hk_cdms.printf("BAE hk succesfully completed\r\n");
+    gPC.printf("Completed BAE HK\n");
 
     /*----------------------------------Beacon message--------------------------------------*/
     unsigned char SC_HK_LBM_0[135];
@@ -138,6 +135,7 @@
     SC_HK_LBM_0[132] = crc;
     SC_HK_LBM_0[133] = crc >> 8;
     FCTN_I2C_WRITE((char *)SC_HK_LBM_0,135);
+    gPC.printf("Completed Beacon\n");
 }
 
 int quantiz(float start,float step,float x)
--- a/DefinitionsAndGlobals.h	Mon Jul 04 05:24:35 2016 +0000
+++ b/DefinitionsAndGlobals.h	Mon Jul 04 13:53:20 2016 +0000
@@ -265,11 +265,10 @@
 DigitalIn PL_GPIO_1_STATUS (PIN71);
 DigitalIn PL_GPIO_2_STATUS (PIN81);
 DigitalIn PL_GPIO_3_STATUS (PIN80);
-DigitalIn PL_BEE_SW_OC_FAULT (PIN4);
-DigitalIn PL_EPS_LATCH_SW_OC_FAULT ();
-DigitalIn V_C_EN_STATUS ();
-DigitalIn V_D_EN_STATUS ();
-
+DigitalIn PL_BEE_SW_OC_FAULT (PIN91);
+DigitalIn PL_EPS_LATCH_SW_OC_FAULT (PIN5);
+DigitalIn V_C_EN_STATUS (PIN72);
+DigitalIn V_D_EN_STATUS (PIN56);
 
 DigitalIn SD_OC_FAULT (PIN90);
 DigitalOut SD_SW_EN_DS (PIN97);
--- a/RESET_functions.h	Mon Jul 04 05:24:35 2016 +0000
+++ b/RESET_functions.h	Mon Jul 04 13:53:20 2016 +0000
@@ -35,6 +35,7 @@
     gCS_RTC=0;
     spi.write(0x8F);
     spi.write(0x00);
+    gCS_RTC=1;
 }
 
 
--- a/ThreadsAndFunctions.h	Mon Jul 04 05:24:35 2016 +0000
+++ b/ThreadsAndFunctions.h	Mon Jul 04 13:53:20 2016 +0000
@@ -19,7 +19,7 @@
     while(true){
         gPC.puts("entering sci\r\n");
         gSCIENCE_THREAD->signal_wait(SCIENCE_SIGNAL);
-        PL_wo_dma->stop();//
+        //PL_wo_dma->stop();//
         gPC.puts("sig_set\r\n");
         srp(gPAYLOAD_BUFFER);
         gPC.puts("exit_srp\r\n");
--- a/cdms_rtc.h	Mon Jul 04 05:24:35 2016 +0000
+++ b/cdms_rtc.h	Mon Jul 04 13:53:20 2016 +0000
@@ -1,131 +1,147 @@
+
 void FCTN_CDMS_INIT_RTC()
-{
-    if(RTC_INIT_STATUS == 1)
-    {
-        
-    }
+{   
+    wait_ms(4000);
     SPI_mutex.lock();
     gCS_RTC=1;
     spi.format(8,0);
     spi.frequency(1000000);
-    //clearing the halt bit
+    
+    //Kick starting the oscillator 
+    gCS_RTC=0;
+    spi.write(0x81); //register address with write flag
+    spi.write(0x80);//enabling stop bit in the seconds register
+    gCS_RTC=1;
+        
+    //clearing the halt bit 
     gCS_RTC=1;
     gCS_RTC=0;
     spi.write(0x8C);
     spi.write(0x00);
-
-    //clearing the OF bit
-    gCS_RTC=1;
+    gCS_RTC=1; 
+     
+    //clearing the OF bit 
     gCS_RTC=0;
     spi.write(0x8F);
     spi.write(0x00);
-
+    gCS_RTC=1; 
+     
     //century bits
-    gCS_RTC=1;
     gCS_RTC=0;
     spi.write(0x80|0x03);
     spi.write(0x00);
-
-    //Kick starting the oscillator
-    gCS_RTC=1;
-    gCS_RTC=0;
-    spi.write(0x81); //register address with write flag
-    spi.write(0x80); //enabling stop bit in the seconds register
-
-    gCS_RTC=1;
-    gCS_RTC=0;
-    spi.write(0x81);
-    spi.write(0x00); //disabling the stop bit to restart the oscillator
-
-
-    gCS_RTC=1;
-    gCS_RTC=0;
-    spi.write(0x80);
-    spi.write(0x01); // set milliseconds value to 00
-    gCS_RTC=1;
-
-    gCS_RTC=0;
-    spi.write(0x81);
-    spi.write(0x01); //set seconds value to 00
-    gCS_RTC=1;
-
-    gCS_RTC=0;
-    spi.write(0x82);
-    spi.write(0x01);//set minutes value to 00
     gCS_RTC=1;
 
+    
     gCS_RTC=0;
-    spi.write(0x83);
+    spi.write(0x81);
+    spi.write(0x00);//disabling the stop bit to restart the oscillator 
+    gCS_RTC=1;
+    
+    gCS_RTC=0;
+    spi.write(0x80); 
+    spi.write(0x01); // set milliseconds value to 00
+    gCS_RTC=1;
+ 
+    gCS_RTC=0;
+    spi.write(0x81); 
+    spi.write(0x01); //set seconds value to 00
+    gCS_RTC=1;
+ 
+    gCS_RTC=0;
+    spi.write(0x82); 
+    spi.write(0x01);//set minutes value to 00
+    gCS_RTC=1;
+ 
+    gCS_RTC=0;
+    spi.write(0x83); 
     spi.write(0x23); //set the hours to 01
     gCS_RTC=1;
-
+    
     gCS_RTC=0;
-    spi.write(0x84);
+    spi.write(0x84); 
     spi.write(0x01); //set day of the week to 01
     gCS_RTC=1;
-
+    
     gCS_RTC=0;
-    spi.write(0x85);
+    spi.write(0x85); 
     spi.write(0x31); //set date of the month to 01
     gCS_RTC=1;
-
+    
     gCS_RTC=0;
-    spi.write(0x86);
+    spi.write(0x86); 
     spi.write(0x12); //set month to 01
     gCS_RTC=1;
-
+    
     gCS_RTC=0;
-    spi.write(0x87);
+    spi.write(0x87); 
     spi.write(0x01); //set year to 00(2000)
     gCS_RTC=1;
-    gPC.puts("\r\nrtc initalised\r\n");
+    gPC.puts("\n\r rtc initalised \n");
     SPI_mutex.unlock();
 }
-
+ 
 uint64_t FCTN_CDMS_RD_RTC()
-{
-    SPI_mutex.lock();
+{   
+    SPI_mutex.lock(); 
     uint8_t response;
     uint64_t time = 0;
     
+    gCS_RTC = 0;
+    spi.write(0x0F);
+    response = spi.write(0x00);
+    //gPC.printf("0x%02X",response);
+    gCS_RTC = 1;
+    
+    gCS_RTC=0;
+    spi.write(0x00); //reading milliseconds register
+    response = spi.write(0x00); // read the value by sending dummy byte
+    uint8_t centiseconds =  (uint8_t(response&0xF0)>>4)*10+uint8_t(response&0x0F)*1;
+    
     gCS_RTC=1;
     gCS_RTC=0;
-    spi.write(0x0F);
-    response = (spi.write(0x00))&0x04;
-    if(response == 0x04)
-    {
-        goto END;
-    }
+    spi.write(0x01); //reading seconds register
+    response =spi.write(0x01);
+    uint8_t seconds =  ((response&0x70)>>4)*10+(response&0x0F)*1;
+    
+    gCS_RTC=1;
+    gCS_RTC=0;
+    spi.write(0x02); //reading minutes register
+    response =spi.write(0x01);
+    uint8_t minutes =  ((response&0xF0)>>4)*10+(response&0x0F)*1;
     
     gCS_RTC=1;
     gCS_RTC=0;
-    spi.write(0x00);                //reading centiseconds register
-    response = spi.write(0x00);     // read the value by sending dummy byte
-    uint8_t centiseconds = ((response&0xF0)>>4)*10+(response&0x0F)*1;
-
-    response =spi.write(0x00);
-    uint8_t seconds = ((response&0x70)>>4)*10+(response&0x0F)*1;
-
-    response =spi.write(0x00);
-    uint8_t minutes = ((response&0x70)>>4)*10+(response&0x0F)*1;
-
-    response=spi.write(0x00);
-    uint8_t hours = ((response&0x30)>>4)*10+(response&0x0F)*1;
-
-    uint8_t day =spi.write(0x00);
-
-    response =spi.write(0x00);
-    uint8_t date = ((response&0x30)>>4)*10+(response&0x0F)*1;
-
-    response =spi.write(0x00);
-    uint8_t month = ((response&0x10)>>4)*10+(response&0x0F)*1;
-
+    spi.write(0x03); //reading hours register
+    response=spi.write(0x01);
+    uint8_t hours =  ((response&0x30)>>4)*10+(response&0x0F)*1;
+    
+    gCS_RTC=1;
+    gCS_RTC=0;
+    spi.write(0x04); //reading day's  register
+    uint8_t day =spi.write(0x01);
+    
+    gCS_RTC=1;
+    gCS_RTC=0;
+    spi.write(0x05); //reading date register
+    response =spi.write(0x01);
+    uint8_t date =  ((response&0x30)>>4)*10+(response&0x0F)*1;
+    
+    gCS_RTC=1;
+    gCS_RTC=0;
+    spi.write(0x06); //reading month registe
+    response =spi.write(0x01);
+    uint8_t month =  ((response&0x10)>>4)*10+(response&0x0F)*1;
+    
+    gCS_RTC=1;
+    gCS_RTC=0;
     response =spi.write(0x00);
     uint8_t year = ((response&0xF0)>>4)*10+(response&0x0F)*1;
-    year = (year == 17)?0x00:(year == 18)?0x01:(year == 19)?0x02:(year == 20)?0x03:0x00;
+    year = (year == 16)?0x00:(year == 17)?0x01:(year == 18)?0x02:(year == 19)?0x03:0x00;
     gCS_RTC=1;
-
-    time = 0;
+    
+    uint8_t Time_stamp[8] = {year, month, date, day, hours, minutes, seconds, centiseconds};
+    
     time = time|(((uint64_t)(centiseconds&0x7F)));
     time = time|(((uint64_t)(seconds&0x3F))<<7);
     time = time|(((uint64_t)(minutes&0x3F))<<13);
@@ -134,10 +150,6 @@
     time = time|(((uint64_t)(month&0x07))<<29);
     time = time|(((uint64_t)(year&0x03))<<33);
     time = (time&0x00000007FFFFFFFF);
-
     SPI_mutex.unlock();
-    TIME_LATEST_RTC = time >> 7;
-    END:
     return time;
 }
-
--- a/cdms_sd.h	Mon Jul 04 05:24:35 2016 +0000
+++ b/cdms_sd.h	Mon Jul 04 13:53:20 2016 +0000
@@ -86,6 +86,9 @@
 
 void  FCTN_SD_MNGR()
 {
+/*    cs_sd = 1;
+    gCS_RTC = 1;
+    gCS_ADF = 1;*/
     uint32_t fsc;
     uint32_t start_fsc;
     uint8_t buffer[512];
--- a/main.cpp	Mon Jul 04 05:24:35 2016 +0000
+++ b/main.cpp	Mon Jul 04 13:53:20 2016 +0000
@@ -149,13 +149,12 @@
 
 
     master.frequency(400000);
-    PL_wo_dma = new RtosTimer(payload_isr_fun_dma, osTimerPeriodic,(void * )NULL);
+    //PL_wo_dma = new RtosTimer(payload_isr_fun_dma, osTimerPeriodic,(void * )NULL);
     //PL_wo_dma->start(6000);//
     gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);
 
 
 
-
     /*gPC.printf("PL_TC sending\r\n");
 
     Base_tm *tm_ptr = new Short_tm;
@@ -165,8 +164,9 @@
     */
     // *******************INITIALISATIONS END********************
 
-    RtosTimer gCDMS_HK_TIMER(FCTN_CDMS_HK_MAIN, osTimerPeriodic);
-    gCDMS_HK_TIMER.start(30000);
+    FCTN_CDMS_HK_MAIN((void *)NULL);
+    //RtosTimer gCDMS_HK_TIMER(FCTN_CDMS_HK_MAIN, osTimerPeriodic);
+    //gCDMS_HK_TIMER.start(30000);
 
     /*starting the thread with signal*/
     //set_sig();