Fix up the verbose logging on nios_ad9361_spi_read/write so that the
numbers line up, and so that it expands out multi-reads and multi-writes
in a useful fashion.
In the event of a timeout, an error is emitted from the actual place where the timeout occurred.
Also, if ENABLE_LIBBLADERF_SYNC_LOG_VERBOSE is defined, it will now print out a condensed status of all the buffers on each run through the sync state machine.
* host: sync: add error message when wait_for_buffer times out
* host: libusb: add error message for timeout
* clean up wording on libusb.c err a bit
* host: sync_worker: add debug prints on init failures
* host: bladerf2: print wallclock time on enable_module
* host: sync: add more super-verbose debug print
* host: sync: simplify ifdef
* host: libbladeRF: clang-format modified functions
Corrects an issue where enabling multiple RX channels would create some confusing discontinuities in the sample stream.
The first RX channel configured would start samples buffering in the FIFO, but the second configuration would not be apparent until after those samples were read.
This PR also does a general refactoring of bladerf2_enable_module and associated helper functions to make the logic flow more clear.
* host: cmake: add function to set SHORT_FILE_ def
The function, based heavily off of a Stack Overflow example :), goes
through all of the source files defined for a given target and sets the
SHORT_FILE_ definition for them.
This results in debug log messages relative to the top directory of the
project, i.e.:
[DEBUG @ host/libraries/libbladeRF/src/board/bladerf2/bladerf2.c:930]
_set_tx_mute: muting TX1 (cached: 10000)
* host: libbladeRF: enable Shortfile for libbladerf_shared
I have a tendency to put 'const' in the middle of the type, e.g. struct bladerf_range const **range
I can argue that it is superior to do it that way, but I don't want to, as it makes no difference and just looks weird :)
* libbladeRF.h: put const at start of type
* board.h: move const to the start of types
* libbladeRF: brf_get_*_range expect bladerf_range**
Previously, the bladerf_get_*_range family of functions expected a
struct bladerf_range *
The gain-related functions turned out to require a double ptr to work
properly. For consistency, this commit changes libbladeRF to use a
double ptr on all the range functions, instead of just the gain ones.
* bladeRF-cli: update get-range function calls
* libbladeRF: add typedefs for common parameter types
This adds typedefs for, and changes libbladeRF.h to use said typedefs
for, the following:
bladerf_gain -> int
bladerf_sample_rate -> unsigned int
bladerf_bandwidth -> unsigned int
bladerf_frequency -> uint64_t
bladerf_timestamp -> uint64_t
bladerf_correction_value -> int16_t
The bladerf_{set,get}_gain functions are now reasonably hardware-independent.
On TX channels, setting a gain of 60 dB should result in a CW TX power of roughly 0 dBm.
On RX channels, 60 dB is the maximum gain level.
The ranges returned by bladerf_get_gain_range are adjusted to reflect this.
The Nios config GPIO bit used for BLADERF_GPIO_TIMESTAMP_DIV2 was
repurposed in bladeRF2 to be used as the UFL output clock enable
bit. Commit fixes unintentional clearing of this bit when timestamps are
not used.
* devinfo: fix strncpy error
Fix two build errors on Arch:
/root/bladeRF/host/libraries/libbladeRF/src/devinfo.c:308:5:
error: ‘strncpy’ destination unchanged after copying no bytes
[-Werror=stringop-truncation]
/root/bladeRF/host/libraries/libbladeRF/src/devinfo.c:308:5:
error: ‘strncpy’ output truncated before terminating nul copying as many
bytes from a string as its length [-Werror=stringop-truncation]
* bladerf2/params: fix implicit conversion error
/root/bladeRF/host/libraries/libbladeRF/src/board/bladerf2/params.c:437:7:
error: implicit conversion from 'int' to 'int16_t' (aka 'short') changes
value from 32768 to -32768 [-Werror,-Wconstant-conversion]
32768, 0, 0, 0, 0, 0, 0, 0,
^~~~~
* Doxyfile: fix CLANG_ASSISTED_PARSING warning
fixes:
warning: Tag `CLANG_ASSISTED_PARSING' at line 1033 of file
`/root/bladeRF/build/host/libraries/libbladeRF/doc/doxygen/Doxyfile'
belongs to an option that was not enabled at compile time.
To avoid this warning please remove this line from your
configuration file or upgrade it using "doxygen -u", or recompile
doxygen with this feature enabled.
warning: Tag `CLANG_OPTIONS' at line 1041 of file
`/root/bladeRF/build/host/libraries/libbladeRF/doc/doxygen/Doxyfile'
belongs to an option that was not enabled at compile time.
To avoid this warning please remove this line from your
configuration file or upgrade it using "doxygen -u", or recompile
doxygen with this feature enabled.
* libbladeRF: fix doxygen build error
fixes:
/home/rtucker/dev/privatebladeRF/host/libraries/libbladeRF/include/libbladeRF.h:2284:
warning: unable to resolve link to `sync_tx_meta.html' for \link command
* bladeRF-fsk: fix clangscan warning
/root/bladeRF/host/utilities/bladeRF-fsk/c/src/correlator.c:261:59:
warning: The left operand of '/' is a garbage value
corr->ins1->real = corr->ins2->real = samples[i].i/2048.0f;
~~~~~~~~~~~~^
1 warning generated.
* fpga_common/lms.c: fix clangscan warning
/root/bladeRF/fpga_common/src/lms.c:2329:14: warning: 3rd function call
argument is an uninitialized value
status = write_vcocap(dev, base, f->vcocap, vcocap_reg_state);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
* test_repeated_stream: fix clangscan warning
/root/bladeRF/host/libraries/libbladeRF_test/test_repeated_stream/src/main.c:284:9:
warning: 1st function call argument is an uninitialized value
pthread_join(rx_thread, NULL);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
* test_interleaver: fix clangscan warning
/root/bladeRF/host/libraries/libbladeRF_test/test_interleaver/src/main.c:119:17:
warning: 4th function call argument is an uninitialized value
snprintf((rowstr + rowidx), rowsize - rowidx, "%02x",
*u8buf++);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
* test_tx_gmsk_bursts: fix clangscan warning
/root/bladeRF/host/libraries/libbladeRF_test/test_timestamps/src/test_tx_gmsk_bursts.c:69:5:
warning: 2nd function call argument is an uninitialized value
printf(" Frequency: %u\n", s->frequency);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
* ad9361_api.c: fix clangscan warning
/root/bladeRF/host/libraries/libbladeRF/src/driver/thirdparty/adi/ad9361_api.c:445:3: warning: Value stored to 'ret' is never read
ret = -ENODEV;
^ ~~~~~~~
1 warning generated.
* correlator: another attempt to fix clangscan warning
* Revert "fpga_common/lms.c: fix clangscan warning"
This reverts commit 8cbb5f03f0d0927befa5053e9564df06d13ede72.
* test_interleaver: fixup clang-scan warning
some sloppy init, some messy iteration, the usual :)
/root/bladeRF/host/libraries/libbladeRF_test/test_interleaver/src/main.c:124:17:
warning: 4th function call argument is an uninitialized value
* Revert "ad9361_api.c: fix clangscan warning"
This reverts commit 14a7f8f53f84aeff721a752259ca9596a13e3a2a.
* bladeRF-fsk: fixup clang-scan warning fix
The functions which return ranges, available modes, gain stages, etc, do
not directly access the hardware and should therefore not need locks
around them.
* host: libbladeRF/bladerf2: FIR filter updates
New FIR filters based upon research and experimentation. The default RX
FIR filter was built using Analog Devices' filter design tools, which
account for the filters upstream of the RX FIR block.
Additionally, two 128-tap, decimate/interpolate-by-2 filters are
present, for RX and TX, providing an even flatter spectrum under certain
circumstances.
* host: libbladeRF/bladerf2: default bypass TX FIR
The default TX FIR filter configuration literally does nothing, so this
disables it entirely by default.
* host: libbladeRF: fix async.h include in cyapi.c
* host: libbladeRF: add devinfo.h include to cyapi.c
* host: libbladeRF: cyapi.c: swear profusely at MSVC
* host: libbladeRF: add bladerf_ad9361_get_ctrl_out
Adds functionality to read the CTRL_OUT pins from the AD9361 RFIC.
* host: bladeRF-cli: add print for AD9361 CTRL_OUT
* host: python: add support for ad9361_ctrl_out
* host: libbladeRF: deprecate bladeRF1 gain controls
We now have bladerf_{get,set}_gain and bladerf_{get,set}_gain_stage,
which are both general-purpose functions replacing the bladeRF1-specific
VGA/LNA library calls.
* host: libbladeRF: deprecate bladeRF1 trimdac controls
Instead of bladerf_dac_write and bladerf_dac_read, folks should use
bladerf_trim_dac_write and bladerf_trim_dac_read.
With this commit, we build without warnings on Arch Linux; CentOS 7; Debian 8 and 9; latest Fedora; Ubuntu 14.04, 16.04, 17.10, and 18.04; Visual Studio 2017; and macOS 10.13.3 w/ Homebrew.
* host: libbladeRF: compile AD9361 srcs with -std=gnu11
Fixes compile errors involving ‘for’ loop initial declarations only
allowed in C99 or C11 mode, on older GCCs.
* host: libbladeRF/adi: remove stdbool workaround
This is not necessary now that we're building to -std=gnu11, and in
fact, it seems to create a conflict.
* host: libbladeRF: pre-declare loop variables
Some compilers are not happy with declaring the loop variable in the for
statement. Begrudgingly placate them.
* host: libbladeRF_test: pre-declare loop variables
Some compilers are not happy with declaring the loop variable in the for
statement. Begrudgingly placate them.
* host: bladeRF-cli: pre-declare loop variables
Some compilers are not happy with declaring the loop variable in the for
statement. Begrudgingly placate them.
* host: libbladeRF: remove refs to strings.h
Windows doesn't have strings.h, but string.h seems to do just fine.
* host: libbladeRF: fix windows compile errors (WIP)
* host: libbladeRF/ad9361: fix windows compile error
"IGNORE" is #define'd in the Windows environment, creating a conflict.
Renaming this to solve the conflict.
* host: common: add setenv implementation for Windows
* host: libbladeRF: build setenv.c stub on Windows
* host: bladeRF-cli: use setenv stub on Windows
* host: common: fixup spacing consistency in setenv
* host: libbladeRF: cast channel macros to bladerf_channel
Visual Studio is picky about this, and throws warnings.
* host: libbladeRF: bladerf2.c: undo workaround for bladerf_channel
* host: libbladeRF: bladerf_get_gain_stages count type is now size_t
This fixes a Windows compile error, and is also generally more sensible.
* host: bladeRF-cli: fix windows compile errors
* host: ad9361: fix variadic macro syntax
Fixes Windows build errors
* host: ad9361: rename _DEBUG to AD9361_DEBUG
Visual Studio automagically sets _DEBUG if the /MDd option is set. Turns
out that a lot of the debugging sections don't build in Visual Studio,
so this accounts for a large number of the build errors...
* host: libbladeRF: fixes for Visual Studio builds
* host: common: fixes for Visual Studio builds
* host: libbladeRF/ad9361: fixes for Visual Studio builds
* host: libbladeRF_test: fixes for Visual Studio builds
* host: bladeRF-cli: fixes for Visual Studio builds
* host: bladeRF-cli: fix static analysis warnings
Fixes potential memory leak in main
Fixes unused values in set_adf_refclk, set_samplerate
* host: common: fix static analysis warnings
fixes:
unread variable in perform_rx_cal
memory leaks in add_arg, add_opt
* host: libbladeRF: fix static analysis warnings
fixes unused variables in bladerf2_set_gain and xb100_enable
* host: libbladeRF: clang-format of bladerf.c
* host: libbladeRF: update apply_config_options
Update apply_config_options to use new semantics for channel specifiers
and range min/max determination
Also fix a couple typos
* host: libbladeRF/doc: fixup old channel references
Calling ReleaseMutex without CloseHandle will let the mutex still exist until the process exists.
In such scenario, further calls to CreateMutex will succeed but GetLastError will return 183 (ERROR_ALREADY_EXISTS) causing libbladerf to fail opening the device. This can be assessed by running ```libbladeRF_test_open.exe -c 2 -v debug```.
Cypress backend is not affected as it systematically closes the handle after releasing the mutex.
* host: libbladeRF: fix typo of "bandwidth" cfg file key
* host: libbladeRF: add documentation for config files
* host: libbladeRF: config.c: minor typo fix
* host: libbladeRF_test: add test case for config file parsing
Creates a surrogate config file with a few different scope restrictions,
then makes sure the configuration is applied appropriately in the end.
This leads to AGC being disabled on every call of bladeRF-cli.
Please see https://github.com/Nuand/bladeRF/blob/master/host/utilities/bladeRF-cli/src/cmd/xb300.c#L117 for the proper usage.
I'm not sure if only checking LSB is the proper way to do it, as val (uint32_t) is uninitialized and str2bool sees it as bool (on my machine "off" is 2048 and "on" is 2049), but it would even work if those "else if's" are being
reordered, thus initialized by something else to a non-zero value, or you could zero it right before the str2bool call.
The printf call might not be needed anymore.
Notes:
With the latest changes in kalibrate-bladeRF (add win32 support), changing the buffer sizes of m_x_cb, m_y_cb, m_e_cb, the results of the program look even more odd. Were those changes intended? Either the outputs are correct
before and after the patch, or one BTS has the worst clock in history. I think it's the second one.
With the latest FPGA change (0.7.0 -> 0.7.1, using edge_detector instead of pulse_gen), even setting the sample rate can sometimes lead to a failure. (At least on my board, only shortly after power-on)
Have a nice weekend!
Signed-off-by: Christian Inci <chris.gh@broke-the-inter.net>
This version is part of development series of changes, not an official
release.
This version of libbladeRF is intended for use with:
FX3 Firmware v2.1.0 (or v1.9.1)
FPGA v0.7.2
Changes:
* Refactor to support for multiple product lines
* Add support for the bladeRF Micro product
* API: replace bladerf_module with bladerf_channel, a
reverse-compatible change to handle products with multiple
independent RF paths in the same direction
* API: BREAKING CHANGE - on bladerf_set_frequency, et al, the frequency
parameter is now uint64_t instead of unsigned int
* Significant code cleanup
* Various other changes that will be listed in more detail during an
official release
* host: libbladeRF: clang-format fixes
* host: bladeRF-cli: clang-format fixes
* host: libbladeRF: spacing/wording/clang-format
Improve wording of various parts, add missing params, clean up various
wrap anomalies, and make it run clean through clang-format.