UHD
003.004.005-release
|
00001 // 00002 // Copyright 2010-2011 Ettus Research LLC 00003 // 00004 // This program is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 // 00017 00018 #ifndef INCLUDED_UHD_USRP_DBOARD_IFACE_HPP 00019 #define INCLUDED_UHD_USRP_DBOARD_IFACE_HPP 00020 00021 #include <uhd/config.hpp> 00022 #include <uhd/utils/pimpl.hpp> 00023 #include <uhd/types/serial.hpp> 00024 #include <boost/shared_ptr.hpp> 00025 #include <boost/cstdint.hpp> 00026 #include <string> 00027 #include <vector> 00028 00029 namespace uhd{ namespace usrp{ 00030 00032 struct UHD_API dboard_iface_special_props_t{ 00039 bool soft_clock_divider; 00040 00049 bool mangle_i2c_addrs; 00050 }; 00051 00058 class UHD_API dboard_iface : public uhd::i2c_iface{ 00059 public: 00060 typedef boost::shared_ptr<dboard_iface> sptr; 00061 typedef dboard_iface_special_props_t special_props_t; 00062 00064 enum unit_t{ 00065 UNIT_RX = int('r'), 00066 UNIT_TX = int('t') 00067 }; 00068 00070 enum atr_reg_t{ 00071 ATR_REG_IDLE = int('i'), 00072 ATR_REG_TX_ONLY = int('t'), 00073 ATR_REG_RX_ONLY = int('r'), 00074 ATR_REG_FULL_DUPLEX = int('f') 00075 }; 00076 00078 enum aux_dac_t{ 00079 AUX_DAC_A = int('a'), 00080 AUX_DAC_B = int('b'), 00081 AUX_DAC_C = int('c'), 00082 AUX_DAC_D = int('d') 00083 }; 00084 00086 enum aux_adc_t{ 00087 AUX_ADC_A = int('a'), 00088 AUX_ADC_B = int('b') 00089 }; 00090 00097 virtual special_props_t get_special_props(void) = 0; 00098 00106 virtual void write_aux_dac(unit_t unit, aux_dac_t which_dac, double value) = 0; 00107 00115 virtual double read_aux_adc(unit_t unit, aux_adc_t which_adc) = 0; 00116 00124 virtual void set_pin_ctrl( 00125 unit_t unit, boost::uint16_t value, boost::uint16_t mask = 0xffff 00126 ); 00127 00134 virtual boost::uint16_t get_pin_ctrl(unit_t unit); 00135 00144 virtual void set_atr_reg( 00145 unit_t unit, atr_reg_t reg, boost::uint16_t value, boost::uint16_t mask = 0xffff 00146 ); 00147 00155 virtual boost::uint16_t get_atr_reg(unit_t unit, atr_reg_t reg); 00156 00164 virtual void set_gpio_ddr( 00165 unit_t unit, boost::uint16_t value, boost::uint16_t mask = 0xffff 00166 ); 00167 00174 virtual boost::uint16_t get_gpio_ddr(unit_t unit); 00175 00183 virtual void set_gpio_out( 00184 unit_t unit, boost::uint16_t value, boost::uint16_t mask = 0xffff 00185 ); 00186 00193 virtual boost::uint16_t get_gpio_out(unit_t unit); 00194 00201 virtual void set_gpio_debug(unit_t unit, int which) = 0; 00202 00209 virtual boost::uint16_t read_gpio(unit_t unit) = 0; 00210 00219 virtual void write_spi( 00220 unit_t unit, 00221 const spi_config_t &config, 00222 boost::uint32_t data, 00223 size_t num_bits 00224 ) = 0; 00225 00235 virtual boost::uint32_t read_write_spi( 00236 unit_t unit, 00237 const spi_config_t &config, 00238 boost::uint32_t data, 00239 size_t num_bits 00240 ) = 0; 00241 00248 virtual void set_clock_rate(unit_t unit, double rate) = 0; 00249 00256 virtual double get_clock_rate(unit_t unit) = 0; 00257 00264 virtual std::vector<double> get_clock_rates(unit_t unit) = 0; 00265 00272 virtual void set_clock_enabled(unit_t unit, bool enb) = 0; 00273 00281 virtual double get_codec_rate(unit_t unit) = 0; 00282 00283 private: 00284 UHD_PIMPL_DECL(impl) _impl; 00285 00286 virtual void _set_pin_ctrl(unit_t unit, boost::uint16_t value) = 0; 00287 virtual void _set_atr_reg(unit_t unit, atr_reg_t reg, boost::uint16_t value) = 0; 00288 virtual void _set_gpio_ddr(unit_t unit, boost::uint16_t value) = 0; 00289 virtual void _set_gpio_out(unit_t unit, boost::uint16_t value) = 0; 00290 00291 protected: 00292 dboard_iface(void); 00293 00294 }; 00295 00296 }} //namespace 00297 00298 #endif /* INCLUDED_UHD_USRP_DBOARD_IFACE_HPP */