diff --git a/lib/include/srslte/phy/sync/cfo.h b/lib/include/srslte/phy/sync/cfo.h index 9da206252..729e1c6a6 100644 --- a/lib/include/srslte/phy/sync/cfo.h +++ b/lib/include/srslte/phy/sync/cfo.h @@ -62,4 +62,7 @@ SRSLTE_API void srslte_cfo_correct(srslte_cfo_t *h, cf_t *output, float freq); +SRSLTE_API void +srslte_cfo_correct_offset(srslte_cfo_t* h, const cf_t* input, cf_t* output, float freq, int cexp_offset, int nsamples); + #endif // SRSLTE_CFO_H diff --git a/lib/src/phy/sync/cfo.c b/lib/src/phy/sync/cfo.c index 1b2d75a75..d68a7c696 100644 --- a/lib/src/phy/sync/cfo.c +++ b/lib/src/phy/sync/cfo.c @@ -101,3 +101,19 @@ void srslte_cfo_correct(srslte_cfo_t *h, const cf_t *input, cf_t *output, float srslte_vec_apply_cfo(input, freq, output, h->nsamples); #endif /* SRSLTE_CFO_USE_EXP_TABLE */ } + +/* CFO correction which allows to specify the offset within the correction + * table to allow phase-continuity across multi-subframe transmissions (NB-IoT) + * Note that when correction table needs to be regenerated, the regeneration + * takes place for the maximum number of samples + */ +void srslte_cfo_correct_offset( + srslte_cfo_t* h, const cf_t* input, cf_t* output, float freq, int cexp_offset, int nsamples) +{ + if (fabs(h->last_freq - freq) > h->tol) { + h->last_freq = freq; + srslte_cexptab_gen(&h->tab, h->cur_cexp, h->last_freq, h->nsamples); + DEBUG("CFO generating new table for frequency %.4fe-6\n", freq * 1e6); + } + srslte_vec_prod_ccc(&h->cur_cexp[cexp_offset], input, output, nsamples); +} \ No newline at end of file