mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
435 lines
14 KiB
C
435 lines
14 KiB
C
11 years ago
|
/**
|
||
|
*
|
||
|
* \section COPYRIGHT
|
||
|
*
|
||
9 years ago
|
* Copyright 2013-2015 Software Radio Systems Limited
|
||
11 years ago
|
*
|
||
|
* \section LICENSE
|
||
11 years ago
|
*
|
||
10 years ago
|
* This file is part of the srsLTE library.
|
||
11 years ago
|
*
|
||
10 years ago
|
* srsLTE is free software: you can redistribute it and/or modify
|
||
10 years ago
|
* it under the terms of the GNU Affero General Public License as
|
||
11 years ago
|
* published by the Free Software Foundation, either version 3 of
|
||
|
* the License, or (at your option) any later version.
|
||
|
*
|
||
10 years ago
|
* srsLTE is distributed in the hope that it will be useful,
|
||
11 years ago
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
10 years ago
|
* GNU Affero General Public License for more details.
|
||
11 years ago
|
*
|
||
10 years ago
|
* A copy of the GNU Affero General Public License can be found in
|
||
11 years ago
|
* the LICENSE file in the top-level directory of this distribution
|
||
|
* and at http://www.gnu.org/licenses/.
|
||
|
*
|
||
11 years ago
|
*/
|
||
|
|
||
11 years ago
|
|
||
11 years ago
|
#include <strings.h>
|
||
|
#include <string.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <complex.h>
|
||
|
#include <math.h>
|
||
|
|
||
10 years ago
|
#include "srslte/sync/pss.h"
|
||
10 years ago
|
#include "srslte/dft/dft.h"
|
||
10 years ago
|
#include "srslte/utils/vector.h"
|
||
|
#include "srslte/utils/convolution.h"
|
||
|
#include "srslte/utils/debug.h"
|
||
11 years ago
|
|
||
11 years ago
|
|
||
9 years ago
|
int srslte_pss_synch_init_N_id_2(cf_t *pss_signal_freq, cf_t *pss_signal_time,
|
||
9 years ago
|
uint32_t N_id_2, uint32_t fft_size, int cfo_i) {
|
||
10 years ago
|
srslte_dft_plan_t plan;
|
||
10 years ago
|
cf_t pss_signal_pad[2048];
|
||
10 years ago
|
int ret = SRSLTE_ERROR_INVALID_INPUTS;
|
||
10 years ago
|
|
||
10 years ago
|
if (srslte_N_id_2_isvalid(N_id_2) &&
|
||
10 years ago
|
fft_size <= 2048)
|
||
10 years ago
|
{
|
||
|
|
||
9 years ago
|
srslte_pss_generate(pss_signal_freq, N_id_2);
|
||
10 years ago
|
|
||
|
bzero(pss_signal_pad, fft_size * sizeof(cf_t));
|
||
9 years ago
|
bzero(pss_signal_time, fft_size * sizeof(cf_t));
|
||
|
memcpy(&pss_signal_pad[(fft_size-SRSLTE_PSS_LEN)/2+cfo_i], pss_signal_freq, SRSLTE_PSS_LEN * sizeof(cf_t));
|
||
10 years ago
|
|
||
9 years ago
|
/* Convert signal into the time domain */
|
||
10 years ago
|
if (srslte_dft_plan(&plan, fft_size, SRSLTE_DFT_BACKWARD, SRSLTE_DFT_COMPLEX)) {
|
||
10 years ago
|
return SRSLTE_ERROR;
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
srslte_dft_plan_set_mirror(&plan, true);
|
||
|
srslte_dft_plan_set_dc(&plan, true);
|
||
|
srslte_dft_plan_set_norm(&plan, true);
|
||
9 years ago
|
srslte_dft_run_c(&plan, pss_signal_pad, pss_signal_time);
|
||
11 years ago
|
|
||
9 years ago
|
srslte_vec_conj_cc(pss_signal_time, pss_signal_time, fft_size);
|
||
|
srslte_vec_sc_prod_cfc(pss_signal_time, 1.0/SRSLTE_PSS_LEN, pss_signal_time, fft_size);
|
||
10 years ago
|
|
||
10 years ago
|
srslte_dft_plan_free(&plan);
|
||
10 years ago
|
|
||
10 years ago
|
ret = SRSLTE_SUCCESS;
|
||
11 years ago
|
}
|
||
10 years ago
|
return ret;
|
||
11 years ago
|
}
|
||
|
|
||
10 years ago
|
/* Initializes the PSS synchronization object with fft_size=128
|
||
11 years ago
|
*/
|
||
10 years ago
|
int srslte_pss_synch_init(srslte_pss_synch_t *q, uint32_t frame_size) {
|
||
|
return srslte_pss_synch_init_fft(q, frame_size, 128);
|
||
10 years ago
|
}
|
||
9 years ago
|
|
||
|
int srslte_pss_synch_init_fft(srslte_pss_synch_t *q, uint32_t frame_size, uint32_t fft_size) {
|
||
|
return srslte_pss_synch_init_fft_offset(q, frame_size, fft_size, 0);
|
||
|
}
|
||
|
|
||
10 years ago
|
/* Initializes the PSS synchronization object.
|
||
|
*
|
||
|
* It correlates a signal of frame_size samples with the PSS sequence in the frequency
|
||
|
* domain. The PSS sequence is transformed using fft_size samples.
|
||
|
*/
|
||
9 years ago
|
int srslte_pss_synch_init_fft_offset(srslte_pss_synch_t *q, uint32_t frame_size, uint32_t fft_size, int offset) {
|
||
10 years ago
|
int ret = SRSLTE_ERROR_INVALID_INPUTS;
|
||
10 years ago
|
|
||
|
if (q != NULL) {
|
||
|
|
||
|
uint32_t N_id_2;
|
||
|
uint32_t buffer_size;
|
||
10 years ago
|
bzero(q, sizeof(srslte_pss_synch_t));
|
||
10 years ago
|
|
||
|
q->N_id_2 = 10;
|
||
|
q->fft_size = fft_size;
|
||
|
q->frame_size = frame_size;
|
||
9 years ago
|
q->ema_alpha = 0.2;
|
||
10 years ago
|
|
||
10 years ago
|
buffer_size = fft_size + frame_size + 1;
|
||
9 years ago
|
|
||
10 years ago
|
if (srslte_dft_plan(&q->dftp_input, fft_size, SRSLTE_DFT_FORWARD, SRSLTE_DFT_COMPLEX)) {
|
||
10 years ago
|
fprintf(stderr, "Error creating DFT plan \n");
|
||
|
goto clean_and_exit;
|
||
|
}
|
||
10 years ago
|
srslte_dft_plan_set_mirror(&q->dftp_input, true);
|
||
|
srslte_dft_plan_set_dc(&q->dftp_input, true);
|
||
|
srslte_dft_plan_set_norm(&q->dftp_input, true);
|
||
10 years ago
|
|
||
10 years ago
|
q->tmp_input = srslte_vec_malloc(buffer_size * sizeof(cf_t));
|
||
10 years ago
|
if (!q->tmp_input) {
|
||
|
fprintf(stderr, "Error allocating memory\n");
|
||
11 years ago
|
goto clean_and_exit;
|
||
|
}
|
||
10 years ago
|
|
||
|
bzero(&q->tmp_input[q->frame_size], q->fft_size * sizeof(cf_t));
|
||
|
|
||
10 years ago
|
q->conv_output = srslte_vec_malloc(buffer_size * sizeof(cf_t));
|
||
10 years ago
|
if (!q->conv_output) {
|
||
|
fprintf(stderr, "Error allocating memory\n");
|
||
|
goto clean_and_exit;
|
||
|
}
|
||
10 years ago
|
bzero(q->conv_output, sizeof(cf_t) * buffer_size);
|
||
10 years ago
|
q->conv_output_avg = srslte_vec_malloc(buffer_size * sizeof(float));
|
||
10 years ago
|
if (!q->conv_output_avg) {
|
||
|
fprintf(stderr, "Error allocating memory\n");
|
||
|
goto clean_and_exit;
|
||
|
}
|
||
10 years ago
|
bzero(q->conv_output_avg, sizeof(float) * buffer_size);
|
||
10 years ago
|
#ifdef SRSLTE_PSS_ACCUMULATE_ABS
|
||
|
q->conv_output_abs = srslte_vec_malloc(buffer_size * sizeof(float));
|
||
10 years ago
|
if (!q->conv_output_abs) {
|
||
|
fprintf(stderr, "Error allocating memory\n");
|
||
|
goto clean_and_exit;
|
||
|
}
|
||
10 years ago
|
bzero(q->conv_output_abs, sizeof(float) * buffer_size);
|
||
10 years ago
|
#endif
|
||
10 years ago
|
|
||
10 years ago
|
for (N_id_2=0;N_id_2<3;N_id_2++) {
|
||
9 years ago
|
q->pss_signal_time[N_id_2] = srslte_vec_malloc(buffer_size * sizeof(cf_t));
|
||
|
if (!q->pss_signal_time[N_id_2]) {
|
||
10 years ago
|
fprintf(stderr, "Error allocating memory\n");
|
||
|
goto clean_and_exit;
|
||
|
}
|
||
9 years ago
|
/* The PSS is translated into the time domain for each N_id_2 */
|
||
9 years ago
|
if (srslte_pss_synch_init_N_id_2(q->pss_signal_freq[N_id_2], q->pss_signal_time[N_id_2], N_id_2, fft_size, offset)) {
|
||
10 years ago
|
fprintf(stderr, "Error initiating PSS detector for N_id_2=%d fft_size=%d\n", N_id_2, fft_size);
|
||
|
goto clean_and_exit;
|
||
|
}
|
||
9 years ago
|
bzero(&q->pss_signal_time[N_id_2][q->fft_size], q->frame_size * sizeof(cf_t));
|
||
10 years ago
|
|
||
10 years ago
|
}
|
||
|
#ifdef CONVOLUTION_FFT
|
||
10 years ago
|
if (srslte_conv_fft_cc_init(&q->conv_fft, frame_size, fft_size)) {
|
||
10 years ago
|
fprintf(stderr, "Error initiating convolution FFT\n");
|
||
|
goto clean_and_exit;
|
||
|
}
|
||
|
#endif
|
||
|
|
||
10 years ago
|
srslte_pss_synch_reset(q);
|
||
10 years ago
|
|
||
10 years ago
|
ret = SRSLTE_SUCCESS;
|
||
11 years ago
|
}
|
||
|
|
||
10 years ago
|
clean_and_exit:
|
||
10 years ago
|
if (ret == SRSLTE_ERROR) {
|
||
10 years ago
|
srslte_pss_synch_free(q);
|
||
11 years ago
|
}
|
||
|
return ret;
|
||
11 years ago
|
}
|
||
|
|
||
10 years ago
|
void srslte_pss_synch_free(srslte_pss_synch_t *q) {
|
||
10 years ago
|
uint32_t i;
|
||
|
|
||
|
if (q) {
|
||
|
for (i=0;i<3;i++) {
|
||
9 years ago
|
if (q->pss_signal_time[i]) {
|
||
|
free(q->pss_signal_time[i]);
|
||
10 years ago
|
}
|
||
|
}
|
||
|
#ifdef CONVOLUTION_FFT
|
||
10 years ago
|
srslte_conv_fft_cc_free(&q->conv_fft);
|
||
10 years ago
|
|
||
|
#endif
|
||
|
if (q->tmp_input) {
|
||
|
free(q->tmp_input);
|
||
|
}
|
||
|
if (q->conv_output) {
|
||
|
free(q->conv_output);
|
||
|
}
|
||
10 years ago
|
if (q->conv_output_abs) {
|
||
|
free(q->conv_output_abs);
|
||
|
}
|
||
|
if (q->conv_output_avg) {
|
||
|
free(q->conv_output_avg);
|
||
|
}
|
||
11 years ago
|
|
||
10 years ago
|
bzero(q, sizeof(srslte_pss_synch_t));
|
||
11 years ago
|
}
|
||
11 years ago
|
}
|
||
|
|
||
10 years ago
|
void srslte_pss_synch_reset(srslte_pss_synch_t *q) {
|
||
10 years ago
|
uint32_t buffer_size = q->fft_size + q->frame_size + 1;
|
||
10 years ago
|
bzero(q->conv_output_avg, sizeof(float) * buffer_size);
|
||
10 years ago
|
}
|
||
|
|
||
11 years ago
|
/**
|
||
|
* This function calculates the Zadoff-Chu sequence.
|
||
|
* @param signal Output array.
|
||
|
*/
|
||
10 years ago
|
int srslte_pss_generate(cf_t *signal, uint32_t N_id_2) {
|
||
11 years ago
|
int i;
|
||
|
float arg;
|
||
|
const float root_value[] = { 25.0, 29.0, 34.0 };
|
||
|
int root_idx;
|
||
|
|
||
|
int sign = -1;
|
||
|
|
||
10 years ago
|
if (N_id_2 > 2) {
|
||
11 years ago
|
fprintf(stderr, "Invalid N_id_2 %d\n", N_id_2);
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
root_idx = N_id_2;
|
||
|
|
||
10 years ago
|
for (i = 0; i < SRSLTE_PSS_LEN / 2; i++) {
|
||
11 years ago
|
arg = (float) sign * M_PI * root_value[root_idx]
|
||
|
* ((float) i * ((float) i + 1.0)) / 63.0;
|
||
|
__real__ signal[i] = cosf(arg);
|
||
|
__imag__ signal[i] = sinf(arg);
|
||
|
}
|
||
10 years ago
|
for (i = SRSLTE_PSS_LEN / 2; i < SRSLTE_PSS_LEN; i++) {
|
||
11 years ago
|
arg = (float) sign * M_PI * root_value[root_idx]
|
||
|
* (((float) i + 2.0) * ((float) i + 1.0)) / 63.0;
|
||
|
__real__ signal[i] = cosf(arg);
|
||
|
__imag__ signal[i] = sinf(arg);
|
||
|
}
|
||
|
return 0;
|
||
11 years ago
|
}
|
||
|
|
||
11 years ago
|
/** 36.211 10.3 section 6.11.1.2
|
||
|
*/
|
||
10 years ago
|
void srslte_pss_put_slot(cf_t *pss_signal, cf_t *slot, uint32_t nof_prb, srslte_cp_t cp) {
|
||
11 years ago
|
int k;
|
||
10 years ago
|
k = (SRSLTE_CP_NSYMB(cp) - 1) * nof_prb * SRSLTE_NRE + nof_prb * SRSLTE_NRE / 2 - 31;
|
||
11 years ago
|
memset(&slot[k - 5], 0, 5 * sizeof(cf_t));
|
||
10 years ago
|
memcpy(&slot[k], pss_signal, SRSLTE_PSS_LEN * sizeof(cf_t));
|
||
|
memset(&slot[k + SRSLTE_PSS_LEN], 0, 5 * sizeof(cf_t));
|
||
11 years ago
|
}
|
||
11 years ago
|
|
||
9 years ago
|
void srslte_pss_get_slot(cf_t *slot, cf_t *pss_signal, uint32_t nof_prb, srslte_cp_t cp) {
|
||
|
int k;
|
||
|
k = (SRSLTE_CP_NSYMB(cp) - 1) * nof_prb * SRSLTE_NRE + nof_prb * SRSLTE_NRE / 2 - 31;
|
||
|
memcpy(pss_signal, &slot[k], SRSLTE_PSS_LEN * sizeof(cf_t));
|
||
|
}
|
||
|
|
||
11 years ago
|
|
||
|
/** Sets the current N_id_2 value. Returns -1 on error, 0 otherwise
|
||
11 years ago
|
*/
|
||
10 years ago
|
int srslte_pss_synch_set_N_id_2(srslte_pss_synch_t *q, uint32_t N_id_2) {
|
||
10 years ago
|
if (!srslte_N_id_2_isvalid((N_id_2))) {
|
||
11 years ago
|
fprintf(stderr, "Invalid N_id_2 %d\n", N_id_2);
|
||
|
return -1;
|
||
11 years ago
|
} else {
|
||
|
q->N_id_2 = N_id_2;
|
||
|
return 0;
|
||
11 years ago
|
}
|
||
11 years ago
|
}
|
||
|
|
||
10 years ago
|
/* Sets the weight factor alpha for the exponential moving average of the PSS correlation output
|
||
|
*/
|
||
10 years ago
|
void srslte_pss_synch_set_ema_alpha(srslte_pss_synch_t *q, float alpha) {
|
||
10 years ago
|
q->ema_alpha = alpha;
|
||
|
}
|
||
|
|
||
10 years ago
|
/** Performs time-domain PSS correlation.
|
||
|
* Returns the index of the PSS correlation peak in a subframe.
|
||
11 years ago
|
* The frame starts at corr_peak_pos-subframe_size/2.
|
||
|
* The value of the correlation is stored in corr_peak_value.
|
||
|
*
|
||
|
* Input buffer must be subframe_size long.
|
||
|
*/
|
||
10 years ago
|
int srslte_pss_synch_find_pss(srslte_pss_synch_t *q, cf_t *input, float *corr_peak_value)
|
||
10 years ago
|
{
|
||
10 years ago
|
int ret = SRSLTE_ERROR_INVALID_INPUTS;
|
||
10 years ago
|
|
||
|
if (q != NULL &&
|
||
|
input != NULL)
|
||
|
{
|
||
|
|
||
|
uint32_t corr_peak_pos;
|
||
|
uint32_t conv_output_len;
|
||
|
|
||
10 years ago
|
if (!srslte_N_id_2_isvalid(q->N_id_2)) {
|
||
10 years ago
|
fprintf(stderr, "Error finding PSS peak, Must set N_id_2 first\n");
|
||
10 years ago
|
return SRSLTE_ERROR;
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
/* Correlate input with PSS sequence */
|
||
9 years ago
|
if (q->frame_size >= q->fft_size) {
|
||
10 years ago
|
#ifdef CONVOLUTION_FFT
|
||
10 years ago
|
memcpy(q->tmp_input, input, q->frame_size * sizeof(cf_t));
|
||
9 years ago
|
conv_output_len = srslte_conv_fft_cc_run(&q->conv_fft, q->tmp_input, q->pss_signal_time[q->N_id_2], q->conv_output);
|
||
10 years ago
|
#else
|
||
9 years ago
|
conv_output_len = srslte_conv_cc(input, q->pss_signal_time[q->N_id_2], q->conv_output, q->frame_size, q->fft_size);
|
||
10 years ago
|
#endif
|
||
|
} else {
|
||
10 years ago
|
for (int i=0;i<q->frame_size;i++) {
|
||
9 years ago
|
q->conv_output[i] = srslte_vec_dot_prod_ccc(q->pss_signal_time[q->N_id_2], &input[i], q->fft_size);
|
||
10 years ago
|
}
|
||
10 years ago
|
conv_output_len = q->frame_size;
|
||
10 years ago
|
}
|
||
10 years ago
|
|
||
10 years ago
|
|
||
10 years ago
|
#ifdef SRSLTE_PSS_ABS_SQUARE
|
||
|
srslte_vec_abs_square_cf(q->conv_output, q->conv_output_abs, conv_output_len-1);
|
||
10 years ago
|
#else
|
||
10 years ago
|
srslte_vec_abs_cf(q->conv_output, q->conv_output_abs, conv_output_len-1);
|
||
10 years ago
|
#endif
|
||
|
|
||
9 years ago
|
if (q->ema_alpha < 1.0 && q->ema_alpha > 0.0) {
|
||
|
srslte_vec_sc_prod_fff(q->conv_output_abs, q->ema_alpha, q->conv_output_abs, conv_output_len-1);
|
||
|
srslte_vec_sc_prod_fff(q->conv_output_avg, 1-q->ema_alpha, q->conv_output_avg, conv_output_len-1);
|
||
10 years ago
|
|
||
9 years ago
|
srslte_vec_sum_fff(q->conv_output_abs, q->conv_output_avg, q->conv_output_avg, conv_output_len-1);
|
||
|
} else {
|
||
|
memcpy(q->conv_output_avg, q->conv_output_abs, sizeof(float)*(conv_output_len-1));
|
||
|
}
|
||
10 years ago
|
/* Find maximum of the absolute value of the correlation */
|
||
10 years ago
|
corr_peak_pos = srslte_vec_max_fi(q->conv_output_avg, conv_output_len-1);
|
||
10 years ago
|
|
||
|
// save absolute value
|
||
|
q->peak_value = q->conv_output_avg[corr_peak_pos];
|
||
|
|
||
10 years ago
|
#ifdef SRSLTE_PSS_RETURN_PSR
|
||
10 years ago
|
// Find second side lobe
|
||
|
|
||
|
// Find end of peak lobe to the right
|
||
|
int pl_ub = corr_peak_pos+1;
|
||
|
while(q->conv_output_avg[pl_ub+1] <= q->conv_output_avg[pl_ub] && pl_ub < conv_output_len) {
|
||
|
pl_ub ++;
|
||
|
}
|
||
|
// Find end of peak lobe to the left
|
||
|
int pl_lb;
|
||
10 years ago
|
if (corr_peak_pos > 2) {
|
||
10 years ago
|
pl_lb = corr_peak_pos-1;
|
||
|
while(q->conv_output_avg[pl_lb-1] <= q->conv_output_avg[pl_lb] && pl_lb > 1) {
|
||
|
pl_lb --;
|
||
|
}
|
||
|
} else {
|
||
|
pl_lb = 0;
|
||
|
}
|
||
|
|
||
|
int sl_distance_right = conv_output_len-1-pl_ub;
|
||
|
if (sl_distance_right < 0) {
|
||
|
sl_distance_right = 0;
|
||
|
}
|
||
|
int sl_distance_left = pl_lb;
|
||
|
|
||
10 years ago
|
int sl_right = pl_ub+srslte_vec_max_fi(&q->conv_output_avg[pl_ub], sl_distance_right);
|
||
|
int sl_left = srslte_vec_max_fi(q->conv_output_avg, sl_distance_left);
|
||
|
float side_lobe_value = SRSLTE_MAX(q->conv_output_avg[sl_right], q->conv_output_avg[sl_left]);
|
||
10 years ago
|
if (corr_peak_value) {
|
||
|
*corr_peak_value = q->conv_output_avg[corr_peak_pos]/side_lobe_value;
|
||
|
|
||
9 years ago
|
if (*corr_peak_value < 10)
|
||
|
DEBUG("peak_pos=%2d, pl_ub=%2d, pl_lb=%2d, sl_right: %2d, sl_left: %2d, PSR: %.2f/%.2f=%.2f\n", corr_peak_pos, pl_ub, pl_lb,
|
||
9 years ago
|
sl_right,sl_left, q->conv_output_avg[corr_peak_pos], side_lobe_value,*corr_peak_value);
|
||
10 years ago
|
}
|
||
|
#else
|
||
10 years ago
|
if (corr_peak_value) {
|
||
|
*corr_peak_value = q->conv_output_avg[corr_peak_pos];
|
||
|
}
|
||
|
#endif
|
||
|
|
||
10 years ago
|
if (q->frame_size >= q->fft_size) {
|
||
|
ret = (int) corr_peak_pos;
|
||
|
} else {
|
||
|
ret = (int) corr_peak_pos + q->fft_size;
|
||
|
}
|
||
10 years ago
|
}
|
||
|
return ret;
|
||
11 years ago
|
}
|
||
|
|
||
10 years ago
|
/* Computes frequency-domain channel estimation of the PSS symbol
|
||
|
* input signal is in the time-domain.
|
||
|
* ce is the returned frequency-domain channel estimates.
|
||
|
*/
|
||
10 years ago
|
int srslte_pss_synch_chest(srslte_pss_synch_t *q, cf_t *input, cf_t ce[SRSLTE_PSS_LEN]) {
|
||
10 years ago
|
int ret = SRSLTE_ERROR_INVALID_INPUTS;
|
||
10 years ago
|
cf_t input_fft[SRSLTE_SYMBOL_SZ_MAX];
|
||
10 years ago
|
|
||
|
if (q != NULL &&
|
||
|
input != NULL)
|
||
|
{
|
||
|
|
||
10 years ago
|
if (!srslte_N_id_2_isvalid(q->N_id_2)) {
|
||
10 years ago
|
fprintf(stderr, "Error finding PSS peak, Must set N_id_2 first\n");
|
||
10 years ago
|
return SRSLTE_ERROR;
|
||
10 years ago
|
}
|
||
|
|
||
|
/* Transform to frequency-domain */
|
||
10 years ago
|
srslte_dft_run_c(&q->dftp_input, input, input_fft);
|
||
10 years ago
|
|
||
|
/* Compute channel estimate taking the PSS sequence as reference */
|
||
9 years ago
|
srslte_vec_prod_conj_ccc(&input_fft[(q->fft_size-SRSLTE_PSS_LEN)/2], q->pss_signal_freq[q->N_id_2], ce, SRSLTE_PSS_LEN);
|
||
10 years ago
|
|
||
10 years ago
|
ret = SRSLTE_SUCCESS;
|
||
10 years ago
|
}
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
11 years ago
|
/* Returns the CFO estimation given a PSS received sequence
|
||
|
*
|
||
|
* Source: An Efficient CFO Estimation Algorithm for the Downlink of 3GPP-LTE
|
||
11 years ago
|
* Feng Wang and Yu Zhu
|
||
11 years ago
|
*/
|
||
10 years ago
|
float srslte_pss_synch_cfo_compute(srslte_pss_synch_t* q, cf_t *pss_recv) {
|
||
11 years ago
|
cf_t y0, y1, yr;
|
||
11 years ago
|
|
||
9 years ago
|
y0 = srslte_vec_dot_prod_ccc(q->pss_signal_time[q->N_id_2], pss_recv, q->fft_size/2);
|
||
|
y1 = srslte_vec_dot_prod_ccc(&q->pss_signal_time[q->N_id_2][q->fft_size/2], &pss_recv[q->fft_size/2], q->fft_size/2);
|
||
10 years ago
|
|
||
11 years ago
|
yr = conjf(y0) * y1;
|
||
11 years ago
|
|
||
11 years ago
|
return atan2f(__imag__ yr, __real__ yr) / M_PI;
|
||
11 years ago
|
}
|
||
|
|