子板接口类

简介:

射频子板由母板通过“子板接口类”进行管理。“子板接口类”继承自i2c:

/*!
 * The daughter board dboard interface to be subclassed.
 * A dboard instance interfaces with the mboard though this api.
 * This interface provides i2c, spi, gpio, atr, aux dac/adc access.
 * Each mboard should have a specially tailored iface for its dboard.
 */
class UHD_API dboard_iface : public uhd::i2c_iface{
public:
    typedef boost::shared_ptr<dboard_iface> sptr;
    typedef dboard_iface_special_props_t special_props_t;

    //! tells the host which unit to use
    enum unit_t{
        UNIT_RX = int('r'),
        UNIT_TX = int('t')
    };

    //! possible atr registers
    enum atr_reg_t{
        ATR_REG_IDLE        = int('i'),
        ATR_REG_TX_ONLY     = int('t'),
        ATR_REG_RX_ONLY     = int('r'),
        ATR_REG_FULL_DUPLEX = int('f')
    };

    //! aux dac selection enums (per unit)
    enum aux_dac_t{
        AUX_DAC_A = int('a'),
        AUX_DAC_B = int('b'),
        AUX_DAC_C = int('c'),
        AUX_DAC_D = int('d')
    };

    //! aux adc selection enums (per unit)
    enum aux_adc_t{
        AUX_ADC_A = int('a'),
        AUX_ADC_B = int('b')
    };

    /*!
     * Get special properties information for this dboard slot.
     * This call helps the dboard code to handle implementation
     * differences between different motherboards and dboard slots.
     * \return the special properties struct
     */
    virtual special_props_t get_special_props(void) = 0;

    /*!
     * Write to an aux dac.
     *
     * \param unit which unit rx or tx
     * \param which_dac the dac index 0, 1, 2, 3...
     * \param value the value in volts
     */
    virtual void write_aux_dac(unit_t unit, aux_dac_t which_dac, double value) = 0;

    /*!
     * Read from an aux adc.
     *
     * \param unit which unit rx or tx
     * \param which_adc the adc index 0, 1, 2, 3...
     * \return the value in volts
     */
    virtual double read_aux_adc(unit_t unit, aux_adc_t which_adc) = 0;

    /*!
     * Set a daughterboard output pin control source.
     *
     * \param unit which unit rx or tx
     * \param value 16-bits, 0=GPIO controlled, 1=ATR controlled
     * \param mask 16-bits, 0=do not change, 1=change value
     */
    virtual void set_pin_ctrl(
        unit_t unit, boost::uint16_t value, boost::uint16_t mask = 0xffff
    );

    /*!
     * Read back the pin control setting.
     *
     * \param unit which unit rx or tx
     * \return the 16-bit settings value
     */
    virtual boost::uint16_t get_pin_ctrl(unit_t unit);

    /*!
     * Set a daughterboard ATR register.
     *
     * \param unit which unit rx or tx
     * \param reg which ATR register
     * \param value 16-bits, 0=ATR output low, 1=ATR output high
     * \param mask 16-bits, 0=do not change, 1=change value
     */
    virtual void set_atr_reg(
        unit_t unit, atr_reg_t reg, boost::uint16_t value, boost::uint16_t mask = 0xffff
    );

    /*!
     * Read back an ATR register setting.
     *
     * \param unit which unit rx or tx
     * \param reg which ATR register
     * \return the 16-bit settings value
     */
    virtual boost::uint16_t get_atr_reg(unit_t unit, atr_reg_t reg);

    /*!
     * Set daughterboard GPIO data direction setting.
     *
     * \param unit which unit rx or tx
     * \param value 16-bits, 0=GPIO input, 1=GPIO output
     * \param mask 16-bits, 0=do not change, 1=change value
     */
    virtual void set_gpio_ddr(
        unit_t unit, boost::uint16_t value, boost::uint16_t mask = 0xffff
    );

    /*!
     * Read back the GPIO data direction setting.
     *
     * \param unit which unit rx or tx
     * \return the 16-bit settings value
     */
    virtual boost::uint16_t get_gpio_ddr(unit_t unit);

    /*!
     * Set daughterboard GPIO pin output setting.
     *
     * \param unit which unit rx or tx
     * \param value 16-bits, 0=GPIO output low, 1=GPIO output high
     * \param mask 16-bits, 0=do not change, 1=change value
     */
    virtual void set_gpio_out(
        unit_t unit, boost::uint16_t value, boost::uint16_t mask = 0xffff
    );

    /*!
     * Read back the GPIO pin output setting.
     *
     * \param unit which unit rx or tx
     * \return the 16-bit settings value
     */
    virtual boost::uint16_t get_gpio_out(unit_t unit);

    /*!
     * Setup the GPIO debug mux.
     *
     * \param unit which unit rx or tx
     * \param which which debug: 0, 1
     */
    virtual void set_gpio_debug(unit_t unit, int which) = 0;

    /*!
     * Read daughterboard GPIO pin values.
     *
     * \param unit which unit rx or tx
     * \return the value of the gpio unit
     */
    virtual boost::uint16_t read_gpio(unit_t unit) = 0;

    /*!
     * Write data to SPI bus peripheral.
     *
     * \param unit which unit, rx or tx
     * \param config configuration settings
     * \param data the bits to write MSB first
     * \param num_bits the number of bits in data
     */
    virtual void write_spi(
        unit_t unit,
        const spi_config_t &config,
        boost::uint32_t data,
        size_t num_bits
    ) = 0;

    /*!
     * Read and write data to SPI bus peripheral.
     *
     * \param unit which unit, rx or tx
     * \param config configuration settings
     * \param data the bits to write MSB first
     * \param num_bits the number of bits in data
     * \return the data that was read
     */
    virtual boost::uint32_t read_write_spi(
        unit_t unit,
        const spi_config_t &config,
        boost::uint32_t data,
        size_t num_bits
    ) = 0;

    /*!
     * Set the rate of a dboard clock.
     *
     * \param unit which unit rx or tx
     * \param rate the clock rate in Hz
     */
    virtual void set_clock_rate(unit_t unit, double rate) = 0;

    /*!
     * Get the rate of a dboard clock.
     *
     * \param unit which unit rx or tx
     * \return the clock rate in Hz
     */
    virtual double get_clock_rate(unit_t unit) = 0;

    /*!
     * Get a list of possible rates for the dboard clock.
     *
     * \param unit which unit rx or tx
     * \return a list of clock rates in Hz
     */
    virtual std::vector<double> get_clock_rates(unit_t unit) = 0;

    /*!
     * Enable or disable a dboard clock.
     *
     * \param unit which unit rx or tx
     * \param enb true for enabled
     */
    virtual void set_clock_enabled(unit_t unit, bool enb) = 0;

    /*!
     * Get the rate of the codec.
     * For rx, this is the rate the ADC feeds the DSP.
     * For tx, this is the rate the DSP feeds the DAC.
     * \param unit which unit rx or tx
     * \return the codec rate in Hz
     */
    virtual double get_codec_rate(unit_t unit) = 0;

private:
    UHD_PIMPL_DECL(impl) _impl;

    virtual void _set_pin_ctrl(unit_t unit, boost::uint16_t value) = 0;
    virtual void _set_atr_reg(unit_t unit, atr_reg_t reg, boost::uint16_t value) = 0;
    virtual void _set_gpio_ddr(unit_t unit, boost::uint16_t value) = 0;
    virtual void _set_gpio_out(unit_t unit, boost::uint16_t value) = 0;

protected:
    dboard_iface(void);
public:
    virtual ~dboard_iface(void);

};

当进行管理时,先定义通过属性树到达射频板的子板接口变量(子板接口对象),然后即可调用上述子板接口类提供的各种方法。比如:

dboard_iface::sptr iface = _tree->access<dboard_iface::sptr>(mb_root(mboard) / "dboards" / name / "iface").get();//定义接口变量
            if (attr == "CTRL") return iface->get_pin_ctrl(unit);//通过接口变量调用方法
            if (attr == "DDR") return iface->get_gpio_ddr(unit);
            if (attr == "OUT") return iface->get_gpio_out(unit);
            if (attr == "ATR_0X") return iface->get_atr_reg(unit, dboard_iface::ATR_REG_IDLE);
            if (attr == "ATR_RX") return iface->get_atr_reg(unit, dboard_iface::ATR_REG_RX_ONLY);
            if (attr == "ATR_TX") return iface->get_atr_reg(unit, dboard_iface::ATR_REG_TX_ONLY);
            if (attr == "ATR_XX") return iface->get_atr_reg(unit, dboard_iface::ATR_REG_FULL_DUPLEX);



目录
相关文章
|
6月前
|
Java
JAVA接口
JAVA接口
43 0
|
Java
类与接口介绍
在Java中,类和接口是两种重要的概念,用于描述对象的属性和行为。它们是面向对象编程的基础,用于组织和管理代码。 类(Class)是一种模板或蓝图,用于创建对象。它定义了对象的属性和行为。类是Java中最基本的组织单元,所有的对象都是根据类来创建的。类由字段(属性)和方法组成。字段表示对象的状态或属性,而方法表示对象的行为或操作。 以下是一个简单的Java类的示例: ```java public class Person { // 字段 private String name; private int age; // 构造方法 publi
63 0
|
Java
Java接口和抽象类
Java接口和抽象类
90 0
|
3月前
|
Java
抽象类和接口类的区别是什么?
【8月更文挑战第6天】抽象类和接口类的区别是什么?
292 0
|
6月前
|
人工智能 Java 编译器
Java接口详解
Java接口详解
35 0
|
6月前
|
设计模式 Java
Java接口与抽象类
Java接口与抽象类
47 0
|
6月前
|
XML JSON Java
服务接口定义
服务接口定义
147 3
|
6月前
|
SQL Java 数据库连接
JAVAJDBC中常用的接口和类
JAVAJDBC中常用的接口和类
86 0