pl ack in tmtc

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of COM_MNG_TMTC_SIMPLE_pl123 by shubham c

Revision:
71:9193fbdaa3e1
Parent:
53:18db568f1098
--- a/adf.h	Fri Jan 15 12:02:12 2016 +0000
+++ b/adf.h	Tue Jan 19 10:30:46 2016 +0000
@@ -3,7 +3,7 @@
 //Ticker ticker;
  
 bool sent_tmfrom_SDcard;
-bool loop_on;
+//bool loop_on;
 bool ADF_off;
 bool buffer_state;
 bool finish_write_data;
@@ -286,50 +286,49 @@
     
     
 #define adf_SND_SDCard {\
-    buffer_state = true;\
-    last_buffer = false;\
-    loop_on = true;\
-    ADF_off = false;\
     sent_tmfrom_SDcard = true;\
+    configure_adf;\
     signal = COM_MNG_TMTC_SIGNAL_ADF_SD;\
-    start_block_num = starting_add;\
-    end_block_num = ending_add;\
-    initial_adf_check;\
-    initiate;\
     send_data;\
     while(loop_on){\
         /*led2=!led2;*/\
-        gCOM_MNG_TMTC_THREAD->signal_wait(COM_MNG_TMTC_SIGNAL_ADF_SD);\
-        if(ADF_off){\
-            SPI_mutex.lock();\
-            /*ticker.detach();*/\
-            gCS_ADF=0;\
-            spi.write(0xB1);\
-            gCS_ADF=1;\
-            SPI_mutex.unlock();\
-            gPC.puts("transmission done\r\n");\
-            loop_on = false;\
-        }else{\
-            write_data;\
-            if(!last_buffer)\
-            send_tm_from_SD_card();\
+        /*gCOM_MNG_TMTC_THREAD->signal_wait(COM_MNG_TMTC_SIGNAL_ADF_SD);*/\
+        wait_ms(COM_TX_TICKER_LIMIT);\
+        if(IRQ){\
+            if(finish_write_data){\
+                if(ADF_off){\
+                    SPI_mutex.lock();\ 
+                    gCS_ADF=0;\
+                    spi.write(0xB1);\
+                    gCS_ADF=1;\
+                    SPI_mutex.unlock();\
+                    loop_on = false;\
+                    gPC.puts("Transmission done\r\n");\
+                }\
+                else{\
+                    ADF_off = true;\
+                }\
+            }else{\   
+                write_data;\
+                send_tm_from_SD_card();\
+            }\
         }\
     }\
 }
     
-void read_TC(Base_tc* TC_ptr){
-    gPC.puts("Inside sd card sending\r\n");
-    unsigned char service_subtype = 0;
-    uint64_t starting_add  = 0, ending_add = 0;
-    service_subtype = (TC_ptr->TC_string[2])&0x0f;
-    starting_add =  (TC_ptr->TC_string[5]) +  ( (TC_ptr->TC_string[4])<<8 ) + ( (TC_ptr->TC_string[3]) <<16);
-    ending_add =  (TC_ptr->TC_string[8]) +  ( (TC_ptr->TC_string[7])<<8 ) + ( (TC_ptr->TC_string[6]) <<16);
-    starting_add = 10; // for now
-    ending_add = 20;
-//    adf_SND_SDCard(starting_add , ending_add);
-    gPC.puts("sending from sd card\r\n");
-    adf_SND_SDCard;
-}
+//void read_TC(Base_tc* TC_ptr){
+//    gPC.puts("Inside sd card sending\r\n");
+//    unsigned char service_subtype = 0;
+//    uint64_t starting_add  = 0, ending_add = 0;
+//    service_subtype = (TC_ptr->TC_string[2])&0x0f;
+//    starting_add =  (TC_ptr->TC_string[5]) +  ( (TC_ptr->TC_string[4])<<8 ) + ( (TC_ptr->TC_string[3]) <<16);
+//    ending_add =  (TC_ptr->TC_string[8]) +  ( (TC_ptr->TC_string[7])<<8 ) + ( (TC_ptr->TC_string[6]) <<16);
+//    starting_add = 10; // for now
+//    ending_add = 20;
+////    adf_SND_SDCard(starting_add , ending_add);
+//    gPC.puts("sending from sd card\r\n");
+//    adf_SND_SDCard;
+//}
  
 #define configure_adf {\
     finish_write_data = false;\