diff options
Diffstat (limited to 'host/lib/usrp/usrp_e100')
| -rw-r--r-- | host/lib/usrp/usrp_e100/clock_ctrl.cpp | 12 | ||||
| -rw-r--r-- | host/lib/usrp/usrp_e100/codec_ctrl.cpp | 20 | ||||
| -rw-r--r-- | host/lib/usrp/usrp_e100/codec_impl.cpp | 2 | ||||
| -rw-r--r-- | host/lib/usrp/usrp_e100/dboard_iface.cpp | 8 | ||||
| -rw-r--r-- | host/lib/usrp/usrp_e100/dboard_impl.cpp | 2 | ||||
| -rw-r--r-- | host/lib/usrp/usrp_e100/dsp_impl.cpp | 14 | ||||
| -rw-r--r-- | host/lib/usrp/usrp_e100/fpga_downloader.cpp | 15 | ||||
| -rw-r--r-- | host/lib/usrp/usrp_e100/mboard_impl.cpp | 10 | ||||
| -rw-r--r-- | host/lib/usrp/usrp_e100/usrp_e100_iface.cpp | 16 | ||||
| -rw-r--r-- | host/lib/usrp/usrp_e100/usrp_e100_iface.hpp | 48 | ||||
| -rw-r--r-- | host/lib/usrp/usrp_e100/usrp_e100_impl.cpp | 8 | ||||
| -rw-r--r-- | host/lib/usrp/usrp_e100/usrp_e100_mmap_zero_copy.cpp | 2 | 
12 files changed, 60 insertions, 97 deletions
| diff --git a/host/lib/usrp/usrp_e100/clock_ctrl.cpp b/host/lib/usrp/usrp_e100/clock_ctrl.cpp index e29fe18ce..bb6fb7e3b 100644 --- a/host/lib/usrp/usrp_e100/clock_ctrl.cpp +++ b/host/lib/usrp/usrp_e100/clock_ctrl.cpp @@ -17,7 +17,7 @@  #include "clock_ctrl.hpp"  #include "ad9522_regs.hpp" -#include <uhd/utils/assert.hpp> +#include <uhd/utils/assert_has.hpp>  #include <boost/cstdint.hpp>  #include "usrp_e100_regs.hpp" //spi slave constants  #include <boost/assign/list_of.hpp> @@ -158,7 +158,7 @@ static clock_settings_type get_clock_settings(double rate){          }      } -    throw std::runtime_error(str(boost::format( +    throw uhd::value_error(str(boost::format(          "USRP-E100 clock control: could not calculate settings for clock rate %fMHz"      ) % (rate/1e6)));  } @@ -409,10 +409,10 @@ private:      void send_reg(boost::uint16_t addr){          boost::uint32_t reg = _ad9522_regs.get_write_reg(addr);          //std::cout << "clock control write reg: " << std::hex << reg << std::endl; -        _iface->transact_spi( +        _iface->write_spi(              UE_SPI_SS_AD9522,              spi_config_t::EDGE_RISE, -            reg, 24, false /*no rb*/ +            reg, 24          );      } @@ -427,9 +427,9 @@ private:          //wait for calibration done:          static const boost::uint8_t addr = 0x01F;          for (size_t ms10 = 0; ms10 < 100; ms10++){ -            boost::uint32_t reg = _iface->transact_spi( +            boost::uint32_t reg = _iface->read_spi(                  UE_SPI_SS_AD9522, spi_config_t::EDGE_RISE, -                _ad9522_regs.get_read_reg(addr), 24, true /*rb*/ +                _ad9522_regs.get_read_reg(addr), 24              );              _ad9522_regs.set_reg(addr, reg);              if (_ad9522_regs.vco_calibration_finished) return; diff --git a/host/lib/usrp/usrp_e100/codec_ctrl.cpp b/host/lib/usrp/usrp_e100/codec_ctrl.cpp index b33c8ae65..50442546a 100644 --- a/host/lib/usrp/usrp_e100/codec_ctrl.cpp +++ b/host/lib/usrp/usrp_e100/codec_ctrl.cpp @@ -18,7 +18,7 @@  #include "codec_ctrl.hpp"  #include "ad9862_regs.hpp"  #include <uhd/types/dict.hpp> -#include <uhd/utils/assert.hpp> +#include <uhd/exception.hpp>  #include <uhd/utils/algorithm.hpp>  #include <boost/cstdint.hpp>  #include <boost/tuple/tuple.hpp> @@ -137,7 +137,7 @@ static const int mtpgw = 255; //maximum tx pga gain word  void usrp_e100_codec_ctrl_impl::set_tx_pga_gain(double gain){      int gain_word = int(mtpgw*(gain - tx_pga_gain_range.start())/(tx_pga_gain_range.stop() - tx_pga_gain_range.start())); -    _ad9862_regs.tx_pga_gain = std::clip(gain_word, 0, mtpgw); +    _ad9862_regs.tx_pga_gain = uhd::clip(gain_word, 0, mtpgw);      this->send_reg(16);  } @@ -149,7 +149,7 @@ static const int mrpgw = 0x14; //maximum rx pga gain word  void usrp_e100_codec_ctrl_impl::set_rx_pga_gain(double gain, char which){      int gain_word = int(mrpgw*(gain - rx_pga_gain_range.start())/(rx_pga_gain_range.stop() - rx_pga_gain_range.start())); -    gain_word = std::clip(gain_word, 0, mrpgw); +    gain_word = uhd::clip(gain_word, 0, mrpgw);      switch(which){      case 'A':          _ad9862_regs.rx_pga_a = gain_word; @@ -227,7 +227,7 @@ double usrp_e100_codec_ctrl_impl::read_aux_adc(aux_adc_t which){      case AUX_ADC_B1: return aux_adc_to_volts(_ad9862_regs.aux_adc_b1_9_2, _ad9862_regs.aux_adc_b1_1_0);      case AUX_ADC_B2: return aux_adc_to_volts(_ad9862_regs.aux_adc_b2_9_2, _ad9862_regs.aux_adc_b2_1_0);      } -    UHD_ASSERT_THROW(false); +    UHD_THROW_INVALID_CODE_PATH();  }  /*********************************************************************** @@ -236,7 +236,7 @@ double usrp_e100_codec_ctrl_impl::read_aux_adc(aux_adc_t which){  void usrp_e100_codec_ctrl_impl::write_aux_dac(aux_dac_t which, double volts){      //special case for aux dac d (aka sigma delta word)      if (which == AUX_DAC_D){ -        boost::uint16_t dac_word = std::clip(boost::math::iround(volts*0xfff/3.3), 0, 0xfff); +        boost::uint16_t dac_word = uhd::clip(boost::math::iround(volts*0xfff/3.3), 0, 0xfff);          _ad9862_regs.sig_delt_11_4 = boost::uint8_t(dac_word >> 4);          _ad9862_regs.sig_delt_3_0 = boost::uint8_t(dac_word & 0xf);          this->send_reg(42); @@ -245,7 +245,7 @@ void usrp_e100_codec_ctrl_impl::write_aux_dac(aux_dac_t which, double volts){      }      //calculate the dac word for aux dac a, b, c -    boost::uint8_t dac_word = std::clip(boost::math::iround(volts*0xff/3.3), 0, 0xff); +    boost::uint8_t dac_word = uhd::clip(boost::math::iround(volts*0xff/3.3), 0, 0xff);      //setup a lookup table for the aux dac params (reg ref, reg addr)      typedef boost::tuple<boost::uint8_t*, boost::uint8_t> dac_params_t; @@ -269,20 +269,20 @@ void usrp_e100_codec_ctrl_impl::write_aux_dac(aux_dac_t which, double volts){  void usrp_e100_codec_ctrl_impl::send_reg(boost::uint8_t addr){      boost::uint32_t reg = _ad9862_regs.get_write_reg(addr);      if (codec_debug) std::cout << "codec control write reg: " << std::hex << reg << std::endl; -    _iface->transact_spi( +    _iface->write_spi(          UE_SPI_SS_AD9862,          spi_config_t::EDGE_RISE, -        reg, 16, false /*no rb*/ +        reg, 16      );  }  void usrp_e100_codec_ctrl_impl::recv_reg(boost::uint8_t addr){      boost::uint32_t reg = _ad9862_regs.get_read_reg(addr);      if (codec_debug) std::cout << "codec control read reg: " << std::hex << reg << std::endl; -    boost::uint32_t ret = _iface->transact_spi( +    boost::uint32_t ret = _iface->read_spi(          UE_SPI_SS_AD9862,          spi_config_t::EDGE_RISE, -        reg, 16, true /*rb*/ +        reg, 16      );      if (codec_debug) std::cout << "codec control read ret: " << std::hex << ret << std::endl;      _ad9862_regs.set_reg(addr, boost::uint16_t(ret)); diff --git a/host/lib/usrp/usrp_e100/codec_impl.cpp b/host/lib/usrp/usrp_e100/codec_impl.cpp index 0d91fb42c..ae198aaa5 100644 --- a/host/lib/usrp/usrp_e100/codec_impl.cpp +++ b/host/lib/usrp/usrp_e100/codec_impl.cpp @@ -16,7 +16,7 @@  //  #include "usrp_e100_impl.hpp" -#include <uhd/utils/assert.hpp> +#include <uhd/exception.hpp>  #include <uhd/usrp/codec_props.hpp>  #include <boost/bind.hpp> diff --git a/host/lib/usrp/usrp_e100/dboard_iface.cpp b/host/lib/usrp/usrp_e100/dboard_iface.cpp index e4c3856c9..4ee354486 100644 --- a/host/lib/usrp/usrp_e100/dboard_iface.cpp +++ b/host/lib/usrp/usrp_e100/dboard_iface.cpp @@ -21,7 +21,7 @@  #include "codec_ctrl.hpp"  #include <uhd/usrp/dboard_iface.hpp>  #include <uhd/types/dict.hpp> -#include <uhd/utils/assert.hpp> +#include <uhd/exception.hpp>  #include <boost/assign/list_of.hpp>  #include <linux/usrp_e.h> //i2c and spi constants @@ -235,7 +235,7 @@ static boost::uint32_t unit_to_otw_spi_dev(dboard_iface::unit_t unit){      case dboard_iface::UNIT_TX: return UE_SPI_SS_TX_DB;      case dboard_iface::UNIT_RX: return UE_SPI_SS_RX_DB;      } -    throw std::invalid_argument("unknown unit type"); +    UHD_THROW_INVALID_CODE_PATH();  }  void usrp_e100_dboard_iface::write_spi( @@ -244,7 +244,7 @@ void usrp_e100_dboard_iface::write_spi(      boost::uint32_t data,      size_t num_bits  ){ -    _iface->transact_spi(unit_to_otw_spi_dev(unit), config, data, num_bits, false /*no rb*/); +    _iface->write_spi(unit_to_otw_spi_dev(unit), config, data, num_bits);  }  boost::uint32_t usrp_e100_dboard_iface::read_write_spi( @@ -253,7 +253,7 @@ boost::uint32_t usrp_e100_dboard_iface::read_write_spi(      boost::uint32_t data,      size_t num_bits  ){ -    return _iface->transact_spi(unit_to_otw_spi_dev(unit), config, data, num_bits, true /*rb*/); +    return _iface->read_spi(unit_to_otw_spi_dev(unit), config, data, num_bits);  }  /*********************************************************************** diff --git a/host/lib/usrp/usrp_e100/dboard_impl.cpp b/host/lib/usrp/usrp_e100/dboard_impl.cpp index b533c2657..0b89fed9f 100644 --- a/host/lib/usrp/usrp_e100/dboard_impl.cpp +++ b/host/lib/usrp/usrp_e100/dboard_impl.cpp @@ -17,7 +17,7 @@  #include "usrp_e100_impl.hpp"  #include "usrp_e100_regs.hpp" -#include <uhd/utils/assert.hpp> +#include <uhd/exception.hpp>  #include <uhd/usrp/dboard_props.hpp>  #include <uhd/usrp/subdev_props.hpp>  #include <uhd/usrp/misc_utils.hpp> diff --git a/host/lib/usrp/usrp_e100/dsp_impl.cpp b/host/lib/usrp/usrp_e100/dsp_impl.cpp index 7d358a607..8d084f066 100644 --- a/host/lib/usrp/usrp_e100/dsp_impl.cpp +++ b/host/lib/usrp/usrp_e100/dsp_impl.cpp @@ -1,5 +1,5 @@  // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 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 @@ -60,10 +60,6 @@ void usrp_e100_impl::rx_ddc_get(const wax::obj &key_, wax::obj &val){          val = _ddc_freq;          return; -    case DSP_PROP_FREQ_SHIFT_NAMES: -        val = prop_names_t(1, ""); -        return; -      case DSP_PROP_CODEC_RATE:          val = _clock_ctrl->get_fpga_clock_rate();          return; @@ -84,6 +80,10 @@ void usrp_e100_impl::rx_ddc_set(const wax::obj &key_, const wax::obj &val){      switch(key.as<dsp_prop_t>()){ +    case DSP_PROP_STREAM_CMD: +        issue_stream_cmd(val.as<stream_cmd_t>()); +        return; +      case DSP_PROP_FREQ_SHIFT:{              double new_freq = val.as<double>();              _iface->poke32(UE_REG_DSP_RX_FREQ, @@ -143,10 +143,6 @@ void usrp_e100_impl::tx_duc_get(const wax::obj &key_, wax::obj &val){          val = _duc_freq;          return; -    case DSP_PROP_FREQ_SHIFT_NAMES: -        val = prop_names_t(1, ""); -        return; -      case DSP_PROP_CODEC_RATE:          val = _clock_ctrl->get_fpga_clock_rate();          return; diff --git a/host/lib/usrp/usrp_e100/fpga_downloader.cpp b/host/lib/usrp/usrp_e100/fpga_downloader.cpp index c0013fcbd..018a120d6 100644 --- a/host/lib/usrp/usrp_e100/fpga_downloader.cpp +++ b/host/lib/usrp/usrp_e100/fpga_downloader.cpp @@ -16,14 +16,21 @@  //  #include <uhd/config.hpp> -#include <uhd/utils/assert.hpp> +#ifdef UHD_DLL_EXPORTS +#include <uhd/exception.hpp> +#else //special case when this file is externally included +#include <stdexcept> +namespace uhd{ +    typedef std::runtime_error os_error; +    typedef std::runtime_error io_error; +} +#endif  #include <iostream>  #include <sstream>  #include <fstream>  #include <string>  #include <cstdlib> -#include <stdexcept>  #include <fcntl.h>  #include <sys/types.h> @@ -88,7 +95,7 @@ gpio::gpio(unsigned int gpio_num, gpio_direction pin_direction)  	std::fstream export_file;  	export_file.open("/sys/class/gpio/export", std::ios::out); -	if (not export_file.is_open()) throw std::runtime_error( +	if (not export_file.is_open()) throw uhd::os_error(  		"Failed to open gpio export file."  	); @@ -212,7 +219,7 @@ static void send_file_to_fpga(const std::string &file_name, gpio &error, gpio &d  	std::ifstream bitstream;  	bitstream.open(file_name.c_str(), std::ios::binary); -	if (!bitstream.is_open()) throw std::runtime_error( +	if (!bitstream.is_open()) throw uhd::os_error(  		"Coult not open the file: " + file_name  	); diff --git a/host/lib/usrp/usrp_e100/mboard_impl.cpp b/host/lib/usrp/usrp_e100/mboard_impl.cpp index 0e08cd435..cec4fd0ad 100644 --- a/host/lib/usrp/usrp_e100/mboard_impl.cpp +++ b/host/lib/usrp/usrp_e100/mboard_impl.cpp @@ -17,9 +17,9 @@  #include "usrp_e100_impl.hpp"  #include "usrp_e100_regs.hpp" +#include <uhd/exception.hpp>  #include <uhd/usrp/dsp_utils.hpp>  #include <uhd/usrp/misc_utils.hpp> -#include <uhd/utils/assert.hpp>  #include <uhd/usrp/mboard_props.hpp>  #include <boost/bind.hpp>  #include <iostream> @@ -53,7 +53,7 @@ void usrp_e100_impl::update_clock_config(void){      switch(_clock_config.pps_polarity){      case clock_config_t::PPS_POS: pps_flags |= UE_FLAG_TIME64_PPS_POSEDGE; break;      case clock_config_t::PPS_NEG: pps_flags |= UE_FLAG_TIME64_PPS_NEGEDGE; break; -    default: throw std::runtime_error("unhandled clock configuration pps polarity"); +    default: throw uhd::value_error("unhandled clock configuration pps polarity");      }      //set the pps flags @@ -64,7 +64,7 @@ void usrp_e100_impl::update_clock_config(void){      case clock_config_t::REF_AUTO: _clock_ctrl->use_auto_ref(); break;      case clock_config_t::REF_INT: _clock_ctrl->use_internal_ref(); break;      case clock_config_t::REF_SMA: _clock_ctrl->use_auto_ref(); break; -    default: throw std::runtime_error("unhandled clock configuration ref source"); +    default: throw uhd::value_error("unhandled clock configuration ref source");      }  } @@ -167,10 +167,6 @@ void usrp_e100_impl::mboard_set(const wax::obj &key, const wax::obj &val){      //handle the get request conditioned on the key      switch(key.as<mboard_prop_t>()){ -    case MBOARD_PROP_STREAM_CMD: -        issue_stream_cmd(val.as<stream_cmd_t>()); -        return; -      case MBOARD_PROP_TIME_NOW:      case MBOARD_PROP_TIME_PPS:{              time_spec_t time_spec = val.as<time_spec_t>(); diff --git a/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp b/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp index c13e880f3..45e57f301 100644 --- a/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp +++ b/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp @@ -17,7 +17,7 @@  #include "usrp_e100_iface.hpp"  #include "usrp_e100_regs.hpp" -#include <uhd/utils/assert.hpp> +#include <uhd/exception.hpp>  #include <sys/ioctl.h> //ioctl  #include <fcntl.h> //open, close  #include <linux/usrp_e.h> //ioctl structures and constants @@ -37,7 +37,7 @@ class i2c_dev_iface : public i2c_iface{  public:      i2c_dev_iface(const std::string &node){          if ((_node_fd = ::open(node.c_str(), O_RDWR)) < 0){ -            throw std::runtime_error("Failed to open " + node); +            throw uhd::io_error("Failed to open " + node);          }      } @@ -106,7 +106,7 @@ public:      {          //open the device node and check file descriptor          if ((_node_fd = ::open(node.c_str(), O_RDWR)) < 0){ -            throw std::runtime_error("Failed to open " + node); +            throw uhd::io_error("Failed to open " + node);          }          //very first thing, reset all the wishbone, always do first! @@ -127,7 +127,7 @@ public:          boost::mutex::scoped_lock lock(_ctrl_mutex);          if (::ioctl(_node_fd, request, mem) < 0){ -            throw std::runtime_error(str( +            throw uhd::os_error(str(                  boost::format("ioctl failed with request %d") % request              ));          } @@ -257,6 +257,14 @@ public:          //unload the data          return data.data;      } +     +    void write_uart(boost::uint8_t, const std::string &) { +        throw uhd::not_implemented_error("Unhandled command write_uart()"); +    } +     +    std::string read_uart(boost::uint8_t) { +        throw uhd::not_implemented_error("Unhandled command read_uart()"); +    }  private:      int _node_fd; diff --git a/host/lib/usrp/usrp_e100/usrp_e100_iface.hpp b/host/lib/usrp/usrp_e100/usrp_e100_iface.hpp index 12283fb52..cb0ca2dd4 100644 --- a/host/lib/usrp/usrp_e100/usrp_e100_iface.hpp +++ b/host/lib/usrp/usrp_e100/usrp_e100_iface.hpp @@ -24,6 +24,7 @@  #include <boost/shared_ptr.hpp>  #include <boost/utility.hpp>  #include <boost/cstdint.hpp> +#include <uhd/usrp/mboard_iface.hpp>  ////////////////////////////////////////////////////////////////////////  // I2C addresses @@ -39,7 +40,7 @@   * Provides a set of functions to implementation layer.   * Including spi, peek, poke, control...   */ -class usrp_e100_iface : boost::noncopyable, public uhd::i2c_iface{ +class usrp_e100_iface : boost::noncopyable, public uhd::usrp::mboard_iface{  public:      typedef boost::shared_ptr<usrp_e100_iface> sptr; @@ -67,51 +68,6 @@ public:      //! Get the I2C interface for the I2C device node      virtual uhd::i2c_iface &get_i2c_dev_iface(void) = 0; -    /*! -     * Write a register (32 bits) -     * \param addr the address -     * \param data the 32bit data -     */ -    virtual void poke32(boost::uint32_t addr, boost::uint32_t data) = 0; - -    /*! -     * Read a register (32 bits) -     * \param addr the address -     * \return the 32bit data -     */ -    virtual boost::uint32_t peek32(boost::uint32_t addr) = 0; - -    /*! -     * Write a register (16 bits) -     * \param addr the address -     * \param data the 16bit data -     */ -    virtual void poke16(boost::uint32_t addr, boost::uint16_t data) = 0; - -    /*! -     * Read a register (16 bits) -     * \param addr the address -     * \return the 16bit data -     */ -    virtual boost::uint16_t peek16(boost::uint32_t addr) = 0; - -    /*! -     * Perform an spi transaction. -     * \param which_slave the slave device number -     * \param config spi config args -     * \param data the bits to write -     * \param num_bits how many bits in data -     * \param readback true to readback a value -     * \return spi data if readback set -     */ -    virtual boost::uint32_t transact_spi( -        int which_slave, -        const uhd::spi_config_t &config, -        boost::uint32_t data, -        size_t num_bits, -        bool readback -    ) = 0; -      //motherboard eeprom map structure      uhd::usrp::mboard_eeprom_t mb_eeprom;  }; diff --git a/host/lib/usrp/usrp_e100/usrp_e100_impl.cpp b/host/lib/usrp/usrp_e100/usrp_e100_impl.cpp index 40ea56466..1385688e0 100644 --- a/host/lib/usrp/usrp_e100/usrp_e100_impl.cpp +++ b/host/lib/usrp/usrp_e100/usrp_e100_impl.cpp @@ -1,5 +1,5 @@  // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 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 @@ -19,7 +19,7 @@  #include "usrp_e100_regs.hpp"  #include <uhd/usrp/device_props.hpp>  #include <uhd/usrp/mboard_props.hpp> -#include <uhd/utils/assert.hpp> +#include <uhd/exception.hpp>  #include <uhd/utils/static.hpp>  #include <uhd/utils/images.hpp>  #include <uhd/utils/warning.hpp> @@ -103,7 +103,7 @@ static device::sptr usrp_e100_make(const device_addr_t &device_addr){      size_t fpga_hash = 0;      {          std::ifstream file(usrp_e100_fpga_image.c_str()); -        if (not file.good()) throw std::runtime_error( +        if (not file.good()) throw uhd::io_error(              "cannot open fpga file for read: " + usrp_e100_fpga_image          );          do{ @@ -132,7 +132,7 @@ static device::sptr usrp_e100_make(const device_addr_t &device_addr){      //check that the compatibility is correct      fpga_compat_num = iface->peek16(UE_REG_MISC_COMPAT);      if (fpga_compat_num != USRP_E_COMPAT_NUM){ -        throw std::runtime_error(str(boost::format( +        throw uhd::runtime_error(str(boost::format(              "Expected fpga compatibility number 0x%x, but got 0x%x:\n"              "The fpga build is not compatible with the host code build."          ) % USRP_E_COMPAT_NUM % fpga_compat_num)); diff --git a/host/lib/usrp/usrp_e100/usrp_e100_mmap_zero_copy.cpp b/host/lib/usrp/usrp_e100/usrp_e100_mmap_zero_copy.cpp index c155d426a..f4274dc5a 100644 --- a/host/lib/usrp/usrp_e100/usrp_e100_mmap_zero_copy.cpp +++ b/host/lib/usrp/usrp_e100/usrp_e100_mmap_zero_copy.cpp @@ -17,7 +17,7 @@  #include "usrp_e100_iface.hpp"  #include <uhd/transport/zero_copy.hpp> -#include <uhd/utils/assert.hpp> +#include <uhd/exception.hpp>  #include <linux/usrp_e.h>  #include <sys/mman.h> //mmap  #include <unistd.h> //getpagesize | 
