2010-08-13 23:20:41 +00:00
|
|
|
//
|
2012-11-14 22:11:39 +00:00
|
|
|
// Copyright 2010-2012 Ettus Research LLC
|
2010-08-13 23:20:41 +00:00
|
|
|
//
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
//
|
|
|
|
|
|
2011-07-01 22:07:38 +00:00
|
|
|
#ifndef INCLUDED_LIBUHD_USRP_COMMON_FX2_CTRL_HPP
|
|
|
|
|
#define INCLUDED_LIBUHD_USRP_COMMON_FX2_CTRL_HPP
|
2010-08-13 23:20:41 +00:00
|
|
|
|
2011-06-30 04:16:28 +00:00
|
|
|
#include <uhd/transport/usb_control.hpp>
|
|
|
|
|
#include <uhd/types/serial.hpp> //i2c iface
|
2010-08-13 23:20:41 +00:00
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
|
#include <boost/utility.hpp>
|
|
|
|
|
|
2012-11-14 22:11:39 +00:00
|
|
|
#define FL_BEGIN 0
|
|
|
|
|
#define FL_END 2
|
|
|
|
|
#define FL_XFER 1
|
|
|
|
|
#define USRP_HASH_SLOT_0_ADDR 0xe1e0
|
|
|
|
|
#define USRP_HASH_SLOT_1_ADDR 0xe1f0
|
|
|
|
|
#define VRQ_FPGA_LOAD 0x02
|
|
|
|
|
#define VRQ_FPGA_SET_RESET 0x04
|
|
|
|
|
#define VRQ_FPGA_SET_TX_ENABLE 0x05
|
|
|
|
|
#define VRQ_FPGA_SET_RX_ENABLE 0x06
|
|
|
|
|
#define VRQ_FPGA_SET_TX_RESET 0x0a
|
|
|
|
|
#define VRQ_FPGA_SET_RX_RESET 0x0b
|
|
|
|
|
#define VRQ_I2C_READ 0x81
|
|
|
|
|
#define VRQ_I2C_WRITE 0x08
|
|
|
|
|
#define VRQ_SET_LED 0x01
|
|
|
|
|
#define VRT_VENDOR_IN 0xC0
|
|
|
|
|
#define VRT_VENDOR_OUT 0x40
|
|
|
|
|
|
2011-06-14 22:32:11 +00:00
|
|
|
namespace uhd{ namespace usrp{
|
|
|
|
|
|
2011-06-30 04:16:28 +00:00
|
|
|
class fx2_ctrl : boost::noncopyable, public uhd::i2c_iface{
|
2010-08-13 23:20:41 +00:00
|
|
|
public:
|
2011-06-14 22:32:11 +00:00
|
|
|
typedef boost::shared_ptr<fx2_ctrl> sptr;
|
2010-08-13 23:20:41 +00:00
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* Make a usrp control object from a control transport
|
|
|
|
|
* \param ctrl_transport a USB control transport
|
|
|
|
|
* \return a new usrp control object
|
|
|
|
|
*/
|
|
|
|
|
static sptr make(uhd::transport::usb_control::sptr ctrl_transport);
|
|
|
|
|
|
2011-01-17 23:18:46 +00:00
|
|
|
//! Call init after the fpga is loaded
|
|
|
|
|
virtual void usrp_init(void) = 0;
|
|
|
|
|
|
2012-02-14 23:01:15 +00:00
|
|
|
//! For emergency situations
|
|
|
|
|
virtual void usrp_fx2_reset(void) = 0;
|
|
|
|
|
|
2010-08-13 23:20:41 +00:00
|
|
|
/*!
|
|
|
|
|
* Load firmware in Intel HEX Format onto device
|
|
|
|
|
* \param filename name of firmware file
|
|
|
|
|
* \param force reload firmware if already loaded
|
|
|
|
|
*/
|
2011-03-10 22:07:38 +00:00
|
|
|
virtual void usrp_load_firmware(std::string filename,
|
2010-08-13 23:20:41 +00:00
|
|
|
bool force = false) = 0;
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* Load fpga file onto usrp
|
|
|
|
|
* \param filename name of fpga image
|
|
|
|
|
*/
|
2011-03-10 22:07:38 +00:00
|
|
|
virtual void usrp_load_fpga(std::string filename) = 0;
|
2010-08-13 23:20:41 +00:00
|
|
|
|
2010-08-31 23:44:30 +00:00
|
|
|
/*!
|
|
|
|
|
* Load USB descriptor file in Intel HEX format into EEPROM
|
2011-03-10 22:07:38 +00:00
|
|
|
* \param filename name of EEPROM image
|
2010-08-31 23:44:30 +00:00
|
|
|
*/
|
2011-03-10 22:07:38 +00:00
|
|
|
virtual void usrp_load_eeprom(std::string filestring) = 0;
|
2011-06-15 00:25:22 +00:00
|
|
|
|
2010-08-13 23:20:41 +00:00
|
|
|
/*!
|
|
|
|
|
* Submit an IN transfer
|
|
|
|
|
* \param request device specific request
|
|
|
|
|
* \param value device specific field
|
|
|
|
|
* \param index device specific field
|
|
|
|
|
* \param buff buffer to place data
|
|
|
|
|
* \return number of bytes read or error
|
|
|
|
|
*/
|
|
|
|
|
virtual int usrp_control_read(boost::uint8_t request,
|
|
|
|
|
boost::uint16_t value,
|
|
|
|
|
boost::uint16_t index,
|
|
|
|
|
unsigned char *buff,
|
|
|
|
|
boost::uint16_t length) = 0;
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* Submit an OUT transfer
|
|
|
|
|
* \param request device specific request
|
|
|
|
|
* \param value device specific field
|
|
|
|
|
* \param index device specific field
|
|
|
|
|
* \param buff buffer of data to be sent
|
|
|
|
|
* \return number of bytes written or error
|
|
|
|
|
*/
|
|
|
|
|
virtual int usrp_control_write(boost::uint8_t request,
|
|
|
|
|
boost::uint16_t value,
|
|
|
|
|
boost::uint16_t index,
|
|
|
|
|
unsigned char *buff,
|
|
|
|
|
boost::uint16_t length) = 0;
|
|
|
|
|
|
2010-08-31 23:44:30 +00:00
|
|
|
/*!
|
|
|
|
|
* Perform an I2C write
|
|
|
|
|
* \param i2c_addr I2C device address
|
|
|
|
|
* \param buf data to be written
|
|
|
|
|
* \param len length of data in bytes
|
|
|
|
|
* \return number of bytes written or error
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
virtual int usrp_i2c_write(boost::uint16_t i2c_addr,
|
|
|
|
|
unsigned char *buf,
|
|
|
|
|
boost::uint16_t len) = 0;
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* Perform an I2C read
|
|
|
|
|
* \param i2c_addr I2C device address
|
|
|
|
|
* \param buf data to be read
|
|
|
|
|
* \param len length of data in bytes
|
|
|
|
|
* \return number of bytes read or error
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
virtual int usrp_i2c_read(boost::uint16_t i2c_addr,
|
|
|
|
|
unsigned char *buf,
|
|
|
|
|
boost::uint16_t len) = 0;
|
|
|
|
|
|
2011-05-15 02:57:03 +00:00
|
|
|
//! enable/disable the rx path
|
|
|
|
|
virtual void usrp_rx_enable(bool on) = 0;
|
|
|
|
|
|
|
|
|
|
//! enable/disable the tx path
|
|
|
|
|
virtual void usrp_tx_enable(bool on) = 0;
|
2012-02-14 20:03:52 +00:00
|
|
|
|
|
|
|
|
//! reset the fpga
|
|
|
|
|
virtual void usrp_fpga_reset(bool on) = 0;
|
2010-08-13 23:20:41 +00:00
|
|
|
};
|
|
|
|
|
|
2011-06-14 22:32:11 +00:00
|
|
|
}} //namespace uhd::usrp
|
|
|
|
|
|
2011-07-01 22:07:38 +00:00
|
|
|
#endif /* INCLUDED_LIBUHD_USRP_COMMON_FX2_CTRL_HPP */
|