Commit graph

28 commits

Author SHA1 Message Date
Jon Szymaniak
6cf29edca5 lms: Use internal termination when running calibration routines
In terms of avoiding interference from external signals, the
internal termination may be a better option than exposing the
signal path to external pads.
2015-12-28 16:10:39 -05:00
Jon Szymaniak
859377326b nios, lms, libbladeRF: Utilize FPGA support for atomic NINT/NFRAC write
Both the host and NIOS II FPGA retuning modes now make use of
FPGA v0.4.0's atomic write of the LMS6002D NINT and NFRAC PLL registers.

This helps avoid changing the PLL multiple times when attempting to
configure it.
2015-08-27 15:54:25 -04:00
Jon Szymaniak
d0f8af8d8e lms: Adjusted debug/warning level for tuning events 2015-08-25 13:28:05 -04:00
Jon Szymaniak
91b5c474da lms: Further relaxed VCO4 upper limit
We were still seeing some boards that wind up a bit too near the
upper edge of the VCO4 range. This change resolves this on the boards
we've tested.
2015-08-25 13:28:05 -04:00
Jon Szymaniak
df4a48fffd lms: Removed disabled code 2015-08-25 13:28:05 -04:00
Jon Szymaniak
a29bf54e78 lms: Account for long VTUNE transitions during HIGH<->LOW change
The cause of tuning failures in "FPGA tuning" mode is caused by
long VTUNE settling times when switching between the search for
VTUNE HIGH and VTUNE LOW.

We now try to force VTUNE to the opposite value and poll for the
expected change instead of simply delaying and hoping VTUNE
has settled before we sample it. If we don't hit the expected VTUNE
value, we'll attempt to walk VTUNE into that region.
2015-08-25 13:28:05 -04:00
Jon Szymaniak
d919a173be lms: Adjusted upper limit of VCO4 range
With the addition of a warning to the lms.c code, we've been seeing
some codes hit a max VCOCAP value before hitting a VCO limit, indicating
that we're too close to the edge of a band.
2015-08-25 13:28:05 -04:00
Jon Szymaniak
75e7793636 libbladeRF: Added bug catcher for CID 1308077
This addresses an item picked up by Coverity. Defects in bands[] or
frequency checks could potentially cause an out-of-bounds memory access.

A bounds check has been added to avoid an invalid access, should one of
the aforementioned defect ever creep in.
2015-08-12 15:50:00 -04:00
Jon Szymaniak
093aed7288 fpga_common/lms: Fixed #405: Fail to exit loopback mode for f >= 1.5 GHz
This defect was introduced when changing the second parameter to
lms_select_band().
2015-07-15 18:45:19 -04:00
Jon Szymaniak
be019d6a3a fpga_common: Addressed MSVC type conversion warnings
These type conversions (and associated truncations) are intentional.
2015-06-18 20:20:58 -04:00
Jon Szymaniak
a219666893 libbladeRF: Decoupling correction calls from USB code
The backend interface now presents functions for IQ gain/phase
access, instead of lumping it all under "FPGA corrections."

There is no need for the USB code to know anything about LMS
corrections, so this has been moved back up the top level,
with bladerf.c calling into the lms.c functions that now
provide this functionality.

The USB backend now hooks up calls to nios_legacy_* routines.
In the future we can maintain a USB backend that uses these, while
another backend structure proivdes the use of new NIOS packet handlers.
2015-06-18 20:20:57 -04:00
Jon Szymaniak
a9b90f6bd3 lms: Fixed VCO4 limit that was yielding bad VCOCAP values
This change ensures we are able to hit VCO_LOW on the upper
range of VCO4 (as verified by a handful of boards).
2015-06-18 18:34:29 -04:00
Brian Padalino
74e19c3202 lms: Removed library warning messages for debug. 2015-06-18 18:34:29 -04:00
Brian Padalino
a7e914cb17 hdl: Upgraded to the Fast NIOS and whatnot. 2015-06-18 18:34:29 -04:00
Jon Szymaniak
c9fefe0cb5 lms: Added lms_get_quick_tune() implementation 2015-06-18 18:34:29 -04:00
Jon Szymaniak
9f0c6fd2f7 lms: Added flags with "force VCOCAP" option 2015-06-18 18:34:28 -04:00
Jon Szymaniak
cbcca71de5 lms: Provided VCOCAP back to caller 2015-06-18 18:34:28 -04:00
Jon Szymaniak
1208818e26 lms: Rewrote LMS6002D Tuning algorithm
A VCOCAP hint is used as a starting point. The algorithm then walks
either up or down to first find the high or low limit, and then walks
the other way to find the other limit.

These seems to be working well, except we commonly run into a situation
where we never actually see VTUNE = LOW when our estimate is 54 or 55.
2015-06-18 18:34:28 -04:00
Jon Szymaniak
e339d88931 lms: Restored UPOFF and DOWNOFF values to 30 uA default value.
This appears to quicken the change in our VTUNE values.
2015-06-18 18:34:28 -04:00
Jon Szymaniak
bbbe04816f lms, libbladeRF: Moved LMS charge pump offset current configuration
This only needs to be done once per initialization, not every time
the device is re-tuned. Moved this to init_device() to cut down
on SPI transactions required to complete tuning operation.
2015-06-18 18:34:28 -04:00
Jon Szymaniak
400531fdc8 lms: Added VCOCAP estimation
Estimate our initial VCOCAP value using a linear interpolation of
experimentally observed min/max values over a VCO range.
2015-06-18 18:34:28 -04:00
Jon Szymaniak
103f931473 lms: Added debug/benchmark code to count VCOCAP/VTUNE busy waits 2015-06-18 18:34:28 -04:00
Jon Szymaniak
376d51f2e4 nios, libbladeRF: Moved band selection to allow it to execute in NIOS II
After retuning, the high or low band must be selected. This requires
a few control register ("CONFIG_GPIO") and LMS6 accesses. Moving these
to the retune operation already in the NIOS II removes some extra
USB communication time.
2015-06-18 18:34:28 -04:00
Jon Szymaniak
19b1bd77a8 lms: Removed fields from lms_freq structure
freq_hz is not necessary; it can be quickly computed on the host side.

The VCO division ratio is only needed on the host side currently.
2015-06-18 18:34:28 -04:00
Jon Szymaniak
7a2d044f2e lms: Removed reference field from lms_freq structure
This is a compile-time constant, so a macro definition is used.
2015-06-18 18:34:28 -04:00
Jon Szymaniak
1d3d78d9f9 lms: Determine high/low band as part of pre-calculating tuning params
This alleviates the need for lms_set_precalculated_frequency() to know
the original frequency value; it just needs the precalculated
parameters.
2015-06-18 18:34:28 -04:00
Jon Szymaniak
edac278d8b lms: Expose function to pre-calculate tuning parameters 2015-06-18 18:34:28 -04:00
Jon Szymaniak
a4c8cb8b52 libbladeRF, nios: Made LMS6002D code available to NIOS II
To allow the LMS6002D code to be build into the NIOS II code,
lms.c has been moved to fpga_common and its license has been
changed from LGPLv2 to MIT.

Currently, only the subset of functions required for
frequency tuning are used during a NIOS II build.
2015-06-18 18:34:28 -04:00