aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp')
-rw-r--r--host/lib/usrp/cores/rx_frontend_core_200.cpp24
-rw-r--r--host/lib/usrp/cores/rx_frontend_core_200.hpp4
-rw-r--r--host/lib/usrp/cores/tx_frontend_core_200.cpp12
-rw-r--r--host/lib/usrp/cores/tx_frontend_core_200.hpp2
4 files changed, 34 insertions, 8 deletions
diff --git a/host/lib/usrp/cores/rx_frontend_core_200.cpp b/host/lib/usrp/cores/rx_frontend_core_200.cpp
index 0e8220b49..bb87cb600 100644
--- a/host/lib/usrp/cores/rx_frontend_core_200.cpp
+++ b/host/lib/usrp/cores/rx_frontend_core_200.cpp
@@ -24,6 +24,9 @@
#define REG_RX_FE_OFFSET_I _base + 12 //18 bits
#define REG_RX_FE_OFFSET_Q _base + 16 //18 bits
+#define OFFSET_FIXED (1ul << 31)
+#define OFFSET_SET (1ul << 30)
+
static boost::uint32_t fs_to_bits(const double num, const size_t bits){
return boost::int32_t(boost::math::round(num * (1 << (bits-1))));
}
@@ -41,9 +44,23 @@ public:
_iface->poke32(REG_RX_FE_SWAP_IQ, swap? 1 : 0);
}
- void set_offset(const std::complex<double> &off){
- _iface->poke32(REG_RX_FE_OFFSET_I, fs_to_bits(off.real(), 24));
- _iface->poke32(REG_RX_FE_OFFSET_Q, fs_to_bits(off.imag(), 24));
+ void set_dc_offset_auto(const bool enb){
+ this->set_dc_offset(enb? 0 : OFFSET_FIXED);
+ }
+
+ std::complex<double> set_dc_offset(const std::complex<double> &off){
+ static const double scaler = double(1ul << 29);
+ _i_dc_off = boost::math::iround(off.real()*scaler);
+ _q_dc_off = boost::math::iround(off.imag()*scaler);
+
+ this->set_dc_offset(OFFSET_SET | OFFSET_FIXED);
+
+ return std::complex<double>(_i_dc_off/scaler, _q_dc_off/scaler);
+ }
+
+ void set_dc_offset(const boost::uint32_t flags){
+ _iface->poke32(REG_RX_FE_OFFSET_I, flags | _i_dc_off);
+ _iface->poke32(REG_RX_FE_OFFSET_Q, flags | _q_dc_off);
}
void set_correction(const std::complex<double> &cor){
@@ -52,6 +69,7 @@ public:
}
private:
+ boost::int32_t _i_dc_off, _q_dc_off;
wb_iface::sptr _iface;
const size_t _base;
};
diff --git a/host/lib/usrp/cores/rx_frontend_core_200.hpp b/host/lib/usrp/cores/rx_frontend_core_200.hpp
index a950e2bb7..73dfbdc72 100644
--- a/host/lib/usrp/cores/rx_frontend_core_200.hpp
+++ b/host/lib/usrp/cores/rx_frontend_core_200.hpp
@@ -33,7 +33,9 @@ public:
virtual void set_mux(const bool swap) = 0;
- virtual void set_offset(const std::complex<double> &off) = 0;
+ virtual void set_dc_offset_auto(const bool enb) = 0;
+
+ virtual std::complex<double> set_dc_offset(const std::complex<double> &off) = 0;
virtual void set_correction(const std::complex<double> &cor) = 0;
diff --git a/host/lib/usrp/cores/tx_frontend_core_200.cpp b/host/lib/usrp/cores/tx_frontend_core_200.cpp
index a7568a81e..71555e47f 100644
--- a/host/lib/usrp/cores/tx_frontend_core_200.cpp
+++ b/host/lib/usrp/cores/tx_frontend_core_200.cpp
@@ -50,9 +50,15 @@ public:
_iface->poke32(REG_TX_FE_MUX, mode_to_mux[mode]);
}
- void set_dc_offset(const std::complex<double> &off){
- _iface->poke32(REG_TX_FE_DC_OFFSET_I, fs_to_bits(off.real(), 24));
- _iface->poke32(REG_TX_FE_DC_OFFSET_Q, fs_to_bits(off.imag(), 24));
+ std::complex<double> set_dc_offset(const std::complex<double> &off){
+ static const double scaler = double(1ul << 23);
+ const boost::int32_t i_dc_off = boost::math::iround(off.real()*scaler);
+ const boost::int32_t q_dc_off = boost::math::iround(off.imag()*scaler);
+
+ _iface->poke32(REG_TX_FE_DC_OFFSET_I, i_dc_off);
+ _iface->poke32(REG_TX_FE_DC_OFFSET_Q, q_dc_off);
+
+ return std::complex<double>(i_dc_off/scaler, q_dc_off/scaler);
}
void set_correction(const std::complex<double> &cor){
diff --git a/host/lib/usrp/cores/tx_frontend_core_200.hpp b/host/lib/usrp/cores/tx_frontend_core_200.hpp
index 9e4a7bc79..f905e447d 100644
--- a/host/lib/usrp/cores/tx_frontend_core_200.hpp
+++ b/host/lib/usrp/cores/tx_frontend_core_200.hpp
@@ -33,7 +33,7 @@ public:
virtual void set_mux(const std::string &mode) = 0;
- virtual void set_dc_offset(const std::complex<double> &off) = 0;
+ virtual std::complex<double> set_dc_offset(const std::complex<double> &off) = 0;
virtual void set_correction(const std::complex<double> &cor) = 0;