2014-03-03 11:09:26 -08:00
|
|
|
/**
|
2014-01-28 03:41:17 -08:00
|
|
|
*
|
2014-03-03 11:09:26 -08:00
|
|
|
* \section COPYRIGHT
|
2014-01-28 03:41:17 -08:00
|
|
|
*
|
2014-03-03 11:09:26 -08:00
|
|
|
* Copyright 2013-2014 The libLTE Developers. See the
|
|
|
|
* COPYRIGHT file at the top-level directory of this distribution.
|
|
|
|
*
|
|
|
|
* \section LICENSE
|
|
|
|
*
|
|
|
|
* This file is part of the libLTE library.
|
|
|
|
*
|
|
|
|
* libLTE is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* libLTE 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
|
|
|
|
* GNU Lesser General Public License for more details.
|
|
|
|
*
|
2014-03-03 11:09:26 -08:00
|
|
|
* A copy of the GNU Lesser 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
|
|
|
*/
|
|
|
|
|
2014-03-03 11:09:26 -08:00
|
|
|
|
2014-01-28 03:41:17 -08:00
|
|
|
#ifndef SYNC_
|
|
|
|
#define SYNC_
|
|
|
|
|
2014-03-27 09:31:25 -07:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2014-01-28 03:41:17 -08:00
|
|
|
#include "pss.h"
|
|
|
|
#include "sss.h"
|
|
|
|
#include "sfo.h"
|
|
|
|
|
2014-03-27 09:31:25 -07:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* This object performs 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().
|
|
|
|
*/
|
|
|
|
|
2014-01-28 03:41:17 -08:00
|
|
|
enum sync_pss_det { ABSOLUTE, PEAK_MEAN};
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
pss_synch_t pss[3]; // One for each N_id_2
|
|
|
|
sss_synch_t sss[3]; // One for each N_id_2
|
|
|
|
enum sync_pss_det pss_mode;
|
|
|
|
float threshold;
|
|
|
|
float peak_to_avg;
|
|
|
|
int force_N_id_2;
|
|
|
|
int N_id_2;
|
|
|
|
int N_id_1;
|
|
|
|
int slot_id;
|
|
|
|
float cfo;
|
2014-03-27 09:31:25 -07:00
|
|
|
lte_cp_t cp;
|
|
|
|
bool detect_cp;
|
2014-03-28 03:27:49 -07:00
|
|
|
bool sss_en;
|
2014-01-28 03:41:17 -08:00
|
|
|
}sync_t;
|
|
|
|
|
2014-03-27 09:31:25 -07:00
|
|
|
|
|
|
|
int sync_init(sync_t *q, int frame_size);
|
|
|
|
void sync_free(sync_t *q);
|
|
|
|
|
|
|
|
/* Runs the synchronization algorithm. input signal must be sampled at 1.92 MHz and should be frame_size long at least */
|
2014-03-03 11:09:26 -08:00
|
|
|
int sync_run(sync_t *q, cf_t *input);
|
2014-03-27 09:31:25 -07:00
|
|
|
|
|
|
|
/* Sets the threshold for peak comparison */
|
|
|
|
void sync_set_threshold(sync_t *q, float threshold);
|
|
|
|
/* Set peak comparison to absolute value */
|
2014-01-28 03:41:17 -08:00
|
|
|
void sync_pss_det_absolute(sync_t *q);
|
2014-03-27 09:31:25 -07:00
|
|
|
/* Set peak comparison to relative to the mean */
|
|
|
|
void sync_pss_det_peak_to_avg(sync_t *q);
|
|
|
|
|
|
|
|
/* Forces the synchronizer to check one N_id_2 PSS sequence only (useful for tracking mode) */
|
2014-01-28 03:41:17 -08:00
|
|
|
void sync_force_N_id_2(sync_t *q, int force_N_id_2);
|
2014-03-27 09:31:25 -07:00
|
|
|
/* Forces the synchronizer to skip CP detection (useful for tracking mode) */
|
|
|
|
void sync_force_cp(sync_t *q, lte_cp_t cp);
|
2014-03-28 03:27:49 -07:00
|
|
|
/* Enables/Disables SSS detection (useful for tracking mode) */
|
|
|
|
void sync_sss_en(sync_t *q, bool enabled);
|
|
|
|
|
2014-03-27 09:31:25 -07:00
|
|
|
|
|
|
|
/* Gets the slot id (0 or 10) */
|
2014-01-28 03:41:17 -08:00
|
|
|
int sync_get_slot_id(sync_t *q);
|
2014-03-27 09:31:25 -07:00
|
|
|
/* Gets the last peak-to-average ratio */
|
2014-01-28 03:41:17 -08:00
|
|
|
float sync_get_peak_to_avg(sync_t *q);
|
2014-03-27 09:31:25 -07:00
|
|
|
/* Gets the N_id_2 from the last call to synch_run() */
|
2014-01-28 03:41:17 -08:00
|
|
|
int sync_get_N_id_2(sync_t *q);
|
2014-03-27 09:31:25 -07:00
|
|
|
/* Gets the N_id_1 from the last call to synch_run() */
|
2014-01-28 03:41:17 -08:00
|
|
|
int sync_get_N_id_1(sync_t *q);
|
2014-03-27 09:31:25 -07:00
|
|
|
/* Gets the Physical CellId from the last call to synch_run() */
|
2014-01-28 03:41:17 -08:00
|
|
|
int sync_get_cell_id(sync_t *q);
|
2014-03-27 09:31:25 -07:00
|
|
|
/* Gets the CFO estimation from the last call to synch_run() */
|
|
|
|
float sync_get_cfo(sync_t *q);
|
|
|
|
/* Gets the CP length estimation from the last call to synch_run() */
|
|
|
|
lte_cp_t sync_get_cp(sync_t *q);
|
2014-01-28 03:41:17 -08:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|