diff options
author | Ashish Chaudhari <ashish@ettus.com> | 2016-01-06 10:03:29 -0800 |
---|---|---|
committer | Ashish Chaudhari <ashish@ettus.com> | 2016-01-06 10:03:29 -0800 |
commit | 04a4d6348bff100305bb7481d652c7170b8ff62c (patch) | |
tree | 1ad2dae096d3fd3682dab8c029e4aef0b70ecd81 | |
parent | 81bbb57c06feaa05406ba86abc237a2e80841226 (diff) | |
download | uhd-04a4d6348bff100305bb7481d652c7170b8ff62c.tar.gz uhd-04a4d6348bff100305bb7481d652c7170b8ff62c.tar.bz2 uhd-04a4d6348bff100305bb7481d652c7170b8ff62c.zip |
n230: Fixed GPSDO detection logic
-rw-r--r-- | host/lib/usrp/n230/n230_clk_pps_ctrl.cpp | 8 | ||||
-rw-r--r-- | host/lib/usrp/n230/n230_clk_pps_ctrl.hpp | 2 | ||||
-rw-r--r-- | host/lib/usrp/n230/n230_fpga_defs.h | 13 | ||||
-rw-r--r-- | host/lib/usrp/n230/n230_impl.cpp | 5 | ||||
-rw-r--r-- | host/lib/usrp/n230/n230_resource_manager.cpp | 21 | ||||
-rw-r--r-- | host/lib/usrp/n230/n230_resource_manager.hpp | 6 |
6 files changed, 29 insertions, 26 deletions
diff --git a/host/lib/usrp/n230/n230_clk_pps_ctrl.cpp b/host/lib/usrp/n230/n230_clk_pps_ctrl.cpp index a36fa133d..9d704b702 100644 --- a/host/lib/usrp/n230/n230_clk_pps_ctrl.cpp +++ b/host/lib/usrp/n230/n230_clk_pps_ctrl.cpp @@ -36,7 +36,7 @@ public: n230_ref_pll_ctrl::sptr ref_pll_ctrl, fpga::core_misc_reg_t& core_misc_reg, fpga::core_pps_sel_reg_t& core_pps_sel, - fpga::core_radio_status_reg_t& core_status_reg, + fpga::core_status_reg_t& core_status_reg, const std::vector<time_core_3000::sptr>& time_cores ): _codec_ctrl(codec_ctrl), _ref_pll_ctrl(ref_pll_ctrl), @@ -98,7 +98,7 @@ public: { bool locked = false; if (_clock_source == "external" || _clock_source == "gpsdo") { - locked = (_core_status_reg.read(fpga::core_radio_status_reg_t::REF_LOCKED) == 1); + locked = (_core_status_reg.read(fpga::core_status_reg_t::REF_LOCKED) == 1); } else { //If the source is internal, the charge pump on the ADF4001 is tristated which //means that the 40MHz VCTXXO is free running i.e. always "locked" @@ -132,7 +132,7 @@ private: n230_ref_pll_ctrl::sptr _ref_pll_ctrl; fpga::core_misc_reg_t& _core_misc_reg; fpga::core_pps_sel_reg_t& _core_pps_sel_reg; - fpga::core_radio_status_reg_t& _core_status_reg; + fpga::core_status_reg_t& _core_status_reg; std::vector<time_core_3000::sptr> _time_cores; double _tick_rate; std::string _clock_source; @@ -149,7 +149,7 @@ n230_clk_pps_ctrl::sptr n230_clk_pps_ctrl::make( n230_ref_pll_ctrl::sptr ref_pll_ctrl, fpga::core_misc_reg_t& core_misc_reg, fpga::core_pps_sel_reg_t& core_pps_sel_reg, - fpga::core_radio_status_reg_t& core_status_reg, + fpga::core_status_reg_t& core_status_reg, const std::vector<time_core_3000::sptr>& time_cores) { return sptr(new n230_clk_pps_ctrl_impl( diff --git a/host/lib/usrp/n230/n230_clk_pps_ctrl.hpp b/host/lib/usrp/n230/n230_clk_pps_ctrl.hpp index e97a163fa..3e0a21e04 100644 --- a/host/lib/usrp/n230/n230_clk_pps_ctrl.hpp +++ b/host/lib/usrp/n230/n230_clk_pps_ctrl.hpp @@ -39,7 +39,7 @@ public: n230_ref_pll_ctrl::sptr ref_pll_ctrl, fpga::core_misc_reg_t& core_misc_reg, fpga::core_pps_sel_reg_t& core_pps_sel_reg, - fpga::core_radio_status_reg_t& core_status_reg, + fpga::core_status_reg_t& core_status_reg, const std::vector<time_core_3000::sptr>& time_cores); virtual ~n230_clk_pps_ctrl() {} diff --git a/host/lib/usrp/n230/n230_fpga_defs.h b/host/lib/usrp/n230/n230_fpga_defs.h index 7e1b008ce..3aa96643f 100644 --- a/host/lib/usrp/n230/n230_fpga_defs.h +++ b/host/lib/usrp/n230/n230_fpga_defs.h @@ -137,10 +137,10 @@ static const double CODEC_DEFAULT_CLK_RATE = 40e6; static const double N230_LINK_RATE_BPS = 1e9/8; /******************************************************************* - * GPSDO status + * GPSDO *******************************************************************/ -static const uint32_t GPSDO_ST_NONE = 0x83; - +static const uint32_t GPSDO_UART_BAUDRATE = 115200; +static const uint32_t GPSDO_ST_ABSENT = 0x83; /******************************************************************* * Register Objects *******************************************************************/ @@ -192,11 +192,12 @@ public: } }; -class core_radio_status_reg_t : public soft_reg64_ro_t { +class core_status_reg_t : public soft_reg64_ro_t { public: - UHD_DEFINE_SOFT_REG_FIELD(REF_LOCKED, /*width*/ 1, /*shift*/ 0); //[0] + UHD_DEFINE_SOFT_REG_FIELD(REF_LOCKED, /*width*/ 1, /*shift*/ 0); //[0] + UHD_DEFINE_SOFT_REG_FIELD(GPSDO_STATUS, /*width*/ 8, /*shift*/ 32); //[32:39] - core_radio_status_reg_t(): + core_status_reg_t(): soft_reg64_ro_t(fpga::rb_addr(fpga::RB_CORE_STATUS)) { } }; diff --git a/host/lib/usrp/n230/n230_impl.cpp b/host/lib/usrp/n230/n230_impl.cpp index 873a9a89f..b3cc4ab59 100644 --- a/host/lib/usrp/n230/n230_impl.cpp +++ b/host/lib/usrp/n230/n230_impl.cpp @@ -396,9 +396,8 @@ void n230_impl::_initialize_property_tree(const fs_path& mb_path) //------------------------------------------------------------------ // GPSDO sensors //------------------------------------------------------------------ - uhd::gps_ctrl::sptr gps_ctrl = _resource_mgr->get_gps_ctrl(); - if (gps_ctrl and gps_ctrl->gps_detected()) - { + if (_resource_mgr->is_gpsdo_present()) { + uhd::gps_ctrl::sptr gps_ctrl = _resource_mgr->get_gps_ctrl(); BOOST_FOREACH(const std::string &name, gps_ctrl->get_sensors()) { _tree->create<sensor_value_t>(mb_path / "sensors" / name) diff --git a/host/lib/usrp/n230/n230_resource_manager.cpp b/host/lib/usrp/n230/n230_resource_manager.cpp index fa55d0cd8..2a47c1615 100644 --- a/host/lib/usrp/n230/n230_resource_manager.cpp +++ b/host/lib/usrp/n230/n230_resource_manager.cpp @@ -192,23 +192,22 @@ n230_resource_manager::n230_resource_manager( _ms1_gpio->set_atr_mode(gpio_atr::MODE_GPIO,gpio_atr::gpio_atr_3000::MASK_SET_ALL); //Create GPSDO interface - const sid_t gps_uart_sid = _generate_sid(GPS_UART, _get_conn(PRI_ETH).type); - transport::zero_copy_if::sptr gps_uart_xport = - _create_transport(_get_conn(PRI_ETH), gps_uart_sid, device_addr_t(), dummy_out_params); - _gps_uart = n230_uart::make(gps_uart_xport, uhd::htonx(gps_uart_sid.get())); - _gps_uart->set_baud_divider(fpga::BUS_CLK_RATE/115200); - _gps_uart->write_uart("\n"); //cause the baud and response to be setup - boost::this_thread::sleep(boost::posix_time::seconds(1)); //allow for a little propagation - if ((_core_ctrl->peek32(fpga::RB_CORE_STATUS) & 0xff) != fpga::GPSDO_ST_NONE) - { + if (_core_status_reg.read(fpga::core_status_reg_t::GPSDO_STATUS) != fpga::GPSDO_ST_ABSENT) { UHD_MSG(status) << "Detecting GPSDO.... " << std::flush; try { + const sid_t gps_uart_sid = _generate_sid(GPS_UART, _get_conn(PRI_ETH).type); + transport::zero_copy_if::sptr gps_uart_xport = + _create_transport(_get_conn(PRI_ETH), gps_uart_sid, device_addr_t(), dummy_out_params); + _gps_uart = n230_uart::make(gps_uart_xport, uhd::htonx(gps_uart_sid.get())); + _gps_uart->set_baud_divider(fpga::BUS_CLK_RATE/fpga::GPSDO_UART_BAUDRATE); + _gps_uart->write_uart("\n"); //cause the baud and response to be setup + boost::this_thread::sleep(boost::posix_time::seconds(1)); //allow for a little propagation _gps_ctrl = gps_ctrl::make(_gps_uart); } catch(std::exception &e) { UHD_MSG(error) << "An error occurred making GPSDO control: " << e.what() << std::endl; } - if (not (_gps_ctrl and _gps_ctrl->gps_detected())) { - _core_ctrl->poke32(fpga::sr_addr(fpga::SR_CORE_GPSDO_ST), fpga::GPSDO_ST_NONE); + if (not is_gpsdo_present()) { + _core_ctrl->poke32(fpga::sr_addr(fpga::SR_CORE_GPSDO_ST), fpga::GPSDO_ST_ABSENT); } } diff --git a/host/lib/usrp/n230/n230_resource_manager.hpp b/host/lib/usrp/n230/n230_resource_manager.hpp index 0c01e765a..c98140141 100644 --- a/host/lib/usrp/n230/n230_resource_manager.hpp +++ b/host/lib/usrp/n230/n230_resource_manager.hpp @@ -181,6 +181,10 @@ public: //Methods } //GPSDO control + inline bool is_gpsdo_present() { + return _gps_ctrl.get() and _gps_ctrl->gps_detected(); + } + inline uhd::gps_ctrl::sptr get_gps_ctrl(void) { return _gps_ctrl; } @@ -283,7 +287,7 @@ private: fpga::core_radio_ctrl_reg_t _core_radio_ctrl_reg; fpga::core_misc_reg_t _core_misc_reg; fpga::core_pps_sel_reg_t _core_pps_sel_reg; - fpga::core_radio_status_reg_t _core_status_reg; + fpga::core_status_reg_t _core_status_reg; //Radio peripherals radio_resource_t _radios[fpga::NUM_RADIOS]; |