diff options
| author | Josh Blum <josh@joshknows.com> | 2010-05-07 21:51:06 +0000 | 
|---|---|---|
| committer | Josh Blum <josh@joshknows.com> | 2010-05-07 21:51:06 +0000 | 
| commit | 6ef09d18def4afdd6413188ab63ee38dbae4e9d8 (patch) | |
| tree | 65be5da1250e41fcaf34c419605506e68c0e87f5 | |
| parent | ac17bb0e8a3049944adde0aa5cbdcfb2ea711794 (diff) | |
| download | uhd-6ef09d18def4afdd6413188ab63ee38dbae4e9d8.tar.gz uhd-6ef09d18def4afdd6413188ab63ee38dbae4e9d8.tar.bz2 uhd-6ef09d18def4afdd6413188ab63ee38dbae4e9d8.zip | |
filled in dboard interface with codec and clock control
| -rw-r--r-- | host/lib/usrp/usrp_e/clock_ctrl.cpp | 4 | ||||
| -rw-r--r-- | host/lib/usrp/usrp_e/clock_ctrl.hpp | 18 | ||||
| -rw-r--r-- | host/lib/usrp/usrp_e/dboard_iface.cpp | 88 | ||||
| -rw-r--r-- | host/lib/usrp/usrp_e/dboard_impl.cpp | 6 | ||||
| -rw-r--r-- | host/lib/usrp/usrp_e/usrp_e_impl.cpp | 2 | ||||
| -rw-r--r-- | host/lib/usrp/usrp_e/usrp_e_impl.hpp | 8 | 
6 files changed, 95 insertions, 31 deletions
| diff --git a/host/lib/usrp/usrp_e/clock_ctrl.cpp b/host/lib/usrp/usrp_e/clock_ctrl.cpp index 9c2ddf670..5f7269412 100644 --- a/host/lib/usrp/usrp_e/clock_ctrl.cpp +++ b/host/lib/usrp/usrp_e/clock_ctrl.cpp @@ -38,6 +38,10 @@ public:      void enable_rx_dboard_clock(bool enb);      void enable_tx_dboard_clock(bool enb); +    double get_fpga_clock_rate(void){return 64e6;} +    double get_rx_dboard_clock_rate(void){return get_fpga_clock_rate();} +    double get_tx_dboard_clock_rate(void){return get_fpga_clock_rate();} +  private:      usrp_e_iface::sptr _iface;      ad9522_regs_t _ad9522_regs; diff --git a/host/lib/usrp/usrp_e/clock_ctrl.hpp b/host/lib/usrp/usrp_e/clock_ctrl.hpp index d0b896a8f..994b83564 100644 --- a/host/lib/usrp/usrp_e/clock_ctrl.hpp +++ b/host/lib/usrp/usrp_e/clock_ctrl.hpp @@ -39,6 +39,24 @@ public:      static sptr make(usrp_e_iface::sptr iface);      /*! +     * Get the rate of the fpga clock line. +     * \return the fpga clock rate in Hz +     */ +    virtual double get_fpga_clock_rate(void) = 0; + +    /*! +     * Get the rate of the dboard clock clock line. +     * \return the dboard clock rate in Hz +     */ +    virtual double get_rx_dboard_clock_rate(void) = 0; + +    /*! +     * Get the rate of the dboard clock clock line. +     * \return the dboard clock rate in Hz +     */ +    virtual double get_tx_dboard_clock_rate(void) = 0; + +    /*!       * Enable/disable the rx dboard clock.       * \param enb true to enable       */ diff --git a/host/lib/usrp/usrp_e/dboard_iface.cpp b/host/lib/usrp/usrp_e/dboard_iface.cpp index 2a3976ba1..e70934b8c 100644 --- a/host/lib/usrp/usrp_e/dboard_iface.cpp +++ b/host/lib/usrp/usrp_e/dboard_iface.cpp @@ -17,6 +17,8 @@  #include "usrp_e_iface.hpp"  #include "usrp_e_regs.hpp" +#include "clock_ctrl.hpp" +#include "codec_ctrl.hpp"  #include <uhd/usrp/dboard_iface.hpp>  #include <uhd/types/dict.hpp>  #include <uhd/utils/assert.hpp> @@ -25,11 +27,24 @@  using namespace uhd;  using namespace uhd::usrp; +using namespace boost::assign;  class usrp_e_dboard_iface : public dboard_iface{  public: -    usrp_e_dboard_iface(usrp_e_iface::sptr iface); -    ~usrp_e_dboard_iface(void); + +    usrp_e_dboard_iface( +        usrp_e_iface::sptr iface, +        clock_ctrl::sptr clock, +        codec_ctrl::sptr codec +    ){ +        _iface = iface; +        _clock = clock; +        _codec = codec; +    } + +    ~usrp_e_dboard_iface(void){ +        /* NOP */ +    }      void write_aux_dac(unit_t, int, float);      float read_aux_adc(unit_t, int); @@ -60,35 +75,37 @@ public:  private:      usrp_e_iface::sptr _iface; +    clock_ctrl::sptr _clock; +    codec_ctrl::sptr _codec;  };  /***********************************************************************   * Make Function   **********************************************************************/ -dboard_iface::sptr make_usrp_e_dboard_iface(usrp_e_iface::sptr iface){ -    return dboard_iface::sptr(new usrp_e_dboard_iface(iface)); -} - -/*********************************************************************** - * Structors - **********************************************************************/ -usrp_e_dboard_iface::usrp_e_dboard_iface(usrp_e_iface::sptr iface){ -    _iface = iface; -} - -usrp_e_dboard_iface::~usrp_e_dboard_iface(void){ -    /* NOP */ +dboard_iface::sptr make_usrp_e_dboard_iface( +    usrp_e_iface::sptr iface, +    clock_ctrl::sptr clock, +    codec_ctrl::sptr codec +){ +    return dboard_iface::sptr(new usrp_e_dboard_iface(iface, clock, codec));  }  /***********************************************************************   * Clock Rates   **********************************************************************/ -double usrp_e_dboard_iface::get_clock_rate(unit_t){ -    throw std::runtime_error("not implemented"); +double usrp_e_dboard_iface::get_clock_rate(unit_t unit){ +    switch(unit){ +    case UNIT_RX: return _clock->get_rx_dboard_clock_rate(); +    case UNIT_TX: return _clock->get_tx_dboard_clock_rate(); +    } +    UHD_ASSERT_THROW(false);  } -void usrp_e_dboard_iface::set_clock_enabled(unit_t, bool){ -    throw std::runtime_error("not implemented"); +void usrp_e_dboard_iface::set_clock_enabled(unit_t unit, bool enb){ +    switch(unit){ +    case UNIT_RX: return _clock->enable_rx_dboard_clock(enb); +    case UNIT_TX: return _clock->enable_tx_dboard_clock(enb); +    }  }  /*********************************************************************** @@ -96,7 +113,7 @@ void usrp_e_dboard_iface::set_clock_enabled(unit_t, bool){   **********************************************************************/  void usrp_e_dboard_iface::set_gpio_ddr(unit_t bank, boost::uint16_t value){      //define mapping of gpio bank to register address -    static const uhd::dict<unit_t, boost::uint32_t> bank_to_addr = boost::assign::map_list_of +    static const uhd::dict<unit_t, boost::uint32_t> bank_to_addr = map_list_of          (UNIT_RX, UE_REG_GPIO_RX_DDR)          (UNIT_TX, UE_REG_GPIO_TX_DDR)      ; @@ -105,7 +122,7 @@ void usrp_e_dboard_iface::set_gpio_ddr(unit_t bank, boost::uint16_t value){  boost::uint16_t usrp_e_dboard_iface::read_gpio(unit_t bank){      //define mapping of gpio bank to register address -    static const uhd::dict<unit_t, boost::uint32_t> bank_to_addr = boost::assign::map_list_of +    static const uhd::dict<unit_t, boost::uint32_t> bank_to_addr = map_list_of          (UNIT_RX, UE_REG_GPIO_RX_IO)          (UNIT_TX, UE_REG_GPIO_TX_IO)      ; @@ -116,14 +133,14 @@ void usrp_e_dboard_iface::set_atr_reg(unit_t bank, atr_reg_t atr, boost::uint16_      //define mapping of bank to atr regs to register address      static const uhd::dict<          unit_t, uhd::dict<atr_reg_t, boost::uint32_t> -    > bank_to_atr_to_addr = boost::assign::map_list_of -        (UNIT_RX, boost::assign::map_list_of +    > bank_to_atr_to_addr = map_list_of +        (UNIT_RX, map_list_of              (ATR_REG_IDLE,        UE_REG_ATR_IDLE_RXSIDE)              (ATR_REG_TX_ONLY,     UE_REG_ATR_INTX_RXSIDE)              (ATR_REG_RX_ONLY,     UE_REG_ATR_INRX_RXSIDE)              (ATR_REG_FULL_DUPLEX, UE_REG_ATR_FULL_RXSIDE)          ) -        (UNIT_TX, boost::assign::map_list_of +        (UNIT_TX, map_list_of              (ATR_REG_IDLE,        UE_REG_ATR_IDLE_TXSIDE)              (ATR_REG_TX_ONLY,     UE_REG_ATR_INTX_TXSIDE)              (ATR_REG_RX_ONLY,     UE_REG_ATR_INRX_TXSIDE) @@ -181,10 +198,27 @@ byte_vector_t usrp_e_dboard_iface::read_i2c(boost::uint8_t addr, size_t num_byte  /***********************************************************************   * Aux DAX/ADC   **********************************************************************/ -void usrp_e_dboard_iface::write_aux_dac(dboard_iface::unit_t unit, int which, float value){ -    throw std::runtime_error("not implemented"); +void usrp_e_dboard_iface::write_aux_dac(dboard_iface::unit_t, int which, float value){ +    //same aux dacs for each unit +    static const uhd::dict<int, codec_ctrl::aux_dac_t> which_to_aux_dac = map_list_of +        (0, codec_ctrl::AUX_DAC_A) (1, codec_ctrl::AUX_DAC_B) +        (2, codec_ctrl::AUX_DAC_C) (3, codec_ctrl::AUX_DAC_D) +    ; +    _codec->write_aux_dac(which_to_aux_dac[which], value);  }  float usrp_e_dboard_iface::read_aux_adc(dboard_iface::unit_t unit, int which){ -    throw std::runtime_error("not implemented"); +    static const uhd::dict< +        unit_t, uhd::dict<int, codec_ctrl::aux_adc_t> +    > unit_to_which_to_aux_adc = map_list_of +        (UNIT_RX, map_list_of +            (0, codec_ctrl::AUX_ADC_A1) +            (1, codec_ctrl::AUX_ADC_B1) +        ) +        (UNIT_TX, map_list_of +            (0, codec_ctrl::AUX_ADC_A2) +            (1, codec_ctrl::AUX_ADC_B2) +        ) +    ; +    return _codec->read_aux_adc(unit_to_which_to_aux_adc[unit][which]);  } diff --git a/host/lib/usrp/usrp_e/dboard_impl.cpp b/host/lib/usrp/usrp_e/dboard_impl.cpp index 00b5d77d7..31f792306 100644 --- a/host/lib/usrp/usrp_e/dboard_impl.cpp +++ b/host/lib/usrp/usrp_e/dboard_impl.cpp @@ -17,6 +17,7 @@  #include <boost/bind.hpp>  #include "usrp_e_impl.hpp" +#include <iostream>  using namespace uhd::usrp; @@ -27,9 +28,12 @@ void usrp_e_impl::dboard_init(void){      _rx_db_eeprom = dboard_eeprom_t(_iface->read_eeprom(I2C_ADDR_RX_DB, 0, dboard_eeprom_t::num_bytes()));      _tx_db_eeprom = dboard_eeprom_t(_iface->read_eeprom(I2C_ADDR_TX_DB, 0, dboard_eeprom_t::num_bytes())); +    std::cout << _rx_db_eeprom.id.to_pp_string() << std::endl; +    std::cout << _tx_db_eeprom.id.to_pp_string() << std::endl; +      //create a new dboard interface and manager      dboard_iface::sptr dboard_iface( -        make_usrp_e_dboard_iface(_iface) +        make_usrp_e_dboard_iface(_iface, _clock_ctrl, _codec_ctrl)      );      _dboard_manager = dboard_manager::make(          _rx_db_eeprom.id, _tx_db_eeprom.id, dboard_iface diff --git a/host/lib/usrp/usrp_e/usrp_e_impl.cpp b/host/lib/usrp/usrp_e/usrp_e_impl.cpp index b6fed6a74..5861be102 100644 --- a/host/lib/usrp/usrp_e/usrp_e_impl.cpp +++ b/host/lib/usrp/usrp_e/usrp_e_impl.cpp @@ -83,8 +83,6 @@ usrp_e_impl::usrp_e_impl(const std::string &node){          ));      } -    sleep(1); //FIXME sleep here until the kernel driver stops hanging -      //setup various interfaces into hardware      _iface = usrp_e_iface::make(_node_fd);      _clock_ctrl = clock_ctrl::make(_iface); diff --git a/host/lib/usrp/usrp_e/usrp_e_impl.hpp b/host/lib/usrp/usrp_e/usrp_e_impl.hpp index 6746e012a..bde0f87c3 100644 --- a/host/lib/usrp/usrp_e/usrp_e_impl.hpp +++ b/host/lib/usrp/usrp_e/usrp_e_impl.hpp @@ -29,9 +29,15 @@  /*!   * Make a usrp-e dboard interface.   * \param iface the usrp-e interface object + * \param clock the clock control interface + * \param codec the codec control interface   * \return a sptr to a new dboard interface   */ -uhd::usrp::dboard_iface::sptr make_usrp_e_dboard_iface(usrp_e_iface::sptr iface); +uhd::usrp::dboard_iface::sptr make_usrp_e_dboard_iface( +    usrp_e_iface::sptr iface, +    clock_ctrl::sptr clock, +    codec_ctrl::sptr codec +);  /*!   * Simple wax obj proxy class: | 
