To fix the hang problem

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE by shubham c

Files at this revision

API Documentation at this revision

Comitter:
ee12b079
Date:
Sat Dec 10 11:49:13 2016 +0000
Parent:
319:c11a52b91d25
Child:
322:7d906d34aaff
Commit message:
Flags corrected, to be tested

Changed in this revision

COM_MNG_TMTC.h Show annotated file Show diff for this revision Revisions of this file
OBSRS.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
--- a/COM_MNG_TMTC.h	Thu Dec 08 15:17:24 2016 +0000
+++ b/COM_MNG_TMTC.h	Sat Dec 10 11:49:13 2016 +0000
@@ -14,6 +14,9 @@
 
 //DigitalIn tm_status_4m_slv(PIN39); //I2C interrupt to CDMS from BAE
 //DigitalIn tm_status_4m_pl(PIN61); //I2C interrupt to CDMS from PL
+#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
+
 #define RESET_CDMS NVIC_SystemReset()
 
 
@@ -1361,7 +1364,7 @@
         obosc_tm_current->next_TM = obosc_tm;\
         /*Sending OBOSC TM to GS*/\
         snd_tm.head_pointer(obosc_tm_head);\
-        transmit_adf;\
+        transmit_adf();\
         /*DELETE THE TM AFTER USE*/\
         obosc_tm_current = obosc_tm_head;\
         int overCount = 0;\
@@ -1435,7 +1438,7 @@
                         }\
                         /*Send only call sign, ACK_L1 to GS*/\
                         snd_tm.head_pointer(tm_ptr_head);\
-                        transmit_adf;\
+                        transmit_adf();\
                         /*DELETE THE TM AFTER USE*/\
                         tm_ptr = tm_ptr_head;\
                         int overflowCountExecute = 0;\
@@ -1565,7 +1568,7 @@
                             /*SEND call sign, ACK_L1, NON OBSRS TM TO GS*/\
                             snd_tm.head_pointer(tm_ptr_head);\
                             gPC.puts("enter_adf\r\n");\
-                            transmit_adf;\
+                            transmit_adf();\
                             gPC.puts("exit_adf\r\n");\
                             /*DELETE THE TM AFTER USE*/\
                             tm_ptr = tm_ptr_head;\
@@ -1589,7 +1592,7 @@
                             /*EXECUTION OF SD-CARD DATA SENDING (OBSRS)*/\
                             execute_OBSRS_TC(current_TC);\
                             gPC.puts("en_adf");\
-                            transmit_adf;\
+                            transmit_adf();\
                             gPC.puts("ex_adf");\
                         }\
                     }\
@@ -1640,4 +1643,6 @@
         gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\
         gFLAGS = gFLAGS & (~COM_SESSION_FLAG);\
     }\
-}
\ No newline at end of file
+}
+
+#endif
\ No newline at end of file
--- a/OBSRS.h	Thu Dec 08 15:17:24 2016 +0000
+++ b/OBSRS.h	Sat Dec 10 11:49:13 2016 +0000
@@ -1,6 +1,7 @@
 // problem in check pa and valid sid not sending anything in one for loop
 
-
+#ifndef OBSRS_H    // To make sure you don't declare the function more than once by including the header multiple times.
+#define OBSRS_H
 
 // no error            case 2 ackl234new->TM_string[2] = (101_0000) = 0x_0;     spare = 0  10100000 =  0xA0
 // Hardware failure    Case 4 ackl234new->TM_string[2] = (100_0101) = 0x_5;     spare = 0  10000101 =  0x85 comes from cdms ask pradeep
@@ -32,7 +33,6 @@
 bool Ack_andcallsign_over = false;
 bool repeat_last_2T_frames = false;
 bool last_block = false;
-bool last_buffer = false;
 bool new_OBSRS_TC = true;
 bool enable_SCH = true;
 bool enable_FCCH = false;
@@ -42,7 +42,6 @@
 //bool session_over = gFLAGS & COM_SESSION_TIMEOUT_FLAG;
 
 uint8_t SID ;
-unsigned char buffer_112[112];
 uint32_t FSC;
 uint16_t read_success = false;
 uint16_t counter_buffer_112=0, counter_EoS=0,T_frames_sent=0;
@@ -145,7 +144,7 @@
  Ack_andcallsign_over = false;\
  repeat_last_2T_frames = false;\
  last_block = false;\
- last_buffer = false;\
+/* last_buffer = false;*/\
  new_OBSRS_TC = true;\
  enable_SCH = true;\
  enable_FCCH = false;\
@@ -355,7 +354,7 @@
         }\
 }
 
-void send_tm_from_SD_card_fun(){
+void send_tm_from_SD_card_fun(unsigned char * buffer_112,bool & last_buffer){
 /*    gPC.printf("\n\rsend tm sd called\r\n");*/
     for(counter_buffer_112=0;counter_buffer_112<112;counter_buffer_112++){
         if(restart_adf_flag)
@@ -689,4 +688,6 @@
 //            send_tm_from_SD_card();
 //        }
 //    }
-}
\ No newline at end of file
+}
+
+#endif
\ No newline at end of file
--- a/ThreadsAndFunctions.h	Thu Dec 08 15:17:24 2016 +0000
+++ b/ThreadsAndFunctions.h	Sat Dec 10 11:49:13 2016 +0000
@@ -1,5 +1,9 @@
 //Science Thread
 //SPI ISR
+
+#include "COM_MNG_TMTC.h"
+#include "adf.h"
+
 void payload_isr_fun(){
     gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);
 }
--- a/adf.h	Thu Dec 08 15:17:24 2016 +0000
+++ b/adf.h	Sat Dec 10 11:49:13 2016 +0000
@@ -1,7 +1,11 @@
 //without reset feature , with state checks.
+
+#ifndef ADF_H    // To make sure you don't declare the function more than once by including the header multiple times.
+#define ADF_H
+
 InterruptIn IRQ(ADF_IRQ);
 //Ticker ticker;
- 
+#include "OBSRS.h" 
 bool loop_on;
 bool ADF_off;
 bool buffer_state;
@@ -29,7 +33,7 @@
 bool hw_reset_flag = false;
 uint8_t firstbyte;
 uint8_t secondbyte;
-
+unsigned char buffer_112[112];
 //ADF temperature reading
 #define temp_correction_value 0
 
@@ -74,7 +78,7 @@
 bool temp_return = 0;
 bool bcn_flag=0;
 bool bbram_flag=0;
-
+bool last_buffer =0;
 bool stop_transmission=false;
 
 #define reset_flags {\
@@ -473,7 +477,7 @@
                 T.start();\
                 write_data;\
                 if(sent_tmfrom_SDcard)\
-                send_tm_from_SD_card_fun();\
+                send_tm_from_SD_card_fun(buffer_112,last_buffer);\
                 else snd_tm.transmit_data(buffer_112,&last_buffer);\
             }\
         } else {\
@@ -517,19 +521,19 @@
     spi.write(0xFF);\
     gCS_ADF=1;\
     if(sent_tmfrom_SDcard){\
-        send_tm_from_SD_card_fun();\
+        send_tm_from_SD_card_fun(buffer_112,last_buffer);\
     }else{\
         snd_tm.transmit_data(buffer_112,&last_buffer);\
     }\
     write_data;\
     if(sent_tmfrom_SDcard){\
-        send_tm_from_SD_card_fun();\
+        send_tm_from_SD_card_fun(buffer_112,last_buffer);\
     }else{\
         snd_tm.transmit_data(buffer_112,&last_buffer);\
     }\
     write_data;\
     if(sent_tmfrom_SDcard){\
-        send_tm_from_SD_card_fun();\
+        send_tm_from_SD_card_fun(buffer_112,last_buffer);\
     }else{\
         snd_tm.transmit_data(buffer_112,&last_buffer);\
     }\
@@ -645,36 +649,38 @@
     gPC.puts("Config_part done\r\n");\
 }
  
-#define transmit_adf {\
-while(power_reset_count<POWER_RESET_THRS){\ 
-    restart_adf_flag=false;\
-    bool tx_err=false;\
-    configure_adf;\
-    send_data;\
-    /*PA MCR level*/;\
-        gCS_ADF=0;\
-        spi.write(0x1B);\
-        spi.write(0x07);\
-        spi.write(0x35);\
-        gCS_ADF=1;\
-    CMD(CMD_PHY_TX);\
-    wait_us(2000);\
-    T.start();\
-    while(loop_on){\
-        wait_us(20);\
-        check;\
-        if(data_irq_err||tx_err){\
-            hw_reset_err_cnt++;\
-            hw_reset_flag=true;\
-        break;\
-        }\
-    }\
-    if(hw_reset_flag==true){\
-        hardware_reset(0);\
-        }\
-    else{\
-        break;\
-    }\
-    gPC.puts("after while loop\r\n");\
-}\
-}
\ No newline at end of file
+void transmit_adf(){
+while(power_reset_count<POWER_RESET_THRS){ 
+    restart_adf_flag=false;
+    bool tx_err=false;
+    configure_adf;
+    send_data;
+    /*PA MCR level*/;
+        gCS_ADF=0;
+        spi.write(0x1B);
+        spi.write(0x07);
+        spi.write(0x35);
+        gCS_ADF=1;
+    CMD(CMD_PHY_TX);
+    wait_us(2000);
+    T.start();
+    while(loop_on){
+        wait_us(20);
+        check;
+        if(data_irq_err||tx_err){
+            hw_reset_err_cnt++;
+            hw_reset_flag=true;
+        break;
+        }
+    }
+    if(hw_reset_flag==true){
+        hardware_reset(0);
+        }
+    else{
+        break;
+    }
+    gPC.puts("after while looprn");
+}
+}
+
+#endif
\ No newline at end of file
--- a/common_functions.h	Thu Dec 08 15:17:24 2016 +0000
+++ b/common_functions.h	Sat Dec 10 11:49:13 2016 +0000
@@ -1,3 +1,5 @@
+
+#define RESET_CDMS NVIC_SystemReset()
 #define get_tc_list(tm_ptr, thePSC){\
     uint8_t TM_PSC = 0xFF;\
     uint8_t TC_PSC = thePSC;\