Commit graph

4 commits

Author SHA1 Message Date
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
4cf79bc8c0 host: python: add RSSI readback for AD9361 2018-03-15 18:24:58 -04:00
Rey Tucker
b2786e9ce2
host: libbladeRF-bindings/python: general updates (#11)
* host: libbladeRF-bindings/python: general updates

This commit adds the following changes:

Overall:
* Adds an _import_header.py tool, which parses libbladeRF.h (or other
  headers) into a convenient string ready for ffi.cdef
* Passes pycodestyle and pyflakes checks cleanly

bladerf.py:
* Various new class wrappers for enums, etc
* Subclassed exceptions (e.g. bladerf.UnsupportedError will be raised if
  libbladeRF returns BLADERF_ERR_UNSUPPORTED)
* Added functions for bootloader firmware recovery
* More comments all around
* Use properties instead of getters/setters:
   >>> b = bladerf.BladeRF()
   >>> # OLD:
   >>> b.get_devinfo()
   >>> b.set_clock_select(ClockSelect.External)
   >>> # NEW:
   >>> b.devinfo
   >>> b.clock_select = ClockSelect.External
* Added more functions, particularly for bladeRF 2
* Added a Channel class, for channel-specific properties:
   >>> b = bladerf.BladeRF()
   >>> ch = d.Channel(bladerf.CHANNEL_RX(0))
   >>> ch.frequency = 2.45e9

bladerf-tool.py:
* General changes to use properties instead of get_/set_ functions
* Also updated to use subclassed exceptions from bladerf.py
* Dump a lot more info with the 'info' command
* Look for bootloader devices with the 'probe' command
* Added 'recover_fw' command, for firmware recovery
* Moved from single-channel paradigm to MIMO paradigm on 'rx', 'tx'

* host: python: implement more methods, various fixes

Implement loopback, rx_mux, ad9361_temperature, and adf4002_* functions

Fix set_clock_select type handling

Use 4-space indent in cffi block, for placating text editors

Add -v option to bladerf-tool.py info, to clean things up a bit
2018-03-15 11:45:11 -04:00
Vanya A. Sergeev
6be5e8ecf2 libbladeRF_bindings: add python3 binding and example tool 2017-12-21 12:55:04 -05:00