Commit graph

44 commits

Author SHA1 Message Date
Robert Ghilduta
de0cf95199 matlab: update Simulink block
The Simulink block is updated to work with the latest libbladeRF.
2018-08-07 11:22:19 -05:00
Robert Ghilduta
b98a1fee79 matlab: update bladeRF_rx_gui
Massive changes to bladeRF_rx_gui to allow it to work with the new gain methods
and also allow it to properly inform the user of problems setting gains when
the gain mode (AGC) is set to automatic.
2018-08-07 11:22:19 -05:00
Robert Ghilduta
124bffe86a matlab: add BladeRF_Misc for miscellaneous measurements and controls
Some platforms have power and temperature monitoring, provide a way for them to
be exposed in matlab. To read the temperature of a device run the following:

> b = bladeRF()
> b.misc.temperature

misc.dc_power can be used to read the current power consumption
misc.dc_source be used to determine if the power is coming from USB or AC
2018-08-07 11:22:19 -05:00
Robert Ghilduta
3510033997 matlab: update bladeRF_XCVR
bladeRF_XCVR has to catch up to the new way of doing things in libbladeRF. Low
level gain settings like directly RXLNA, RXVGA1, RXVGA2, TXVGA1, and TXVGA2 have
all been removed to make way for the unified gain setting based on
bladerf_set_gain(). Setting the gain value to 60 for RX indicates maximum RX
gain, while a value of 60 for TX indicates a output power of 0dBm.
2018-08-07 11:22:19 -05:00
Robert Ghilduta
1815ec7695 matlab: identify new boards and FPGA sizes
Adding the new A4 and A9 boards. Currently some decisions are being made by
identifying the generation of the device. In the future this should be replaced
with a feature and capability mask.
2018-08-07 11:22:19 -05:00
Robert Ghilduta
eeb6253657 matlab: update libbladeRF_proto
Add or update the definitions for the following functions:

bladerf_enable_module
bladerf_set_gain
bladerf_set_gain_mode
bladerf_get_gain_mode
bladerf_set_sample_rate
bladerf_set_rational_sample_rate
bladerf_get_sample_rate
bladerf_get_rational_sample_rate
bladerf_set_bandwidth
bladerf_get_bandwidth
bladerf_set_lpf_mode
bladerf_get_lpf_mode
bladerf_select_band
bladerf_set_frequency
bladerf_schedule_retune
bladerf_cancel_scheduled_retunes
bladerf_get_frequency
bladerf_get_quick_tune
bladerf_set_loopback
bladerf_get_loopback
bladerf_trigger_init
bladerf_set_correction
bladerf_get_correction
bladerf_xb200_set_filterbank
bladerf_xb200_get_filterbank
bladerf_xb200_set_path
bladerf_xb200_get_path
bladerf_get_timestamp
bladerf_stream
bladerf_set_stream_timeout
bladerf_get_stream_timeout
bladerf_sync_config
bladerf_sync_tx
bladerf_read_trigger
bladerf_write_trigger
bladerf_get_board_name
bladerf_get_channel_count
bladerf_get_gain
bladerf_get_gain_modes
bladerf_get_gain_range
bladerf_set_gain_stage
bladerf_get_gain_stage
bladerf_get_gain_stage_range
bladerf_get_gain_stages
bladerf_get_sample_rate_range
bladerf_get_bandwidth_range
bladerf_get_frequency_range
bladerf_set_rf_port
bladerf_get_rf_port
bladerf_get_rf_ports
bladerf_get_loopback_modes
bladerf_is_loopback_mode_supported
bladerf_interleave_stream_buffer
bladerf_deinterleave_stream_buffer
bladerf_trim_dac_write
bladerf_trim_dac_read
bladerf_get_tuning_mode
bladerf_get_bias_tee
bladerf_set_bias_tee
bladerf_get_rfic_register
bladerf_set_rfic_register
bladerf_get_rfic_temperature
bladerf_get_rfic_rssi
bladerf_get_rfic_ctrl_out
bladerf_get_pll_lock_state
bladerf_get_pll_enable
bladerf_set_pll_enable
bladerf_get_pll_refclk_range
bladerf_get_pll_refclk
bladerf_set_pll_refclk
bladerf_get_pll_register
bladerf_set_pll_register
bladerf_get_power_source
bladerf_get_clock_select
bladerf_set_clock_select
bladerf_get_clock_output
bladerf_set_clock_output
bladerf_get_pmic_register
bladerf_get_rf_switch_config
2018-08-07 11:22:19 -05:00
Robert Ghilduta
7e015568a8 matlab: change not supported (-8) library errors to Matlab warnings
Most of the changes that make libbladeRF return -8 still allow scripts to run
without serious issues. This commit should be changed back after a few releases
once developers have had a chance to update their scripts.
2018-08-07 11:22:19 -05:00
Robert Ghilduta
106a66fddc matlab: build_thunk() now needs bladeRF1.h and bladeRF2.h
libbladeRF.h references bladeRF1.h and bladeRF2.h so they must now be copied
over to compile the matlab bindings.
2018-08-07 11:22:08 -05:00
Robert Ghilduta
bc576497fc host: python: add trim DAC read/write accessors
These functions get and set trim DAC values
2018-06-20 00:50:31 -04:00
Rey Tucker
152b7be95c
host: python: fix calls to get_*_range (#59)
The Python bindings didn't get updated for the `const struct bladerf_range **` changes in #48 and #53 , but now they are
2018-06-01 15:51:47 -04:00
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
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
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
52f6c08063 host: libbladeRF_bindings: matlab: update libbladeRF_proto.m (#547)
* libbladeRF/matlab: change win64 bool type (#543)

This should fix an error in recent Thunk builds.  I am not sure what the
side effects of this will be (esp. with older Matlab versions) but this
seems to work now.

* host: libbladeRF_bindings: re-sort libbladeRF_proto.m to match recent MATLAB output

* host: matlab: update for libbladeRF 1.9.0

Add a few missing functions:

 bladerf_set_gain_mode
 bladerf_get_gain_mode
 bladerf_set_smb_mode
 bladerf_get_smb_mode
 bladerf_trigger_init
 bladerf_trigger_arm
 bladerf_trigger_fire
 bladerf_trigger_state
 bladerf_set_vctcxo_tamer_mode
 bladerf_get_vctcxo_tamer_mode
 bladerf_xb300_set_trx
 bladerf_xb300_get_trx
 bladerf_xb300_set_amplifier_enable
 bladerf_xb300_get_amplifier_enable
 bladerf_xb300_get_output_power
 bladerf_get_fw_log
 bladerf_init_stream
 bladerf_stream
 bladerf_submit_stream_buffer
 bladerf_submit_stream_buffer_nb
 bladerf_deinit_stream
 bladerf_read_trigger
 bladerf_write_trigger

Add a few missing structs and enums, related to above

Also remove the bool_ret/bool_arg vars, as they aren't really needed any
more.

* host: matlab: fixup uint64s, cleanup

Removed the 'pathsep' from the architecture case, since it's seemingly
set by matlab itself

Not pre-allocating ival, to avoid having to count that high

* host: matlab: comment out stream-related protos

Matlab doesn't support FcnPtrs (bladerf_stream_cb) or voidPtrPtrPtr
(void***), so bladerf_init_stream is not usable.  If bladerf_init_stream
isn't usable, then anything involving struct bladerf_stream isn't
usable.
2018-03-30 14:05:00 -04:00
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
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
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
Rey Tucker
37d457365c bladerf.py: fix device_reset call 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
Vanya A. Sergeev
6be5e8ecf2 libbladeRF_bindings: add python3 binding and example tool 2017-12-21 12:55:04 -05:00
Brian Glod
1410ac2df9 matlab: Update README.md
- Added "Before Starting" section
- Added "MATLAB Toolbox Requirements" section
2017-07-05 08:58:17 -07:00
Jon Szymaniak
e4e7ef896a matlab: Updated version to v0.1.2 2016-06-29 14:35:17 -04:00
Jon Szymaniak
6e35ea384e matlab: Fixed loopback name typo in bladeRF_Simulink.m 2016-01-08 17:56:16 -05:00
Jon Szymaniak
b4b11da4b9 matlab: README.md touch-ups 2016-01-08 10:57:03 -05:00
Jon Szymaniak
0caef9463b matlab: Updated to v0.1.1 2016-01-07 17:04:10 -05:00
Jon Szymaniak
7f6a461348 matlab: Search for thunk file in '.' and MATLABPATH
Our proto file must provide the absolute path to the thunk library,
whether it is in the current directory or in MATLABPATH (as is the
case with our Windows installer).
2016-01-04 22:36:04 -05:00
Jon Szymaniak
e8cdde2f69 matlab: v0.1.0 release 2015-12-30 23:04:09 -05:00
Jon Szymaniak
7e704a8edf matlab: Added automatic RX/TX DC correction 2015-12-28 22:20:20 -05:00
Jon Szymaniak
f255b9ceea matlab: Removed extraneous loopback assignment 2015-12-13 12:31:46 -05:00
Jon Szymaniak
c7148b5031 matlab: Added methods for LMS6 DC cal routines 2015-12-12 21:18:56 -05:00
Jon Szymaniak
b3d268b0bc matlab: Ensure TX DAC is returned to 0+0j for tx.stop()
Waiting `num_buffers` worth of samples through this should
be more than sufficient to achieve this.
2015-12-10 15:09:52 -05:00
Jon Szymaniak
15278332f8 matlab: Added FPGA RX mux mode support 2015-12-10 14:38:55 -05:00
Jon Szymaniak
ea898fb7ae matlab: Added bladeRF.calibrate function 2015-12-08 23:03:28 -05:00
Jon Szymaniak
976bd1a174 matlab: List any functions not found in the library 2015-12-07 11:37:46 -05:00
Jon Szymaniak
2f2dd15876 matlab: Fixed items that caused warnings in 2015b
- varargout must be a cell
- Initial values in StringSets must match exactly, even though
  our accessors are case-insensitive.
2015-12-07 11:34:25 -05:00
Jon Szymaniak
71a96ba160 matlab: Made corrections in the help text for bladeRF/transmit 2015-11-30 12:41:14 -05:00
Jon Szymaniak
43ccce8d5d matlab: Updated README to note tested versions 2015-11-23 18:39:39 -05:00
Jon Szymaniak
e3f31f1e8f matlab: Fixed use of invalid varible in error msg 2015-11-23 18:25:31 -05:00
Jon Szymaniak
628c3e6c5e matlab: Added MATLAB libbladeRF bindings
Moving forward, MATLAB and Simulink support will be offered via
libbladeRF bindings maintained in this repository. These MATLAB bindings
are implemented as a thin object-oriented interface that utilizes
loadlibrary() and calllib().

Simulink support is achieved through a MATLAB System block
implementation that uses bladeRF.m. Users are welcome to adapt the
provided bladeRF_Simulink.m implementation to their particular needs.
2015-11-23 17:55:36 -05:00