aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
authorAshish Chaudhari <ashish@ettus.com>2015-10-15 13:58:34 -0700
committerAshish Chaudhari <ashish@ettus.com>2016-02-18 09:07:26 -0800
commit2d68f228888807d0fd76c7b759ec39fd86523f67 (patch)
tree0665569a3f78a2ed5b619417d60d0426bdb40192 /host/lib
parentc37ab6091c48b3486b7af745f0a61cdf7db9fc42 (diff)
downloaduhd-2d68f228888807d0fd76c7b759ec39fd86523f67.tar.gz
uhd-2d68f228888807d0fd76c7b759ec39fd86523f67.tar.bz2
uhd-2d68f228888807d0fd76c7b759ec39fd86523f67.zip
x300: Added capability to write_spi to BOTH channels in dboard_iface
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/usrp/x300/x300_dboard_iface.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/host/lib/usrp/x300/x300_dboard_iface.cpp b/host/lib/usrp/x300/x300_dboard_iface.cpp
index 981976867..ef55368c8 100644
--- a/host/lib/usrp/x300/x300_dboard_iface.cpp
+++ b/host/lib/usrp/x300/x300_dboard_iface.cpp
@@ -245,17 +245,17 @@ boost::uint32_t x300_dboard_iface::read_gpio(unit_t unit)
/***********************************************************************
* SPI
**********************************************************************/
-#define toslaveno(unit) \
- (((unit) == dboard_iface::UNIT_TX)? _config.tx_spi_slaveno : _config.rx_spi_slaveno)
-
void x300_dboard_iface::write_spi(
unit_t unit,
const spi_config_t &config,
boost::uint32_t data,
size_t num_bits
){
- if (unit == UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported.");
- _config.spi->write_spi(toslaveno(unit), config, data, num_bits);
+ boost::uint32_t slave = 0;
+ if (unit == UNIT_TX) slave |= _config.tx_spi_slaveno;
+ if (unit == UNIT_RX) slave |= _config.rx_spi_slaveno;
+
+ _config.spi->write_spi(int(slave), config, data, num_bits);
}
boost::uint32_t x300_dboard_iface::read_write_spi(
@@ -265,7 +265,9 @@ boost::uint32_t x300_dboard_iface::read_write_spi(
size_t num_bits
){
if (unit == UNIT_BOTH) throw uhd::runtime_error("UNIT_BOTH not supported.");
- return _config.spi->read_spi(toslaveno(unit), config, data, num_bits);
+ return _config.spi->read_spi(
+ (unit==dboard_iface::UNIT_TX)?_config.tx_spi_slaveno:_config.rx_spi_slaveno,
+ config, data, num_bits);
}
/***********************************************************************