aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/dboard
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp/dboard')
-rw-r--r--host/lib/usrp/dboard/db_cbx.cpp2
-rw-r--r--host/lib/usrp/dboard/db_tvrx2.cpp14
-rw-r--r--host/lib/usrp/dboard/db_ubx.cpp54
3 files changed, 37 insertions, 33 deletions
diff --git a/host/lib/usrp/dboard/db_cbx.cpp b/host/lib/usrp/dboard/db_cbx.cpp
index db7f84932..ad255460e 100644
--- a/host/lib/usrp/dboard/db_cbx.cpp
+++ b/host/lib/usrp/dboard/db_cbx.cpp
@@ -142,7 +142,7 @@ double sbx_xcvr::cbx::set_lo_freq(dboard_iface::unit_t unit, double target_freq)
}
//keep pfd freq low enough to achieve 50kHz BS clock
- BS = std::ceil(pfd_freq / 50e3);
+ BS = int(std::ceil(pfd_freq / 50e3));
if(BS <= 1023) break;
}
diff --git a/host/lib/usrp/dboard/db_tvrx2.cpp b/host/lib/usrp/dboard/db_tvrx2.cpp
index c74c64471..9300483d1 100644
--- a/host/lib/usrp/dboard/db_tvrx2.cpp
+++ b/host/lib/usrp/dboard/db_tvrx2.cpp
@@ -1103,7 +1103,7 @@ tvrx2::~tvrx2(void){
* TDA18272 Register IO Functions
**********************************************************************/
void tvrx2::set_scaled_rf_freq(double rf_freq){
- _tda18272hnm_regs.set_rf_freq(_freq_scalar*rf_freq/1e3);
+ _tda18272hnm_regs.set_rf_freq(boost::uint32_t(_freq_scalar*rf_freq/1e3));
}
double tvrx2::get_scaled_rf_freq(void){
@@ -1320,9 +1320,9 @@ void tvrx2::tvrx2_tda18272_tune_rf_filter(boost::uint32_t uRF)
read_reg(0x26, 0x2B);
subband_freqs = get_tda18272_rfcal_result_freq_range(1);
- uRFCal0 = subband_freqs.start();
+ uRFCal0 = boost::uint32_t(subband_freqs.start());
subband_freqs = get_tda18272_rfcal_result_freq_range(4);
- uRFCal1 = subband_freqs.start();
+ uRFCal1 = boost::uint32_t(subband_freqs.start());
if(uRF < uRFCal0)
subband = 0;
@@ -1335,9 +1335,9 @@ void tvrx2::tvrx2_tda18272_tune_rf_filter(boost::uint32_t uRF)
else
{
subband_freqs = get_tda18272_rfcal_result_freq_range(7);
- uRFCal0 = subband_freqs.start();
+ uRFCal0 = boost::uint32_t(subband_freqs.start());
subband_freqs = get_tda18272_rfcal_result_freq_range(10);
- uRFCal1 = subband_freqs.start();
+ uRFCal1 = boost::uint32_t(subband_freqs.start());
if(uRF < uRFCal0)
subband = 4;
@@ -1351,7 +1351,7 @@ void tvrx2::tvrx2_tda18272_tune_rf_filter(boost::uint32_t uRF)
cal_result = _rfcal_coeffs[subband].cal_number;
subband_freqs = get_tda18272_rfcal_result_freq_range(cal_result);
- uRFCal0 = subband_freqs.start();
+ uRFCal0 = boost::uint32_t(subband_freqs.start());
RF_A1 = _rfcal_coeffs[subband].RF_A1;
RF_B1 = _rfcal_coeffs[subband].RF_B1;
@@ -1721,7 +1721,7 @@ void tvrx2::wait_irq(void){
send_reg(0xA, 0xA);
read_reg(0xA, 0xB);
- irq = (this->get_iface()->read_gpio(dboard_iface::UNIT_RX) & tvrx2_sd_name_to_irq_io[get_subdev_name()]);
+ irq = (this->get_iface()->read_gpio(dboard_iface::UNIT_RX) & tvrx2_sd_name_to_irq_io[get_subdev_name()]) > 0;
UHD_LOGV(often) << boost::format(
"\nTVRX2 (%s): Cleared IRQ, subdev = %d, mask = 0x%x, Status: 0x%x\n") % (get_subdev_name()) % get_subdev_name() % (int(tvrx2_sd_name_to_irq_io[get_subdev_name()])) % irq << std::endl;
diff --git a/host/lib/usrp/dboard/db_ubx.cpp b/host/lib/usrp/dboard/db_ubx.cpp
index dd30cf534..06bfad7d3 100644
--- a/host/lib/usrp/dboard/db_ubx.cpp
+++ b/host/lib/usrp/dboard/db_ubx.cpp
@@ -32,6 +32,7 @@
#include <boost/math/special_functions/round.hpp>
#include <boost/thread.hpp>
#include <boost/algorithm/string.hpp>
+#include <boost/thread/mutex.hpp>
#include <map>
using namespace uhd;
@@ -83,7 +84,7 @@ protected:
// Get only regs with changes
try {
changed_regs = get_changed_addrs();
- } catch (uhd::runtime_error& e) {
+ } catch (uhd::runtime_error&) {
// No saved state - write all regs
for (int addr = 5; addr >= 0; addr--)
changed_regs.insert(boost::uint32_t(addr));
@@ -190,7 +191,7 @@ protected:
}
//keep pfd freq low enough to achieve 50kHz BS clock
- BS = std::ceil(pfd_freq / 50e3);
+ BS = int(std::ceil(pfd_freq / 50e3));
if(BS <= 1023) break;
}
UHD_ASSERT_THROW(R <= 1023);
@@ -691,7 +692,7 @@ static const ubx_gpio_field_info_t ubx_v1_gpio_info[] = {
};
/***********************************************************************
- * Macros and helper functions for routing and writing SPI registers
+ * Macros for routing and writing SPI registers
**********************************************************************/
#define ROUTE_SPI(iface, dest) \
iface->set_gpio_out(dboard_iface::UNIT_TX, dest, 0x7);
@@ -699,19 +700,6 @@ static const ubx_gpio_field_info_t ubx_v1_gpio_info[] = {
#define WRITE_SPI(iface, val) \
iface->write_spi(dboard_iface::UNIT_TX, spi_config_t::EDGE_RISE, val, 32);
-UHD_INLINE void write_spi_reg(dboard_iface::sptr iface, spi_dest_t dest, boost::uint32_t value)
-{
- ROUTE_SPI(iface, dest);
- WRITE_SPI(iface, value);
-}
-
-UHD_INLINE void write_spi_regs(dboard_iface::sptr iface, spi_dest_t dest, std::vector<boost::uint32_t> values)
-{
- ROUTE_SPI(iface, dest);
- for (size_t i = 0; i < values.size(); i++)
- WRITE_SPI(iface, values[i]);
-}
-
/***********************************************************************
* UBX Class Definition
**********************************************************************/
@@ -813,17 +801,17 @@ public:
// Initialize LOs
if (_rev == 0)
{
- _txlo1.reset(new max2870(boost::bind(&write_spi_regs, _iface, TXLO1, _1)));
- _txlo2.reset(new max2870(boost::bind(&write_spi_regs, _iface, TXLO2, _1)));
- _rxlo1.reset(new max2870(boost::bind(&write_spi_regs, _iface, RXLO1, _1)));
- _rxlo2.reset(new max2870(boost::bind(&write_spi_regs, _iface, RXLO2, _1)));
+ _txlo1.reset(new max2870(boost::bind(&ubx_xcvr::write_spi_regs, this, TXLO1, _1)));
+ _txlo2.reset(new max2870(boost::bind(&ubx_xcvr::write_spi_regs, this, TXLO2, _1)));
+ _rxlo1.reset(new max2870(boost::bind(&ubx_xcvr::write_spi_regs, this, RXLO1, _1)));
+ _rxlo2.reset(new max2870(boost::bind(&ubx_xcvr::write_spi_regs, this, RXLO2, _1)));
}
else if (_rev == 1)
{
- _txlo1.reset(new max2871(boost::bind(&write_spi_regs, _iface, TXLO1, _1)));
- _txlo2.reset(new max2871(boost::bind(&write_spi_regs, _iface, TXLO2, _1)));
- _rxlo1.reset(new max2871(boost::bind(&write_spi_regs, _iface, RXLO1, _1)));
- _rxlo2.reset(new max2871(boost::bind(&write_spi_regs, _iface, RXLO2, _1)));
+ _txlo1.reset(new max2871(boost::bind(&ubx_xcvr::write_spi_regs, this, TXLO1, _1)));
+ _txlo2.reset(new max2871(boost::bind(&ubx_xcvr::write_spi_regs, this, TXLO2, _1)));
+ _rxlo1.reset(new max2871(boost::bind(&ubx_xcvr::write_spi_regs, this, RXLO1, _1)));
+ _rxlo2.reset(new max2871(boost::bind(&ubx_xcvr::write_spi_regs, this, RXLO2, _1)));
}
else
{
@@ -948,6 +936,21 @@ private:
/***********************************************************************
* Helper Functions
**********************************************************************/
+ void write_spi_reg(spi_dest_t dest, boost::uint32_t value)
+ {
+ boost::mutex::scoped_lock lock(_spi_lock);
+ ROUTE_SPI(_iface, dest);
+ WRITE_SPI(_iface, value);
+ }
+
+ void write_spi_regs(spi_dest_t dest, std::vector<boost::uint32_t> values)
+ {
+ boost::mutex::scoped_lock lock(_spi_lock);
+ ROUTE_SPI(_iface, dest);
+ BOOST_FOREACH(boost::uint32_t value, values)
+ WRITE_SPI(_iface, value);
+ }
+
void set_cpld_field(ubx_cpld_field_id_t id, boost::uint32_t value)
{
_cpld_reg.set_field(id, value);
@@ -955,7 +958,7 @@ private:
void write_cpld_reg()
{
- write_spi_reg(_iface, CPLD, _cpld_reg.value);
+ write_spi_reg(CPLD, _cpld_reg.value);
}
void set_gpio_field(ubx_gpio_field_id_t id, boost::uint32_t value)
@@ -1389,6 +1392,7 @@ private:
* Variables
**********************************************************************/
dboard_iface::sptr _iface;
+ boost::mutex _spi_lock;
ubx_cpld_reg_t _cpld_reg;
boost::shared_ptr<max287x_synthesizer_iface> _txlo1;
boost::shared_ptr<max287x_synthesizer_iface> _txlo2;