FM

Dependencies:   SimpleDMA eeprom mbed-rtos mbed FreescaleIAP

Fork of CDMS_CODE by shubham c

Files at this revision

API Documentation at this revision

Comitter:
ee12b079
Date:
Mon Jan 02 14:21:44 2017 +0000
Parent:
337:163824c3fef1
Child:
339:5c4bda268e08
Child:
341:599aa20d0279
Child:
342:77b0d59897f7
Child:
343:cd7b1734f7a0
Commit message:
Changed rssi, oc_sw_status, decresed com session timeout.

Changed in this revision

CDMS_HK.h Show annotated file Show diff for this revision Revisions of this file
COM_MNG_TMTC.h Show annotated file Show diff for this revision Revisions of this file
COM_POWER_ON_TX.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
ThreadsAndFunctions.h Show annotated file Show diff for this revision Revisions of this file
adf.h Show annotated file Show diff for this revision Revisions of this file
common_functions.h Show annotated file Show diff for this revision Revisions of this file
dmaSPIslave.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	Sun Jan 01 09:50:36 2017 +0000
+++ b/CDMS_HK.h	Mon Jan 02 14:21:44 2017 +0000
@@ -67,7 +67,11 @@
         CDMS_HK_MAIN_COUNTER++;
 
         FCTN_CDMS_HK();         //collects temperatures
-        RSSI_VOLTAGE = COMRX_RSSI_VOLTAGE.read() * 3.3;//to be checked
+        if(!COM_RSSI_SET)
+        {
+            RSSI_VOLTAGE = COMRX_RSSI_VOLTAGE.read() * 3.3;//to be checked
+        }
+        else COM_RSSI_SET = 0;
         //VERIFY_COMRX();
         VERIFY_RTC();
         HANDLE_HW_FAULTS();
@@ -208,7 +212,13 @@
         beacon_array[7] = SD_FAULTCOUNT;
         beacon_array[8] = RTC_FAULTCOUNT >> 8;
         beacon_array[9] = RTC_FAULTCOUNT;
+        if(!COM_OC_SET)
         beacon_array[10] = (((SD_STATUS == DEVICE_DISABLED || SD_STATUS == DEVICE_OC_FAULT)?1:0)<<7)|(RTC_STATUS <<6)|(COM_RX_STATUS<<3)|(0<<2)|(COMRX_OC_FAULT<<1)|(COM_TX_OC_FAULT);
+        else
+        {
+            beacon_array[10] = (((SD_STATUS == DEVICE_DISABLED || SD_STATUS == DEVICE_OC_FAULT)?1:0)<<7)|(RTC_STATUS <<6)|(COM_RX_STATUS<<3)|(0<<2)|(COMRX_OC_FAULT<<1)|(com_oc_sw_status);
+            COM_OC_SET = 0;
+        }
         beacon_array[11] = (COM_RX_CNTRL <<7)|(COM_TX_CNTRL);
         beacon_array[12] = CDMS_HK_MAIN_COUNTER >>8;
         beacon_array[13] = CDMS_HK_MAIN_COUNTER;
--- a/COM_MNG_TMTC.h	Sun Jan 01 09:50:36 2017 +0000
+++ b/COM_MNG_TMTC.h	Mon Jan 02 14:21:44 2017 +0000
@@ -17,6 +17,8 @@
 #ifndef COM_MNG_TMTC_H    // To make sure you don't declare the function more than once by including the header multiple times.
 #define COM_MNG_TMTC_H
 
+#include "dmaSPIslave.h"
+
 #define RESET_CDMS NVIC_SystemReset()
 
 
@@ -1406,6 +1408,7 @@
         /*gPC.puts("iNSIDE EXECUTE_TC\r\n")*/;\
     /*gPC.printf("%u\r\n", gTOTAL_VALID_TC);*/\
     for(uint8_t execute_psc = PSC_START_VALUE ; execute_psc < gTOTAL_VALID_TC ; ++execute_psc ){\
+        /*wait(10)*/;\
         if (DEBUG)\
             gPC.printf("executing normal %u\r\n", execute_psc);\
         /*gLEDG = !gLEDG;*/\
@@ -1647,6 +1650,7 @@
         COM_POWER_OFF_TX;\
         reset_all;\
         /*ENABLE THREADS*/\
+        resume_pl_dma = 1;\
         /*gPAY_SPI->bulkRead_resume(&payload_isr_fun)*/;\
         HK_counter->start(10000);\
         gSESSION_TIMEOUT.detach();\
--- a/COM_POWER_ON_TX.h	Sun Jan 01 09:50:36 2017 +0000
+++ b/COM_POWER_ON_TX.h	Mon Jan 02 14:21:44 2017 +0000
@@ -251,8 +251,8 @@
         }
         get_tc_list(power_on_tm->next_TM, 0x00);
         /*Call Sign, ACK_L1, TC_LIST*/
-        snd_tm.head_pointer(power_on_tm_head);
-        transmit_adf();
+        /*snd_tm.head_pointer(power_on_tm_head);*/
+        /*transmit_adf();*/
         uint8_t transmissionPass = 0xFF;
         /*PENDING: get acknowledgement of transmission*/
         /*deleting the telemetry*/
--- a/DefinitionsAndGlobals.h	Sun Jan 01 09:50:36 2017 +0000
+++ b/DefinitionsAndGlobals.h	Mon Jan 02 14:21:44 2017 +0000
@@ -77,7 +77,6 @@
     #define RF_BCN 1
 
 // COM_MNG_TMTC THREAD
-    #define SESSION_TIME_LIMIT 1500
     #define COM_MNG_TMTC_SIGNAL_UART_INT 0x01
     #define COM_MNG_TMTC_SIGNAL_ADF_NSD 0x02
     #define COM_MNG_TMTC_SIGNAL_ADF_SD 0x03
@@ -207,7 +206,7 @@
 DigitalOut RF_SW_CNTRL_TX(RF_RELAY_CNTRL_TX);
 
 //COM_RX
-DigitalOut COM_RX_CNTRL(PIN72,1);
+DigitalOut COM_RX_CNTRL(PIN55,1);//changed!! earlier version had PIN72
 DigitalOut COM_TX_CNTRL(PIN56,1);
 //DigitalIn COM_TX_OC_FAULT(PIN69);
 DigitalIn COM_TX_OC_FAULT(PIN58);
@@ -240,7 +239,6 @@
 
 // PAYLOAD OR SCIENCE_THREAD
 Thread* gSCIENCE_THREAD = NULL;
-dmaSPISlave *gPAY_SPI;
 uint8_t gPAYLOAD_BUFFER[PAYLOAD_BUFFER_LENGTH] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,44,1,44,1,44,1,44,1,44,1,44,1,188,2,188,2,188,2,188,2,88,2,88,2,88,2,88,2,100,0,100,0,200,0,200,0,244,1,244,1,88,2,88,2,208,2,208,2,246,0,246,0,10,0,250,0,250,0,250,0,120,0,0,0,172,13,0,0,184,11,0,0,160,15,0,0};
 RtosTimer *PL_wo_dma;
 
@@ -284,7 +282,7 @@
 DigitalIn V_A_PGOOD (PIN88);
 DigitalIn V_B_PGOOD_1 (PIN6);
 DigitalIn V_B_PGOOD_2 (PIN7);
-DigitalIn V_C_PGOOD (PIN54);
+AnalogIn V_C_PGOOD (PIN54);
 DigitalIn COMRX_OC_FAULT (PIN68);
 //DigitalIn COMTX_OC_FAULT (PIN69);
 DigitalIn BAE_OC_FAULT (PIN92);
@@ -376,9 +374,16 @@
 uint8_t COM_RX_DISABLE_TIMEOUT;
 uint8_t COM_PA_TMP_HIGH;
 uint8_t COM_PA_RECOVERY_TIMEOUT;
-uint8_t COM_SESSION_TIMEOUT = 1500;  //confirm with Anirudh 
+uint8_t COM_SESSION_TIMEOUT = 60;  //confirm with Anirudh 
 uint8_t COM_RSSI_MIN;
 uint16_t SD_LIB_BLK_CURRENT;
 
 // Ambigouties
-uint8_t EN_RTC = 0x01;
\ No newline at end of file
+uint8_t EN_RTC = 0x01;
+
+//Variables used by shubham (02-01-2017)
+uint8_t com_oc_sw_status = 1;
+uint8_t COM_OC_SET = 0;
+uint8_t COM_RSSI_SET = 0;
+uint8_t resume_pl_dma = 0;
+
--- a/ThreadsAndFunctions.h	Sun Jan 01 09:50:36 2017 +0000
+++ b/ThreadsAndFunctions.h	Mon Jan 02 14:21:44 2017 +0000
@@ -4,6 +4,10 @@
 #include "COM_MNG_TMTC.h"
 #include "adf.h"
 
+#include "dmaSPIslave.h"
+
+dmaSPISlave *gPAY_SPI;
+
 void payload_isr_fun(){
     gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);
 }
@@ -13,7 +17,6 @@
 }
 
 void SCIENCE_FUN(void const *args){
-    gPAY_SPI = new dmaSPISlave(PAY_SPI_MOSI, PAY_SPI_MISO, PAY_SPI_CLK, PAY_SPI_CS);
    // gPAY_SPI->frequency(1000000);   //1000000
     gPAY_SPI->format(8,0); 
     gPC.printf("\n\rTest...........................");
@@ -64,6 +67,10 @@
 // UART ISR
 void rx_read(){
     gRX_CURRENT_DATA_NODE->values[gRX_COUNT] = RX1M.getc();
+    //Checking RSSI
+    if(!COM_RSSI_SET)
+    RSSI_VOLTAGE = COMRX_RSSI_VOLTAGE.read() * 3.3;//to be checked
+    COM_RSSI_SET = 1;
     gFLAGS = gFLAGS | UART_INT_FLAG;
     gCOM_MNG_TMTC_THREAD->signal_set(COM_MNG_TMTC_SIGNAL_UART_INT);
 }
@@ -85,9 +92,9 @@
 void after_session(){
     gSESSION_TIMEOUT.detach();
     gFLAGS = gFLAGS | COM_SESSION_TIMEOUT_FLAG;
-    if( gMASTER_STATE != TCL_STATE_EXECUTING ){
+    //if( gMASTER_STATE != TCL_STATE_EXECUTING ){
         gCOM_MNG_TMTC_THREAD->signal_set(COM_MNG_TMTC_SIGNAL_UART_INT);
-    }
+    //}
 }
 
 #define reset_all {\
@@ -153,7 +160,7 @@
                 HK_counter->stop();
                 gPAY_SPI->bulkRead_pause();
                 gFLAGS = gFLAGS | COM_SESSION_FLAG;
-                gSESSION_TIMEOUT.attach(&after_session, SESSION_TIME_LIMIT);
+                gSESSION_TIMEOUT.attach(&after_session, COM_SESSION_TIMEOUT);
                 gFLAGS = gFLAGS | COM_RX_FLAG;
                 gTOTAL_RAW_BYTES = 0;
                 PUT_RAW_BYTE;
@@ -203,6 +210,7 @@
             
             if( gTOTAL_VALID_TC > 0 ){
                 gPC.printf("valid TC rx: %u\r\n", gTOTAL_VALID_TC);
+                //gTOTAL_VALID_TC = 1;
                 if( gTOTAL_VALID_TC < COM_MAX_TC_LIMIT ){
                     // CHECK WEATHER TC LIST HAS MISSING TC OR WEATHER LAST FRAME BIT IS HIGH IN THE LAST PSC-TC
                     //gPC.puts("checking for tc list complete\r\n");
@@ -235,6 +243,7 @@
                                 EXECUTE_OBOSC_ONLY;
                                 EXECUTE_TC;
                                 gPC.puts("COMPLETED EXECUTION\r\n");
+                                gPC.printf("master_state : %d\n",gMASTER_STATE);
                             }
                         }
                         else{
@@ -244,7 +253,8 @@
                             gFLAGS = gFLAGS & (~COM_SESSION_VALIDITY);
                             // ENABLE THREADS
                             HK_counter->start(10000);
-                            gPAY_SPI->bulkRead_resume(&payload_isr_fun);
+                            resume_pl_dma = 1;
+                            //gPAY_SPI->bulkRead_resume(&payload_isr_fun);
                             gSESSION_TIMEOUT.detach();
                             gFLAGS = gFLAGS & (~COM_SESSION_FLAG);
                             // WARNING: clear COM_MNG_TMTC ?
@@ -303,7 +313,7 @@
                 reset_all;
                 // ENABLE THREADS
                 HK_counter->start(10000);
-                gPAY_SPI->bulkRead_resume(&payload_isr_fun);
+                resume_pl_dma = 1;
                 gSESSION_TIMEOUT.detach();
                 gFLAGS = gFLAGS & (~COM_SESSION_FLAG);
             }
@@ -332,7 +342,7 @@
             COM_POWER_OFF_TX;
             /*ENABLE THREADS*/
             HK_counter->start(10000);
-            gPAY_SPI->bulkRead_resume(&payload_isr_fun);
+            resume_pl_dma = 1;
             gSESSION_TIMEOUT.detach();
             gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);
             gFLAGS = gFLAGS & (~COM_SESSION_FLAG);
@@ -345,11 +355,19 @@
             reset_all;
             // ENABLE THREADS
             HK_counter->start(10000);
-            gPAY_SPI->bulkRead_resume(&payload_isr_fun);
+            resume_pl_dma = 1;
             gSESSION_TIMEOUT.detach();
             gFLAGS = gFLAGS & (~COM_SESSION_FLAG);
         }
+        if(resume_pl_dma)
+        {
+            
+            
+            resume_pl_dma = 0;
+        }
+        //gPC.puts("dma started");
         gPAY_SPI->bulkRead_resume(&payload_isr_fun);
         gMutex.unlock();
+        
     }
 }
\ No newline at end of file
--- a/adf.h	Sun Jan 01 09:50:36 2017 +0000
+++ b/adf.h	Mon Jan 02 14:21:44 2017 +0000
@@ -273,9 +273,23 @@
                 COM_ADF_TMP |= secondbyte & 0xfc;
                 COM_ADF_TMP = 0.9474*(COM_ADF_TMP - 28) +28.2;
                 
-                gPC.printf("\n\rCOM_ADF_TMP : %d",COM_ADF_TMP);
-                uint8_t txcurr = (3.3*COM_TX_OC_FAULT)/(0.05)*100;
+                gPC.printf("\n\rCOM_ADF_TMP : %d \n",COM_ADF_TMP);
+                /*uint8_t txcurr = (3.3*COM_TX_OC_FAULT)/(0.05)*100;*///    ID_current
+                
+                
+                
     }
+    
+void get_com_oc_sw_status()
+{
+    COM_OC_SET = 1;
+    if (COM_TX_OC_FAULT){\
+         com_oc_sw_status = 0x1;\
+    }\
+    else{\
+        com_oc_sw_status = 0;\
+    }\
+} 
 
 bool hardware_reset(int bcn_call)
 {
@@ -459,6 +473,7 @@
     check_status;\
     /*gPC.printf("I 0x%X\r\n",(int)status);*/\
     if(IRQ){\
+        get_com_oc_sw_status();\
         /*gPC.printf("det\r\n");*/\
         if(!ADF_off) {\
             if(finish_write_data || restart_adf_flag) {\
--- a/common_functions.h	Sun Jan 01 09:50:36 2017 +0000
+++ b/common_functions.h	Mon Jan 02 14:21:44 2017 +0000
@@ -186,13 +186,12 @@
 }
 
 #define isPAoc(returnHere){\
-    if (COM_TX_OC_FAULT){\
+    if (!com_oc_sw_status){\
         returnHere = 0xFF;\
     }\
     else{\
         returnHere = 0;\
     }\
-    returnHere = 0;\
 }
 
 #define get_call_sign(tm_ptr) {\
--- a/dmaSPIslave.h	Sun Jan 01 09:50:36 2017 +0000
+++ b/dmaSPIslave.h	Mon Jan 02 14:21:44 2017 +0000
@@ -1,3 +1,6 @@
+#ifndef DMASPISLAVE_H    // To make sure you don't declare the function more than once by including the header multiple times.
+#define DMASPISLAVE_H
+
 #ifdef TARGET_KL46Z
 class dmaSPISlave : public SPISlave{
     public:
@@ -81,3 +84,4 @@
         SimpleDMA read_dma;
 };
 #endif
+#endif
\ No newline at end of file
--- a/main.cpp	Sun Jan 01 09:50:36 2017 +0000
+++ b/main.cpp	Mon Jan 02 14:21:44 2017 +0000
@@ -103,6 +103,9 @@
     gPC.puts("allocating threads\r\n");
     #endif
     
+    //DMA iobject decalaration
+    gPAY_SPI = new dmaSPISlave(PAY_SPI_MOSI, PAY_SPI_MISO, PAY_SPI_CLK, PAY_SPI_CS);
+    
     // COM_POWER_ON_TX();
     
     // COM_MNG_TMTC THREAD