From 1a044242a74584ee074dc0a194997882a4431a41 Mon Sep 17 00:00:00 2001
From: Raymond Knopp <raymond.knopp@eurecom.fr>
Date: Tue, 15 Jul 2014 18:20:11 +0000
Subject: [PATCH] git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5503
 818b1a75-f10b-46b9-bf7c-635c3b92a50f

---
 targets/RT/USER/lte-softmodem.c | 39 ++++++++++++++++++++++++++++-----
 1 file changed, 34 insertions(+), 5 deletions(-)

diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c
index 625c6241d1..1d17657d93 100644
--- a/targets/RT/USER/lte-softmodem.c
+++ b/targets/RT/USER/lte-softmodem.c
@@ -1040,8 +1040,9 @@ static void *eNB_thread(void *arg)
   int ret;
   //  int tx_offset;
   int sf;
+#ifndef USRP
   volatile unsigned int *DAQ_MBOX = openair0_daq_cnt();
-
+#endif
 #if defined(ENABLE_ITTI)
   /* Wait for eNB application initialization to be complete (eNB registration to MME) */
   wait_system_ready ("Waiting for eNB application to be ready %s\r", &start_eNB);
@@ -1071,6 +1072,8 @@ static void *eNB_thread(void *arg)
     timing_info.n_samples = 0;
 
     while (!oai_exit) {
+
+#ifndef USRP
       hw_slot = (((((volatile unsigned int *)DAQ_MBOX)[0]+1)%150)<<1)/15;
       //        LOG_D(HW,"eNB frame %d, time %llu: slot %d, hw_slot %d (mbox %d)\n",frame,rt_get_time_ns(),slot,hw_slot,((unsigned int *)DAQ_MBOX)[0]);
       //this is the mbox counter where we should be
@@ -1131,7 +1134,27 @@ static void *eNB_thread(void *arg)
 	else
 	  diff = mbox_target - mbox_current;
       }
-      
+
+#else  // USRP
+      while (rx_cnt < sf_bounds[hw_subframe]) {
+	openair0.trx_read_func(&openair0, &timestamp, &rxdata[rx_cnt*samples_per_packets], samples_per_packets);
+
+	openair0.trx_write_func(&openair0, (timestamp+samples_per_packets*tx_delay-tx_forward_nsamps), &txdata[tx_cnt*samples_per_packets], samples_per_packets, 1);
+
+	rx_cnt++;
+	tx_cnt++;
+      }
+
+#ifndef RTAI
+      //pthread_mutex_lock(&tti_mutex);
+#endif
+      hw_subframe++;
+      slot+=2;
+      if(hw_subframe==10)
+        hw_subframe = 0;
+
+#endif // USRP
+     
       if (oai_exit) break;
 
       if (frame>5)  {
@@ -1206,8 +1229,14 @@ static void *eNB_thread(void *arg)
 	  }
 	}
       }
-      
+#ifndef USRP
       slot++;
+#else
+      if(rx_cnt == max_cnt) {
+	rx_cnt = 0;
+      } 
+#endif     
+
       if (slot==20) {
 	slot=0;
 	frame++;
@@ -2045,8 +2074,8 @@ int main(int argc, char **argv) {
 
   openair0_dump_config(card);
   /*  
-  for (ant=0;ant<4;ant++)
-    p_exmimo_config->rf.do_autocal[ant] = 0;
+      for (ant=0;ant<4;ant++)
+      p_exmimo_config->rf.do_autocal[ant] = 0;
   */
 
 #ifdef EMOS
-- 
2.26.2