diff --git a/host/libraries/libbladeRF/src/lms.c b/host/libraries/libbladeRF/src/lms.c index 63c4ed06..cd82a7fe 100644 --- a/host/libraries/libbladeRF/src/lms.c +++ b/host/libraries/libbladeRF/src/lms.c @@ -1935,6 +1935,55 @@ int lms_calibrate_dc(struct bladerf *dev, bladerf_cal_module module) if (status != 0) { return status; } + /* Special decoding addressing case for RXVGA2 */ + if (module == BLADERF_DC_CAL_RXVGA2) { + switch (i) { + + case 0: + /* Set to direct control signals: RXVGA2 Decode = 1 */ + status = bladerf_lms_read(dev, 0x64, &val); + if (status != 0) { + return status; + } + + val |= 1; + + status = bladerf_lms_write(dev, 0x64, val); + if (status != 0) { + return status; + } + + /* VGA2GAINA = 0110, VGA2GAINB = 0 */ + val = 6; + status = bladerf_lms_write(dev, 0x68, val); + if (status != 0) { + return status; + } + + case 2: + /* VGA2GAINA = 0, VGA2GAINB = 0110 */ + val = 6 << 4; + status = bladerf_lms_write(dev, 0x68, val); + if (status != 0) { + return status; + } + + case 4: + /* Set to decode control signals: RXVGA2 Decode = 0 */ + status = bladerf_lms_read(dev, 0x64, &val); + if (status != 0) { + return status; + } + + val &= (~1); + + status = bladerf_lms_write(dev, 0x64, val); + if (status != 0) { + return status; + } + break; + } + } } /* Special case for LPF tuning module where results are diff --git a/host/utilities/bladeRF-cli/src/cmd/calibrate.c b/host/utilities/bladeRF-cli/src/cmd/calibrate.c index 159a9fc3..0affb93d 100644 --- a/host/utilities/bladeRF-cli/src/cmd/calibrate.c +++ b/host/utilities/bladeRF-cli/src/cmd/calibrate.c @@ -46,7 +46,7 @@ int cmd_calibrate(struct cli_state *state, int argc, char **argv) } - if (argc == 1) { + if (argc == 1) { /* Ensure both TX and RX are enabled */ status = bladerf_enable_module(state->dev, BLADERF_MODULE_TX, true); @@ -103,10 +103,9 @@ int cmd_calibrate(struct cli_state *state, int argc, char **argv) return CLI_RET_INVPARAM; } - if (status != 0) { - /* Calibrate it */ - status = bladerf_calibrate_dc(state->dev, module); - } + /* Calibrate it */ + status = bladerf_calibrate_dc(state->dev, module); + } else { return CLI_RET_INVPARAM; }