int bladerf_set_sample_rate(struct bladerf *dev, bladerf_module module, uint32_t rate, uint32_t *actual) { int status; MUTEX_LOCK(&dev->ctrl_lock); status = si5338_set_sample_rate(dev, module, rate, actual); MUTEX_UNLOCK(&dev->ctrl_lock); return status; }
int bladerf_set_sample_rate(struct bladerf *dev, bladerf_module module, uint32_t rate, uint32_t *actual) { return si5338_set_sample_rate(dev, module, rate, actual); }
int init_device(struct bladerf *dev) { int status; uint32_t val; /* Readback the GPIO values to see if they are default or already set */ status = CONFIG_GPIO_READ( dev, &val ); if (status != 0) { log_debug("Failed to read GPIO config %s\n", bladerf_strerror(status)); return status; } if ((val & 0x7f) == 0) { log_verbose( "Default GPIO value found - initializing device\n" ); /* Set the GPIO pins to enable the LMS and select the low band */ status = CONFIG_GPIO_WRITE(dev, 0x57); if (status != 0) { return status; } /* Disable the front ends */ status = lms_enable_rffe(dev, BLADERF_MODULE_TX, false); if (status != 0) { return status; } status = lms_enable_rffe(dev, BLADERF_MODULE_RX, false); if (status != 0) { return status; } /* Set the internal LMS register to enable RX and TX */ status = LMS_WRITE(dev, 0x05, 0x3e); if (status != 0) { return status; } /* LMS FAQ: Improve TX spurious emission performance */ status = LMS_WRITE(dev, 0x47, 0x40); if (status != 0) { return status; } /* LMS FAQ: Improve ADC performance */ status = LMS_WRITE(dev, 0x59, 0x29); if (status != 0) { return status; } /* LMS FAQ: Common mode voltage for ADC */ status = LMS_WRITE(dev, 0x64, 0x36); if (status != 0) { return status; } /* LMS FAQ: Higher LNA Gain */ status = LMS_WRITE(dev, 0x79, 0x37); if (status != 0) { return status; } /* Set a default samplerate */ status = si5338_set_sample_rate(dev, BLADERF_MODULE_TX, 1000000, NULL); if (status != 0) { return status; } status = si5338_set_sample_rate(dev, BLADERF_MODULE_RX, 1000000, NULL); if (status != 0) { return status; } /* Set a default frequency of 1GHz */ status = tuning_set_freq(dev, BLADERF_MODULE_TX, 1000000000); if (status != 0) { return status; } status = tuning_set_freq(dev, BLADERF_MODULE_RX, 1000000000); if (status != 0) { return status; } /* Set the calibrated VCTCXO DAC value */ status = DAC_WRITE(dev, dev->dac_trim); if (status != 0) { return status; } /* Set up LMS DC offset register calibration and initial IQ settings, * if any tables have been loaded already */ status = apply_lms_dc_cals(dev); } return status; }