diff options
author | Josh Blum <josh@joshknows.com> | 2011-10-26 12:58:43 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-11-07 11:21:24 -0800 |
commit | aa0513375eb60a594f323b82d6f06c7b69c574fc (patch) | |
tree | 98d0790d6508f717aef6b997841362f183216710 /host/lib/usrp/dboard/db_wbx_common.hpp | |
parent | a0e9612f7a32c370f26d1b2db2eee7e692a8f8e9 (diff) | |
download | uhd-aa0513375eb60a594f323b82d6f06c7b69c574fc.tar.gz uhd-aa0513375eb60a594f323b82d6f06c7b69c574fc.tar.bz2 uhd-aa0513375eb60a594f323b82d6f06c7b69c574fc.zip |
wbx: squashed Ben's WBX work
Diffstat (limited to 'host/lib/usrp/dboard/db_wbx_common.hpp')
-rw-r--r-- | host/lib/usrp/dboard/db_wbx_common.hpp | 172 |
1 files changed, 163 insertions, 9 deletions
diff --git a/host/lib/usrp/dboard/db_wbx_common.hpp b/host/lib/usrp/dboard/db_wbx_common.hpp index 5d33ddce9..57e2a0fe6 100644 --- a/host/lib/usrp/dboard/db_wbx_common.hpp +++ b/host/lib/usrp/dboard/db_wbx_common.hpp @@ -18,14 +18,74 @@ #ifndef INCLUDED_LIBUHD_USRP_DBOARD_DB_WBX_COMMON_HPP #define INCLUDED_LIBUHD_USRP_DBOARD_DB_WBX_COMMON_HPP -#include "adf4350_regs.hpp" +// Common IO Pins +#define ADF4350_CE (1 << 3) +#define ADF4350_PDBRF (1 << 2) +#define ADF4350_MUXOUT (1 << 1) // INPUT!!! +#define ADF4351_CE (1 << 3) +#define ADF4351_PDBRF (1 << 2) +#define ADF4351_MUXOUT (1 << 1) // INPUT!!! + +#define LOCKDET_MASK (1 << 0) // INPUT!!! + +// TX IO Pins +#define TX_PUP_5V (1 << 7) // enables 5.0V power supply +#define TX_PUP_3V (1 << 6) // enables 3.3V supply +#define TXMOD_EN (1 << 4) // on UNIT_TX, 1 enables TX Modulator + +// RX IO Pins +#define RX_PUP_5V (1 << 7) // enables 5.0V power supply +#define RX_PUP_3V (1 << 6) // enables 3.3V supply +#define RXBB_PDB (1 << 4) // on UNIT_RX, 1 powers up RX baseband + +// RX Attenuator Pins +#define RX_ATTN_SHIFT 8 // lsb of RX Attenuator Control +#define RX_ATTN_MASK (63 << RX_ATTN_SHIFT) // valid bits of RX Attenuator Control + +// TX Attenuator Pins (v3 only) +#define TX_ATTN_16 (1 << 14) +#define TX_ATTN_8 (1 << 5) +#define TX_ATTN_4 (1 << 4) +#define TX_ATTN_2 (1 << 3) +#define TX_ATTN_1 (1 << 1) +#define TX_ATTN_MASK (TX_ATTN_16|TX_ATTN_8|TX_ATTN_4|TX_ATTN_2|TX_ATTN_1) // valid bits of TX Attenuator Control + +// Mixer functions +#define TX_MIXER_ENB (TXMOD_EN|ADF4350_PDBRF) // for v3, TXMOD_EN tied to ADF4350_PDBRF rather than separate +#define TX_MIXER_DIS 0 + +#define RX_MIXER_ENB (RXBB_PDB|ADF4350_PDBRF) +#define RX_MIXER_DIS 0 + +// Power functions +#define TX_POWER_UP (TX_PUP_5V|TX_PUP_3V) // high enables power supply +#define TX_POWER_DOWN 0 + +#define RX_POWER_UP (RX_PUP_5V|RX_PUP_3V|ADF4350_CE) // high enables power supply +#define RX_POWER_DOWN 0 + + #include <uhd/types/dict.hpp> #include <uhd/types/ranges.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/props.hpp> +#include <uhd/utils/static.hpp> #include <uhd/usrp/dboard_base.hpp> +#include <boost/assign/list_of.hpp> +#include <boost/format.hpp> +#include <boost/shared_ptr.hpp> +#include <boost/math/special_functions/round.hpp> namespace uhd{ namespace usrp{ + +/*********************************************************************** + * The WBX Common dboard constants + **********************************************************************/ +static const uhd::dict<std::string, gain_range_t> wbx_rx_gain_ranges = boost::assign::map_list_of + ("PGA0", gain_range_t(0, 31.5, 0.5)); + + /*********************************************************************** * The WBX dboard base class **********************************************************************/ @@ -41,11 +101,17 @@ protected: virtual void set_rx_enabled(bool enb); virtual void set_tx_enabled(bool enb); - void rx_get(const wax::obj &key, wax::obj &val); - void rx_set(const wax::obj &key, const wax::obj &val); + virtual void rx_get(const wax::obj &key, wax::obj &val); + virtual void rx_set(const wax::obj &key, const wax::obj &val); - void tx_get(const wax::obj &key, wax::obj &val); - void tx_set(const wax::obj &key, const wax::obj &val); + virtual void tx_get(const wax::obj &key, wax::obj &val); + virtual void tx_set(const wax::obj &key, const wax::obj &val); + + /*! + * Retrieve the frequency range of the board. + * \return the frequency range as a freq_range_t + */ + virtual freq_range_t get_freq_range(void); /*! * Set the LO frequency for the particular dboard unit. @@ -57,22 +123,110 @@ protected: /*! * Get the lock detect status of the LO. + * + * This operation is identical for all versions of the WBX board. * \param unit which unit rx or tx * \return true for locked */ virtual bool get_locked(dboard_iface::unit_t unit); + /*! - * Detect if this a v3 WBX - * \return true for locked + * Version-agnostic ABC that wraps version-specific implementations of the + * WBX base daughterboard. + * + * This class is an abstract base class, and thus is impossible to + * instantiate. */ - virtual bool is_v3(void); + class wbx_versionx { + public: + wbx_versionx() {} + ~wbx_versionx(void) {} + + virtual void set_tx_gain(double gain, const std::string &name) = 0; + virtual void set_tx_enabled(bool enb) = 0; + virtual void tx_get(const wax::obj &key, wax::obj &val) = 0; + virtual freq_range_t get_freq_range(void) = 0; + virtual double set_lo_freq(dboard_iface::unit_t unit, double target_freq) = 0; + }; + + + /*! + * Version 2 of the WBX Daughterboard + * + * Basically the original release of the DB. + */ + class wbx_version2 : public wbx_versionx { + public: + wbx_version2(wbx_base *_self_wbx_base); + ~wbx_version2(void); + + void set_tx_gain(double gain, const std::string &name); + void set_tx_enabled(bool enb); + void tx_get(const wax::obj &key, wax::obj &val); + freq_range_t get_freq_range(void); + double set_lo_freq(dboard_iface::unit_t unit, double target_freq); + + /*! This is the registered instance of the wrapper class, wbx_base. */ + wbx_base *self_base; + }; + + /*! + * Version 3 of the WBX Daughterboard + * + * Fixed a problem with the AGC from Version 2. + */ + class wbx_version3 : public wbx_versionx { + public: + wbx_version3(wbx_base *_self_wbx_base); + ~wbx_version3(void); + + void set_tx_gain(double gain, const std::string &name); + void set_tx_enabled(bool enb); + void tx_get(const wax::obj &key, wax::obj &val); + freq_range_t get_freq_range(void); + double set_lo_freq(dboard_iface::unit_t unit, double target_freq); + + /*! This is the registered instance of the wrapper class, wbx_base. */ + wbx_base *self_base; + }; + + /*! + * Version 4 of the WBX Daughterboard + * + * Upgrades the Frequnecy Synthensizer from ADF4350 to ADF4351. + */ + class wbx_version4 : public wbx_versionx { + public: + wbx_version4(wbx_base *_self_wbx_base); + ~wbx_version4(void); + + void set_tx_gain(double gain, const std::string &name); + void set_tx_enabled(bool enb); + void tx_get(const wax::obj &key, wax::obj &val); + freq_range_t get_freq_range(void); + double set_lo_freq(dboard_iface::unit_t unit, double target_freq); + + /*! This is the registered instance of the wrapper class, wbx_base. */ + wbx_base *self_base; + }; + + /*! + * Handle to the version-specific implementation of the WBX. + * + * Since many of this class's functions are dependent on the version of the + * WBX board, this class will instantiate an object of the appropriate + * wbx_version_* subclass, and invoke any relevant functions through that + * object. This pointer is set to the proper object at construction time. + */ + typedef boost::shared_ptr<wbx_versionx> wbx_versionx_sptr; + wbx_versionx_sptr db_actual; -private: uhd::dict<std::string, double> _tx_gains, _rx_gains; bool _rx_enabled, _tx_enabled; }; + }} //namespace uhd::usrp #endif /* INCLUDED_LIBUHD_USRP_DBOARD_DB_WBX_COMMON_HPP */ |