static void qpsk_demod(complex float, int *);
static void ofdm_txframe(struct OFDM *, complex float [OFDM_SAMPLESPERFRAME], complex float *);
static int coarse_sync(struct OFDM *, complex float *, int);
-static void freq_shift(struct OFDM *, complex float [], complex float [], int);
/* Defines */
ofdm->foff_est_gain = 0.01f;
ofdm->foff_est_hz = 0.0f;
- ofdm->rx_foff_hz = 0.0f;
ofdm->sample_point = 0;
ofdm->timing_est = 0;
ofdm->nin = OFDM_SAMPLESPERFRAME;
ofdm->foff_est_hz = val;
}
-void ofdm_rx_shift_freq(struct OFDM *ofdm, float val) {
- if (val > -500.0f && val < 500.0) {
- ofdm->rx_foff_hz = val;
- }
-}
-
/*
* --------------------------------------
* ofdm_mod - modulates one frame of bits
}
}
-/*
- * -----------------------------
- * Frequency shift modem signal
- * -----------------------------
- *
- * The use of complex input and output allows single sided
- * frequency shifting (no images).
- */
-
-static void freq_shift(struct OFDM *ofdm, complex float rxbuf_fcorr[], complex float rx[], int nin) {
- int i;
-
- float woff = TAU * ofdm->rx_foff_hz / OFDM_FS;
-
- for (i = 0; i < nin; i++) {
- rxbuf_fcorr[i] = rx[i] * cexpf(I * woff * i);
- }
-}
-
/*
* ------------------------------------------
* ofdm_demod - Demodulates one frame of bits
float woff_est = TAU * ofdm->foff_est_hz / OFDM_FS;
- freq_shift(ofdm, ofdm->rxbuf_fcorr, ofdm->rxbuf, ofdm->nin);
-
/* update timing estimate -------------------------------------------------- */
if (ofdm->timing_en == true) {
/* update timing at start of every frame */
- st = (OFDM_M + OFDM_NCP + OFDM_SAMPLESPERFRAME) - floorf(OFDM_FTWINDOWWIDTH / 2) + ofdm->timing_est;
- en = st + OFDM_SAMPLESPERFRAME - 1 + OFDM_M + OFDM_NCP + OFDM_FTWINDOWWIDTH;
+ st = ((OFDM_M + OFDM_NCP) + OFDM_SAMPLESPERFRAME) - floorf(OFDM_FTWINDOWWIDTH / 2) + ofdm->timing_est;
+ en = st + OFDM_SAMPLESPERFRAME - 1 + (OFDM_M + OFDM_NCP) + OFDM_FTWINDOWWIDTH;
complex float work[(en - st)];
*/
for (i = st, j = 0; i < en; i++, j++) {
- work[j] = ofdm->rxbuf_fcorr[i] * cexpf(-I * woff_est * i);
+ work[j] = ofdm->rxbuf[i] * cexpf(-I * woff_est * i);
}
ft_est = coarse_sync(ofdm, work, (en - st));
* Convert the time-domain samples to the frequency-domain using the rx_sym
* data matrix. This will be 18 carriers of 11 symbols (P P DDDDDDD P P)
*
- * So we will have one modem data frame and four pilots to do magic.
+ * So we will have one modem data frame and four pilots.
*/
for (i = 0; i < (OFDM_NS + 3); i++) {
/* down-convert at current timing instant---------------------------------- */
for (j = st, k = 0; j < en; j++, k++) {
- work[k] = ofdm->rxbuf_fcorr[j] * cexpf(-I * woff_est * j);
+ work[k] = ofdm->rxbuf[j] * cexpf(-I * woff_est * j);
}
matrix_vector_conjugate_multiply(ofdm, ofdm->rx_sym[0], work); /* sym[0] = previous pilot */
/* down-convert at current timing instant---------------------------------- */
for (j = st, k = 0; j < en; j++, k++) {
- work[k] = ofdm->rxbuf_fcorr[j] * cexpf(-I * woff_est * j);
+ work[k] = ofdm->rxbuf[j] * cexpf(-I * woff_est * j);
}
matrix_vector_conjugate_multiply(ofdm, ofdm->rx_sym[rr + 1], work); /* sym[1..9] = this pilot + Data + next pilot */
/* down-convert at current timing instant---------------------------------- */
for (j = st, k = 0; j < en; j++, k++) {
- work[k] = ofdm->rxbuf_fcorr[j] * cexpf(-I * woff_est * j);
+ work[k] = ofdm->rxbuf[j] * cexpf(-I * woff_est * j);
}
matrix_vector_conjugate_multiply(ofdm, ofdm->rx_sym[OFDM_NS + 2], work); /* sym[10] = last pilot */