diff --git a/lib/include/srslte/phy/sync/cfo.h b/lib/include/srslte/phy/sync/cfo.h index c21c8b49d..46922d114 100644 --- a/lib/include/srslte/phy/sync/cfo.h +++ b/lib/include/srslte/phy/sync/cfo.h @@ -62,6 +62,4 @@ srslte_cfo_correct_offset(srslte_cfo_t* h, const cf_t* input, cf_t* output, floa SRSLTE_API float srslte_cfo_est_corr_cp(cf_t* input_buffer, uint32_t nof_prb); -SRSLTE_API float srslte_sl_cfo_est_corr_cp(cf_t* input_buffer, uint32_t nof_prb, srslte_cp_t cp); - #endif // SRSLTE_CFO_H diff --git a/lib/src/phy/phch/test/pscch_file_test.c b/lib/src/phy/phch/test/pscch_file_test.c index ebf443bb5..900281cc0 100644 --- a/lib/src/phy/phch/test/pscch_file_test.c +++ b/lib/src/phy/phch/test/pscch_file_test.c @@ -238,8 +238,7 @@ int main(int argc, char** argv) nread = -1; } - // CFO estimation and correction - srslte_sl_cfo_est_corr_cp(input_buffer, cell.nof_prb, cell.cp); + // Convert to frequency domain srslte_ofdm_rx_sf(&fft); if (cell.tm == SRSLTE_SIDELINK_TM1 || cell.tm == SRSLTE_SIDELINK_TM2) { diff --git a/lib/src/phy/sync/cfo.c b/lib/src/phy/sync/cfo.c index 441adb779..2ac643853 100644 --- a/lib/src/phy/sync/cfo.c +++ b/lib/src/phy/sync/cfo.c @@ -146,50 +146,4 @@ float srslte_cfo_est_corr_cp(cf_t* input_buffer, uint32_t nof_prb) float cfo = (float)(-1 * carg(cfo_estimated) / (float)(2 * M_PI * tFFT)); srslte_vec_apply_cfo(input_buffer, (float)(1 / (nFFT * 15e3)) * ((-15e3 / 2.0) - cfo), input_buffer, sf_n_samples); return cfo; -} - -/* - * Sidelink CFO estimation and correction based on cp - */ -float srslte_sl_cfo_est_corr_cp(cf_t* input_buffer, uint32_t nof_prb, srslte_cp_t cp) -{ - int symbol_sz = srslte_symbol_sz(nof_prb); - int sf_n_samples = SRSLTE_SF_LEN_PRB(nof_prb); - float tFFT = (float)(1 / 15000.0); - int cp_size = SRSLTE_CP_SZ(symbol_sz, cp); - int cp_size_0 = (cp == SRSLTE_CP_NORM) ? SRSLTE_CP_LEN_NORM(0, symbol_sz) : cp_size; - - // Compensate for initial SC-FDMA half subcarrier shift, cfo = 7500 / (15000 * symbol_sz) <=> 1 / (symbol_sz * 2.0) - srslte_vec_apply_cfo(input_buffer, (1 / (float)(symbol_sz * 2.0)), input_buffer, sf_n_samples); - - uint32_t p1 = 0; - uint32_t p2 = symbol_sz; - uint32_t cp_len = 0; - - uint32_t sf_n_symbols = (cp == SRSLTE_CP_NORM) - ? (14 - 1) - : (12 - 1); // // TS 36.211 Section 9.3.2: The last SC-FDMA symbol in a sidelink subframe, - // serves as a guard period and shall not be used for sidelink transmission. - - cf_t average_cfo = 0.0f; - - for (int i = 0; i < sf_n_symbols; i++) { - // Calculate CP length - cp_len = (i == 0 || i == SRSLTE_CP_NSYMB(cp)) ? cp_size_0 : cp_size; - - // Correlate CP with tail - average_cfo += srslte_vec_dot_prod_conj_ccc(&input_buffer[p2], &input_buffer[p1], cp_len); - - // Increment pointers for next symbol - p1 += cp_len + symbol_sz; - p2 += cp_len + symbol_sz; - } - - float cfo = (float)(carg(average_cfo) / (float)(2 * M_PI * tFFT)); - - // Compensate for initial SC-FDMA half subcarrier shift, cfo = - 7500 / (15000 * symbol_sz) <=> 1 / (symbol_sz * 2.0) - srslte_vec_apply_cfo( - input_buffer, (-1 / (float)(symbol_sz * 2.0)) + (-cfo / (float)(15e3 * symbol_sz)), input_buffer, sf_n_samples); - - return cfo; } \ No newline at end of file