for frequency correction testing

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE by shubham c

Revision:
321:42bdefc37270
Parent:
318:978d72f191f9
--- 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