Commit graph

84 commits

Author SHA1 Message Date
Rey Tucker
14e7f317a2 host: common/conversions: add str2channel
Converts from a string to a bladerf_channel
2018-02-05 15:35:28 -05:00
Rey Tucker
1bf9f4e9af host: common/host_config.h: add macro for fallthrough cases
GCC 7.x adds a warning for implicit fallthroughs in switch cases. We
intentionally do this sometimes, so adding an EXPLICIT_FALLTHROUGH macro
to denote this.

The __attribute__((fallthrough)) on a null statement is only supported
by GCC 7.x as well, hence the macro.
2018-01-15 17:55:17 -05:00
Vanya A. Sergeev
bccd7e19f7 libbladeRF: migrate api to 64-bit frequency 2017-12-21 12:54:58 -05:00
Vanya A. Sergeev
9062b66d9c libbladeRF: migrate bladerf_module to bladerf_channel and bladerf_direction 2017-12-21 12:54:58 -05:00
Vanya A. Sergeev
562243c80d libbladeRF: refactor codebase for multi-board support
Includes fixups for clean rebase atop bladeRF commit 8b420eb
2017-12-15 18:15:06 -05:00
Robert Ghilduta
a39a81d700 Add config option file parsing capabilities
This commit adds functions that parse config option files
2017-12-07 20:34:34 -08:00
Robert Ghilduta
68bf8e231a Add string parsing functions
The line to argumenet parser uses a two pass approach. The first pass
finds beginning and end of arguments, and counts the number of quotes.
The second pass copies the characters into the argument buffers.
2017-12-07 20:34:33 -08:00
Robert Ghilduta
82c424cc8c Add string manipulation functions 2017-12-07 20:34:33 -08:00
Robert Ghilduta
38664eaa10 Add bladeRF and libbladeRF specific look-ups and conversion 2017-12-07 17:10:28 -08:00
Robert Ghilduta
579199768c Cleanup files to add options file parser 2017-12-07 17:10:28 -08:00
Robert Ghilduta
dccc4edc2f Filenames are starting to become ambiguous without full pathnames 2017-12-07 17:10:28 -08:00
Rey Tucker
5ba5f16221 clock_gettime.h: include host_config.h 2017-08-02 19:25:49 -04:00
Rey Tucker
0779109841 host: explicitly test for clock_gettime (#508)
Instead of using version-based guessing on macOS (which appears to fail
with newer versions of Xcode on older versions of macOS), use an
explicit test for clock_gettime in CMake.
2017-08-02 15:02:38 -04:00
Robert Ghilduta
7aff155a97 libbladeRF: add gain specific mean errors to DC calibration table
The DC calibration table will now include mean residual errors for 3 different
gains (that will be used by the AGC amont other things) including:
    Max : LNA=6dB, RXVGA1=30dB, RXVGA2=15dB
    Mid : LNA=6dB, RXVGA1=30dB, RXVGA2= 0dB
    Low : LNA=3dB, RXVGA1=12dB, RXVGA2= 0dB

The DC cal table version has been bumped to 2. This commit will allow backward
compatibility with existing DC cal tables.
2017-07-05 08:59:08 -07:00
Thomas Brown
21690e5da0 libbladeRF: Use system clock_gettime on macOS >= 10.12. 2017-07-05 08:58:17 -07:00
Ian Frasch
63afe69ac5 bladeRF-fsk: Added support for Visual studio 2012
- Added round() and roundf() functions for VS version 2012 and below, since
    they lack implementation of these functions

- Minor formatting edits to make the compiler (v17.00.50727.1) happy
2016-08-22 16:13:20 -04:00
Jon Szymaniak
210591e8e2 host: common: Added conversion routines for bladerf_smb_mode 2016-05-17 00:20:01 -04:00
Jon Szymaniak
7656724db7 host: common: Added trigger role conversion routines 2016-05-17 00:20:01 -04:00
Jon Szymaniak
8c0ac5629d host/common: Added string <-> trigger enum conversion functions 2016-05-17 00:19:53 -04:00
Jon Szymaniak
3537c3a49a host: common: Added str2bool() conversion routine
This is intended for use with functions that require
enable/disable, on/off, true/false.
2016-04-25 19:03:34 -04:00
Jon Szymaniak
a4a065f3ae host: Added endian-conversion macros for use with constants
The existing macros make use of functions, which cannot be used to
define constants on architectures where they are actually implemented
as functions (as opposed to macros).
2016-01-11 23:38:02 -05:00
Jon Szymaniak
279db7aee4 host/common: Added missing extern "C" { ... } in headers 2016-01-11 23:01:20 -05:00
Bjoern Kerler
5a360d7b4c libbladeRF: use c99 snprintf/vsnprintf for vc14
These functions come with MSVC 2015 (vc14) as part of the c99 support.
The compatibility definitions in host_config.h.in were causing
a compilation error. This fix disables the compatibility definitions
when the more recent vc14 compiler is detected.
2016-01-10 17:27:36 -08:00
Jon Szymaniak
221083a2d6 host/common: Added MIT-licensed DC calibration routines
This code is a re-designed set of DC calibration functionality
built atop of libbladeRF.

This functionality provides the ability to:
    - Run LMS6002D DC calibrations per module (or all at once)

    - Search for nominal RX/TX DC correction values for a single
      frequencies or a range of frequencies.

To avoid inducing issue #408 by utilizing a single stream,
rather than repeatedly starting and stopping streams.

No TX thread is used, as this is uneccessary; it is sufficient to
flush 0+0j samples through the TX path at the start of calibration
and allow the DAC to remain held in this state as the FPGA
(intentionally) underruns.
2015-12-28 22:29:04 -05:00
Jon Szymaniak
454b4931ec host/common: Added str to bladerf_module & bladerf_dc_cal_module fns 2015-12-28 22:20:20 -05:00
Nick "Darkfiber" Wolff
327dce57b1 host: Minimal build fixes for FreeBSD
Work still needs to be done to troubleshoot libusb issues.
2015-12-14 11:36:15 -05:00
Jon Szymaniak
c5d1e4a9f3 host/common: Made devcfg_perform_sync_config() parameter const 2015-11-29 21:20:54 -05:00
Jon Szymaniak
672cf27eae host/common: Added string to uint64 and double w/ suffix conversions 2015-10-08 12:48:55 -04:00
Jon Szymaniak
bf9f8a62a4 host: Moved device config helpers to host/common
People may find these useful when developing their own tools or
contributions to the bladeRF codebase.
2015-06-21 23:07:40 -04:00
Jon Szymaniak
3cfb507f91 host_common: Use size_t for array length, MSVC build fix
size_t or unsigned int are preferred for variables that describe
the length of an array.

This change fixes an additional MSVC build issue caused by
test_scheduled_retune.
2015-06-21 22:52:19 -04:00
Jon Szymaniak
cd6cb0cca7 host/common: Added SC16Q11 <-> float conversion routines 2015-04-10 13:39:09 -04:00
Jon Szymaniak
4d5027bc41 host: Don't redefine inline for C++ (Windows) in host-compat header
It appears the 'inline' keyword still isn't supported as of VS2013
(MSVC 18.00). However, we shouldn't be re-defining it
if building with VS's C++ compiler.
2015-01-22 18:47:31 -05:00
Jon Szymaniak
41bcf7b12c host: Centralized duplicated code
Moved function to get string description to conversions.c.

There's a similar function within libbladeRF's backend.c, but that
is intended to be used in the device information string; this is
intended to be a bit more humand-readable.
2014-12-18 17:58:21 -05:00
Jon Szymaniak
7218273716 libbladeRF_test: Added common cmdline arg handling and device config
Most of the libbladeRF_test items contain their own command line
argument handling, yielding repeated code and inconsistent invocations.

This commit introduces common command-line argument handling and device
configuration for the most used device parameters.

Future patches will migrate the tests over to using this functionality.
New tests should use this immediately.
2014-11-18 17:09:11 -05:00
Jon Szymaniak
64275e768f host: Updated and moved Windows C99 compatibility headers
Visual Studio 2013 now includes these headers, so they have
been moved as not to conflict (even though they are intended to
be equivalent.)

Our stdbool.h was providing an incorrect typedef; sizeof(bool)
should have been 1, not sizeof(int).

Per http://msdn.microsoft.com/en-us/library/tf4dy80a.aspx:
    "In Visual C++4.2, the Standard C++ header files contained a typedef
    that equated bool with int. In Visual C++ 5.0 and later, bool is
    implemented as a built-in type with a size of 1 byte. That means
    that for Visual C++ 4.2, a call of sizeof(bool) yields 4, while in
    Visual C++ 5.0 and later, the same call yields 1. This can cause
    memory corruption problems if you have defined structure members of
    type bool in Visual C++ 4.2 and are mixing object files (OBJ) and/or
    DLLs built with the 4.2 and 5.0 or later compilers."
2014-11-14 15:19:18 -05:00
Jon Szymaniak
7c0969a44d host: Enable short source file name and line # in log output by default
When making log_* calls, add these two lines to the corresponding
CMake file prior to add_library() or add_executable():

    set(SRC_TO_SHORTEN ${MY_SRC_LIST})
    include(ShortFileMacro)

Many thanks to LazyDodo for providing the CMake approach for doing this,
and to rwr for suggesting this change.
2014-10-02 12:29:14 -04:00
Jon Szymaniak
c4d5bbe8b4 bladeRF-cli: Added '#' end-of-line comment
All characters following '#' are ignored as part of an end-of-line
comment.

Thank you to Karl Lehenbauer for suggesting this change.
2014-08-15 01:47:36 -04:00
Jon Szymaniak
7b0cc24f95 libbladeRF: Introduced thread-safety to the API
Top-level API functions now acquire a per-device "control lock" before
performing control, programming, and low-level access operations.
(Specifically, these are the functions that manipulate the device handle
and utilize the FX3 <-> FPGA UART.)

Synchronous data transfer functions now hold a per-device, per-module
"sync lock" to ensure these operations are carried out atomically. The
control lock is also held during sync configuration, as upcoming changes
to introduce metadata support will require flipping some config bits on
the FPGA during this operation.

Only these top-level functions shall acquire these locks; the core logic
code should be able to assume that locks are already acquired.

To alleviate confusion, functions that are *not* part of the API, and
therefore are safe to call within the core logic, are stripped of the
bladerf_ prefix.

Now that pthreads is a required dependency, use of the sync API is
is no longer marked optional in the libbladeRF build.
ENABLE_LIBBLADERF_SYNC and related items have been removed from the
CMake build.
2014-08-02 19:22:49 -04:00
Jon Szymaniak
a151ba4f99 bladeRF-cli: Handle unterminated quote as a non-fatal error condition
And additional return value has been added to str2args in order to
differentiate between an unexpected fatal (e.g, memory) error and
unterminated quotes.

This was previously causing cmd_handle() to fall through to an
"Unknown error" case, which is treated as a fatal error, resulting in
the CLI being terminated.

Thank you to Jens Elofsson (jenselo) for tracking down and reporting the
underlying defect! (Issue #259)
2014-06-30 01:34:00 -04:00
Jon Szymaniak
67938789f9 libbladeRF: Load calibration tables or FPGA bitstream on device open
On Linux and OSX, the following directories will be searched,
in the order listed:
    ~/.config/Nuand/bladeRF
    ~/.Nuand/bladeRF
    /etc/Nuand/bladeRF

In Windows, %appdata%/Nuand/bladeRF will searched.

The following files will be loaded, if found in these search paths:

    FPGA image: hostedx40.rbf or hostedx115.rbf, depending on the
                size of the FPGA reported by the device.

    DC Calibration tables: <serial>_dc_<rx|tx>.tbl

libbladeRF: Added Windows support to file_find
2014-06-30 00:04:39 -04:00
Jon Szymaniak
c1ffb2dafe libbladeRF: Moved ARRAY_SIZE() macro to host config header 2014-06-30 00:04:38 -04:00
Jon Szymaniak
952db39be0 libbladeRF: Added DC calibration table structure and routines 2014-06-30 00:04:37 -04:00
Ryan Tucker
b24cf702b6 Support Windows builds with MinGW
- Our surrogate inttypes.h is only needed for Visual Studio 2010 and
  earlier, due to the lack of C99 support.
- Move all the inttypes.h includes into host_config.h, where we can
  do the ugly in a centralized location
- MinGW on Linux is case-sensitive -- reflect that when including
  windows.h.
2014-06-21 13:41:44 -04:00
Jon Szymaniak
e0f6ee0eea bladeRF-cli: Added -e <command> support
This option allows interactive mode commands to be executed from the
command line. Multiple -e <cmd> arguments may be provided; they will be
executed in the order they are specified.

Operations/command are performed in the following order:
    - Command line options (e.g., FPGA load, firmware flash)
    - Commands from '-e <cmd>' arguments
    - Commands from script files
    - Interactive mode commands
2014-05-28 21:33:27 -04:00
Jon Szymaniak
28cb63e375 common: Fixed comment typo introduced in 18c4e23a 2014-05-06 23:28:23 -04:00
Jon Szymaniak
18c4e23a56 libbladeRF: Fixed OSX build issue due to invalid endian wrapper macro 2014-05-06 22:57:26 -04:00
Jon Szymaniak
fc6827f03f libbladeRF: Refactored backend i/f to allow for new USB drivers
This work is largely based upon or directly from contributions by LazyDodo.

To allow for other USB drivers (e.g., native host drivers, the CyAPI) to
be more easily integrated, all driver-agnostic bladeRF<->USB code has
been moved to a generic USB backend. The intent is here is to decouple
bladeRF-specific logic from these USB "driver" interfaces to remove
unnecessary code duplication.

The contained changes include:
 - Splitting the libusb backend code into backend/usb/usb.c and
   backend/usb/libusb.c, and some cleanup in the moved code.

 - Removal of the flash_firmware() backend function. This is has been
   moved to flash.c, and is implemented atop the backend flash
   functions.

 - Removal of legacy support in the USB code. All legacy support
   is planned for removal and replacement with an appropriate
   error code to denote that a FW upgrade is required.
2014-05-06 21:59:41 -04:00
Jon Szymaniak
3ad30c3b5a libbladeRF: Windows build fix for test_sync program
Build error results from treating warnings as errors, with possible overflow in 64 -> 32bit conversion.
2014-03-08 19:55:22 -05:00
Jon Szymaniak
ffb54863b2 libbladeRF: Added loopback and clean SIGTERM handling to test_sync 2014-03-08 19:55:21 -05:00
Jon Szymaniak
daaa2e92c8 libbladeRF: Re-implemented sync interface, updated API docs, renamed timeout function
The sync interface has been re-implemented atop the existing
asynchronous interface. This is currently opt-in and only enable when
pthreads support is enabled and available.

Some clarifications have been made in the API documentation,
specifically in the explanations of the various stream parameters.

The bladerf_set_transfer_timeout and bladerf_get_transfer_timeout have
been named more appropriately, as these control stream transfer
timeouts, as opposed to all transfers.
2014-03-08 19:55:21 -05:00