diff options
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/usrp/dboard/eiscat/eiscat_radio_ctrl_impl.cpp | 30 | ||||
-rw-r--r-- | host/lib/usrp/dboard/eiscat/eiscat_radio_ctrl_impl.hpp | 7 |
2 files changed, 35 insertions, 2 deletions
diff --git a/host/lib/usrp/dboard/eiscat/eiscat_radio_ctrl_impl.cpp b/host/lib/usrp/dboard/eiscat/eiscat_radio_ctrl_impl.cpp index 8e93ac55b..5b10572f7 100644 --- a/host/lib/usrp/dboard/eiscat/eiscat_radio_ctrl_impl.cpp +++ b/host/lib/usrp/dboard/eiscat/eiscat_radio_ctrl_impl.cpp @@ -74,6 +74,7 @@ UHD_RFNOC_RADIO_BLOCK_CONSTRUCTOR(eiscat_radio_ctrl) ); /**** Configure the radio_ctrl itself ***********************************/ + // This also sets the command tick rate: radio_ctrl_impl::set_rate(EISCAT_TICK_RATE); for (size_t chan = 0; chan < _num_ports; chan++) { radio_ctrl_impl::set_rx_frequency(EISCAT_CENTER_FREQ, chan); @@ -521,11 +522,14 @@ void eiscat_radio_ctrl_impl::set_rpc_client( UHD_LOG_INFO( "EISCAT", - "Finalizing dboard initialization using internal PPS" + "Finalizing dboard initialization; initializing JESD cores and ADCs." ); + if (not assert_jesd_cores_initialized()) { + throw uhd::runtime_error("Failed to initialize JESD cores and reset ADCs!"); + } send_sysref(); if (not assert_adcs_deframers()) { - throw uhd::runtime_error("Failed to initialize ADCs and JESD cores!"); + throw uhd::runtime_error("Failed to initialize ADCs and JESD deframers!"); } send_sysref(); std::this_thread::sleep_for(std::chrono::milliseconds(500)); @@ -711,7 +715,20 @@ void eiscat_radio_ctrl_impl::send_sysref() if (_block_args.has_key("use_mpm_sysref")) { _rpcc->notify_with_token("db_0_send_sysref"); } else { + // This value needs to be big enough that we actually hit it between + // reading back the time, and applying the command: + const int CMD_DELAY_MS = 100; + auto sysref_time = get_time_now() + + uhd::time_spec_t(double(CMD_DELAY_MS * 1000)); + uint64_t sysref_time_ticks = sysref_time.to_ticks(EISCAT_TICK_RATE); + // The tick value must be even, or we'd still have the 180 degree phase + // ambiguity! The actual value doesn't matter. + sysref_time_ticks += sysref_time_ticks % 2; + set_command_time(uhd::time_spec_t::from_ticks( + sysref_time_ticks, EISCAT_TICK_RATE + )); this->sr_write("SR_SYSREF", 1); + std::this_thread::sleep_for(std::chrono::milliseconds(CMD_DELAY_MS)); } } @@ -725,6 +742,15 @@ void eiscat_radio_ctrl_impl::enable_counter(bool enable) configure_beams(new_value); } +bool eiscat_radio_ctrl_impl::assert_jesd_cores_initialized() +{ + if (_num_dboards == 1) { + return _rpcc->request_with_token<bool>("db_0_init_jesd_core_reset_adcs"); + } + return _rpcc->request_with_token<bool>("db_0_init_jesd_core_reset_adcs") + and _rpcc->request_with_token<bool>("db_1_init_jesd_core_reset_adcs"); +} + bool eiscat_radio_ctrl_impl::assert_adcs_deframers() { if (_num_dboards == 1) { diff --git a/host/lib/usrp/dboard/eiscat/eiscat_radio_ctrl_impl.hpp b/host/lib/usrp/dboard/eiscat/eiscat_radio_ctrl_impl.hpp index 4a99793c9..7b54667da 100644 --- a/host/lib/usrp/dboard/eiscat/eiscat_radio_ctrl_impl.hpp +++ b/host/lib/usrp/dboard/eiscat/eiscat_radio_ctrl_impl.hpp @@ -262,8 +262,15 @@ private: */ void enable_counter(bool enable); + //! Sends a SYSREF pulse. Device arg use_mpm_sysref can be used to send it + // via MPM. Default is to send it via CHDR, in which case calling this + // function *will modify the command time!*, but it will ensure that the + // sysref is sent on an even time void send_sysref(); + //! Run initialization of JESD cores, put ADCs into reset + bool assert_jesd_cores_initialized(); + //! Run initialization of ADCs and deframers; returns success status bool assert_adcs_deframers(); |