aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/usrp2/mboard_impl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp/usrp2/mboard_impl.cpp')
-rw-r--r--host/lib/usrp/usrp2/mboard_impl.cpp37
1 files changed, 18 insertions, 19 deletions
diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp
index ea268651a..1521de1fe 100644
--- a/host/lib/usrp/usrp2/mboard_impl.cpp
+++ b/host/lib/usrp/usrp2/mboard_impl.cpp
@@ -22,6 +22,9 @@
#include <uhd/utils/assert.hpp>
#include <uhd/types/mac_addr.hpp>
#include <uhd/types/dict.hpp>
+#include <boost/bind.hpp>
+#include <boost/asio.hpp> //htonl and ntohl
+#include <boost/assign/list_of.hpp>
using namespace uhd;
using namespace uhd::usrp;
@@ -35,7 +38,7 @@ void usrp2_impl::mboard_init(void){
boost::bind(&usrp2_impl::mboard_set, this, _1, _2)
);
- _clock_control = clock_control::make_ad9510(this);
+ _clk_ctrl = clock_control::make_ad9510(_iface);
//setup the ad9777 dac
ad9777_regs_t ad9777_regs;
@@ -58,14 +61,10 @@ void usrp2_impl::mboard_init(void){
//write all regs
for(boost::uint8_t addr = 0; addr <= 0xC; addr++){
boost::uint16_t data = ad9777_regs.get_write_reg(addr);
- this->transact_spi(SPI_SS_AD9777, spi_config_t::EDGE_RISE, data, 16, false /*no rb*/);
+ _iface->transact_spi(SPI_SS_AD9777, spi_config_t::EDGE_RISE, data, 16, false /*no rb*/);
}
}
-clock_control::sptr usrp2_impl::get_clock_control(void){
- return _clock_control;
-}
-
void usrp2_impl::init_clock_config(void){
//setup the clock configuration settings
_clock_config.ref_source = clock_config_t::REF_INT;
@@ -94,28 +93,28 @@ void usrp2_impl::update_clock_config(void){
}
//set the pps flags
- this->poke32(FR_TIME64_FLAGS, pps_flags);
+ _iface->poke32(FR_TIME64_FLAGS, pps_flags);
//clock source ref 10mhz
switch(_clock_config.ref_source){
- case clock_config_t::REF_INT : this->poke32(FR_CLOCK_CONTROL, 0x10); break;
- case clock_config_t::REF_SMA : this->poke32(FR_CLOCK_CONTROL, 0x1C); break;
- case clock_config_t::REF_MIMO: this->poke32(FR_CLOCK_CONTROL, 0x15); break;
+ case clock_config_t::REF_INT : _iface->poke32(FR_CLOCK_CONTROL, 0x10); break;
+ case clock_config_t::REF_SMA : _iface->poke32(FR_CLOCK_CONTROL, 0x1C); break;
+ case clock_config_t::REF_MIMO: _iface->poke32(FR_CLOCK_CONTROL, 0x15); break;
}
//clock source ref 10mhz
bool use_external = _clock_config.ref_source != clock_config_t::REF_INT;
- this->get_clock_control()->enable_external_ref(use_external);
+ _clk_ctrl->enable_external_ref(use_external);
}
void usrp2_impl::set_time_spec(const time_spec_t &time_spec, bool now){
//set ticks and seconds
- this->poke32(FR_TIME64_SECS, time_spec.secs);
- this->poke32(FR_TIME64_TICKS, time_spec.get_ticks(get_master_clock_freq()));
+ _iface->poke32(FR_TIME64_SECS, time_spec.secs);
+ _iface->poke32(FR_TIME64_TICKS, time_spec.get_ticks(get_master_clock_freq()));
//set the register to latch it all in
boost::uint32_t imm_flags = (now)? FRF_TIME64_LATCH_NOW : FRF_TIME64_LATCH_NEXT_PPS;
- this->poke32(FR_TIME64_IMM, imm_flags);
+ _iface->poke32(FR_TIME64_IMM, imm_flags);
}
void usrp2_impl::issue_ddc_stream_cmd(const stream_cmd_t &stream_cmd){
@@ -151,7 +150,7 @@ void usrp2_impl::issue_ddc_stream_cmd(const stream_cmd_t &stream_cmd){
}
//send and recv
- usrp2_ctrl_data_t in_data = ctrl_send_and_recv(out_data);
+ usrp2_ctrl_data_t in_data = _iface->ctrl_send_and_recv(out_data);
ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_GOT_THAT_STREAM_COMMAND_DUDE);
}
@@ -170,7 +169,7 @@ void usrp2_impl::mboard_get(const wax::obj &key_, wax::obj &val){
out_data.id = htonl(USRP2_CTRL_ID_GIVE_ME_YOUR_MAC_ADDR_BRO);
//send and recv
- usrp2_ctrl_data_t in_data = ctrl_send_and_recv(out_data);
+ usrp2_ctrl_data_t in_data = _iface->ctrl_send_and_recv(out_data);
ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_THIS_IS_MY_MAC_ADDR_DUDE);
//extract the address
@@ -184,7 +183,7 @@ void usrp2_impl::mboard_get(const wax::obj &key_, wax::obj &val){
out_data.id = htonl(USRP2_CTRL_ID_GIVE_ME_YOUR_IP_ADDR_BRO);
//send and recv
- usrp2_ctrl_data_t in_data = ctrl_send_and_recv(out_data);
+ usrp2_ctrl_data_t in_data = _iface->ctrl_send_and_recv(out_data);
ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_THIS_IS_MY_IP_ADDR_DUDE);
//extract the address
@@ -272,7 +271,7 @@ void usrp2_impl::mboard_set(const wax::obj &key, const wax::obj &val){
std::copy(mac_addr.to_bytes(), mac_addr.to_bytes()+mac_addr_t::hlen, out_data.data.mac_addr);
//send and recv
- usrp2_ctrl_data_t in_data = ctrl_send_and_recv(out_data);
+ usrp2_ctrl_data_t in_data = _iface->ctrl_send_and_recv(out_data);
ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_THIS_IS_MY_MAC_ADDR_DUDE);
return;
}
@@ -284,7 +283,7 @@ void usrp2_impl::mboard_set(const wax::obj &key, const wax::obj &val){
out_data.data.ip_addr = htonl(boost::asio::ip::address_v4::from_string(val.as<std::string>()).to_ulong());
//send and recv
- usrp2_ctrl_data_t in_data = ctrl_send_and_recv(out_data);
+ usrp2_ctrl_data_t in_data = _iface->ctrl_send_and_recv(out_data);
ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_THIS_IS_MY_IP_ADDR_DUDE);
return;
}