From f64179039ec232fb5d8a02a8fd768020b5e3907a Mon Sep 17 00:00:00 2001
From: Sagar Parsawar <sagar.parsawar@eurecom.fr>
Date: Fri, 26 May 2023 14:13:24 +0200
Subject: [PATCH] Applied clang formatting

---
 executables/nr-ru.c                           |   9 +-
 executables/nr-softmodem-common.h             |   4 +-
 executables/nr-ue.c                           |   9 +-
 executables/nr-uesoftmodem.c                  |   6 +-
 executables/nr-uesoftmodem.h                  |   2 +-
 .../nr_dl_channel_estimation.c                | 162 ++++++++++--------
 .../PHY/NR_UE_TRANSPORT/nr_initial_sync.c     |   2 +-
 openair1/PHY/defs_nr_common.h                 |   8 +-
 openair1/SCHED_NR_UE/phy_procedures_nr_ue.c   |   8 +-
 openair2/RRC/NR_UE/main_ue.c                  |   7 +-
 openair2/RRC/NR_UE/rrc_UE.c                   |  14 +-
 openair2/RRC/NR_UE/rrc_proto.h                |   6 +-
 12 files changed, 125 insertions(+), 112 deletions(-)

diff --git a/executables/nr-ru.c b/executables/nr-ru.c
index a429d579c2..fb3b8a2e6c 100644
--- a/executables/nr-ru.c
+++ b/executables/nr-ru.c
@@ -777,8 +777,13 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) {
   void *txp[ru->nb_tx];
   unsigned int txs;
   int i;
-  T(T_ENB_PHY_OUTPUT_SIGNAL, T_INT(0), T_INT(0), T_INT(frame), T_INT(slot),
-    T_INT(0), T_BUFFER(&ru->common.txdata[0][fp->get_samples_slot_timestamp(slot,fp,0)], fp->get_samples_per_slot(slot,fp) * 4));
+  T(T_ENB_PHY_OUTPUT_SIGNAL,
+    T_INT(0),
+    T_INT(0),
+    T_INT(frame),
+    T_INT(slot),
+    T_INT(0),
+    T_BUFFER(&ru->common.txdata[0][fp->get_samples_slot_timestamp(slot, fp, 0)], fp->get_samples_per_slot(slot, fp) * 4));
   int sf_extension = 0;
   int siglen=fp->get_samples_per_slot(slot,fp);
   radio_tx_burst_flag_t flags_burst = TX_BURST_INVALID;
diff --git a/executables/nr-softmodem-common.h b/executables/nr-softmodem-common.h
index 8a25395abe..2550001956 100644
--- a/executables/nr-softmodem-common.h
+++ b/executables/nr-softmodem-common.h
@@ -88,8 +88,8 @@
 #define CONFIG_HLP_DISABLNBIOT   "disable nb-iot, even if defined in config\n"
 #define CONFIG_HLP_DISABLETIMECORR "disable UE timing correction\n"
 #define CONFIG_HLP_RRC_CFG_PATH  "path for RRC configuration\n"
-#define CONFIG_HLP_RE_CFG_FILE   "filename for reconfig.raw in phy-test mode\n"
-#define CONFIG_HLP_RB_CFG_FILE   "filename for rbconfig.raw in phy-test mode\n"
+#define CONFIG_HLP_RE_CFG_FILE "filename for reconfig.raw in phy-test mode\n"
+#define CONFIG_HLP_RB_CFG_FILE "filename for rbconfig.raw in phy-test mode\n"
 #define CONFIG_HLP_UECAP_FILE    "path for UE Capabilities file\n"
 
 #define CONFIG_HLP_NUMEROLOGY    "adding numerology for 5G\n"
diff --git a/executables/nr-ue.c b/executables/nr-ue.c
index f0f9927f3c..8eae392f96 100644
--- a/executables/nr-ue.c
+++ b/executables/nr-ue.c
@@ -944,17 +944,14 @@ void *UE_thread(void *arg)
   return NULL;
 }
 
-void init_NR_UE(int nb_inst,
-                char* uecap_file,
-                char* rrc_config_path, 
-                char* reconfig_file, 
-                char* rbconfig_file) {
+void init_NR_UE(int nb_inst, char *uecap_file, char *rrc_config_path, char *reconfig_file, char *rbconfig_file)
+{
   int inst;
   NR_UE_MAC_INST_t *mac_inst;
   NR_UE_RRC_INST_t* rrc_inst;
   
   for (inst=0; inst < nb_inst; inst++) {
-    AssertFatal((rrc_inst = nr_l3_init_ue(uecap_file,rrc_config_path, reconfig_file, rbconfig_file)) != NULL, "can not initialize RRC module\n");
+    AssertFatal((rrc_inst = nr_l3_init_ue(uecap_file, rrc_config_path, reconfig_file, rbconfig_file)) != NULL, "can not initialize RRC module\n");
     AssertFatal((mac_inst = nr_l2_init_ue(rrc_inst)) != NULL, "can not initialize L2 module\n");
     AssertFatal((mac_inst->if_module = nr_ue_if_module_init(inst)) != NULL, "can not initialize IF module\n");
   }
diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c
index 92f957ab8f..e746f66e9c 100644
--- a/executables/nr-uesoftmodem.c
+++ b/executables/nr-uesoftmodem.c
@@ -123,8 +123,8 @@ char             *usrp_args = NULL;
 char             *tx_subdev = NULL;
 char             *rx_subdev = NULL;
 char       *rrc_config_path = NULL;
-char         *reconfig_file = NULL;
-char         *rbconfig_file = NULL;
+char *reconfig_file = NULL;
+char *rbconfig_file = NULL;
 char            *uecap_file = NULL;
 int               dumpframe = 0;
 
@@ -474,7 +474,7 @@ int main( int argc, char **argv ) {
 #endif
   LOG_I(HW, "Version: %s\n", PACKAGE_VERSION);
 
-  init_NR_UE(1,uecap_file,rrc_config_path,reconfig_file,rbconfig_file);
+  init_NR_UE(1, uecap_file, rrc_config_path, reconfig_file, rbconfig_file);
 
   int mode_offset = get_softmodem_params()->nsa ? NUMBER_OF_UE_MAX : 1;
   uint16_t node_number = get_softmodem_params()->node_number;
diff --git a/executables/nr-uesoftmodem.h b/executables/nr-uesoftmodem.h
index a9e18098d8..f104aaea93 100644
--- a/executables/nr-uesoftmodem.h
+++ b/executables/nr-uesoftmodem.h
@@ -93,7 +93,7 @@ extern nrUE_params_t *get_nrUE_params(void);
 // In nr-ue.c
 extern int setup_nr_ue_buffers(PHY_VARS_NR_UE **phy_vars_ue, openair0_config_t *openair0_cfg);
 extern void fill_ue_band_info(void);
-extern void init_NR_UE(int, char*, char*, char*, char*);
+extern void init_NR_UE(int, char *, char *, char *, char *);
 extern void init_NR_UE_threads(int);
 extern void reset_opp_meas(void);
 extern void print_opp_meas(void);
diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c
index 7e7f473b29..8f2e0ed5ed 100644
--- a/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c
+++ b/openair1/PHY/NR_UE_ESTIMATION/nr_dl_channel_estimation.c
@@ -58,16 +58,13 @@ void peak_estimator(int32_t *buffer, int32_t buf_len, int32_t *peak_idx, int32_t
       max_idx = k;
     }
   }
-  
+
   // Check for detection threshold
-  LOG_D(PHY,"PRS ToA estimator: max_val %d, mean_val %d, max_idx %d\n", max_val, mean_val, max_idx);
-  if((mean_val !=0) && (max_val/mean_val > 10))
-  {
+  LOG_D(PHY, "PRS ToA estimator: max_val %d, mean_val %d, max_idx %d\n", max_val, mean_val, max_idx);
+  if ((mean_val != 0) && (max_val / mean_val > 10)) {
     *peak_val = max_val;
     *peak_idx = max_idx;
-  }
-  else
-  {
+  } else {
     *peak_val = 0;
     *peak_idx = 0;
   }
@@ -106,9 +103,9 @@ int nr_prs_channel_estimation(uint8_t gNB_id,
   int16_t *ch_tmp     = (int16_t *)ch_tmp_buf; 
   int16_t scale_factor = (1.0f/(float)(prs_cfg->NumPRSSymbols))*(1<<15);
   int16_t num_pilots   = (12/prs_cfg->CombSize)*prs_cfg->NumRB;
-  int16_t first_half   = frame_params->ofdm_symbol_size - frame_params->first_carrier_offset;
-  int16_t second_half  = (prs_cfg->NumRB*12) - first_half;
-  int16_t start_offset = NR_PRS_IDFT_OVERSAMP_FACTOR*frame_params->ofdm_symbol_size - first_half;
+  int16_t first_half = frame_params->ofdm_symbol_size - frame_params->first_carrier_offset;
+  int16_t second_half = (prs_cfg->NumRB * 12) - first_half;
+  int16_t start_offset = NR_PRS_IDFT_OVERSAMP_FACTOR * frame_params->ofdm_symbol_size - first_half;
   LOG_D(PHY, "start_offset %d, first_half %d, second_half %d\n", start_offset, first_half, second_half);
 
   int16_t k_prime_table[K_PRIME_TABLE_ROW_SIZE][K_PRIME_TABLE_COL_SIZE] = PRS_K_PRIME_TABLE;
@@ -142,10 +139,11 @@ int nr_prs_channel_estimation(uint8_t gNB_id,
     for (rxAnt=0; rxAnt < frame_params->nb_antennas_rx; rxAnt++)
     {
       // reset variables
-      snr = 0; rsrp = 0;
-      
+      snr = 0;
+      rsrp = 0;
+
       // calculate RE offset
-      k = (prs_cfg->REOffset+k_prime) % prs_cfg->CombSize + prs_cfg->RBOffset*12 + frame_params->first_carrier_offset;
+      k = (prs_cfg->REOffset + k_prime) % prs_cfg->CombSize + prs_cfg->RBOffset * 12 + frame_params->first_carrier_offset;
 
       // Channel estimation and interpolation
       pil       = (int16_t *)&mod_prs[0];
@@ -187,8 +185,8 @@ int nr_prs_channel_estimation(uint8_t gNB_id,
 		    	       ch_tmp,
 		    	       8);
 
-        //SNR & RSRP estimation
-        rsrp += squaredMod(*((c16_t*)rxF));
+        // SNR & RSRP estimation
+        rsrp += squaredMod(*((c16_t *)rxF));
         noiseFig[0] = rxF[0] - (int16_t)(((int32_t)ch[0]*pil[0] - (int32_t)ch[1]*pil[1])>>15);
         noiseFig[1] = rxF[1] - (int16_t)(((int32_t)ch[1]*pil[0] + (int32_t)ch[0]*pil[1])>>15);
         snr += 10*log10(squaredMod(*(c16_t*)rxF) - squaredMod(*(c16_t*)noiseFig)) - 10*log10(squaredMod(*(c16_t*)noiseFig));
@@ -218,9 +216,9 @@ int nr_prs_channel_estimation(uint8_t gNB_id,
 		        	       ch_tmp,
 		        	       8);
           }
-          
-          //SNR & RSRP estimation
-          rsrp += squaredMod(*((c16_t*)rxF));
+
+          // SNR & RSRP estimation
+          rsrp += squaredMod(*((c16_t *)rxF));
           noiseFig[0] = rxF[0] - (int16_t)(((int32_t)ch[0]*pil[0] - (int32_t)ch[1]*pil[1])>>15);
           noiseFig[1] = rxF[1] - (int16_t)(((int32_t)ch[1]*pil[0] + (int32_t)ch[0]*pil[1])>>15);
           snr += 10*log10(squaredMod(*(c16_t*)rxF) - squaredMod(*(c16_t*)noiseFig)) - 10*log10(squaredMod(*(c16_t*)noiseFig));
@@ -247,9 +245,9 @@ int nr_prs_channel_estimation(uint8_t gNB_id,
 		        	       ch_tmp,
 		        	       8);
           }
-          
-          //SNR & RSRP estimation
-          rsrp += squaredMod(*((c16_t*)rxF));
+
+          // SNR & RSRP estimation
+          rsrp += squaredMod(*((c16_t *)rxF));
           noiseFig[0] = rxF[0] - (int16_t)(((int32_t)ch[0]*pil[0] - (int32_t)ch[1]*pil[1])>>15);
           noiseFig[1] = rxF[1] - (int16_t)(((int32_t)ch[1]*pil[0] + (int32_t)ch[0]*pil[1])>>15);
           snr += 10*log10(squaredMod(*((c16_t*)rxF)) - squaredMod(*((c16_t*)noiseFig))) - 10*log10(squaredMod(*((c16_t*)noiseFig)));
@@ -270,13 +268,23 @@ int nr_prs_channel_estimation(uint8_t gNB_id,
 	      	       ch_tmp,
 	      	       8);
 
-        //SNR & RSRP estimation
-        rsrp += squaredMod(*((c16_t*)rxF));
-        noiseFig[0] = rxF[0] - (int16_t)(((int32_t)ch[0]*pil[0] - (int32_t)ch[1]*pil[1])>>15);
-        noiseFig[1] = rxF[1] - (int16_t)(((int32_t)ch[1]*pil[0] + (int32_t)ch[0]*pil[1])>>15);
-        snr += 10*log10(squaredMod(*((c16_t*)rxF)) - squaredMod(*((c16_t*)noiseFig))) - 10*log10(squaredMod(*((c16_t*)noiseFig)));
+        // SNR & RSRP estimation
+        rsrp += squaredMod(*((c16_t *)rxF));
+        noiseFig[0] = rxF[0] - (int16_t)(((int32_t)ch[0] * pil[0] - (int32_t)ch[1] * pil[1]) >> 15);
+        noiseFig[1] = rxF[1] - (int16_t)(((int32_t)ch[1] * pil[0] + (int32_t)ch[0] * pil[1]) >> 15);
+        snr += 10 * log10(squaredMod(*((c16_t *)rxF)) - squaredMod(*((c16_t *)noiseFig))) - 10 * log10(squaredMod(*((c16_t *)noiseFig)));
 #ifdef DEBUG_PRS_PRINTS
-        printf("[Rx %d] pilot %3d, SNR %+2d dB: rxF - > (%+3d, %+3d) addr %p  ch -> (%+3d, %+3d), pil -> (%+d, %+d) \n", rxAnt, num_pilots-1, snr/num_pilots, rxF[0],rxF[1],&rxF[0],ch[0],ch[1],pil[0],pil[1]);
+        printf("[Rx %d] pilot %3d, SNR %+2d dB: rxF - > (%+3d, %+3d) addr %p  ch -> (%+3d, %+3d), pil -> (%+d, %+d) \n",
+               rxAnt,
+               num_pilots - 1,
+               snr / num_pilots,
+               rxF[0],
+               rxF[1],
+               &rxF[0],
+               ch[0],
+               ch[1],
+               pil[0],
+               pil[1]);
 #endif
       }
       else if(prs_cfg->CombSize == 4)
@@ -332,9 +340,9 @@ int nr_prs_channel_estimation(uint8_t gNB_id,
 	      	       ch,
 	      	       ch_tmp,
 	      	       16);
-        
-        //SNR & RSRP estimation
-        rsrp += squaredMod(*((c16_t*)rxF));
+
+        // SNR & RSRP estimation
+        rsrp += squaredMod(*((c16_t *)rxF));
         noiseFig[0] = rxF[0] - (int16_t)(((int32_t)ch[0]*pil[0] - (int32_t)ch[1]*pil[1])>>15);
         noiseFig[1] = rxF[1] - (int16_t)(((int32_t)ch[1]*pil[0] + (int32_t)ch[0]*pil[1])>>15);
         snr += 10*log10(squaredMod(*((c16_t*)rxF)) - squaredMod(*((c16_t*)noiseFig))) - 10*log10(squaredMod(*((c16_t*)noiseFig)));
@@ -352,8 +360,8 @@ int nr_prs_channel_estimation(uint8_t gNB_id,
 	      	       ch_tmp,
 	      	       16);
 
-        //SNR & RSRP estimation
-        rsrp += squaredMod(*((c16_t*)rxF));
+        // SNR & RSRP estimation
+        rsrp += squaredMod(*((c16_t *)rxF));
         noiseFig[0] = rxF[0] - (int16_t)(((int32_t)ch[0]*pil[0] - (int32_t)ch[1]*pil[1])>>15);
         noiseFig[1] = rxF[1] - (int16_t)(((int32_t)ch[1]*pil[0] + (int32_t)ch[0]*pil[1])>>15);
         snr += 10*log10(squaredMod(*((c16_t*)rxF)) - squaredMod(*((c16_t*)noiseFig))) - 10*log10(squaredMod(*((c16_t*)noiseFig)));
@@ -374,9 +382,9 @@ int nr_prs_channel_estimation(uint8_t gNB_id,
 	      	         ch,
 	      	         ch_tmp,
 	      	         16);
-        
-          //SNR & RSRP estimation
-          rsrp += squaredMod(*((c16_t*)rxF));
+
+          // SNR & RSRP estimation
+          rsrp += squaredMod(*((c16_t *)rxF));
           noiseFig[0] = rxF[0] - (int16_t)(((int32_t)ch[0]*pil[0] - (int32_t)ch[1]*pil[1])>>15);
           noiseFig[1] = rxF[1] - (int16_t)(((int32_t)ch[1]*pil[0] + (int32_t)ch[0]*pil[1])>>15);
           snr += 10*log10(squaredMod(*((c16_t*)rxF)) - squaredMod(*((c16_t*)noiseFig))) - 10*log10(squaredMod(*((c16_t*)noiseFig)));
@@ -396,9 +404,9 @@ int nr_prs_channel_estimation(uint8_t gNB_id,
 	      	       ch,
 	      	       ch_tmp,
 	      	       16);
-        
-        //SNR & RSRP estimation
-        rsrp += squaredMod(*((c16_t*)rxF));
+
+        // SNR & RSRP estimation
+        rsrp += squaredMod(*((c16_t *)rxF));
         noiseFig[0] = rxF[0] - (int16_t)(((int32_t)ch[0]*pil[0] - (int32_t)ch[1]*pil[1])>>15);
         noiseFig[1] = rxF[1] - (int16_t)(((int32_t)ch[1]*pil[0] + (int32_t)ch[0]*pil[1])>>15);
         snr += 10*log10(squaredMod(*((c16_t*)rxF)) - squaredMod(*((c16_t*)noiseFig))) - 10*log10(squaredMod(*((c16_t*)noiseFig)));
@@ -415,9 +423,9 @@ int nr_prs_channel_estimation(uint8_t gNB_id,
 	      	       ch,
 	      	       ch_tmp,
 	      	       16);
-        
-        //SNR & RSRP estimation
-        rsrp += squaredMod(*((c16_t*)rxF));
+
+        // SNR & RSRP estimation
+        rsrp += squaredMod(*((c16_t *)rxF));
         noiseFig[0] = rxF[0] - (int16_t)(((int32_t)ch[0]*pil[0] - (int32_t)ch[1]*pil[1])>>15);
         noiseFig[1] = rxF[1] - (int16_t)(((int32_t)ch[1]*pil[0] + (int32_t)ch[0]*pil[1])>>15);
         snr += 10*log10(squaredMod(*((c16_t*)rxF)) - squaredMod(*((c16_t*)noiseFig))) - 10*log10(squaredMod(*((c16_t*)noiseFig)));
@@ -429,10 +437,10 @@ int nr_prs_channel_estimation(uint8_t gNB_id,
       {
         AssertFatal((prs_cfg->CombSize == 2)||(prs_cfg->CombSize == 4), "[%s] DL PRS CombSize other than 2 and 4 are NOT supported currently. Exiting!!!", __FUNCTION__);
       }
-      
+
       // average out the SNR and RSRP computed
-      prs_meas[rxAnt]->snr  = snr/(float)num_pilots;
-      prs_meas[rxAnt]->rsrp = rsrp/(float)num_pilots;
+      prs_meas[rxAnt]->snr = snr / (float)num_pilots;
+      prs_meas[rxAnt]->rsrp = rsrp / (float)num_pilots;
 
       //reset channel pointer
       ch_tmp = (int16_t*)ch_tmp_buf;
@@ -463,9 +471,9 @@ int nr_prs_channel_estimation(uint8_t gNB_id,
 
     // Place PRS channel estimates in FFT shifted format
     if(first_half > 0)
-      memcpy((int16_t *)&chF_interpol[rxAnt][start_offset], &ch_tmp[0], first_half*sizeof(int32_t));
+      memcpy((int16_t *)&chF_interpol[rxAnt][start_offset], &ch_tmp[0], first_half * sizeof(int32_t));
     if(second_half > 0)
-      memcpy((int16_t *)&chF_interpol[rxAnt][0], &ch_tmp[first_half<<1], second_half*sizeof(int32_t));
+      memcpy((int16_t *)&chF_interpol[rxAnt][0], &ch_tmp[first_half << 1], second_half * sizeof(int32_t));
 
     // Time domain IMPULSE response
     idft_size_idx_t idftsizeidx;
@@ -549,32 +557,36 @@ int nr_prs_channel_estimation(uint8_t gNB_id,
          (int16_t *)&chT_interpol[rxAnt][0],1);
 
     // peak estimator
-    mean_val = squaredMod(((c16_t*)ch_tmp)[(prs_cfg->NumRB*12)>>1]);
-    peak_estimator(&chT_interpol[rxAnt][0],
-                   NR_PRS_IDFT_OVERSAMP_FACTOR*frame_params->ofdm_symbol_size,
-                   &prs_toa,
-                   &ch_pwr,
-                   mean_val);
+    mean_val = squaredMod(((c16_t *)ch_tmp)[(prs_cfg->NumRB * 12) >> 1]);
+    peak_estimator(&chT_interpol[rxAnt][0], NR_PRS_IDFT_OVERSAMP_FACTOR * frame_params->ofdm_symbol_size, &prs_toa, &ch_pwr, mean_val);
 
     // adjusting the rx_gains for channel peak power
-    ch_pwr_dbm =  10*log10(ch_pwr)+30
-                  - 10*log10(pow(2,30)) - ((int)openair0_cfg[0].rx_gain[0]
-                  - (int)openair0_cfg[0].rx_gain_offset[0]) - dB_fixed(frame_params->ofdm_symbol_size);
-    
-    prs_meas[rxAnt]->rsrp_dBm = 10*log10(prs_meas[rxAnt]->rsrp) + 30 
-                                            - 10*log10(pow(2,30)) - ((int)openair0_cfg[0].rx_gain[0]
-                                            - (int)openair0_cfg[0].rx_gain_offset[0]) - dB_fixed(ue->frame_parms.ofdm_symbol_size);
-    
+    ch_pwr_dbm = 10 * log10(ch_pwr) + 30 - 10 * log10(pow(2, 30)) - ((int)openair0_cfg[0].rx_gain[0] - (int)openair0_cfg[0].rx_gain_offset[0]) - dB_fixed(frame_params->ofdm_symbol_size);
+
+    prs_meas[rxAnt]->rsrp_dBm =
+        10 * log10(prs_meas[rxAnt]->rsrp) + 30 - 10 * log10(pow(2, 30)) - ((int)openair0_cfg[0].rx_gain[0] - (int)openair0_cfg[0].rx_gain_offset[0]) - dB_fixed(ue->frame_parms.ofdm_symbol_size);
+
     //prs measurements
     prs_meas[rxAnt]->gNB_id     = gNB_id;
     prs_meas[rxAnt]->sfn        = proc->frame_rx;
     prs_meas[rxAnt]->slot       = proc->nr_slot_rx;
     prs_meas[rxAnt]->rxAnt_idx  = rxAnt;
     prs_meas[rxAnt]->dl_aoa     = rsc_id;
-    prs_meas[rxAnt]->dl_toa     = prs_toa/(float)NR_PRS_IDFT_OVERSAMP_FACTOR;
-    if ((frame_params->ofdm_symbol_size - prs_meas[rxAnt]->dl_toa) < frame_params->ofdm_symbol_size/2)
-      prs_meas[rxAnt]->dl_toa     -= (frame_params->ofdm_symbol_size);
-    LOG_I(PHY, "[gNB %d][rsc %d][Rx %d][sfn %d][slot %d] DL PRS ToA ==> %.1f / %d samples, peak channel power %.1f dBm, SNR %+.1f dB, rsrp %+.1f dBm\n", gNB_id, rsc_id, rxAnt, proc->frame_rx, proc->nr_slot_rx, prs_meas[rxAnt]->dl_toa, frame_params->ofdm_symbol_size, ch_pwr_dbm, prs_meas[rxAnt]->snr, prs_meas[rxAnt]->rsrp_dBm);
+    prs_meas[rxAnt]->dl_toa = prs_toa / (float)NR_PRS_IDFT_OVERSAMP_FACTOR;
+    if ((frame_params->ofdm_symbol_size - prs_meas[rxAnt]->dl_toa) < frame_params->ofdm_symbol_size / 2)
+      prs_meas[rxAnt]->dl_toa -= (frame_params->ofdm_symbol_size);
+    LOG_I(PHY,
+          "[gNB %d][rsc %d][Rx %d][sfn %d][slot %d] DL PRS ToA ==> %.1f / %d samples, peak channel power %.1f dBm, SNR %+.1f dB, rsrp %+.1f dBm\n",
+          gNB_id,
+          rsc_id,
+          rxAnt,
+          proc->frame_rx,
+          proc->nr_slot_rx,
+          prs_meas[rxAnt]->dl_toa,
+          frame_params->ofdm_symbol_size,
+          ch_pwr_dbm,
+          prs_meas[rxAnt]->snr,
+          prs_meas[rxAnt]->rsrp_dBm);
 
 #ifdef DEBUG_PRS_CHEST
     sprintf(filename, "%s%i%s", "PRSpilot_", rxAnt, ".m");
@@ -595,13 +607,21 @@ int nr_prs_channel_estimation(uint8_t gNB_id,
       T_INT(proc->frame_rx), T_INT(proc->nr_slot_rx),
       T_INT(rxAnt), T_BUFFER(&rxdataF[rxAnt][0], frame_params->samples_per_slot_wCP*sizeof(int32_t)));
 
-    T(T_UE_PHY_DL_CHANNEL_ESTIMATE_FREQ, T_INT(gNB_id), T_INT(rsc_id),
-      T_INT(proc->frame_rx), T_INT(proc->nr_slot_rx),
-      T_INT(rxAnt), T_BUFFER(&chF_interpol[rxAnt][0], NR_PRS_IDFT_OVERSAMP_FACTOR*frame_params->ofdm_symbol_size*sizeof(int32_t)));
-
-    T(T_UE_PHY_DL_CHANNEL_ESTIMATE, T_INT(gNB_id), T_INT(rsc_id),
-      T_INT(proc->frame_rx), T_INT(proc->nr_slot_rx),
-      T_INT(rxAnt), T_BUFFER(&chT_interpol[rxAnt][0], NR_PRS_IDFT_OVERSAMP_FACTOR*frame_params->ofdm_symbol_size*sizeof(int32_t)));
+    T(T_UE_PHY_DL_CHANNEL_ESTIMATE_FREQ,
+      T_INT(gNB_id),
+      T_INT(rsc_id),
+      T_INT(proc->frame_rx),
+      T_INT(proc->nr_slot_rx),
+      T_INT(rxAnt),
+      T_BUFFER(&chF_interpol[rxAnt][0], NR_PRS_IDFT_OVERSAMP_FACTOR * frame_params->ofdm_symbol_size * sizeof(int32_t)));
+
+    T(T_UE_PHY_DL_CHANNEL_ESTIMATE,
+      T_INT(gNB_id),
+      T_INT(rsc_id),
+      T_INT(proc->frame_rx),
+      T_INT(proc->nr_slot_rx),
+      T_INT(rxAnt),
+      T_BUFFER(&chT_interpol[rxAnt][0], NR_PRS_IDFT_OVERSAMP_FACTOR * frame_params->ofdm_symbol_size * sizeof(int32_t)));
   }
 
   return(0);
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c
index 8141ece1c9..a03555f772 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c
@@ -187,7 +187,7 @@ int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_ini
 
 
 #ifdef DEBUG_INITIAL_SYNCH
-    LOG_I(PHY,"[UE%d] Initial sync: pbch decoded sucessfully, ssb index %d\n",ue->Mod_id, frame_parms->ssb_index);
+    LOG_I(PHY, "[UE%d] Initial sync: pbch decoded sucessfully, ssb index %d\n", ue->Mod_id, frame_parms->ssb_index);
 #endif
     return(0);
   } else {
diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h
index a7b22cc211..0741291fb4 100644
--- a/openair1/PHY/defs_nr_common.h
+++ b/openair1/PHY/defs_nr_common.h
@@ -289,11 +289,11 @@ typedef struct {
     int32_t sfn;
     int8_t  slot;
     int8_t  rxAnt_idx;
-    float   dl_toa;
+    float dl_toa;
     int32_t dl_aoa;
-    float   snr;
-    float   rsrp;
-    float   rsrp_dBm;
+    float snr;
+    float rsrp;
+    float rsrp_dBm;
     int32_t reserved;
 } prs_meas_t;
 
diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c
index 0950cbdd34..3c5c7e250a 100644
--- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c
+++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c
@@ -943,13 +943,7 @@ void pbch_pdcch_processing(PHY_VARS_NR_UE *ue,
                         (j%fp->symbols_per_slot),
                         rxdataF);
           }
-          nr_prs_channel_estimation(gNB_id,
-                                    rsc_id,
-                                    i,
-                                    ue,
-                                    proc,
-                                    fp,
-                                    rxdataF);
+          nr_prs_channel_estimation(gNB_id, rsc_id, i, ue, proc, fp, rxdataF);
         }
       } // for i
     } // for rsc_id
diff --git a/openair2/RRC/NR_UE/main_ue.c b/openair2/RRC/NR_UE/main_ue.c
index bf7e313879..37aff4ff9b 100644
--- a/openair2/RRC/NR_UE/main_ue.c
+++ b/openair2/RRC/NR_UE/main_ue.c
@@ -34,8 +34,9 @@
 #include "rrc_proto.h"
 #include "common/utils/LOG/log.h"
 
-NR_UE_RRC_INST_t* nr_l3_init_ue(char* uecap, char* rrc_config_path, char* reconfig_file, char* rbconfig_file){
-    //LOG_I(RRC, "[MAIN] NR UE MAC initialization...\n");
+NR_UE_RRC_INST_t* nr_l3_init_ue(char* uecap, char* rrc_config_path, char* reconfig_file, char* rbconfig_file)
+{
+  // LOG_I(RRC, "[MAIN] NR UE MAC initialization...\n");
 
-    return openair_rrc_top_init_ue_nr(uecap,rrc_config_path,reconfig_file,rbconfig_file);
+  return openair_rrc_top_init_ue_nr(uecap, rrc_config_path, reconfig_file, rbconfig_file);
 }
diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c
index 9881be47dd..e13274b14a 100644
--- a/openair2/RRC/NR_UE/rrc_UE.c
+++ b/openair2/RRC/NR_UE/rrc_UE.c
@@ -344,7 +344,6 @@ void process_nsa_message(NR_UE_RRC_INST_t *rrc, nsa_message_t nsa_message_type,
 
 }
 
-
 NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* uecap_file, char* rrc_config_path, char* reconfig_file, char* rbconfig_file)
 {
   if(NB_NR_UE_INST > 0) {
@@ -371,11 +370,11 @@ NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* uecap_file, char* rrc_config_
       FILE *fd;
       char filename[1024];
       if (rrc_config_path && reconfig_file)
-        sprintf(filename,"%s/%s",rrc_config_path,reconfig_file);
+        sprintf(filename, "%s/%s", rrc_config_path, reconfig_file);
       else
         sprintf(filename,"reconfig.raw");
-      
-      LOG_I(NR_RRC, "using %s for rrc init[1/2]\n",filename);
+
+      LOG_I(NR_RRC, "using %s for rrc init[1/2]\n", filename);
       fd = fopen(filename,"r");
       char buffer[1024];
       AssertFatal(fd,
@@ -387,11 +386,11 @@ NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* uecap_file, char* rrc_config_
       fclose(fd);
       process_nsa_message(NR_UE_rrc_inst, nr_SecondaryCellGroupConfig_r15, buffer,msg_len);
       if (rrc_config_path && rbconfig_file)
-        sprintf(filename,"%s/%s",rrc_config_path,rbconfig_file);
+        sprintf(filename, "%s/%s", rrc_config_path, rbconfig_file);
       else
         sprintf(filename,"rbconfig.raw");
-      
-      LOG_I(NR_RRC, "using %s for rrc init[2/2]\n",filename);
+
+      LOG_I(NR_RRC, "using %s for rrc init[2/2]\n", filename);
       fd = fopen(filename,"r");
       AssertFatal(fd,
                   "cannot read file %s: errno %d, %s\n",
@@ -418,7 +417,6 @@ NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* uecap_file, char* rrc_config_
   return NR_UE_rrc_inst;
 }
 
-
 int8_t nr_ue_process_rlc_bearer_list(NR_CellGroupConfig_t *cell_group_config){
 
     return 0;
diff --git a/openair2/RRC/NR_UE/rrc_proto.h b/openair2/RRC/NR_UE/rrc_proto.h
index a10b3570ae..94ea697c87 100644
--- a/openair2/RRC/NR_UE/rrc_proto.h
+++ b/openair2/RRC/NR_UE/rrc_proto.h
@@ -56,16 +56,14 @@ extern queue_t nr_ul_tti_req_queue;
 //  main_rrc.c
 //
 /**\brief Layer 3 initialization*/
-NR_UE_RRC_INST_t* nr_l3_init_ue(char*,char*,char*,char*);
+NR_UE_RRC_INST_t *nr_l3_init_ue(char *, char *, char *, char *);
 
 //
 //  UE_rrc.c
 //
 
 /**\brief Initial the top level RRC structure instance*/
-NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char*,char*,char*,char*);
-
-
+NR_UE_RRC_INST_t *openair_rrc_top_init_ue_nr(char *, char *, char *, char *);
 
 /**\brief Decode RRC Connection Reconfiguration, sent from E-UTRA RRC Connection Reconfiguration v1510 carring EN-DC config
    \param buffer  encoded NR-RRC-Connection-Reconfiguration/Secondary-Cell-Group-Config message.
-- 
2.26.2