[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r9657 - in gnuradio/branches/developers/eb/u2-wip/usrp
From: |
eb |
Subject: |
[Commit-gnuradio] r9657 - in gnuradio/branches/developers/eb/u2-wip/usrp2/host: include/usrp2 lib |
Date: |
Wed, 24 Sep 2008 13:43:16 -0600 (MDT) |
Author: eb
Date: 2008-09-24 13:43:13 -0600 (Wed, 24 Sep 2008)
New Revision: 9657
Modified:
gnuradio/branches/developers/eb/u2-wip/usrp2/host/include/usrp2/usrp2.h
gnuradio/branches/developers/eb/u2-wip/usrp2/host/lib/usrp2.cc
gnuradio/branches/developers/eb/u2-wip/usrp2/host/lib/usrp2_impl.cc
gnuradio/branches/developers/eb/u2-wip/usrp2/host/lib/usrp2_impl.h
Log:
work-in-progress on usrp2
Modified:
gnuradio/branches/developers/eb/u2-wip/usrp2/host/include/usrp2/usrp2.h
===================================================================
--- gnuradio/branches/developers/eb/u2-wip/usrp2/host/include/usrp2/usrp2.h
2008-09-24 18:59:43 UTC (rev 9656)
+++ gnuradio/branches/developers/eb/u2-wip/usrp2/host/include/usrp2/usrp2.h
2008-09-24 19:43:13 UTC (rev 9657)
@@ -29,6 +29,13 @@
#include <usrp2/rx_sample_handler.h>
+/*
+ * N.B., The interfaces described here are still in flux.
+ *
+ * We will keep all the code in the tree up-to-date with regard to changes
+ * here, but reserve the right to change this on a whim.
+ */
+
namespace usrp2 {
/*!
@@ -89,14 +96,6 @@
*/
std::string mac_addr();
- /*!
- * Burn new mac address into EEPROM on USRP2
- *
- * \param new_addr Network mac address, e.g., "01:23:45:67:89:ab" or
"89:ab".
- * If \p addr is HH:HH, it's treated as if it were
00:50:c2:85:HH:HH
- */
- bool burn_mac_addr(const std::string &new_addr);
-
/*
* ----------------------------------------------------------------
* Rx configuration and control
@@ -253,7 +252,11 @@
size_t nitems,
const tx_metadata *metadata);
- // ----------------------------------------------------------------
+ /*
+ * ----------------------------------------------------------------
+ * miscellaneous methods
+ * ----------------------------------------------------------------
+ */
/*!
* \brief MIMO configuration
@@ -274,6 +277,122 @@
*/
bool config_mimo(int flags);
+
+ //! Get frequency of master oscillator in Hz
+ bool fpga_master_clock_freq(long *freq);
+
+ // Get Sampling rate of A/D converter in Hz
+ bool adc_rate(long *rate);
+
+ // Get Sampling rate of D/A converter in Hz
+ bool dac_rate(long *rate);
+
+ /*!
+ * \brief Get Tx daughterboard ID
+ *
+ * \param[out] dbid returns the daughterboard id.
+ *
+ * daughterboard id >= 0 if successful, -1 if no daugherboard installed,
+ * -2 if invalid EEPROM on daughterboard.
+ */
+ bool tx_daughterboard_id(int *dbid);
+
+ /*!
+ * \brief Get Rx daughterboard ID
+ *
+ * \param[out] dbid returns the daughterboard id.
+ *
+ * daughterboard id >= 0 if successful, -1 if no daugherboard installed,
+ * -2 if invalid EEPROM on daughterboard.
+ */
+ bool rx_daughterboard_id(int *dbid);
+
+ /*
+ * ----------------------------------------------------------------
+ * Low level methods
+ * ----------------------------------------------------------------
+ */
+
+ /*!
+ * Burn new mac address into EEPROM on USRP2
+ *
+ * \param new_addr Network mac address, e.g., "01:23:45:67:89:ab" or
"89:ab".
+ * If \p addr is HH:HH, it's treated as if it were
00:50:c2:85:HH:HH
+ */
+ bool burn_mac_addr(const std::string &new_addr);
+
+
+#if 0 // not yet implemented
+ /*!
+ * \brief Write EEPROM on motherboard or any daughterboard.
+ * \param i2c_addr I2C bus address of EEPROM
+ * \param eeprom_offset byte offset in EEPROM to begin writing
+ * \param buf the data to write
+ * \returns true iff sucessful
+ */
+ bool write_eeprom (int i2c_addr, int eeprom_offset, const std::string
&buf);
+
+ /*!
+ * \brief Read EEPROM on motherboard or any daughterboard.
+ * \param i2c_addr I2C bus address of EEPROM
+ * \param eeprom_offset byte offset in EEPROM to begin reading
+ * \param len number of bytes to read
+ * \returns the data read if successful, else a zero length string.
+ */
+ std::string read_eeprom (int i2c_addr, int eeprom_offset, int len);
+
+ /*!
+ * \brief Write to I2C peripheral
+ * \param i2c_addr I2C bus address (7-bits)
+ * \param buf the data to write
+ * \returns true iff successful
+ * Writes are limited to a maximum of of 64 bytes.
+ */
+ bool write_i2c (int i2c_addr, const std::string &buf);
+
+ /*!
+ * \brief Read from I2C peripheral
+ * \param i2c_addr I2C bus address (7-bits)
+ * \param len number of bytes to read
+ * \returns the data read if successful, else a zero length string.
+ * Reads are limited to a maximum of 64 bytes.
+ */
+ std::string read_i2c (int i2c_addr, int len);
+
+ /*!
+ * \brief Write data to SPI bus peripheral.
+ *
+ * \param optional_header 0,1 or 2 bytes to write before buf.
+ * \param enables bitmask of peripherals to write. See
usrp_spi_defs.h
+ * \param format transaction format. See usrp_spi_defs.h
SPI_FMT_*
+ * \param buf the data to write
+ * \returns true iff successful
+ * Writes are limited to a maximum of 64 bytes.
+ *
+ * If \p format specifies that optional_header bytes are present, they are
+ * written to the peripheral immediately prior to writing \p buf.
+ */
+ bool write_spi (int optional_header, int enables, int format, const
std::string &buf);
+
+ /*
+ * \brief Read data from SPI bus peripheral.
+ *
+ * \param optional_header 0,1 or 2 bytes to write before buf.
+ * \param enables bitmask of peripheral to read. See
usrp_spi_defs.h
+ * \param format transaction format. See usrp_spi_defs.h
SPI_FMT_*
+ * \param len number of bytes to read. Must be in [0,64].
+ * \returns the data read if sucessful, else a zero length string.
+ *
+ * Reads are limited to a maximum of 64 bytes.
+ *
+ * If \p format specifies that optional_header bytes are present, they
+ * are written to the peripheral first. Then \p len bytes are read from
+ * the peripheral and returned.
+ */
+ std::string read_spi (int optional_header, int enables, int format, int
len);
+#endif
+
+
class impl; // implementation details
private:
Modified: gnuradio/branches/developers/eb/u2-wip/usrp2/host/lib/usrp2.cc
===================================================================
--- gnuradio/branches/developers/eb/u2-wip/usrp2/host/lib/usrp2.cc
2008-09-24 18:59:43 UTC (rev 9656)
+++ gnuradio/branches/developers/eb/u2-wip/usrp2/host/lib/usrp2.cc
2008-09-24 19:43:13 UTC (rev 9657)
@@ -160,13 +160,6 @@
return d_impl->mac_addr();
}
- bool
- usrp2::burn_mac_addr(const std::string &new_addr)
- {
- return d_impl->burn_mac_addr(new_addr);
- }
-
-
// Receive
bool
@@ -276,6 +269,54 @@
return d_impl->tx_raw(channel, items, nitems, metadata);
}
+ // miscellaneous methods
+
+ bool
+ usrp2::config_mimo(int flags)
+ {
+ return d_impl->config_mimo(flags);
+ }
+
+ bool
+ usrp2::fpga_master_clock_freq(long *freq)
+ {
+ return d_impl->fpga_master_clock_freq(freq);
+ }
+
+ bool
+ usrp2::adc_rate(long *rate)
+ {
+ return d_impl->adc_rate(rate);
+ }
+
+ bool
+ usrp2::dac_rate(long *rate)
+ {
+ return d_impl->dac_rate(rate);
+ }
+
+ bool
+ usrp2::tx_daughterboard_id(int *dbid)
+ {
+ return d_impl->tx_daughterboard_id(dbid);
+ }
+
+ bool
+ usrp2::rx_daughterboard_id(int *dbid)
+ {
+ return d_impl->rx_daughterboard_id(dbid);
+ }
+
+
+ // low level methods
+
+ bool
+ usrp2::burn_mac_addr(const std::string &new_addr)
+ {
+ return d_impl->burn_mac_addr(new_addr);
+ }
+
+
} // namespace usrp2
Modified: gnuradio/branches/developers/eb/u2-wip/usrp2/host/lib/usrp2_impl.cc
===================================================================
--- gnuradio/branches/developers/eb/u2-wip/usrp2/host/lib/usrp2_impl.cc
2008-09-24 18:59:43 UTC (rev 9656)
+++ gnuradio/branches/developers/eb/u2-wip/usrp2/host/lib/usrp2_impl.cc
2008-09-24 19:43:13 UTC (rev 9657)
@@ -412,33 +412,6 @@
// ----------------------------------------------------------------
- // misc commands
- // ----------------------------------------------------------------
-
- bool
- usrp2::impl::burn_mac_addr(const std::string &new_addr)
- {
- op_burn_mac_addr_cmd cmd;
- op_generic_t reply;
-
- memset(&cmd, 0, sizeof(cmd));
- init_etf_hdrs(&cmd.h, d_addr, 0, CONTROL_CHAN, -1);
- cmd.op.opcode = OP_BURN_MAC_ADDR;
- cmd.op.len = sizeof(cmd.op);
- cmd.op.rid = d_next_rid++;
- if (!parse_mac_addr(new_addr, &cmd.op.addr))
- return false;
-
- pending_reply p(cmd.op.rid, &reply, sizeof(reply));
- if (!transmit_cmd(&cmd, sizeof(cmd), &p, 4*DEF_CMD_TIMEOUT))
- return false;
-
- bool success = (ntohx(reply.ok) == 1);
- return success;
- }
-
-
- // ----------------------------------------------------------------
// Receive
// ----------------------------------------------------------------
@@ -870,5 +843,75 @@
return true;
}
+ // ----------------------------------------------------------------
+ // misc commands
+ // ----------------------------------------------------------------
+ bool
+ usrp2::impl::config_mimo(int flags)
+ {
+ return false; // FIXME implement
+ }
+
+ bool
+ usrp2::impl::fpga_master_clock_freq(long *freq)
+ {
+ *freq = 100000000L;
+ return true;
+ }
+
+ bool
+ usrp2::impl::adc_rate(long *rate)
+ {
+ return fpga_master_clock_freq(rate);
+ }
+
+ bool
+ usrp2::impl::dac_rate(long *rate)
+ {
+ return fpga_master_clock_freq(rate);
+ }
+
+ bool
+ usrp2::impl::tx_daughterboard_id(int *dbid)
+ {
+ *dbid = -1; // FIXME implement
+ return true;
+ }
+
+ bool
+ usrp2::impl::rx_daughterboard_id(int *dbid)
+ {
+ *dbid = -1; // FIXME implement
+ return true;
+ }
+
+
+ // ----------------------------------------------------------------
+ // low-level commands
+ // ----------------------------------------------------------------
+
+ bool
+ usrp2::impl::burn_mac_addr(const std::string &new_addr)
+ {
+ op_burn_mac_addr_cmd cmd;
+ op_generic_t reply;
+
+ memset(&cmd, 0, sizeof(cmd));
+ init_etf_hdrs(&cmd.h, d_addr, 0, CONTROL_CHAN, -1);
+ cmd.op.opcode = OP_BURN_MAC_ADDR;
+ cmd.op.len = sizeof(cmd.op);
+ cmd.op.rid = d_next_rid++;
+ if (!parse_mac_addr(new_addr, &cmd.op.addr))
+ return false;
+
+ pending_reply p(cmd.op.rid, &reply, sizeof(reply));
+ if (!transmit_cmd(&cmd, sizeof(cmd), &p, 4*DEF_CMD_TIMEOUT))
+ return false;
+
+ bool success = (ntohx(reply.ok) == 1);
+ return success;
+ }
+
+
} // namespace usrp2
Modified: gnuradio/branches/developers/eb/u2-wip/usrp2/host/lib/usrp2_impl.h
===================================================================
--- gnuradio/branches/developers/eb/u2-wip/usrp2/host/lib/usrp2_impl.h
2008-09-24 18:59:43 UTC (rev 9656)
+++ gnuradio/branches/developers/eb/u2-wip/usrp2/host/lib/usrp2_impl.h
2008-09-24 19:43:13 UTC (rev 9657)
@@ -95,8 +95,9 @@
void bg_loop();
std::string mac_addr() const { return d_addr; } // FIXME: convert from
u2_mac_addr_t
- bool burn_mac_addr(const std::string &new_addr);
+ // Rx
+
bool set_rx_gain(double gain);
bool set_rx_center_freq(double frequency, tune_result *result);
bool set_rx_decim(int decimation_factor);
@@ -107,6 +108,8 @@
unsigned int rx_overruns() const { return d_num_rx_overruns; }
unsigned int rx_missing() const { return d_num_rx_missing; }
+ // Tx
+
bool set_tx_gain(double gain);
bool set_tx_center_freq(double frequency, tune_result *result);
bool set_tx_interp(int interpolation_factor);
@@ -126,6 +129,19 @@
const uint32_t *items,
size_t nitems,
const tx_metadata *metadata);
+
+ // misc
+
+ bool config_mimo(int flags);
+ bool fpga_master_clock_freq(long *freq);
+ bool adc_rate(long *rate);
+ bool dac_rate(long *rate);
+ bool tx_daughterboard_id(int *dbid);
+ bool rx_daughterboard_id(int *dbid);
+
+ // low level
+
+ bool burn_mac_addr(const std::string &new_addr);
};
} // namespace usrp2
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r9657 - in gnuradio/branches/developers/eb/u2-wip/usrp2/host: include/usrp2 lib,
eb <=