host: bladerf2: init ina219 before ad9361

This is a workaround for persistent USB timeouts after AD9361
init when CMAKE_BUILD_TYPE=Release.

If DEBUG is defined, ad9361_verify_fir_filter_coef reads in all
the FIR filter coeffs from the 9361 and makes sure they are as
expected.  If it is NOT defined, it skips this check.

For reasons unknown, if ina219_init is called immediately after
ad9361_ensm_restore_prev_state (the last thing that happens before
ad9361_verify_fir_filter_coef in ad9361_load_fir_filter_coef),
libusb times out and everything goes terribly wrong.  Adding a
usleep(100) is sufficient to avoid this.

There does not seem to be a reason why this should make any
difference whatsoever, but this seems to do the trick.
This commit is contained in:
Ryan Tucker 2017-05-30 12:34:05 -04:00 • committed by Robert Ghilduta
commit 5bddc8da29

View file

@ -356,6 +356,17 @@ static int bladerf2_initialize(struct bladerf *dev)
return status;
}
/* Initialize INA219 */
/* For reasons unknown, this fails if done immediately after
* ad9361_set_rx_fir_config when DEBUG is not defined. It shouldn't make
* a difference, but it does. TODO: Investigate/fix this */
status = ina219_init(dev, ina219_r_shunt);
if (status < 0) {
log_error("INA219 init error: %d\n", status);
return status;
}
/* Initialize AD9361 */
status = ad9361_init(&board_data->phy, &ad9361_init_params, dev);
if (status < 0) {
log_error("AD9361 initialization error: %d\n", status);
@ -374,12 +385,7 @@ static int bladerf2_initialize(struct bladerf *dev)
return errno_ad9361_to_bladerf(status);
}
status = ina219_init(dev, ina219_r_shunt);
if (status < 0) {
log_error("INA219 init error: %d\n", status);
return status;
}
/* Set up band selection */
status = bladerf2_select_band(dev, BLADERF_TX, board_data->phy->pdata->tx_synth_freq);
if (status < 0) {
log_error("bladeRF TX band select error: %d\n", status);