Commit graph

262 commits

Author SHA1 Message Date
Rey Tucker
7dc32cc56f
host: bladerf_get_channel_count now takes a bladerf_direction (#58)
This is more intuitive than 'bool tx'.
2018-06-01 15:49:04 -04:00
Rey Tucker
ae129c5ccd
host: libbladeRF: improve consistency of 'const' modifier location (#54)
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
2018-05-29 13:11:05 -04:00
Rey Tucker
5ef5199d88
host: bladerf_get_*_range now expect struct bladerf_range** (#53)
* 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
2018-05-29 13:10:49 -04:00
Rey Tucker
a0d498e723
host: typedef common parameter types (#51)
* 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
2018-05-25 11:45:38 -04:00
Rey Tucker
1dc6317b93
host: make low-level API calls generic by removing part numbers (#49)
Instead of using specific part numbers for low-level API calls on the bladeRF micro, use generic functionality-based names.
2018-05-25 10:55:04 -04:00
Rey Tucker
c74c6282ad
host: improve platform-independence of bladerf_{set,get}_gain (#48)
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.
2018-05-25 10:53:58 -04:00
Rey Tucker
5023f0cb03
host: fix build errors and clang-scan warnings (#47)
* 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
2018-05-23 12:14:26 -04:00
Rey Tucker
ee55f859b9
host: clean up build warnings across multiple platforms (#21)
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
2018-04-03 18:20:51 -04:00
Rey Tucker
fabe4f50a1 host: libbladeRF: version 1.9.1
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
2018-03-26 15:53:33 -04:00
Rey Tucker
27e7273b42
host: formatting fixes for clang-format, libbladeRF.h comment wording/structure tweaks (#16)
* 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.
2018-03-23 11:17:57 -04:00
Rey Tucker
f7f150fb49 host: libbladeRF: allow null range on bladerf_get_gain_stage_range()
In the event a library user needs to test for the existence of a gain
stage, the bladerf_get_gain_stage_range function may now be called with
a null range, and the return value can be checked to determine whether
it exists.
2018-02-05 16:49:57 -05:00
Rey Tucker
ac55b6edeb
host: libbladeRF: add per-device query of supported loopback modes
* host: libbladeRF: add bladerf_get_loopback_modes

Returns a pointer to an array of supported loopback modes.

* host: libbladeRF: add bladerf_is_loopback_mode_supported()

Tests if a given loopback mode is supported on a device
2018-02-05 16:34:14 -05:00
Rey Tucker
dab88815b1 host: libbladeRF: add BLADERF_CHANNEL_IS_TX() macro
Convenience macro that evals to true if the argument is a TX channel,
false otherwise.
2018-02-05 15:35:28 -05:00
Rey Tucker
db79697bf1 host: libbladeRF: fix compile error on empty struct
clang on OS X complains thus:

error: empty struct has size 0 in C, size 1 in C++ [-Werror,-Wextern-c-compat]
2018-01-15 19:09:47 -05:00
Rey Tucker
bc0d8169d8 host: libbladeRF: doc, consistency fixes
Update bladerf_rf_switch_config struct to use "rfic" instead of "ad9361"
for genericness and consistency.

Also clean up missing/incorrect documentation in various places.

Fix bladeRF-cli to use proper struct member names for
bladerf_rf_switch_config.
2017-12-22 16:02:22 -05:00
Rey Tucker
e51afc828e host: libbladeRF: trivial typo fix in a comment 2017-12-21 12:55:09 -05:00
Rey Tucker
9bab63979b host: libbladeRF: add bladeRF2 capabilities, bladerf_get_channel_count
Squashed commit of the following:

commit d12066467c99bdbb7048285c0616db70ff383e2f
Merge: 3493a3b3c 2770a187a
Author: Rey Tucker <rey.tucker@nuand.com>
Date:   Tue Sep 19 13:56:34 2017 -0400

    Merge branch 'master' into rtucker-host-capabilities

commit 3493a3b3c1ab17ea4a616bbf8b543108e5defeca
Author: Rey Tucker <rey.tucker@nuand.com>
Date:   Thu Sep 14 13:40:33 2017 -0400

    host: libbladeRF: add bladerf_get_channel_count call

    This will return the number of channels available on a given hardware.

commit 609bfc7d4bc4bb1fea09164de184b94fe9f691da
Author: Rey Tucker <rey.tucker@nuand.com>
Date:   Thu Sep 14 13:37:04 2017 -0400

    host: libbladeRF/board: add FW capabilities for bladeRF 2

    Not entirely certain we need a capability flag for bladeRF 2 support in
    the firmware, but now there is one.

commit 12f6d61c0c04df1a52d7552ff3ee45f6faaaf6b1
Author: Rey Tucker <rey.tucker@nuand.com>
Date:   Thu Sep 14 13:35:11 2017 -0400

    host: libbladeRF/board: move capabilities to board.h

    Keeping them common between boards seems prudent for now.
2017-12-21 12:55:07 -05:00
Rey Tucker
6662cf40f2 host: libbladeRF: backwards compat for gain mode
older libbladeRF had BLADERF_GAIN_AUTOMATIC, so aliasing it to
BLADERF_GAIN_DEFAULT to avoid mysterious code breakage
2017-12-21 12:55:07 -05:00
Rey Tucker
c677516ab3 host: libbladeRF: add bladerf_get_gain_modes
Squashed commit of the following:

commit b06ffe841dc5e8cc91cfa743213979be49843b83
Author: Rey Tucker <rey.tucker@nuand.com>
Date:   Fri Sep 15 13:46:59 2017 -0400

    host: libbladeRF: forgot bladerf_get_gain_modes implementation

commit ef115599d0baea3ae27136059aedadaaf67f5f43
Author: Rey Tucker <rey.tucker@nuand.com>
Date:   Fri Sep 15 12:15:07 2017 -0400

    libbladeRF: add bladerf_get_gain_modes

    bladerf_get_gain_modes provides a pointer to an array of gain modes
    supported by the device, including human-readable names.
2017-12-21 12:55:07 -05:00
Rey Tucker
11806609ec libbladeRF/bladerf2: add A9 FPGA support 2017-12-21 12:55:07 -05:00
Rey Tucker
62857242b4 libbladeRF: bladerf_enable_module MIMO support
Change bladerf_enable_module to expect a bladerf_channel instead of a
bladerf_direction.  This should have no impact on existing applications:
BLADERF_RX and BLADERF_TX map to BLADERF_CHANNEL_RX(0) and
BLADERF_CHANNEL_TX(0) respectively.

Modify bladerf2_enable_module to set the expected RFFE control reg bits.
2017-12-21 12:55:07 -05:00
Rey Tucker
81fc77760d libbladeRF: add prototypes for MIMO (de)interleave 2017-12-21 12:55:06 -05:00
Rey Tucker
4dee30d2b2 libbladeRF: constify samples param on sync_tx
Since we aren't going to touch any of the data in the sample buffer on
TX, consting it is a good thing to do.
2017-12-21 12:55:06 -05:00
Ryan Tucker
a378f6a037 bladerf2: handle invalid gain changes gracefully
Squashed commit of the following:

commit da6b51bbe208e5beaeb5de7302177acd10eb096e
Author: Ryan Tucker <ryan.tucker@nuand.com>
Date:   Thu Jul 20 14:16:23 2017 -0400

    libbladeRF: improve wording for clarity

commit 0b14959d6192f687f7c584e0c3d66d83b814530a
Author: Ryan Tucker <ryan.tucker@nuand.com>
Date:   Thu Jul 20 14:16:02 2017 -0400

    bladerf2: general error message improvements

commit 36d6ba728bfc17cf6461fe131ae3af5c2e4c4f1b
Author: Ryan Tucker <ryan.tucker@nuand.com>
Date:   Thu Jul 20 14:05:56 2017 -0400

    bladerf2: warn on invalid gain stage but don't fail

    Some software blindly sets gain stages without checking first, e.g. gqrx
    when switching between bladeRF 1 and bladeRF 2. This will avoid crashes
    in those cases.
2017-12-21 12:55:05 -05:00
Ryan Tucker
2effd65b01 libbladeRF: fix handling of tx gain on bladerf2 2017-12-21 12:55:04 -05:00
Rey Tucker
0c386f45c1 libbladeRF/bladerf2: add initial FPGA size data
Assume an A4 for now.

This lets one stash hostedxA4.rbf into <install_prefix>/share/Nuand/bladeRF
and have it Do The Right Thing for autoloading.

Full implementation will depend on SPI flash, etc
2017-12-21 12:55:04 -05:00
Ryan Tucker
8e98542d95 libbladeRF: doc/formatting fixes
Constrained everything to within 80 characters width, did some
doxygen-oriented cleanup, corrected some misleading information
2017-12-21 12:55:04 -05:00
Ryan Tucker
a3be0b955d host: libbladeRF: add get_gain_mode, set_gain_mode
On boards with hardware AGC, permit client applications to query and
change the gain mode (e.g. manual, automatic fast attack, etc).
2017-12-21 12:55:04 -05:00
Ryan Tucker
65f19e30bf libbladeRF: add ad9361 bist loopback mode 2017-12-21 12:55:04 -05:00
Vanya A. Sergeev
53e3bf6c2c libbladeRF: update docstring for enable module method 2017-12-21 12:55:03 -05:00
Vanya A. Sergeev
6d1b456d05 libbladeRF: clean up API docs 2017-12-21 12:55:03 -05:00
Vanya A. Sergeev
768ddd9364 libbladeRF: strip lms mentions from docs for generic API 2017-12-21 12:55:03 -05:00
Vanya A. Sergeev
36b3233c3b libbladeRF: add union + anon struct to quick tune structure for bladeRF2
for future implementation.
2017-12-21 12:55:03 -05:00
Vanya A. Sergeev
4527d92e89 libbladeRF: split bladerf 1 & 2 specific APIs into their own header files 2017-12-21 12:55:03 -05:00
Vanya A. Sergeev
9260495ca9 libbladeRF: move dc/phase/gain correction from bladerf1-specific to generic 2017-12-21 12:55:03 -05:00
Vanya A. Sergeev
8a42e206f7 libbladeRF: move vctcxo tamer mode from bladerf1-specific to generic 2017-12-21 12:55:03 -05:00
Vanya A. Sergeev
5d488173d0 libbladeRF: move config gpio accessors from bladerf1-specific to generic 2017-12-21 12:55:03 -05:00
Vanya A. Sergeev
51607bb327 libbladeRF: move trigger control accessors from bladerf1-specific to generic 2017-12-21 12:55:03 -05:00
Vanya A. Sergeev
fec3595463 libbladeRF: add doc group for low-level vctcxo trim dac methods 2017-12-21 12:55:03 -05:00
Vanya A. Sergeev
660fb291d2 libbladeRF: move spi flash accessors from bladerf1-specific to generic 2017-12-21 12:55:03 -05:00
Vanya A. Sergeev
e54b76cbb3 libbladeRF: add get tuning mode method 2017-12-21 12:55:02 -05:00
Vanya A. Sergeev
78f8140655 libbladeRF: move set tuning mode from bladerf1-specific to generic 2017-12-21 12:55:02 -05:00
Vanya A. Sergeev
1d41ea5505 libbladeRF: update param directions and returns in api docs 2017-12-21 12:55:02 -05:00
Vanya A. Sergeev
8fa0710227 libbladeRF: move trim dac read/write from bladerf1-specific to generic 2017-12-21 12:55:01 -05:00
Vanya A. Sergeev
7ac2caf419 libbladeRF: move get vctcxo trim from bladerf1-specific to generic 2017-12-21 12:55:01 -05:00
Robert Ghilduta
d8de9f4303 Add bladerf_ad9361_read() and bladerf_ad9361_write() functions 2017-12-21 12:55:00 -05:00
Vanya A. Sergeev
e63af470b9 libbladeRF/bladerf: make rx mux enumerated values generic 2017-12-21 12:54:59 -05:00
Vanya A. Sergeev
2a4c8998a7 libbladeRF: move set/get loopback from bladerf1-specific to generic 2017-12-21 12:54:59 -05:00
Vanya A. Sergeev
9e371cc375 libbladeRF: move set tuning mode from generic to bladerf1-specific 2017-12-21 12:54:59 -05:00
Vanya A. Sergeev
97728b06f3 libbladeRF: move get/set sampling from generic to bladerf1-specific 2017-12-21 12:54:59 -05:00