Commit graph

36 commits

Author SHA1 Message Date
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
23ecfad9ed fpga_common: Fixed data unpacking for pkt_8x16 format 2015-06-23 23:12:04 -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
81a330f010 fpga_common: Added missing #include's 2015-06-18 20:20:58 -04:00
Jon Szymaniak
d28a953ab9 libbladeRF: Use updated NIOS II packet formats for FPGA >= v0.3.0 2015-06-18 20:20:58 -04:00
Jon Szymaniak
8a9572780c hdl, nios: Added 8x8, 8x16, 8x32, 8x64, and 32x32 packet handlers
This packet handlers replace the pkt_legacy function to use
message formats that require only a single request to perform
the specific action.
2015-06-18 20:20:58 -04:00
Jon Szymaniak
3b0d65ca7f nios: Added VCTCXO trim DAC read routine 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
9bd4ce9157 nios, libbladeRF: Macro renaming, added PIO addr defs
The legacy packet format uses magic values for the "address" for
PIO accesses. This commit adds some definitions of these to be shared
between the NIOS II code and the host code, to help reduce the
use of magic values.

Some general macro naming has been done to keep the macro naming
scheme for packet handlers more consistent.
2015-06-18 20:20:57 -04:00
Jon Szymaniak
4f37d2b202 libbladeRF, fpga_common: Fixed typo in legacy subdevice address macro 2015-06-18 20:20:57 -04:00
Jon Szymaniak
f4a9ec5dca fpga_common: Added <addr>x<data> packet format definitions 2015-06-18 20:20:57 -04:00
Jon Szymaniak
88bb372cf5 fpga_common: Cleaned up header for NIOS II legacy packet format
Removed unused struct and union.

Added summary of the packet format and its response.
2015-06-18 18:34:30 -04:00
Jon Szymaniak
56916e3c54 fpga_common: Updated NIOS Retune packet format to include queue clear 2015-06-18 18:34:29 -04:00
Jon Szymaniak
196abbbea3 nios: Time all operations performed by retune handler 2015-06-18 18:34:29 -04:00
Jon Szymaniak
6c9d15c518 fpga_common: Updated retune packet Success/Failure flag semantics 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
bf24f9ae50 fpga_common: Fixed retune packet pack() param order 2015-06-18 18:34:29 -04:00
Jon Szymaniak
37eebaf9d9 nios: Added "Quick Tune" flag to retune packet 2015-06-18 18:34:28 -04:00
Jon Szymaniak
9f0c6fd2f7 lms: Added flags with "force VCOCAP" option 2015-06-18 18:34:28 -04:00
Jon Szymaniak
80fb8ee526 lms: Struct re-order nitpick 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
090c05d6bd libbladeRF, nios: Added VCOCAP hint to nios retune pkt 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
14f7ea0e39 lms: Fixed @file and copyright dates 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
731123aa40 nios: Fixed simulation build issues 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
d2554d9e1b nios: PC simulation build fixes 2015-06-18 18:34:28 -04:00
Jon Szymaniak
84a9ccc328 nios: Define packet length in shared header 2015-06-18 18:34:28 -04:00
Jon Szymaniak
d7f1908629 nios: Added nios retune packet format 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
Jon Szymaniak
67109af361 libbladeRF, nios: Moved legacy packet format definitions
The definition of the legacy FX3 UART <-> FPGA packet format
has been moved to a top-level fpga_common directory. This
directory will be used to store headers and source files
shared between host code and NIOS II code.
2015-06-18 18:34:28 -04:00