mirror of
https://github.com/fairwaves/UHD-Fairwaves.git
synced 2025-10-23 07:42:00 +00:00
host: integrate support class for umsel2
This commit is contained in:
@@ -58,6 +58,7 @@ list(APPEND UMTRX_SOURCES
|
|||||||
cores/time64_core_200.cpp
|
cores/time64_core_200.cpp
|
||||||
cores/validate_subdev_spec.cpp
|
cores/validate_subdev_spec.cpp
|
||||||
cores/apply_corrections.cpp
|
cores/apply_corrections.cpp
|
||||||
|
umsel2_ctrl.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
|
67
host/umsel2_ctrl.cpp
Normal file
67
host/umsel2_ctrl.cpp
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
// Copyright 2015-2015 Fairwaves LLC
|
||||||
|
//
|
||||||
|
// 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/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "umsel2_ctrl.hpp"
|
||||||
|
#include "umtrx_regs.hpp"
|
||||||
|
|
||||||
|
class umsel2_ctrl_impl : public umsel2_ctrl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
umsel2_ctrl_impl(uhd::wb_iface::sptr ctrl, uhd::spi_iface::sptr spiface):
|
||||||
|
_ctrl(ctrl), _spiface(spiface)
|
||||||
|
{
|
||||||
|
//TODO init stuff?
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
~umsel2_ctrl_impl(void)
|
||||||
|
{
|
||||||
|
//TODO shutdown
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uhd::freq_range_t get_rx_freq_range(const int which)
|
||||||
|
{
|
||||||
|
//TODO range
|
||||||
|
}
|
||||||
|
|
||||||
|
double set_rx_freq(const int which, const double freq)
|
||||||
|
{
|
||||||
|
const int slaveno = (which == 1)?SPI_SS_AUX1 : SPI_SS_AUX2;
|
||||||
|
//TODO tune...
|
||||||
|
|
||||||
|
return freq;
|
||||||
|
}
|
||||||
|
|
||||||
|
uhd::sensor_value_t get_locked(const int which)
|
||||||
|
{
|
||||||
|
boost::uint32_t irq = _ctrl->peek32(U2_REG_IRQ_RB);
|
||||||
|
bool locked = false;
|
||||||
|
if (which == 1) locked = (irq & AUX_LD1_IRQ_BIT) != 0;
|
||||||
|
if (which == 2) locked = (irq & AUX_LD2_IRQ_BIT) != 0;
|
||||||
|
return uhd::sensor_value_t("LO", locked, "locked", "unlocked");
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
uhd::wb_iface::sptr _ctrl;
|
||||||
|
uhd::spi_iface::sptr _spiface;
|
||||||
|
};
|
||||||
|
|
||||||
|
umsel2_ctrl::sptr umsel2_ctrl::make(uhd::wb_iface::sptr ctrl, uhd::spi_iface::sptr spiface)
|
||||||
|
{
|
||||||
|
return umsel2_ctrl::sptr(new umsel2_ctrl_impl(ctrl, spiface));
|
||||||
|
}
|
58
host/umsel2_ctrl.hpp
Normal file
58
host/umsel2_ctrl.hpp
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
// Copyright 2015-2015 Fairwaves LLC
|
||||||
|
//
|
||||||
|
// 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/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef INCLUDED_UMSEL2_CTRL_HPP
|
||||||
|
#define INCLUDED_UMSEL2_CTRL_HPP
|
||||||
|
|
||||||
|
#include <uhd/types/serial.hpp>
|
||||||
|
#include <uhd/types/wb_iface.hpp>
|
||||||
|
#include <uhd/types/sensors.hpp>
|
||||||
|
#include <uhd/types/ranges.hpp>
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
#include <boost/utility.hpp>
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Control UmSEL2 board.
|
||||||
|
*/
|
||||||
|
class umsel2_ctrl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef boost::shared_ptr<umsel2_ctrl> sptr;
|
||||||
|
|
||||||
|
static sptr make(uhd::wb_iface::sptr ctrl, uhd::spi_iface::sptr spiface);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Query the tune range.
|
||||||
|
* \param which values 1 or 2
|
||||||
|
*/
|
||||||
|
virtual uhd::freq_range_t get_rx_freq_range(const int which) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Tune the synthesizer
|
||||||
|
* \param which values 1 or 2
|
||||||
|
* \param freq the freq in Hz
|
||||||
|
* \return the actual freq in Hz
|
||||||
|
*/
|
||||||
|
virtual double set_rx_freq(const int which, const double freq) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Query lock detect.
|
||||||
|
* \param which values 1 or 2
|
||||||
|
*/
|
||||||
|
virtual uhd::sensor_value_t get_locked(const int which) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* INCLUDED_UMSEL2_CTRL_HPP */
|
@@ -270,6 +270,22 @@ umtrx_impl::umtrx_impl(const device_addr_t &device_addr)
|
|||||||
_tree->create<std::string>(mb_path / "hwrev").set(get_hw_rev());
|
_tree->create<std::string>(mb_path / "hwrev").set(get_hw_rev());
|
||||||
UHD_MSG(status) << "Detected UmTRX " << get_hw_rev() << std::endl;
|
UHD_MSG(status) << "Detected UmTRX " << get_hw_rev() << std::endl;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
// setup umsel2 control when present
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
//TODO delect umsel2 and setup _umsel2 sptr...
|
||||||
|
//will be null when not available
|
||||||
|
_umsel2 = umsel2_ctrl::make(_ctrl/*peek*/, _ctrl/*spi*/);
|
||||||
|
|
||||||
|
//register lock detect for umsel2
|
||||||
|
if (_umsel2)
|
||||||
|
{
|
||||||
|
_tree->create<sensor_value_t>(mb_path / "dboards" / "A" / "rx_frontends" / "0" / "sensors" / "aux_lo_locked")
|
||||||
|
.publish(boost::bind(&umsel2_ctrl::get_locked, _umsel2, 1));
|
||||||
|
_tree->create<sensor_value_t>(mb_path / "dboards" / "B" / "rx_frontends" / "0" / "sensors" / "aux_lo_locked")
|
||||||
|
.publish(boost::bind(&umsel2_ctrl::get_locked, _umsel2, 2));
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// configure diversity switches
|
// configure diversity switches
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
@@ -570,9 +586,17 @@ umtrx_impl::umtrx_impl(const device_addr_t &device_addr)
|
|||||||
|
|
||||||
//rx freq
|
//rx freq
|
||||||
_tree->create<double>(rx_rf_fe_path / "freq" / "value")
|
_tree->create<double>(rx_rf_fe_path / "freq" / "value")
|
||||||
.coerce(boost::bind(&lms6002d_ctrl::set_rx_freq, ctrl, _1));
|
.coerce(boost::bind(&umtrx_impl::set_rx_freq, this, fe_name, _1));
|
||||||
_tree->create<meta_range_t>(rx_rf_fe_path / "freq" / "range")
|
if (_umsel2)
|
||||||
.publish(boost::bind(&lms6002d_ctrl::get_rx_freq_range, ctrl));
|
{
|
||||||
|
_tree->create<meta_range_t>(rx_rf_fe_path / "freq" / "range")
|
||||||
|
.publish(boost::bind(&umsel2_ctrl::get_rx_freq_range, _umsel2, (fe_name=="A")?1:2));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_tree->create<meta_range_t>(rx_rf_fe_path / "freq" / "range")
|
||||||
|
.publish(boost::bind(&lms6002d_ctrl::get_rx_freq_range, ctrl));
|
||||||
|
}
|
||||||
_tree->create<bool>(rx_rf_fe_path / "use_lo_offset").set(false);
|
_tree->create<bool>(rx_rf_fe_path / "use_lo_offset").set(false);
|
||||||
|
|
||||||
//tx freq
|
//tx freq
|
||||||
@@ -871,6 +895,19 @@ uint8_t umtrx_impl::dc_offset_double2int(double corr)
|
|||||||
return (int)(corr*128 + 128.5);
|
return (int)(corr*128 + 128.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double umtrx_impl::set_rx_freq(const std::string &which, const double freq)
|
||||||
|
{
|
||||||
|
if (_umsel2)
|
||||||
|
{
|
||||||
|
//TODO _lms_ctrl[which]->set_rx_freq(freq);360Mhz and 400MHz
|
||||||
|
return _umsel2->set_rx_freq((which=="A")?1:2, freq);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return _lms_ctrl[which]->set_rx_freq(freq);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uhd::sensor_value_t umtrx_impl::read_temp_c(const std::string &which)
|
uhd::sensor_value_t umtrx_impl::read_temp_c(const std::string &which)
|
||||||
{
|
{
|
||||||
boost::recursive_mutex::scoped_lock l(_i2c_mutex);
|
boost::recursive_mutex::scoped_lock l(_i2c_mutex);
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
#include "ads1015_ctrl.hpp"
|
#include "ads1015_ctrl.hpp"
|
||||||
#include "tmp102_ctrl.hpp"
|
#include "tmp102_ctrl.hpp"
|
||||||
#include "power_amp.hpp"
|
#include "power_amp.hpp"
|
||||||
|
#include "umsel2_ctrl.hpp"
|
||||||
#include <uhd/usrp/mboard_eeprom.hpp>
|
#include <uhd/usrp/mboard_eeprom.hpp>
|
||||||
#include <uhd/property_tree.hpp>
|
#include <uhd/property_tree.hpp>
|
||||||
#include <uhd/device.hpp>
|
#include <uhd/device.hpp>
|
||||||
@@ -152,6 +153,7 @@ private:
|
|||||||
std::string _device_ip_addr;
|
std::string _device_ip_addr;
|
||||||
umtrx_iface::sptr _iface;
|
umtrx_iface::sptr _iface;
|
||||||
umtrx_fifo_ctrl::sptr _ctrl;
|
umtrx_fifo_ctrl::sptr _ctrl;
|
||||||
|
umsel2_ctrl::sptr _umsel2;
|
||||||
|
|
||||||
//controls for perifs
|
//controls for perifs
|
||||||
uhd::dict<std::string, lms6002d_ctrl::sptr> _lms_ctrl;
|
uhd::dict<std::string, lms6002d_ctrl::sptr> _lms_ctrl;
|
||||||
@@ -195,6 +197,7 @@ private:
|
|||||||
uhd::transport::zero_copy_if::sptr make_xport(const size_t which, const uhd::device_addr_t &args);
|
uhd::transport::zero_copy_if::sptr make_xport(const size_t which, const uhd::device_addr_t &args);
|
||||||
std::complex<double> get_dc_offset_correction(const std::string &which) const;
|
std::complex<double> get_dc_offset_correction(const std::string &which) const;
|
||||||
void set_dc_offset_correction(const std::string &which, const std::complex<double> &corr);
|
void set_dc_offset_correction(const std::string &which, const std::complex<double> &corr);
|
||||||
|
double set_rx_freq(const std::string &which, const double freq);
|
||||||
|
|
||||||
static double dc_offset_int2double(uint8_t corr);
|
static double dc_offset_int2double(uint8_t corr);
|
||||||
static uint8_t dc_offset_double2int(double corr);
|
static uint8_t dc_offset_double2int(double corr);
|
||||||
|
@@ -104,6 +104,9 @@ localparam SR_SPI_CORE = 185; // 3
|
|||||||
#define U2_REG_TIME64_HI_RB_PPS READBACK_BASE + 4*14
|
#define U2_REG_TIME64_HI_RB_PPS READBACK_BASE + 4*14
|
||||||
#define U2_REG_TIME64_LO_RB_PPS READBACK_BASE + 4*15
|
#define U2_REG_TIME64_LO_RB_PPS READBACK_BASE + 4*15
|
||||||
|
|
||||||
|
#define AUX_LD1_IRQ_BIT (1 << 14)
|
||||||
|
#define AUX_LD2_IRQ_BIT (1 << 15)
|
||||||
|
|
||||||
/////////////////////////////////////////////////
|
/////////////////////////////////////////////////
|
||||||
// LMS regs
|
// LMS regs
|
||||||
////////////////////////////////////////////////
|
////////////////////////////////////////////////
|
||||||
|
Reference in New Issue
Block a user