From fe0c9ba075cdae5c4edc0152cee73434b77a192a Mon Sep 17 00:00:00 2001
From: Francesco Mani <francesco.mani@eurecom.fr>
Date: Wed, 27 Nov 2019 09:11:51 +0100
Subject: [PATCH] fix for number of slots in half frame for different
 numerologies

---
 openair1/PHY/INIT/nr_parms.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c
index 21b1e176ffc..6a13ac88a3e 100644
--- a/openair1/PHY/INIT/nr_parms.c
+++ b/openair1/PHY/INIT/nr_parms.c
@@ -83,10 +83,12 @@ int nr_is_ssb_slot(nfapi_nr_config_request_t *cfg, int slot, int frame)
 {
 
   uint8_t n_hf;
-  uint16_t p;
+  uint16_t p,mu,hf_slots;
   uint64_t ssb_map;
   int rel_slot;
 
+  mu = cfg->subframe_config.numerology_index_mu.value;
+
   ssb_map = cfg->sch_config.ssb_scg_position_in_burst.value;
   p = cfg->sch_config.ssb_periodicity.value;
   n_hf = cfg->sch_config.half_frame_index.value;
@@ -95,16 +97,17 @@ int nr_is_ssb_slot(nfapi_nr_config_request_t *cfg, int slot, int frame)
   if ( (p>10) && (frame%(p/10)) )  
     return 0;
   else {
+    hf_slots = (10<<mu)>>1; // number of slots per half frame
     // if SSB periodicity is 5ms, they are transmitted in both half frames
     if ( p == 5) {
-      if (slot<10)  //the value 10 needs to be changed for other numerologies (using slots_per_frame) in this function
+      if (slot<hf_slots) 
         n_hf=0;
       else
         n_hf=1;
     }
 
-    // to set a effective slot number between 0 to 9 in the half frame where the SSB is supposed to be
-    rel_slot = (n_hf)? (slot-10) : slot;
+    // to set a effective slot number between 0 to hf_slots-1 in the half frame where the SSB is supposed to be
+    rel_slot = (n_hf)? (slot-hf_slots) : slot;
 
     // there are two potential SSB per slot
     return ( ((ssb_map >> rel_slot*2) & 0x01) || ((ssb_map >> (1+rel_slot*2)) & 0x01) ); 
-- 
GitLab