aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-08-14 14:45:59 -0700
committerJosh Blum <josh@joshknows.com>2010-08-14 14:45:59 -0700
commitf0960e79489c6702d3bd79c40f9e24f2b9e5b42d (patch)
tree4de0d8c492fd2fac83684fc4a766891bc3c37157 /host
parent6d2899d18661e4cec5ae90692e08404ea48bc112 (diff)
downloaduhd-f0960e79489c6702d3bd79c40f9e24f2b9e5b42d.tar.gz
uhd-f0960e79489c6702d3bd79c40f9e24f2b9e5b42d.tar.bz2
uhd-f0960e79489c6702d3bd79c40f9e24f2b9e5b42d.zip
usrp: replaced mboard name with special props for dboard iface
Diffstat (limited to 'host')
-rw-r--r--host/include/uhd/usrp/dboard_iface.hpp29
-rw-r--r--host/lib/usrp/dboard/db_dbsrx.cpp31
-rw-r--r--host/lib/usrp/usrp2/dboard_iface.cpp7
3 files changed, 46 insertions, 21 deletions
diff --git a/host/include/uhd/usrp/dboard_iface.hpp b/host/include/uhd/usrp/dboard_iface.hpp
index fc7ea3052..e776ecc42 100644
--- a/host/include/uhd/usrp/dboard_iface.hpp
+++ b/host/include/uhd/usrp/dboard_iface.hpp
@@ -65,11 +65,34 @@ public:
AUX_ADC_B = 'b'
};
+ //! Special properties that differentiate this daughterboard slot
+ struct special_props_t{
+ /*!
+ * Soft clock divider:
+ * When a motherboard cannot provided a divided dboard clock,
+ * it may provided a "soft" divided clock over an FPGA GPIO.
+ * The implementation must know the type of clock provided.
+ */
+ bool soft_clock_divider;
+
+ /*!
+ * Mangle i2c addresses:
+ * When i2c is shared across multiple daugterboard slots,
+ * the i2c addresses will be mangled on the secondary slot
+ * to avoid conflicts between slots in the i2c address space.
+ * The mangling is daguhterboard specific so the implementation
+ * needs to know whether it should use mangled addresses or not.
+ */
+ bool mangle_i2c_addrs;
+ };
+
/*!
- * Get the motherboard name of the form: usrp1, usrp2...
- * \return string representing the motherboard name
+ * 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 std::string get_mboard_name(void) = 0;
+ virtual special_props_t get_special_props(void) = 0;
/*!
* Write to an aux dac.
diff --git a/host/lib/usrp/dboard/db_dbsrx.cpp b/host/lib/usrp/dboard/db_dbsrx.cpp
index 03e6b6255..072497dcc 100644
--- a/host/lib/usrp/dboard/db_dbsrx.cpp
+++ b/host/lib/usrp/dboard/db_dbsrx.cpp
@@ -61,7 +61,7 @@ static const uhd::dict<std::string, gain_range_t> dbsrx_gain_ranges = map_list_o
**********************************************************************/
class dbsrx : public rx_dboard_base{
public:
- dbsrx(ctor_args_t args, boost::uint8_t max2118_addr);
+ dbsrx(ctor_args_t args);
~dbsrx(void);
void rx_get(const wax::obj &key, wax::obj &val);
@@ -73,7 +73,9 @@ private:
uhd::dict<std::string, float> _gains;
max2118_write_regs_t _max2118_write_regs;
max2118_read_regs_t _max2118_read_regs;
- boost::uint8_t _max2118_addr; //0x67 or 0x65 depending on which side
+ boost::uint8_t _max2118_addr(void){
+ return (this->get_iface()->get_special_props().mangle_i2c_addrs)? 0x65 : 0x67;
+ };
void set_lo_freq(double target_freq);
void set_gain(float gain, const std::string &name);
@@ -102,7 +104,7 @@ private:
//send the data
this->get_iface()->write_i2c(
- _max2118_addr, regs_vector
+ _max2118_addr(), regs_vector
);
}
}
@@ -120,7 +122,7 @@ private:
//read from i2c
regs_vector = this->get_iface()->read_i2c(
- _max2118_addr, num_bytes
+ _max2118_addr(), num_bytes
);
for(boost::uint8_t i=0; i < num_bytes; i++){
@@ -156,10 +158,8 @@ private:
/***********************************************************************
* Register the DBSRX dboard
**********************************************************************/
-// FIXME 0x67 is the default i2c address on USRP2
-// need to handle which side for USRP1 with different address
static dboard_base::sptr make_dbsrx(dboard_base::ctor_args_t args){
- return dboard_base::sptr(new dbsrx(args, 0x67));
+ return dboard_base::sptr(new dbsrx(args));
}
//dbid for USRP2 version
@@ -177,27 +177,27 @@ UHD_STATIC_BLOCK(reg_dbsrx_on_usrp1_dboard){
/***********************************************************************
* Structors
**********************************************************************/
-dbsrx::dbsrx(ctor_args_t args, boost::uint8_t max2118_addr) : rx_dboard_base(args){
+dbsrx::dbsrx(ctor_args_t args) : rx_dboard_base(args){
//warn user about incorrect DBID on USRP1, requires R193 populated
- if (this->get_iface()->get_mboard_name() == "usrp1" and this->get_rx_id() == 0x000D)
+ if (this->get_iface()->get_special_props().soft_clock_divider and this->get_rx_id() == 0x000D)
uhd::print_warning(
str(boost::format(
"DBSRX: incorrect dbid\n"
- "%s expects dbid 0x0002 and R193\n"
+ "Expected dbid 0x0002 and R193\n"
"found dbid == %d\n"
"Please see the daughterboard app notes"
- ) % (this->get_iface()->get_mboard_name()) % (this->get_rx_id().to_pp_string()))
+ ) % this->get_rx_id().to_pp_string())
);
//warn user about incorrect DBID on non-USRP1, requires R194 populated
- if (this->get_iface()->get_mboard_name() != "usrp1" and this->get_rx_id() == 0x0002)
+ if (not this->get_iface()->get_special_props().soft_clock_divider and this->get_rx_id() == 0x0002)
uhd::print_warning(
str(boost::format(
"DBSRX: incorrect dbid\n"
- "%s expects dbid 0x000D and R194\n"
+ "Expected dbid 0x000D and R194\n"
"found dbid == %d\n"
"Please see the daughterboard app notes"
- ) % (this->get_iface()->get_mboard_name()) % (this->get_rx_id().to_pp_string()))
+ ) % this->get_rx_id().to_pp_string())
);
//enable only the clocks we need
@@ -207,9 +207,6 @@ dbsrx::dbsrx(ctor_args_t args, boost::uint8_t max2118_addr) : rx_dboard_base(arg
this->get_iface()->set_pin_ctrl(dboard_iface::UNIT_RX, 0x0); // All unused in atr
this->get_iface()->set_gpio_ddr(dboard_iface::UNIT_RX, 0x0); // All Inputs
- //set the i2c address for the max2118
- _max2118_addr = max2118_addr;
-
//send initial register settings
this->send_reg(0x0, 0x5);
diff --git a/host/lib/usrp/usrp2/dboard_iface.cpp b/host/lib/usrp/usrp2/dboard_iface.cpp
index 1b9a4bb97..8bded1ea3 100644
--- a/host/lib/usrp/usrp2/dboard_iface.cpp
+++ b/host/lib/usrp/usrp2/dboard_iface.cpp
@@ -37,7 +37,12 @@ public:
usrp2_dboard_iface(usrp2_iface::sptr iface, usrp2_clock_ctrl::sptr clock_ctrl);
~usrp2_dboard_iface(void);
- std::string get_mboard_name(void){return "usrp2";}
+ special_props_t get_special_props(void){
+ special_props_t props;
+ props.soft_clock_divider = false;
+ props.mangle_i2c_addrs = false;
+ return props;
+ }
void write_aux_dac(unit_t, aux_dac_t, float);
float read_aux_adc(unit_t, aux_adc_t);