void srslte_ue_sync_free(srslte_ue_sync_t *q) { if (q->input_buffer) { free(q->input_buffer); } if (q->do_agc) { srslte_agc_free(&q->agc); } if (!q->file_mode) { srslte_sync_free(&q->sfind); srslte_sync_free(&q->strack); } else { srslte_filesource_free(&q->file_source); } bzero(q, sizeof(srslte_ue_sync_t)); }
int srslte_sync_init(srslte_sync_t *q, uint32_t frame_size, uint32_t fft_size) { int ret = SRSLTE_ERROR_INVALID_INPUTS; if (q != NULL && frame_size <= 307200 && fft_size_isvalid(fft_size)) { ret = SRSLTE_ERROR; bzero(q, sizeof(srslte_sync_t)); q->detect_cp = true; q->cp = SRSLTE_CP_NORM; q->mean_peak_value = 0.0; q->sss_en = true; q->correct_cfo = true; q->mean_cfo = 0; q->N_id_2 = 1000; q->N_id_1 = 1000; q->fft_size = fft_size; q->frame_size = frame_size; q->sss_alg = SSS_PARTIAL_3; if (srslte_pss_synch_init_fft(&q->pss, frame_size, fft_size)) { fprintf(stderr, "Error initializing PSS object\n"); goto clean_exit; } if (srslte_sss_synch_init(&q->sss, fft_size)) { fprintf(stderr, "Error initializing SSS object\n"); goto clean_exit; } if (srslte_cfo_init(&q->cfocorr, frame_size)) { fprintf(stderr, "Error initiating CFO\n"); goto clean_exit; } DEBUG("SYNC init with frame_size=%d and fft_size=%d\n", frame_size, fft_size); ret = SRSLTE_SUCCESS; } else { fprintf(stderr, "Invalid parameters frame_size: %d, fft_size: %d\n", frame_size, fft_size); } clean_exit: if (ret == SRSLTE_ERROR) { srslte_sync_free(q); } return ret; }
void srslte_ue_mib_free(srslte_ue_mib_t * q) { if (q->sf_symbols) { free(q->sf_symbols); } for (int i=0;i<SRSLTE_MAX_PORTS;i++) { if (q->ce[i]) { free(q->ce[i]); } } srslte_sync_free(&q->sfind); srslte_chest_dl_free(&q->chest); srslte_pbch_free(&q->pbch); srslte_ofdm_rx_free(&q->fft); bzero(q, sizeof(srslte_ue_mib_t)); }
int srslte_sync_init(srslte_sync_t *q, uint32_t frame_size, uint32_t max_offset, uint32_t fft_size) { int ret = SRSLTE_ERROR_INVALID_INPUTS; if (q != NULL && frame_size <= 307200 && fft_size_isvalid(fft_size)) { ret = SRSLTE_ERROR; bzero(q, sizeof(srslte_sync_t)); q->detect_cp = true; q->mean_peak_value = 0.0; q->sss_en = true; q->mean_cfo = 0; q->N_id_2 = 1000; q->N_id_1 = 1000; q->cfo_i = 0; q->find_cfo_i = false; q->find_cfo_i_initiated = false; q->cfo_ema_alpha = CFO_EMA_ALPHA; q->fft_size = fft_size; q->frame_size = frame_size; q->max_offset = max_offset; q->sss_alg = SSS_PARTIAL_3; q->enable_cfo_corr = true; for (int i=0;i<2;i++) { q->cfo_i_corr[i] = srslte_vec_malloc(sizeof(cf_t)*q->frame_size); if (!q->cfo_i_corr[i]) { perror("malloc"); goto clean_exit; } } srslte_sync_set_cp(q, SRSLTE_CP_NORM); if (srslte_pss_synch_init_fft(&q->pss, max_offset, fft_size)) { fprintf(stderr, "Error initializing PSS object\n"); goto clean_exit; } if (srslte_sss_synch_init(&q->sss, fft_size)) { fprintf(stderr, "Error initializing SSS object\n"); goto clean_exit; } if (srslte_cfo_init(&q->cfocorr, frame_size)) { fprintf(stderr, "Error initiating CFO\n"); goto clean_exit; } if (srslte_cp_synch_init(&q->cp_synch, fft_size)) { fprintf(stderr, "Error initiating CFO\n"); goto clean_exit; } DEBUG("SYNC init with frame_size=%d, max_offset=%d and fft_size=%d\n", frame_size, max_offset, fft_size); ret = SRSLTE_SUCCESS; } else { fprintf(stderr, "Invalid parameters frame_size: %d, fft_size: %d\n", frame_size, fft_size); } clean_exit: if (ret == SRSLTE_ERROR) { srslte_sync_free(q); } return ret; }
int srslte_sync_init_decim(srslte_sync_t *q, uint32_t frame_size, uint32_t max_offset, uint32_t fft_size, int decimate) { int ret = SRSLTE_ERROR_INVALID_INPUTS; if (q != NULL && fft_size_isvalid(fft_size)) { ret = SRSLTE_ERROR; bzero(q, sizeof(srslte_sync_t)); q->N_id_2 = 1000; q->N_id_1 = 1000; q->cfo_ema_alpha = CFO_EMA_ALPHA; q->sss_alg = SSS_FULL; q->detect_cp = true; q->sss_en = true; q->cfo_pss_enable = false; q->cfo_cp_enable = false; q->cfo_i_initiated = false; q->pss_filtering_enabled = false; q->cfo_cp_nsymbols = 3; q->fft_size = fft_size; q->frame_size = frame_size; q->max_offset = max_offset; q->max_frame_size = frame_size; srslte_sync_cfo_reset(q); if (srslte_cfo_init(&q->cfo_corr_frame, q->frame_size)) { fprintf(stderr, "Error initiating CFO\n"); goto clean_exit; } if (srslte_cfo_init(&q->cfo_corr_symbol, q->fft_size)) { fprintf(stderr, "Error initiating CFO\n"); goto clean_exit; } // Set default CFO tolerance srslte_sync_set_cfo_tol(q, DEFAULT_CFO_TOL); for (int i=0;i<2;i++) { q->cfo_i_corr[i] = srslte_vec_malloc(sizeof(cf_t)*q->frame_size); if (!q->cfo_i_corr[i]) { perror("malloc"); goto clean_exit; } } q->temp = srslte_vec_malloc(sizeof(cf_t)*2*q->frame_size); if (!q->temp) { perror("malloc"); goto clean_exit; } srslte_sync_set_cp(q, SRSLTE_CP_NORM); q->decimate = decimate; if(!decimate) { decimate = 1; } if (srslte_pss_init_fft_offset_decim(&q->pss, max_offset, fft_size, 0, decimate)) { fprintf(stderr, "Error initializing PSS object\n"); goto clean_exit; } if (srslte_sss_init(&q->sss, fft_size)) { fprintf(stderr, "Error initializing SSS object\n"); goto clean_exit; } if (srslte_cp_synch_init(&q->cp_synch, fft_size)) { fprintf(stderr, "Error initiating CFO\n"); goto clean_exit; } DEBUG("SYNC init with frame_size=%d, max_offset=%d and fft_size=%d\n", frame_size, max_offset, fft_size); ret = SRSLTE_SUCCESS; } else { fprintf(stderr, "Invalid parameters frame_size: %d, fft_size: %d\n", frame_size, fft_size); } clean_exit: if (ret == SRSLTE_ERROR) { srslte_sync_free(q); } return ret; }