clarify and indent correctly the function initial sync
This commit is contained in:
@@ -311,7 +311,7 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc,
|
|||||||
fp->dl_CarrierFreq,
|
fp->dl_CarrierFreq,
|
||||||
fp->N_RB_DL,
|
fp->N_RB_DL,
|
||||||
numGscn);
|
numGscn);
|
||||||
|
DevAssert(numGscn);
|
||||||
task_ans_t ans;
|
task_ans_t ans;
|
||||||
init_task_ans(&ans, numGscn);
|
init_task_ans(&ans, numGscn);
|
||||||
nr_ue_ssb_scan_t ssb_info[numGscn];
|
nr_ue_ssb_scan_t ssb_info[numGscn];
|
||||||
@@ -342,8 +342,7 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Collect the scan results
|
// Collect the scan results
|
||||||
nr_ue_ssb_scan_t res = {0};
|
nr_ue_ssb_scan_t *res = NULL;
|
||||||
if (numGscn > 0) {
|
|
||||||
join_task_ans(&ans);
|
join_task_ans(&ans);
|
||||||
for (int i = 0; i < numGscn; i++) {
|
for (int i = 0; i < numGscn; i++) {
|
||||||
nr_ue_ssb_scan_t *ssbInfo = &ssb_info[i];
|
nr_ue_ssb_scan_t *ssbInfo = &ssb_info[i];
|
||||||
@@ -355,26 +354,26 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc,
|
|||||||
ssbInfo->gscnInfo.ssRef,
|
ssbInfo->gscnInfo.ssRef,
|
||||||
ssbInfo->pssCorrPeakPower,
|
ssbInfo->pssCorrPeakPower,
|
||||||
ssbInfo->pssCorrAvgPower);
|
ssbInfo->pssCorrAvgPower);
|
||||||
if (!res.syncRes.cell_detected) { // take the first cell detected
|
// take the first cell detected
|
||||||
res = *ssbInfo;
|
if (!res)
|
||||||
}
|
res = ssbInfo;
|
||||||
}
|
}
|
||||||
for (int ant = 0; ant < fp->nb_antennas_rx; ant++) {
|
for (int ant = 0; ant < fp->nb_antennas_rx; ant++) {
|
||||||
free(ssbInfo->rxdata[ant]);
|
free(ssbInfo->rxdata[ant]);
|
||||||
}
|
}
|
||||||
free(ssbInfo->rxdata);
|
free(ssbInfo->rxdata);
|
||||||
}
|
ssbInfo->rxdata = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set globals based on detected cell
|
// Set globals based on detected cell
|
||||||
if (res.syncRes.cell_detected) {
|
if (res) {
|
||||||
fp->Nid_cell = res.nidCell;
|
fp->Nid_cell = res->nidCell;
|
||||||
fp->ssb_start_subcarrier = res.gscnInfo.ssbFirstSC;
|
fp->ssb_start_subcarrier = res->gscnInfo.ssbFirstSC;
|
||||||
fp->half_frame_bit = res.halfFrameBit;
|
fp->half_frame_bit = res->halfFrameBit;
|
||||||
fp->ssb_index = res.ssbIndex;
|
fp->ssb_index = res->ssbIndex;
|
||||||
ue->symbol_offset = res.symbolOffset;
|
ue->symbol_offset = res->symbolOffset;
|
||||||
ue->common_vars.freq_offset = res.freqOffset;
|
ue->common_vars.freq_offset = res->freqOffset;
|
||||||
ue->adjust_rxgain = res.adjust_rxgain;
|
ue->adjust_rxgain = res->adjust_rxgain;
|
||||||
}
|
}
|
||||||
|
|
||||||
// In initial sync, we indicate PBCH to MAC after the scan is complete.
|
// In initial sync, we indicate PBCH to MAC after the scan is complete.
|
||||||
@@ -389,7 +388,7 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc,
|
|||||||
NULL,
|
NULL,
|
||||||
number_pdus,
|
number_pdus,
|
||||||
proc,
|
proc,
|
||||||
res.syncRes.cell_detected ? (void *)&res.pbchResult : NULL,
|
res ? (void *)&res->pbchResult : NULL,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (ue->if_inst && ue->if_inst->dl_indication)
|
if (ue->if_inst && ue->if_inst->dl_indication)
|
||||||
@@ -398,36 +397,36 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc,
|
|||||||
|
|
||||||
LOG_D(PHY, "nr_initial sync ue RB_DL %d\n", fp->N_RB_DL);
|
LOG_D(PHY, "nr_initial sync ue RB_DL %d\n", fp->N_RB_DL);
|
||||||
|
|
||||||
if (res.syncRes.cell_detected) {
|
if (res) {
|
||||||
// digital compensation of FFO for SSB symbols
|
// digital compensation of FFO for SSB symbols
|
||||||
if (res.freqOffset && ue->UE_fo_compensation) {
|
if (res->freqOffset && ue->UE_fo_compensation) {
|
||||||
// In SA we need to perform frequency offset correction until the end of buffer because we need to decode SIB1
|
// In SA we need to perform frequency offset correction until the end of buffer because we need to decode SIB1
|
||||||
// and we do not know yet in which slot it goes.
|
// and we do not know yet in which slot it goes.
|
||||||
compensate_freq_offset(ue->common_vars.rxdata, fp, res.freqOffset, res.syncRes.frame_id);
|
compensate_freq_offset(ue->common_vars.rxdata, fp, res->freqOffset, res->syncRes.frame_id);
|
||||||
}
|
}
|
||||||
// sync at symbol ue->symbol_offset
|
// sync at symbol ue->symbol_offset
|
||||||
// computing the offset wrt the beginning of the frame
|
// computing the offset wrt the beginning of the frame
|
||||||
int mu = fp->numerology_index;
|
int mu = fp->numerology_index;
|
||||||
// number of symbols with different prefix length
|
// number of symbols with different prefix length
|
||||||
// every 7*(1<<mu) symbols there is a different prefix length (38.211 5.3.1)
|
// every 7*(1<<mu) symbols there is a different prefix length (38.211 5.3.1)
|
||||||
int n_symb_prefix0 = (res.symbolOffset / (7 * (1 << mu))) + 1;
|
int n_symb_prefix0 = (res->symbolOffset / (7 * (1 << mu))) + 1;
|
||||||
const int sync_pos_frame = n_symb_prefix0 * (fp->ofdm_symbol_size + fp->nb_prefix_samples0)
|
const int sync_pos_frame = n_symb_prefix0 * (fp->ofdm_symbol_size + fp->nb_prefix_samples0)
|
||||||
+ (res.symbolOffset - n_symb_prefix0) * (fp->ofdm_symbol_size + fp->nb_prefix_samples);
|
+ (res->symbolOffset - n_symb_prefix0) * (fp->ofdm_symbol_size + fp->nb_prefix_samples);
|
||||||
// for a correct computation of frame number to sync with the one decoded at MIB we need to take into account in which of
|
// for a correct computation of frame number to sync with the one decoded at MIB we need to take into account in which of
|
||||||
// the n_frames we got sync
|
// the n_frames we got sync
|
||||||
ue->init_sync_frame = n_frames - 1 - res.syncRes.frame_id;
|
ue->init_sync_frame = n_frames - 1 - res->syncRes.frame_id;
|
||||||
|
|
||||||
// we also need to take into account the shift by samples_per_frame in case the if is true
|
// we also need to take into account the shift by samples_per_frame in case the if is true
|
||||||
if (res.ssbOffset < sync_pos_frame) {
|
if (res->ssbOffset < sync_pos_frame) {
|
||||||
res.syncRes.rx_offset = fp->samples_per_frame - sync_pos_frame + res.ssbOffset;
|
res->syncRes.rx_offset = fp->samples_per_frame - sync_pos_frame + res->ssbOffset;
|
||||||
ue->init_sync_frame += 1;
|
ue->init_sync_frame += 1;
|
||||||
} else
|
} else
|
||||||
res.syncRes.rx_offset = res.ssbOffset - sync_pos_frame;
|
res->syncRes.rx_offset = res->ssbOffset - sync_pos_frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res.syncRes.cell_detected) {
|
if (res) {
|
||||||
LOG_I(PHY, "[UE%d] In synch, rx_offset %d samples\n", ue->Mod_id, res.syncRes.rx_offset);
|
LOG_I(PHY, "[UE%d] In synch, rx_offset %d samples\n", ue->Mod_id, res->syncRes.rx_offset);
|
||||||
LOG_I(PHY, "[UE %d] Measured Carrier Frequency offset %d Hz\n", ue->Mod_id, res.freqOffset);
|
LOG_I(PHY, "[UE %d] Measured Carrier Frequency offset %d Hz\n", ue->Mod_id, res->freqOffset);
|
||||||
} else {
|
} else {
|
||||||
#ifdef DEBUG_INITIAL_SYNC
|
#ifdef DEBUG_INITIAL_SYNC
|
||||||
LOG_I(PHY,"[UE%d] Initial sync : PBCH not ok\n",ue->Mod_id);
|
LOG_I(PHY,"[UE%d] Initial sync : PBCH not ok\n",ue->Mod_id);
|
||||||
@@ -438,7 +437,7 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// gain control
|
// gain control
|
||||||
if (!res.syncRes.cell_detected) { // we are not synched, so we cannot use rssi measurement (which is based on channel estimates)
|
if (!res) { // we are not synched, so we cannot use rssi measurement (which is based on channel estimates)
|
||||||
int rx_power = 0;
|
int rx_power = 0;
|
||||||
|
|
||||||
// do a measurement on the best guess of the PSS
|
// do a measurement on the best guess of the PSS
|
||||||
@@ -466,5 +465,8 @@ nr_initial_sync_t nr_initial_sync(UE_nr_rxtx_proc_t *proc,
|
|||||||
}
|
}
|
||||||
// exit_fun("debug exit");
|
// exit_fun("debug exit");
|
||||||
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_INITIAL_UE_SYNC, VCD_FUNCTION_OUT);
|
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_INITIAL_UE_SYNC, VCD_FUNCTION_OUT);
|
||||||
return res.syncRes;
|
if (res)
|
||||||
|
return res->syncRes;
|
||||||
|
else
|
||||||
|
return (nr_initial_sync_t){.cell_detected = false};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user