Commit graph

1,721 commits

Author SHA1 Message Date
Rey Tucker
ba8e485d2f host: python: set version = 0.9.1 (so we can bump to 1.0.0 at release) 2018-03-26 12:44:50 -04:00
Rey Tucker
5240d995b0
host: python: Python packaging (#18)
* host: python: reorganize files for packaging

* host: python: move bladerf-tool CLI into main()

* host: python: move cdef string into its own file

Since packaging lets us have multiple files easily, this cleans up
bladerf.py a lot.

* host: python: add __init__.py skeleton

* host: python: fixup py3flakes and pycodestyle

* host: python: fix unused local variable

* host: python: more reorganization to appease Python

* host: python: update .gitignore for setup detritus

* host: python: initial setup.py

* host: python: update accompanying documentation

* host: python: cleanup setup.py

* host: python: move license stuff into files

* host: python: version 1.0.0
2018-03-26 12:26:46 -04:00
Rey Tucker
f857b28b34
host: python: fix up error handling on rssi property (#17) 2018-03-23 16:28:24 -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
4cf79bc8c0 host: python: add RSSI readback for AD9361 2018-03-15 18:24:58 -04:00
Rey Tucker
585cb926bb host: bladeRF-cli: add 'print rssi' function 2018-03-15 18:24:58 -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
Rey Tucker
677216dfd5 host: libbladeRF: fix dependencies for doxygen
It should rebuild on any .h change, not just libbladeRF.h
2018-03-15 18:24:07 -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
Rey Tucker
eb9a7a313d
host: libbladeRF/bladerf2: Fix safety checks on board-specific functions (#10)
Some are missing, others are too noisy in practice. Uniformly return BLADERF_ERR_UNSUPPORTED.

* host: bladerf2: test for board support in bias_tee

* host: bladeRF2: be quieter on unsupported gain mode query

* host: bladerf2: check for compat on ina219 reads

* host: libbladeRF/bladerf2: fixup remaining board compat checks
2018-03-15 11:43:27 -04:00
Brian Glod
3d54be5937 host: bladeRF-cli: Add bladeRF2 clock_out command
Allow user to control whether to enable the external clock output (UFL
CLKOUT).
2018-03-09 13:04:38 -05: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
6ae3419abf host: bladeRF-cli: Add bladeRF2 clock_sel command
Allow user to control which Si53304 clock input to select: onboard
VCTCXO or external UFL clock. The external clock must be present before
changing the active clock, otherwise the host connection to the bladeRF
will drop.
2018-03-09 12:50:51 -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
0d320fd53d host: bladeRF-cli: Add print_power_source function 2018-03-01 15:20:19 -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
01cdbc78f5 host: libbladeRF: fix lock collision in load_fpga
Because we call bladerf*_initialize from within bladerf*_load_fpga, and
we then do things that do their own locking from within
bladerf*_initialize, problems ensue when loading FPGAs from bladeRF-cli.

This removes the lock from the greater load_fpga call, and moves it to
just around the dev->backend->load_fpga call.
2018-03-01 15:20:02 -05:00
Rey Tucker
21831477f1 host: libbladeRF: force AD9361 freq change on init
The EVM coming out of the AD9361 is about 1% worse than it should be,
when doing a TX directly after initialization.  However, by changing the
frequency and changing it back, the EVM returns to the expected level.

I suspect libad9361 is missing a calibration step somewhere in the
initialization, but we can work around this by doing two frequency
changes during initialization.
2018-03-01 15:18:28 -05:00
Rey Tucker
a8cad99887 host: libbladeRF: harmonize get_gain_stage_range
Sync up bladerf_get_gain_stage_range between bladeRF 1 and bladeRF 2,
and let a null range argument be okay
2018-02-05 17:20:42 -05: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
84e1b5d099 host: libbladeRF: use common macro for channel decoding 2018-02-05 15:35:28 -05:00
Rey Tucker
ee2c85d02a host: bladeRF-cli: refactor out str<->channel conversions 2018-02-05 15:35:28 -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
14e7f317a2 host: common/conversions: add str2channel
Converts from a string to a bladerf_channel
2018-02-05 15:35:28 -05:00
Rey Tucker
b9db604801 host: common/conversions: add firmware and rf_bist loopback options 2018-02-05 15:35:28 -05:00
Rey Tucker
fe211170f2 host: bladeRF-cli/generate.bash: fix pandoc warning
pandoc emits a warning if a title is not specified for the
page.

Also: cleanup
2018-01-15 19:24:12 -05:00
Rey Tucker
2f906c5e5e host: bladeRF-cli: improve cmd_help.h generation
generate.bash now allows specification of paths to awk, date, grep, and
so forth; this will permit it to be used in very weird environments.

generate.bash now uses bash built-ins whenever possible.

generate.bash checks the existence of necessary non-built-in commands
before doing anything, and prints a useful error if they're wrong.

Only try doing generate.bash if pandoc and bash are installed.
2018-01-15 19:13:58 -05:00
Rey Tucker
ad0e61049a host: cmake: make the search for libtecla quiet
This eliminates an unnecessary "libtecla not found" error during cmake.
2018-01-15 19:13:58 -05:00
Rey Tucker
fced701f87 host: libbladeRF/thirdparty/adi: fix errno conflicts
The various macros for error numbers are already defined in
errno.h, so we can just include that and avoid conflicts with
other OSes (e.g. OS X).
2018-01-15 19:09:47 -05:00
Rey Tucker
e9e735ca9e host: libbladeRF/bladerf.c: don't use alias attribute
This works great with name-brand gcc on Linux, but unfortunately
it is not supported by clang on OS X.  So, do it the hard way.
2018-01-15 19:09:47 -05:00
Rey Tucker
1518d174a4 host: libbladeRF: include malloc dir on OS X
The ad9361 software includes malloc.h, which is actually located
in /usr/include/malloc/malloc.h on OS X.
2018-01-15 19:09:47 -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
857e301156 host: bladeRF-cli: fix implicit-fallthrough warning
This should fix it, and allow it to build with compilers which aren't
GCC 7+.
2018-01-15 17:56:50 -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
Brian Glod
4fdc92ca27 host: bladeRF-cli: Intentional case fallthrough
Add compiler attribute to denote that the case fallthrough is
intentional and to not throw a warning about it.
2018-01-15 13:35:27 -05:00
Brian Glod
f06679bf78 host: libbladeRF_test: Fix GCC undefined operation
"state->idx = (++state->idx)" is undefined behavior for the compiler
2018-01-15 13:31:24 -05:00
Rey Tucker
1b066d7ca9 host: libbladeRF_test: test_digital_loopback fixes
Make test_digital_loopback work with bladeRF micro

General cleanup/modernization
2018-01-12 18:07:19 -05:00
Rey Tucker
41e21dc1cb host: bladeRF-cli: fix uninitialized status var in cmd_poke
Fixes clang warning:

poke.c:137:24: error: variable 'status' is used uninitialized whenever
'if' condition is false [-Werror ,-Wsometimes-uninitialized]

Realistically, there is no way that 'status' could be used on line 141
without one of f, f2, or f3 being true (thus setting the value), due to
the test on 132. There is no harm in initializing it anyway, though.
2017-12-22 16:04:02 -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
877caacd72 host: libbladeRF: add FPGA 0.7.[01] to bladerf2 compat table 2017-12-22 16:01:03 -05:00
Rey Tucker
3eec0ad9ee host: thirdparty/adi: fix warnings
Fixes missing fields in initializers and misuse of abs() (using abs() on
an unsigned int has no effect, and using it on an int64_t risks
truncation)

Also fix up a missing newline in an error printf
2017-12-22 15:59:20 -05:00
Rey Tucker
31c1a52007 host: bladeRF-cli: fixup merge issue with AGC commands 2017-12-21 12:55:09 -05:00
Rey Tucker
7e36cd38fc host: libbladeRF: fixup merge issues with bladeRF1 AGC 2017-12-21 12:55:09 -05:00
Rey Tucker
470480d32f host: libbladeRF_test: fix cmake error from merge 2017-12-21 12:55:09 -05:00
Rey Tucker
903e6053c5 host: bladeRF-cli: add ADF4002 lock status to print 2017-12-21 12:55:09 -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