diff options
author | Josh Blum <josh@joshknows.com> | 2010-04-21 18:40:53 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-04-21 18:40:53 -0700 |
commit | d73db2cc560f975512db7748f0e82865285c76e8 (patch) | |
tree | d5b6ecfa5a6a32212ecc305969eba661397a1915 /host/lib/usrp | |
parent | d91c18e6d061cf4584e271508a7a4475d8224663 (diff) | |
download | uhd-d73db2cc560f975512db7748f0e82865285c76e8.tar.gz uhd-d73db2cc560f975512db7748f0e82865285c76e8.tar.bz2 uhd-d73db2cc560f975512db7748f0e82865285c76e8.zip |
work on atr registers and filling in functions
Diffstat (limited to 'host/lib/usrp')
-rw-r--r-- | host/lib/usrp/dboard/db_xcvr2450.cpp | 122 |
1 files changed, 108 insertions, 14 deletions
diff --git a/host/lib/usrp/dboard/db_xcvr2450.cpp b/host/lib/usrp/dboard/db_xcvr2450.cpp index 7242fd96c..3f00b2539 100644 --- a/host/lib/usrp/dboard/db_xcvr2450.cpp +++ b/host/lib/usrp/dboard/db_xcvr2450.cpp @@ -15,6 +15,38 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // +// TX IO Pins +#define HB_PA_OFF_TXIO (1 << 15) // 5GHz PA, 1 = off, 0 = on +#define LB_PA_OFF_TXIO (1 << 14) // 2.4GHz PA, 1 = off, 0 = on +#define ANTSEL_TX1_RX2_TXIO (1 << 13) // 1 = Ant 1 to TX, Ant 2 to RX +#define ANTSEL_TX2_RX1_TXIO (1 << 12) // 1 = Ant 2 to TX, Ant 1 to RX +#define TX_EN_TXIO (1 << 11) // 1 = TX on, 0 = TX off +#define AD9515DIV_TXIO (1 << 4) // 1 = Div by 3, 0 = Div by 2 + +#define TXIO_MASK (HB_PA_OFF_TXIO | LB_PA_OFF_TXIO | ANTSEL_TX1_RX2_TXIO | ANTSEL_TX2_RX1_TXIO | TX_EN_TXIO | AD9515DIV_TXIO) + +// TX IO Functions +#define HB_PA_TXIO LB_PA_OFF_TXIO +#define LB_PA_TXIO HB_PA_OFF_TXIO +#define TX_ENB_TXIO TX_EN_TXIO +#define TX_DIS_TXIO 0 +#define AD9515DIV_3_TXIO AD9515DIV_TXIO +#define AD9515DIV_2_TXIO 0 + +// RX IO Pins +#define LOCKDET_RXIO (1 << 15) // This is an INPUT!!! +#define EN_RXIO (1 << 14) +#define RX_EN_RXIO (1 << 13) // 1 = RX on, 0 = RX off +#define RX_HP_RXIO (1 << 12) // 0 = Fc set by rx_hpf, 1 = 600 KHz + +#define RXIO_MASK (EN_RXIO | RX_EN_RXIO | RX_HP_RXIO) + +// RX IO Functions +#define ALL_ENB_RXIO EN_RXIO +#define ALL_DIS_RXIO 0 +#define RX_ENB_RXIO RX_EN_RXIO +#define RX_DIS_RXIO 0 + #include <uhd/utils/static.hpp> #include <uhd/utils/assert.hpp> #include <uhd/utils/algorithm.hpp> @@ -52,12 +84,15 @@ private: double _lo_freq; uhd::dict<std::string, float> _tx_gains, _rx_gains; std::string _tx_ant, _rx_ant; + int _ad9515div; + + void set_lo_freq(double target_freq); + void set_tx_ant(const std::string &ant); + void set_rx_ant(const std::string &ant); + void set_tx_gain(float gain, const std::string &name); + void set_rx_gain(float gain, const std::string &name); - void set_lo_freq(double target_freq){} - void set_tx_ant(const std::string &ant){} - void set_rx_ant(const std::string &ant){} - void set_tx_gain(float gain, const std::string &name){} - void set_rx_gain(float gain, const std::string &name){} + void update_atr(void); }; /*********************************************************************** @@ -77,18 +112,69 @@ UHD_STATIC_BLOCK(reg_xcvr2450_dboard){ * Structors **********************************************************************/ xcvr2450::xcvr2450(ctor_args_t const& args) : xcvr_dboard_base(args){ - /* NOP */ + //enable only the clocks we need + this->get_iface()->set_clock_enabled(dboard_iface::UNIT_TX, true); + + //set the gpio directions + this->get_iface()->set_gpio_ddr(dboard_iface::UNIT_TX, TXIO_MASK); + this->get_iface()->set_gpio_ddr(dboard_iface::UNIT_RX, RXIO_MASK); + + //set defaults for LO, gains, antennas + set_lo_freq(2.45e9); + set_rx_ant("J1"); + set_tx_ant("J2"); + set_rx_gain(0, "RF LNA"); + set_rx_gain(0, "BB VGA"); + set_tx_gain(0, "VGA"); } xcvr2450::~xcvr2450(void){ /* NOP */ } +void xcvr2450::update_atr(void){ + //calculate tx atr pins + int band_sel = (_lo_freq > 4e9)? HB_PA_TXIO : LB_PA_TXIO; + int tx_ant_sel = (_tx_ant == "J1")? ANTSEL_TX1_RX2_TXIO : ANTSEL_TX2_RX1_TXIO; + int rx_ant_sel = (_rx_ant == "J1")? ANTSEL_TX1_RX2_TXIO : ANTSEL_TX2_RX1_TXIO; + int ad9515div = (_ad9515div == 3)? AD9515DIV_3_TXIO : AD9515DIV_2_TXIO; + + //set the tx registers + this->get_iface()->set_atr_reg(dboard_iface::UNIT_TX, dboard_iface::ATR_REG_IDLE, band_sel | ad9515div | TX_DIS_TXIO); + this->get_iface()->set_atr_reg(dboard_iface::UNIT_TX, dboard_iface::ATR_REG_RX_ONLY, band_sel | ad9515div | TX_DIS_TXIO | rx_ant_sel); + this->get_iface()->set_atr_reg(dboard_iface::UNIT_TX, dboard_iface::ATR_REG_TX_ONLY, band_sel | ad9515div | TX_ENB_TXIO | tx_ant_sel); + this->get_iface()->set_atr_reg(dboard_iface::UNIT_TX, dboard_iface::ATR_REG_FULL_DUPLEX, band_sel | ad9515div | TX_ENB_TXIO); + + //set the rx registers + this->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_IDLE, ALL_ENB_RXIO | RX_DIS_RXIO); + this->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_RX_ONLY, ALL_ENB_RXIO | RX_ENB_RXIO); + this->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_TX_ONLY, ALL_ENB_RXIO | RX_DIS_RXIO); + this->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_FULL_DUPLEX, ALL_ENB_RXIO | RX_ENB_RXIO); +} + +/*********************************************************************** + * Tuning + **********************************************************************/ +void xcvr2450::set_lo_freq(double target_freq){ + //TODO + //set _ad9515div +} + /*********************************************************************** * Antenna Handling **********************************************************************/ static const prop_names_t xcvr_antennas = list_of("J1")("J2"); +void xcvr2450::set_tx_ant(const std::string &ant){ + assert_has(xcvr_antennas, ant, "xcvr antenna name"); + //TODO +} + +void xcvr2450::set_rx_ant(const std::string &ant){ + assert_has(xcvr_antennas, ant, "xcvr antenna name"); + //TODO +} + /*********************************************************************** * Gain Handling **********************************************************************/ @@ -148,6 +234,16 @@ static int gain_to_rx_rf_lna_reg(float &gain){ return reg; } +void xcvr2450::set_tx_gain(float gain, const std::string &name){ + assert_has(xcvr_tx_gain_ranges.keys(), name, "xcvr tx gain name"); + //TODO +} + +void xcvr2450::set_rx_gain(float gain, const std::string &name){ + assert_has(xcvr_rx_gain_ranges.keys(), name, "xcvr rx gain name"); + //TODO +} + /*********************************************************************** * RX Get and Set **********************************************************************/ @@ -232,10 +328,9 @@ void xcvr2450::rx_set(const wax::obj &key_, const wax::obj &val){ this->set_rx_ant(val.as<std::string>()); return; - default: - throw std::runtime_error(str(boost::format( - "Error: trying to set read-only property on %s subdev" - ) % dboard_id::to_string(get_rx_id()))); + default: throw std::runtime_error(str(boost::format( + "Error: trying to set read-only property on %s subdev" + ) % dboard_id::to_string(get_rx_id()))); } } @@ -323,9 +418,8 @@ void xcvr2450::tx_set(const wax::obj &key_, const wax::obj &val){ this->set_tx_ant(val.as<std::string>()); return; - default: - throw std::runtime_error(str(boost::format( - "Error: trying to set read-only property on %s subdev" - ) % dboard_id::to_string(get_tx_id()))); + default: throw std::runtime_error(str(boost::format( + "Error: trying to set read-only property on %s subdev" + ) % dboard_id::to_string(get_tx_id()))); } } |