sdr: add gain configuration

This commit is contained in:
Thomas Kolb 2022-04-08 16:17:00 +02:00
parent 715cda83a8
commit 96f10f7fb6
2 changed files with 37 additions and 0 deletions

View file

@ -46,4 +46,12 @@
// NOTE: the SDR center frequency will be SDR_RX_FREQ - SDR_RX_IF_SHIFT. // NOTE: the SDR center frequency will be SDR_RX_FREQ - SDR_RX_IF_SHIFT.
// gain configuration
#define SDR_GAIN_TX_AMP 0.0f // extra power amplifier. Set to 14.0f to activate.
#define SDR_GAIN_TX_LNA 0.0f // normal variable gain amplifier.
#define SDR_GAIN_RX_AMP 0.0f // extra input amplifier. Set to 14.0f to activate.
#define SDR_GAIN_RX_LNA 30.0f // RF variable gain amplifier.
#define SDR_GAIN_RX_VGA 24.0f // Baseband variable gain amplifier.
#endif // CONFIG_H #endif // CONFIG_H

View file

@ -151,6 +151,23 @@ result_t sdr_start_rx(sdr_ctx_t *ctx)
fprintf(stderr, "sdr: activateStream fail: %s\n", SoapySDRDevice_lastError()); fprintf(stderr, "sdr: activateStream fail: %s\n", SoapySDRDevice_lastError());
} }
// set gains
if(SoapySDRDevice_setGainElement(ctx->sdr, SOAPY_SDR_RX, 0, "AMP", SDR_GAIN_RX_AMP) != 0) {
fprintf(stderr, "sdr: setGainElement fail: %s\n", SoapySDRDevice_lastError());
return ERR_SOAPY;
}
if(SoapySDRDevice_setGainElement(ctx->sdr, SOAPY_SDR_RX, 0, "LNA", SDR_GAIN_RX_LNA) != 0) {
fprintf(stderr, "sdr: setGainElement fail: %s\n", SoapySDRDevice_lastError());
return ERR_SOAPY;
}
if(SoapySDRDevice_setGainElement(ctx->sdr, SOAPY_SDR_RX, 0, "VGA", SDR_GAIN_RX_VGA) != 0) {
fprintf(stderr, "sdr: setGainElement fail: %s\n", SoapySDRDevice_lastError());
return ERR_SOAPY;
}
return OK; return OK;
} }
@ -161,6 +178,18 @@ result_t sdr_start_tx(sdr_ctx_t *ctx, size_t burst_size)
fprintf(stderr, "sdr: activateStream fail: %s\n", SoapySDRDevice_lastError()); fprintf(stderr, "sdr: activateStream fail: %s\n", SoapySDRDevice_lastError());
} }
// set gain
if(SoapySDRDevice_setGainElement(ctx->sdr, SOAPY_SDR_TX, 0, "AMP", SDR_GAIN_TX_AMP) != 0) {
fprintf(stderr, "sdr: setGainElement fail: %s\n", SoapySDRDevice_lastError());
return ERR_SOAPY;
}
if(SoapySDRDevice_setGainElement(ctx->sdr, SOAPY_SDR_TX, 0, "LNA", SDR_GAIN_TX_LNA) != 0) {
fprintf(stderr, "sdr: setGainElement fail: %s\n", SoapySDRDevice_lastError());
return ERR_SOAPY;
}
return OK; return OK;
} }