sdr: fixed RX sample data conversion
This commit is contained in:
parent
be5fa06950
commit
a6f12d876b
|
@ -36,7 +36,7 @@ static int rx_callback(hackrf_transfer *transfer)
|
||||||
|
|
||||||
for(size_t i = 0; i < nsamples; i++) {
|
for(size_t i = 0; i < nsamples; i++) {
|
||||||
liquid_float_complex sample =
|
liquid_float_complex sample =
|
||||||
0.0078125f * (transfer->buffer[2*i + 0] + I * transfer->buffer[2*i + 1]);
|
0.0078125f * ((int8_t)transfer->buffer[2*i + 0] + I * (int8_t)transfer->buffer[2*i + 1]);
|
||||||
|
|
||||||
int result = cbuffercf_push(sdr_ctx->rx_buf, sample);
|
int result = cbuffercf_push(sdr_ctx->rx_buf, sample);
|
||||||
if(result != LIQUID_OK) {
|
if(result != LIQUID_OK) {
|
||||||
|
@ -158,6 +158,8 @@ static result_t stop_streaming(sdr_ctx_t *ctx)
|
||||||
fsleep(1e-3);
|
fsleep(1e-3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fsleep(10e-3); // ensure all asynchronous USB communication has stopped
|
||||||
|
|
||||||
ctx->status = SDR_STATUS_IDLE;
|
ctx->status = SDR_STATUS_IDLE;
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
@ -221,12 +223,13 @@ result_t sdr_start_rx(sdr_ctx_t *ctx)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
result = hackrf_set_freq(ctx->hackrf, SDR_RX_FREQ - SDR_RX_IF_SHIFT);
|
|
||||||
CHECK_HACKRF_RESULT(result, "hackrf_set_freq");
|
|
||||||
|
|
||||||
result = hackrf_set_sample_rate(ctx->hackrf, SDR_RX_SAMPLING_RATE);
|
result = hackrf_set_sample_rate(ctx->hackrf, SDR_RX_SAMPLING_RATE);
|
||||||
CHECK_HACKRF_RESULT(result, "hackrf_set_sample_rate");
|
CHECK_HACKRF_RESULT(result, "hackrf_set_sample_rate");
|
||||||
|
|
||||||
|
result = hackrf_set_freq(ctx->hackrf, SDR_RX_FREQ - SDR_RX_IF_SHIFT);
|
||||||
|
fprintf(stderr, "Set RX frequency to %f Hz.\n", SDR_RX_FREQ - SDR_RX_IF_SHIFT);
|
||||||
|
CHECK_HACKRF_RESULT(result, "hackrf_set_freq");
|
||||||
|
|
||||||
result = hackrf_set_lna_gain(ctx->hackrf, SDR_GAIN_RX_LNA);
|
result = hackrf_set_lna_gain(ctx->hackrf, SDR_GAIN_RX_LNA);
|
||||||
CHECK_HACKRF_RESULT(result, "hackrf_set_lna_gain");
|
CHECK_HACKRF_RESULT(result, "hackrf_set_lna_gain");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue