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.
218 lines
7.3 KiB
C
218 lines
7.3 KiB
C
4 years ago
|
/**
|
||
11 years ago
|
*
|
||
4 years ago
|
* \section COPYRIGHT
|
||
11 years ago
|
*
|
||
4 years ago
|
* Copyright 2013-2021 Software Radio Systems Limited
|
||
11 years ago
|
*
|
||
4 years ago
|
* By using this file, you agree to the terms and conditions set
|
||
|
* forth in the LICENSE file which can be found at the top level of
|
||
|
* the distribution.
|
||
11 years ago
|
*
|
||
11 years ago
|
*/
|
||
|
|
||
10 years ago
|
/******************************************************************************
|
||
|
* File: sync.h
|
||
|
*
|
||
|
* Description: Time and frequency synchronization using the PSS and SSS signals.
|
||
|
*
|
||
|
* 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.
|
||
|
*
|
||
|
* Correlation peak is detected comparing the maximum at the output
|
||
|
* of the correlator with a threshold. The comparison accepts two
|
||
|
* modes: absolute value or peak-to-mean ratio, which are configured
|
||
|
* with the functions sync_pss_det_absolute() and sync_pss_det_peakmean().
|
||
|
*
|
||
|
*
|
||
|
* Reference: 3GPP TS 36.211 version 10.0.0 Release 10 Sec. 6.11.1, 6.11.2
|
||
|
*****************************************************************************/
|
||
11 years ago
|
|
||
4 years ago
|
#ifndef SRSRAN_SYNC_H
|
||
|
#define SRSRAN_SYNC_H
|
||
11 years ago
|
|
||
11 years ago
|
#include <math.h>
|
||
5 years ago
|
#include <stdbool.h>
|
||
11 years ago
|
|
||
4 years ago
|
#include "srsran/config.h"
|
||
|
#include "srsran/phy/sync/cfo.h"
|
||
|
#include "srsran/phy/sync/cp.h"
|
||
|
#include "srsran/phy/sync/pss.h"
|
||
|
#include "srsran/phy/sync/sss.h"
|
||
11 years ago
|
|
||
4 years ago
|
#define SRSRAN_SYNC_FFT_SZ_MIN 64
|
||
|
#define SRSRAN_SYNC_FFT_SZ_MAX 2048
|
||
11 years ago
|
|
||
5 years ago
|
typedef enum { SSS_DIFF = 0, SSS_PARTIAL_3 = 2, SSS_FULL = 1 } sss_alg_t;
|
||
10 years ago
|
|
||
4 years ago
|
typedef struct SRSRAN_API {
|
||
|
srsran_pss_t pss;
|
||
|
srsran_pss_t pss_i[2];
|
||
|
srsran_sss_t sss;
|
||
|
srsran_cp_synch_t cp_synch;
|
||
5 years ago
|
cf_t* cfo_i_corr[2];
|
||
|
int decimate;
|
||
|
float threshold;
|
||
|
float peak_value;
|
||
|
uint32_t N_id_2;
|
||
|
uint32_t N_id_1;
|
||
|
uint32_t sf_idx;
|
||
|
uint32_t fft_size;
|
||
|
uint32_t frame_size;
|
||
|
uint32_t max_offset;
|
||
|
uint32_t nof_symbols;
|
||
|
uint32_t cp_len;
|
||
|
float current_cfo_tol;
|
||
|
sss_alg_t sss_alg;
|
||
|
bool detect_cp;
|
||
|
bool sss_en;
|
||
4 years ago
|
srsran_cp_t cp;
|
||
5 years ago
|
uint32_t m0;
|
||
|
uint32_t m1;
|
||
|
float m0_value;
|
||
|
float m1_value;
|
||
|
float M_norm_avg;
|
||
|
float M_ext_avg;
|
||
|
cf_t* temp;
|
||
10 years ago
|
|
||
7 years ago
|
uint32_t max_frame_size;
|
||
|
|
||
4 years ago
|
srsran_frame_type_t frame_type;
|
||
6 years ago
|
bool detect_frame_type;
|
||
7 years ago
|
|
||
|
// variables for various CFO estimation methods
|
||
|
bool cfo_cp_enable;
|
||
|
bool cfo_pss_enable;
|
||
|
bool cfo_i_enable;
|
||
|
|
||
|
bool cfo_cp_is_set;
|
||
|
bool cfo_pss_is_set;
|
||
|
bool cfo_i_initiated;
|
||
|
|
||
|
float cfo_cp_mean;
|
||
7 years ago
|
float cfo_pss;
|
||
7 years ago
|
float cfo_pss_mean;
|
||
|
int cfo_i_value;
|
||
|
|
||
|
float cfo_ema_alpha;
|
||
|
|
||
7 years ago
|
uint32_t cfo_cp_nsymbols;
|
||
|
|
||
4 years ago
|
srsran_cfo_t cfo_corr_frame;
|
||
|
srsran_cfo_t cfo_corr_symbol;
|
||
7 years ago
|
|
||
7 years ago
|
bool sss_channel_equalize;
|
||
7 years ago
|
bool pss_filtering_enabled;
|
||
4 years ago
|
cf_t sss_filt[SRSRAN_SYMBOL_SZ_MAX];
|
||
|
cf_t pss_filt[SRSRAN_SYMBOL_SZ_MAX];
|
||
7 years ago
|
|
||
6 years ago
|
bool sss_generated;
|
||
|
bool sss_detected;
|
||
|
bool sss_available;
|
||
5 years ago
|
float sss_corr;
|
||
4 years ago
|
srsran_dft_plan_t idftp_sss;
|
||
|
cf_t sss_recv[SRSRAN_SYMBOL_SZ_MAX];
|
||
|
cf_t sss_signal[2][SRSRAN_SYMBOL_SZ_MAX];
|
||
6 years ago
|
|
||
4 years ago
|
} srsran_sync_t;
|
||
11 years ago
|
|
||
9 years ago
|
typedef enum {
|
||
4 years ago
|
SRSRAN_SYNC_FOUND = 1,
|
||
|
SRSRAN_SYNC_FOUND_NOSPACE = 2,
|
||
|
SRSRAN_SYNC_NOFOUND = 0,
|
||
|
SRSRAN_SYNC_ERROR = -1
|
||
|
} srsran_sync_find_ret_t;
|
||
11 years ago
|
|
||
4 years ago
|
SRSRAN_API int srsran_sync_init(srsran_sync_t* q, uint32_t frame_size, uint32_t max_offset, uint32_t fft_size);
|
||
11 years ago
|
|
||
4 years ago
|
SRSRAN_API int
|
||
|
srsran_sync_init_decim(srsran_sync_t* q, uint32_t frame_size, uint32_t max_offset, uint32_t fft_size, int decimate);
|
||
8 years ago
|
|
||
4 years ago
|
SRSRAN_API void srsran_sync_free(srsran_sync_t* q);
|
||
8 years ago
|
|
||
4 years ago
|
SRSRAN_API int srsran_sync_resize(srsran_sync_t* q, uint32_t frame_size, uint32_t max_offset, uint32_t fft_size);
|
||
11 years ago
|
|
||
4 years ago
|
SRSRAN_API void srsran_sync_reset(srsran_sync_t* q);
|
||
11 years ago
|
|
||
11 years ago
|
/* Finds a correlation peak in the input signal around position find_offset */
|
||
4 years ago
|
SRSRAN_API srsran_sync_find_ret_t srsran_sync_find(srsran_sync_t* q,
|
||
5 years ago
|
const cf_t* input,
|
||
|
uint32_t find_offset,
|
||
|
uint32_t* peak_position);
|
||
11 years ago
|
|
||
10 years ago
|
/* Estimates the CP length */
|
||
4 years ago
|
SRSRAN_API srsran_cp_t srsran_sync_detect_cp(srsran_sync_t* q, const cf_t* input, uint32_t peak_pos);
|
||
10 years ago
|
|
||
11 years ago
|
/* Sets the threshold for peak comparison */
|
||
4 years ago
|
SRSRAN_API void srsran_sync_set_threshold(srsran_sync_t* q, float threshold);
|
||
11 years ago
|
|
||
|
/* Gets the subframe idx (0 or 5) */
|
||
4 years ago
|
SRSRAN_API uint32_t srsran_sync_get_sf_idx(srsran_sync_t* q);
|
||
11 years ago
|
|
||
7 years ago
|
/* Gets the peak value */
|
||
4 years ago
|
SRSRAN_API float srsran_sync_get_peak_value(srsran_sync_t* q);
|
||
11 years ago
|
|
||
10 years ago
|
/* Choose SSS detection algorithm */
|
||
4 years ago
|
SRSRAN_API void srsran_sync_set_sss_algorithm(srsran_sync_t* q, sss_alg_t alg);
|
||
10 years ago
|
|
||
|
/* Sets PSS exponential averaging alpha weight */
|
||
4 years ago
|
SRSRAN_API void srsran_sync_set_em_alpha(srsran_sync_t* q, float alpha);
|
||
11 years ago
|
|
||
11 years ago
|
/* Sets the N_id_2 to search for */
|
||
4 years ago
|
SRSRAN_API int srsran_sync_set_N_id_2(srsran_sync_t* q, uint32_t N_id_2);
|
||
11 years ago
|
|
||
4 years ago
|
SRSRAN_API int srsran_sync_set_N_id_1(srsran_sync_t* q, uint32_t N_id_1);
|
||
6 years ago
|
|
||
11 years ago
|
/* Gets the Physical CellId from the last call to synch_run() */
|
||
4 years ago
|
SRSRAN_API int srsran_sync_get_cell_id(srsran_sync_t* q);
|
||
11 years ago
|
|
||
7 years ago
|
/* Enables/disables filtering of the central PRBs before PSS CFO estimation or SSS correlation*/
|
||
4 years ago
|
SRSRAN_API void srsran_sync_set_pss_filt_enable(srsran_sync_t* q, bool enable);
|
||
7 years ago
|
|
||
4 years ago
|
SRSRAN_API void srsran_sync_set_sss_eq_enable(srsran_sync_t* q, bool enable);
|
||
7 years ago
|
|
||
11 years ago
|
/* Gets the CFO estimation from the last call to synch_run() */
|
||
4 years ago
|
SRSRAN_API float srsran_sync_get_cfo(srsran_sync_t* q);
|
||
11 years ago
|
|
||
7 years ago
|
/* Resets internal CFO state */
|
||
4 years ago
|
SRSRAN_API void srsran_sync_cfo_reset(srsran_sync_t* q, float cfo_Hz);
|
||
7 years ago
|
|
||
|
/* Copies CFO internal state from another object to avoid long transients */
|
||
4 years ago
|
SRSRAN_API void srsran_sync_copy_cfo(srsran_sync_t* q, srsran_sync_t* src_obj);
|
||
10 years ago
|
|
||
7 years ago
|
/* Enable different CFO estimation stages */
|
||
4 years ago
|
SRSRAN_API void srsran_sync_set_cfo_i_enable(srsran_sync_t* q, bool enable);
|
||
|
SRSRAN_API void srsran_sync_set_cfo_cp_enable(srsran_sync_t* q, bool enable, uint32_t nof_symbols);
|
||
7 years ago
|
|
||
4 years ago
|
SRSRAN_API void srsran_sync_set_cfo_pss_enable(srsran_sync_t* q, bool enable);
|
||
9 years ago
|
|
||
7 years ago
|
/* Sets CFO correctors tolerance (in Hz) */
|
||
4 years ago
|
SRSRAN_API void srsran_sync_set_cfo_tol(srsran_sync_t* q, float tol);
|
||
9 years ago
|
|
||
4 years ago
|
SRSRAN_API void srsran_sync_set_frame_type(srsran_sync_t* q, srsran_frame_type_t frame_type);
|
||
9 years ago
|
|
||
6 years ago
|
/* Sets the exponential moving average coefficient for CFO averaging */
|
||
4 years ago
|
SRSRAN_API void srsran_sync_set_cfo_ema_alpha(srsran_sync_t* q, float alpha);
|
||
7 years ago
|
|
||
11 years ago
|
/* Gets the CP length estimation from the last call to synch_run() */
|
||
4 years ago
|
SRSRAN_API srsran_cp_t srsran_sync_get_cp(srsran_sync_t* q);
|
||
11 years ago
|
|
||
10 years ago
|
/* Sets the CP length estimation (must do it if disabled) */
|
||
4 years ago
|
SRSRAN_API void srsran_sync_set_cp(srsran_sync_t* q, srsran_cp_t cp);
|
||
10 years ago
|
|
||
11 years ago
|
/* Enables/Disables SSS detection */
|
||
4 years ago
|
SRSRAN_API void srsran_sync_sss_en(srsran_sync_t* q, bool enabled);
|
||
11 years ago
|
|
||
4 years ago
|
SRSRAN_API srsran_pss_t* srsran_sync_get_cur_pss_obj(srsran_sync_t* q);
|
||
9 years ago
|
|
||
4 years ago
|
SRSRAN_API bool srsran_sync_sss_detected(srsran_sync_t* q);
|
||
11 years ago
|
|
||
4 years ago
|
SRSRAN_API float srsran_sync_sss_correlation_peak(srsran_sync_t* q);
|
||
5 years ago
|
|
||
4 years ago
|
SRSRAN_API bool srsran_sync_sss_available(srsran_sync_t* q);
|
||
6 years ago
|
|
||
11 years ago
|
/* Enables/Disables CP detection */
|
||
4 years ago
|
SRSRAN_API void srsran_sync_cp_en(srsran_sync_t* q, bool enabled);
|
||
11 years ago
|
|
||
4 years ago
|
#endif // SRSRAN_SYNC_H
|