Commit graph

28 commits

Author SHA1 Message Date
Rey Tucker
05f7fd571a host: refactoring bladerf2.c
General documentation cleanup, function name adjustments, merging of
redundant structures, etc.

fpga_common/ad936x_helpers:
    Contains wrappers for AD936x RFIC functionality.

fpga_common/bladerf2_common:
    Contains bladeRF2-specific helper functions and constants.

fpga_common/ad936x_params:
    Reformat (no more tabs, phew)

    Move ina219 shunt const to bladerf2_common

host/common/range:
    Move functions and macros for handling bladerf_range structs

../libbladeRF/include/bladeRF2.h:
    Explicitly index RX/TX FIR enums

    Update references to ad936x_params.c

../libbladeRF/src/board/bladerf2/common:
    New macros for boilerplate:
        - WITH_MUTEX: wrap around locked blocks
        - CHECK_STATUS: calls function, checks return code
        - CHECK_AD936X: calls function, checks return code, translates
          from AD936x to libbladeRF error codes
        - CHECK_*_LOCKED: above, but unlocks mutex before erroring
        - NULL_CHECK: checks a var for null

    Move helper functions into here

../libbladeRF/src/board/bladerf2/bladerf2.c:
    Use new macros

    Code style fixes

    Remove redundant code
2018-11-26 18:03:45 -05:00
Rey Tucker
045708a0f3 libbladeRF: add format macros for frequency, timestamp
Adds new format macros for displaying bladerf_frequency and
bladerf_timestamp values to libbladeRF.h.

Transitions bladerf1.c and bladerf2.c to use these new macros,
and also cleans up a few more places where the typedefs aren't
currently used.

Also fixes a doxygen warning for undocumented #defines in
bladeRF2.h.

Fixes #577
Fixes #618
Fixes #620
2018-09-12 17:50:40 -04:00
Rey Tucker
eaf9475a44 libbladeRF/bladerf2: add support for lower sample rates
This commit adds libbladeRF support for sample rates down to 0.521 Msps
on the bladeRF 2.0.

* Add bladerf_rfic_rxfir and bladerf_rfic_txfir enums to bladeRF2.h
* Add fns: bladerf_{get,set}_rfic_{rx,tx}_fir for controlling the RFIC's
  FIR filters
* Add members to the bladerf2_board_data struct for tracking FIR filter
  status, and whether or not it is in low_samplerate_mode
* Shift bladerf2_initialize to use the new setters for rx and tx FIR
* Update bladerf2_set_sample_rate to use the 4x FIR if the sample rate
  is in the "low range"
2018-09-04 12:33:37 -04:00
Brian Glod
84ea9784ec host: libbladeRF: Rename clock select option
The bladeRF-micro has an option to use either its onboard VCTCXO or an
external 38.4 MHz clock as the clock source for components on the
board. This change addresses some ambiguity in the naming of the onboard
option by renaming it from 'vctcxo' to 'onboard'.

The valid options are now:

1. onboard
2. external
2018-08-23 23:29:56 -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
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
8919cac557 host: add support for AD9361's CTRL_OUT pins (#28)
* 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
2018-05-22 12:58:06 -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
10d0f549b2
host: add bladerf_adf4002_{get,set}_refclk and related functionality (#15)
* host: libbladeRF: add functions to get/set ADF4002 refclk frequency

* host: bladeRF-cli: add print/set adf_refclk

* host: python: add adf4002_refclk functions

This permits getting and setting the ADF4002 reference clock
frequency.

>>> import bladerf
>>> b = bladerf.BladeRF()
ad9361_init : AD936x Rev 2 successfully initialized
>>> b.adf4002_refclk
10000000
>>> b.adf4002_refclk = 9000000
>>> b.adf4002_refclk
9000000
>>> b.adf4002_refclk = 900000000
[ERROR @
"/home/rtucker/dev/privatebladeRF/host/libraries/libbladeRF/src/board/bladerf2/bladerf2.c":4360]
bladerf_adf4002_set_refclk: bladerf_adf4002_calculate_ratio failed:
Provided parameter was out of the allowable range
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File
"/home/rtucker/dev/privatebladeRF/host/libraries/libbladeRF_bindings/python/bladerf.py",
line 1581, in set_adf4002_refclk
    _check_error(ret)
  File
"/home/rtucker/dev/privatebladeRF/host/libraries/libbladeRF_bindings/python/bladerf.py",
line 998, in _check_error
    raise globals()[errorval.name](err)
bladerf.RangeError: Provided parameter was out of the allowable range
>>> b.adf4002_refclk
9000000
>>> b.adf4002_refclk = 10000000
>>> b.adf4002_refclk
10000000

* host: libbladeRF: make ADF convenience functions static

bladerf_adf4002_set_refclk is much nicer (and safer) than calculating
the R/N ratio and then doing a bladerf_adf4002_configure.

* host: python: update cffi header block
2018-03-23 11:10:14 -04:00
Rey Tucker
8898192015 host: libbladeRF/bladeRF2: add AD9361 RSSI access
Adds bladerf_ad9361_get_rssi() API call, to query the RSSIs from the
AD9361 RFIC.
2018-03-15 18:24:58 -04:00
Rey Tucker
06fb60f719 host: libbladeRF/bladeRF2: fix doxygen grouping for Si53304 2018-03-15 18:24:07 -04:00
Brian Glod
22e90c763c host: libbladeRF: Clock output enable for bladeRF2
Add functinos to enable/disable the external clock output (UFL CLKOUT).
2018-03-09 13:04:38 -05:00
Brian Glod
2f4ec99c3d host: libbladeRF: Clock input select for bladeRF2
Si53304 clock input selection getter and setter functions.
2018-03-09 12:50:51 -05:00
Brian Glod
75bf9d0043 host: libbladeRF: Add power source accessor
Intended for use by bladeRF-micro, which has a TPS2115A auto power
mux. The function will read the power status bit from the Nios GPIO and
set the human-readable enum corresponding to the active power source.
2018-03-01 15:20:19 -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
1479696aa2 host: bladerf2: add bladerf_adf4002_get_locked fn
Determines the lock status of the ADF4002 chip
2017-12-21 12:55:09 -05:00
Rey Tucker
151c000ae8 host: bladerf2: ADF4002 configuration
Add bladerf_adf4002_configure and bladerf_adf4002_calculate_ratio
functions to set up the ADF4002.
2017-12-21 12:55:09 -05:00
Rey Tucker
55c8866d28 host: bladeRF2: fix ADF4002 poke functionality 2017-12-21 12:55:08 -05:00
Rey Tucker
9af8e2458d host: bladeRF2: change ad9361 temperature to a float
also divide it by 1000 since that seems to be the thing to do
2017-12-21 12:55:08 -05:00
Rey Tucker
70f533e462 host: bladeRF2: add bladerf_ad9361_temperature function 2017-12-21 12:55:08 -05:00
Rey Tucker
9c6d6d9a7b first cut of bladerf_get_rf_switch_config 2017-12-21 12:55:08 -05:00
Rey Tucker
7cec443e48 host: bladeRF2: minor formatting tweaks 2017-12-21 12:55:08 -05:00
Rey Tucker
c6ba55b347 host: libbladeRF: add ADF4002 enable setter/getter 2017-12-21 12:55:08 -05:00
Rey Tucker
2c96247cd6 host: add support for bias tee
e.g.

print biastee
set biastee rx 1
set biastee tx 1
set biastee rx 0
set biastee tx 0
2017-12-21 12:55:08 -05:00
Rey Tucker
e433628ddf host: add ina219 readback to bladeRF-cli
Example output from "print ina219":

  Bus voltage:  4.896 V
  Load current: 0.56 A
  Load power:   2.76 W
2017-12-21 12:55:08 -05:00
Rey Tucker
ae0c803f39 libbladeRF: add bladerf_adf4002_{read,write} accessors 2017-12-21 12:55:06 -05:00
Vanya A. Sergeev
6d1b456d05 libbladeRF: clean up API docs 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