aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/common/ad9361_ctrl.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp/common/ad9361_ctrl.hpp')
-rw-r--r--host/lib/usrp/common/ad9361_ctrl.hpp62
1 files changed, 15 insertions, 47 deletions
diff --git a/host/lib/usrp/common/ad9361_ctrl.hpp b/host/lib/usrp/common/ad9361_ctrl.hpp
index 098b5dae8..93d697349 100644
--- a/host/lib/usrp/common/ad9361_ctrl.hpp
+++ b/host/lib/usrp/common/ad9361_ctrl.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2012-2013 Ettus Research LLC
+// Copyright 2012-2014 Ettus Research 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
@@ -19,61 +19,27 @@
#define INCLUDED_AD9361_CTRL_HPP
#include <uhd/transport/zero_copy.hpp>
-#include <uhd/types/serial.hpp>
#include <uhd/types/ranges.hpp>
+#include <uhd/types/serial.hpp>
#include <boost/shared_ptr.hpp>
-#include <boost/utility.hpp>
-#include <boost/function.hpp>
-#include <vector>
+#include <ad9361_device.h>
#include <string>
-#include "ad9361_transaction.h"
-
+namespace uhd { namespace usrp {
-static const double AD9361_CLOCK_RATE_MAX = 61.44e6;
-static const double AD9361_1_CHAN_CLOCK_RATE_MAX = AD9361_CLOCK_RATE_MAX;
-static const double AD9361_2_CHAN_CLOCK_RATE_MAX = (AD9361_1_CHAN_CLOCK_RATE_MAX / 2);
-
-
-struct ad9361_ctrl_iface_type
+/***********************************************************************
+ * AD9361 Control Interface
+ **********************************************************************/
+class ad9361_ctrl : public boost::noncopyable
{
- virtual void ad9361_transact(const unsigned char in_buff[AD9361_DISPATCH_PACKET_SIZE], unsigned char out_buff[AD9361_DISPATCH_PACKET_SIZE]) = 0;
-};
-typedef boost::shared_ptr<ad9361_ctrl_iface_type> ad9361_ctrl_iface_sptr;
-
-
-struct ad9361_ctrl_over_zc : ad9361_ctrl_iface_type
-{
- ad9361_ctrl_over_zc(uhd::transport::zero_copy_if::sptr xport)
- {
- _xport = xport;
- }
-
- void ad9361_transact(const unsigned char in_buff[AD9361_DISPATCH_PACKET_SIZE], unsigned char out_buff[AD9361_DISPATCH_PACKET_SIZE])
- {
- {
- uhd::transport::managed_send_buffer::sptr buff = _xport->get_send_buff(10.0);
- if (not buff or buff->size() < AD9361_DISPATCH_PACKET_SIZE) throw std::runtime_error("ad9361_ctrl_over_zc send timeout");
- std::memcpy(buff->cast<void *>(), in_buff, AD9361_DISPATCH_PACKET_SIZE);
- buff->commit(AD9361_DISPATCH_PACKET_SIZE);
- }
- {
- uhd::transport::managed_recv_buffer::sptr buff = _xport->get_recv_buff(10.0);
- if (not buff or buff->size() < AD9361_DISPATCH_PACKET_SIZE) throw std::runtime_error("ad9361_ctrl_over_zc recv timeout");
- std::memcpy(out_buff, buff->cast<const void *>(), AD9361_DISPATCH_PACKET_SIZE);
- }
- }
-
- uhd::transport::zero_copy_if::sptr _xport;
-};
-
-
-class ad9361_ctrl : boost::noncopyable{
public:
typedef boost::shared_ptr<ad9361_ctrl> sptr;
+ virtual ~ad9361_ctrl(void) {};
+
//! make a new codec control object
- static sptr make(ad9361_ctrl_iface_sptr iface);
+ static sptr make_spi(
+ ad9361_params::sptr client_settings, uhd::spi_iface::sptr spi_iface, boost::uint32_t slave_num);
//! Get a list of gain names for RX or TX
static std::vector<std::string> get_gain_names(const std::string &/*which*/)
@@ -107,7 +73,7 @@ public:
static uhd::meta_range_t get_clock_rate_range(void)
{
//return uhd::meta_range_t(220e3, 61.44e6);
- return uhd::meta_range_t(5e6, AD9361_CLOCK_RATE_MAX); //5 MHz DCM low end
+ return uhd::meta_range_t(5e6, ad9361_device_t::AD9361_MAX_CLOCK_RATE); //5 MHz DCM low end
}
//! set the filter bandwidth for the frontend
@@ -132,4 +98,6 @@ public:
virtual void data_port_loopback(const bool on) = 0;
};
+}}
+
#endif /* INCLUDED_AD9361_CTRL_HPP */