srsLTE/lib/include/srslte/phy/sync/pss.h

174 lines
6.1 KiB
C
Raw Normal View History

/**
2014-01-28 03:41:17 -08:00
*
* \section COPYRIGHT
2014-01-28 03:41:17 -08:00
*
2015-11-13 04:22:33 -08:00
* Copyright 2013-2015 Software Radio Systems Limited
*
* \section LICENSE
*
* This file is part of the srsLTE library.
*
* srsLTE is free software: you can redistribute it and/or modify
2015-05-08 08:05:40 -07:00
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE is distributed in the hope that it will be useful,
2014-01-28 03:41:17 -08:00
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2015-05-08 08:05:40 -07:00
* GNU Affero General Public License for more details.
2014-01-28 03:41:17 -08:00
*
2015-05-08 08:05:40 -07:00
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
2014-01-28 03:41:17 -08:00
*/
/******************************************************************************
* File: pss.h
*
* Description: Primary synchronization signal (PSS) generation and detection.
*
* The srslte_pss_synch_t object provides functions for fast
* computation of the crosscorrelation between the PSS and received
* signal and CFO estimation. Also, the function srslte_pss_synch_tperiodic()
* is designed to be called periodically every subframe, taking
* care of the correct data alignment with respect to the PSS sequence.
*
* The object is designed to work with signals sampled at 1.92 Mhz
* centered at the carrier frequency. Thus, downsampling is required
* if the signal is sampled at higher frequencies.
*
* Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 6.11.1
*****************************************************************************/
2014-01-28 03:41:17 -08:00
#ifndef PSS_
#define PSS_
#include <stdint.h>
#include <stdbool.h>
#include "srslte/config.h"
2017-05-18 00:48:24 -07:00
#include "srslte/phy/common/phy_common.h"
#include "srslte/phy/utils/convolution.h"
#include "srslte/phy/utils/filter.h"
2014-01-28 03:41:17 -08:00
#define CONVOLUTION_FFT
2015-03-18 11:14:24 -07:00
#define SRSLTE_PSS_LEN 62
#define SRSLTE_PSS_RE (6*12)
2014-01-28 03:41:17 -08:00
/* PSS processing options */
2015-03-18 11:14:24 -07:00
#define SRSLTE_PSS_ACCUMULATE_ABS // If enabled, accumulates the correlation absolute value on consecutive calls to srslte_pss_synch_find_pss
2015-03-18 11:14:24 -07:00
#define SRSLTE_PSS_ABS_SQUARE // If enabled, compute abs square, otherwise computes absolute value only
2015-03-18 11:14:24 -07:00
#define SRSLTE_PSS_RETURN_PSR // If enabled returns peak to side-lobe ratio, otherwise returns absolute peak value
2014-01-28 03:41:17 -08:00
/* Low-level API */
typedef struct SRSLTE_API {
2017-11-29 02:58:18 -08:00
2014-01-28 03:41:17 -08:00
#ifdef CONVOLUTION_FFT
2015-03-18 11:14:24 -07:00
srslte_conv_fft_cc_t conv_fft;
srslte_filt_cc_t filter;
2014-01-28 03:41:17 -08:00
#endif
int decimate;
uint32_t max_frame_size;
uint32_t max_fft_size;
uint32_t frame_size;
uint32_t N_id_2;
uint32_t fft_size;
cf_t *pss_signal_freq_full[3];
2017-11-29 02:58:18 -08:00
2015-09-23 11:19:13 -07:00
cf_t *pss_signal_time[3];
2017-11-29 02:58:18 -08:00
2015-09-23 11:19:13 -07:00
cf_t pss_signal_freq[3][SRSLTE_PSS_LEN]; // One sequence for each N_id_2
2014-06-17 02:11:41 -07:00
cf_t *tmp_input;
cf_t *conv_output;
float *conv_output_abs;
2017-11-29 02:58:18 -08:00
float ema_alpha;
float *conv_output_avg;
float peak_value;
2017-11-29 02:58:18 -08:00
bool filter_pss_enable;
srslte_dft_plan_t dftp_input;
srslte_dft_plan_t idftp_input;
cf_t tmp_fft[SRSLTE_SYMBOL_SZ_MAX];
cf_t tmp_fft2[SRSLTE_SYMBOL_SZ_MAX];
2015-03-18 11:14:24 -07:00
}srslte_pss_synch_t;
2014-01-28 03:41:17 -08:00
typedef enum { PSS_TX, PSS_RX } pss_direction_t;
2014-01-28 03:41:17 -08:00
/* Basic functionality */
2015-03-18 11:14:24 -07:00
SRSLTE_API int srslte_pss_synch_init_fft(srslte_pss_synch_t *q,
uint32_t frame_size,
uint32_t fft_size);
SRSLTE_API int srslte_pss_synch_init_fft_offset(srslte_pss_synch_t *q,
uint32_t frame_size,
uint32_t fft_size,
int cfo_i);
2017-05-09 03:34:35 -07:00
SRSLTE_API int srslte_pss_synch_init_fft_offset_decim(srslte_pss_synch_t *q,
uint32_t frame_size,
uint32_t fft_size,
int cfo_i,
int decimate);
SRSLTE_API int srslte_pss_synch_resize(srslte_pss_synch_t *q, uint32_t frame_size,
uint32_t fft_size,
int offset);
2015-03-18 11:14:24 -07:00
SRSLTE_API int srslte_pss_synch_init(srslte_pss_synch_t *q,
uint32_t frame_size);
2015-03-18 11:14:24 -07:00
SRSLTE_API void srslte_pss_synch_free(srslte_pss_synch_t *q);
2014-01-28 03:41:17 -08:00
2015-03-18 11:14:24 -07:00
SRSLTE_API void srslte_pss_synch_reset(srslte_pss_synch_t *q);
2017-11-29 02:58:18 -08:00
SRSLTE_API void srslte_pss_synch_filter_enable(srslte_pss_synch_t *q,
bool enable);
SRSLTE_API void srslte_pss_synch_filter(srslte_pss_synch_t *q,
cf_t *input,
cf_t *output);
2015-03-18 11:14:24 -07:00
SRSLTE_API int srslte_pss_generate(cf_t *signal,
uint32_t N_id_2);
SRSLTE_API void srslte_pss_get_slot(cf_t *slot,
cf_t *pss_signal,
uint32_t nof_prb,
srslte_cp_t cp);
2015-03-18 11:14:24 -07:00
SRSLTE_API void srslte_pss_put_slot(cf_t *pss_signal,
cf_t *slot,
uint32_t nof_prb,
srslte_cp_t cp);
2014-01-28 03:41:17 -08:00
2015-03-18 11:14:24 -07:00
SRSLTE_API void srslte_pss_synch_set_ema_alpha(srslte_pss_synch_t *q,
float alpha);
2014-12-09 15:29:48 -08:00
2015-03-18 11:14:24 -07:00
SRSLTE_API int srslte_pss_synch_set_N_id_2(srslte_pss_synch_t *q,
uint32_t N_id_2);
2014-01-28 03:41:17 -08:00
2015-03-18 11:14:24 -07:00
SRSLTE_API int srslte_pss_synch_find_pss(srslte_pss_synch_t *q,
cf_t *input,
float *corr_peak_value);
2014-01-28 03:41:17 -08:00
2015-03-18 11:14:24 -07:00
SRSLTE_API int srslte_pss_synch_chest(srslte_pss_synch_t *q,
cf_t *input,
cf_t ce[SRSLTE_PSS_LEN]);
2015-03-18 11:14:24 -07:00
SRSLTE_API float srslte_pss_synch_cfo_compute(srslte_pss_synch_t* q,
cf_t *pss_recv);
2014-01-28 03:41:17 -08:00
#endif // PSS_