From 38248b816c75bcf60eca69244d363cae2397ce47 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 31 Mar 2010 17:43:20 -0700 Subject: Refactor ATR part of dboard interface (and some constants). Added peek and poke to the dude/bro protocol. Started moving more control code through peek and poke. Added usrp_regs.hpp to be like memory map for slave perifs. --- host/include/uhd/usrp/dboard_interface.hpp | 75 ++++++++++++------------------ 1 file changed, 31 insertions(+), 44 deletions(-) (limited to 'host/include') diff --git a/host/include/uhd/usrp/dboard_interface.hpp b/host/include/uhd/usrp/dboard_interface.hpp index c779431ab..8ff0c5d2f 100644 --- a/host/include/uhd/usrp/dboard_interface.hpp +++ b/host/include/uhd/usrp/dboard_interface.hpp @@ -38,32 +38,34 @@ public: //tells the host which unit to use enum unit_type_t{ - UNIT_TYPE_RX, - UNIT_TYPE_TX + UNIT_TYPE_RX = 'r', + UNIT_TYPE_TX = 't' }; //tells the host which device to use enum spi_dev_t{ - SPI_TX_DEV, - SPI_RX_DEV + SPI_DEV_RX = 'r', + SPI_DEV_TX = 't' }; - //args for writing spi data - enum spi_push_t{ - SPI_PUSH_RISE, - SPI_PUSH_FALL - }; - - //args for reading spi data - enum spi_latch_t{ - SPI_LATCH_RISE, - SPI_LATCH_FALL + //args for spi format + enum spi_edge_t{ + SPI_EDGE_RISE = 'r', + SPI_EDGE_FALL = 'f' }; //tell the host which gpio bank enum gpio_bank_t{ - GPIO_TX_BANK, - GPIO_RX_BANK + GPIO_BANK_RX = 'r', + GPIO_BANK_TX = 't' + }; + + //possible atr registers + enum atr_reg_t{ + ATR_REG_IDLE = 'i', + ATR_REG_TXONLY = 't', + ATR_REG_RXONLY = 'r', + ATR_REG_BOTH = 'b' }; //structors @@ -87,17 +89,13 @@ public: virtual int read_aux_adc(unit_type_t unit, int which_adc) = 0; /*! - * Set daughterboard ATR register. - * The ATR register for a particular bank has 2 values: - * one value when transmitting, one when receiving. - * The mask controls which pins are controlled by ATR. + * Set a daughterboard ATR register. * - * \param bank GPIO_TX_BANK or GPIO_RX_BANK - * \param tx_value 16-bits, 0=FPGA output low, 1=FPGA output high - * \param rx_value 16-bits, 0=FPGA output low, 1=FPGA output high - * \param mask 16-bits, 0=software, 1=atr + * \param bank GPIO_TX_BANK or GPIO_RX_BANK + * \param reg which ATR register to set + * \param value 16-bits, 0=FPGA output low, 1=FPGA output high */ - virtual void set_atr_reg(gpio_bank_t bank, boost::uint16_t tx_value, boost::uint16_t rx_value, boost::uint16_t mask) = 0; + virtual void set_atr_reg(gpio_bank_t bank, atr_reg_t reg, boost::uint16_t value) = 0; /*! * Set daughterboard GPIO data direction register. @@ -107,14 +105,6 @@ public: */ virtual void set_gpio_ddr(gpio_bank_t bank, boost::uint16_t value) = 0; - /*! - * Set daughterboard GPIO pin values. - * - * \param bank GPIO_TX_BANK or GPIO_RX_BANK - * \param value 16 bits, 0=low, 1=high - */ - virtual void write_gpio(gpio_bank_t bank, boost::uint16_t value) = 0; - /*! * Read daughterboard GPIO pin values * @@ -142,32 +132,31 @@ public: * \brief Write data to SPI bus peripheral. * * \param dev which spi device - * \param push args for writing + * \param edge args for format * \param buf the data to write */ - void write_spi(spi_dev_t dev, spi_push_t push, const byte_vector_t &buf); + void write_spi(spi_dev_t dev, spi_edge_t edge, const byte_vector_t &buf); /*! * \brief Read data to SPI bus peripheral. * * \param dev which spi device - * \param latch args for reading + * \param edge args for format * \param num_bytes number of bytes to read * \return the data that was read */ - byte_vector_t read_spi(spi_dev_t dev, spi_latch_t latch, size_t num_bytes); + byte_vector_t read_spi(spi_dev_t dev, spi_edge_t edge, size_t num_bytes); /*! * \brief Read and write data to SPI bus peripheral. * The data read back will be the same length as the input buffer. * * \param dev which spi device - * \param latch args for reading - * \param push args for clock + * \param edge args for format * \param buf the data to write * \return the data that was read */ - byte_vector_t read_write_spi(spi_dev_t dev, spi_latch_t latch, spi_push_t push, const byte_vector_t &buf); + byte_vector_t read_write_spi(spi_dev_t dev, spi_edge_t edge, const byte_vector_t &buf); /*! * \brief Get the rate of the rx dboard clock. @@ -186,16 +175,14 @@ private: * \brief Read and write data to SPI bus peripheral. * * \param dev which spi device - * \param latch args for reading - * \param push args for clock + * \param edge args for format * \param buf the data to write * \param readback false for write only * \return the data that was read */ virtual byte_vector_t transact_spi( spi_dev_t dev, - spi_latch_t latch, - spi_push_t push, + spi_edge_t edge, const byte_vector_t &buf, bool readback ) = 0; -- cgit v1.2.3 From 91ef18021c0f0f5fe8ff7705e23b5f1a6b25162f Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 1 Apr 2010 15:08:52 -0700 Subject: moved props into usrp and multiple hpp files --- host/examples/rx_timed_samples.cpp | 1 - host/include/uhd/CMakeLists.txt | 1 - host/include/uhd/props.hpp | 145 ----------------------------- host/include/uhd/usrp/CMakeLists.txt | 10 ++ host/include/uhd/usrp/dboard_interface.hpp | 8 +- host/include/uhd/usrp/dboard_manager.hpp | 2 +- host/include/uhd/usrp/dboard_props.hpp | 38 ++++++++ host/include/uhd/usrp/device_props.hpp | 57 ++++++++++++ host/include/uhd/usrp/dsp_props.hpp | 40 ++++++++ host/include/uhd/usrp/mboard_props.hpp | 50 ++++++++++ host/include/uhd/usrp/subdev_props.hpp | 49 ++++++++++ host/include/uhd/utils/CMakeLists.txt | 1 + host/include/uhd/utils/props.hpp | 48 ++++++++++ host/lib/gain_handler.cpp | 2 +- host/lib/simple_device.cpp | 6 +- host/lib/tune_helper.cpp | 3 +- host/lib/usrp/dboard/db_basic_and_lf.cpp | 2 +- host/lib/usrp/dboard_manager.cpp | 1 + host/lib/usrp/usrp2/dboard_impl.cpp | 2 + host/lib/usrp/usrp2/dboard_interface.cpp | 4 +- host/lib/usrp/usrp2/dsp_impl.cpp | 2 + host/lib/usrp/usrp2/mboard_impl.cpp | 2 + host/lib/usrp/usrp2/usrp2_impl.cpp | 1 + host/test/gain_handler_test.cpp | 2 +- host/utils/uhd_find_devices.cpp | 1 - host/utils/usrp2_burner.cpp | 4 +- 26 files changed, 320 insertions(+), 162 deletions(-) delete mode 100644 host/include/uhd/props.hpp create mode 100644 host/include/uhd/usrp/dboard_props.hpp create mode 100644 host/include/uhd/usrp/device_props.hpp create mode 100644 host/include/uhd/usrp/dsp_props.hpp create mode 100644 host/include/uhd/usrp/mboard_props.hpp create mode 100644 host/include/uhd/usrp/subdev_props.hpp create mode 100644 host/include/uhd/utils/props.hpp (limited to 'host/include') diff --git a/host/examples/rx_timed_samples.cpp b/host/examples/rx_timed_samples.cpp index 88e112584..b3516e686 100644 --- a/host/examples/rx_timed_samples.cpp +++ b/host/examples/rx_timed_samples.cpp @@ -17,7 +17,6 @@ #include #include -#include #include #include #include diff --git a/host/include/uhd/CMakeLists.txt b/host/include/uhd/CMakeLists.txt index b364f78cd..1c5202caa 100644 --- a/host/include/uhd/CMakeLists.txt +++ b/host/include/uhd/CMakeLists.txt @@ -24,7 +24,6 @@ ADD_SUBDIRECTORY(utils) INSTALL(FILES config.hpp device.hpp - props.hpp simple_device.hpp wax.hpp DESTINATION ${INCLUDE_DIR}/uhd diff --git a/host/include/uhd/props.hpp b/host/include/uhd/props.hpp deleted file mode 100644 index 01746f853..000000000 --- a/host/include/uhd/props.hpp +++ /dev/null @@ -1,145 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -#ifndef INCLUDED_UHD_PROPS_HPP -#define INCLUDED_UHD_PROPS_HPP - -#include -#include -#include -#include -#include - -namespace uhd{ - - //typedef for handling named properties - typedef std::vector prop_names_t; - typedef boost::tuple named_prop_t; - - /*! - * Utility function to separate a named property into its components. - * \param key a reference to the prop object - * \param name a reference to the name object - */ - inline UHD_API named_prop_t //must be exported as part of the api to work (TODO move guts to cpp file) - extract_named_prop(const wax::obj &key, const std::string &name = ""){ - if (key.type() == typeid(named_prop_t)){ - return key.as(); - } - return named_prop_t(key, name); - } - - /*! - * Possible device properties: - * In general, a device will have a single mboard. - * In certain mimo applications, multiple boards - * will be present in the interface for configuration. - */ - enum device_prop_t{ - DEVICE_PROP_NAME, //ro, std::string - DEVICE_PROP_MBOARD, //ro, wax::obj - DEVICE_PROP_MBOARD_NAMES, //ro, prop_names_t - DEVICE_PROP_MAX_RX_SAMPLES, //ro, size_t - DEVICE_PROP_MAX_TX_SAMPLES //ro, size_t - }; - - /*! - * Possible device mboard properties: - * The general mboard properties are listed below. - * Custom properties can be identified with a string - * and discovered though the others property. - */ - enum mboard_prop_t{ - MBOARD_PROP_NAME, //ro, std::string - MBOARD_PROP_OTHERS, //ro, prop_names_t - MBOARD_PROP_CLOCK_RATE, //ro, freq_t - MBOARD_PROP_RX_DSP, //ro, wax::obj - MBOARD_PROP_RX_DSP_NAMES, //ro, prop_names_t - MBOARD_PROP_TX_DSP, //ro, wax::obj - MBOARD_PROP_TX_DSP_NAMES, //ro, prop_names_t - MBOARD_PROP_RX_DBOARD, //ro, wax::obj - MBOARD_PROP_RX_DBOARD_NAMES, //ro, prop_names_t - MBOARD_PROP_TX_DBOARD, //ro, wax::obj - MBOARD_PROP_TX_DBOARD_NAMES, //ro, prop_names_t - MBOARD_PROP_CLOCK_CONFIG, //rw, clock_config_t - MBOARD_PROP_TIME_NOW, //wo, time_spec_t - MBOARD_PROP_TIME_NEXT_PPS //wo, time_spec_t - }; - - /*! - * Possible device dsp properties: - * A dsp can have a wide range of possible properties. - * A ddc would have a properties "decim", "freq", "taps"... - * Other properties could be gains, complex scalars, enables... - * For this reason the only required properties of a dsp is a name - * and a property to get list of other possible properties. - */ - enum dsp_prop_t{ - DSP_PROP_NAME, //ro, std::string - DSP_PROP_OTHERS //ro, prop_names_t - }; - - /*! - * Possible device dboard properties - */ - enum dboard_prop_t{ - DBOARD_PROP_NAME, //ro, std::string - DBOARD_PROP_SUBDEV, //ro, wax::obj - DBOARD_PROP_SUBDEV_NAMES, //ro, prop_names_t - DBOARD_PROP_USED_SUBDEVS //ro, prop_names_t - //DBOARD_PROP_CODEC //ro, wax::obj //----> not sure, dont have to deal with yet - }; - - /*! ------ not dealing with yet, commented out ------------ - * Possible device codec properties: - * A codec is expected to have a rate and gain elements. - * Other properties can be discovered through the others prop. - */ - /*enum codec_prop_t{ - CODEC_PROP_NAME, //ro, std::string - CODEC_PROP_OTHERS, //ro, prop_names_t - CODEC_PROP_GAIN, //rw, gain_t - CODEC_PROP_GAIN_RANGE, //ro, gain_range_t - CODEC_PROP_GAIN_NAMES, //ro, prop_names_t - //CODEC_PROP_CLOCK_RATE //ro, freq_t //----> not sure we care to know - };*/ - - /*! - * Possible device subdev properties - */ - enum subdev_prop_t{ - SUBDEV_PROP_NAME, //ro, std::string - SUBDEV_PROP_OTHERS, //ro, prop_names_t - SUBDEV_PROP_GAIN, //rw, gain_t - SUBDEV_PROP_GAIN_RANGE, //ro, gain_range_t - SUBDEV_PROP_GAIN_NAMES, //ro, prop_names_t - SUBDEV_PROP_FREQ, //rw, freq_t - SUBDEV_PROP_FREQ_RANGE, //ro, freq_range_t - SUBDEV_PROP_ANTENNA, //rw, std::string - SUBDEV_PROP_ANTENNA_NAMES, //ro, prop_names_t - SUBDEV_PROP_ENABLED, //rw, bool - SUBDEV_PROP_QUADRATURE, //ro, bool - SUBDEV_PROP_IQ_SWAPPED, //ro, bool - SUBDEV_PROP_SPECTRUM_INVERTED, //ro, bool - SUBDEV_PROP_LO_INTERFERES //ro, bool - //SUBDEV_PROP_RSSI, //ro, gain_t //----> not on all boards, use named prop - //SUBDEV_PROP_BANDWIDTH //rw, freq_t //----> not on all boards, use named prop - }; - -} //namespace uhd - -#endif /* INCLUDED_UHD_PROPS_HPP */ diff --git a/host/include/uhd/usrp/CMakeLists.txt b/host/include/uhd/usrp/CMakeLists.txt index bab01fdeb..d0f385f13 100644 --- a/host/include/uhd/usrp/CMakeLists.txt +++ b/host/include/uhd/usrp/CMakeLists.txt @@ -17,10 +17,20 @@ INSTALL(FILES + #### props headers ### + dboard_props.hpp + device_props.hpp + dsp_props.hpp + mboard_props.hpp + subdev_props.hpp + + #### dboard headers ### dboard_base.hpp dboard_id.hpp dboard_interface.hpp dboard_manager.hpp + + ### usrp headers ### usrp1e.hpp usrp2.hpp DESTINATION ${INCLUDE_DIR}/uhd/usrp diff --git a/host/include/uhd/usrp/dboard_interface.hpp b/host/include/uhd/usrp/dboard_interface.hpp index 8ff0c5d2f..b3bab131d 100644 --- a/host/include/uhd/usrp/dboard_interface.hpp +++ b/host/include/uhd/usrp/dboard_interface.hpp @@ -62,10 +62,10 @@ public: //possible atr registers enum atr_reg_t{ - ATR_REG_IDLE = 'i', - ATR_REG_TXONLY = 't', - ATR_REG_RXONLY = 'r', - ATR_REG_BOTH = 'b' + ATR_REG_IDLE = 'i', + ATR_REG_TX_ONLY = 't', + ATR_REG_RX_ONLY = 'r', + ATR_REG_FULL_DUPLEX = 'f' }; //structors diff --git a/host/include/uhd/usrp/dboard_manager.hpp b/host/include/uhd/usrp/dboard_manager.hpp index c7c091220..ed8ee73ef 100644 --- a/host/include/uhd/usrp/dboard_manager.hpp +++ b/host/include/uhd/usrp/dboard_manager.hpp @@ -19,7 +19,7 @@ #define INCLUDED_UHD_USRP_DBOARD_MANAGER_HPP #include -#include +#include #include #include #include diff --git a/host/include/uhd/usrp/dboard_props.hpp b/host/include/uhd/usrp/dboard_props.hpp new file mode 100644 index 000000000..08c4eef6a --- /dev/null +++ b/host/include/uhd/usrp/dboard_props.hpp @@ -0,0 +1,38 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#ifndef INCLUDED_UHD_USRP_DBOARD_PROPS_HPP +#define INCLUDED_UHD_USRP_DBOARD_PROPS_HPP + +#include + +namespace uhd{ namespace usrp{ + + /*! + * Possible device dboard properties + */ + enum dboard_prop_t{ + DBOARD_PROP_NAME, //ro, std::string + DBOARD_PROP_SUBDEV, //ro, wax::obj + DBOARD_PROP_SUBDEV_NAMES, //ro, prop_names_t + DBOARD_PROP_USED_SUBDEVS //ro, prop_names_t + //DBOARD_PROP_CODEC //ro, wax::obj //----> not sure, dont have to deal with yet + }; + +}} //namespace + +#endif /* INCLUDED_UHD_USRP_DBOARD_PROPS_HPP */ diff --git a/host/include/uhd/usrp/device_props.hpp b/host/include/uhd/usrp/device_props.hpp new file mode 100644 index 000000000..dcfa26240 --- /dev/null +++ b/host/include/uhd/usrp/device_props.hpp @@ -0,0 +1,57 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#ifndef INCLUDED_UHD_USRP_DEVICE_PROPS_HPP +#define INCLUDED_UHD_USRP_DEVICE_PROPS_HPP + +#include + +namespace uhd{ namespace usrp{ + + /*! + * Possible device properties: + * In general, a device will have a single mboard. + * In certain mimo applications, multiple boards + * will be present in the interface for configuration. + */ + enum device_prop_t{ + DEVICE_PROP_NAME, //ro, std::string + DEVICE_PROP_MBOARD, //ro, wax::obj + DEVICE_PROP_MBOARD_NAMES, //ro, prop_names_t + DEVICE_PROP_MAX_RX_SAMPLES, //ro, size_t + DEVICE_PROP_MAX_TX_SAMPLES //ro, size_t + }; + + //////////////////////////////////////////////////////////////////////// + /*! ------ not dealing with yet, commented out ------------ + * Possible device codec properties: + * A codec is expected to have a rate and gain elements. + * Other properties can be discovered through the others prop. + */ + /*enum codec_prop_t{ + CODEC_PROP_NAME, //ro, std::string + CODEC_PROP_OTHERS, //ro, prop_names_t + CODEC_PROP_GAIN, //rw, gain_t + CODEC_PROP_GAIN_RANGE, //ro, gain_range_t + CODEC_PROP_GAIN_NAMES, //ro, prop_names_t + //CODEC_PROP_CLOCK_RATE //ro, freq_t //----> not sure we care to know + };*/ + + +}} //namespace + +#endif /* INCLUDED_UHD_USRP_DEVICE_PROPS_HPP */ diff --git a/host/include/uhd/usrp/dsp_props.hpp b/host/include/uhd/usrp/dsp_props.hpp new file mode 100644 index 000000000..ef3f771df --- /dev/null +++ b/host/include/uhd/usrp/dsp_props.hpp @@ -0,0 +1,40 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#ifndef INCLUDED_UHD_USRP_DSP_PROPS_HPP +#define INCLUDED_UHD_USRP_DSP_PROPS_HPP + +#include + +namespace uhd{ namespace usrp{ + + /*! + * Possible device dsp properties: + * A dsp can have a wide range of possible properties. + * A ddc would have a properties "decim", "freq", "taps"... + * Other properties could be gains, complex scalars, enables... + * For this reason the only required properties of a dsp is a name + * and a property to get list of other possible properties. + */ + enum dsp_prop_t{ + DSP_PROP_NAME, //ro, std::string + DSP_PROP_OTHERS //ro, prop_names_t + }; + +}} //namespace + +#endif /* INCLUDED_UHD_USRP_DSP_PROPS_HPP */ diff --git a/host/include/uhd/usrp/mboard_props.hpp b/host/include/uhd/usrp/mboard_props.hpp new file mode 100644 index 000000000..ddb95ef0d --- /dev/null +++ b/host/include/uhd/usrp/mboard_props.hpp @@ -0,0 +1,50 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#ifndef INCLUDED_UHD_USRP_MBOARD_PROPS_HPP +#define INCLUDED_UHD_USRP_MBOARD_PROPS_HPP + +#include + +namespace uhd{ namespace usrp{ + + /*! + * Possible device mboard properties: + * The general mboard properties are listed below. + * Custom properties can be identified with a string + * and discovered though the others property. + */ + enum mboard_prop_t{ + MBOARD_PROP_NAME, //ro, std::string + MBOARD_PROP_OTHERS, //ro, prop_names_t + MBOARD_PROP_CLOCK_RATE, //ro, double + MBOARD_PROP_RX_DSP, //ro, wax::obj + MBOARD_PROP_RX_DSP_NAMES, //ro, prop_names_t + MBOARD_PROP_TX_DSP, //ro, wax::obj + MBOARD_PROP_TX_DSP_NAMES, //ro, prop_names_t + MBOARD_PROP_RX_DBOARD, //ro, wax::obj + MBOARD_PROP_RX_DBOARD_NAMES, //ro, prop_names_t + MBOARD_PROP_TX_DBOARD, //ro, wax::obj + MBOARD_PROP_TX_DBOARD_NAMES, //ro, prop_names_t + MBOARD_PROP_CLOCK_CONFIG, //rw, clock_config_t + MBOARD_PROP_TIME_NOW, //wo, time_spec_t + MBOARD_PROP_TIME_NEXT_PPS //wo, time_spec_t + }; + +}} //namespace + +#endif /* INCLUDED_UHD_USRP_MBOARD_PROPS_HPP */ diff --git a/host/include/uhd/usrp/subdev_props.hpp b/host/include/uhd/usrp/subdev_props.hpp new file mode 100644 index 000000000..667f34f9c --- /dev/null +++ b/host/include/uhd/usrp/subdev_props.hpp @@ -0,0 +1,49 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#ifndef INCLUDED_UHD_USRP_SUBDEV_PROPS_HPP +#define INCLUDED_UHD_USRP_SUBDEV_PROPS_HPP + +#include + +namespace uhd{ namespace usrp{ + + /*! + * Possible device subdev properties + */ + enum subdev_prop_t{ + SUBDEV_PROP_NAME, //ro, std::string + SUBDEV_PROP_OTHERS, //ro, prop_names_t + SUBDEV_PROP_GAIN, //rw, float + SUBDEV_PROP_GAIN_RANGE, //ro, gain_range_t + SUBDEV_PROP_GAIN_NAMES, //ro, prop_names_t + SUBDEV_PROP_FREQ, //rw, double + SUBDEV_PROP_FREQ_RANGE, //ro, freq_range_t + SUBDEV_PROP_ANTENNA, //rw, std::string + SUBDEV_PROP_ANTENNA_NAMES, //ro, prop_names_t + SUBDEV_PROP_ENABLED, //rw, bool + SUBDEV_PROP_QUADRATURE, //ro, bool + SUBDEV_PROP_IQ_SWAPPED, //ro, bool + SUBDEV_PROP_SPECTRUM_INVERTED, //ro, bool + SUBDEV_PROP_LO_INTERFERES //ro, bool + //SUBDEV_PROP_RSSI, //ro, float //----> not on all boards, use named prop + //SUBDEV_PROP_BANDWIDTH //rw, double //----> not on all boards, use named prop + }; + +}} //namespace + +#endif /* INCLUDED_UHD_USRP_SUBDEV_PROPS_HPP */ diff --git a/host/include/uhd/utils/CMakeLists.txt b/host/include/uhd/utils/CMakeLists.txt index 1b673f44a..2bb72e31d 100644 --- a/host/include/uhd/utils/CMakeLists.txt +++ b/host/include/uhd/utils/CMakeLists.txt @@ -19,6 +19,7 @@ INSTALL(FILES algorithm.hpp assert.hpp gain_handler.hpp + props.hpp safe_main.hpp static.hpp tune_helper.hpp diff --git a/host/include/uhd/utils/props.hpp b/host/include/uhd/utils/props.hpp new file mode 100644 index 000000000..fdbc17d1c --- /dev/null +++ b/host/include/uhd/utils/props.hpp @@ -0,0 +1,48 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#ifndef INCLUDED_UHD_USRP_PROPS_COMMON_HPP +#define INCLUDED_UHD_USRP_PROPS_COMMON_HPP + +#include +#include +#include +#include +#include + +namespace uhd{ + + //typedef for handling named properties + typedef std::vector prop_names_t; + typedef boost::tuple named_prop_t; + + /*! + * Utility function to separate a named property into its components. + * \param key a reference to the prop object + * \param name a reference to the name object + */ + inline UHD_API named_prop_t //must be exported as part of the api to work (TODO move guts to cpp file) + extract_named_prop(const wax::obj &key, const std::string &name = ""){ + if (key.type() == typeid(named_prop_t)){ + return key.as(); + } + return named_prop_t(key, name); + } + +} //namespace uhd + +#endif /* INCLUDED_UHD_USRP_PROPS_COMMON_HPP */ diff --git a/host/lib/gain_handler.cpp b/host/lib/gain_handler.cpp index daf629f0b..36e2e8ed3 100644 --- a/host/lib/gain_handler.cpp +++ b/host/lib/gain_handler.cpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/host/lib/simple_device.cpp b/host/lib/simple_device.cpp index 25beb45a9..801516353 100644 --- a/host/lib/simple_device.cpp +++ b/host/lib/simple_device.cpp @@ -18,12 +18,16 @@ #include #include #include -#include +#include +#include +#include +#include #include #include #include using namespace uhd; +using namespace uhd::usrp; /*********************************************************************** * Helper Functions diff --git a/host/lib/tune_helper.cpp b/host/lib/tune_helper.cpp index 1e5c4cd0d..381685578 100644 --- a/host/lib/tune_helper.cpp +++ b/host/lib/tune_helper.cpp @@ -17,10 +17,11 @@ #include #include -#include +#include #include using namespace uhd; +using namespace uhd::usrp; /*********************************************************************** * Tune Helper Function diff --git a/host/lib/usrp/dboard/db_basic_and_lf.cpp b/host/lib/usrp/dboard/db_basic_and_lf.cpp index 977eb3d49..be4e646ed 100644 --- a/host/lib/usrp/dboard/db_basic_and_lf.cpp +++ b/host/lib/usrp/dboard/db_basic_and_lf.cpp @@ -15,7 +15,7 @@ // along with this program. If not, see . // -#include +#include #include #include #include diff --git a/host/lib/usrp/dboard_manager.cpp b/host/lib/usrp/dboard_manager.cpp index 5c063d51d..3a5cf3a35 100644 --- a/host/lib/usrp/dboard_manager.cpp +++ b/host/lib/usrp/dboard_manager.cpp @@ -16,6 +16,7 @@ // #include +#include #include #include #include diff --git a/host/lib/usrp/usrp2/dboard_impl.cpp b/host/lib/usrp/usrp2/dboard_impl.cpp index 29fb32eeb..30883cd50 100644 --- a/host/lib/usrp/usrp2/dboard_impl.cpp +++ b/host/lib/usrp/usrp2/dboard_impl.cpp @@ -18,6 +18,8 @@ #include "usrp2_impl.hpp" #include "usrp2_regs.hpp" +#include +#include #include #include diff --git a/host/lib/usrp/usrp2/dboard_interface.cpp b/host/lib/usrp/usrp2/dboard_interface.cpp index 4160ad467..dcd6453a8 100644 --- a/host/lib/usrp/usrp2/dboard_interface.cpp +++ b/host/lib/usrp/usrp2/dboard_interface.cpp @@ -114,8 +114,8 @@ boost::uint16_t usrp2_dboard_interface::read_gpio(gpio_bank_t bank){ void usrp2_dboard_interface::set_atr_reg(gpio_bank_t bank, atr_reg_t reg, boost::uint16_t value){ //map the atr reg to an offset in register space static const uhd::dict reg_to_addr = boost::assign::map_list_of - (ATR_REG_IDLE, FR_ATR_IDLE) (ATR_REG_TXONLY, FR_ATR_TX) - (ATR_REG_RXONLY, FR_ATR_RX) (ATR_REG_BOTH, FR_ATR_FULL) + (ATR_REG_IDLE, FR_ATR_IDLE) (ATR_REG_TX_ONLY, FR_ATR_TX) + (ATR_REG_RX_ONLY, FR_ATR_RX) (ATR_REG_FULL_DUPLEX, FR_ATR_FULL) ; ASSERT_THROW(reg_to_addr.has_key(reg)); diff --git a/host/lib/usrp/usrp2/dsp_impl.cpp b/host/lib/usrp/usrp2/dsp_impl.cpp index d50c1ad56..d70248682 100644 --- a/host/lib/usrp/usrp2/dsp_impl.cpp +++ b/host/lib/usrp/usrp2/dsp_impl.cpp @@ -17,12 +17,14 @@ #include "usrp2_impl.hpp" #include "usrp2_regs.hpp" +#include #include #include #include #include using namespace uhd; +using namespace uhd::usrp; static const size_t default_decim = 16; static const size_t default_interp = 16; diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp index 7b658b22d..7594c85fa 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -17,11 +17,13 @@ #include "usrp2_impl.hpp" #include "usrp2_regs.hpp" +#include #include #include #include using namespace uhd; +using namespace uhd::usrp; /*********************************************************************** * Helper Methods diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index e89fe8a63..b3a22e175 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -16,6 +16,7 @@ // #include +#include #include #include #include diff --git a/host/test/gain_handler_test.cpp b/host/test/gain_handler_test.cpp index 76b065ce2..72d26e1c2 100644 --- a/host/test/gain_handler_test.cpp +++ b/host/test/gain_handler_test.cpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include diff --git a/host/utils/uhd_find_devices.cpp b/host/utils/uhd_find_devices.cpp index b328216d0..6c945cbca 100644 --- a/host/utils/uhd_find_devices.cpp +++ b/host/utils/uhd_find_devices.cpp @@ -17,7 +17,6 @@ #include #include -#include #include #include #include diff --git a/host/utils/usrp2_burner.cpp b/host/utils/usrp2_burner.cpp index b24425316..9c1bf72fe 100644 --- a/host/utils/usrp2_burner.cpp +++ b/host/utils/usrp2_burner.cpp @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include #include @@ -56,7 +56,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //create a usrp2 device uhd::device::sptr u2_dev = uhd::usrp::usrp2::make(device_addr); //FIXME usees the default mboard for now (until the mimo link is supported) - wax::obj u2_mb = (*u2_dev)[uhd::DEVICE_PROP_MBOARD]; + wax::obj u2_mb = (*u2_dev)[uhd::usrp::DEVICE_PROP_MBOARD]; std::cout << std::endl; //fetch and print current settings -- cgit v1.2.3 From 54e8b566f6d1efecfd5fdc2c14bb287fd551089e Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 1 Apr 2010 16:01:46 -0700 Subject: Moved usrp specific things into usrp directories and namespaces. Renamed simple device to simple usrp (it was usrp specific). Moved tune helper to usrp dir for same reason. --- host/examples/rx_timed_samples.cpp | 4 +- host/include/uhd/CMakeLists.txt | 1 - host/include/uhd/simple_device.hpp | 97 --------------- host/include/uhd/usrp/CMakeLists.txt | 5 + host/include/uhd/usrp/simple_usrp.hpp | 97 +++++++++++++++ host/include/uhd/usrp/tune_helper.hpp | 79 +++++++++++++ host/include/uhd/utils/CMakeLists.txt | 1 - host/include/uhd/utils/props.hpp | 6 +- host/include/uhd/utils/tune_helper.hpp | 79 ------------- host/lib/CMakeLists.txt | 4 +- host/lib/simple_device.cpp | 207 --------------------------------- host/lib/tune_helper.cpp | 126 -------------------- host/lib/usrp/simple_usrp.cpp | 207 +++++++++++++++++++++++++++++++++ host/lib/usrp/tune_helper.cpp | 126 ++++++++++++++++++++ 14 files changed, 521 insertions(+), 518 deletions(-) delete mode 100644 host/include/uhd/simple_device.hpp create mode 100644 host/include/uhd/usrp/simple_usrp.hpp create mode 100644 host/include/uhd/usrp/tune_helper.hpp delete mode 100644 host/include/uhd/utils/tune_helper.hpp delete mode 100644 host/lib/simple_device.cpp delete mode 100644 host/lib/tune_helper.cpp create mode 100644 host/lib/usrp/simple_usrp.cpp create mode 100644 host/lib/usrp/tune_helper.cpp (limited to 'host/include') diff --git a/host/examples/rx_timed_samples.cpp b/host/examples/rx_timed_samples.cpp index b3516e686..58b5af9da 100644 --- a/host/examples/rx_timed_samples.cpp +++ b/host/examples/rx_timed_samples.cpp @@ -16,7 +16,7 @@ // #include -#include +#include #include #include #include @@ -52,7 +52,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << std::endl; std::cout << boost::format("Creating the usrp device with: %s...") % transport_args << std::endl; - uhd::simple_device::sptr sdev = uhd::simple_device::make(transport_args); + uhd::usrp::simple_usrp::sptr sdev = uhd::usrp::simple_usrp::make(transport_args); uhd::device::sptr dev = sdev->get_device(); std::cout << boost::format("Using Device: %s") % sdev->get_name() << std::endl; diff --git a/host/include/uhd/CMakeLists.txt b/host/include/uhd/CMakeLists.txt index 1c5202caa..d63062032 100644 --- a/host/include/uhd/CMakeLists.txt +++ b/host/include/uhd/CMakeLists.txt @@ -24,7 +24,6 @@ ADD_SUBDIRECTORY(utils) INSTALL(FILES config.hpp device.hpp - simple_device.hpp wax.hpp DESTINATION ${INCLUDE_DIR}/uhd ) diff --git a/host/include/uhd/simple_device.hpp b/host/include/uhd/simple_device.hpp deleted file mode 100644 index 52928367a..000000000 --- a/host/include/uhd/simple_device.hpp +++ /dev/null @@ -1,97 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -#ifndef INCLUDED_UHD_SIMPLE_DEVICE_HPP -#define INCLUDED_UHD_SIMPLE_DEVICE_HPP - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace uhd{ - -/*! - * The simple UHD device class: - * A simple device facilitates ease-of-use for most use-case scenarios. - * The wrapper provides convenience functions to tune the devices - * as well as to set the dboard gains, antennas, and other properties. - */ -class UHD_API simple_device : boost::noncopyable{ -public: - typedef boost::shared_ptr sptr; - static sptr make(const std::string &args); - - virtual device::sptr get_device(void) = 0; - - virtual std::string get_name(void) = 0; - - /******************************************************************* - * Timing - ******************************************************************/ - virtual void set_time_now(const time_spec_t &time_spec) = 0; - virtual void set_time_next_pps(const time_spec_t &time_spec) = 0; - - /******************************************************************* - * Streaming - ******************************************************************/ - virtual void issue_stream_cmd(const stream_cmd_t &stream_cmd) = 0; - - /******************************************************************* - * RX methods - ******************************************************************/ - virtual void set_rx_rate(double rate) = 0; - virtual double get_rx_rate(void) = 0; - virtual std::vector get_rx_rates(void) = 0; - - virtual tune_result_t set_rx_freq(double freq) = 0; - virtual freq_range_t get_rx_freq_range(void) = 0; - - virtual void set_rx_gain(float gain) = 0; - virtual float get_rx_gain(void) = 0; - virtual gain_range_t get_rx_gain_range(void) = 0; - - virtual void set_rx_antenna(const std::string &ant) = 0; - virtual std::string get_rx_antenna(void) = 0; - virtual std::vector get_rx_antennas(void) = 0; - - /******************************************************************* - * TX methods - ******************************************************************/ - virtual void set_tx_rate(double rate) = 0; - virtual double get_tx_rate(void) = 0; - virtual std::vector get_tx_rates(void) = 0; - - virtual tune_result_t set_tx_freq(double freq) = 0; - virtual freq_range_t get_tx_freq_range(void) = 0; - - virtual void set_tx_gain(float gain) = 0; - virtual float get_tx_gain(void) = 0; - virtual gain_range_t get_tx_gain_range(void) = 0; - - virtual void set_tx_antenna(const std::string &ant) = 0; - virtual std::string get_tx_antenna(void) = 0; - virtual std::vector get_tx_antennas(void) = 0; -}; - -} //namespace uhd - -#endif /* INCLUDED_UHD_SIMPLE_DEVICE_HPP */ diff --git a/host/include/uhd/usrp/CMakeLists.txt b/host/include/uhd/usrp/CMakeLists.txt index d0f385f13..7815a4fb9 100644 --- a/host/include/uhd/usrp/CMakeLists.txt +++ b/host/include/uhd/usrp/CMakeLists.txt @@ -33,5 +33,10 @@ INSTALL(FILES ### usrp headers ### usrp1e.hpp usrp2.hpp + + ### utilities ### + tune_helper.hpp + simple_usrp.hpp + DESTINATION ${INCLUDE_DIR}/uhd/usrp ) diff --git a/host/include/uhd/usrp/simple_usrp.hpp b/host/include/uhd/usrp/simple_usrp.hpp new file mode 100644 index 000000000..dea1cabda --- /dev/null +++ b/host/include/uhd/usrp/simple_usrp.hpp @@ -0,0 +1,97 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#ifndef INCLUDED_UHD_USRP_SIMPLE_USRP_HPP +#define INCLUDED_UHD_USRP_SIMPLE_USRP_HPP + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace uhd{ namespace usrp{ + +/*! + * The simple USRP device class: + * A simple usrp facilitates ease-of-use for most use-case scenarios. + * The wrapper provides convenience functions to tune the devices + * as well as to set the dboard gains, antennas, and other properties. + */ +class UHD_API simple_usrp : boost::noncopyable{ +public: + typedef boost::shared_ptr sptr; + static sptr make(const std::string &args); + + virtual device::sptr get_device(void) = 0; + + virtual std::string get_name(void) = 0; + + /******************************************************************* + * Timing + ******************************************************************/ + virtual void set_time_now(const time_spec_t &time_spec) = 0; + virtual void set_time_next_pps(const time_spec_t &time_spec) = 0; + + /******************************************************************* + * Streaming + ******************************************************************/ + virtual void issue_stream_cmd(const stream_cmd_t &stream_cmd) = 0; + + /******************************************************************* + * RX methods + ******************************************************************/ + virtual void set_rx_rate(double rate) = 0; + virtual double get_rx_rate(void) = 0; + virtual std::vector get_rx_rates(void) = 0; + + virtual tune_result_t set_rx_freq(double freq) = 0; + virtual freq_range_t get_rx_freq_range(void) = 0; + + virtual void set_rx_gain(float gain) = 0; + virtual float get_rx_gain(void) = 0; + virtual gain_range_t get_rx_gain_range(void) = 0; + + virtual void set_rx_antenna(const std::string &ant) = 0; + virtual std::string get_rx_antenna(void) = 0; + virtual std::vector get_rx_antennas(void) = 0; + + /******************************************************************* + * TX methods + ******************************************************************/ + virtual void set_tx_rate(double rate) = 0; + virtual double get_tx_rate(void) = 0; + virtual std::vector get_tx_rates(void) = 0; + + virtual tune_result_t set_tx_freq(double freq) = 0; + virtual freq_range_t get_tx_freq_range(void) = 0; + + virtual void set_tx_gain(float gain) = 0; + virtual float get_tx_gain(void) = 0; + virtual gain_range_t get_tx_gain_range(void) = 0; + + virtual void set_tx_antenna(const std::string &ant) = 0; + virtual std::string get_tx_antenna(void) = 0; + virtual std::vector get_tx_antennas(void) = 0; +}; + +}} + +#endif /* INCLUDED_UHD_USRP_SIMPLE_USRP_HPP */ diff --git a/host/include/uhd/usrp/tune_helper.hpp b/host/include/uhd/usrp/tune_helper.hpp new file mode 100644 index 000000000..f1e276d4f --- /dev/null +++ b/host/include/uhd/usrp/tune_helper.hpp @@ -0,0 +1,79 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#ifndef INCLUDED_UHD_USRP_TUNE_HELPER_HPP +#define INCLUDED_UHD_USRP_TUNE_HELPER_HPP + +#include +#include +#include + +namespace uhd{ namespace usrp{ + +/*! + * Tune a rx chain to the desired frequency: + * The IF of the subdevice is set as close as possible to + * the given target frequency + the LO offset (when applicable). + * The ddc cordic is setup to bring the IF down to baseband. + * \param subdev the dboard subdevice object with properties + * \param ddc the ddc properties object (with "if_rate", "bb_rate", "freq") + * \param target_freq the desired center frequency + * \param lo_offset an offset for the subdevice IF from center + * \return a tune result struct + */ +UHD_API tune_result_t tune_rx_subdev_and_ddc( + wax::obj subdev, wax::obj ddc, + double target_freq, double lo_offset +); + +/*! + * Tune a rx chain to the desired frequency: + * Same as the above, except the LO offset + * is calculated based on the subdevice and BW. + */ +UHD_API tune_result_t tune_rx_subdev_and_ddc( + wax::obj subdev, wax::obj ddc, double target_freq +); + +/*! + * Tune a tx chain to the desired frequency: + * The IF of the subdevice is set as close as possible to + * the given target frequency + the LO offset (when applicable). + * The duc cordic is setup to bring the baseband up to IF. + * \param subdev the dboard subdevice object with properties + * \param duc the duc properties object (with "if_rate", "bb_rate", "freq") + * \param target_freq the desired center frequency + * \param lo_offset an offset for the subdevice IF from center + * \return a tune result struct + */ +UHD_API tune_result_t tune_tx_subdev_and_duc( + wax::obj subdev, wax::obj duc, + double target_freq, double lo_offset +); + +/*! + * Tune a tx chain to the desired frequency: + * Same as the above, except the LO offset + * is calculated based on the subdevice and BW. + */ +UHD_API tune_result_t tune_tx_subdev_and_duc( + wax::obj subdev, wax::obj duc, double target_freq +); + +}} + +#endif /* INCLUDED_UHD_USRP_TUNE_HELPER_HPP */ diff --git a/host/include/uhd/utils/CMakeLists.txt b/host/include/uhd/utils/CMakeLists.txt index 2bb72e31d..2831ab0b0 100644 --- a/host/include/uhd/utils/CMakeLists.txt +++ b/host/include/uhd/utils/CMakeLists.txt @@ -22,6 +22,5 @@ INSTALL(FILES props.hpp safe_main.hpp static.hpp - tune_helper.hpp DESTINATION ${INCLUDE_DIR}/uhd/utils ) diff --git a/host/include/uhd/utils/props.hpp b/host/include/uhd/utils/props.hpp index fdbc17d1c..6be0b2ce5 100644 --- a/host/include/uhd/utils/props.hpp +++ b/host/include/uhd/utils/props.hpp @@ -15,8 +15,8 @@ // along with this program. If not, see . // -#ifndef INCLUDED_UHD_USRP_PROPS_COMMON_HPP -#define INCLUDED_UHD_USRP_PROPS_COMMON_HPP +#ifndef INCLUDED_UHD_UTILS_PROPS_HPP +#define INCLUDED_UHD_UTILS_PROPS_HPP #include #include @@ -45,4 +45,4 @@ namespace uhd{ } //namespace uhd -#endif /* INCLUDED_UHD_USRP_PROPS_COMMON_HPP */ +#endif /* INCLUDED_UHD_UTILS_PROPS_HPP */ diff --git a/host/include/uhd/utils/tune_helper.hpp b/host/include/uhd/utils/tune_helper.hpp deleted file mode 100644 index 958d1eceb..000000000 --- a/host/include/uhd/utils/tune_helper.hpp +++ /dev/null @@ -1,79 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -#ifndef INCLUDED_UHD_UTILS_TUNE_HELPER_HPP -#define INCLUDED_UHD_UTILS_TUNE_HELPER_HPP - -#include -#include -#include - -namespace uhd{ - -/*! - * Tune a rx chain to the desired frequency: - * The IF of the subdevice is set as close as possible to - * the given target frequency + the LO offset (when applicable). - * The ddc cordic is setup to bring the IF down to baseband. - * \param subdev the dboard subdevice object with properties - * \param ddc the ddc properties object (with "if_rate", "bb_rate", "freq") - * \param target_freq the desired center frequency - * \param lo_offset an offset for the subdevice IF from center - * \return a tune result struct - */ -UHD_API tune_result_t tune_rx_subdev_and_ddc( - wax::obj subdev, wax::obj ddc, - double target_freq, double lo_offset -); - -/*! - * Tune a rx chain to the desired frequency: - * Same as the above, except the LO offset - * is calculated based on the subdevice and BW. - */ -UHD_API tune_result_t tune_rx_subdev_and_ddc( - wax::obj subdev, wax::obj ddc, double target_freq -); - -/*! - * Tune a tx chain to the desired frequency: - * The IF of the subdevice is set as close as possible to - * the given target frequency + the LO offset (when applicable). - * The duc cordic is setup to bring the baseband up to IF. - * \param subdev the dboard subdevice object with properties - * \param duc the duc properties object (with "if_rate", "bb_rate", "freq") - * \param target_freq the desired center frequency - * \param lo_offset an offset for the subdevice IF from center - * \return a tune result struct - */ -UHD_API tune_result_t tune_tx_subdev_and_duc( - wax::obj subdev, wax::obj duc, - double target_freq, double lo_offset -); - -/*! - * Tune a tx chain to the desired frequency: - * Same as the above, except the LO offset - * is calculated based on the subdevice and BW. - */ -UHD_API tune_result_t tune_tx_subdev_and_duc( - wax::obj subdev, wax::obj duc, double target_freq -); - -} //namespace uhd - -#endif /* INCLUDED_UHD_UTILS_TUNE_HELPER_HPP */ diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt index b205bad5b..a5345cae4 100644 --- a/host/lib/CMakeLists.txt +++ b/host/lib/CMakeLists.txt @@ -22,8 +22,6 @@ SET(libuhd_sources device.cpp gain_handler.cpp load_modules.cpp - simple_device.cpp - tune_helper.cpp types.cpp wax.cpp transport/if_addrs.cpp @@ -32,7 +30,9 @@ SET(libuhd_sources usrp/dboard/db_basic_and_lf.cpp usrp/dboard_base.cpp usrp/dboard_interface.cpp + usrp/simple_usrp.cpp usrp/dboard_manager.cpp + usrp/tune_helper.cpp usrp/usrp2/dboard_impl.cpp usrp/usrp2/dboard_interface.cpp usrp/usrp2/dsp_impl.cpp diff --git a/host/lib/simple_device.cpp b/host/lib/simple_device.cpp deleted file mode 100644 index 801516353..000000000 --- a/host/lib/simple_device.cpp +++ /dev/null @@ -1,207 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace uhd; -using namespace uhd::usrp; - -/*********************************************************************** - * Helper Functions - **********************************************************************/ -static std::vector get_xx_rates(wax::obj decerps, wax::obj rate){ - std::vector rates; - BOOST_FOREACH(size_t decerp, decerps.as >()){ - rates.push_back(rate.as()/decerp); - } - return rates; -} - -/*********************************************************************** - * Simple Device Implementation - **********************************************************************/ -class simple_device_impl : public simple_device{ -public: - simple_device_impl(const device_addr_t &addr){ - _dev = device::make(addr); - _mboard = (*_dev)[DEVICE_PROP_MBOARD]; - _rx_ddc = _mboard[named_prop_t(MBOARD_PROP_RX_DSP, "ddc0")]; - _tx_duc = _mboard[named_prop_t(MBOARD_PROP_TX_DSP, "duc0")]; - - //extract rx subdevice - wax::obj rx_dboard = _mboard[MBOARD_PROP_RX_DBOARD]; - std::string rx_subdev_in_use = rx_dboard[DBOARD_PROP_USED_SUBDEVS].as().at(0); - _rx_subdev = rx_dboard[named_prop_t(DBOARD_PROP_SUBDEV, rx_subdev_in_use)]; - - //extract tx subdevice - wax::obj tx_dboard = _mboard[MBOARD_PROP_TX_DBOARD]; - std::string tx_subdev_in_use = tx_dboard[DBOARD_PROP_USED_SUBDEVS].as().at(0); - _tx_subdev = tx_dboard[named_prop_t(DBOARD_PROP_SUBDEV, tx_subdev_in_use)]; - } - - ~simple_device_impl(void){ - /* NOP */ - } - - device::sptr get_device(void){ - return _dev; - } - - std::string get_name(void){ - return _mboard[MBOARD_PROP_NAME].as(); - } - - /******************************************************************* - * Timing - ******************************************************************/ - 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; - } - - /******************************************************************* - * Streaming - ******************************************************************/ - void issue_stream_cmd(const stream_cmd_t &stream_cmd){ - _rx_ddc[std::string("stream_cmd")] = stream_cmd; - } - - /******************************************************************* - * RX methods - ******************************************************************/ - void set_rx_rate(double rate){ - double samp_rate = _rx_ddc[std::string("if_rate")].as(); - assert_has(get_rx_rates(), rate, "simple device rx rate"); - _rx_ddc[std::string("decim")] = size_t(samp_rate/rate); - } - - double get_rx_rate(void){ - return _rx_ddc[std::string("bb_rate")].as(); - } - - std::vector get_rx_rates(void){ - return get_xx_rates(_rx_ddc[std::string("decims")], _rx_ddc[std::string("if_rate")]); - } - - tune_result_t set_rx_freq(double target_freq){ - return tune_rx_subdev_and_ddc(_rx_subdev, _rx_ddc, target_freq); - } - - freq_range_t get_rx_freq_range(void){ - return _rx_subdev[SUBDEV_PROP_FREQ_RANGE].as(); - } - - void set_rx_gain(float gain){ - _rx_subdev[SUBDEV_PROP_GAIN] = gain; - } - - float get_rx_gain(void){ - return _rx_subdev[SUBDEV_PROP_GAIN].as(); - } - - gain_range_t get_rx_gain_range(void){ - return _rx_subdev[SUBDEV_PROP_GAIN_RANGE].as(); - } - - void set_rx_antenna(const std::string &ant){ - _rx_subdev[SUBDEV_PROP_ANTENNA] = ant; - } - - std::string get_rx_antenna(void){ - return _rx_subdev[SUBDEV_PROP_ANTENNA].as(); - } - - std::vector get_rx_antennas(void){ - return _rx_subdev[SUBDEV_PROP_ANTENNA_NAMES].as >(); - } - - /******************************************************************* - * TX methods - ******************************************************************/ - void set_tx_rate(double rate){ - double samp_rate = _tx_duc[std::string("if_rate")].as(); - assert_has(get_tx_rates(), rate, "simple device tx rate"); - _tx_duc[std::string("interp")] = size_t(samp_rate/rate); - } - - double get_tx_rate(void){ - return _tx_duc[std::string("bb_rate")].as(); - } - - std::vector get_tx_rates(void){ - return get_xx_rates(_tx_duc[std::string("interps")], _tx_duc[std::string("if_rate")]); - } - - tune_result_t set_tx_freq(double target_freq){ - return tune_tx_subdev_and_duc(_tx_subdev, _tx_duc, target_freq); - } - - freq_range_t get_tx_freq_range(void){ - return _tx_subdev[SUBDEV_PROP_FREQ_RANGE].as(); - } - - void set_tx_gain(float gain){ - _tx_subdev[SUBDEV_PROP_GAIN] = gain; - } - - float get_tx_gain(void){ - return _tx_subdev[SUBDEV_PROP_GAIN].as(); - } - - gain_range_t get_tx_gain_range(void){ - return _tx_subdev[SUBDEV_PROP_GAIN_RANGE].as(); - } - - void set_tx_antenna(const std::string &ant){ - _tx_subdev[SUBDEV_PROP_ANTENNA] = ant; - } - - std::string get_tx_antenna(void){ - return _tx_subdev[SUBDEV_PROP_ANTENNA].as(); - } - - std::vector get_tx_antennas(void){ - return _tx_subdev[SUBDEV_PROP_ANTENNA_NAMES].as >(); - } - -private: - device::sptr _dev; - wax::obj _mboard; - wax::obj _rx_ddc; - wax::obj _tx_duc; - wax::obj _rx_subdev; - wax::obj _tx_subdev; -}; - -/*********************************************************************** - * The Make Function - **********************************************************************/ -simple_device::sptr simple_device::make(const std::string &args){ - return sptr(new simple_device_impl(device_addr_t::from_args_str(args))); -} diff --git a/host/lib/tune_helper.cpp b/host/lib/tune_helper.cpp deleted file mode 100644 index 381685578..000000000 --- a/host/lib/tune_helper.cpp +++ /dev/null @@ -1,126 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -#include -#include -#include -#include - -using namespace uhd; -using namespace uhd::usrp; - -/*********************************************************************** - * Tune Helper Function - **********************************************************************/ -static tune_result_t tune_xx_subdev_and_dxc( - bool is_tx, - wax::obj subdev, wax::obj dxc, - double target_freq, double lo_offset -){ - wax::obj subdev_freq_proxy = subdev[SUBDEV_PROP_FREQ]; - bool subdev_quadrature = subdev[SUBDEV_PROP_QUADRATURE].as(); - bool subdev_spectrum_inverted = subdev[SUBDEV_PROP_SPECTRUM_INVERTED].as(); - wax::obj dxc_freq_proxy = dxc[std::string("freq")]; - double dxc_sample_rate = dxc[std::string("if_rate")].as(); - - // Ask the d'board to tune as closely as it can to target_freq+lo_offset - double target_inter_freq = target_freq + lo_offset; - subdev_freq_proxy = target_inter_freq; - double actual_inter_freq = subdev_freq_proxy.as(); - - // Calculate the DDC setting that will downconvert the baseband from the - // daughterboard to our target frequency. - double delta_freq = target_freq - actual_inter_freq; - double delta_sign = std::signum(delta_freq); - delta_freq *= delta_sign; - delta_freq = std::fmod(delta_freq, dxc_sample_rate); - bool inverted = delta_freq > dxc_sample_rate/2.0; - double target_dxc_freq = inverted? (delta_freq - dxc_sample_rate) : (-delta_freq); - target_dxc_freq *= delta_sign; - - // If the spectrum is inverted, and the daughterboard doesn't do - // quadrature downconversion, we can fix the inversion by flipping the - // sign of the dxc_freq... (This only happens using the basic_rx board) - if (subdev_spectrum_inverted){ - inverted = not inverted; - } - if (inverted and not subdev_quadrature){ - target_dxc_freq *= -1.0; - inverted = not inverted; - } - // down conversion versus up conversion, fight! - // your mother is ugly and your going down... - target_dxc_freq *= (is_tx)? -1.0 : +1.0; - - dxc_freq_proxy = target_dxc_freq; - double actual_dxc_freq = dxc_freq_proxy.as(); - - //return some kind of tune result tuple/struct - tune_result_t tune_result; - tune_result.target_inter_freq = target_inter_freq; - tune_result.actual_inter_freq = actual_inter_freq; - tune_result.target_dxc_freq = target_dxc_freq; - tune_result.actual_dxc_freq = actual_dxc_freq; - tune_result.spectrum_inverted = inverted; - return tune_result; -} - -/*********************************************************************** - * RX Tune - **********************************************************************/ -tune_result_t uhd::tune_rx_subdev_and_ddc( - wax::obj subdev, wax::obj ddc, - double target_freq, double lo_offset -){ - bool is_tx = false; - return tune_xx_subdev_and_dxc(is_tx, subdev, ddc, target_freq, lo_offset); -} - -tune_result_t uhd::tune_rx_subdev_and_ddc( - wax::obj subdev, wax::obj ddc, - double target_freq -){ - double lo_offset = 0.0; - //if the local oscillator will be in the passband, use an offset - if (subdev[SUBDEV_PROP_LO_INTERFERES].as()){ - lo_offset = 2.0*ddc[std::string("bb_rate")].as(); - } - return tune_rx_subdev_and_ddc(subdev, ddc, target_freq, lo_offset); -} - -/*********************************************************************** - * TX Tune - **********************************************************************/ -tune_result_t uhd::tune_tx_subdev_and_duc( - wax::obj subdev, wax::obj duc, - double target_freq, double lo_offset -){ - bool is_tx = true; - return tune_xx_subdev_and_dxc(is_tx, subdev, duc, target_freq, lo_offset); -} - -tune_result_t uhd::tune_tx_subdev_and_duc( - wax::obj subdev, wax::obj duc, - double target_freq -){ - double lo_offset = 0.0; - //if the local oscillator will be in the passband, use an offset - if (subdev[SUBDEV_PROP_LO_INTERFERES].as()){ - lo_offset = 2.0*duc[std::string("bb_rate")].as(); - } - return tune_tx_subdev_and_duc(subdev, duc, target_freq, lo_offset); -} diff --git a/host/lib/usrp/simple_usrp.cpp b/host/lib/usrp/simple_usrp.cpp new file mode 100644 index 000000000..4bd47dc3f --- /dev/null +++ b/host/lib/usrp/simple_usrp.cpp @@ -0,0 +1,207 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace uhd; +using namespace uhd::usrp; + +/*********************************************************************** + * Helper Functions + **********************************************************************/ +static std::vector get_xx_rates(wax::obj decerps, wax::obj rate){ + std::vector rates; + BOOST_FOREACH(size_t decerp, decerps.as >()){ + rates.push_back(rate.as()/decerp); + } + return rates; +} + +/*********************************************************************** + * Simple Device Implementation + **********************************************************************/ +class simple_usrp_impl : public simple_usrp{ +public: + simple_usrp_impl(const device_addr_t &addr){ + _dev = device::make(addr); + _mboard = (*_dev)[DEVICE_PROP_MBOARD]; + _rx_ddc = _mboard[named_prop_t(MBOARD_PROP_RX_DSP, "ddc0")]; + _tx_duc = _mboard[named_prop_t(MBOARD_PROP_TX_DSP, "duc0")]; + + //extract rx subdevice + wax::obj rx_dboard = _mboard[MBOARD_PROP_RX_DBOARD]; + std::string rx_subdev_in_use = rx_dboard[DBOARD_PROP_USED_SUBDEVS].as().at(0); + _rx_subdev = rx_dboard[named_prop_t(DBOARD_PROP_SUBDEV, rx_subdev_in_use)]; + + //extract tx subdevice + wax::obj tx_dboard = _mboard[MBOARD_PROP_TX_DBOARD]; + std::string tx_subdev_in_use = tx_dboard[DBOARD_PROP_USED_SUBDEVS].as().at(0); + _tx_subdev = tx_dboard[named_prop_t(DBOARD_PROP_SUBDEV, tx_subdev_in_use)]; + } + + ~simple_usrp_impl(void){ + /* NOP */ + } + + device::sptr get_device(void){ + return _dev; + } + + std::string get_name(void){ + return _mboard[MBOARD_PROP_NAME].as(); + } + + /******************************************************************* + * Timing + ******************************************************************/ + 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; + } + + /******************************************************************* + * Streaming + ******************************************************************/ + void issue_stream_cmd(const stream_cmd_t &stream_cmd){ + _rx_ddc[std::string("stream_cmd")] = stream_cmd; + } + + /******************************************************************* + * RX methods + ******************************************************************/ + void set_rx_rate(double rate){ + double samp_rate = _rx_ddc[std::string("if_rate")].as(); + assert_has(get_rx_rates(), rate, "simple device rx rate"); + _rx_ddc[std::string("decim")] = size_t(samp_rate/rate); + } + + double get_rx_rate(void){ + return _rx_ddc[std::string("bb_rate")].as(); + } + + std::vector get_rx_rates(void){ + return get_xx_rates(_rx_ddc[std::string("decims")], _rx_ddc[std::string("if_rate")]); + } + + tune_result_t set_rx_freq(double target_freq){ + return tune_rx_subdev_and_ddc(_rx_subdev, _rx_ddc, target_freq); + } + + freq_range_t get_rx_freq_range(void){ + return _rx_subdev[SUBDEV_PROP_FREQ_RANGE].as(); + } + + void set_rx_gain(float gain){ + _rx_subdev[SUBDEV_PROP_GAIN] = gain; + } + + float get_rx_gain(void){ + return _rx_subdev[SUBDEV_PROP_GAIN].as(); + } + + gain_range_t get_rx_gain_range(void){ + return _rx_subdev[SUBDEV_PROP_GAIN_RANGE].as(); + } + + void set_rx_antenna(const std::string &ant){ + _rx_subdev[SUBDEV_PROP_ANTENNA] = ant; + } + + std::string get_rx_antenna(void){ + return _rx_subdev[SUBDEV_PROP_ANTENNA].as(); + } + + std::vector get_rx_antennas(void){ + return _rx_subdev[SUBDEV_PROP_ANTENNA_NAMES].as >(); + } + + /******************************************************************* + * TX methods + ******************************************************************/ + void set_tx_rate(double rate){ + double samp_rate = _tx_duc[std::string("if_rate")].as(); + assert_has(get_tx_rates(), rate, "simple device tx rate"); + _tx_duc[std::string("interp")] = size_t(samp_rate/rate); + } + + double get_tx_rate(void){ + return _tx_duc[std::string("bb_rate")].as(); + } + + std::vector get_tx_rates(void){ + return get_xx_rates(_tx_duc[std::string("interps")], _tx_duc[std::string("if_rate")]); + } + + tune_result_t set_tx_freq(double target_freq){ + return tune_tx_subdev_and_duc(_tx_subdev, _tx_duc, target_freq); + } + + freq_range_t get_tx_freq_range(void){ + return _tx_subdev[SUBDEV_PROP_FREQ_RANGE].as(); + } + + void set_tx_gain(float gain){ + _tx_subdev[SUBDEV_PROP_GAIN] = gain; + } + + float get_tx_gain(void){ + return _tx_subdev[SUBDEV_PROP_GAIN].as(); + } + + gain_range_t get_tx_gain_range(void){ + return _tx_subdev[SUBDEV_PROP_GAIN_RANGE].as(); + } + + void set_tx_antenna(const std::string &ant){ + _tx_subdev[SUBDEV_PROP_ANTENNA] = ant; + } + + std::string get_tx_antenna(void){ + return _tx_subdev[SUBDEV_PROP_ANTENNA].as(); + } + + std::vector get_tx_antennas(void){ + return _tx_subdev[SUBDEV_PROP_ANTENNA_NAMES].as >(); + } + +private: + device::sptr _dev; + wax::obj _mboard; + wax::obj _rx_ddc; + wax::obj _tx_duc; + wax::obj _rx_subdev; + wax::obj _tx_subdev; +}; + +/*********************************************************************** + * The Make Function + **********************************************************************/ +simple_usrp::sptr simple_usrp::make(const std::string &args){ + return sptr(new simple_usrp_impl(device_addr_t::from_args_str(args))); +} diff --git a/host/lib/usrp/tune_helper.cpp b/host/lib/usrp/tune_helper.cpp new file mode 100644 index 000000000..79a6aff7b --- /dev/null +++ b/host/lib/usrp/tune_helper.cpp @@ -0,0 +1,126 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#include +#include +#include +#include + +using namespace uhd; +using namespace uhd::usrp; + +/*********************************************************************** + * Tune Helper Function + **********************************************************************/ +static tune_result_t tune_xx_subdev_and_dxc( + bool is_tx, + wax::obj subdev, wax::obj dxc, + double target_freq, double lo_offset +){ + wax::obj subdev_freq_proxy = subdev[SUBDEV_PROP_FREQ]; + bool subdev_quadrature = subdev[SUBDEV_PROP_QUADRATURE].as(); + bool subdev_spectrum_inverted = subdev[SUBDEV_PROP_SPECTRUM_INVERTED].as(); + wax::obj dxc_freq_proxy = dxc[std::string("freq")]; + double dxc_sample_rate = dxc[std::string("if_rate")].as(); + + // Ask the d'board to tune as closely as it can to target_freq+lo_offset + double target_inter_freq = target_freq + lo_offset; + subdev_freq_proxy = target_inter_freq; + double actual_inter_freq = subdev_freq_proxy.as(); + + // Calculate the DDC setting that will downconvert the baseband from the + // daughterboard to our target frequency. + double delta_freq = target_freq - actual_inter_freq; + double delta_sign = std::signum(delta_freq); + delta_freq *= delta_sign; + delta_freq = std::fmod(delta_freq, dxc_sample_rate); + bool inverted = delta_freq > dxc_sample_rate/2.0; + double target_dxc_freq = inverted? (delta_freq - dxc_sample_rate) : (-delta_freq); + target_dxc_freq *= delta_sign; + + // If the spectrum is inverted, and the daughterboard doesn't do + // quadrature downconversion, we can fix the inversion by flipping the + // sign of the dxc_freq... (This only happens using the basic_rx board) + if (subdev_spectrum_inverted){ + inverted = not inverted; + } + if (inverted and not subdev_quadrature){ + target_dxc_freq *= -1.0; + inverted = not inverted; + } + // down conversion versus up conversion, fight! + // your mother is ugly and your going down... + target_dxc_freq *= (is_tx)? -1.0 : +1.0; + + dxc_freq_proxy = target_dxc_freq; + double actual_dxc_freq = dxc_freq_proxy.as(); + + //return some kind of tune result tuple/struct + tune_result_t tune_result; + tune_result.target_inter_freq = target_inter_freq; + tune_result.actual_inter_freq = actual_inter_freq; + tune_result.target_dxc_freq = target_dxc_freq; + tune_result.actual_dxc_freq = actual_dxc_freq; + tune_result.spectrum_inverted = inverted; + return tune_result; +} + +/*********************************************************************** + * RX Tune + **********************************************************************/ +tune_result_t uhd::usrp::tune_rx_subdev_and_ddc( + wax::obj subdev, wax::obj ddc, + double target_freq, double lo_offset +){ + bool is_tx = false; + return tune_xx_subdev_and_dxc(is_tx, subdev, ddc, target_freq, lo_offset); +} + +tune_result_t uhd::usrp::tune_rx_subdev_and_ddc( + wax::obj subdev, wax::obj ddc, + double target_freq +){ + double lo_offset = 0.0; + //if the local oscillator will be in the passband, use an offset + if (subdev[SUBDEV_PROP_LO_INTERFERES].as()){ + lo_offset = 2.0*ddc[std::string("bb_rate")].as(); + } + return tune_rx_subdev_and_ddc(subdev, ddc, target_freq, lo_offset); +} + +/*********************************************************************** + * TX Tune + **********************************************************************/ +tune_result_t uhd::usrp::tune_tx_subdev_and_duc( + wax::obj subdev, wax::obj duc, + double target_freq, double lo_offset +){ + bool is_tx = true; + return tune_xx_subdev_and_dxc(is_tx, subdev, duc, target_freq, lo_offset); +} + +tune_result_t uhd::usrp::tune_tx_subdev_and_duc( + wax::obj subdev, wax::obj duc, + double target_freq +){ + double lo_offset = 0.0; + //if the local oscillator will be in the passband, use an offset + if (subdev[SUBDEV_PROP_LO_INTERFERES].as()){ + lo_offset = 2.0*duc[std::string("bb_rate")].as(); + } + return tune_tx_subdev_and_duc(subdev, duc, target_freq, lo_offset); +} -- cgit v1.2.3 From f1f4865119605c66ffece113a621308d82512d23 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 1 Apr 2010 16:37:25 -0700 Subject: hardcoded values for enum props, added clock get/set for simple usrp --- host/include/uhd/usrp/dboard_props.hpp | 8 ++++---- host/include/uhd/usrp/device_props.hpp | 10 +++++----- host/include/uhd/usrp/dsp_props.hpp | 4 ++-- host/include/uhd/usrp/mboard_props.hpp | 28 ++++++++++++++-------------- host/include/uhd/usrp/simple_usrp.hpp | 9 ++++----- host/include/uhd/usrp/subdev_props.hpp | 28 ++++++++++++++-------------- host/lib/usrp/simple_usrp.cpp | 17 +++++++++++------ 7 files changed, 54 insertions(+), 50 deletions(-) (limited to 'host/include') diff --git a/host/include/uhd/usrp/dboard_props.hpp b/host/include/uhd/usrp/dboard_props.hpp index 08c4eef6a..3b290319f 100644 --- a/host/include/uhd/usrp/dboard_props.hpp +++ b/host/include/uhd/usrp/dboard_props.hpp @@ -26,10 +26,10 @@ namespace uhd{ namespace usrp{ * Possible device dboard properties */ enum dboard_prop_t{ - DBOARD_PROP_NAME, //ro, std::string - DBOARD_PROP_SUBDEV, //ro, wax::obj - DBOARD_PROP_SUBDEV_NAMES, //ro, prop_names_t - DBOARD_PROP_USED_SUBDEVS //ro, prop_names_t + DBOARD_PROP_NAME = 'n', //ro, std::string + DBOARD_PROP_SUBDEV = 's', //ro, wax::obj + DBOARD_PROP_SUBDEV_NAMES = 'S', //ro, prop_names_t + DBOARD_PROP_USED_SUBDEVS = 'u' //ro, prop_names_t //DBOARD_PROP_CODEC //ro, wax::obj //----> not sure, dont have to deal with yet }; diff --git a/host/include/uhd/usrp/device_props.hpp b/host/include/uhd/usrp/device_props.hpp index dcfa26240..b8f6f5cd4 100644 --- a/host/include/uhd/usrp/device_props.hpp +++ b/host/include/uhd/usrp/device_props.hpp @@ -29,11 +29,11 @@ namespace uhd{ namespace usrp{ * will be present in the interface for configuration. */ enum device_prop_t{ - DEVICE_PROP_NAME, //ro, std::string - DEVICE_PROP_MBOARD, //ro, wax::obj - DEVICE_PROP_MBOARD_NAMES, //ro, prop_names_t - DEVICE_PROP_MAX_RX_SAMPLES, //ro, size_t - DEVICE_PROP_MAX_TX_SAMPLES //ro, size_t + DEVICE_PROP_NAME = 'n', //ro, std::string + DEVICE_PROP_MBOARD = 'm', //ro, wax::obj + DEVICE_PROP_MBOARD_NAMES = 'M', //ro, prop_names_t + DEVICE_PROP_MAX_RX_SAMPLES = 'r', //ro, size_t + DEVICE_PROP_MAX_TX_SAMPLES = 't' //ro, size_t }; //////////////////////////////////////////////////////////////////////// diff --git a/host/include/uhd/usrp/dsp_props.hpp b/host/include/uhd/usrp/dsp_props.hpp index ef3f771df..60c0df942 100644 --- a/host/include/uhd/usrp/dsp_props.hpp +++ b/host/include/uhd/usrp/dsp_props.hpp @@ -31,8 +31,8 @@ namespace uhd{ namespace usrp{ * and a property to get list of other possible properties. */ enum dsp_prop_t{ - DSP_PROP_NAME, //ro, std::string - DSP_PROP_OTHERS //ro, prop_names_t + DSP_PROP_NAME = 'n', //ro, std::string + DSP_PROP_OTHERS = 'o' //ro, prop_names_t }; }} //namespace diff --git a/host/include/uhd/usrp/mboard_props.hpp b/host/include/uhd/usrp/mboard_props.hpp index ddb95ef0d..cfc1f412e 100644 --- a/host/include/uhd/usrp/mboard_props.hpp +++ b/host/include/uhd/usrp/mboard_props.hpp @@ -29,20 +29,20 @@ namespace uhd{ namespace usrp{ * and discovered though the others property. */ enum mboard_prop_t{ - MBOARD_PROP_NAME, //ro, std::string - MBOARD_PROP_OTHERS, //ro, prop_names_t - MBOARD_PROP_CLOCK_RATE, //ro, double - MBOARD_PROP_RX_DSP, //ro, wax::obj - MBOARD_PROP_RX_DSP_NAMES, //ro, prop_names_t - MBOARD_PROP_TX_DSP, //ro, wax::obj - MBOARD_PROP_TX_DSP_NAMES, //ro, prop_names_t - MBOARD_PROP_RX_DBOARD, //ro, wax::obj - MBOARD_PROP_RX_DBOARD_NAMES, //ro, prop_names_t - MBOARD_PROP_TX_DBOARD, //ro, wax::obj - MBOARD_PROP_TX_DBOARD_NAMES, //ro, prop_names_t - MBOARD_PROP_CLOCK_CONFIG, //rw, clock_config_t - MBOARD_PROP_TIME_NOW, //wo, time_spec_t - MBOARD_PROP_TIME_NEXT_PPS //wo, time_spec_t + MBOARD_PROP_NAME = 'n', //ro, std::string + MBOARD_PROP_OTHERS = 'o', //ro, prop_names_t + MBOARD_PROP_CLOCK_RATE = 'c', //ro, double + MBOARD_PROP_RX_DSP = 'd', //ro, wax::obj + MBOARD_PROP_RX_DSP_NAMES = 'D', //ro, prop_names_t + MBOARD_PROP_TX_DSP = 'u', //ro, wax::obj + MBOARD_PROP_TX_DSP_NAMES = 'U', //ro, prop_names_t + MBOARD_PROP_RX_DBOARD = 'e', //ro, wax::obj + MBOARD_PROP_RX_DBOARD_NAMES = 'E', //ro, prop_names_t + MBOARD_PROP_TX_DBOARD = 'v', //ro, wax::obj + MBOARD_PROP_TX_DBOARD_NAMES = 'V', //ro, prop_names_t + MBOARD_PROP_CLOCK_CONFIG = 'C', //rw, clock_config_t + MBOARD_PROP_TIME_NOW = 't', //wo, time_spec_t + MBOARD_PROP_TIME_NEXT_PPS = 'T' //wo, time_spec_t }; }} //namespace diff --git a/host/include/uhd/usrp/simple_usrp.hpp b/host/include/uhd/usrp/simple_usrp.hpp index dea1cabda..2d6ad2a0f 100644 --- a/host/include/uhd/usrp/simple_usrp.hpp +++ b/host/include/uhd/usrp/simple_usrp.hpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -45,15 +46,13 @@ public: virtual std::string get_name(void) = 0; /******************************************************************* - * Timing + * Misc ******************************************************************/ virtual void set_time_now(const time_spec_t &time_spec) = 0; virtual void set_time_next_pps(const time_spec_t &time_spec) = 0; - - /******************************************************************* - * Streaming - ******************************************************************/ virtual void issue_stream_cmd(const stream_cmd_t &stream_cmd) = 0; + virtual void set_clock_config(const clock_config_t &clock_config) = 0; + virtual double get_clock_rate(void) = 0; /******************************************************************* * RX methods diff --git a/host/include/uhd/usrp/subdev_props.hpp b/host/include/uhd/usrp/subdev_props.hpp index 667f34f9c..92d18340b 100644 --- a/host/include/uhd/usrp/subdev_props.hpp +++ b/host/include/uhd/usrp/subdev_props.hpp @@ -26,20 +26,20 @@ namespace uhd{ namespace usrp{ * Possible device subdev properties */ enum subdev_prop_t{ - SUBDEV_PROP_NAME, //ro, std::string - SUBDEV_PROP_OTHERS, //ro, prop_names_t - SUBDEV_PROP_GAIN, //rw, float - SUBDEV_PROP_GAIN_RANGE, //ro, gain_range_t - SUBDEV_PROP_GAIN_NAMES, //ro, prop_names_t - SUBDEV_PROP_FREQ, //rw, double - SUBDEV_PROP_FREQ_RANGE, //ro, freq_range_t - SUBDEV_PROP_ANTENNA, //rw, std::string - SUBDEV_PROP_ANTENNA_NAMES, //ro, prop_names_t - SUBDEV_PROP_ENABLED, //rw, bool - SUBDEV_PROP_QUADRATURE, //ro, bool - SUBDEV_PROP_IQ_SWAPPED, //ro, bool - SUBDEV_PROP_SPECTRUM_INVERTED, //ro, bool - SUBDEV_PROP_LO_INTERFERES //ro, bool + SUBDEV_PROP_NAME = 'n', //ro, std::string + SUBDEV_PROP_OTHERS = 'o', //ro, prop_names_t + SUBDEV_PROP_GAIN = 'g', //rw, float + SUBDEV_PROP_GAIN_RANGE = 'r', //ro, gain_range_t + SUBDEV_PROP_GAIN_NAMES = 'G', //ro, prop_names_t + SUBDEV_PROP_FREQ = 'f', //rw, double + SUBDEV_PROP_FREQ_RANGE = 'F', //ro, freq_range_t + SUBDEV_PROP_ANTENNA = 'a', //rw, std::string + SUBDEV_PROP_ANTENNA_NAMES = 'A', //ro, prop_names_t + SUBDEV_PROP_ENABLED = 'e', //rw, bool + SUBDEV_PROP_QUADRATURE = 'q', //ro, bool + SUBDEV_PROP_IQ_SWAPPED = 'i', //ro, bool + SUBDEV_PROP_SPECTRUM_INVERTED = 's', //ro, bool + SUBDEV_PROP_LO_INTERFERES = 'l' //ro, bool //SUBDEV_PROP_RSSI, //ro, float //----> not on all boards, use named prop //SUBDEV_PROP_BANDWIDTH //rw, double //----> not on all boards, use named prop }; diff --git a/host/lib/usrp/simple_usrp.cpp b/host/lib/usrp/simple_usrp.cpp index 4bd47dc3f..a0551a630 100644 --- a/host/lib/usrp/simple_usrp.cpp +++ b/host/lib/usrp/simple_usrp.cpp @@ -75,7 +75,7 @@ public: } /******************************************************************* - * Timing + * Misc ******************************************************************/ void set_time_now(const time_spec_t &time_spec){ _mboard[MBOARD_PROP_TIME_NOW] = time_spec; @@ -85,13 +85,18 @@ public: _mboard[MBOARD_PROP_TIME_NEXT_PPS] = time_spec; } - /******************************************************************* - * Streaming - ******************************************************************/ void issue_stream_cmd(const stream_cmd_t &stream_cmd){ _rx_ddc[std::string("stream_cmd")] = stream_cmd; } + void set_clock_config(const clock_config_t &clock_config){ + _mboard[MBOARD_PROP_CLOCK_CONFIG] = clock_config; + } + + double get_clock_rate(void){ + return _mboard[MBOARD_PROP_CLOCK_RATE].as(); + } + /******************************************************************* * RX methods ******************************************************************/ @@ -138,7 +143,7 @@ public: } std::vector get_rx_antennas(void){ - return _rx_subdev[SUBDEV_PROP_ANTENNA_NAMES].as >(); + return _rx_subdev[SUBDEV_PROP_ANTENNA_NAMES].as(); } /******************************************************************* @@ -187,7 +192,7 @@ public: } std::vector get_tx_antennas(void){ - return _tx_subdev[SUBDEV_PROP_ANTENNA_NAMES].as >(); + return _tx_subdev[SUBDEV_PROP_ANTENNA_NAMES].as(); } private: -- cgit v1.2.3