// reset frame synchronizer object void flexframesync_reset(flexframesync _q) { // reset binary pre-demod synchronizer detector_cccf_reset(_q->frame_detector); // clear pre-demod buffer windowcf_clear(_q->buffer); // reset carrier recovery objects nco_crcf_reset(_q->nco_coarse); nco_crcf_reset(_q->nco_fine); // reset symbol timing recovery state firpfb_crcf_reset(_q->mf); firpfb_crcf_reset(_q->dmf); _q->pfb_q = 0.0f; // filtered error signal // reset state _q->state = STATE_DETECTFRAME; _q->pn_counter = 0; _q->header_counter = 0; _q->payload_counter = 0; // reset frame statistics _q->framestats.evm = 0.0f; }
// push buffered p/n sequence through synchronizer void flexframesync_pushpn(flexframesync _q) { unsigned int i; // reset filterbanks firpfb_crcf_reset(_q->mf); firpfb_crcf_reset(_q->dmf); // read buffer float complex * rc; windowcf_read(_q->buffer, &rc); // compute delay and filterbank index // tau_hat < 0 : delay = 2*k*m-1, index = round( tau_hat *npfb), flag = 0 // tau_hat > 0 : delay = 2*k*m-2, index = round((1-tau_hat)*npfb), flag = 0 assert(_q->tau_hat < 0.5f && _q->tau_hat > -0.5f); unsigned int delay = 2*_q->k*_q->m - 1; // samples to buffer before computing output _q->pfb_soft = -_q->tau_hat*_q->npfb; _q->pfb_index = (int) roundf(_q->pfb_soft); while (_q->pfb_index < 0) { delay -= 1; _q->pfb_index += _q->npfb; _q->pfb_soft += _q->npfb; } _q->pfb_timer = 0; // set coarse carrier frequency offset nco_crcf_set_frequency(_q->nco_coarse, _q->dphi_hat); unsigned int buffer_len = (64+_q->m)*_q->k; for (i=0; i<buffer_len; i++) { if (i < delay) { float complex y; nco_crcf_mix_down(_q->nco_coarse, rc[i]*0.5f/_q->gamma_hat, &y); nco_crcf_step(_q->nco_coarse); // push initial samples into filterbanks firpfb_crcf_push(_q->mf, y); firpfb_crcf_push(_q->dmf, y); } else { // run remaining samples through p/n sequence recovery flexframesync_execute_rxpn(_q, rc[i]); } } // set state (still need a few more samples before entire p/n // sequence has been received) _q->state = STATE_RXPN; }
// reset frame synchronizer object void flexframesync_reset(flexframesync _q) { // reset binary pre-demod synchronizer qdetector_cccf_reset(_q->detector); // reset carrier recovery objects nco_crcf_reset(_q->mixer); nco_crcf_reset(_q->pll); // reset symbol timing recovery state firpfb_crcf_reset(_q->mf); // reset state _q->state = FLEXFRAMESYNC_STATE_DETECTFRAME; _q->preamble_counter= 0; _q->symbol_counter = 0; // reset frame statistics _q->framesyncstats.evm = 0.0f; }