diff options
Diffstat (limited to 'host')
-rw-r--r-- | host/examples/test_pps_input.cpp | 37 | ||||
-rw-r--r-- | host/examples/tx_from_file.cpp | 2 | ||||
-rw-r--r-- | host/examples/tx_timed_samples.cpp | 2 | ||||
-rw-r--r-- | host/examples/tx_waveforms.cpp | 2 | ||||
-rw-r--r-- | host/include/uhd/usrp/mboard_props.hpp | 2 | ||||
-rw-r--r-- | host/include/uhd/usrp/multi_usrp.hpp | 17 | ||||
-rw-r--r-- | host/include/uhd/usrp/single_usrp.hpp | 8 | ||||
-rw-r--r-- | host/lib/CMakeLists.txt | 2 | ||||
-rw-r--r-- | host/lib/ic_reg_maps/.gitignore | 2 | ||||
-rw-r--r-- | host/lib/usrp/dboard/db_tvrx.cpp | 2 | ||||
-rw-r--r-- | host/lib/usrp/multi_usrp.cpp | 29 | ||||
-rw-r--r-- | host/lib/usrp/single_usrp.cpp | 6 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/fw_common.h | 5 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/io_impl.cpp | 10 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/mboard_impl.cpp | 24 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/usrp2_iface.cpp | 14 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/usrp2_iface.hpp | 9 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/usrp2_regs.cpp | 6 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/usrp2_regs.hpp | 6 | ||||
-rw-r--r-- | host/lib/usrp/usrp_e100/mboard_impl.cpp | 2 |
20 files changed, 79 insertions, 108 deletions
diff --git a/host/examples/test_pps_input.cpp b/host/examples/test_pps_input.cpp index 4b2bb62a3..273c73df0 100644 --- a/host/examples/test_pps_input.cpp +++ b/host/examples/test_pps_input.cpp @@ -17,7 +17,7 @@ #include <uhd/utils/thread_priority.hpp> #include <uhd/utils/safe_main.hpp> -#include <uhd/usrp/single_usrp.hpp> +#include <uhd/usrp/multi_usrp.hpp> #include <boost/program_options.hpp> #include <boost/format.hpp> #include <boost/thread.hpp> @@ -31,7 +31,6 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //variables to be set by po std::string args; - double seconds; //setup the program options po::options_description desc("Allowed options"); @@ -52,35 +51,13 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //create a usrp device std::cout << std::endl; std::cout << boost::format("Creating the usrp device with: %s...") % args << std::endl; - uhd::usrp::single_usrp::sptr sdev = uhd::usrp::single_usrp::make(args); + uhd::usrp::multi_usrp::sptr sdev = uhd::usrp::multi_usrp::make(args); uhd::device::sptr dev = sdev->get_device(); std::cout << boost::format("Using Device: %s") % sdev->get_pp_string() << std::endl; - //set a known time value - std::cout << "Set time to known value (100.0) without regard to pps:" << std::endl; - sdev->set_time_now(uhd::time_spec_t(100.0)); - boost::this_thread::sleep(boost::posix_time::seconds(1)); - std::cout << boost::format("Reading time 1 second later: %f\n") % (sdev->get_time_now().get_real_secs()) << std::endl; - - //store the time to see if PPS resets it - seconds = sdev->get_time_now().get_real_secs(); - - //set a known time at next PPS, check that time increments - uhd::time_spec_t time_spec = uhd::time_spec_t(0.0); - std::cout << "Set time to known value (0.0) at next pps:" << std::endl; - sdev->set_time_next_pps(time_spec); - boost::this_thread::sleep(boost::posix_time::seconds(1)); - std::cout << boost::format("Reading time 1 second later: %f\n") % (sdev->get_time_now().get_real_secs()) << std::endl; - - //finished - if (seconds > sdev->get_time_now().get_real_secs()){ - std::cout << std::endl << "Success!" << std::endl << std::endl; - return 0; - } else { - std::cout << std::endl << "Failed!" << std::endl << std::endl - << "If you expected PPS to work:" << std::endl - << "\tsee Device App Notes for PPS level information" - << std::endl << std::endl; - return -1; - } + //set the time at an unknown pps (will throw if no pps) + std::cout << std::endl << "Attempt to detect the PPS and set the time..." << std::endl << std::endl; + sdev->set_time_unknown_pps(uhd::time_spec_t(0.0)); + std::cout << std::endl << "Success!" << std::endl << std::endl; + return 0; } diff --git a/host/examples/tx_from_file.cpp b/host/examples/tx_from_file.cpp index 9611cf47c..40ce6db6b 100644 --- a/host/examples/tx_from_file.cpp +++ b/host/examples/tx_from_file.cpp @@ -102,7 +102,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ size_t num_packets = (total_num_samps+samps_per_packet-1)/samps_per_packet; for (size_t i = 0; i < num_packets; i++){ //setup the metadata flags and time spec - md.start_of_burst = true; //always SOB (good for continuous streaming) + md.start_of_burst = (i == 0); //only first packet has SOB md.end_of_burst = (i == num_packets-1); //only last packet has EOB md.has_time_spec = (i == 0); //only first packet has time md.time_spec = uhd::time_spec_t(seconds_in_future); diff --git a/host/examples/tx_timed_samples.cpp b/host/examples/tx_timed_samples.cpp index 799da37e0..ef0cd8212 100644 --- a/host/examples/tx_timed_samples.cpp +++ b/host/examples/tx_timed_samples.cpp @@ -89,7 +89,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ for (size_t i = 0; i < num_packets; i++){ //setup the metadata flags and time spec uhd::tx_metadata_t md; - md.start_of_burst = true; //always SOB (good for continuous streaming) + md.start_of_burst = (i == 0); //only first packet has SOB md.end_of_burst = (i == num_packets-1); //only last packet has EOB md.has_time_spec = (i == 0); //only first packet has time md.time_spec = uhd::time_spec_t(seconds_in_future); diff --git a/host/examples/tx_waveforms.cpp b/host/examples/tx_waveforms.cpp index 50982cf88..751b79cf5 100644 --- a/host/examples/tx_waveforms.cpp +++ b/host/examples/tx_waveforms.cpp @@ -142,7 +142,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //setup the metadata flags uhd::tx_metadata_t md; - md.start_of_burst = true; //always SOB (good for continuous streaming) + md.start_of_burst = false; //never SOB when continuous md.end_of_burst = false; //send the data in multiple packets diff --git a/host/include/uhd/usrp/mboard_props.hpp b/host/include/uhd/usrp/mboard_props.hpp index df94d1678..c82bfc21a 100644 --- a/host/include/uhd/usrp/mboard_props.hpp +++ b/host/include/uhd/usrp/mboard_props.hpp @@ -43,7 +43,7 @@ namespace uhd{ namespace usrp{ MBOARD_PROP_TX_SUBDEV_SPEC = 'R', //rw, subdev_spec_t MBOARD_PROP_CLOCK_CONFIG = 'C', //rw, clock_config_t MBOARD_PROP_TIME_NOW = 't', //rw, time_spec_t - MBOARD_PROP_TIME_NEXT_PPS = 'T', //wo, time_spec_t + MBOARD_PROP_TIME_PPS = 'T', //wo, time_spec_t MBOARD_PROP_STREAM_CMD = 's', //wo, stream_cmd_t MBOARD_PROP_EEPROM_MAP = 'M' //wr, mboard_eeprom_t::sptr }; diff --git a/host/include/uhd/usrp/multi_usrp.hpp b/host/include/uhd/usrp/multi_usrp.hpp index 98ba07fc0..ce99d713e 100644 --- a/host/include/uhd/usrp/multi_usrp.hpp +++ b/host/include/uhd/usrp/multi_usrp.hpp @@ -108,12 +108,18 @@ public: virtual std::string get_mboard_name(size_t mboard) = 0; /*! - * Gets the current time in the usrp time registers. + * Get the current time in the usrp time registers. * \return a timespec representing current usrp time */ virtual time_spec_t get_time_now(void) = 0; /*! + * Get the time when the last pps pulse occured. + * \return a timespec representing the last pps + */ + virtual time_spec_t get_time_last_pps(void) = 0; + + /*! * Set the time registers on the usrp at the next pps tick. * The values will not be latched in until the pulse occurs. * It is recommended that the user sleep(1) after calling to ensure @@ -133,14 +139,13 @@ public: * Ex: Host machine is not attached to serial port of GPSDO * and can therefore not query the GPSDO for the PPS edge. * - * This is a 3-step process, and will take at most 3 seconds to complete. + * This is a 2-step process, and will take at most 2 seconds to complete. * Upon completion, the times will be synchronized to the time provided. * - * - Step1: set the time at the next pps (potential race condition) - * - Step2: wait for the seconds to rollover to catch the pps edge - * - Step3: set the time at the next pps (synchronous for all boards) + * - Step1: wait for the last pps time to transition to catch the edge + * - Step2: set the time at the next pps (synchronous for all boards) * - * \param time_spec the time to latch into the usrp device + * \param time_spec the time to latch at the next pps after catching the edge */ virtual void set_time_unknown_pps(const time_spec_t &time_spec) = 0; diff --git a/host/include/uhd/usrp/single_usrp.hpp b/host/include/uhd/usrp/single_usrp.hpp index 26303fe10..bfbb90912 100644 --- a/host/include/uhd/usrp/single_usrp.hpp +++ b/host/include/uhd/usrp/single_usrp.hpp @@ -77,12 +77,18 @@ public: virtual std::string get_mboard_name(void) = 0; /*! - * Gets the current time in the usrp time registers. + * Get the current time in the usrp time registers. * \return a timespec representing current usrp time */ virtual time_spec_t get_time_now(void) = 0; /*! + * Get the time when the last pps pulse occured. + * \return a timespec representing the last pps + */ + virtual time_spec_t get_time_last_pps(void) = 0; + + /*! * Sets the time registers on the usrp immediately. * \param time_spec the time to latch into the usrp device */ diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt index fa5d6b67b..498841561 100644 --- a/host/lib/CMakeLists.txt +++ b/host/lib/CMakeLists.txt @@ -55,7 +55,7 @@ MACRO(LIBUHD_PYTHON_GEN_SOURCE pyfile outfile) #make the outfile depend on the python script ADD_CUSTOM_COMMAND( OUTPUT ${outfile} DEPENDS ${pyfile} - COMMAND ${PYTHON_EXECUTABLE} ${pyfile} ${outfile} + COMMAND ${PYTHON_EXECUTABLE} -B ${pyfile} ${outfile} COMMENT "Generating ${outfile}" ) diff --git a/host/lib/ic_reg_maps/.gitignore b/host/lib/ic_reg_maps/.gitignore deleted file mode 100644 index 053049d05..000000000 --- a/host/lib/ic_reg_maps/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/*.pyc -/*.pyo diff --git a/host/lib/usrp/dboard/db_tvrx.cpp b/host/lib/usrp/dboard/db_tvrx.cpp index 17fdad74a..2508555d0 100644 --- a/host/lib/usrp/dboard/db_tvrx.cpp +++ b/host/lib/usrp/dboard/db_tvrx.cpp @@ -280,7 +280,7 @@ static float rf_gain_to_voltage(float gain, double lo_freq){ gain = get_tvrx_gain_ranges()["RF"].clip(gain); //first we need to find out what band we're in, because gains are different across different bands - std::string band = get_band(lo_freq + tvrx_if_freq); + std::string band = get_band(lo_freq - tvrx_if_freq); //this is the voltage at the TVRX gain input double gain_volts = gain_interp(gain, tvrx_rf_gains_db[band], tvrx_gains_volts); diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index 876f1a3fc..5610bcd3f 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -117,26 +117,31 @@ public: return _mboard(0)[MBOARD_PROP_TIME_NOW].as<time_spec_t>(); } + time_spec_t get_time_last_pps(void){ + return _mboard(0)[MBOARD_PROP_TIME_PPS].as<time_spec_t>(); + } + void set_time_next_pps(const time_spec_t &time_spec){ for (size_t m = 0; m < get_num_mboards(); m++){ - _mboard(m)[MBOARD_PROP_TIME_NEXT_PPS] = time_spec; + _mboard(m)[MBOARD_PROP_TIME_PPS] = time_spec; } } void set_time_unknown_pps(const time_spec_t &time_spec){ - std::cout << "Set time with unknown pps edge:" << std::endl; - std::cout << " 1) set times next pps (race condition)" << std::endl; - set_time_next_pps(time_spec); - boost::this_thread::sleep(boost::posix_time::seconds(1)); - - std::cout << " 2) catch seconds rollover at pps edge" << std::endl; - time_t last_secs = 0, curr_secs = 0; - while(curr_secs == last_secs){ - last_secs = curr_secs; - curr_secs = get_time_now().get_full_secs(); + std::cout << " 1) catch time transition at pps edge" << std::endl; + time_spec_t time_start = get_time_now(); + time_spec_t time_start_last_pps = get_time_last_pps(); + while(true){ + if (get_time_last_pps() != time_start_last_pps) break; + if ((get_time_now() - time_start) > time_spec_t(1.1)){ + throw std::runtime_error( + "Board 0 may not be getting a PPS signal.\n" + "The time at the last PPS has not changed.\n" + ); + } } - std::cout << " 3) set times next pps (synchronously)" << std::endl; + std::cout << " 2) set times next pps (synchronously)" << std::endl; set_time_next_pps(time_spec); boost::this_thread::sleep(boost::posix_time::seconds(1)); diff --git a/host/lib/usrp/single_usrp.cpp b/host/lib/usrp/single_usrp.cpp index a0456d1f0..12730929a 100644 --- a/host/lib/usrp/single_usrp.cpp +++ b/host/lib/usrp/single_usrp.cpp @@ -106,12 +106,16 @@ public: return _mboard()[MBOARD_PROP_TIME_NOW].as<time_spec_t>(); } + time_spec_t get_time_last_pps(void){ + return _mboard()[MBOARD_PROP_TIME_PPS].as<time_spec_t>(); + } + void set_time_now(const time_spec_t &time_spec){ _mboard()[MBOARD_PROP_TIME_NOW] = time_spec; } void set_time_next_pps(const time_spec_t &time_spec){ - _mboard()[MBOARD_PROP_TIME_NEXT_PPS] = time_spec; + _mboard()[MBOARD_PROP_TIME_PPS] = time_spec; } void issue_stream_cmd(const stream_cmd_t &stream_cmd){ diff --git a/host/lib/usrp/usrp2/fw_common.h b/host/lib/usrp/usrp2/fw_common.h index ee7fc3882..2cdfdc359 100644 --- a/host/lib/usrp/usrp2/fw_common.h +++ b/host/lib/usrp/usrp2/fw_common.h @@ -127,9 +127,8 @@ typedef struct{ struct { __stdint(uint32_t) addr; __stdint(uint32_t) data; - __stdint(uint32_t) addrhi; - __stdint(uint32_t) datahi; - __stdint(uint8_t) num_bytes; //1, 2, 4, 8 + __stdint(uint32_t) _pad[2]; + __stdint(uint8_t) num_bytes; //1, 2, 4 } poke_args; struct { __stdint(uint8_t) dev; diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp index 5a6c0983c..86fb512cc 100644 --- a/host/lib/usrp/usrp2/io_impl.cpp +++ b/host/lib/usrp/usrp2/io_impl.cpp @@ -251,16 +251,6 @@ void usrp2_impl::io_init(void){ //create new io impl _io_impl = UHD_PIMPL_MAKE(io_impl, (send_frame_size, _data_transports.size())); - //TODO temporary fix for weird power up state, remove when FPGA fixed - { - //send an initial packet to all transports - tx_metadata_t md; md.end_of_burst = true; - this->send( - std::vector<const void *>(_data_transports.size(), NULL), 0, md, - io_type_t::COMPLEX_FLOAT32, device::SEND_MODE_ONE_PACKET, 0 - ); - } - //create a new pirate thread for each zc if (yarr!!) for (size_t i = 0; i < _data_transports.size(); i++){ //lock the unlocked mutex (non-blocking) diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp index 4dcc45fd3..9ca47cdc3 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -330,15 +330,21 @@ void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){ val = _clock_config; return; - case MBOARD_PROP_TIME_NOW:{ - usrp2_iface::pair64 time64( - _iface->peek64(_iface->regs.time64_secs_rb, _iface->regs.time64_ticks_rb) - ); - val = time_spec_t( - time64.first, time64.second, get_master_clock_freq() - ); - } + case MBOARD_PROP_TIME_NOW: while(true){ + uint32_t secs = _iface->peek32(_iface->regs.time64_secs_rb_imm); + uint32_t ticks = _iface->peek32(_iface->regs.time64_ticks_rb_imm); + if (secs != _iface->peek32(_iface->regs.time64_secs_rb_imm)) continue; + val = time_spec_t(secs, ticks, get_master_clock_freq()); return; + } + + case MBOARD_PROP_TIME_PPS: while(true){ + uint32_t secs = _iface->peek32(_iface->regs.time64_secs_rb_pps); + uint32_t ticks = _iface->peek32(_iface->regs.time64_ticks_rb_pps); + if (secs != _iface->peek32(_iface->regs.time64_secs_rb_pps)) continue; + val = time_spec_t(secs, ticks, get_master_clock_freq()); + return; + } case MBOARD_PROP_RX_SUBDEV_SPEC: val = _rx_subdev_spec; @@ -372,7 +378,7 @@ void usrp2_mboard_impl::set(const wax::obj &key, const wax::obj &val){ set_time_spec(val.as<time_spec_t>(), true); return; - case MBOARD_PROP_TIME_NEXT_PPS: + case MBOARD_PROP_TIME_PPS: set_time_spec(val.as<time_spec_t>(), false); return; diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp index ffbe8eedb..dcb25dc54 100644 --- a/host/lib/usrp/usrp2/usrp2_iface.cpp +++ b/host/lib/usrp/usrp2/usrp2_iface.cpp @@ -93,20 +93,6 @@ public: return this->peek<boost::uint16_t>(addr); } - pair64 peek64(boost::uint32_t addrlo, boost::uint32_t addrhi){ - //setup the out data - usrp2_ctrl_data_t out_data; - out_data.id = htonl(USRP2_CTRL_ID_PEEK_AT_THIS_REGISTER_FOR_ME_BRO); - out_data.data.poke_args.addr = htonl(addrlo); - out_data.data.poke_args.addrhi = htonl(addrhi); - out_data.data.poke_args.num_bytes = sizeof(boost::uint64_t); - - //send and recv - usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data); - UHD_ASSERT_THROW(ntohl(in_data.id) == USRP2_CTRL_ID_WOAH_I_DEFINITELY_PEEKED_IT_DUDE); - return pair64(ntohl(in_data.data.poke_args.data), ntohl(in_data.data.poke_args.datahi)); - } - /*********************************************************************** * SPI **********************************************************************/ diff --git a/host/lib/usrp/usrp2/usrp2_iface.hpp b/host/lib/usrp/usrp2/usrp2_iface.hpp index af3ed6c9f..2b4378ddf 100644 --- a/host/lib/usrp/usrp2/usrp2_iface.hpp +++ b/host/lib/usrp/usrp2/usrp2_iface.hpp @@ -37,7 +37,6 @@ class usrp2_iface : public uhd::i2c_iface, boost::noncopyable{ public: typedef boost::shared_ptr<usrp2_iface> sptr; - typedef std::pair<boost::uint32_t, boost::uint32_t> pair64; /*! * Make a new usrp2 interface with the control transport. @@ -54,14 +53,6 @@ public: virtual usrp2_ctrl_data_t ctrl_send_and_recv(const usrp2_ctrl_data_t &data) = 0; /*! - * Read a dual register (64 bits) - * \param addrlo the address for the low-32 bits - * \param addrhi the address for the high-32 bits - * \return a pair of 32 bit integers lo, hi - */ - virtual pair64 peek64(boost::uint32_t addrlo, boost::uint32_t addrhi) = 0; - - /*! * Write a register (32 bits) * \param addr the address * \param data the 32bit data diff --git a/host/lib/usrp/usrp2/usrp2_regs.cpp b/host/lib/usrp/usrp2/usrp2_regs.cpp index 82ad30f08..13f475413 100644 --- a/host/lib/usrp/usrp2/usrp2_regs.cpp +++ b/host/lib/usrp/usrp2/usrp2_regs.cpp @@ -59,9 +59,11 @@ usrp2_regs_t usrp2_get_regs(bool use_n2xx_map) { x.time64_tps = sr_addr(misc_output_base, x.sr_time64 + 4); x.time64_mimo_sync = sr_addr(misc_output_base, x.sr_time64 + 5); x.status = bp_base + 4*8; - x.time64_secs_rb = bp_base + 4*10; - x.time64_ticks_rb = bp_base + 4*11; + x.time64_secs_rb_imm = bp_base + 4*10; + x.time64_ticks_rb_imm = bp_base + 4*11; x.compat_num_rb = bp_base + 4*12; + x.time64_secs_rb_pps = bp_base + 4*14; + x.time64_ticks_rb_pps = bp_base + 4*15; x.dsp_tx_freq = sr_addr(misc_output_base, x.sr_tx_dsp + 0); x.dsp_tx_scale_iq = sr_addr(misc_output_base, x.sr_tx_dsp + 1); x.dsp_tx_interp_rate = sr_addr(misc_output_base, x.sr_tx_dsp + 2); diff --git a/host/lib/usrp/usrp2/usrp2_regs.hpp b/host/lib/usrp/usrp2/usrp2_regs.hpp index 56e64029e..68b8796d2 100644 --- a/host/lib/usrp/usrp2/usrp2_regs.hpp +++ b/host/lib/usrp/usrp2/usrp2_regs.hpp @@ -59,8 +59,10 @@ typedef struct { int time64_tps; // ticks per second rollover count int time64_mimo_sync; int status; - int time64_secs_rb; - int time64_ticks_rb; + int time64_secs_rb_imm; + int time64_ticks_rb_imm; + int time64_secs_rb_pps; + int time64_ticks_rb_pps; int compat_num_rb; int dsp_tx_freq; int dsp_tx_scale_iq; diff --git a/host/lib/usrp/usrp_e100/mboard_impl.cpp b/host/lib/usrp/usrp_e100/mboard_impl.cpp index fe26cd63d..c056bf3ea 100644 --- a/host/lib/usrp/usrp_e100/mboard_impl.cpp +++ b/host/lib/usrp/usrp_e100/mboard_impl.cpp @@ -150,7 +150,7 @@ void usrp_e100_impl::mboard_set(const wax::obj &key, const wax::obj &val){ return; case MBOARD_PROP_TIME_NOW: - case MBOARD_PROP_TIME_NEXT_PPS:{ + case MBOARD_PROP_TIME_PPS:{ time_spec_t time_spec = val.as<time_spec_t>(); _iface->poke32(UE_REG_TIME64_TICKS, time_spec.get_tick_count(_clock_ctrl->get_fpga_clock_rate())); boost::uint32_t imm_flags = (key.as<mboard_prop_t>() == MBOARD_PROP_TIME_NOW)? 1 : 0; |