aboutsummaryrefslogtreecommitdiffstats
path: root/mpm
diff options
context:
space:
mode:
Diffstat (limited to 'mpm')
-rw-r--r--mpm/include/mpm/ad9361/ad9361_ctrl.hpp30
-rw-r--r--mpm/include/mpm/ad9361/e320_defaults.hpp33
-rw-r--r--mpm/include/mpm/ad937x/ad937x_ctrl.hpp201
-rw-r--r--mpm/include/mpm/ad937x/ad937x_ctrl_types.hpp74
-rw-r--r--mpm/include/mpm/ad937x/ad937x_spi_iface.hpp13
-rw-r--r--mpm/include/mpm/ad937x/adi_ctrl.hpp9
-rw-r--r--mpm/include/mpm/dboards/magnesium_manager.hpp53
-rw-r--r--mpm/include/mpm/dboards/neon_manager.hpp29
-rw-r--r--mpm/include/mpm/exception.hpp264
-rw-r--r--mpm/include/mpm/i2c/i2c_iface.hpp83
-rw-r--r--mpm/include/mpm/i2c/i2c_python.hpp26
-rw-r--r--mpm/include/mpm/i2c/i2c_regs_iface.hpp33
-rw-r--r--mpm/include/mpm/spi/spi_iface.hpp68
-rw-r--r--mpm/include/mpm/spi/spi_python.hpp14
-rw-r--r--mpm/include/mpm/spi/spi_regs_iface.hpp35
-rw-r--r--mpm/include/mpm/tests/tests_spi_iface.hpp77
-rw-r--r--mpm/include/mpm/types/lockable.hpp39
-rw-r--r--mpm/include/mpm/types/log_buf.hpp117
-rw-r--r--mpm/include/mpm/types/mmap_regs_iface.hpp77
-rw-r--r--mpm/include/mpm/types/regs_iface.hpp57
-rw-r--r--mpm/include/mpm/types/types_python.hpp46
-rw-r--r--mpm/include/mpm/xbar_iface.hpp30
-rw-r--r--mpm/lib/dboards/magnesium_manager.cpp20
-rw-r--r--mpm/lib/dboards/neon_manager.cpp27
-rw-r--r--mpm/lib/exception.cpp53
-rw-r--r--mpm/lib/i2c/i2c_regs_iface.cpp75
-rw-r--r--mpm/lib/i2c/i2cdev_iface.cpp78
-rw-r--r--mpm/lib/mykonos/ad937x_ctrl.cpp342
-rw-r--r--mpm/lib/mykonos/ad937x_device.cpp767
-rw-r--r--mpm/lib/mykonos/ad937x_device.hpp120
-rw-r--r--mpm/lib/mykonos/ad937x_device_types.hpp45
-rw-r--r--mpm/lib/mykonos/ad937x_spi_iface.cpp17
-rw-r--r--mpm/lib/mykonos/adi_ctrl.cpp169
-rw-r--r--mpm/lib/mykonos/config/ad937x_config_t.cpp521
-rw-r--r--mpm/lib/mykonos/config/ad937x_config_t.hpp9
-rw-r--r--mpm/lib/mykonos/config/ad937x_default_config.hpp656
-rw-r--r--mpm/lib/mykonos/config/ad937x_fir.cpp29
-rw-r--r--mpm/lib/mykonos/config/ad937x_fir.hpp3
-rw-r--r--mpm/lib/mykonos/config/ad937x_gain_ctrl_config.cpp215
-rw-r--r--mpm/lib/mykonos/config/ad937x_gain_ctrl_config.hpp39
-rw-r--r--mpm/lib/spi/spi_regs_iface.cpp98
-rw-r--r--mpm/lib/spi/spidev_iface.cpp83
-rw-r--r--mpm/lib/types/lockable.cpp14
-rw-r--r--mpm/lib/types/log_buf.cpp28
-rw-r--r--mpm/lib/types/mmap_regs_iface.cpp56
-rw-r--r--mpm/lib/xbar_iface.cpp31
-rw-r--r--mpm/python/lib_helper.cpp22
-rw-r--r--mpm/python/pyusrp_periphs/converters.hpp89
-rw-r--r--mpm/python/pyusrp_periphs/e320/pyusrp_periphs.cpp21
-rw-r--r--mpm/python/pyusrp_periphs/n3xx/pyusrp_periphs.cpp23
-rw-r--r--mpm/python/tests_periphs.cpp19
-rw-r--r--mpm/tests/tests_device.hpp23
-rw-r--r--mpm/tests/tests_spi_iface.cpp98
53 files changed, 2585 insertions, 2613 deletions
diff --git a/mpm/include/mpm/ad9361/ad9361_ctrl.hpp b/mpm/include/mpm/ad9361/ad9361_ctrl.hpp
index f79502add..8bcd7f7c4 100644
--- a/mpm/include/mpm/ad9361/ad9361_ctrl.hpp
+++ b/mpm/include/mpm/ad9361/ad9361_ctrl.hpp
@@ -8,24 +8,24 @@
// Relative to uhd/host/lib/usrp/common/ad9361_driver/
#include "../../../include/uhdlib/usrp/common/ad9361_ctrl.hpp"
-
#include <boost/make_shared.hpp>
#include <boost/noncopyable.hpp>
-
#include <functional>
#include <string>
#include <vector>
namespace mpm { namespace chips {
- using uhd::usrp::ad9361_ctrl;
-}};
+using uhd::usrp::ad9361_ctrl;
+}}; // namespace mpm::chips
-//TODO: pull in filter_info_base
+// TODO: pull in filter_info_base
#ifdef LIBMPM_PYTHON
-void export_catalina(){
+void export_catalina()
+{
LIBMPM_BOOST_PREAMBLE("ad9361")
using namespace mpm::chips;
- bp::class_<ad9361_ctrl, boost::noncopyable, boost::shared_ptr<ad9361_ctrl>>("ad9361_ctrl", bp::no_init)
+ bp::class_<ad9361_ctrl, boost::noncopyable, boost::shared_ptr<ad9361_ctrl>>(
+ "ad9361_ctrl", bp::no_init)
.def("get_gain_names", &ad9361_ctrl::get_gain_names)
.staticmethod("get_gain_names")
// Make this "Python private" because the return value can't be serialized
@@ -51,19 +51,17 @@ void export_catalina(){
.def("set_iq_balance_auto", &ad9361_ctrl::set_iq_balance_auto)
.def("get_freq", &ad9361_ctrl::get_freq)
.def("data_port_loopback", &ad9361_ctrl::data_port_loopback)
- .def("get_rssi", +[](ad9361_ctrl& self, std::string which) {
- return self.get_rssi(which).to_real();
- })
- .def("get_temperature", +[](ad9361_ctrl& self) {
- return self.get_temperature().to_real();
- })
+ .def("get_rssi",
+ +[](ad9361_ctrl& self, std::string which) {
+ return self.get_rssi(which).to_real();
+ })
+ .def("get_temperature",
+ +[](ad9361_ctrl& self) { return self.get_temperature().to_real(); })
.def("get_filter_names", &ad9361_ctrl::get_filter_names)
// Make this "Python private" because the return value can't be serialized.
.def("_get_filter", &ad9361_ctrl::get_filter)
.def("set_filter", &ad9361_ctrl::set_filter)
- .def("output_digital_test_tone", &ad9361_ctrl::output_digital_test_tone)
- ;
+ .def("output_digital_test_tone", &ad9361_ctrl::output_digital_test_tone);
}
#endif
-
diff --git a/mpm/include/mpm/ad9361/e320_defaults.hpp b/mpm/include/mpm/ad9361/e320_defaults.hpp
index 558aed375..3ce510059 100644
--- a/mpm/include/mpm/ad9361/e320_defaults.hpp
+++ b/mpm/include/mpm/ad9361/e320_defaults.hpp
@@ -13,33 +13,42 @@ namespace mpm { namespace types { namespace e320 {
using namespace uhd::usrp;
-class e320_ad9361_client_t : public uhd::usrp::ad9361_params {
+class e320_ad9361_client_t : public uhd::usrp::ad9361_params
+{
public:
~e320_ad9361_client_t() {}
- double get_band_edge(frequency_band_t band) {
+ double get_band_edge(frequency_band_t band)
+ {
switch (band) {
- case AD9361_RX_BAND0: return 0.0;
- case AD9361_RX_BAND1: return 2.6e9;
- case AD9361_TX_BAND0: return 2940.0e6;
- default: return 0;
+ case AD9361_RX_BAND0:
+ return 0.0;
+ case AD9361_RX_BAND1:
+ return 2.6e9;
+ case AD9361_TX_BAND0:
+ return 2940.0e6;
+ default:
+ return 0;
}
}
- clocking_mode_t get_clocking_mode() {
+ clocking_mode_t get_clocking_mode()
+ {
return clocking_mode_t::AD9361_XTAL_N_CLK_PATH;
}
- digital_interface_mode_t get_digital_interface_mode() {
+ digital_interface_mode_t get_digital_interface_mode()
+ {
return AD9361_DDR_FDD_LVDS;
}
- digital_interface_delays_t get_digital_interface_timing() {
+ digital_interface_delays_t get_digital_interface_timing()
+ {
digital_interface_delays_t delays;
- delays.rx_clk_delay = 0;
+ delays.rx_clk_delay = 0;
delays.rx_data_delay = 0;
- delays.tx_clk_delay = 0;
+ delays.tx_clk_delay = 0;
delays.tx_data_delay = 0;
return delays;
}
};
-}}} // namespace
+}}} // namespace mpm::types::e320
#endif // INCLUDED_E320_DEFAULTS_HPP
diff --git a/mpm/include/mpm/ad937x/ad937x_ctrl.hpp b/mpm/include/mpm/ad937x/ad937x_ctrl.hpp
index 762bd2e0e..7274c433a 100644
--- a/mpm/include/mpm/ad937x/ad937x_ctrl.hpp
+++ b/mpm/include/mpm/ad937x/ad937x_ctrl.hpp
@@ -7,40 +7,36 @@
#pragma once
#include "ad937x_ctrl_types.hpp"
-
-#include <mpm/exception.hpp>
-#include <mpm/spi/spi_iface.hpp>
-
#include <uhd/types/direction.hpp>
#include <uhd/types/ranges.hpp>
-
+#include <mpm/exception.hpp>
+#include <mpm/spi/spi_iface.hpp>
#include <boost/noncopyable.hpp>
-
-#include <memory>
#include <functional>
-#include <set>
-#include <mutex>
#include <future>
+#include <memory>
+#include <mutex>
+#include <set>
namespace mpm { namespace chips {
/*! AD937x Control Interface
-*
-* A sane API for configuring AD937x chips.
-*
-* \section ad937x_which The `which` parameter
-*
-* Many function calls require a `which` string parameter to select
-* the RF frontend. Valid values for `which` are:
-* - RX1, RX2
-* - TX1, TX2
-*
-* Frontend numbering is as designed by the AD9371.
-*
-* While all functions that use `which` specify an individual channel,
-* certain functions affect more than one channel due to the limitations of
-* the AD9371.
-*/
+ *
+ * A sane API for configuring AD937x chips.
+ *
+ * \section ad937x_which The `which` parameter
+ *
+ * Many function calls require a `which` string parameter to select
+ * the RF frontend. Valid values for `which` are:
+ * - RX1, RX2
+ * - TX1, TX2
+ *
+ * Frontend numbering is as designed by the AD9371.
+ *
+ * While all functions that use `which` specify an individual channel,
+ * certain functions affect more than one channel due to the limitations of
+ * the AD9371.
+ */
class ad937x_ctrl : public boost::noncopyable
{
public:
@@ -55,7 +51,7 @@ public:
static const uint32_t FLASH_CAL;
static const uint32_t PATH_DELAY;
static const uint32_t TX_LO_LEAKAGE_INTERNAL;
- static const uint32_t TX_LO_LEAKAGE_EXTERNAL ;
+ static const uint32_t TX_LO_LEAKAGE_EXTERNAL;
static const uint32_t TX_QEC_INIT;
static const uint32_t LOOPBACK_RX_LO_DELAY;
static const uint32_t LOOPBACK_RX_RX_QEC_INIT;
@@ -95,40 +91,37 @@ public:
* \param iface the spi_iface for accessing the AD9371
* \param gain_pins a struct defining the usage of gain pins by this device
*/
- static sptr make(
- std::shared_ptr<std::mutex> spi_mutex,
+ static sptr make(std::shared_ptr<std::mutex> spi_mutex,
const size_t deserializer_lane_xbar,
mpm::types::regs_iface::sptr iface,
mpm::ad937x::gpio::gain_pins_t gain_pins);
virtual ~ad937x_ctrl(void) {}
- //! initializes the AD9371, checks basic functionality, and prepares the chip to receive a SYSREF pulse
+ //! initializes the AD9371, checks basic functionality, and prepares the chip to
+ //! receive a SYSREF pulse
virtual void begin_initialization() = 0;
- //! finishes initialization of the AD9371 by loading the ARM binary and setting a default RF configuration
+ //! finishes initialization of the AD9371 by loading the ARM binary and setting a
+ //! default RF configuration
virtual void finish_initialization() = 0;
/*! \setup initialization and tracking calibration
- *
- *\param init_cals_mask bit masking field for init calibration default to 0x4DFF
- * NOTE: this init cals mask need to be at least 0x4F.
- *\param tracking_cals_mask bit masking field for tracking calibration default to 0xC3
- *\param timeout init calibration timeout. default to 10s
- */
- virtual void setup_cal(
- const uint32_t init_cals_mask,
- const uint32_t tracking_cals_mask,
- const uint32_t timeout
- ) = 0;
+ *
+ *\param init_cals_mask bit masking field for init calibration default to 0x4DFF
+ * NOTE: this init cals mask need to be at least 0x4F.
+ *\param tracking_cals_mask bit masking field for tracking calibration default to 0xC3
+ *\param timeout init calibration timeout. default to 10s
+ */
+ virtual void setup_cal(const uint32_t init_cals_mask,
+ const uint32_t tracking_cals_mask,
+ const uint32_t timeout) = 0;
//! set LO source
virtual std::string set_lo_source(
- const std::string &which,
- const std::string &source
- ) = 0;
+ const std::string& which, const std::string& source) = 0;
//! get LO source
- virtual std::string get_lo_source(const std::string &which) = 0;
+ virtual std::string get_lo_source(const std::string& which) = 0;
//! resets and start the JESD deframer (JESD Rx, for RF Tx)
virtual void start_jesd_rx() = 0;
@@ -154,7 +147,8 @@ public:
//! get the ilas config status bytes, see AD9371 data sheet for more information
virtual uint16_t get_ilas_config_match() = 0;
- //! enable or disable JESD loopback, when enabled JESD Rx will be directly connected to JESD Tx
+ //! enable or disable JESD loopback, when enabled JESD Rx will be directly connected
+ //! to JESD Tx
virtual void enable_jesd_loopback(const uint8_t enable) = 0;
//! get the RF frequency range for the AD9371
@@ -167,7 +161,7 @@ public:
static std::vector<double> get_clock_rates(void);
//! get the gain range for a frontend (RX, TX)
- static uhd::meta_range_t get_gain_range(const std::string &which);
+ static uhd::meta_range_t get_gain_range(const std::string& which);
//! read the product ID from the device
virtual uint8_t get_product_id() = 0;
@@ -188,10 +182,7 @@ public:
virtual std::string get_arm_version() = 0;
//! set the BW filter for the frontend which
- virtual double set_bw_filter(
- const std::string &which,
- const double value
- ) = 0;
+ virtual double set_bw_filter(const std::string& which, const double value) = 0;
/*! \brief set the gain for the frontend which
*
@@ -199,21 +190,21 @@ public:
* \param value target gain value
* \return actual gain value
*/
- virtual double set_gain(const std::string &which, const double value) = 0;
+ virtual double set_gain(const std::string& which, const double value) = 0;
/*! \brief get the gain for the frontend which
- *
- * \param which frontend string
- * \return actual gain value
- */
- virtual double get_gain(const std::string &which) = 0;
+ *
+ * \param which frontend string
+ * \return actual gain value
+ */
+ virtual double get_gain(const std::string& which) = 0;
/*! \brief set the agc mode for all RX channels
*
* \param which frontend string
* \param mode requested mode (automatic, manual, hybrid)
*/
- virtual void set_agc_mode(const std::string &which, const std::string &mode) = 0;
+ virtual void set_agc_mode(const std::string& which, const std::string& mode) = 0;
/*! \brief set the clock rate for the device
*
@@ -223,7 +214,7 @@ public:
virtual double set_clock_rate(double value) = 0;
//! enable the frontend which
- virtual void enable_channel(const std::string &which, const bool enable) = 0;
+ virtual void enable_channel(const std::string& which, const bool enable) = 0;
/*! \brief set the RF frequency for the direction specified in which
* Sets the RF frequency. This is a per direction setting.
@@ -233,10 +224,7 @@ public:
* \return actual frequency
*/
virtual double set_freq(
- const std::string &which,
- const double value,
- const bool wait_for_lock
- ) = 0;
+ const std::string& which, const double value, const bool wait_for_lock) = 0;
/*! \brief get the RF frequency for the direction specified in which
*
@@ -244,7 +232,7 @@ public:
* \param which frontend string to specify direction to get
* \return actual frequency
*/
- virtual double get_freq(const std::string &which) = 0;
+ virtual double get_freq(const std::string& which) = 0;
/*! \brief Returns the LO lock status
*
@@ -253,40 +241,28 @@ public:
* This does not check the PLL lock status for the main clock, the sniffer,
* or the CAL PLL.
*/
- virtual bool get_lo_locked(const std::string &which) = 0;
+ virtual bool get_lo_locked(const std::string& which) = 0;
//! set master clock rate
virtual void set_master_clock_rate(const double rate) = 0;
//! set the FIR filter for the frontend which
virtual void set_fir(
- const std::string &which,
- const int8_t gain,
- const std::vector<int16_t> & fir
- ) = 0;
+ const std::string& which, const int8_t gain, const std::vector<int16_t>& fir) = 0;
//! get the FIR filter for the frontend which
- virtual std::vector<int16_t> get_fir(
- const std::string &which,
- int8_t &gain
- ) = 0;
+ virtual std::vector<int16_t> get_fir(const std::string& which, int8_t& gain) = 0;
// TODO: update docstring with temperature unit and calibration information
//! get the device temperature
virtual int16_t get_temperature() = 0;
//! enable or disable gain ctrl pins for one channel
- virtual void set_enable_gain_pins(
- const std::string &which,
- const bool enable
- ) = 0;
+ virtual void set_enable_gain_pins(const std::string& which, const bool enable) = 0;
//! set step sizes for gain ctrl pins for one channel
virtual void set_gain_pin_step_sizes(
- const std::string &which,
- double inc_step,
- double dec_step
- ) = 0;
+ const std::string& which, double inc_step, double dec_step) = 0;
//! Direct register read access
virtual uint8_t peek8(const uint32_t addr) = 0;
@@ -298,54 +274,51 @@ public:
}}; /* namespace mpm::chips */
#ifdef LIBMPM_PYTHON
-void export_mykonos(){
+void export_mykonos()
+{
LIBMPM_BOOST_PREAMBLE("ad937x")
using namespace mpm::chips;
- bp::class_<ad937x_ctrl, boost::noncopyable, std::shared_ptr<ad937x_ctrl>>("ad937x_ctrl", bp::no_init)
+ bp::class_<ad937x_ctrl, boost::noncopyable, std::shared_ptr<ad937x_ctrl>>(
+ "ad937x_ctrl", bp::no_init)
.def("set_master_clock_rate", &ad937x_ctrl::set_master_clock_rate)
.def("begin_initialization", &ad937x_ctrl::begin_initialization)
- .def("async__finish_initialization", +[](
- ad937x_ctrl& self
- ){
- self.handle_finish_initialization = std::async(std::launch::async,
- &ad937x_ctrl::finish_initialization,
- &self
- );
- })
- .def("await__finish_initialization", +[](
- ad937x_ctrl& self
- )->bool{
- if (self.handle_finish_initialization.wait_for(std::chrono::seconds(0)) == std::future_status::ready){
+ .def("async__finish_initialization",
+ +[](ad937x_ctrl& self) {
+ self.handle_finish_initialization = std::async(
+ std::launch::async, &ad937x_ctrl::finish_initialization, &self);
+ })
+ .def("await__finish_initialization",
+ +[](ad937x_ctrl& self) -> bool {
+ if (self.handle_finish_initialization.wait_for(std::chrono::seconds(0))
+ == std::future_status::ready) {
self.handle_finish_initialization.get();
return true;
}
return false;
- })
+ })
.def("set_lo_source", &ad937x_ctrl::set_lo_source)
.def("get_lo_source", &ad937x_ctrl::get_lo_source)
- .def("async__setup_cal", +[](
- ad937x_ctrl& self,
- const uint32_t init_cals_mask,
- const uint32_t timeout,
- const uint32_t tracking_cals_mask
- ){
+ .def("async__setup_cal",
+ +[](ad937x_ctrl& self,
+ const uint32_t init_cals_mask,
+ const uint32_t timeout,
+ const uint32_t tracking_cals_mask) {
self.handle_setup_cal = std::async(std::launch::async,
&ad937x_ctrl::setup_cal,
&self,
init_cals_mask,
timeout,
- tracking_cals_mask
- );
- })
- .def("await__setup_cal", +[](
- ad937x_ctrl& self
- )->bool{
- if (self.handle_setup_cal.wait_for(std::chrono::seconds(0)) == std::future_status::ready){
+ tracking_cals_mask);
+ })
+ .def("await__setup_cal",
+ +[](ad937x_ctrl& self) -> bool {
+ if (self.handle_setup_cal.wait_for(std::chrono::seconds(0))
+ == std::future_status::ready) {
self.handle_setup_cal.get();
return true;
}
return false;
- })
+ })
.def("start_jesd_rx", &ad937x_ctrl::start_jesd_rx)
.def("start_jesd_tx", &ad937x_ctrl::start_jesd_tx)
.def("start_radio", &ad937x_ctrl::start_radio)
@@ -411,9 +384,9 @@ void export_mykonos(){
.def_readonly("TRACK_ORX2_QEC_SNLO", &ad937x_ctrl::TRACK_ORX2_QEC_SNLO)
.def_readonly("TRACK_SRX_QEC", &ad937x_ctrl::TRACK_SRX_QEC)
.def_readonly("DEFAULT_INIT_CALS_MASKS", &ad937x_ctrl::DEFAULT_INIT_CALS_MASKS)
- .def_readonly("DEFAULT_TRACKING_CALS_MASKS", &ad937x_ctrl::DEFAULT_TRACKING_CALS_MASKS)
- .def_readonly("DEFAULT_INIT_CALS_TIMEOUT", &ad937x_ctrl::DEFAULT_INIT_CALS_TIMEOUT)
- ;
+ .def_readonly(
+ "DEFAULT_TRACKING_CALS_MASKS", &ad937x_ctrl::DEFAULT_TRACKING_CALS_MASKS)
+ .def_readonly(
+ "DEFAULT_INIT_CALS_TIMEOUT", &ad937x_ctrl::DEFAULT_INIT_CALS_TIMEOUT);
}
#endif
-
diff --git a/mpm/include/mpm/ad937x/ad937x_ctrl_types.hpp b/mpm/include/mpm/ad937x/ad937x_ctrl_types.hpp
index 89c539739..3f308e361 100644
--- a/mpm/include/mpm/ad937x/ad937x_ctrl_types.hpp
+++ b/mpm/include/mpm/ad937x/ad937x_ctrl_types.hpp
@@ -6,43 +6,39 @@
#pragma once
-namespace mpm {
- namespace ad937x {
- namespace gpio {
- enum class gain_pin_t {
- NONE,
- PIN0,
- PIN1,
- PIN2,
- PIN3,
- PIN4,
- PIN5,
- PIN6,
- PIN7,
- PIN8,
- PIN9,
- PIN10,
- PIN11,
- PIN12,
- PIN13,
- PIN14,
- PIN15,
- PIN16,
- PIN17,
- PIN18,
- };
+namespace mpm { namespace ad937x { namespace gpio {
+enum class gain_pin_t {
+ NONE,
+ PIN0,
+ PIN1,
+ PIN2,
+ PIN3,
+ PIN4,
+ PIN5,
+ PIN6,
+ PIN7,
+ PIN8,
+ PIN9,
+ PIN10,
+ PIN11,
+ PIN12,
+ PIN13,
+ PIN14,
+ PIN15,
+ PIN16,
+ PIN17,
+ PIN18,
+};
- struct gain_pins_t
- {
- gain_pin_t rx1_inc_gain_pin;
- gain_pin_t rx1_dec_gain_pin;
- gain_pin_t rx2_inc_gain_pin;
- gain_pin_t rx2_dec_gain_pin;
- gain_pin_t tx1_inc_gain_pin;
- gain_pin_t tx1_dec_gain_pin;
- gain_pin_t tx2_inc_gain_pin;
- gain_pin_t tx2_dec_gain_pin;
- };
- }
- }
-}
+struct gain_pins_t
+{
+ gain_pin_t rx1_inc_gain_pin;
+ gain_pin_t rx1_dec_gain_pin;
+ gain_pin_t rx2_inc_gain_pin;
+ gain_pin_t rx2_dec_gain_pin;
+ gain_pin_t tx1_inc_gain_pin;
+ gain_pin_t tx1_dec_gain_pin;
+ gain_pin_t tx2_inc_gain_pin;
+ gain_pin_t tx2_dec_gain_pin;
+};
+}}} // namespace mpm::ad937x::gpio
diff --git a/mpm/include/mpm/ad937x/ad937x_spi_iface.hpp b/mpm/include/mpm/ad937x/ad937x_spi_iface.hpp
index 042c55265..26a51e20b 100644
--- a/mpm/include/mpm/ad937x/ad937x_spi_iface.hpp
+++ b/mpm/include/mpm/ad937x/ad937x_spi_iface.hpp
@@ -10,13 +10,10 @@
namespace mpm { namespace chips {
- /*! Return a peek/poke interface to the LMK04828
- *
- * Assumption is it is attached to a spidev
- */
- mpm::types::regs_iface::sptr make_ad937x_iface(
- const std::string &spi_device
- );
+/*! Return a peek/poke interface to the LMK04828
+ *
+ * Assumption is it is attached to a spidev
+ */
+mpm::types::regs_iface::sptr make_ad937x_iface(const std::string& spi_device);
}}; /* namespace mpm::chips */
-
diff --git a/mpm/include/mpm/ad937x/adi_ctrl.hpp b/mpm/include/mpm/ad937x/adi_ctrl.hpp
index f6b8aa89b..caf8ad191 100644
--- a/mpm/include/mpm/ad937x/adi_ctrl.hpp
+++ b/mpm/include/mpm/ad937x/adi_ctrl.hpp
@@ -11,8 +11,9 @@
struct ad9371_spiSettings_t
{
- static ad9371_spiSettings_t* make(spiSettings_t *sps) {
- return reinterpret_cast<ad9371_spiSettings_t *>(sps);
+ static ad9371_spiSettings_t* make(spiSettings_t* sps)
+ {
+ return reinterpret_cast<ad9371_spiSettings_t*>(sps);
}
explicit ad9371_spiSettings_t(mpm::types::regs_iface*);
@@ -25,9 +26,7 @@ struct ad9371_spiSettings_t
std::chrono::microseconds timeout_duration;
};
-enum ad9371_spi_errors_t : uint32_t
-{
+enum ad9371_spi_errors_t : uint32_t {
SPI_READ_ERROR = 4096,
SPI_WRITE_ERROR = 4097,
};
-
diff --git a/mpm/include/mpm/dboards/magnesium_manager.hpp b/mpm/include/mpm/dboards/magnesium_manager.hpp
index 200de90b3..ab2a20864 100644
--- a/mpm/include/mpm/dboards/magnesium_manager.hpp
+++ b/mpm/include/mpm/dboards/magnesium_manager.hpp
@@ -6,47 +6,52 @@
#pragma once
+#include <mpm/ad937x/ad937x_ctrl.hpp>
#include <mpm/types/lockable.hpp>
#include <mpm/types/regs_iface.hpp>
-#include <mpm/ad937x/ad937x_ctrl.hpp>
#include <memory>
#include <mutex>
namespace mpm { namespace dboards {
- class magnesium_manager// : public dboard_periph_manager
+class magnesium_manager // : public dboard_periph_manager
+{
+public:
+ magnesium_manager(
+ const std::string& mykonos_spidev, const size_t deserializer_lane_xbar);
+
+ /*! Return a reference to the SPI mutex
+ */
+ mpm::types::lockable::sptr get_spi_lock()
{
- public:
- magnesium_manager(
- const std::string &mykonos_spidev,
- const size_t deserializer_lane_xbar
- );
+ return _spi_lock;
+ }
- /*! Return a reference to the SPI mutex
- */
- mpm::types::lockable::sptr get_spi_lock() { return _spi_lock; }
-
- /*! Return a reference to the radio chip controls
- */
- mpm::chips::ad937x_ctrl::sptr get_radio_ctrl(){ return _mykonos_ctrl; }
+ /*! Return a reference to the radio chip controls
+ */
+ mpm::chips::ad937x_ctrl::sptr get_radio_ctrl()
+ {
+ return _mykonos_ctrl;
+ }
- private:
- std::shared_ptr<std::mutex> _spi_mutex;
+private:
+ std::shared_ptr<std::mutex> _spi_mutex;
- // TODO: cpld control, or maybe it goes into Python
+ // TODO: cpld control, or maybe it goes into Python
- mpm::types::lockable::sptr _spi_lock;
- mpm::chips::ad937x_ctrl::sptr _mykonos_ctrl;
- };
+ mpm::types::lockable::sptr _spi_lock;
+ mpm::chips::ad937x_ctrl::sptr _mykonos_ctrl;
+};
}}; /* namespace mpm::dboards */
#ifdef LIBMPM_PYTHON
-void export_magnesium(){
+void export_magnesium()
+{
LIBMPM_BOOST_PREAMBLE("dboards")
using namespace mpm::dboards;
- bp::class_<mpm::dboards::magnesium_manager>("magnesium_manager", bp::init<std::string,size_t>())
+ bp::class_<mpm::dboards::magnesium_manager>(
+ "magnesium_manager", bp::init<std::string, size_t>())
.def("get_spi_lock", &mpm::dboards::magnesium_manager::get_spi_lock)
- .def("get_radio_ctrl", &mpm::dboards::magnesium_manager::get_radio_ctrl)
- ;
+ .def("get_radio_ctrl", &mpm::dboards::magnesium_manager::get_radio_ctrl);
}
#endif
diff --git a/mpm/include/mpm/dboards/neon_manager.hpp b/mpm/include/mpm/dboards/neon_manager.hpp
index 706dbe7c4..580b9cd38 100644
--- a/mpm/include/mpm/dboards/neon_manager.hpp
+++ b/mpm/include/mpm/dboards/neon_manager.hpp
@@ -14,27 +14,30 @@
#include <mutex>
namespace mpm { namespace dboards {
- class neon_manager// : public dboard_periph_manager
- {
- public:
- neon_manager(const std::string &catalina_spidev);
+class neon_manager // : public dboard_periph_manager
+{
+public:
+ neon_manager(const std::string& catalina_spidev);
- /*! Return a reference to the radio chip controls
- */
- mpm::chips::ad9361_ctrl::sptr get_radio_ctrl(){ return _catalina_ctrl; }
+ /*! Return a reference to the radio chip controls
+ */
+ mpm::chips::ad9361_ctrl::sptr get_radio_ctrl()
+ {
+ return _catalina_ctrl;
+ }
- private:
- mpm::chips::ad9361_ctrl::sptr _catalina_ctrl;
- };
+private:
+ mpm::chips::ad9361_ctrl::sptr _catalina_ctrl;
+};
}}; /* namespace mpm::dboards */
#ifdef LIBMPM_PYTHON
-void export_neon(){
+void export_neon()
+{
LIBMPM_BOOST_PREAMBLE("dboards")
using namespace mpm::dboards;
bp::class_<mpm::dboards::neon_manager>("neon_manager", bp::init<std::string>())
- .def("get_radio_ctrl", &mpm::dboards::neon_manager::get_radio_ctrl)
- ;
+ .def("get_radio_ctrl", &mpm::dboards::neon_manager::get_radio_ctrl);
}
#endif
diff --git a/mpm/include/mpm/exception.hpp b/mpm/include/mpm/exception.hpp
index 876ca7714..15a4a2f11 100644
--- a/mpm/include/mpm/exception.hpp
+++ b/mpm/include/mpm/exception.hpp
@@ -11,131 +11,145 @@
namespace mpm {
- struct exception : std::runtime_error{
- exception(const std::string &what);
- virtual unsigned code(void) const = 0;
- virtual exception *dynamic_clone(void) const = 0;
- virtual void dynamic_throw(void) const = 0;
- };
-
- struct assertion_error : exception{
- assertion_error(const std::string &what);
- virtual unsigned code(void) const;
- virtual assertion_error *dynamic_clone(void) const;
- virtual void dynamic_throw(void) const;
- };
-
- struct lookup_error : exception{
- lookup_error(const std::string &what);
- virtual unsigned code(void) const;
- virtual lookup_error *dynamic_clone(void) const;
- virtual void dynamic_throw(void) const;
- };
-
- struct index_error : lookup_error{
- index_error(const std::string &what);
- virtual unsigned code(void) const;
- virtual index_error *dynamic_clone(void) const;
- virtual void dynamic_throw(void) const;
- };
-
- struct key_error : lookup_error{
- key_error(const std::string &what);
- virtual unsigned code(void) const;
- virtual key_error *dynamic_clone(void) const;
- virtual void dynamic_throw(void) const;
- };
-
- struct type_error : exception{
- type_error(const std::string &what);
- virtual unsigned code(void) const;
- virtual type_error *dynamic_clone(void) const;
- virtual void dynamic_throw(void) const;
- };
-
- struct value_error : exception{
- value_error(const std::string &what);
- virtual unsigned code(void) const;
- virtual value_error *dynamic_clone(void) const;
- virtual void dynamic_throw(void) const;
- };
-
- struct runtime_error : exception{
- runtime_error(const std::string &what);
- virtual unsigned code(void) const;
- virtual runtime_error *dynamic_clone(void) const;
- virtual void dynamic_throw(void) const;
- };
-
- struct not_implemented_error : runtime_error{
- not_implemented_error(const std::string &what);
- virtual unsigned code(void) const;
- virtual not_implemented_error *dynamic_clone(void) const;
- virtual void dynamic_throw(void) const;
- };
-
- struct environment_error : exception{
- environment_error(const std::string &what);
- virtual unsigned code(void) const;
- virtual environment_error *dynamic_clone(void) const;
- virtual void dynamic_throw(void) const;
- };
-
- struct io_error : environment_error{
- io_error(const std::string &what);
- virtual unsigned code(void) const;
- virtual io_error *dynamic_clone(void) const;
- virtual void dynamic_throw(void) const;
- };
-
- struct os_error : environment_error{
- os_error(const std::string &what);
- virtual unsigned code(void) const;
- virtual os_error *dynamic_clone(void) const;
- virtual void dynamic_throw(void) const;
- };
-
- struct system_error : exception{
- system_error(const std::string &what);
- virtual unsigned code(void) const;
- virtual system_error *dynamic_clone(void) const;
- virtual void dynamic_throw(void) const;
- };
-
- struct syntax_error : exception{
- syntax_error(const std::string &what);
- virtual unsigned code(void) const;
- virtual syntax_error *dynamic_clone(void) const;
- virtual void dynamic_throw(void) const;
- };
-
- /*!
- * Create a formatted string with throw-site information.
- * Fills in the function name, file name, and line number.
- * \param what the std::exception message
- * \return the formatted exception message
- */
- #define MPM_THROW_SITE_INFO(what) std::string( \
- std::string(what) + "\n" + \
- " in " + std::string(__PRETTY_FUNCTION__) + "\n" + \
- " at " + std::string(__FILE__) + ":" + BOOST_STRINGIZE(__LINE__) + "\n" \
- )
-
- /*!
- * Throws an invalid code path exception with throw-site information.
- * Use this macro in places that code execution is not supposed to go.
- */
- #define MPM_THROW_INVALID_CODE_PATH() \
- throw mpm::system_error(MPM_THROW_SITE_INFO("invalid code path"))
-
- /*!
- * Assert the result of the code evaluation.
- * If the code evaluates to false, throw an assertion error.
- * \param code the code that resolved to a boolean
- */
- #define MPM_ASSERT_THROW(code) {if (not (code)) \
- throw mpm::assertion_error(MPM_THROW_SITE_INFO(#code)); \
+struct exception : std::runtime_error
+{
+ exception(const std::string& what);
+ virtual unsigned code(void) const = 0;
+ virtual exception* dynamic_clone(void) const = 0;
+ virtual void dynamic_throw(void) const = 0;
+};
+
+struct assertion_error : exception
+{
+ assertion_error(const std::string& what);
+ virtual unsigned code(void) const;
+ virtual assertion_error* dynamic_clone(void) const;
+ virtual void dynamic_throw(void) const;
+};
+
+struct lookup_error : exception
+{
+ lookup_error(const std::string& what);
+ virtual unsigned code(void) const;
+ virtual lookup_error* dynamic_clone(void) const;
+ virtual void dynamic_throw(void) const;
+};
+
+struct index_error : lookup_error
+{
+ index_error(const std::string& what);
+ virtual unsigned code(void) const;
+ virtual index_error* dynamic_clone(void) const;
+ virtual void dynamic_throw(void) const;
+};
+
+struct key_error : lookup_error
+{
+ key_error(const std::string& what);
+ virtual unsigned code(void) const;
+ virtual key_error* dynamic_clone(void) const;
+ virtual void dynamic_throw(void) const;
+};
+
+struct type_error : exception
+{
+ type_error(const std::string& what);
+ virtual unsigned code(void) const;
+ virtual type_error* dynamic_clone(void) const;
+ virtual void dynamic_throw(void) const;
+};
+
+struct value_error : exception
+{
+ value_error(const std::string& what);
+ virtual unsigned code(void) const;
+ virtual value_error* dynamic_clone(void) const;
+ virtual void dynamic_throw(void) const;
+};
+
+struct runtime_error : exception
+{
+ runtime_error(const std::string& what);
+ virtual unsigned code(void) const;
+ virtual runtime_error* dynamic_clone(void) const;
+ virtual void dynamic_throw(void) const;
+};
+
+struct not_implemented_error : runtime_error
+{
+ not_implemented_error(const std::string& what);
+ virtual unsigned code(void) const;
+ virtual not_implemented_error* dynamic_clone(void) const;
+ virtual void dynamic_throw(void) const;
+};
+
+struct environment_error : exception
+{
+ environment_error(const std::string& what);
+ virtual unsigned code(void) const;
+ virtual environment_error* dynamic_clone(void) const;
+ virtual void dynamic_throw(void) const;
+};
+
+struct io_error : environment_error
+{
+ io_error(const std::string& what);
+ virtual unsigned code(void) const;
+ virtual io_error* dynamic_clone(void) const;
+ virtual void dynamic_throw(void) const;
+};
+
+struct os_error : environment_error
+{
+ os_error(const std::string& what);
+ virtual unsigned code(void) const;
+ virtual os_error* dynamic_clone(void) const;
+ virtual void dynamic_throw(void) const;
+};
+
+struct system_error : exception
+{
+ system_error(const std::string& what);
+ virtual unsigned code(void) const;
+ virtual system_error* dynamic_clone(void) const;
+ virtual void dynamic_throw(void) const;
+};
+
+struct syntax_error : exception
+{
+ syntax_error(const std::string& what);
+ virtual unsigned code(void) const;
+ virtual syntax_error* dynamic_clone(void) const;
+ virtual void dynamic_throw(void) const;
+};
+
+/*!
+ * Create a formatted string with throw-site information.
+ * Fills in the function name, file name, and line number.
+ * \param what the std::exception message
+ * \return the formatted exception message
+ */
+#define MPM_THROW_SITE_INFO(what) \
+ std::string(std::string(what) + "\n" + " in " + std::string(__PRETTY_FUNCTION__) \
+ + "\n" + " at " + std::string(__FILE__) + ":" \
+ + BOOST_STRINGIZE(__LINE__) + "\n")
+
+/*!
+ * Throws an invalid code path exception with throw-site information.
+ * Use this macro in places that code execution is not supposed to go.
+ */
+#define MPM_THROW_INVALID_CODE_PATH() \
+ throw mpm::system_error(MPM_THROW_SITE_INFO("invalid code path"))
+
+/*!
+ * Assert the result of the code evaluation.
+ * If the code evaluates to false, throw an assertion error.
+ * \param code the code that resolved to a boolean
+ */
+#define MPM_ASSERT_THROW(code) \
+ { \
+ if (not(code)) \
+ throw mpm::assertion_error(MPM_THROW_SITE_INFO(#code)); \
}
} /* namespace mpm */
-
diff --git a/mpm/include/mpm/i2c/i2c_iface.hpp b/mpm/include/mpm/i2c/i2c_iface.hpp
index e3fe9e8ed..c49a70b48 100644
--- a/mpm/include/mpm/i2c/i2c_iface.hpp
+++ b/mpm/include/mpm/i2c/i2c_iface.hpp
@@ -13,49 +13,46 @@
namespace mpm { namespace i2c {
- /*! Implementation of a uhd::i2c_iface that uses Linux's i2c-dev underneath.
+/*! Implementation of a uhd::i2c_iface that uses Linux's i2c-dev underneath.
+ */
+class i2c_iface : public boost::noncopyable
+{
+public:
+ using sptr = std::shared_ptr<i2c_iface>;
+
+ /*!
+ * \param bus The path to the i2c bus segment used (e.g. "/dev/i2c3")
+ * \param addr Address of the slave device on the bus segment
+ * \param ten_bit_addr Whether the slave device's address is 10 bits
+ * \param timeout_ms Time to wait for ACK from slave device
*/
- class i2c_iface : public boost::noncopyable
- {
- public:
- using sptr = std::shared_ptr<i2c_iface>;
-
- /*!
- * \param bus The path to the i2c bus segment used (e.g. "/dev/i2c3")
- * \param addr Address of the slave device on the bus segment
- * \param ten_bit_addr Whether the slave device's address is 10 bits
- * \param timeout_ms Time to wait for ACK from slave device
- */
- static sptr make_i2cdev(
- const std::string &bus,
- const uint16_t addr,
- const bool ten_bit_addr,
- const int timeout_ms
- );
-
- /*!
- * \param tx Buffer of data to send
- * \param tx_len Size (in bytes) of TX buffer
- * \param rx Buffer to hold read data
- * \param rx_len Number of bytes to read
- * \param do_close If true, close file descriptor at end of function
- */
- virtual int transfer(uint8_t *tx, size_t tx_len, uint8_t *rx,
- size_t rx_len, bool do_close = true) = 0;
-
- /*!
- * \param tx Buffer of data to send
- * \param rx Buffer to hold read data
- * \param do_close If true, close file descriptor at end of function
- *
- * All data in tx will be transmitted.
- * The amount of data read will be determined by the number of elements
- * in the rx vector. Those elements will be overwritten with the data.
- * Use the resize() function for a new rx vector.
- */
- virtual int transfer(std::vector<uint8_t> *tx, std::vector<uint8_t> *rx,
- bool do_close = true) = 0;
- };
+ static sptr make_i2cdev(const std::string& bus,
+ const uint16_t addr,
+ const bool ten_bit_addr,
+ const int timeout_ms);
+
+ /*!
+ * \param tx Buffer of data to send
+ * \param tx_len Size (in bytes) of TX buffer
+ * \param rx Buffer to hold read data
+ * \param rx_len Number of bytes to read
+ * \param do_close If true, close file descriptor at end of function
+ */
+ virtual int transfer(
+ uint8_t* tx, size_t tx_len, uint8_t* rx, size_t rx_len, bool do_close = true) = 0;
+
+ /*!
+ * \param tx Buffer of data to send
+ * \param rx Buffer to hold read data
+ * \param do_close If true, close file descriptor at end of function
+ *
+ * All data in tx will be transmitted.
+ * The amount of data read will be determined by the number of elements
+ * in the rx vector. Those elements will be overwritten with the data.
+ * Use the resize() function for a new rx vector.
+ */
+ virtual int transfer(
+ std::vector<uint8_t>* tx, std::vector<uint8_t>* rx, bool do_close = true) = 0;
+};
}}; /* namespace mpm::i2c */
-
diff --git a/mpm/include/mpm/i2c/i2c_python.hpp b/mpm/include/mpm/i2c/i2c_python.hpp
index d50b1d4d6..f358ea687 100644
--- a/mpm/include/mpm/i2c/i2c_python.hpp
+++ b/mpm/include/mpm/i2c/i2c_python.hpp
@@ -6,24 +6,24 @@
#pragma once
-#include "i2c_regs_iface.hpp"
#include "i2c_iface.hpp"
+#include "i2c_regs_iface.hpp"
-void export_i2c() {
+void export_i2c()
+{
LIBMPM_BOOST_PREAMBLE("i2c")
bp::def("make_i2cdev_regs_iface", &mpm::i2c::make_i2cdev_regs_iface);
-/*
- bp::def("make_i2cdev", &mpm::i2c::i2c_iface::make_i2cdev);
+ /*
+ bp::def("make_i2cdev", &mpm::i2c::i2c_iface::make_i2cdev);
- int (mpm::i2c::i2c_iface::*transfer_vec)(std::vector<uint8_t>*,
- std::vector<uint8_t>*) =
- &mpm::i2c::i2c_iface::transfer;
+ int (mpm::i2c::i2c_iface::*transfer_vec)(std::vector<uint8_t>*,
+ std::vector<uint8_t>*) =
+ &mpm::i2c::i2c_iface::transfer;
- bp::class_<mpm::i2c::i2c_iface, boost::noncopyable,
- std::shared_ptr<mpm::i2c::i2c_iface> >("i2c_iface", bp::no_init)
- .def("transfer", transfer_vec)
- ;
-*/
+ bp::class_<mpm::i2c::i2c_iface, boost::noncopyable,
+ std::shared_ptr<mpm::i2c::i2c_iface> >("i2c_iface", bp::no_init)
+ .def("transfer", transfer_vec)
+ ;
+ */
}
-
diff --git a/mpm/include/mpm/i2c/i2c_regs_iface.hpp b/mpm/include/mpm/i2c/i2c_regs_iface.hpp
index b63f00994..628a3bb10 100644
--- a/mpm/include/mpm/i2c/i2c_regs_iface.hpp
+++ b/mpm/include/mpm/i2c/i2c_regs_iface.hpp
@@ -6,29 +6,24 @@
#pragma once
-#include <mpm/types/regs_iface.hpp>
#include <mpm/i2c/i2c_iface.hpp>
+#include <mpm/types/regs_iface.hpp>
namespace mpm { namespace i2c {
- /*! The regs_iface class can only be used for certain i2c devices
- * For more control over the length of write and read data, use the lower-level
- * i2c_iface
- */
- mpm::types::regs_iface::sptr make_i2c_regs_iface(
- mpm::i2c::i2c_iface::sptr i2c_iface,
- const size_t reg_addr_size
- );
+/*! The regs_iface class can only be used for certain i2c devices
+ * For more control over the length of write and read data, use the lower-level
+ * i2c_iface
+ */
+mpm::types::regs_iface::sptr make_i2c_regs_iface(
+ mpm::i2c::i2c_iface::sptr i2c_iface, const size_t reg_addr_size);
- /*! Convenience factory for regs_iface based on i2c based on i2cdev
- */
- mpm::types::regs_iface::sptr make_i2cdev_regs_iface(
- const std::string &bus,
- const uint16_t addr,
- const bool ten_bit_addr,
- const int timeout_ms,
- const size_t reg_addr_size
- );
+/*! Convenience factory for regs_iface based on i2c based on i2cdev
+ */
+mpm::types::regs_iface::sptr make_i2cdev_regs_iface(const std::string& bus,
+ const uint16_t addr,
+ const bool ten_bit_addr,
+ const int timeout_ms,
+ const size_t reg_addr_size);
}}; /* namespace mpm::i2c */
-
diff --git a/mpm/include/mpm/spi/spi_iface.hpp b/mpm/include/mpm/spi/spi_iface.hpp
index c3e17c0f3..e295d1bb7 100644
--- a/mpm/include/mpm/spi/spi_iface.hpp
+++ b/mpm/include/mpm/spi/spi_iface.hpp
@@ -13,43 +13,35 @@
namespace mpm { namespace spi {
- /*! Implementation of a uhd::spi_iface that uses Linux' spidev underneath.
+/*! Implementation of a uhd::spi_iface that uses Linux' spidev underneath.
+ */
+class spi_iface : public boost::noncopyable
+{
+public:
+ using sptr = std::shared_ptr<spi_iface>;
+
+ /*! Convenience function: SPI xfer is 24 bits write, 8 bits read.
+ *
+ * \param data The write data for this xfer
+ *
+ * \return 8 bits worth of the return xfer
*/
- class spi_iface : public boost::noncopyable
- {
- public:
- using sptr = std::shared_ptr<spi_iface>;
-
- /*! Convenience function: SPI xfer is 24 bits write, 8 bits read.
- *
- * \param data The write data for this xfer
- *
- * \return 8 bits worth of the return xfer
- */
- virtual uint32_t transfer24_8(
- const uint32_t data
- ) = 0;
-
- /*! Convenience function: SPI xfer is 24 bits write, 16 bits read.
- *
- * \param data The write data for this xfer
- *
- * \return 16 bits worth of the return xfer
- */
- virtual uint32_t transfer24_16(
- const uint32_t data
- ) = 0;
-
- /*!
- * \param device The path to the spidev used (e.g. "/dev/spidev0.0")
- * \param speed_hz Transaction speed in Hz
- */
- static sptr make_spidev(
- const std::string &device,
- const int speed_hz,
- const int spi_mode=3
- );
- };
-
-}}; /* namespace mpm */
+ virtual uint32_t transfer24_8(const uint32_t data) = 0;
+ /*! Convenience function: SPI xfer is 24 bits write, 16 bits read.
+ *
+ * \param data The write data for this xfer
+ *
+ * \return 16 bits worth of the return xfer
+ */
+ virtual uint32_t transfer24_16(const uint32_t data) = 0;
+
+ /*!
+ * \param device The path to the spidev used (e.g. "/dev/spidev0.0")
+ * \param speed_hz Transaction speed in Hz
+ */
+ static sptr make_spidev(
+ const std::string& device, const int speed_hz, const int spi_mode = 3);
+};
+
+}}; // namespace mpm::spi
diff --git a/mpm/include/mpm/spi/spi_python.hpp b/mpm/include/mpm/spi/spi_python.hpp
index ab6a7a232..2b609c44a 100644
--- a/mpm/include/mpm/spi/spi_python.hpp
+++ b/mpm/include/mpm/spi/spi_python.hpp
@@ -6,18 +6,18 @@
#pragma once
-#include "spi_regs_iface.hpp"
#include "spi_iface.hpp"
+#include "spi_regs_iface.hpp"
-void export_spi() {
+void export_spi()
+{
LIBMPM_BOOST_PREAMBLE("spi")
bp::def("make_spidev_regs_iface", &mpm::spi::make_spidev_regs_iface);
bp::def("make_spidev", &mpm::spi::spi_iface::make_spidev);
- bp::class_<mpm::spi::spi_iface, boost::noncopyable, std::shared_ptr<mpm::spi::spi_iface> >("spi_iface", bp::no_init)
- .def("transfer24_8", &mpm::spi::spi_iface::transfer24_8)
- ;
-
+ bp::class_<mpm::spi::spi_iface,
+ boost::noncopyable,
+ std::shared_ptr<mpm::spi::spi_iface>>("spi_iface", bp::no_init)
+ .def("transfer24_8", &mpm::spi::spi_iface::transfer24_8);
}
-
diff --git a/mpm/include/mpm/spi/spi_regs_iface.hpp b/mpm/include/mpm/spi/spi_regs_iface.hpp
index a74d7ebb4..6351cf9b5 100644
--- a/mpm/include/mpm/spi/spi_regs_iface.hpp
+++ b/mpm/include/mpm/spi/spi_regs_iface.hpp
@@ -6,30 +6,25 @@
#pragma once
-#include <mpm/types/regs_iface.hpp>
#include <mpm/spi/spi_iface.hpp>
+#include <mpm/types/regs_iface.hpp>
namespace mpm { namespace spi {
- mpm::types::regs_iface::sptr make_spi_regs_iface(
- mpm::spi::spi_iface::sptr spi_iface,
- uint32_t addr_shift,
- uint32_t data_shift,
- uint32_t read_flags,
- uint32_t write_flags = 0
- );
+mpm::types::regs_iface::sptr make_spi_regs_iface(mpm::spi::spi_iface::sptr spi_iface,
+ uint32_t addr_shift,
+ uint32_t data_shift,
+ uint32_t read_flags,
+ uint32_t write_flags = 0);
- /*! Convenience factory for regs_iface based on SPI based on spidev
- */
- mpm::types::regs_iface::sptr make_spidev_regs_iface(
- const std::string &device,
- const int speed_hz,
- const int spi_mode,
- uint32_t addr_shift,
- uint32_t data_shift,
- uint32_t read_flags,
- uint32_t write_flags = 0
- );
+/*! Convenience factory for regs_iface based on SPI based on spidev
+ */
+mpm::types::regs_iface::sptr make_spidev_regs_iface(const std::string& device,
+ const int speed_hz,
+ const int spi_mode,
+ uint32_t addr_shift,
+ uint32_t data_shift,
+ uint32_t read_flags,
+ uint32_t write_flags = 0);
}}; /* namespace mpm::spi */
-
diff --git a/mpm/include/mpm/tests/tests_spi_iface.hpp b/mpm/include/mpm/tests/tests_spi_iface.hpp
index c30922747..71993ac46 100644
--- a/mpm/include/mpm/tests/tests_spi_iface.hpp
+++ b/mpm/include/mpm/tests/tests_spi_iface.hpp
@@ -9,50 +9,37 @@
#include <memory>
namespace mpm {
- class tests_spi_iface : public virtual spi_iface
+class tests_spi_iface : public virtual spi_iface
+{
+public:
+ /**************************************************************************
+ * spi_iface API calls
+ *************************************************************************/
+
+ typedef std::shared_ptr<tests_spi_iface> sptr;
+ static sptr make()
{
- public:
-
- /**************************************************************************
- * spi_iface API calls
- *************************************************************************/
-
- typedef std::shared_ptr<tests_spi_iface> sptr;
- static sptr make(){
- return std::make_shared<tests_spi_iface>();
- };
-
- void write_byte(
- const uint16_t addr,
- const uint8_t data
- );
-
- void write_bytes(
- const uint16_t *addr,
- const uint8_t *data,
- const uint32_t count
- );
-
- uint8_t read_byte(const uint16_t addr);
-
- void write_field(
- const uint16_t addr,
- const uint8_t field_val,
- const uint8_t mask,
- const uint8_t start_bit
- );
-
- uint8_t read_field(
- const uint16_t addr,
- const uint8_t mask,
- const uint8_t start_bit
- );
- spi_wire_mode_t get_wire_mode() const;
- spi_endianness_t get_endianness() const;
- size_t get_chip_select() const;
-
- private:
- std::unordered_map<uint16_t, uint8_t> _regs;
- uint8_t _default_val = 0;
+ return std::make_shared<tests_spi_iface>();
};
-}
+
+ void write_byte(const uint16_t addr, const uint8_t data);
+
+ void write_bytes(const uint16_t* addr, const uint8_t* data, const uint32_t count);
+
+ uint8_t read_byte(const uint16_t addr);
+
+ void write_field(const uint16_t addr,
+ const uint8_t field_val,
+ const uint8_t mask,
+ const uint8_t start_bit);
+
+ uint8_t read_field(const uint16_t addr, const uint8_t mask, const uint8_t start_bit);
+ spi_wire_mode_t get_wire_mode() const;
+ spi_endianness_t get_endianness() const;
+ size_t get_chip_select() const;
+
+private:
+ std::unordered_map<uint16_t, uint8_t> _regs;
+ uint8_t _default_val = 0;
+};
+} // namespace mpm
diff --git a/mpm/include/mpm/types/lockable.hpp b/mpm/include/mpm/types/lockable.hpp
index 848fdbd7e..36b96fa50 100644
--- a/mpm/include/mpm/types/lockable.hpp
+++ b/mpm/include/mpm/types/lockable.hpp
@@ -12,29 +12,26 @@
namespace mpm { namespace types {
- /*! A lockable object
- *
- * Don't tell anyone, but's really just a wrapper around a mutex. This
- * class is primarily to make it easy to safely expose that mutex into
- * Python.
+/*! A lockable object
+ *
+ * Don't tell anyone, but's really just a wrapper around a mutex. This
+ * class is primarily to make it easy to safely expose that mutex into
+ * Python.
+ */
+class lockable : public boost::noncopyable
+{
+public:
+ using sptr = std::shared_ptr<lockable>;
+
+ /*! Lock the lock
*/
- class lockable : public boost::noncopyable
- {
- public:
- using sptr = std::shared_ptr<lockable>;
+ virtual void lock() = 0;
- /*! Lock the lock
- */
- virtual void lock() = 0;
-
- /*! Unlock the lock
- */
- virtual void unlock() = 0;
+ /*! Unlock the lock
+ */
+ virtual void unlock() = 0;
- static sptr make(
- std::shared_ptr<std::mutex> spi_mutex
- );
- };
+ static sptr make(std::shared_ptr<std::mutex> spi_mutex);
+};
}}; /* namespace mpm::types */
-
diff --git a/mpm/include/mpm/types/log_buf.hpp b/mpm/include/mpm/types/log_buf.hpp
index df788ff6f..99ca71bcd 100644
--- a/mpm/include/mpm/types/log_buf.hpp
+++ b/mpm/include/mpm/types/log_buf.hpp
@@ -6,82 +6,75 @@
#pragma once
-#include <boost/noncopyable.hpp>
#include <boost/circular_buffer.hpp>
-#include <mutex>
+#include <boost/noncopyable.hpp>
+#include <functional>
#include <memory>
+#include <mutex>
#include <tuple>
-#include <functional>
namespace mpm { namespace types {
- //! Log levels, designed to match the ones in mpmlog.py
- enum class log_level_t {
- NONE = 0, //!< Use this when there's actually no message
- TRACE = 1,
- DEBUG = 10,
- INFO = 20,
- WARNING = 30,
- ERROR = 40,
- CRITICAL = 50
- };
-
- struct log_message {
- log_level_t log_level;
- std::string component;
- std::string message;
-
- log_message(
- const log_level_t log_level_,
- const std::string& component_,
- const std::string& message_
- ) : log_level(log_level_)
- , component(component_)
- , message(message_)
- {
- // nop
- }
- };
-
- class log_buf : public boost::noncopyable
+//! Log levels, designed to match the ones in mpmlog.py
+enum class log_level_t {
+ NONE = 0, //!< Use this when there's actually no message
+ TRACE = 1,
+ DEBUG = 10,
+ INFO = 20,
+ WARNING = 30,
+ ERROR = 40,
+ CRITICAL = 50
+};
+
+struct log_message
+{
+ log_level_t log_level;
+ std::string component;
+ std::string message;
+
+ log_message(const log_level_t log_level_,
+ const std::string& component_,
+ const std::string& message_)
+ : log_level(log_level_), component(component_), message(message_)
{
- public:
- using sptr = std::shared_ptr<log_buf>;
+ // nop
+ }
+};
- static const size_t BUFSIZE = 20;
+class log_buf : public boost::noncopyable
+{
+public:
+ using sptr = std::shared_ptr<log_buf>;
- log_buf() : _buf(BUFSIZE) {}
- ~log_buf() {}
+ static const size_t BUFSIZE = 20;
- static sptr make();
+ log_buf() : _buf(BUFSIZE) {}
+ ~log_buf() {}
- static sptr make_singleton();
+ static sptr make();
- /*! Post a message to the ring buffer
- *
- * \param log_level Log level
- * \param component The component where the message is originating from
- * \param message The actual log message
- */
- void post(
- const log_level_t log_level,
- const std::string &component,
- const std::string &message
- );
+ static sptr make_singleton();
- //! Use this to set a callback that gets called when a new message was
- // posted.
- void set_notify_callback(
- std::function<void(void)> callback
- );
+ /*! Post a message to the ring buffer
+ *
+ * \param log_level Log level
+ * \param component The component where the message is originating from
+ * \param message The actual log message
+ */
+ void post(const log_level_t log_level,
+ const std::string& component,
+ const std::string& message);
- std::tuple<log_level_t, std::string, std::string> pop();
+ //! Use this to set a callback that gets called when a new message was
+ // posted.
+ void set_notify_callback(std::function<void(void)> callback);
- private:
- std::mutex _buf_lock;
- boost::circular_buffer<log_message> _buf;
- std::function<void(void)> _notify_callback;
- };
+ std::tuple<log_level_t, std::string, std::string> pop();
-}} /* namespace mpm::types */
+private:
+ std::mutex _buf_lock;
+ boost::circular_buffer<log_message> _buf;
+ std::function<void(void)> _notify_callback;
+};
+}} /* namespace mpm::types */
diff --git a/mpm/include/mpm/types/mmap_regs_iface.hpp b/mpm/include/mpm/types/mmap_regs_iface.hpp
index ad76d54ee..375a5e8ed 100644
--- a/mpm/include/mpm/types/mmap_regs_iface.hpp
+++ b/mpm/include/mpm/types/mmap_regs_iface.hpp
@@ -8,51 +8,44 @@
#include <mpm/types/log_buf.hpp>
#include <boost/noncopyable.hpp>
-#include <string>
#include <cstdint>
+#include <string>
namespace mpm { namespace types {
- class mmap_regs_iface : public boost::noncopyable
- {
- public:
- mmap_regs_iface(
- const std::string &path,
- const size_t length,
- const size_t offset,
- const bool read_only = true,
- const bool open_now = true
- );
-
- //! Will call close()
- ~mmap_regs_iface();
-
- //! Open the file descriptor and mmap. Safe to call multiple times.
- void open();
-
- //! Close the file descriptor and mmap. Safe to call multiple times.
- void close();
-
- //! Write \p data to \p addr
- void poke32(const uint32_t addr, const uint32_t data);
-
- //! Read data from \p addr
- uint32_t peek32(const uint32_t addr);
-
- private:
- void log(
- mpm::types::log_level_t level,
- const std::string path,
- const char *comment
- );
-
- const std::string _path;
- const size_t _length;
- const size_t _offset;
- const bool _read_only;
- int _fd = -1;
- uint32_t *_mmap = NULL;
-
- };
+class mmap_regs_iface : public boost::noncopyable
+{
+public:
+ mmap_regs_iface(const std::string& path,
+ const size_t length,
+ const size_t offset,
+ const bool read_only = true,
+ const bool open_now = true);
+
+ //! Will call close()
+ ~mmap_regs_iface();
+
+ //! Open the file descriptor and mmap. Safe to call multiple times.
+ void open();
+
+ //! Close the file descriptor and mmap. Safe to call multiple times.
+ void close();
+
+ //! Write \p data to \p addr
+ void poke32(const uint32_t addr, const uint32_t data);
+
+ //! Read data from \p addr
+ uint32_t peek32(const uint32_t addr);
+
+private:
+ void log(mpm::types::log_level_t level, const std::string path, const char* comment);
+
+ const std::string _path;
+ const size_t _length;
+ const size_t _offset;
+ const bool _read_only;
+ int _fd = -1;
+ uint32_t* _mmap = NULL;
+};
}} /* namespace mpm::types */
diff --git a/mpm/include/mpm/types/regs_iface.hpp b/mpm/include/mpm/types/regs_iface.hpp
index 832e798da..b47c31821 100644
--- a/mpm/include/mpm/types/regs_iface.hpp
+++ b/mpm/include/mpm/types/regs_iface.hpp
@@ -11,39 +11,28 @@
namespace mpm { namespace types {
- /*! Interface to a register reader/writer interface
+/*! Interface to a register reader/writer interface
+ */
+class regs_iface : public boost::noncopyable
+{
+public:
+ using sptr = std::shared_ptr<regs_iface>;
+
+ /*! Return an 8-bit value from a given address
*/
- class regs_iface : public boost::noncopyable
- {
- public:
- using sptr = std::shared_ptr<regs_iface>;
-
- /*! Return an 8-bit value from a given address
- */
- virtual uint8_t peek8(
- const uint32_t addr
- ) = 0;
-
- /*! Write an 8-bit value to a given address
- */
- virtual void poke8(
- const uint32_t addr,
- const uint8_t data
- ) = 0;
-
- /*! Return a 16-bit value from a given address
- */
- virtual uint16_t peek16(
- const uint32_t addr
- ) = 0;
-
- /*! Write a 16-bit value to a given address
- */
- virtual void poke16(
- const uint32_t addr,
- const uint16_t data
- ) = 0;
- };
-
-}}; /* namespace mpm::regs */
+ virtual uint8_t peek8(const uint32_t addr) = 0;
+ /*! Write an 8-bit value to a given address
+ */
+ virtual void poke8(const uint32_t addr, const uint8_t data) = 0;
+
+ /*! Return a 16-bit value from a given address
+ */
+ virtual uint16_t peek16(const uint32_t addr) = 0;
+
+ /*! Write a 16-bit value to a given address
+ */
+ virtual void poke16(const uint32_t addr, const uint16_t data) = 0;
+};
+
+}}; // namespace mpm::types
diff --git a/mpm/include/mpm/types/types_python.hpp b/mpm/include/mpm/types/types_python.hpp
index 0dcc7e6ad..d523c2065 100644
--- a/mpm/include/mpm/types/types_python.hpp
+++ b/mpm/include/mpm/types/types_python.hpp
@@ -7,47 +7,45 @@
#pragma once
#include "lockable.hpp"
-#include "regs_iface.hpp"
#include "log_buf.hpp"
#include "mmap_regs_iface.hpp"
+#include "regs_iface.hpp"
-void export_types() {
+void export_types()
+{
LIBMPM_BOOST_PREAMBLE("types")
using namespace mpm::types;
- bp::class_<lockable, boost::noncopyable, std::shared_ptr<lockable> >("lockable", bp::no_init)
+ bp::class_<lockable, boost::noncopyable, std::shared_ptr<lockable>>(
+ "lockable", bp::no_init)
.def("lock", &lockable::lock)
- .def("unlock", &lockable::unlock)
- ;
+ .def("unlock", &lockable::unlock);
- bp::class_<regs_iface, boost::noncopyable, std::shared_ptr<regs_iface> >("regs_iface", bp::no_init)
+ bp::class_<regs_iface, boost::noncopyable, std::shared_ptr<regs_iface>>(
+ "regs_iface", bp::no_init)
.def("peek8", &regs_iface::peek8)
.def("poke8", &regs_iface::poke8)
.def("peek16", &regs_iface::peek16)
- .def("poke16", &regs_iface::poke16)
- ;
+ .def("poke16", &regs_iface::poke16);
- bp::class_<log_buf, boost::noncopyable, std::shared_ptr<log_buf> >("log_buf", bp::no_init)
+ bp::class_<log_buf, boost::noncopyable, std::shared_ptr<log_buf>>(
+ "log_buf", bp::no_init)
.def("make_singleton", &log_buf::make_singleton)
.staticmethod("make_singleton")
- .def("set_notify_callback", +[](log_buf& self,
- boost::python::object object) {
- self.set_notify_callback(object);
- })
- .def("pop", +[](log_buf& self){
+ .def("set_notify_callback",
+ +[](log_buf& self, boost::python::object object) {
+ self.set_notify_callback(object);
+ })
+ .def("pop", +[](log_buf& self) {
auto log_msg = self.pop();
- return bp::make_tuple(
- static_cast<int>(std::get<0>(log_msg)),
+ return bp::make_tuple(static_cast<int>(std::get<0>(log_msg)),
std::get<1>(log_msg),
- std::get<2>(log_msg)
- );
- })
- ;
+ std::get<2>(log_msg));
+ });
- bp::class_<mmap_regs_iface, boost::noncopyable, std::shared_ptr<mmap_regs_iface>>("mmap_regs_iface", bp::init<std::string, size_t, size_t, bool, bool>())
+ bp::class_<mmap_regs_iface, boost::noncopyable, std::shared_ptr<mmap_regs_iface>>(
+ "mmap_regs_iface", bp::init<std::string, size_t, size_t, bool, bool>())
.def("open", &mmap_regs_iface::open)
.def("close", &mmap_regs_iface::close)
.def("peek32", &mmap_regs_iface::peek32)
- .def("poke32", &mmap_regs_iface::poke32)
- ;
+ .def("poke32", &mmap_regs_iface::poke32);
}
-
diff --git a/mpm/include/mpm/xbar_iface.hpp b/mpm/include/mpm/xbar_iface.hpp
index 89751b115..c76aed640 100644
--- a/mpm/include/mpm/xbar_iface.hpp
+++ b/mpm/include/mpm/xbar_iface.hpp
@@ -5,20 +5,21 @@
//
#pragma once
#include <boost/noncopyable.hpp>
+#include <cstdint>
#include <memory>
#include <mutex>
-#include <cstdint>
-namespace mpm{
+namespace mpm {
/*!
* Crossbar route command
*/
-using rfnoc_crossbar_cmd = struct rfnoc_crossbar_cmd {
+using rfnoc_crossbar_cmd = struct rfnoc_crossbar_cmd
+{
/*! destination address */
- uint8_t dest_addr;
+ uint8_t dest_addr;
/*! destination port */
- uint8_t dest_port;
+ uint8_t dest_port;
};
#define RFNCBWROUTIOC _IOW('R', 1, struct rfnoc_crossbar_cmd)
@@ -27,32 +28,33 @@ using rfnoc_crossbar_cmd = struct rfnoc_crossbar_cmd {
/*!
* Crossbar interface class holding a crossbar context
*/
-class xbar_iface: boost::noncopyable{
+class xbar_iface : boost::noncopyable
+{
public:
// use static mutex! lock_guard
using sptr = std::shared_ptr<xbar_iface>;
- static sptr make(const std::string &device);
+ static sptr make(const std::string& device);
void set_route(uint8_t dst_addr, uint8_t dst_port);
void del_route(uint8_t dst_addr, uint8_t dst_port);
~xbar_iface();
- xbar_iface(const std::string &device);
+ xbar_iface(const std::string& device);
private:
static std::mutex _lock;
int _fd;
};
-}
+} // namespace mpm
#ifdef LIBMPM_PYTHON
-void export_xbar(){
+void export_xbar()
+{
LIBMPM_BOOST_PREAMBLE("xbar")
- bp::class_<mpm::xbar_iface, boost::noncopyable, std::shared_ptr<mpm::xbar_iface> >("xbar", bp::no_init)
+ bp::class_<mpm::xbar_iface, boost::noncopyable, std::shared_ptr<mpm::xbar_iface>>(
+ "xbar", bp::no_init)
.def("make", &mpm::xbar_iface::make)
.staticmethod("make")
.def("set_route", &mpm::xbar_iface::set_route)
- .def("del_route", &mpm::xbar_iface::del_route)
- ;
+ .def("del_route", &mpm::xbar_iface::del_route);
}
#endif
-
diff --git a/mpm/lib/dboards/magnesium_manager.cpp b/mpm/lib/dboards/magnesium_manager.cpp
index 49ab7f9ec..c9f9a93b6 100644
--- a/mpm/lib/dboards/magnesium_manager.cpp
+++ b/mpm/lib/dboards/magnesium_manager.cpp
@@ -4,23 +4,19 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <mpm/dboards/magnesium_manager.hpp>
#include <mpm/ad937x/ad937x_spi_iface.hpp>
+#include <mpm/dboards/magnesium_manager.hpp>
using namespace mpm::dboards;
using namespace mpm::chips;
magnesium_manager::magnesium_manager(
- const std::string &mykonos_spidev,
- const size_t deserializer_lane_xbar
-) : _spi_mutex(std::make_shared<std::mutex>())
- , _spi_lock(mpm::types::lockable::make(_spi_mutex))
- , _mykonos_ctrl(ad937x_ctrl::make(
- _spi_mutex,
- deserializer_lane_xbar,
- make_ad937x_iface(mykonos_spidev),
- mpm::ad937x::gpio::gain_pins_t()
- ))
+ const std::string& mykonos_spidev, const size_t deserializer_lane_xbar)
+ : _spi_mutex(std::make_shared<std::mutex>())
+ , _spi_lock(mpm::types::lockable::make(_spi_mutex))
+ , _mykonos_ctrl(ad937x_ctrl::make(_spi_mutex,
+ deserializer_lane_xbar,
+ make_ad937x_iface(mykonos_spidev),
+ mpm::ad937x::gpio::gain_pins_t()))
{
}
-
diff --git a/mpm/lib/dboards/neon_manager.cpp b/mpm/lib/dboards/neon_manager.cpp
index bdd82f0b7..671e44d8d 100644
--- a/mpm/lib/dboards/neon_manager.cpp
+++ b/mpm/lib/dboards/neon_manager.cpp
@@ -27,9 +27,9 @@ constexpr uint32_t AD9361_SPI_DATA_MASK = 0x000000FF;
constexpr uint32_t AD9361_SPI_DATA_SHIFT = 0;
constexpr uint32_t AD9361_SPI_NUM_BITS = 24;
constexpr uint32_t AD9361_SPI_SPEED_HZ = 2000000;
-constexpr int AD9361_SPI_MODE = 1;
+constexpr int AD9361_SPI_MODE = 1;
-} // namespace /*anon*/
+} // namespace
/*! MPM-style E320 SPI Iface for AD9361 CTRL
*
@@ -37,10 +37,14 @@ constexpr int AD9361_SPI_MODE = 1;
class e320_ad9361_io_spi : public ad9361_io
{
public:
- e320_ad9361_io_spi(regs_iface::sptr regs_iface, uint32_t slave_num) :
- _regs_iface(regs_iface), _slave_num(slave_num) { }
+ e320_ad9361_io_spi(regs_iface::sptr regs_iface, uint32_t slave_num)
+ : _regs_iface(regs_iface), _slave_num(slave_num)
+ {
+ }
- ~e320_ad9361_io_spi() {/*nop*/}
+ ~e320_ad9361_io_spi()
+ { /*nop*/
+ }
uint8_t peek8(uint32_t reg)
{
@@ -57,11 +61,12 @@ private:
uint32_t _slave_num;
};
-neon_manager::neon_manager(const std::string &catalina_spidev)
+neon_manager::neon_manager(const std::string& catalina_spidev)
{
// Make the MPM-style low level SPI Regs iface
- auto spi_iface = mpm::spi::make_spi_regs_iface(
- mpm::spi::spi_iface::make_spidev(catalina_spidev, AD9361_SPI_SPEED_HZ, AD9361_SPI_MODE),
+ auto spi_iface = mpm::spi::make_spi_regs_iface(
+ mpm::spi::spi_iface::make_spidev(
+ catalina_spidev, AD9361_SPI_SPEED_HZ, AD9361_SPI_MODE),
AD9361_SPI_ADDR_SHIFT,
AD9361_SPI_DATA_SHIFT,
AD9361_SPI_READ_CMD,
@@ -70,10 +75,8 @@ neon_manager::neon_manager(const std::string &catalina_spidev)
auto spi_io_iface = std::make_shared<e320_ad9361_io_spi>(spi_iface, 0);
// Translate from a std shared_ptr to Boost (for legacy compatability)
auto spi_io_iface_boost = boost::shared_ptr<e320_ad9361_io_spi>(
- spi_io_iface.get(),
- [spi_io_iface](...) mutable { spi_io_iface.reset(); });
+ spi_io_iface.get(), [spi_io_iface](...) mutable { spi_io_iface.reset(); });
// Make the actual Catalina Ctrl object
_catalina_ctrl = ad9361_ctrl::make_spi(
- boost::make_shared<e320_ad9361_client_t>(),
- spi_io_iface_boost);
+ boost::make_shared<e320_ad9361_client_t>(), spi_io_iface_boost);
}
diff --git a/mpm/lib/exception.cpp b/mpm/lib/exception.cpp
index 89883a980..9d3692933 100644
--- a/mpm/lib/exception.cpp
+++ b/mpm/lib/exception.cpp
@@ -10,26 +10,37 @@
using namespace mpm;
-exception::exception(const std::string &what):
- std::runtime_error(what){/* NOP */}
+exception::exception(const std::string& what) : std::runtime_error(what)
+{ /* NOP */
+}
-#define make_exception_impl(name, class, base) \
- class::class(const std::string &what): \
- base(str(boost::format("%s: %s") % name % what)){} \
- unsigned class::code(void) const{return std::hash<std::string>()(#class) & 0xfff;} \
- class *class::dynamic_clone(void) const{return new class(*this);} \
- void class::dynamic_throw(void) const{throw *this;}
-
-make_exception_impl("AssertionError", assertion_error, exception)
-make_exception_impl("LookupError", lookup_error, exception)
-make_exception_impl("IndexError", index_error, lookup_error)
-make_exception_impl("KeyError", key_error, lookup_error)
-make_exception_impl("TypeError", type_error, exception)
-make_exception_impl("ValueError", value_error, exception)
-make_exception_impl("RuntimeError", runtime_error, exception)
-make_exception_impl("NotImplementedError", not_implemented_error, runtime_error)
-make_exception_impl("EnvironmentError", environment_error, exception)
-make_exception_impl("IOError", io_error, environment_error)
-make_exception_impl("OSError", os_error, environment_error)
-make_exception_impl("SystemError", system_error, exception)
+#define make_exception_impl(name, class, base) \
+ class ::class(const std::string& what) \
+ : base(str(boost::format("%s: %s") % name % what)) \
+ { \
+ } \
+ unsigned class ::code(void) const \
+ { \
+ return std::hash<std::string>()(#class) & 0xfff; \
+ } \
+ class* class ::dynamic_clone(void) const \
+ { \
+ return new class(*this); \
+ } \
+ void class ::dynamic_throw(void) const \
+ { \
+ throw *this; \
+ }
+make_exception_impl("AssertionError", assertion_error, exception) make_exception_impl(
+ "LookupError", lookup_error, exception) make_exception_impl("IndexError",
+ index_error,
+ lookup_error) make_exception_impl("KeyError", key_error, lookup_error)
+ make_exception_impl("TypeError", type_error, exception) make_exception_impl(
+ "ValueError", value_error, exception)
+ make_exception_impl("RuntimeError", runtime_error, exception) make_exception_impl(
+ "NotImplementedError", not_implemented_error, runtime_error)
+ make_exception_impl("EnvironmentError", environment_error, exception)
+ make_exception_impl("IOError", io_error, environment_error)
+ make_exception_impl("OSError", os_error, environment_error)
+ make_exception_impl("SystemError", system_error, exception)
diff --git a/mpm/lib/i2c/i2c_regs_iface.cpp b/mpm/lib/i2c/i2c_regs_iface.cpp
index c476cf636..575e19d26 100644
--- a/mpm/lib/i2c/i2c_regs_iface.cpp
+++ b/mpm/lib/i2c/i2c_regs_iface.cpp
@@ -4,10 +4,10 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <mpm/types/regs_iface.hpp>
+#include <mpm/exception.hpp>
#include <mpm/i2c/i2c_iface.hpp>
#include <mpm/i2c/i2c_regs_iface.hpp>
-#include <mpm/exception.hpp>
+#include <mpm/types/regs_iface.hpp>
using mpm::types::regs_iface;
@@ -18,26 +18,21 @@ using mpm::types::regs_iface;
class i2c_regs_iface_impl : public regs_iface
{
public:
-
- i2c_regs_iface_impl(
- mpm::i2c::i2c_iface::sptr i2c_iface,
- const size_t reg_addr_size
- ) : _i2c_iface(i2c_iface),
- _reg_addr_size(reg_addr_size)
+ i2c_regs_iface_impl(mpm::i2c::i2c_iface::sptr i2c_iface, const size_t reg_addr_size)
+ : _i2c_iface(i2c_iface), _reg_addr_size(reg_addr_size)
{
if (reg_addr_size > 4) {
throw mpm::runtime_error("reg_addr_size too largs for i2c_regs_iface");
}
}
- uint8_t peek8(
- const uint32_t addr
- ) {
+ uint8_t peek8(const uint32_t addr)
+ {
uint8_t rx[1];
uint8_t tx[5];
int i = 0;
for (; i < _reg_addr_size; i++) {
- tx[i] = 0xff & (addr >> 8*(_reg_addr_size-i-1));
+ tx[i] = 0xff & (addr >> 8 * (_reg_addr_size - i - 1));
}
int err = _i2c_iface->transfer(tx, _reg_addr_size, rx, 1);
@@ -48,14 +43,12 @@ public:
return rx[0];
}
- void poke8(
- const uint32_t addr,
- const uint8_t data
- ) {
+ void poke8(const uint32_t addr, const uint8_t data)
+ {
uint8_t tx[5];
int i = 0;
for (; i < _reg_addr_size; i++) {
- tx[i] = 0xff & (addr >> 8*(_reg_addr_size-i-1));
+ tx[i] = 0xff & (addr >> 8 * (_reg_addr_size - i - 1));
}
tx[i] = data;
@@ -65,14 +58,13 @@ public:
}
}
- uint16_t peek16(
- const uint32_t addr
- ) {
+ uint16_t peek16(const uint32_t addr)
+ {
uint8_t rx[2];
uint8_t tx[5];
int i = 0;
for (; i < _reg_addr_size; i++) {
- tx[i] = 0xff & (addr >> 8*(_reg_addr_size-i-1));
+ tx[i] = 0xff & (addr >> 8 * (_reg_addr_size - i - 1));
}
int err = _i2c_iface->transfer(tx, _reg_addr_size, rx, 2);
@@ -81,21 +73,19 @@ public:
}
uint16_t data = rx[0];
- data = (data << 8) | rx[1];
+ data = (data << 8) | rx[1];
return data;
}
- void poke16(
- const uint32_t addr,
- const uint16_t data
- ) {
+ void poke16(const uint32_t addr, const uint16_t data)
+ {
uint8_t tx[6];
int i = 0;
for (; i < _reg_addr_size; i++) {
- tx[i] = 0xff & (addr >> 8*(_reg_addr_size-i-1));
+ tx[i] = 0xff & (addr >> 8 * (_reg_addr_size - i - 1));
}
- tx[i] = (data >> 8) & 0xff;
- tx[i+1] = data & 0xff;
+ tx[i] = (data >> 8) & 0xff;
+ tx[i + 1] = data & 0xff;
int err = _i2c_iface->transfer(tx, _reg_addr_size + 2, NULL, 0);
if (err) {
@@ -110,27 +100,18 @@ private:
};
regs_iface::sptr mpm::i2c::make_i2c_regs_iface(
- mpm::i2c::i2c_iface::sptr i2c_iface,
- const size_t reg_addr_size
-) {
- return std::make_shared<i2c_regs_iface_impl>(
- i2c_iface,
- reg_addr_size
- );
+ mpm::i2c::i2c_iface::sptr i2c_iface, const size_t reg_addr_size)
+{
+ return std::make_shared<i2c_regs_iface_impl>(i2c_iface, reg_addr_size);
}
-mpm::types::regs_iface::sptr mpm::i2c::make_i2cdev_regs_iface(
- const std::string &bus,
+mpm::types::regs_iface::sptr mpm::i2c::make_i2cdev_regs_iface(const std::string& bus,
const uint16_t addr,
const bool ten_bit_addr,
const int timeout_ms,
- const size_t reg_addr_size
-) {
- auto i2c_iface_sptr = mpm::i2c::i2c_iface::make_i2cdev(
- bus, addr, ten_bit_addr, timeout_ms
- );
- return std::make_shared<i2c_regs_iface_impl>(
- i2c_iface_sptr,
- reg_addr_size
- );
+ const size_t reg_addr_size)
+{
+ auto i2c_iface_sptr =
+ mpm::i2c::i2c_iface::make_i2cdev(bus, addr, ten_bit_addr, timeout_ms);
+ return std::make_shared<i2c_regs_iface_impl>(i2c_iface_sptr, reg_addr_size);
}
diff --git a/mpm/lib/i2c/i2cdev_iface.cpp b/mpm/lib/i2c/i2cdev_iface.cpp
index 5b59e06f8..b346597a8 100644
--- a/mpm/lib/i2c/i2cdev_iface.cpp
+++ b/mpm/lib/i2c/i2cdev_iface.cpp
@@ -5,15 +5,12 @@
//
-#include <mpm/i2c/i2c_iface.hpp>
-#include <mpm/exception.hpp>
-
#include "i2cdev.h"
-
#include <fcntl.h>
-#include <linux/i2c.h>
#include <linux/i2c-dev.h>
-
+#include <linux/i2c.h>
+#include <mpm/exception.hpp>
+#include <mpm/i2c/i2c_iface.hpp>
#include <boost/format.hpp>
#include <iostream>
@@ -25,17 +22,15 @@ using namespace mpm::i2c;
class i2cdev_iface_impl : public i2c_iface
{
public:
-
- i2cdev_iface_impl(
- const std::string &device,
- const uint16_t addr,
- const bool ten_bit_addr,
- const unsigned int timeout_ms,
- const bool do_open = false
- ) : _device(device),
- _addr(addr),
- _ten_bit_addr(ten_bit_addr),
- _timeout_ms(timeout_ms)
+ i2cdev_iface_impl(const std::string& device,
+ const uint16_t addr,
+ const bool ten_bit_addr,
+ const unsigned int timeout_ms,
+ const bool do_open = false)
+ : _device(device)
+ , _addr(addr)
+ , _ten_bit_addr(ten_bit_addr)
+ , _timeout_ms(timeout_ms)
{
if (do_open)
_open();
@@ -49,13 +44,12 @@ public:
close(_fd);
}
- int transfer(uint8_t *tx, size_t tx_len, uint8_t *rx, size_t rx_len, bool do_close)
+ int transfer(uint8_t* tx, size_t tx_len, uint8_t* rx, size_t rx_len, bool do_close)
{
if (_fd < 0)
_open();
- int ret = i2cdev_transfer(_fd, _addr, _ten_bit_addr,
- tx, tx_len, rx, rx_len);
+ int ret = i2cdev_transfer(_fd, _addr, _ten_bit_addr, tx, tx_len, rx, rx_len);
if (do_close) {
close(_fd);
@@ -63,27 +57,25 @@ public:
}
if (ret) {
- throw mpm::runtime_error(str(
- boost::format("I2C Transaction failed!")
- ));
+ throw mpm::runtime_error(str(boost::format("I2C Transaction failed!")));
}
return ret;
}
- int transfer(std::vector<uint8_t> *tx, std::vector<uint8_t> *rx, bool do_close)
+ int transfer(std::vector<uint8_t>* tx, std::vector<uint8_t>* rx, bool do_close)
{
uint8_t *tx_data = NULL, *rx_data = NULL;
size_t tx_len = 0, rx_len = 0;
if (tx) {
tx_data = tx->data();
- tx_len = tx->size();
+ tx_len = tx->size();
}
if (rx) {
rx_data = rx->data();
- rx_len = rx->size();
+ rx_len = rx->size();
}
int ret = transfer(tx_data, tx_len, rx_data, rx_len, do_close);
@@ -97,22 +89,16 @@ private:
const bool _ten_bit_addr;
const unsigned int _timeout_ms;
- int _open(void) {
- if (i2cdev_open(
- &_fd,
- _device.c_str(),
- _timeout_ms) < 0)
- {
- throw mpm::runtime_error(str(
- boost::format("Could not initialize i2cdev device %s")
- % _device));
+ int _open(void)
+ {
+ if (i2cdev_open(&_fd, _device.c_str(), _timeout_ms) < 0) {
+ throw mpm::runtime_error(
+ str(boost::format("Could not initialize i2cdev device %s") % _device));
}
- if (_fd < 0)
- {
- throw mpm::runtime_error(str(
- boost::format("Could not open i2cdev device %s")
- % _device));
+ if (_fd < 0) {
+ throw mpm::runtime_error(
+ str(boost::format("Could not open i2cdev device %s") % _device));
}
}
};
@@ -120,14 +106,10 @@ private:
/******************************************************************************
* Factory
*****************************************************************************/
-i2c_iface::sptr i2c_iface::make_i2cdev(
- const std::string &bus,
+i2c_iface::sptr i2c_iface::make_i2cdev(const std::string& bus,
const uint16_t addr,
const bool ten_bit_addr,
- const int timeout_ms
-) {
- return std::make_shared<i2cdev_iface_impl>(
- bus, addr, ten_bit_addr, timeout_ms
- );
+ const int timeout_ms)
+{
+ return std::make_shared<i2cdev_iface_impl>(bus, addr, ten_bit_addr, timeout_ms);
}
-
diff --git a/mpm/lib/mykonos/ad937x_ctrl.cpp b/mpm/lib/mykonos/ad937x_ctrl.cpp
index efb39c972..f4abae7a7 100644
--- a/mpm/lib/mykonos/ad937x_ctrl.cpp
+++ b/mpm/lib/mykonos/ad937x_ctrl.cpp
@@ -4,25 +4,24 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
+#include "mpm/ad937x/ad937x_ctrl.hpp"
+#include "../../../host/include/uhd/utils/math.hpp"
#include "ad937x_device.hpp"
#include "adi/mykonos.h"
-#include "mpm/ad937x/ad937x_ctrl.hpp"
#include <mpm/exception.hpp>
-#include "../../../host/include/uhd/utils/math.hpp"
-
#include <boost/format.hpp>
-#include <sstream>
-#include <set>
+#include <algorithm>
+#include <chrono>
#include <functional>
#include <iostream>
-#include <algorithm>
+#include <set>
+#include <sstream>
#include <thread>
-#include <chrono>
using namespace mpm::chips;
using namespace mpm::ad937x::device;
-//Init cals mask
+// Init cals mask
const uint32_t ad937x_ctrl::TX_BB_FILTER = ::TX_BB_FILTER;
const uint32_t ad937x_ctrl::ADC_TUNER = ::ADC_TUNER;
const uint32_t ad937x_ctrl::TIA_3DB_CORNER = ::TIA_3DB_CORNER;
@@ -41,55 +40,42 @@ const uint32_t ad937x_ctrl::RX_QEC_INIT = ::RX_QEC_INIT;
const uint32_t ad937x_ctrl::DPD_INIT = ::DPD_INIT;
const uint32_t ad937x_ctrl::CLGC_INIT = ::CLGC_INIT;
const uint32_t ad937x_ctrl::VSWR_INIT = ::VSWR_INIT;
-//Tracking Cals mask
-const uint32_t ad937x_ctrl::TRACK_RX1_QEC = ::TRACK_RX1_QEC;
-const uint32_t ad937x_ctrl::TRACK_RX2_QEC = ::TRACK_RX2_QEC;
-const uint32_t ad937x_ctrl::TRACK_ORX1_QEC = ::TRACK_ORX1_QEC;
-const uint32_t ad937x_ctrl::TRACK_ORX2_QEC = ::TRACK_ORX2_QEC;
-const uint32_t ad937x_ctrl::TRACK_TX1_LOL = ::TRACK_TX1_LOL;
-const uint32_t ad937x_ctrl::TRACK_TX2_LOL = ::TRACK_TX2_LOL;
-const uint32_t ad937x_ctrl::TRACK_TX1_QEC = ::TRACK_TX1_QEC;
-const uint32_t ad937x_ctrl::TRACK_TX2_QEC = ::TRACK_TX2_QEC;
-const uint32_t ad937x_ctrl::TRACK_TX1_DPD = ::TRACK_TX1_DPD;
-const uint32_t ad937x_ctrl::TRACK_TX2_DPD = ::TRACK_TX2_DPD;
-const uint32_t ad937x_ctrl::TRACK_TX1_CLGC = ::TRACK_TX1_CLGC;
-const uint32_t ad937x_ctrl::TRACK_TX2_CLGC = ::TRACK_TX2_CLGC;
-const uint32_t ad937x_ctrl::TRACK_TX1_VSWR = ::TRACK_TX1_VSWR;
-const uint32_t ad937x_ctrl::TRACK_TX2_VSWR = ::TRACK_TX2_VSWR;
-const uint32_t ad937x_ctrl::TRACK_ORX1_QEC_SNLO = ::TRACK_ORX1_QEC_SNLO;
-const uint32_t ad937x_ctrl::TRACK_ORX2_QEC_SNLO = ::TRACK_ORX2_QEC_SNLO;
-const uint32_t ad937x_ctrl::TRACK_SRX_QEC = ::TRACK_SRX_QEC;
+// Tracking Cals mask
+const uint32_t ad937x_ctrl::TRACK_RX1_QEC = ::TRACK_RX1_QEC;
+const uint32_t ad937x_ctrl::TRACK_RX2_QEC = ::TRACK_RX2_QEC;
+const uint32_t ad937x_ctrl::TRACK_ORX1_QEC = ::TRACK_ORX1_QEC;
+const uint32_t ad937x_ctrl::TRACK_ORX2_QEC = ::TRACK_ORX2_QEC;
+const uint32_t ad937x_ctrl::TRACK_TX1_LOL = ::TRACK_TX1_LOL;
+const uint32_t ad937x_ctrl::TRACK_TX2_LOL = ::TRACK_TX2_LOL;
+const uint32_t ad937x_ctrl::TRACK_TX1_QEC = ::TRACK_TX1_QEC;
+const uint32_t ad937x_ctrl::TRACK_TX2_QEC = ::TRACK_TX2_QEC;
+const uint32_t ad937x_ctrl::TRACK_TX1_DPD = ::TRACK_TX1_DPD;
+const uint32_t ad937x_ctrl::TRACK_TX2_DPD = ::TRACK_TX2_DPD;
+const uint32_t ad937x_ctrl::TRACK_TX1_CLGC = ::TRACK_TX1_CLGC;
+const uint32_t ad937x_ctrl::TRACK_TX2_CLGC = ::TRACK_TX2_CLGC;
+const uint32_t ad937x_ctrl::TRACK_TX1_VSWR = ::TRACK_TX1_VSWR;
+const uint32_t ad937x_ctrl::TRACK_TX2_VSWR = ::TRACK_TX2_VSWR;
+const uint32_t ad937x_ctrl::TRACK_ORX1_QEC_SNLO = ::TRACK_ORX1_QEC_SNLO;
+const uint32_t ad937x_ctrl::TRACK_ORX2_QEC_SNLO = ::TRACK_ORX2_QEC_SNLO;
+const uint32_t ad937x_ctrl::TRACK_SRX_QEC = ::TRACK_SRX_QEC;
const uint32_t ad937x_ctrl::DEFAULT_INIT_CALS_MASKS =
- ad937x_ctrl::TX_BB_FILTER |
- ad937x_ctrl::ADC_TUNER |
- ad937x_ctrl::TIA_3DB_CORNER |
- ad937x_ctrl::DC_OFFSET |
- ad937x_ctrl::TX_ATTENUATION_DELAY |
- ad937x_ctrl::RX_GAIN_DELAY |
- ad937x_ctrl::FLASH_CAL |
- ad937x_ctrl::PATH_DELAY |
- ad937x_ctrl::TX_LO_LEAKAGE_INTERNAL |
- ad937x_ctrl::TX_QEC_INIT |
- ad937x_ctrl::LOOPBACK_RX_LO_DELAY |
- ad937x_ctrl::RX_QEC_INIT
- ;
+ ad937x_ctrl::TX_BB_FILTER | ad937x_ctrl::ADC_TUNER | ad937x_ctrl::TIA_3DB_CORNER
+ | ad937x_ctrl::DC_OFFSET | ad937x_ctrl::TX_ATTENUATION_DELAY
+ | ad937x_ctrl::RX_GAIN_DELAY | ad937x_ctrl::FLASH_CAL | ad937x_ctrl::PATH_DELAY
+ | ad937x_ctrl::TX_LO_LEAKAGE_INTERNAL | ad937x_ctrl::TX_QEC_INIT
+ | ad937x_ctrl::LOOPBACK_RX_LO_DELAY | ad937x_ctrl::RX_QEC_INIT;
const uint32_t ad937x_ctrl::DEFAULT_TRACKING_CALS_MASKS =
- ad937x_ctrl::TRACK_RX1_QEC |
- ad937x_ctrl::TRACK_RX2_QEC |
- ad937x_ctrl::TRACK_TX1_QEC |
- ad937x_ctrl::TRACK_TX2_QEC
- ;
+ ad937x_ctrl::TRACK_RX1_QEC | ad937x_ctrl::TRACK_RX2_QEC | ad937x_ctrl::TRACK_TX1_QEC
+ | ad937x_ctrl::TRACK_TX2_QEC;
const uint32_t ad937x_ctrl::DEFAULT_INIT_CALS_TIMEOUT = 60000;
static uhd::direction_t _get_direction_from_antenna(const std::string& antenna)
{
auto sub = antenna.substr(0, 2);
if (sub == "RX") {
return uhd::direction_t::RX_DIRECTION;
- }
- else if (sub == "TX") {
+ } else if (sub == "TX") {
return uhd::direction_t::TX_DIRECTION;
- }
- else {
+ } else {
throw mpm::runtime_error("ad937x_ctrl got an invalid channel string.");
}
return uhd::direction_t::RX_DIRECTION;
@@ -100,11 +86,9 @@ static chain_t _get_chain_from_antenna(const std::string& antenna)
auto sub = antenna.substr(2, 1);
if (sub == "1") {
return chain_t::ONE;
- }
- else if (sub == "2") {
+ } else if (sub == "2") {
return chain_t::TWO;
- }
- else {
+ } else {
throw mpm::runtime_error("ad937x_ctrl got an invalid channel string.");
}
return chain_t::ONE;
@@ -113,15 +97,14 @@ static chain_t _get_chain_from_antenna(const std::string& antenna)
std::set<size_t> _get_valid_fir_lengths(const std::string& which)
{
auto dir = _get_direction_from_antenna(which);
- switch (dir)
- {
- case uhd::direction_t::RX_DIRECTION:
- return{ 24, 48, 72 };
- case uhd::direction_t::TX_DIRECTION:
- return{ 16, 32, 48, 64, 80, 96 };
- default:
- MPM_THROW_INVALID_CODE_PATH();
- return std::set<size_t>();
+ switch (dir) {
+ case uhd::direction_t::RX_DIRECTION:
+ return {24, 48, 72};
+ case uhd::direction_t::TX_DIRECTION:
+ return {16, 32, 48, 64, 80, 96};
+ default:
+ MPM_THROW_INVALID_CODE_PATH();
+ return std::set<size_t>();
}
}
@@ -152,43 +135,37 @@ uhd::meta_range_t ad937x_ctrl::get_bw_filter_range(void)
std::vector<double> ad937x_ctrl::get_clock_rates(void)
{
// TODO: fix
- return { 125e6 };
+ return {125e6};
}
-uhd::meta_range_t ad937x_ctrl::get_gain_range(const std::string &which)
+uhd::meta_range_t ad937x_ctrl::get_gain_range(const std::string& which)
{
auto dir = _get_direction_from_antenna(which);
- switch (dir)
- {
- case uhd::direction_t::RX_DIRECTION:
- return uhd::meta_range_t(
- ad937x_device::MIN_RX_GAIN,
+ switch (dir) {
+ case uhd::direction_t::RX_DIRECTION:
+ return uhd::meta_range_t(ad937x_device::MIN_RX_GAIN,
ad937x_device::MAX_RX_GAIN,
- ad937x_device::RX_GAIN_STEP
- );
- case uhd::direction_t::TX_DIRECTION:
- return uhd::meta_range_t(
- ad937x_device::MIN_TX_GAIN,
+ ad937x_device::RX_GAIN_STEP);
+ case uhd::direction_t::TX_DIRECTION:
+ return uhd::meta_range_t(ad937x_device::MIN_TX_GAIN,
ad937x_device::MAX_TX_GAIN,
- ad937x_device::TX_GAIN_STEP
- );
- default:
- MPM_THROW_INVALID_CODE_PATH();
- return uhd::meta_range_t();
+ ad937x_device::TX_GAIN_STEP);
+ default:
+ MPM_THROW_INVALID_CODE_PATH();
+ return uhd::meta_range_t();
}
}
class ad937x_ctrl_impl : public ad937x_ctrl
{
public:
- ad937x_ctrl_impl(
- std::shared_ptr<std::mutex> spi_mutex,
+ ad937x_ctrl_impl(std::shared_ptr<std::mutex> spi_mutex,
const size_t deserializer_lane_xbar,
mpm::types::regs_iface::sptr iface,
- mpm::ad937x::gpio::gain_pins_t gain_pins) :
- spi_mutex(spi_mutex),
- device(iface.get(), deserializer_lane_xbar, gain_pins),
- _iface(iface)
+ mpm::ad937x::gpio::gain_pins_t gain_pins)
+ : spi_mutex(spi_mutex)
+ , device(iface.get(), deserializer_lane_xbar, gain_pins)
+ , _iface(iface)
{
/* nop */
}
@@ -205,49 +182,45 @@ public:
device.finish_initialization();
}
- virtual void setup_cal(
- const uint32_t init_cals_mask,
- const uint32_t tracking_cals_mask,
- const uint32_t timeout
- ) {
+ virtual void setup_cal(const uint32_t init_cals_mask,
+ const uint32_t tracking_cals_mask,
+ const uint32_t timeout)
+ {
std::lock_guard<std::mutex> lock(*spi_mutex);
device.setup_cal(init_cals_mask, tracking_cals_mask, timeout);
}
- virtual std::string set_lo_source(
- const std::string &which,
- const std::string &source
- ) {
+ virtual std::string set_lo_source(const std::string& which, const std::string& source)
+ {
const auto dir = _get_direction_from_antenna(which);
- uint8_t pll_source = 0 ;
- if (source == "internal"){
+ uint8_t pll_source = 0;
+ if (source == "internal") {
pll_source = 0;
- }
- else if (source == "external") {
+ } else if (source == "external") {
pll_source = 1;
- }
- else {
+ } else {
throw mpm::runtime_error("invalid LO source");
}
std::lock_guard<std::mutex> lock(*spi_mutex);
uint8_t retval = device.set_lo_source(dir, pll_source);
- if (retval == 0){
+ if (retval == 0) {
return "internal";
- } else if (retval == 1){
+ } else if (retval == 1) {
return "external";
- }else{
+ } else {
throw mpm::runtime_error("invalid return from set LO source");
}
}
- virtual std::string get_lo_source(const std::string &which){
+ virtual std::string get_lo_source(const std::string& which)
+ {
const auto dir = _get_direction_from_antenna(which);
std::lock_guard<std::mutex> lock(*spi_mutex);
uint8_t retval = device.get_lo_source(dir);
- if (retval == 0){
+ if (retval == 0) {
return "internal";
} else if (retval == 1) {
return "external";
@@ -328,10 +301,8 @@ public:
std::lock_guard<std::mutex> lock(*spi_mutex);
const auto api = device.get_api_version();
std::ostringstream ss;
- ss << api.silicon_ver << "."
- << api.major_ver << "."
- << api.minor_ver << "."
- << api.build_ver;
+ ss << api.silicon_ver << "." << api.major_ver << "." << api.minor_ver << "."
+ << api.build_ver;
return ss.str();
}
@@ -341,45 +312,43 @@ public:
std::lock_guard<std::mutex> lock(*spi_mutex);
const auto arm = device.get_arm_version();
std::ostringstream ss;
- ss << (int)(arm.major_ver) << "."
- << (int)(arm.minor_ver) << "."
- << (int)(arm.rc_ver);
-
- switch (arm.build_type)
- {
- case mpm::ad937x::device::build_type_t::RELEASE:
- ss << " Release";
- break;
- case mpm::ad937x::device::build_type_t::DEBUG:
- ss << " Debug";
- break;
- case mpm::ad937x::device::build_type_t::TEST_OBJECT:
- ss << " Test Object";
- break;
+ ss << (int)(arm.major_ver) << "." << (int)(arm.minor_ver) << "."
+ << (int)(arm.rc_ver);
+
+ switch (arm.build_type) {
+ case mpm::ad937x::device::build_type_t::RELEASE:
+ ss << " Release";
+ break;
+ case mpm::ad937x::device::build_type_t::DEBUG:
+ ss << " Debug";
+ break;
+ case mpm::ad937x::device::build_type_t::TEST_OBJECT:
+ ss << " Test Object";
+ break;
}
return ss.str();
}
- virtual double set_bw_filter(const std::string &which, const double value)
+ virtual double set_bw_filter(const std::string& which, const double value)
{
const auto dir = _get_direction_from_antenna(which);
std::lock_guard<std::mutex> lock(*spi_mutex);
return device.set_bw_filter(dir, value);
}
- virtual double set_gain(const std::string &which, const double value)
+ virtual double set_gain(const std::string& which, const double value)
{
- const auto dir = _get_direction_from_antenna(which);
+ const auto dir = _get_direction_from_antenna(which);
const auto chain = _get_chain_from_antenna(which);
std::lock_guard<std::mutex> lock(*spi_mutex);
return device.set_gain(dir, chain, value);
}
- virtual double get_gain(const std::string &which)
+ virtual double get_gain(const std::string& which)
{
- const auto dir = _get_direction_from_antenna(which);
+ const auto dir = _get_direction_from_antenna(which);
const auto chain = _get_chain_from_antenna(which);
std::lock_guard<std::mutex> lock(*spi_mutex);
@@ -388,27 +357,21 @@ public:
// TODO: does agc mode need to have a which parameter?
// this affects all RX channels on the device
- virtual void set_agc_mode(
- const std::string &which,
- const std::string &mode
- ) {
+ virtual void set_agc_mode(const std::string& which, const std::string& mode)
+ {
const auto dir = _get_direction_from_antenna(which);
- if (dir != uhd::direction_t::RX_DIRECTION)
- {
+ if (dir != uhd::direction_t::RX_DIRECTION) {
throw mpm::runtime_error("set_agc not valid for non-rx channels");
}
ad937x_device::gain_mode_t gain_mode;
if (mode == "automatic") {
gain_mode = ad937x_device::gain_mode_t::AUTOMATIC;
- }
- else if (mode == "manual") {
+ } else if (mode == "manual") {
gain_mode = ad937x_device::gain_mode_t::MANUAL;
- }
- else if (mode == "hybrid") {
+ } else if (mode == "hybrid") {
gain_mode = ad937x_device::gain_mode_t::HYBRID;
- }
- else {
+ } else {
throw mpm::runtime_error("invalid agc mode");
}
@@ -427,9 +390,9 @@ public:
return device.set_clock_rate(value);
}
- virtual void enable_channel(const std::string &which, const bool enable)
+ virtual void enable_channel(const std::string& which, const bool enable)
{
- const auto dir = _get_direction_from_antenna(which);
+ const auto dir = _get_direction_from_antenna(which);
const auto chain = _get_chain_from_antenna(which);
std::lock_guard<std::mutex> lock(*spi_mutex);
@@ -437,18 +400,16 @@ public:
}
virtual double set_freq(
- const std::string &which,
- const double value,
- const bool wait_for_lock
- ) {
- const auto dir = _get_direction_from_antenna(which);
+ const std::string& which, const double value, const bool wait_for_lock)
+ {
+ const auto dir = _get_direction_from_antenna(which);
const auto clipped_value = get_rf_freq_range().clip(value);
std::lock_guard<std::mutex> lock(*spi_mutex);
return device.tune(dir, clipped_value, wait_for_lock);
}
- virtual double get_freq(const std::string &which)
+ virtual double get_freq(const std::string& which)
{
const auto dir = _get_direction_from_antenna(which);
@@ -456,27 +417,23 @@ public:
return device.get_freq(dir);
}
- virtual bool get_lo_locked(const std::string &which)
+ virtual bool get_lo_locked(const std::string& which)
{
- const auto dir = _get_direction_from_antenna(which);
- const uint8_t pll_select = (dir == uhd::RX_DIRECTION) ?
- ad937x_device::RX_SYNTH :
- ad937x_device::TX_SYNTH;
+ const auto dir = _get_direction_from_antenna(which);
+ const uint8_t pll_select = (dir == uhd::RX_DIRECTION) ? ad937x_device::RX_SYNTH
+ : ad937x_device::TX_SYNTH;
std::lock_guard<std::mutex> lock(*spi_mutex);
return device.get_pll_lock_status(pll_select);
}
virtual void set_fir(
- const std::string &which,
- const int8_t gain,
- const std::vector<int16_t>& fir
- ) {
- const auto dir = _get_direction_from_antenna(which);
+ const std::string& which, const int8_t gain, const std::vector<int16_t>& fir)
+ {
+ const auto dir = _get_direction_from_antenna(which);
const auto lengths = _get_valid_fir_lengths(which);
- if (std::find(lengths.begin(), lengths.end(), fir.size()) == lengths.end())
- {
+ if (std::find(lengths.begin(), lengths.end(), fir.size()) == lengths.end()) {
throw mpm::value_error("invalid filter length");
}
@@ -484,7 +441,7 @@ public:
device.set_fir(dir, gain, fir);
}
- virtual std::vector<int16_t> get_fir(const std::string &which, int8_t &gain)
+ virtual std::vector<int16_t> get_fir(const std::string& which, int8_t& gain)
{
auto dir = _get_direction_from_antenna(which);
@@ -504,28 +461,22 @@ public:
ad937x_device::mcr_t mcr;
if (uhd::math::frequencies_are_equal(rate, 122.88e6)) {
mcr = ad937x_device::MCR_122_88MHZ;
- }
- else if (uhd::math::frequencies_are_equal(rate, 125e6)) {
+ } else if (uhd::math::frequencies_are_equal(rate, 125e6)) {
mcr = ad937x_device::MCR_125_00MHZ;
- }
- else if (uhd::math::frequencies_are_equal(rate, 153.6e6)) {
+ } else if (uhd::math::frequencies_are_equal(rate, 153.6e6)) {
mcr = ad937x_device::MCR_153_60MHZ;
- }
- else {
- throw mpm::value_error(boost::str(
- boost::format("Requested invalid master clock rate: %f MHz")
- % (rate / 1e6)
- ));
+ } else {
+ throw mpm::value_error(
+ boost::str(boost::format("Requested invalid master clock rate: %f MHz")
+ % (rate / 1e6)));
}
device.set_master_clock_rate(mcr);
}
- virtual void set_enable_gain_pins(
- const std::string &which,
- const bool enable
- ) {
- const auto dir = _get_direction_from_antenna(which);
+ virtual void set_enable_gain_pins(const std::string& which, const bool enable)
+ {
+ const auto dir = _get_direction_from_antenna(which);
const auto chain = _get_chain_from_antenna(which);
std::lock_guard<std::mutex> lock(*spi_mutex);
@@ -533,27 +484,24 @@ public:
}
virtual void set_gain_pin_step_sizes(
- const std::string &which,
- double inc_step,
- double dec_step
- ) {
- const auto dir = _get_direction_from_antenna(which);
+ const std::string& which, double inc_step, double dec_step)
+ {
+ const auto dir = _get_direction_from_antenna(which);
const auto chain = _get_chain_from_antenna(which);
if (dir == uhd::RX_DIRECTION) {
auto steps = _get_valid_rx_gain_steps();
- inc_step = steps.clip(inc_step);
- dec_step = steps.clip(dec_step);
- }
- else if (dir == uhd::TX_DIRECTION) {
+ inc_step = steps.clip(inc_step);
+ dec_step = steps.clip(dec_step);
+ } else if (dir == uhd::TX_DIRECTION) {
auto steps = _get_valid_tx_gain_steps();
- inc_step = steps.clip(inc_step);
- dec_step = steps.clip(dec_step);
+ inc_step = steps.clip(inc_step);
+ dec_step = steps.clip(dec_step);
// double comparison here should be okay because of clipping
if (inc_step != dec_step) {
throw mpm::value_error(
- "TX gain increment and decrement steps must be equal");
+ "TX gain increment and decrement steps must be equal");
}
}
@@ -579,17 +527,11 @@ private:
mpm::types::regs_iface::sptr _iface;
};
-ad937x_ctrl::sptr ad937x_ctrl::make(
- std::shared_ptr<std::mutex> spi_mutex,
- const size_t deserializer_lane_xbar,
- mpm::types::regs_iface::sptr iface,
- mpm::ad937x::gpio::gain_pins_t gain_pins
-) {
+ad937x_ctrl::sptr ad937x_ctrl::make(std::shared_ptr<std::mutex> spi_mutex,
+ const size_t deserializer_lane_xbar,
+ mpm::types::regs_iface::sptr iface,
+ mpm::ad937x::gpio::gain_pins_t gain_pins)
+{
return std::make_shared<ad937x_ctrl_impl>(
- spi_mutex,
- deserializer_lane_xbar,
- iface,
- gain_pins
- );
+ spi_mutex, deserializer_lane_xbar, iface, gain_pins);
}
-
diff --git a/mpm/lib/mykonos/ad937x_device.cpp b/mpm/lib/mykonos/ad937x_device.cpp
index ceaa0b93c..144b813ae 100644
--- a/mpm/lib/mykonos/ad937x_device.cpp
+++ b/mpm/lib/mykonos/ad937x_device.cpp
@@ -6,28 +6,27 @@
#include "ad937x_device.hpp"
#include "adi/mykonos.h"
-#include "adi/mykonos_gpio.h"
#include "adi/mykonos_debug/mykonos_dbgjesd.h"
+#include "adi/mykonos_gpio.h"
#include "config/ad937x_config_t.hpp"
#include "config/ad937x_default_config.hpp"
#include <boost/format.hpp>
-
+#include <fstream>
#include <functional>
#include <iostream>
#include <thread>
-#include <fstream>
using namespace mpm::ad937x::device;
using namespace mpm::ad937x::gpio;
using namespace uhd;
-const double ad937x_device::MIN_FREQ = 300e6;
-const double ad937x_device::MAX_FREQ = 6e9;
-const double ad937x_device::MIN_RX_GAIN = 0.0;
-const double ad937x_device::MAX_RX_GAIN = 30.0;
+const double ad937x_device::MIN_FREQ = 300e6;
+const double ad937x_device::MAX_FREQ = 6e9;
+const double ad937x_device::MIN_RX_GAIN = 0.0;
+const double ad937x_device::MAX_RX_GAIN = 30.0;
const double ad937x_device::RX_GAIN_STEP = 0.5;
-const double ad937x_device::MIN_TX_GAIN = 0.0;
-const double ad937x_device::MAX_TX_GAIN = 41.95;
+const double ad937x_device::MIN_TX_GAIN = 0.0;
+const double ad937x_device::MAX_TX_GAIN = 41.95;
const double ad937x_device::TX_GAIN_STEP = 0.05;
static const double RX_DEFAULT_FREQ = 2.5e9;
@@ -35,9 +34,9 @@ static const double TX_DEFAULT_FREQ = 2.5e9;
static const double RX_DEFAULT_GAIN = 0;
static const double TX_DEFAULT_GAIN = 0;
-static const uint32_t AD9371_PRODUCT_ID = 0x3;
+static const uint32_t AD9371_PRODUCT_ID = 0x3;
static const uint32_t AD9371_XBCZ_PRODUCT_ID = 0x1;
-static const size_t ARM_BINARY_SIZE = 98304;
+static const size_t ARM_BINARY_SIZE = 98304;
static const uint32_t PLL_LOCK_TIMEOUT_MS = 200;
@@ -46,29 +45,26 @@ Helper functions
******************************************************/
// Macro to call an API function via lambda
-#define CALL_API(function_call) \
- _call_api_function([&,this]{return function_call;})
+#define CALL_API(function_call) _call_api_function([&, this] { return function_call; })
// helper function to unify error handling
void ad937x_device::_call_api_function(const std::function<mykonosErr_t()>& func)
{
const auto error = func();
- if (error != MYKONOS_ERR_OK)
- {
+ if (error != MYKONOS_ERR_OK) {
throw mpm::runtime_error(getMykonosErrorMessage(error));
}
}
// Macro to call a GPIO API function via lambda
#define CALL_GPIO_API(function_call) \
- _call_gpio_api_function([&,this]{return function_call;})
+ _call_gpio_api_function([&, this] { return function_call; })
// helper function to unify error handling, GPIO version
void ad937x_device::_call_gpio_api_function(const std::function<mykonosGpioErr_t()>& func)
{
const auto error = func();
- if (error != MYKONOS_ERR_GPIO_OK)
- {
+ if (error != MYKONOS_ERR_GPIO_OK) {
throw mpm::runtime_error(getGpioMykonosErrorMessage(error));
}
}
@@ -84,23 +80,19 @@ ad937x_device::radio_state_t ad937x_device::_move_to_config_state()
{
uint32_t status;
CALL_API(MYKONOS_getRadioState(mykonos_config.device, &status));
- if ((status & 0x3) == 0x3)
- {
+ if ((status & 0x3) == 0x3) {
stop_radio();
return radio_state_t::ON;
- }
- else {
+ } else {
return radio_state_t::OFF;
}
}
// restores the state from before a call to _move_to_config_state
// if ON, move to radioOn, otherwise this function is a no-op
-void ad937x_device::_restore_from_config_state(
- const ad937x_device::radio_state_t state
-) {
- if (state == radio_state_t::ON)
- {
+void ad937x_device::_restore_from_config_state(const ad937x_device::radio_state_t state)
+{
+ if (state == radio_state_t::ON) {
start_radio();
}
}
@@ -117,17 +109,14 @@ std::vector<uint8_t> ad937x_device::_get_arm_binary()
const auto path = _get_arm_binary_path();
std::ifstream file(path, std::ios::binary);
if (!file.is_open()) {
- throw mpm::runtime_error(
- "Could not open AD9371 ARM binary at path " + path);
+ throw mpm::runtime_error("Could not open AD9371 ARM binary at path " + path);
}
// TODO: add check that opened file size is equal to ARM_BINARY_SIZE
std::vector<uint8_t> binary(ARM_BINARY_SIZE);
file.read(reinterpret_cast<char*>(binary.data()), ARM_BINARY_SIZE);
- if (file.bad())
- {
- throw mpm::runtime_error(
- "Error reading AD9371 ARM binary at path " + path);
+ if (file.bad()) {
+ throw mpm::runtime_error("Error reading AD9371 ARM binary at path " + path);
}
return binary;
}
@@ -135,31 +124,26 @@ std::vector<uint8_t> ad937x_device::_get_arm_binary()
void ad937x_device::_verify_product_id()
{
const uint8_t product_id = get_product_id();
- if (product_id != AD9371_PRODUCT_ID
- && product_id != AD9371_XBCZ_PRODUCT_ID) {
+ if (product_id != AD9371_PRODUCT_ID && product_id != AD9371_XBCZ_PRODUCT_ID) {
// The XBCZ code is an exception, so we don't print it as 'Expected'
// if this fails.
- throw mpm::runtime_error(str(
- boost::format("AD9371 product ID does not match expected ID! "
- "Read: %X Expected: %X")
- % int(product_id) % int(AD9371_PRODUCT_ID)
- ));
+ throw mpm::runtime_error(
+ str(boost::format("AD9371 product ID does not match expected ID! "
+ "Read: %X Expected: %X")
+ % int(product_id) % int(AD9371_PRODUCT_ID)));
}
}
void ad937x_device::_verify_multichip_sync_status(const multichip_sync_t mcs)
{
- const uint8_t status_expected =
- (mcs == multichip_sync_t::FULL) ? 0x0B : 0x0A;
- const uint8_t status_mask = status_expected; // all 1s expected, mask is the same
+ const uint8_t status_expected = (mcs == multichip_sync_t::FULL) ? 0x0B : 0x0A;
+ const uint8_t status_mask = status_expected; // all 1s expected, mask is the same
const uint8_t mcs_status = get_multichip_sync_status();
- if ((mcs_status & status_mask) != status_expected)
- {
- throw mpm::runtime_error(str(
- boost::format("Multichip sync failed! Read: %X Expected: %X")
- % int(mcs_status) % int(status_expected)
- ));
+ if ((mcs_status & status_mask) != status_expected) {
+ throw mpm::runtime_error(
+ str(boost::format("Multichip sync failed! Read: %X Expected: %X")
+ % int(mcs_status) % int(status_expected)));
}
}
@@ -193,10 +177,8 @@ double ad937x_device::_convert_tx_gain_from_mykonos(const uint16_t gain)
return (MAX_TX_GAIN - (static_cast<double>(gain) / 1e3));
}
-void ad937x_device::_apply_gain_pins(
- const direction_t direction,
- const chain_t chain
-) {
+void ad937x_device::_apply_gain_pins(const direction_t direction, const chain_t chain)
+{
// get this channels configuration
const auto chan = gain_ctrl.config.at(direction).at(chain);
@@ -207,51 +189,44 @@ void ad937x_device::_apply_gain_pins(
const auto state = _move_to_config_state();
- switch (direction)
- {
- case RX_DIRECTION:
- {
+ switch (direction) {
+ case RX_DIRECTION: {
std::function<decltype(MYKONOS_setRx1GainCtrlPin)> func;
- switch (chain)
- {
- case chain_t::ONE:
- func = MYKONOS_setRx1GainCtrlPin;
- break;
- case chain_t::TWO:
- func = MYKONOS_setRx2GainCtrlPin;
- break;
+ switch (chain) {
+ case chain_t::ONE:
+ func = MYKONOS_setRx1GainCtrlPin;
+ break;
+ case chain_t::TWO:
+ func = MYKONOS_setRx2GainCtrlPin;
+ break;
}
CALL_GPIO_API(func(mykonos_config.device,
- chan.inc_step,
- chan.dec_step,
- chan.inc_pin,
- chan.dec_pin,
- chan.enable));
+ chan.inc_step,
+ chan.dec_step,
+ chan.inc_pin,
+ chan.dec_pin,
+ chan.enable));
break;
}
- case TX_DIRECTION:
- {
+ case TX_DIRECTION: {
// TX sets attenuation, but the configuration should be stored correctly
- switch (chain)
- {
- case chain_t::ONE:
- // TX1 has an extra parameter "useTx1ForTx2" that we do not support
- CALL_GPIO_API(MYKONOS_setTx1AttenCtrlPin(
- mykonos_config.device,
+ switch (chain) {
+ case chain_t::ONE:
+ // TX1 has an extra parameter "useTx1ForTx2" that we do not support
+ CALL_GPIO_API(MYKONOS_setTx1AttenCtrlPin(mykonos_config.device,
chan.inc_step,
chan.inc_pin,
chan.dec_pin,
chan.enable,
0));
- break;
- case chain_t::TWO:
- CALL_GPIO_API(MYKONOS_setTx2AttenCtrlPin(
- mykonos_config.device,
+ break;
+ case chain_t::TWO:
+ CALL_GPIO_API(MYKONOS_setTx2AttenCtrlPin(mykonos_config.device,
chan.inc_step,
chan.inc_pin,
chan.dec_pin,
chan.enable));
- break;
+ break;
}
break;
}
@@ -260,29 +235,27 @@ void ad937x_device::_apply_gain_pins(
}
-
/******************************************************
Initialization functions
******************************************************/
-ad937x_device::ad937x_device(
- mpm::types::regs_iface* iface,
+ad937x_device::ad937x_device(mpm::types::regs_iface* iface,
const size_t deserializer_lane_xbar,
- const gain_pins_t gain_pins) :
- full_spi_settings(iface),
- mykonos_config(&full_spi_settings.spi_settings, deserializer_lane_xbar),
- gain_ctrl(gain_pins)
+ const gain_pins_t gain_pins)
+ : full_spi_settings(iface)
+ , mykonos_config(&full_spi_settings.spi_settings, deserializer_lane_xbar)
+ , gain_ctrl(gain_pins)
{
}
-void ad937x_device::_setup_rf(){
+void ad937x_device::_setup_rf()
+{
// TODO: add setRfPllLoopFilter here
// Set frequencies
tune(uhd::RX_DIRECTION, RX_DEFAULT_FREQ, false);
tune(uhd::TX_DIRECTION, TX_DEFAULT_FREQ, false);
- if (!get_pll_lock_status(CLK_SYNTH | RX_SYNTH | TX_SYNTH | SNIFF_SYNTH, true))
- {
+ if (!get_pll_lock_status(CLK_SYNTH | RX_SYNTH | TX_SYNTH | SNIFF_SYNTH, true)) {
throw mpm::runtime_error("PLLs did not lock after initial tuning!");
}
@@ -299,54 +272,50 @@ void ad937x_device::_setup_rf(){
set_gain(uhd::RX_DIRECTION, chain_t::TWO, RX_DEFAULT_GAIN);
set_gain(uhd::TX_DIRECTION, chain_t::ONE, TX_DEFAULT_GAIN);
set_gain(uhd::TX_DIRECTION, chain_t::TWO, TX_DEFAULT_GAIN);
-
-
}
-void ad937x_device::setup_cal(
- const uint32_t init_cals_mask,
+void ad937x_device::setup_cal(const uint32_t init_cals_mask,
const uint32_t tracking_cals_mask,
- const uint32_t timeout
-) {
+ const uint32_t timeout)
+{
// Run and wait for init cals
CALL_API(MYKONOS_runInitCals(mykonos_config.device, init_cals_mask));
uint8_t errorFlag = 0, errorCode = 0;
- CALL_API(MYKONOS_waitInitCals(mykonos_config.device,
- timeout, &errorFlag, &errorCode));
+ CALL_API(
+ MYKONOS_waitInitCals(mykonos_config.device, timeout, &errorFlag, &errorCode));
if ((errorFlag != 0) || (errorCode != 0)) {
throw mpm::runtime_error("Init cals failed!");
// TODO: add more debugging information here
}
- CALL_API(MYKONOS_enableTrackingCals(mykonos_config.device,
- tracking_cals_mask));
+ CALL_API(MYKONOS_enableTrackingCals(mykonos_config.device, tracking_cals_mask));
// ready for radioOn
}
uint8_t ad937x_device::set_lo_source(
- const uhd::direction_t direction,
- const uint8_t pll_source
-) {
- switch (direction){
+ const uhd::direction_t direction, const uint8_t pll_source)
+{
+ switch (direction) {
case TX_DIRECTION:
mykonos_config.device->tx->txPllUseExternalLo = pll_source;
return pll_source;
case RX_DIRECTION:
mykonos_config.device->rx->rxPllUseExternalLo = pll_source;
return pll_source;
- default:
- MPM_THROW_INVALID_CODE_PATH();
+ default:
+ MPM_THROW_INVALID_CODE_PATH();
}
}
-uint8_t ad937x_device::get_lo_source(const uhd::direction_t direction) const {
- switch (direction){
+uint8_t ad937x_device::get_lo_source(const uhd::direction_t direction) const
+{
+ switch (direction) {
case TX_DIRECTION:
return mykonos_config.device->tx->txPllUseExternalLo;
case RX_DIRECTION:
return mykonos_config.device->rx->rxPllUseExternalLo;
- default:
- MPM_THROW_INVALID_CODE_PATH();
+ default:
+ MPM_THROW_INVALID_CODE_PATH();
}
}
void ad937x_device::begin_initialization()
@@ -355,8 +324,7 @@ void ad937x_device::begin_initialization()
_verify_product_id();
- if (!get_pll_lock_status(CLK_SYNTH))
- {
+ if (!get_pll_lock_status(CLK_SYNTH)) {
throw mpm::runtime_error("AD937x CLK_SYNTH PLL failed to lock");
}
@@ -370,14 +338,12 @@ void ad937x_device::finish_initialization()
CALL_API(MYKONOS_initArm(mykonos_config.device));
auto binary = _get_arm_binary();
- CALL_API(MYKONOS_loadArmFromBinary(
- mykonos_config.device,
- binary.data(),
- binary.size()));
+ CALL_API(
+ MYKONOS_loadArmFromBinary(mykonos_config.device, binary.data(), binary.size()));
// TODO: check ARM version before or after the load of the ARM
// currently binary has no readable version number until after it's loaded
- //Run setup RF
+ // Run setup RF
_setup_rf();
}
@@ -404,7 +370,6 @@ void ad937x_device::stop_radio()
}
-
/******************************************************
Get status functions
******************************************************/
@@ -455,8 +420,7 @@ uint8_t ad937x_device::get_device_rev()
api_version_t ad937x_device::get_api_version()
{
api_version_t api;
- CALL_API(MYKONOS_getApiVersion(
- mykonos_config.device,
+ CALL_API(MYKONOS_getApiVersion(mykonos_config.device,
&api.silicon_ver,
&api.major_ver,
&api.minor_ver,
@@ -469,25 +433,20 @@ arm_version_t ad937x_device::get_arm_version()
arm_version_t arm;
mykonosBuild_t build;
CALL_API(MYKONOS_getArmVersion(
- mykonos_config.device,
- &arm.major_ver,
- &arm.minor_ver,
- &arm.rc_ver,
- &build));
-
- switch (build)
- {
- case MYK_BUILD_RELEASE:
- arm.build_type = mpm::ad937x::device::build_type_t::RELEASE;
- break;
- case MYK_BUILD_DEBUG:
- arm.build_type = mpm::ad937x::device::build_type_t::DEBUG;
- break;
- case MYK_BUILD_TEST_OBJECT:
- arm.build_type = mpm::ad937x::device::build_type_t::TEST_OBJECT;
- break;
- default:
- MPM_THROW_INVALID_CODE_PATH();
+ mykonos_config.device, &arm.major_ver, &arm.minor_ver, &arm.rc_ver, &build));
+
+ switch (build) {
+ case MYK_BUILD_RELEASE:
+ arm.build_type = mpm::ad937x::device::build_type_t::RELEASE;
+ break;
+ case MYK_BUILD_DEBUG:
+ arm.build_type = mpm::ad937x::device::build_type_t::DEBUG;
+ break;
+ case MYK_BUILD_TEST_OBJECT:
+ arm.build_type = mpm::ad937x::device::build_type_t::TEST_OBJECT;
+ break;
+ default:
+ MPM_THROW_INVALID_CODE_PATH();
}
return arm;
@@ -509,7 +468,7 @@ double ad937x_device::set_clock_rate(const double req_rate)
{
const auto rate = static_cast<uint32_t>(req_rate / 1000.0);
- const auto state = _move_to_config_state();
+ const auto state = _move_to_config_state();
mykonos_config.device->clocks->deviceClock_kHz = rate;
CALL_API(MYKONOS_initDigitalClocks(mykonos_config.device));
_restore_from_config_state(state);
@@ -518,23 +477,19 @@ double ad937x_device::set_clock_rate(const double req_rate)
}
void ad937x_device::enable_channel(
- const direction_t direction,
- const chain_t chain,
- const bool enable
-) {
+ const direction_t direction, const chain_t chain, const bool enable)
+{
// TODO:
// Turns out the only code in the API that actually sets the channel enable settings
// is _initialize(). Need to figure out how to deal with this.
// mmeserve 8/24/2017
- // While it is possible to change the enable state after disabling the radio, we'll probably
- // always use the GPIO pins to do so. Delete this function at a later time.
+ // While it is possible to change the enable state after disabling the radio, we'll
+ // probably always use the GPIO pins to do so. Delete this function at a later time.
}
double ad937x_device::tune(
- const direction_t direction,
- const double value,
- const bool wait_for_lock = false
-) {
+ const direction_t direction, const double value, const bool wait_for_lock = false)
+{
// I'm not sure why we set the PLL value in the config AND as a function parameter
// but here it is
@@ -542,30 +497,27 @@ double ad937x_device::tune(
uint8_t locked_pll;
uint64_t* config_value;
const uint64_t integer_value = static_cast<uint64_t>(value);
- switch (direction)
- {
- case TX_DIRECTION:
- pll = TX_PLL;
- locked_pll = TX_SYNTH;
- config_value = &(mykonos_config.device->tx->txPllLoFrequency_Hz);
- break;
- case RX_DIRECTION:
- pll = RX_PLL;
- locked_pll = RX_SYNTH;
- config_value = &(mykonos_config.device->rx->rxPllLoFrequency_Hz);
- break;
- default:
- MPM_THROW_INVALID_CODE_PATH();
+ switch (direction) {
+ case TX_DIRECTION:
+ pll = TX_PLL;
+ locked_pll = TX_SYNTH;
+ config_value = &(mykonos_config.device->tx->txPllLoFrequency_Hz);
+ break;
+ case RX_DIRECTION:
+ pll = RX_PLL;
+ locked_pll = RX_SYNTH;
+ config_value = &(mykonos_config.device->rx->rxPllLoFrequency_Hz);
+ break;
+ default:
+ MPM_THROW_INVALID_CODE_PATH();
}
const auto state = _move_to_config_state();
- *config_value = integer_value;
+ *config_value = integer_value;
CALL_API(MYKONOS_setRfPllFrequency(mykonos_config.device, pll, integer_value));
- if (wait_for_lock)
- {
- if (!get_pll_lock_status(locked_pll, true))
- {
+ if (wait_for_lock) {
+ if (!get_pll_lock_status(locked_pll, true)) {
throw mpm::runtime_error("PLL did not lock");
}
}
@@ -574,24 +526,18 @@ double ad937x_device::tune(
return get_freq(direction);
}
-double ad937x_device::set_bw_filter(
- const direction_t direction,
- const double value
-) {
-
- switch (direction)
- {
- case TX_DIRECTION:
- {
- mykonos_config.device->tx->txProfile->rfBandwidth_Hz = value;
- mykonos_config.device->tx->txProfile->txBbf3dBCorner_kHz = value/1000;
- mykonos_config.device->tx->txProfile->txDac3dBCorner_kHz = value/1000;
+double ad937x_device::set_bw_filter(const direction_t direction, const double value)
+{
+ switch (direction) {
+ case TX_DIRECTION: {
+ mykonos_config.device->tx->txProfile->rfBandwidth_Hz = value;
+ mykonos_config.device->tx->txProfile->txBbf3dBCorner_kHz = value / 1000;
+ mykonos_config.device->tx->txProfile->txDac3dBCorner_kHz = value / 1000;
break;
}
- case RX_DIRECTION:
- {
- mykonos_config.device->rx->rxProfile->rfBandwidth_Hz = value;
- mykonos_config.device->rx->rxProfile->rxBbf3dBCorner_kHz = value/1000;
+ case RX_DIRECTION: {
+ mykonos_config.device->rx->rxProfile->rfBandwidth_Hz = value;
+ mykonos_config.device->rx->rxProfile->rxBbf3dBCorner_kHz = value / 1000;
break;
}
}
@@ -603,87 +549,76 @@ double ad937x_device::set_bw_filter(
double ad937x_device::set_gain(
- const direction_t direction,
- const chain_t chain,
- const double value
-) {
+ const direction_t direction, const chain_t chain, const double value)
+{
double coerced_value;
const auto state = _move_to_config_state();
- switch (direction)
- {
- case TX_DIRECTION:
- {
- const uint16_t attenuation = _convert_tx_gain_to_mykonos(value);
- coerced_value = static_cast<double>(attenuation);
-
- std::function<mykonosErr_t(mykonosDevice_t*, uint16_t)> func;
- switch (chain)
- {
- case chain_t::ONE:
- func = MYKONOS_setTx1Attenuation;
- break;
- case chain_t::TWO:
- func = MYKONOS_setTx2Attenuation;
+ switch (direction) {
+ case TX_DIRECTION: {
+ const uint16_t attenuation = _convert_tx_gain_to_mykonos(value);
+ coerced_value = static_cast<double>(attenuation);
+
+ std::function<mykonosErr_t(mykonosDevice_t*, uint16_t)> func;
+ switch (chain) {
+ case chain_t::ONE:
+ func = MYKONOS_setTx1Attenuation;
+ break;
+ case chain_t::TWO:
+ func = MYKONOS_setTx2Attenuation;
+ break;
+ default:
+ MPM_THROW_INVALID_CODE_PATH();
+ }
+ CALL_API(func(mykonos_config.device, attenuation));
break;
- default:
- MPM_THROW_INVALID_CODE_PATH();
}
- CALL_API(func(mykonos_config.device, attenuation));
- break;
- }
- case RX_DIRECTION:
- {
- const uint8_t gain = _convert_rx_gain_to_mykonos(value);
- coerced_value = static_cast<double>(gain);
-
- std::function<mykonosErr_t(mykonosDevice_t*, uint8_t)> func;
- switch (chain)
- {
- case chain_t::ONE:
- func = MYKONOS_setRx1ManualGain;
- break;
- case chain_t::TWO:
- func = MYKONOS_setRx2ManualGain;
+ case RX_DIRECTION: {
+ const uint8_t gain = _convert_rx_gain_to_mykonos(value);
+ coerced_value = static_cast<double>(gain);
+
+ std::function<mykonosErr_t(mykonosDevice_t*, uint8_t)> func;
+ switch (chain) {
+ case chain_t::ONE:
+ func = MYKONOS_setRx1ManualGain;
+ break;
+ case chain_t::TWO:
+ func = MYKONOS_setRx2ManualGain;
+ break;
+ default:
+ MPM_THROW_INVALID_CODE_PATH();
+ }
+ CALL_API(func(mykonos_config.device, gain));
break;
+ }
default:
MPM_THROW_INVALID_CODE_PATH();
- }
- CALL_API(func(mykonos_config.device, gain));
- break;
- }
- default:
- MPM_THROW_INVALID_CODE_PATH();
}
_restore_from_config_state(state);
return get_gain(direction, chain);
}
-void ad937x_device::set_agc_mode(
- const direction_t direction,
- const gain_mode_t mode
-) {
+void ad937x_device::set_agc_mode(const direction_t direction, const gain_mode_t mode)
+{
mykonosGainMode_t mykonos_mode;
- switch (direction)
- {
- case RX_DIRECTION:
- switch (mode)
- {
- case gain_mode_t::MANUAL:
- mykonos_mode = MGC;
- break;
- case gain_mode_t::AUTOMATIC:
- mykonos_mode = AGC;
- break;
- case gain_mode_t::HYBRID:
- mykonos_mode = HYBRID;
+ switch (direction) {
+ case RX_DIRECTION:
+ switch (mode) {
+ case gain_mode_t::MANUAL:
+ mykonos_mode = MGC;
+ break;
+ case gain_mode_t::AUTOMATIC:
+ mykonos_mode = AGC;
+ break;
+ case gain_mode_t::HYBRID:
+ mykonos_mode = HYBRID;
+ break;
+ default:
+ MPM_THROW_INVALID_CODE_PATH();
+ }
break;
default:
MPM_THROW_INVALID_CODE_PATH();
- }
- break;
- default:
- MPM_THROW_INVALID_CODE_PATH();
}
const auto state = _move_to_config_state();
@@ -692,74 +627,67 @@ void ad937x_device::set_agc_mode(
}
void ad937x_device::set_fir(
- const direction_t direction,
- int8_t gain,
- const std::vector<int16_t> & fir)
-{
- switch (direction)
- {
- case TX_DIRECTION:
- mykonos_config.tx_fir_config.set_fir(gain, fir);
- break;
- case RX_DIRECTION:
- mykonos_config.rx_fir_config.set_fir(gain, fir);
- break;
- default:
- MPM_THROW_INVALID_CODE_PATH();
+ const direction_t direction, int8_t gain, const std::vector<int16_t>& fir)
+{
+ switch (direction) {
+ case TX_DIRECTION:
+ mykonos_config.tx_fir_config.set_fir(gain, fir);
+ break;
+ case RX_DIRECTION:
+ mykonos_config.rx_fir_config.set_fir(gain, fir);
+ break;
+ default:
+ MPM_THROW_INVALID_CODE_PATH();
}
// TODO: reload this on device
}
-void ad937x_device::set_gain_pin_step_sizes(
- const direction_t direction,
- const chain_t chain,
- const double inc_step,
- const double dec_step
-) {
- if (direction == RX_DIRECTION)
- {
+void ad937x_device::set_gain_pin_step_sizes(const direction_t direction,
+ const chain_t chain,
+ const double inc_step,
+ const double dec_step)
+{
+ if (direction == RX_DIRECTION) {
gain_ctrl.config.at(direction).at(chain).inc_step =
static_cast<uint8_t>(inc_step / 0.5);
gain_ctrl.config.at(direction).at(chain).dec_step =
static_cast<uint8_t>(dec_step / 0.5);
- }
- else if (direction == TX_DIRECTION) {
+ } else if (direction == TX_DIRECTION) {
// !!! TX is attenuation direction, so the pins are flipped !!!
gain_ctrl.config.at(direction).at(chain).dec_step =
static_cast<uint8_t>(inc_step / 0.05);
gain_ctrl.config.at(direction).at(chain).inc_step =
static_cast<uint8_t>(dec_step / 0.05);
- }
- else {
+ } else {
MPM_THROW_INVALID_CODE_PATH();
}
_apply_gain_pins(direction, chain);
}
void ad937x_device::set_enable_gain_pins(
- const direction_t direction,
- const chain_t chain,
- const bool enable
-) {
+ const direction_t direction, const chain_t chain, const bool enable)
+{
gain_ctrl.config.at(direction).at(chain).enable = enable;
_apply_gain_pins(direction, chain);
}
-
/******************************************************
Get configuration functions
******************************************************/
double ad937x_device::get_freq(const direction_t direction)
{
mykonosRfPllName_t pll;
- switch (direction)
- {
- case TX_DIRECTION: pll = TX_PLL; break;
- case RX_DIRECTION: pll = RX_PLL; break;
- default:
- MPM_THROW_INVALID_CODE_PATH();
+ switch (direction) {
+ case TX_DIRECTION:
+ pll = TX_PLL;
+ break;
+ case RX_DIRECTION:
+ pll = RX_PLL;
+ break;
+ default:
+ MPM_THROW_INVALID_CODE_PATH();
}
// TODO: because coerced_pll is returned as an integer, it's not accurate
@@ -768,29 +696,22 @@ double ad937x_device::get_freq(const direction_t direction)
return static_cast<double>(coerced_pll);
}
-bool ad937x_device::get_pll_lock_status(
- const uint8_t pll,
- const bool wait_for_lock
-) {
+bool ad937x_device::get_pll_lock_status(const uint8_t pll, const bool wait_for_lock)
+{
uint8_t pll_status;
CALL_API(MYKONOS_checkPllsLockStatus(mykonos_config.device, &pll_status));
- if (not wait_for_lock)
- {
+ if (not wait_for_lock) {
return (pll_status & pll) == pll;
- }
- else {
- const auto lock_time =
- std::chrono::steady_clock::now()
- + std::chrono::milliseconds(PLL_LOCK_TIMEOUT_MS);
+ } else {
+ const auto lock_time = std::chrono::steady_clock::now()
+ + std::chrono::milliseconds(PLL_LOCK_TIMEOUT_MS);
bool locked = false;
- while (not locked and lock_time > std::chrono::steady_clock::now())
- {
+ while (not locked and lock_time > std::chrono::steady_clock::now()) {
locked = get_pll_lock_status(pll);
}
- if (!locked)
- {
+ if (!locked) {
// last chance
locked = get_pll_lock_status(pll);
}
@@ -798,39 +719,32 @@ bool ad937x_device::get_pll_lock_status(
}
}
-double ad937x_device::get_gain(
- const direction_t direction,
- const chain_t chain
-) {
- switch (direction)
- {
- case TX_DIRECTION:
- {
+double ad937x_device::get_gain(const direction_t direction, const chain_t chain)
+{
+ switch (direction) {
+ case TX_DIRECTION: {
std::function<mykonosErr_t(mykonosDevice_t*, uint16_t*)> func;
- switch (chain)
- {
- case chain_t::ONE:
- func = MYKONOS_getTx1Attenuation;
- break;
- case chain_t::TWO:
- func = MYKONOS_getTx2Attenuation;
- break;
+ switch (chain) {
+ case chain_t::ONE:
+ func = MYKONOS_getTx1Attenuation;
+ break;
+ case chain_t::TWO:
+ func = MYKONOS_getTx2Attenuation;
+ break;
}
uint16_t atten;
CALL_API(func(mykonos_config.device, &atten));
return _convert_tx_gain_from_mykonos(atten);
}
- case RX_DIRECTION:
- {
+ case RX_DIRECTION: {
std::function<mykonosErr_t(mykonosDevice_t*, uint8_t*)> func;
- switch (chain)
- {
- case chain_t::ONE:
- func = MYKONOS_getRx1Gain;
- break;
- case chain_t::TWO:
- func = MYKONOS_getRx2Gain;
- break;
+ switch (chain) {
+ case chain_t::ONE:
+ func = MYKONOS_getRx1Gain;
+ break;
+ case chain_t::TWO:
+ func = MYKONOS_getRx2Gain;
+ break;
}
uint8_t gain;
CALL_API(func(mykonos_config.device, &gain));
@@ -841,18 +755,15 @@ double ad937x_device::get_gain(
}
}
-std::vector<int16_t> ad937x_device::get_fir(
- const direction_t direction,
- int8_t &gain)
+std::vector<int16_t> ad937x_device::get_fir(const direction_t direction, int8_t& gain)
{
- switch (direction)
- {
- case TX_DIRECTION:
- return mykonos_config.tx_fir_config.get_fir(gain);
- case RX_DIRECTION:
- return mykonos_config.rx_fir_config.get_fir(gain);
- default:
- MPM_THROW_INVALID_CODE_PATH();
+ switch (direction) {
+ case TX_DIRECTION:
+ return mykonos_config.tx_fir_config.get_fir(gain);
+ case RX_DIRECTION:
+ return mykonos_config.rx_fir_config.get_fir(gain);
+ default:
+ MPM_THROW_INVALID_CODE_PATH();
}
}
@@ -868,95 +779,89 @@ int16_t ad937x_device::get_temperature()
void ad937x_device::set_master_clock_rate(const mcr_t rate)
{
switch (rate) {
- case MCR_125_00MHZ: {
- mykonos_config.device->clocks->deviceClock_kHz = 125000;
- mykonos_config.device->clocks->clkPllVcoFreq_kHz = 10000000;
- mykonos_config.device->clocks->clkPllVcoDiv = ::VCODIV_2;
- set_fir(TX_DIRECTION,
- mykonos_config.device->tx->txProfile->txFir->gain_dB,
- std::vector<int16_t>(ad937x_config_t::DEFAULT_TX_FIR,
- ad937x_config_t::DEFAULT_TX_FIR
- + ad937x_config_t::DEFAULT_TX_FIR_SIZE)
- );
- mykonos_config.device->tx->txProfile->iqRate_kHz = 125000;
- mykonos_config.device->tx->txProfile->primarySigBandwidth_Hz = 20000000;
- mykonos_config.device->tx->txProfile->rfBandwidth_Hz = 102000000;
- mykonos_config.device->tx->txProfile->txDac3dBCorner_kHz = 722000;
- mykonos_config.device->tx->txProfile->txBbf3dBCorner_kHz = 51000;
-
- set_fir(RX_DIRECTION,
- mykonos_config.device->rx->rxProfile->rxFir->gain_dB,
- std::vector<int16_t>(ad937x_config_t::DEFAULT_RX_FIR,
- ad937x_config_t::DEFAULT_RX_FIR
- + ad937x_config_t::DEFAULT_RX_FIR_SIZE)
- );
-
- mykonos_config.device->rx->rxProfile->iqRate_kHz = 125000;
- mykonos_config.device->rx->rxProfile->rxBbf3dBCorner_kHz = 102000;
-
- mykonos_config.device->obsRx->orxProfile->iqRate_kHz = 125000;
- mykonos_config.device->obsRx->orxProfile->rxBbf3dBCorner_kHz = 102000;
- break;
- }
- case MCR_122_88MHZ: {
- mykonos_config.device->clocks->deviceClock_kHz = 122880;
- mykonos_config.device->clocks->clkPllVcoFreq_kHz = 9830400;
- mykonos_config.device->clocks->clkPllVcoDiv = ::VCODIV_2;
- set_fir(TX_DIRECTION,
- mykonos_config.device->tx->txProfile->txFir->gain_dB,
- std::vector<int16_t>(ad937x_config_t::DEFAULT_TX_FIR,
- ad937x_config_t::DEFAULT_TX_FIR
- + ad937x_config_t::DEFAULT_TX_FIR_SIZE)
- );
- mykonos_config.device->tx->txProfile->iqRate_kHz = 122880;
- mykonos_config.device->tx->txProfile->primarySigBandwidth_Hz = 20000000;
- mykonos_config.device->tx->txProfile->rfBandwidth_Hz = 100000000;
- mykonos_config.device->tx->txProfile->txDac3dBCorner_kHz = 710539;
- mykonos_config.device->tx->txProfile->txBbf3dBCorner_kHz = 50000;
-
- set_fir(RX_DIRECTION,
- mykonos_config.device->rx->rxProfile->rxFir->gain_dB,
- std::vector<int16_t>(ad937x_config_t::DEFAULT_RX_FIR,
- ad937x_config_t::DEFAULT_RX_FIR
- + ad937x_config_t::DEFAULT_RX_FIR_SIZE)
- );
- mykonos_config.device->rx->rxProfile->iqRate_kHz = 122880;
- mykonos_config.device->rx->rxProfile->rxBbf3dBCorner_kHz = 100000;
-
- mykonos_config.device->obsRx->orxProfile->iqRate_kHz = 122880;
- mykonos_config.device->obsRx->orxProfile->rxBbf3dBCorner_kHz = 100000;
- break;
- }
- case MCR_153_60MHZ: {
- mykonos_config.device->clocks->deviceClock_kHz = 153600;
- mykonos_config.device->clocks->clkPllVcoFreq_kHz = 6144000;
- mykonos_config.device->clocks->clkPllVcoDiv = ::VCODIV_1;
- set_fir(TX_DIRECTION,
- mykonos_config.device->tx->txProfile->txFir->gain_dB,
- std::vector<int16_t>(ad937x_config_t::DEFAULT_TX_FIR_15366,
- ad937x_config_t::DEFAULT_TX_FIR_15366
- + ad937x_config_t::DEFAULT_TX_FIR_SIZE)
- );
- mykonos_config.device->tx->txProfile->iqRate_kHz = 153600;
- mykonos_config.device->tx->txProfile->primarySigBandwidth_Hz = 10000000;
- mykonos_config.device->tx->txProfile->rfBandwidth_Hz = 100000000;
- mykonos_config.device->tx->txProfile->txDac3dBCorner_kHz = 100000;
- mykonos_config.device->tx->txProfile->txBbf3dBCorner_kHz = 100000;
-
- set_fir(RX_DIRECTION,
- mykonos_config.device->rx->rxProfile->rxFir->gain_dB,
- std::vector<int16_t>(ad937x_config_t::DEFAULT_RX_FIR_15366,
- ad937x_config_t::DEFAULT_RX_FIR_15366
- + ad937x_config_t::DEFAULT_RX_FIR_SIZE)
- );
- mykonos_config.device->rx->rxProfile->iqRate_kHz = 153600;
- mykonos_config.device->rx->rxProfile->rxBbf3dBCorner_kHz = 100000;
-
- mykonos_config.device->obsRx->orxProfile->iqRate_kHz = 153600;
- mykonos_config.device->obsRx->orxProfile->rxBbf3dBCorner_kHz = 225000;
- break;
- }
- default:
- MPM_THROW_INVALID_CODE_PATH();
+ case MCR_125_00MHZ: {
+ mykonos_config.device->clocks->deviceClock_kHz = 125000;
+ mykonos_config.device->clocks->clkPllVcoFreq_kHz = 10000000;
+ mykonos_config.device->clocks->clkPllVcoDiv = ::VCODIV_2;
+ set_fir(TX_DIRECTION,
+ mykonos_config.device->tx->txProfile->txFir->gain_dB,
+ std::vector<int16_t>(ad937x_config_t::DEFAULT_TX_FIR,
+ ad937x_config_t::DEFAULT_TX_FIR
+ + ad937x_config_t::DEFAULT_TX_FIR_SIZE));
+ mykonos_config.device->tx->txProfile->iqRate_kHz = 125000;
+ mykonos_config.device->tx->txProfile->primarySigBandwidth_Hz = 20000000;
+ mykonos_config.device->tx->txProfile->rfBandwidth_Hz = 102000000;
+ mykonos_config.device->tx->txProfile->txDac3dBCorner_kHz = 722000;
+ mykonos_config.device->tx->txProfile->txBbf3dBCorner_kHz = 51000;
+
+ set_fir(RX_DIRECTION,
+ mykonos_config.device->rx->rxProfile->rxFir->gain_dB,
+ std::vector<int16_t>(ad937x_config_t::DEFAULT_RX_FIR,
+ ad937x_config_t::DEFAULT_RX_FIR
+ + ad937x_config_t::DEFAULT_RX_FIR_SIZE));
+
+ mykonos_config.device->rx->rxProfile->iqRate_kHz = 125000;
+ mykonos_config.device->rx->rxProfile->rxBbf3dBCorner_kHz = 102000;
+
+ mykonos_config.device->obsRx->orxProfile->iqRate_kHz = 125000;
+ mykonos_config.device->obsRx->orxProfile->rxBbf3dBCorner_kHz = 102000;
+ break;
+ }
+ case MCR_122_88MHZ: {
+ mykonos_config.device->clocks->deviceClock_kHz = 122880;
+ mykonos_config.device->clocks->clkPllVcoFreq_kHz = 9830400;
+ mykonos_config.device->clocks->clkPllVcoDiv = ::VCODIV_2;
+ set_fir(TX_DIRECTION,
+ mykonos_config.device->tx->txProfile->txFir->gain_dB,
+ std::vector<int16_t>(ad937x_config_t::DEFAULT_TX_FIR,
+ ad937x_config_t::DEFAULT_TX_FIR
+ + ad937x_config_t::DEFAULT_TX_FIR_SIZE));
+ mykonos_config.device->tx->txProfile->iqRate_kHz = 122880;
+ mykonos_config.device->tx->txProfile->primarySigBandwidth_Hz = 20000000;
+ mykonos_config.device->tx->txProfile->rfBandwidth_Hz = 100000000;
+ mykonos_config.device->tx->txProfile->txDac3dBCorner_kHz = 710539;
+ mykonos_config.device->tx->txProfile->txBbf3dBCorner_kHz = 50000;
+
+ set_fir(RX_DIRECTION,
+ mykonos_config.device->rx->rxProfile->rxFir->gain_dB,
+ std::vector<int16_t>(ad937x_config_t::DEFAULT_RX_FIR,
+ ad937x_config_t::DEFAULT_RX_FIR
+ + ad937x_config_t::DEFAULT_RX_FIR_SIZE));
+ mykonos_config.device->rx->rxProfile->iqRate_kHz = 122880;
+ mykonos_config.device->rx->rxProfile->rxBbf3dBCorner_kHz = 100000;
+
+ mykonos_config.device->obsRx->orxProfile->iqRate_kHz = 122880;
+ mykonos_config.device->obsRx->orxProfile->rxBbf3dBCorner_kHz = 100000;
+ break;
+ }
+ case MCR_153_60MHZ: {
+ mykonos_config.device->clocks->deviceClock_kHz = 153600;
+ mykonos_config.device->clocks->clkPllVcoFreq_kHz = 6144000;
+ mykonos_config.device->clocks->clkPllVcoDiv = ::VCODIV_1;
+ set_fir(TX_DIRECTION,
+ mykonos_config.device->tx->txProfile->txFir->gain_dB,
+ std::vector<int16_t>(ad937x_config_t::DEFAULT_TX_FIR_15366,
+ ad937x_config_t::DEFAULT_TX_FIR_15366
+ + ad937x_config_t::DEFAULT_TX_FIR_SIZE));
+ mykonos_config.device->tx->txProfile->iqRate_kHz = 153600;
+ mykonos_config.device->tx->txProfile->primarySigBandwidth_Hz = 10000000;
+ mykonos_config.device->tx->txProfile->rfBandwidth_Hz = 100000000;
+ mykonos_config.device->tx->txProfile->txDac3dBCorner_kHz = 100000;
+ mykonos_config.device->tx->txProfile->txBbf3dBCorner_kHz = 100000;
+
+ set_fir(RX_DIRECTION,
+ mykonos_config.device->rx->rxProfile->rxFir->gain_dB,
+ std::vector<int16_t>(ad937x_config_t::DEFAULT_RX_FIR_15366,
+ ad937x_config_t::DEFAULT_RX_FIR_15366
+ + ad937x_config_t::DEFAULT_RX_FIR_SIZE));
+ mykonos_config.device->rx->rxProfile->iqRate_kHz = 153600;
+ mykonos_config.device->rx->rxProfile->rxBbf3dBCorner_kHz = 100000;
+
+ mykonos_config.device->obsRx->orxProfile->iqRate_kHz = 153600;
+ mykonos_config.device->obsRx->orxProfile->rxBbf3dBCorner_kHz = 225000;
+ break;
+ }
+ default:
+ MPM_THROW_INVALID_CODE_PATH();
}
}
diff --git a/mpm/lib/mykonos/ad937x_device.hpp b/mpm/lib/mykonos/ad937x_device.hpp
index 55c6f0cad..8ee77db54 100644
--- a/mpm/lib/mykonos/ad937x_device.hpp
+++ b/mpm/lib/mykonos/ad937x_device.hpp
@@ -6,29 +6,27 @@
#pragma once
+#include "ad937x_device_types.hpp"
+#include "adi/mykonos_debug/t_mykonos_dbgjesd.h"
+#include "adi/t_mykonos.h"
+#include "adi/t_mykonos_gpio.h"
#include "config/ad937x_config_t.hpp"
#include "config/ad937x_fir.hpp"
#include "config/ad937x_gain_ctrl_config.hpp"
-#include "mpm/ad937x/adi_ctrl.hpp"
-#include "ad937x_device_types.hpp"
#include "mpm/ad937x/ad937x_ctrl_types.hpp"
-#include "adi/t_mykonos.h"
-#include "adi/t_mykonos_gpio.h"
-#include "adi/mykonos_debug/t_mykonos_dbgjesd.h"
-
-#include <mpm/spi/spi_iface.hpp>
+#include "mpm/ad937x/adi_ctrl.hpp"
#include <mpm/exception.hpp>
-#include <boost/noncopyable.hpp>
+#include <mpm/spi/spi_iface.hpp>
#include <boost/filesystem.hpp>
-#include <memory>
+#include <boost/noncopyable.hpp>
#include <functional>
+#include <memory>
class ad937x_device : public boost::noncopyable
{
public:
enum class gain_mode_t { MANUAL, AUTOMATIC, HYBRID };
- enum pll_t : uint8_t
- {
+ enum pll_t : uint8_t {
CLK_SYNTH = 0x01,
RX_SYNTH = 0x02,
TX_SYNTH = 0x04,
@@ -36,30 +34,18 @@ public:
CALPLL_SDM = 0x10,
};
- enum mcr_t
- {
- MCR_122_88MHZ,
- MCR_125_00MHZ,
- MCR_153_60MHZ
- };
+ enum mcr_t { MCR_122_88MHZ, MCR_125_00MHZ, MCR_153_60MHZ };
- ad937x_device(
- mpm::types::regs_iface* iface,
+ ad937x_device(mpm::types::regs_iface* iface,
const size_t deserializer_lane_xbar,
- mpm::ad937x::gpio::gain_pins_t gain_pins
- );
+ mpm::ad937x::gpio::gain_pins_t gain_pins);
void begin_initialization();
void finish_initialization();
- void setup_cal(
- const uint32_t init_cals_mask,
- const uint32_t tracking_cals_mask,
- const uint32_t timeout
- );
- uint8_t set_lo_source(
- const uhd::direction_t direction,
- const uint8_t pll_source
- );
+ void setup_cal(const uint32_t init_cals_mask,
+ const uint32_t tracking_cals_mask,
+ const uint32_t timeout);
+ uint8_t set_lo_source(const uhd::direction_t direction, const uint8_t pll_source);
uint8_t get_lo_source(const uhd::direction_t direction) const;
void start_jesd_rx();
void start_jesd_tx();
@@ -77,66 +63,38 @@ public:
mpm::ad937x::device::api_version_t get_api_version();
mpm::ad937x::device::arm_version_t get_arm_version();
- double set_bw_filter(
- const uhd::direction_t direction,
- const double value
- );
- void set_agc_mode(
- const uhd::direction_t direction,
- const gain_mode_t mode
- );
+ double set_bw_filter(const uhd::direction_t direction, const double value);
+ void set_agc_mode(const uhd::direction_t direction, const gain_mode_t mode);
double set_clock_rate(const double value);
- void enable_channel(
- const uhd::direction_t direction,
- const mpm::ad937x::device::chain_t chain,
- const bool enable
- );
-
- double set_gain(
- const uhd::direction_t direction,
- const mpm::ad937x::device::chain_t chain,
- const double value
- );
+ void enable_channel(const uhd::direction_t direction,
+ const mpm::ad937x::device::chain_t chain,
+ const bool enable);
+
+ double set_gain(const uhd::direction_t direction,
+ const mpm::ad937x::device::chain_t chain,
+ const double value);
double get_gain(
- const uhd::direction_t direction,
- const mpm::ad937x::device::chain_t chain
- );
+ const uhd::direction_t direction, const mpm::ad937x::device::chain_t chain);
double tune(
- const uhd::direction_t direction,
- const double value,
- const bool wait_for_lock
- );
+ const uhd::direction_t direction, const double value, const bool wait_for_lock);
double get_freq(const uhd::direction_t direction);
- bool get_pll_lock_status(
- const uint8_t pll,
- const bool wait_for_lock=false
- );
+ bool get_pll_lock_status(const uint8_t pll, const bool wait_for_lock = false);
void set_fir(
- const uhd::direction_t direction,
- int8_t gain,
- const std::vector<int16_t>& fir
- );
- std::vector<int16_t> get_fir(
- const uhd::direction_t direction,
- int8_t &gain
- );
+ const uhd::direction_t direction, int8_t gain, const std::vector<int16_t>& fir);
+ std::vector<int16_t> get_fir(const uhd::direction_t direction, int8_t& gain);
int16_t get_temperature();
- void set_enable_gain_pins(
- const uhd::direction_t direction,
- const mpm::ad937x::device::chain_t chain,
- const bool enable
- );
- void set_gain_pin_step_sizes(
- const uhd::direction_t direction,
- const mpm::ad937x::device::chain_t chain,
- const double inc_step,
- const double dec_step
- );
+ void set_enable_gain_pins(const uhd::direction_t direction,
+ const mpm::ad937x::device::chain_t chain,
+ const bool enable);
+ void set_gain_pin_step_sizes(const uhd::direction_t direction,
+ const mpm::ad937x::device::chain_t chain,
+ const double inc_step,
+ const double dec_step);
void update_rx_lo_source(uint8_t rxPllUseExternalLo);
void update_tx_lo_source(uint8_t rxPllUseExternalLo);
uint8_t get_rx_lo_source();
@@ -160,9 +118,7 @@ private:
ad937x_gain_ctrl_config_t gain_ctrl;
void _apply_gain_pins(
- const uhd::direction_t direction,
- mpm::ad937x::device::chain_t chain
- );
+ const uhd::direction_t direction, mpm::ad937x::device::chain_t chain);
void _setup_rf();
void _call_api_function(const std::function<mykonosErr_t()>& func);
void _call_gpio_api_function(const std::function<mykonosGpioErr_t()>& func);
diff --git a/mpm/lib/mykonos/ad937x_device_types.hpp b/mpm/lib/mykonos/ad937x_device_types.hpp
index e4330d278..bdf995c15 100644
--- a/mpm/lib/mykonos/ad937x_device_types.hpp
+++ b/mpm/lib/mykonos/ad937x_device_types.hpp
@@ -11,27 +11,24 @@
#include <uhd/types/direction.hpp>
#include <uhd/types/ranges.hpp>
-namespace mpm {
- namespace ad937x {
- namespace device {
- enum class build_type_t { RELEASE, DEBUG, TEST_OBJECT };
-
- struct api_version_t {
- uint32_t silicon_ver;
- uint32_t major_ver;
- uint32_t minor_ver;
- uint32_t build_ver;
- };
-
- struct arm_version_t {
- uint8_t major_ver;
- uint8_t minor_ver;
- uint8_t rc_ver;
- build_type_t build_type;
- };
-
- enum class chain_t { ONE, TWO };
- }
- }
-}
-
+namespace mpm { namespace ad937x { namespace device {
+enum class build_type_t { RELEASE, DEBUG, TEST_OBJECT };
+
+struct api_version_t
+{
+ uint32_t silicon_ver;
+ uint32_t major_ver;
+ uint32_t minor_ver;
+ uint32_t build_ver;
+};
+
+struct arm_version_t
+{
+ uint8_t major_ver;
+ uint8_t minor_ver;
+ uint8_t rc_ver;
+ build_type_t build_type;
+};
+
+enum class chain_t { ONE, TWO };
+}}} // namespace mpm::ad937x::device
diff --git a/mpm/lib/mykonos/ad937x_spi_iface.cpp b/mpm/lib/mykonos/ad937x_spi_iface.cpp
index d78f4951f..3944c2906 100644
--- a/mpm/lib/mykonos/ad937x_spi_iface.cpp
+++ b/mpm/lib/mykonos/ad937x_spi_iface.cpp
@@ -9,22 +9,17 @@
using namespace mpm::spi;
-static const int MYK_SPI_SPEED_HZ = 20000000;
+static const int MYK_SPI_SPEED_HZ = 20000000;
static const size_t MYK_ADDR_SHIFT = 8;
static const size_t MYK_DATA_SHIFT = 0;
-static const size_t MYK_READ_FLAG = 1 << 23;
+static const size_t MYK_READ_FLAG = 1 << 23;
static const size_t MYK_WRITE_FLAG = 0;
-mpm::types::regs_iface::sptr mpm::chips::make_ad937x_iface(
- const std::string &spi_device
-) {
- return make_spi_regs_iface(
- spi_iface::make_spidev(spi_device, MYK_SPI_SPEED_HZ),
+mpm::types::regs_iface::sptr mpm::chips::make_ad937x_iface(const std::string& spi_device)
+{
+ return make_spi_regs_iface(spi_iface::make_spidev(spi_device, MYK_SPI_SPEED_HZ),
MYK_ADDR_SHIFT,
MYK_DATA_SHIFT,
MYK_READ_FLAG,
- MYK_WRITE_FLAG
- );
+ MYK_WRITE_FLAG);
}
-
-
diff --git a/mpm/lib/mykonos/adi_ctrl.cpp b/mpm/lib/mykonos/adi_ctrl.cpp
index 2ae0ef663..83e363bc8 100644
--- a/mpm/lib/mykonos/adi_ctrl.cpp
+++ b/mpm/lib/mykonos/adi_ctrl.cpp
@@ -5,32 +5,28 @@
//
#include "adi/common.h"
-
+#include <uhd/exception.hpp>
#include <mpm/ad937x/adi_ctrl.hpp>
#include <mpm/types/log_buf.hpp>
-#include <uhd/exception.hpp>
#include <boost/format.hpp>
-
-#include <iostream>
#include <chrono>
-#include <thread>
+#include <iostream>
#include <sstream>
+#include <thread>
-ad9371_spiSettings_t::ad9371_spiSettings_t(
- mpm::types::regs_iface* spi_iface_
-) :
- spi_iface(spi_iface_)
+ad9371_spiSettings_t::ad9371_spiSettings_t(mpm::types::regs_iface* spi_iface_)
+ : spi_iface(spi_iface_)
{
- spi_settings.chipSelectIndex = 0; // set later
- spi_settings.writeBitPolarity = 1; // unused
+ spi_settings.chipSelectIndex = 0; // set later
+ spi_settings.writeBitPolarity = 1; // unused
spi_settings.longInstructionWord = 1;
- spi_settings.MSBFirst = 1;
- spi_settings.CPHA = 0;
- spi_settings.CPOL = 0;
- spi_settings.enSpiStreaming = 0; // unused
- spi_settings.autoIncAddrUp = 0; // unused
- spi_settings.fourWireMode = 1; // unused
- spi_settings.spiClkFreq_Hz = 250000000; // currently unused
+ spi_settings.MSBFirst = 1;
+ spi_settings.CPHA = 0;
+ spi_settings.CPOL = 0;
+ spi_settings.enSpiStreaming = 0; // unused
+ spi_settings.autoIncAddrUp = 0; // unused
+ spi_settings.fourWireMode = 1; // unused
+ spi_settings.spiClkFreq_Hz = 250000000; // currently unused
}
// TODO: change // not implemented to meaningful errors
@@ -61,7 +57,7 @@ commonErr_t CMB_hardReset(uint8_t spiChipSelectIndex)
//
// allows the platform HAL to work with devices with various SPI settings
-commonErr_t CMB_setSPIOptions(spiSettings_t *spiSettings)
+commonErr_t CMB_setSPIOptions(spiSettings_t* spiSettings)
{
// not implemented
return COMMONERR_OK;
@@ -75,22 +71,21 @@ commonErr_t CMB_setSPIChannel(uint16_t chipSelectIndex)
}
// single SPI byte write function
-commonErr_t CMB_SPIWriteByte(spiSettings_t *spiSettings, uint16_t addr, uint8_t data)
+commonErr_t CMB_SPIWriteByte(spiSettings_t* spiSettings, uint16_t addr, uint8_t data)
{
if (spiSettings == nullptr || spiSettings->MSBFirst == 0) {
return COMMONERR_FAILED;
}
- ad9371_spiSettings_t *spi = ad9371_spiSettings_t::make(spiSettings);
+ ad9371_spiSettings_t* spi = ad9371_spiSettings_t::make(spiSettings);
try {
spi->spi_iface->poke8(addr, data);
return COMMONERR_OK;
- } catch (const std::exception &e) {
+ } catch (const std::exception& e) {
// TODO: spit out a reasonable error here (that will survive the C API transition)
std::stringstream ss;
ss << "Error in CMB_SPIWriteByte: " << e.what();
- CMB_writeToLog(
- ADIHAL_LOG_ERROR,
+ CMB_writeToLog(ADIHAL_LOG_ERROR,
spiSettings->chipSelectIndex,
ad9371_spi_errors_t::SPI_WRITE_ERROR,
ss.str().c_str());
@@ -99,31 +94,27 @@ commonErr_t CMB_SPIWriteByte(spiSettings_t *spiSettings, uint16_t addr, uint8_t
}
// multi SPI byte write function (address, data pairs)
-commonErr_t CMB_SPIWriteBytes(spiSettings_t *spiSettings, uint16_t *addr, uint8_t *data, uint32_t count)
+commonErr_t CMB_SPIWriteBytes(
+ spiSettings_t* spiSettings, uint16_t* addr, uint8_t* data, uint32_t count)
{
- if (spiSettings == nullptr ||
- addr == nullptr ||
- data == nullptr ||
- spiSettings->MSBFirst == 0)
- {
+ if (spiSettings == nullptr || addr == nullptr || data == nullptr
+ || spiSettings->MSBFirst == 0) {
return COMMONERR_FAILED;
}
- ad9371_spiSettings_t *spi = ad9371_spiSettings_t::make(spiSettings);
+ ad9371_spiSettings_t* spi = ad9371_spiSettings_t::make(spiSettings);
try {
- for (size_t i = 0; i < count; ++i)
- {
+ for (size_t i = 0; i < count; ++i) {
uint32_t data_word = (0) | (addr[i] << 8) | (data[i]);
spi->spi_iface->poke8(addr[i], data[i]);
}
return COMMONERR_OK;
- } catch (const std::exception &e) {
+ } catch (const std::exception& e) {
// TODO: spit out a reasonable error here (that will survive the C API transition)
std::stringstream ss;
ss << "Error in CMB_SPIWriteBytes: " << e.what();
- CMB_writeToLog(
- ADIHAL_LOG_ERROR,
+ CMB_writeToLog(ADIHAL_LOG_ERROR,
spiSettings->chipSelectIndex,
ad9371_spi_errors_t::SPI_WRITE_ERROR,
ss.str().c_str());
@@ -132,25 +123,21 @@ commonErr_t CMB_SPIWriteBytes(spiSettings_t *spiSettings, uint16_t *addr, uint8_
}
// single SPI byte read function
-commonErr_t CMB_SPIReadByte (spiSettings_t *spiSettings, uint16_t addr, uint8_t *readdata)
+commonErr_t CMB_SPIReadByte(spiSettings_t* spiSettings, uint16_t addr, uint8_t* readdata)
{
- if (spiSettings == nullptr ||
- readdata == nullptr ||
- spiSettings->MSBFirst == 0)
- {
+ if (spiSettings == nullptr || readdata == nullptr || spiSettings->MSBFirst == 0) {
return COMMONERR_FAILED;
}
- ad9371_spiSettings_t *spi = ad9371_spiSettings_t::make(spiSettings);
+ ad9371_spiSettings_t* spi = ad9371_spiSettings_t::make(spiSettings);
try {
*readdata = spi->spi_iface->peek8(addr);
return COMMONERR_OK;
- } catch (const std::exception &e) {
+ } catch (const std::exception& e) {
// TODO: spit out a reasonable error here (that will survive the C API transition)
std::stringstream ss;
ss << "Error in CMB_SPIReadByte: " << e.what();
- CMB_writeToLog(
- ADIHAL_LOG_ERROR,
+ CMB_writeToLog(ADIHAL_LOG_ERROR,
spiSettings->chipSelectIndex,
ad9371_spi_errors_t::SPI_READ_ERROR,
ss.str().c_str());
@@ -159,24 +146,24 @@ commonErr_t CMB_SPIReadByte (spiSettings_t *spiSettings, uint16_t addr, uint8_t
}
// write a field in a single register
-commonErr_t CMB_SPIWriteField(
- spiSettings_t *spiSettings,
- uint16_t addr, uint8_t field_val,
- uint8_t mask, uint8_t start_bit
-) {
- ad9371_spiSettings_t *spi = ad9371_spiSettings_t::make(spiSettings);
+commonErr_t CMB_SPIWriteField(spiSettings_t* spiSettings,
+ uint16_t addr,
+ uint8_t field_val,
+ uint8_t mask,
+ uint8_t start_bit)
+{
+ ad9371_spiSettings_t* spi = ad9371_spiSettings_t::make(spiSettings);
try {
uint8_t current_value = spi->spi_iface->peek8(addr);
- uint8_t new_value = ((current_value & ~mask) | (field_val << start_bit));
+ uint8_t new_value = ((current_value & ~mask) | (field_val << start_bit));
spi->spi_iface->poke8(addr, new_value);
return COMMONERR_OK;
- } catch (const std::exception &e) {
+ } catch (const std::exception& e) {
// TODO: spit out a reasonable error here (that will survive the C API transition)
std::stringstream ss;
ss << "Error in CMB_SPIWriteField: " << e.what();
- CMB_writeToLog(
- ADIHAL_LOG_ERROR,
+ CMB_writeToLog(ADIHAL_LOG_ERROR,
spiSettings->chipSelectIndex,
ad9371_spi_errors_t::SPI_WRITE_ERROR,
ss.str().c_str());
@@ -186,23 +173,23 @@ commonErr_t CMB_SPIWriteField(
// read a field in a single register
-commonErr_t CMB_SPIReadField(
- spiSettings_t *spiSettings,
- uint16_t addr, uint8_t *field_val,
- uint8_t mask, uint8_t start_bit
-) {
- ad9371_spiSettings_t *spi = ad9371_spiSettings_t::make(spiSettings);
+commonErr_t CMB_SPIReadField(spiSettings_t* spiSettings,
+ uint16_t addr,
+ uint8_t* field_val,
+ uint8_t mask,
+ uint8_t start_bit)
+{
+ ad9371_spiSettings_t* spi = ad9371_spiSettings_t::make(spiSettings);
try {
uint8_t value = spi->spi_iface->peek8(addr);
- *field_val = static_cast<uint8_t>((value & mask) >> start_bit);
+ *field_val = static_cast<uint8_t>((value & mask) >> start_bit);
return COMMONERR_OK;
- } catch (const std::exception &e) {
+ } catch (const std::exception& e) {
// TODO: spit out a reasonable error here (that will survive the C API transition)
std::stringstream ss;
ss << "Error in CMB_SPIReadField: " << e.what();
- CMB_writeToLog(
- ADIHAL_LOG_ERROR,
+ CMB_writeToLog(ADIHAL_LOG_ERROR,
spiSettings->chipSelectIndex,
ad9371_spi_errors_t::SPI_READ_ERROR,
ss.str().c_str());
@@ -223,35 +210,34 @@ commonErr_t CMB_wait_us(uint32_t time_us)
return COMMONERR_OK;
}
-commonErr_t CMB_setTimeout_ms(spiSettings_t *spiSettings, uint32_t timeOut_ms)
+commonErr_t CMB_setTimeout_ms(spiSettings_t* spiSettings, uint32_t timeOut_ms)
{
- ad9371_spiSettings_t *mpm_spi = ad9371_spiSettings_t::make(spiSettings);
- mpm_spi->timeout_start = std::chrono::steady_clock::now();
- mpm_spi->timeout_duration = std::chrono::milliseconds(timeOut_ms);
+ ad9371_spiSettings_t* mpm_spi = ad9371_spiSettings_t::make(spiSettings);
+ mpm_spi->timeout_start = std::chrono::steady_clock::now();
+ mpm_spi->timeout_duration = std::chrono::milliseconds(timeOut_ms);
return COMMONERR_OK;
}
-commonErr_t CMB_setTimeout_us(spiSettings_t *spiSettings, uint32_t timeOut_us)
+commonErr_t CMB_setTimeout_us(spiSettings_t* spiSettings, uint32_t timeOut_us)
{
- ad9371_spiSettings_t *mpm_spi = ad9371_spiSettings_t::make(spiSettings);
- mpm_spi->timeout_start = std::chrono::steady_clock::now();
- mpm_spi->timeout_duration = std::chrono::microseconds(timeOut_us);
+ ad9371_spiSettings_t* mpm_spi = ad9371_spiSettings_t::make(spiSettings);
+ mpm_spi->timeout_start = std::chrono::steady_clock::now();
+ mpm_spi->timeout_duration = std::chrono::microseconds(timeOut_us);
return COMMONERR_OK;
}
-commonErr_t CMB_hasTimeoutExpired(spiSettings_t *spiSettings)
+commonErr_t CMB_hasTimeoutExpired(spiSettings_t* spiSettings)
{
- ad9371_spiSettings_t *mpm_spi = ad9371_spiSettings_t::make(spiSettings);
- auto current_time = std::chrono::steady_clock::now();
- if ((std::chrono::steady_clock::now() - mpm_spi->timeout_start) > mpm_spi->timeout_duration)
- {
+ ad9371_spiSettings_t* mpm_spi = ad9371_spiSettings_t::make(spiSettings);
+ auto current_time = std::chrono::steady_clock::now();
+ if ((std::chrono::steady_clock::now() - mpm_spi->timeout_start)
+ > mpm_spi->timeout_duration) {
return COMMONERR_FAILED;
- }
- else {
+ } else {
return COMMONERR_OK;
}
}
// platform logging functions
-commonErr_t CMB_openLog(const char *filename)
+commonErr_t CMB_openLog(const char* filename)
{
// not implemented
return COMMONERR_FAILED;
@@ -263,22 +249,17 @@ commonErr_t CMB_closeLog(void)
}
commonErr_t CMB_writeToLog(
- ADI_LOGLEVEL level,
- uint8_t deviceIndex,
- uint32_t errorCode,
- const char *comment
-) {
+ ADI_LOGLEVEL level, uint8_t deviceIndex, uint32_t errorCode, const char* comment)
+{
mpm::types::log_level_t mpm_log_level;
if (level & ADIHAL_LOG_ERROR) {
mpm_log_level = mpm::types::log_level_t::ERROR;
- }
- else if (level & ADIHAL_LOG_WARNING) {
+ } else if (level & ADIHAL_LOG_WARNING) {
mpm_log_level = mpm::types::log_level_t::WARNING;
- }
- else {
+ } else {
mpm_log_level = mpm::types::log_level_t::TRACE;
}
- //FIXME: This caused segfault with the async pattern call to c++ from boost python
+ // FIXME: This caused segfault with the async pattern call to c++ from boost python
// mpm::types::log_buf::make_singleton()->post(
// mpm_log_level,
// "AD937X",
@@ -295,7 +276,7 @@ commonErr_t CMB_flushLog(void)
}
/* platform FPGA AXI register read/write functions */
-commonErr_t CMB_regRead(uint32_t offset, uint32_t *data)
+commonErr_t CMB_regRead(uint32_t offset, uint32_t* data)
{
// not implemented
return COMMONERR_FAILED;
@@ -307,12 +288,12 @@ commonErr_t CMB_regWrite(uint32_t offset, uint32_t data)
}
/* platform DDR3 memory read/write functions */
-commonErr_t CMB_memRead(uint32_t offset, uint32_t *data, uint32_t len)
+commonErr_t CMB_memRead(uint32_t offset, uint32_t* data, uint32_t len)
{
// not implemented
return COMMONERR_FAILED;
}
-commonErr_t CMB_memWrite(uint32_t offset, uint32_t *data, uint32_t len)
+commonErr_t CMB_memWrite(uint32_t offset, uint32_t* data, uint32_t len)
{
// not implemented
return COMMONERR_FAILED;
diff --git a/mpm/lib/mykonos/config/ad937x_config_t.cpp b/mpm/lib/mykonos/config/ad937x_config_t.cpp
index 9bebeafad..97651b0b4 100644
--- a/mpm/lib/mykonos/config/ad937x_config_t.cpp
+++ b/mpm/lib/mykonos/config/ad937x_config_t.cpp
@@ -7,87 +7,421 @@
#include "ad937x_config_t.hpp"
#include "ad937x_default_config.hpp"
-const int16_t ad937x_config_t::DEFAULT_TX_FIR[DEFAULT_TX_FIR_SIZE] =
- { -94, -26, 282, 177, -438, -368, 756, 732,-1170,-1337, 1758, 2479,-2648,-5088, 4064,16760,
- 16759, 4110,-4881,-2247, 2888, 1917,-1440,-1296, 745, 828, -358, -474, 164, 298, -16, -94 };
-
-const int16_t ad937x_config_t::DEFAULT_TX_FIR_15366[DEFAULT_TX_FIR_SIZE] =
- { 4, -16, -5, 75, -13, -229, 85, 547, -293,-1158, 738, 2290,-1640,-4805, 3687,17108,
- 17108, 3687,-4805,-1640, 2290, 738,-1158, -293, 547, 85, -229, -13, 75, -5, -16, 4 };
-
-const int16_t ad937x_config_t::DEFAULT_RX_FIR[DEFAULT_RX_FIR_SIZE] =
- { -20, 6, 66, 22, -128, -54, 240, 126, -402, -248, 634, 444, -956, -756, 1400, 1244,
- -2028,-2050, 2978, 3538,-4646,-7046, 9536,30880,30880, 9536,-7046,-4646, 3538, 2978,-2050,-2028,
- 1244, 1400, -756, -956, 444, 634, -248, -402, 126, 240, -54, -128, 22, 66, 6, -20 };
-
-const int16_t ad937x_config_t::DEFAULT_RX_FIR_15366[DEFAULT_RX_FIR_SIZE] =
- { -16, -22, 18, 74, 24, -132, -152, 132, 372, 38, -598, -474, 638, 1178, -206,-1952,
- -984, 2362, 3152,-1612,-6544,-2164,12806,26836,26836,12806,-2164,-6544,-1612, 3152, 2362, -984,
- -1952, -206, 1178, 638, -474, -598, 38, 372, 132, -152, -132, 24, 74, 18, -22, -16 };
-
-const int16_t ad937x_config_t::DEFAULT_OBSRX_FIR[DEFAULT_RX_FIR_SIZE] =
- { -14, -19, 44, 41, -89, -95, 175, 178, -303, -317, 499, 527, -779, -843, 1184, 1317,
- -1781,-2059, 2760, 3350,-4962,-7433, 9822,32154,32154, 9822,-7433,-4962, 3350, 2760,-2059,-1781,
- 1317, 1184, -843, -779, 527, 499, -317, -303, 178, 175, -95, -89, 41, 44, -19, -14 };
-
-const int16_t ad937x_config_t::DEFAULT_OBSRX_FIR_15366[DEFAULT_RX_FIR_SIZE] =
- { -2, 3, 12, -19, -28, 44, 74, -92, -169, 150, 353, -203, -671, 203, 1179, -66,
- -1952, -347, 3153, 1307,-5595,-4820,11323,29525,29525,11323,-4820,-5595, 1307, 3153, -347,-1952,
- -66, 1179, 203, -671, -203, 353, 150, -169, -92, 74, 44, -28, -19, 12, 3, -2 };
-
-const int16_t ad937x_config_t::DEFAULT_SNIFFER_FIR[DEFAULT_RX_FIR_SIZE] =
- { -1, -5, -14, -23, -16, 24, 92, 137, 80, -120, -378, -471, -174, 507, 1174, 1183,
- 98,-1771,-3216,-2641, 942, 7027,13533,17738,17738,13533, 7027, 942,-2641,-3216,-1771, 98,
- 1183, 1174, 507, -174, -471, -378, -120, 80, 137, 92, 24, -16, -23, -14, -5, -1 };
-
-const int16_t ad937x_config_t::DEFAULT_SNIFFER_FIR_15366[DEFAULT_RX_FIR_SIZE] =
- { 10, 31, 59, 71, 30, -92, -283, -456, -466, -175, 440, 1192, 1683, 1444, 198,-1871,
- -3988, -4942,-3512, 958, 8118,16519,23993,28395,28395,23993,16519, 8118, 958,-3512,-4942,-3988,
- -1871, 198, 1444, 1683, 1192, 440, -175, -466, -456, -283, -92, 30, 71, 59, 31, 10 };
-
-ad937x_config_t::ad937x_config_t(spiSettings_t* sps, const size_t deserializer_lane_xbar) :
- _rx(DEFAULT_RX_SETTINGS),
- _rxProfile(DEFAULT_RX_PROFILE),
- _framer(DEFAULT_FRAMER),
- _rxGainCtrl(DEFAULT_RX_GAIN),
- _rxPeakAgc(DEFAULT_RX_PEAK_AGC),
- _rxPowerAgc(DEFAULT_RX_POWER_AGC),
- _rxAgcCtrl(DEFAULT_RX_AGC_CTRL),
-
- _tx(DEFAULT_TX_SETTINGS),
- _txProfile(DEFAULT_TX_PROFILE),
- _deframer(DEFAULT_DEFRAMER),
+const int16_t ad937x_config_t::DEFAULT_TX_FIR[DEFAULT_TX_FIR_SIZE] = {-94,
+ -26,
+ 282,
+ 177,
+ -438,
+ -368,
+ 756,
+ 732,
+ -1170,
+ -1337,
+ 1758,
+ 2479,
+ -2648,
+ -5088,
+ 4064,
+ 16760,
+ 16759,
+ 4110,
+ -4881,
+ -2247,
+ 2888,
+ 1917,
+ -1440,
+ -1296,
+ 745,
+ 828,
+ -358,
+ -474,
+ 164,
+ 298,
+ -16,
+ -94};
+
+const int16_t ad937x_config_t::DEFAULT_TX_FIR_15366[DEFAULT_TX_FIR_SIZE] = {4,
+ -16,
+ -5,
+ 75,
+ -13,
+ -229,
+ 85,
+ 547,
+ -293,
+ -1158,
+ 738,
+ 2290,
+ -1640,
+ -4805,
+ 3687,
+ 17108,
+ 17108,
+ 3687,
+ -4805,
+ -1640,
+ 2290,
+ 738,
+ -1158,
+ -293,
+ 547,
+ 85,
+ -229,
+ -13,
+ 75,
+ -5,
+ -16,
+ 4};
+
+const int16_t ad937x_config_t::DEFAULT_RX_FIR[DEFAULT_RX_FIR_SIZE] = {-20,
+ 6,
+ 66,
+ 22,
+ -128,
+ -54,
+ 240,
+ 126,
+ -402,
+ -248,
+ 634,
+ 444,
+ -956,
+ -756,
+ 1400,
+ 1244,
+ -2028,
+ -2050,
+ 2978,
+ 3538,
+ -4646,
+ -7046,
+ 9536,
+ 30880,
+ 30880,
+ 9536,
+ -7046,
+ -4646,
+ 3538,
+ 2978,
+ -2050,
+ -2028,
+ 1244,
+ 1400,
+ -756,
+ -956,
+ 444,
+ 634,
+ -248,
+ -402,
+ 126,
+ 240,
+ -54,
+ -128,
+ 22,
+ 66,
+ 6,
+ -20};
+
+const int16_t ad937x_config_t::DEFAULT_RX_FIR_15366[DEFAULT_RX_FIR_SIZE] = {-16,
+ -22,
+ 18,
+ 74,
+ 24,
+ -132,
+ -152,
+ 132,
+ 372,
+ 38,
+ -598,
+ -474,
+ 638,
+ 1178,
+ -206,
+ -1952,
+ -984,
+ 2362,
+ 3152,
+ -1612,
+ -6544,
+ -2164,
+ 12806,
+ 26836,
+ 26836,
+ 12806,
+ -2164,
+ -6544,
+ -1612,
+ 3152,
+ 2362,
+ -984,
+ -1952,
+ -206,
+ 1178,
+ 638,
+ -474,
+ -598,
+ 38,
+ 372,
+ 132,
+ -152,
+ -132,
+ 24,
+ 74,
+ 18,
+ -22,
+ -16};
+
+const int16_t ad937x_config_t::DEFAULT_OBSRX_FIR[DEFAULT_RX_FIR_SIZE] = {-14,
+ -19,
+ 44,
+ 41,
+ -89,
+ -95,
+ 175,
+ 178,
+ -303,
+ -317,
+ 499,
+ 527,
+ -779,
+ -843,
+ 1184,
+ 1317,
+ -1781,
+ -2059,
+ 2760,
+ 3350,
+ -4962,
+ -7433,
+ 9822,
+ 32154,
+ 32154,
+ 9822,
+ -7433,
+ -4962,
+ 3350,
+ 2760,
+ -2059,
+ -1781,
+ 1317,
+ 1184,
+ -843,
+ -779,
+ 527,
+ 499,
+ -317,
+ -303,
+ 178,
+ 175,
+ -95,
+ -89,
+ 41,
+ 44,
+ -19,
+ -14};
+
+const int16_t ad937x_config_t::DEFAULT_OBSRX_FIR_15366[DEFAULT_RX_FIR_SIZE] = {-2,
+ 3,
+ 12,
+ -19,
+ -28,
+ 44,
+ 74,
+ -92,
+ -169,
+ 150,
+ 353,
+ -203,
+ -671,
+ 203,
+ 1179,
+ -66,
+ -1952,
+ -347,
+ 3153,
+ 1307,
+ -5595,
+ -4820,
+ 11323,
+ 29525,
+ 29525,
+ 11323,
+ -4820,
+ -5595,
+ 1307,
+ 3153,
+ -347,
+ -1952,
+ -66,
+ 1179,
+ 203,
+ -671,
+ -203,
+ 353,
+ 150,
+ -169,
+ -92,
+ 74,
+ 44,
+ -28,
+ -19,
+ 12,
+ 3,
+ -2};
+
+const int16_t ad937x_config_t::DEFAULT_SNIFFER_FIR[DEFAULT_RX_FIR_SIZE] = {-1,
+ -5,
+ -14,
+ -23,
+ -16,
+ 24,
+ 92,
+ 137,
+ 80,
+ -120,
+ -378,
+ -471,
+ -174,
+ 507,
+ 1174,
+ 1183,
+ 98,
+ -1771,
+ -3216,
+ -2641,
+ 942,
+ 7027,
+ 13533,
+ 17738,
+ 17738,
+ 13533,
+ 7027,
+ 942,
+ -2641,
+ -3216,
+ -1771,
+ 98,
+ 1183,
+ 1174,
+ 507,
+ -174,
+ -471,
+ -378,
+ -120,
+ 80,
+ 137,
+ 92,
+ 24,
+ -16,
+ -23,
+ -14,
+ -5,
+ -1};
+
+const int16_t ad937x_config_t::DEFAULT_SNIFFER_FIR_15366[DEFAULT_RX_FIR_SIZE] = {10,
+ 31,
+ 59,
+ 71,
+ 30,
+ -92,
+ -283,
+ -456,
+ -466,
+ -175,
+ 440,
+ 1192,
+ 1683,
+ 1444,
+ 198,
+ -1871,
+ -3988,
+ -4942,
+ -3512,
+ 958,
+ 8118,
+ 16519,
+ 23993,
+ 28395,
+ 28395,
+ 23993,
+ 16519,
+ 8118,
+ 958,
+ -3512,
+ -4942,
+ -3988,
+ -1871,
+ 198,
+ 1444,
+ 1683,
+ 1192,
+ 440,
+ -175,
+ -466,
+ -456,
+ -283,
+ -92,
+ 30,
+ 71,
+ 59,
+ 31,
+ 10};
+
+ad937x_config_t::ad937x_config_t(spiSettings_t* sps, const size_t deserializer_lane_xbar)
+ : _rx(DEFAULT_RX_SETTINGS)
+ , _rxProfile(DEFAULT_RX_PROFILE)
+ , _framer(DEFAULT_FRAMER)
+ , _rxGainCtrl(DEFAULT_RX_GAIN)
+ , _rxPeakAgc(DEFAULT_RX_PEAK_AGC)
+ , _rxPowerAgc(DEFAULT_RX_POWER_AGC)
+ , _rxAgcCtrl(DEFAULT_RX_AGC_CTRL)
+ ,
+
+ _tx(DEFAULT_TX_SETTINGS)
+ , _txProfile(DEFAULT_TX_PROFILE)
+ , _deframer(DEFAULT_DEFRAMER)
+ ,
// TODO: Remove if ADI ever fixes this
// The TX bring up requires a valid ORX profile
// https://github.com/EttusResearch/uhddev/blob/f0f8f58471c3fed94279c32f00e9f8da7db40efd/mpm/lib/mykonos/adi/mykonos.c#L16590
- _obsRx(DEFAULT_ORX_SETTINGS),
- _orxFramer(DEFAULT_ORX_FRAMER),
- _orxProfile(DEFAULT_ORX_PROFILE),
- _orxGainCtrl(DEFAULT_ORX_GAIN),
- _orxPeakAgc(DEFAULT_ORX_PEAK_AGC),
- _orxPowerAgc(DEFAULT_ORX_POWER_AGC),
- _orxAgcCtrl(DEFAULT_ORX_AGC_CTRL),
+ _obsRx(DEFAULT_ORX_SETTINGS)
+ , _orxFramer(DEFAULT_ORX_FRAMER)
+ , _orxProfile(DEFAULT_ORX_PROFILE)
+ , _orxGainCtrl(DEFAULT_ORX_GAIN)
+ , _orxPeakAgc(DEFAULT_ORX_PEAK_AGC)
+ , _orxPowerAgc(DEFAULT_ORX_POWER_AGC)
+ , _orxAgcCtrl(DEFAULT_ORX_AGC_CTRL)
+ ,
// TODO: Remove if ADI ever fixes this
// ORX bring up requires a valid sniffer gain control struct
// https://github.com/EttusResearch/uhddev/blob/f0f8f58471c3fed94279c32f00e9f8da7db40efd/mpm/lib/mykonos/adi/mykonos.c#L5752
- _snifferGainCtrl(DEFAULT_SNIFFER_GAIN),
+ _snifferGainCtrl(DEFAULT_SNIFFER_GAIN)
+ ,
- _armGpio(DEFAULT_ARM_GPIO),
- _gpio3v3(DEFAULT_GPIO_3V3),
- _gpio(DEFAULT_GPIO),
+ _armGpio(DEFAULT_ARM_GPIO)
+ , _gpio3v3(DEFAULT_GPIO_3V3)
+ , _gpio(DEFAULT_GPIO)
+ ,
- _auxIo(DEFAULT_AUX_IO),
- _clocks(DEFAULT_CLOCKS),
+ _auxIo(DEFAULT_AUX_IO)
+ , _clocks(DEFAULT_CLOCKS)
+ ,
- tx_fir_config(DEFAULT_TX_FIR_GAIN, std::vector<int16_t>(DEFAULT_TX_FIR, DEFAULT_TX_FIR + DEFAULT_TX_FIR_SIZE)),
- rx_fir_config(DEFAULT_RX_FIR_GAIN, std::vector<int16_t>(DEFAULT_RX_FIR, DEFAULT_RX_FIR + DEFAULT_RX_FIR_SIZE)),
- _orx_fir_config(DEFAULT_RX_FIR_GAIN, std::vector<int16_t>(DEFAULT_OBSRX_FIR, DEFAULT_OBSRX_FIR + DEFAULT_RX_FIR_SIZE)),
- _sniffer_rx_fir_config(DEFAULT_RX_FIR_GAIN, std::vector<int16_t>(DEFAULT_SNIFFER_FIR, DEFAULT_SNIFFER_FIR + DEFAULT_RX_FIR_SIZE))
+ tx_fir_config(DEFAULT_TX_FIR_GAIN,
+ std::vector<int16_t>(DEFAULT_TX_FIR, DEFAULT_TX_FIR + DEFAULT_TX_FIR_SIZE))
+ , rx_fir_config(DEFAULT_RX_FIR_GAIN,
+ std::vector<int16_t>(DEFAULT_RX_FIR, DEFAULT_RX_FIR + DEFAULT_RX_FIR_SIZE))
+ , _orx_fir_config(DEFAULT_RX_FIR_GAIN,
+ std::vector<int16_t>(
+ DEFAULT_OBSRX_FIR, DEFAULT_OBSRX_FIR + DEFAULT_RX_FIR_SIZE))
+ , _sniffer_rx_fir_config(DEFAULT_RX_FIR_GAIN,
+ std::vector<int16_t>(
+ DEFAULT_SNIFFER_FIR, DEFAULT_SNIFFER_FIR + DEFAULT_RX_FIR_SIZE))
{
- _device.spiSettings = sps;
+ _device.spiSettings = sps;
_deframer.deserializerLaneCrossbar = deserializer_lane_xbar;
_init_pointers();
@@ -95,52 +429,51 @@ ad937x_config_t::ad937x_config_t(spiSettings_t* sps, const size_t deserializer_l
device = &_device;
}
-// This function sets up all the pointers in all of our local members that represent the device struct
-// This function should only be called during construction.
+// This function sets up all the pointers in all of our local members that represent the
+// device struct This function should only be called during construction.
void ad937x_config_t::_init_pointers()
{
- _device.rx = &_rx;
- _device.tx = &_tx;
- _device.obsRx = &_obsRx;
- _device.auxIo = &_auxIo;
+ _device.rx = &_rx;
+ _device.tx = &_tx;
+ _device.obsRx = &_obsRx;
+ _device.auxIo = &_auxIo;
_device.clocks = &_clocks;
- _rx.rxProfile = &_rxProfile;
- _rx.framer = &_framer;
- _rx.rxGainCtrl = &_rxGainCtrl;
- _rx.rxAgcCtrl = &_rxAgcCtrl;
- _rxProfile.rxFir = rx_fir_config.fir;
+ _rx.rxProfile = &_rxProfile;
+ _rx.framer = &_framer;
+ _rx.rxGainCtrl = &_rxGainCtrl;
+ _rx.rxAgcCtrl = &_rxAgcCtrl;
+ _rxProfile.rxFir = rx_fir_config.fir;
_rxProfile.customAdcProfile = nullptr;
- _rxAgcCtrl.peakAgc = &_rxPeakAgc;
- _rxAgcCtrl.powerAgc = &_rxPowerAgc;
+ _rxAgcCtrl.peakAgc = &_rxPeakAgc;
+ _rxAgcCtrl.powerAgc = &_rxPowerAgc;
- _tx.txProfile = &_txProfile;
+ _tx.txProfile = &_txProfile;
_txProfile.txFir = tx_fir_config.fir;
- _tx.deframer = &_deframer;
+ _tx.deframer = &_deframer;
// AD9373
- _tx.dpdConfig = nullptr;
+ _tx.dpdConfig = nullptr;
_tx.clgcConfig = nullptr;
_tx.vswrConfig = nullptr;
// TODO: ideally we set none of this information and leave the profile as nullptr
// Check that the API supports this
- _obsRx.orxProfile = &_orxProfile;
- _obsRx.orxGainCtrl = &_orxGainCtrl;
- _obsRx.orxAgcCtrl = &_orxAgcCtrl;
- _orxProfile.rxFir = _orx_fir_config.fir;
+ _obsRx.orxProfile = &_orxProfile;
+ _obsRx.orxGainCtrl = &_orxGainCtrl;
+ _obsRx.orxAgcCtrl = &_orxAgcCtrl;
+ _orxProfile.rxFir = _orx_fir_config.fir;
_orxProfile.customAdcProfile = nullptr;
- _orxAgcCtrl.peakAgc = &_orxPeakAgc;
- _orxAgcCtrl.powerAgc = &_orxPowerAgc;
+ _orxAgcCtrl.peakAgc = &_orxPeakAgc;
+ _orxAgcCtrl.powerAgc = &_orxPowerAgc;
- _obsRx.snifferProfile = &_snifferProfile;
- _snifferProfile.rxFir = _sniffer_rx_fir_config.fir;
+ _obsRx.snifferProfile = &_snifferProfile;
+ _snifferProfile.rxFir = _sniffer_rx_fir_config.fir;
_obsRx.snifferGainCtrl = &_snifferGainCtrl;
// sniffer has no AGC ctrl, so leave as null
_obsRx.framer = &_orxFramer;
_auxIo.gpio3v3 = &_gpio3v3;
- _auxIo.gpio = &_gpio;
+ _auxIo.gpio = &_gpio;
_auxIo.armGpio = &_armGpio;
}
-
diff --git a/mpm/lib/mykonos/config/ad937x_config_t.hpp b/mpm/lib/mykonos/config/ad937x_config_t.hpp
index 7cbabb9b5..ab5ddb894 100644
--- a/mpm/lib/mykonos/config/ad937x_config_t.hpp
+++ b/mpm/lib/mykonos/config/ad937x_config_t.hpp
@@ -10,11 +10,11 @@
#include "ad937x_fir.hpp"
#include <boost/noncopyable.hpp>
// Allocates and links the entire mykonos config struct in a single class
-class ad937x_config_t : public boost::noncopyable
+class ad937x_config_t : public boost::noncopyable
{
public:
ad937x_config_t(spiSettings_t* sps, const size_t deserializer_lane_xbar);
- mykonosDevice_t * device;
+ mykonosDevice_t* device;
ad937x_fir rx_fir_config;
ad937x_fir tx_fir_config;
@@ -35,8 +35,9 @@ public:
static const int16_t DEFAULT_SNIFFER_FIR_15366[DEFAULT_RX_FIR_SIZE];
private:
- // The top level device struct is non-const and contains all other structs, so everything is "public"
- // a user could technically modify the pointers in the structs, but we have no way of preventing that
+ // The top level device struct is non-const and contains all other structs, so
+ // everything is "public" a user could technically modify the pointers in the structs,
+ // but we have no way of preventing that
mykonosDevice_t _device;
ad937x_fir _orx_fir_config;
diff --git a/mpm/lib/mykonos/config/ad937x_default_config.hpp b/mpm/lib/mykonos/config/ad937x_default_config.hpp
index e01c0c6d3..72fbd6cf5 100644
--- a/mpm/lib/mykonos/config/ad937x_default_config.hpp
+++ b/mpm/lib/mykonos/config/ad937x_default_config.hpp
@@ -9,368 +9,396 @@
// This file is more or less the static config provided by a run of the eval software
// except all pointers have been changed to nullptr
// Hopefully this helps the compiler use these as purely constants
-// The pointers should be filled in if these data structures are to be actually used with the API
+// The pointers should be filled in if these data structures are to be actually used with
+// the API
-static const mykonosRxSettings_t DEFAULT_RX_SETTINGS =
-{
- nullptr, // Rx datapath profile, 3dB corner frequencies, and digital filter enables
- nullptr, // Rx JESD204b framer configuration structure
- nullptr, // Rx Gain control settings structure
- nullptr, // Rx AGC control settings structure
- RX1_RX2, // The desired Rx Channels to enable during initialization
- 0, // Internal LO = 0, external LO*2 = 1
- 3500000000U, // Rx PLL LO Frequency (internal or external LO)
- 0 // Flag to choose if complex baseband or real IF data are selected for Rx and ObsRx paths. Where, if > 0 = real IF data, '0' = zero IF (IQ) data
+static const mykonosRxSettings_t DEFAULT_RX_SETTINGS = {
+ nullptr, // Rx datapath profile, 3dB corner frequencies, and digital filter enables
+ nullptr, // Rx JESD204b framer configuration structure
+ nullptr, // Rx Gain control settings structure
+ nullptr, // Rx AGC control settings structure
+ RX1_RX2, // The desired Rx Channels to enable during initialization
+ 0, // Internal LO = 0, external LO*2 = 1
+ 3500000000U, // Rx PLL LO Frequency (internal or external LO)
+ 0 // Flag to choose if complex baseband or real IF data are selected for Rx and ObsRx
+ // paths. Where, if > 0 = real IF data, '0' = zero IF (IQ) data
};
-static const mykonosRxProfile_t DEFAULT_RX_PROFILE =
-{ // Rx 100MHz, IQrate 125MSPS, Dec5
- 1, // The divider used to generate the ADC clock
- nullptr, // Pointer to Rx FIR filter structure
- 2, // Rx FIR decimation (1,2,4)
- 5, // Decimation of Dec5 or Dec4 filter (5,4)
- 1, // If set, and DEC5 filter used, will use a higher rejection DEC5 FIR filter (1=Enabled, 0=Disabled)
- 1, // RX Half band 1 decimation (1 or 2)
- 125000, // Rx IQ data rate in kHz
- 100000000, // The Rx RF passband bandwidth for the profile
- 102000, // Rx BBF 3dB corner in kHz
- NULL // pointer to custom ADC profile
+static const mykonosRxProfile_t DEFAULT_RX_PROFILE = {
+ // Rx 100MHz, IQrate 125MSPS, Dec5
+ 1, // The divider used to generate the ADC clock
+ nullptr, // Pointer to Rx FIR filter structure
+ 2, // Rx FIR decimation (1,2,4)
+ 5, // Decimation of Dec5 or Dec4 filter (5,4)
+ 1, // If set, and DEC5 filter used, will use a higher rejection DEC5 FIR filter
+ // (1=Enabled, 0=Disabled)
+ 1, // RX Half band 1 decimation (1 or 2)
+ 125000, // Rx IQ data rate in kHz
+ 100000000, // The Rx RF passband bandwidth for the profile
+ 102000, // Rx BBF 3dB corner in kHz
+ NULL // pointer to custom ADC profile
};
-static const mykonosJesd204bFramerConfig_t DEFAULT_FRAMER =
-{
- 0, // JESD204B Configuration Bank ID -extension to Device ID (Valid 0..15)
- 0, // JESD204B Configuration Device ID - link identification number. (Valid 0..255)
- 0, // JESD204B Configuration starting Lane ID. If more than one lane used, each lane will increment from the Lane0 ID. (Valid 0..31)
- 4, // number of ADCs (0, 2, or 4) - 2 ADCs per receive chain
- 20, // number of frames in a multiframe (default=32), F*K must be a multiple of 4. (F=2*M/numberOfLanes)
- 1, // scrambling off if framerScramble= 0, if framerScramble>0 scramble is enabled.
- 1, // 0=use internal SYSREF, 1= use external SYSREF
- 0x0F, // serializerLanesEnabled - bit per lane, [0] = Lane0 enabled, [1] = Lane1 enabled
- 0x4B, // serializerLaneCrossbar
- 26, // serializerAmplitude - default 22 (valid (0-31)
- 0, // preEmphasis - < default 4 (valid 0 - 7)
- 0, // invertLanePolarity - default 0 ([0] will invert lane [0], bit1 will invert lane1)
- 0, // lmfcOffset - LMFC offset value for deterministic latency setting
- 0, // Flag for determining if SYSREF on relink should be set. Where, if > 0 = set, 0 = not set
- 0, // Flag for determining if auto channel select for the xbar should be set. Where, if > 0 = set, '0' = not set
- 0, // Selects SYNCb input source. Where, 0 = use RXSYNCB for this framer, 1 = use OBSRX_SYNCB for this framer
- 1, // Flag for determining if CMOS mode for RX Sync signal is used. Where, if > 0 = CMOS, '0' = LVDS
- 0, // Selects framer bit repeat or oversampling mode for lane rate matching. Where, 0 = bitRepeat mode (changes effective lanerate), 1 = overSample (maintains same lane rate between ObsRx framer and Rx framer and oversamples the ADC samples)
- 1 // Flag for determining if API will calculate the appropriate settings for framer lane outputs to physical lanes. Where, if '0' = API will set automatic lane crossbar, '1' = set to manual mode and the value in serializerLaneCrossbar will be used
+static const mykonosJesd204bFramerConfig_t DEFAULT_FRAMER = {
+ 0, // JESD204B Configuration Bank ID -extension to Device ID (Valid 0..15)
+ 0, // JESD204B Configuration Device ID - link identification number. (Valid 0..255)
+ 0, // JESD204B Configuration starting Lane ID. If more than one lane used, each lane
+ // will increment from the Lane0 ID. (Valid 0..31)
+ 4, // number of ADCs (0, 2, or 4) - 2 ADCs per receive chain
+ 20, // number of frames in a multiframe (default=32), F*K must be a multiple of 4.
+ // (F=2*M/numberOfLanes)
+ 1, // scrambling off if framerScramble= 0, if framerScramble>0 scramble is enabled.
+ 1, // 0=use internal SYSREF, 1= use external SYSREF
+ 0x0F, // serializerLanesEnabled - bit per lane, [0] = Lane0 enabled, [1] = Lane1
+ // enabled
+ 0x4B, // serializerLaneCrossbar
+ 26, // serializerAmplitude - default 22 (valid (0-31)
+ 0, // preEmphasis - < default 4 (valid 0 - 7)
+ 0, // invertLanePolarity - default 0 ([0] will invert lane [0], bit1 will invert
+ // lane1)
+ 0, // lmfcOffset - LMFC offset value for deterministic latency setting
+ 0, // Flag for determining if SYSREF on relink should be set. Where, if > 0 = set, 0 =
+ // not set
+ 0, // Flag for determining if auto channel select for the xbar should be set. Where,
+ // if > 0 = set, '0' = not set
+ 0, // Selects SYNCb input source. Where, 0 = use RXSYNCB for this framer, 1 = use
+ // OBSRX_SYNCB for this framer
+ 1, // Flag for determining if CMOS mode for RX Sync signal is used. Where, if > 0 =
+ // CMOS, '0' = LVDS
+ 0, // Selects framer bit repeat or oversampling mode for lane rate matching. Where, 0
+ // = bitRepeat mode (changes effective lanerate), 1 = overSample (maintains same
+ // lane rate between ObsRx framer and Rx framer and oversamples the ADC samples)
+ 1 // Flag for determining if API will calculate the appropriate settings for framer
+ // lane outputs to physical lanes. Where, if '0' = API will set automatic lane
+ // crossbar, '1' = set to manual mode and the value in serializerLaneCrossbar will
+ // be used
};
-static const mykonosRxGainControl_t DEFAULT_RX_GAIN =
-{
- MGC, // Current Rx gain control mode setting
- 255, // Rx1 Gain Index, can be used in different ways for manual and AGC gain control
- 255, // Rx2 Gain Index, can be used in different ways for manual and AGC gain control
- 255, // Max gain index for the currently loaded Rx1 Gain table
- 195, // Min gain index for the currently loaded Rx1 Gain table
- 255, // Max gain index for the currently loaded Rx2 Gain table
- 195, // Min gain index for the currently loaded Rx2 Gain table
- 0, // Stores Rx1 RSSI value read back from the Mykonos
- 0 // Stores Rx2 RSSI value read back from the Mykonos
+static const mykonosRxGainControl_t DEFAULT_RX_GAIN = {
+ MGC, // Current Rx gain control mode setting
+ 255, // Rx1 Gain Index, can be used in different ways for manual and AGC gain control
+ 255, // Rx2 Gain Index, can be used in different ways for manual and AGC gain control
+ 255, // Max gain index for the currently loaded Rx1 Gain table
+ 195, // Min gain index for the currently loaded Rx1 Gain table
+ 255, // Max gain index for the currently loaded Rx2 Gain table
+ 195, // Min gain index for the currently loaded Rx2 Gain table
+ 0, // Stores Rx1 RSSI value read back from the Mykonos
+ 0 // Stores Rx2 RSSI value read back from the Mykonos
};
-static const mykonosPeakDetAgcCfg_t DEFAULT_RX_PEAK_AGC =
-{
- 0x1F, // apdHighThresh:
- 0x16, // apdLowThresh
- 0xB5, // hb2HighThresh
- 0x80, // hb2LowThresh
- 0x40, // hb2VeryLowThresh
- 0x06, // apdHighThreshExceededCnt
- 0x04, // apdLowThreshExceededCnt
- 0x06, // hb2HighThreshExceededCnt
- 0x04, // hb2LowThreshExceededCnt
- 0x04, // hb2VeryLowThreshExceededCnt
- 0x4, // apdHighGainStepAttack
- 0x2, // apdLowGainStepRecovery
- 0x4, // hb2HighGainStepAttack
- 0x2, // hb2LowGainStepRecovery
- 0x4, // hb2VeryLowGainStepRecovery
- 0x1, // apdFastAttack
- 0x1, // hb2FastAttack
- 0x1, // hb2OverloadDetectEnable
- 0x1, // hb2OverloadDurationCnt
- 0x1 // hb2OverloadThreshCnt
+static const mykonosPeakDetAgcCfg_t DEFAULT_RX_PEAK_AGC = {
+ 0x1F, // apdHighThresh:
+ 0x16, // apdLowThresh
+ 0xB5, // hb2HighThresh
+ 0x80, // hb2LowThresh
+ 0x40, // hb2VeryLowThresh
+ 0x06, // apdHighThreshExceededCnt
+ 0x04, // apdLowThreshExceededCnt
+ 0x06, // hb2HighThreshExceededCnt
+ 0x04, // hb2LowThreshExceededCnt
+ 0x04, // hb2VeryLowThreshExceededCnt
+ 0x4, // apdHighGainStepAttack
+ 0x2, // apdLowGainStepRecovery
+ 0x4, // hb2HighGainStepAttack
+ 0x2, // hb2LowGainStepRecovery
+ 0x4, // hb2VeryLowGainStepRecovery
+ 0x1, // apdFastAttack
+ 0x1, // hb2FastAttack
+ 0x1, // hb2OverloadDetectEnable
+ 0x1, // hb2OverloadDurationCnt
+ 0x1 // hb2OverloadThreshCnt
};
-static const mykonosPowerMeasAgcCfg_t DEFAULT_RX_POWER_AGC =
-{
- 0x01, // pmdUpperHighThresh
- 0x03, // pmdUpperLowThresh
- 0x0C, // pmdLowerHighThresh
- 0x04, // pmdLowerLowThresh
- 0x4, // pmdUpperHighGainStepAttack
- 0x2, // pmdUpperLowGainStepAttack
- 0x2, // pmdLowerHighGainStepRecovery
- 0x4, // pmdLowerLowGainStepRecovery
- 0x08, // pmdMeasDuration
- 0x02 // pmdMeasConfig
+static const mykonosPowerMeasAgcCfg_t DEFAULT_RX_POWER_AGC = {
+ 0x01, // pmdUpperHighThresh
+ 0x03, // pmdUpperLowThresh
+ 0x0C, // pmdLowerHighThresh
+ 0x04, // pmdLowerLowThresh
+ 0x4, // pmdUpperHighGainStepAttack
+ 0x2, // pmdUpperLowGainStepAttack
+ 0x2, // pmdLowerHighGainStepRecovery
+ 0x4, // pmdLowerLowGainStepRecovery
+ 0x08, // pmdMeasDuration
+ 0x02 // pmdMeasConfig
};
-static const mykonosAgcCfg_t DEFAULT_RX_AGC_CTRL =
-{
- 255, // AGC peak wait time
- 195, // agcRx1MinGainIndex
- 255, // agcRx2MaxGainIndex
- 195, // agcRx2MinGainIndex:
- 255, // agcObsRxMaxGainIndex
- 203, // agcObsRxMinGainIndex
- 1, // agcObsRxSelect
- 1, // agcPeakThresholdMode
- 1, // agcLowThsPreventGainIncrease
- 30720, // agcGainUpdateCounter
- 3, // agcSlowLoopSettlingDelay
- 2, // agcPeakWaitTime
- 0, // agcResetOnRxEnable
- 0, // agcEnableSyncPulseForGainCounter
- nullptr,// *peakAgc
+static const mykonosAgcCfg_t DEFAULT_RX_AGC_CTRL = {
+ 255, // AGC peak wait time
+ 195, // agcRx1MinGainIndex
+ 255, // agcRx2MaxGainIndex
+ 195, // agcRx2MinGainIndex:
+ 255, // agcObsRxMaxGainIndex
+ 203, // agcObsRxMinGainIndex
+ 1, // agcObsRxSelect
+ 1, // agcPeakThresholdMode
+ 1, // agcLowThsPreventGainIncrease
+ 30720, // agcGainUpdateCounter
+ 3, // agcSlowLoopSettlingDelay
+ 2, // agcPeakWaitTime
+ 0, // agcResetOnRxEnable
+ 0, // agcEnableSyncPulseForGainCounter
+ nullptr, // *peakAgc
nullptr // *powerAgc
};
-static const mykonosTxSettings_t DEFAULT_TX_SETTINGS =
-{
- nullptr, // Tx datapath profile, 3dB corner frequencies, and digital filter enables
- nullptr, // Mykonos JESD204b deframer config for the Tx data path
- TX1_TX2, // The desired Tx channels to enable during initialization
- 0, // Internal LO=0, external LO*2 if =1
- 3500000000U, // Tx PLL LO frequency (internal or external LO)
- TXATTEN_0P05_DB,// Initial and current Tx1 Attenuation
- 10000, // Initial and current Tx1 Attenuation mdB
- 10000, // Initial and current Tx2 Attenuation mdB
- nullptr, // DPD,CLGC,VSWR settings. Only valid for AD9373 device, set pointer to NULL otherwise
- nullptr, // CLGC Config Structure. Only valid for AD9373 device, set pointer to NULL otherwise
- nullptr // VSWR Config Structure. Only valid for AD9373 device, set pointer to NULL otherwise
+static const mykonosTxSettings_t DEFAULT_TX_SETTINGS = {
+ nullptr, // Tx datapath profile, 3dB corner frequencies, and digital filter enables
+ nullptr, // Mykonos JESD204b deframer config for the Tx data path
+ TX1_TX2, // The desired Tx channels to enable during initialization
+ 0, // Internal LO=0, external LO*2 if =1
+ 3500000000U, // Tx PLL LO frequency (internal or external LO)
+ TXATTEN_0P05_DB, // Initial and current Tx1 Attenuation
+ 10000, // Initial and current Tx1 Attenuation mdB
+ 10000, // Initial and current Tx2 Attenuation mdB
+ nullptr, // DPD,CLGC,VSWR settings. Only valid for AD9373 device, set pointer to NULL
+ // otherwise
+ nullptr, // CLGC Config Structure. Only valid for AD9373 device, set pointer to NULL
+ // otherwise
+ nullptr // VSWR Config Structure. Only valid for AD9373 device, set pointer to NULL
+ // otherwise
};
-static const mykonosTxProfile_t DEFAULT_TX_PROFILE =
-{ // Tx 20/100MHz, IQrate 122.88MHz, Dec5
- DACDIV_2p5, // The divider used to generate the DAC clock
- nullptr, // Pointer to Tx FIR filter structure
- 2, // The Tx digital FIR filter interpolation (1,2,4)
- 2, // Tx Halfband1 filter interpolation (1,2)
- 1, // Tx Halfband2 filter interpolation (1,2)
- 1, // TxInputHbInterpolation (1,2)
- 125000, // Tx IQ data rate in kHz
- 20000000, // Primary Signal BW
- 102000000, // The Tx RF passband bandwidth for the profile
- 722000, // The DAC filter 3dB corner in kHz
- 51000, // Tx BBF 3dB corner in kHz
- 0 // Enable DPD, only valid for AD9373
+static const mykonosTxProfile_t DEFAULT_TX_PROFILE = {
+ // Tx 20/100MHz, IQrate 122.88MHz, Dec5
+ DACDIV_2p5, // The divider used to generate the DAC clock
+ nullptr, // Pointer to Tx FIR filter structure
+ 2, // The Tx digital FIR filter interpolation (1,2,4)
+ 2, // Tx Halfband1 filter interpolation (1,2)
+ 1, // Tx Halfband2 filter interpolation (1,2)
+ 1, // TxInputHbInterpolation (1,2)
+ 125000, // Tx IQ data rate in kHz
+ 20000000, // Primary Signal BW
+ 102000000, // The Tx RF passband bandwidth for the profile
+ 722000, // The DAC filter 3dB corner in kHz
+ 51000, // Tx BBF 3dB corner in kHz
+ 0 // Enable DPD, only valid for AD9373
};
-static const mykonosJesd204bDeframerConfig_t DEFAULT_DEFRAMER =
-{
- 0, // bankId extension to Device ID (Valid 0..15)
- 0, // deviceId link identification number. (Valid 0..255)
- 0, // lane0Id Lane0 ID. (Valid 0..31)
- 4, // M number of DACss (0, 2, or 4) - 2 DACs per transmit chain
- 20, // K #frames in a multiframe (default=32), F*K=multiple of 4. (F=2*M/numberOfLanes)
- 0, // Scrambling off if scramble = 0, if framerScramble > 0 scrambling is enabled
- 1, // External SYSREF select. 0 = use internal SYSREF, 1 = external SYSREF
- 0x0F, // Deserializer lane select bit field. Where, [0] = Lane0 enabled, [1] = Lane1 enabled, etc
- 0xD2, // Lane crossbar to map physical lanes to deframer lane inputs [1:0] = Deframer Input 0 Lane section, [3:2] = Deframer Input 1 lane select, etc
- 1, // Equalizer setting. Applied to all deserializer lanes. Range is 0..4
- 0, // PN inversion per each lane. bit[0] = 1 Invert PN of Lane 0, bit[1] = Invert PN of Lane 1, etc).
- 0, // LMFC offset value to adjust deterministic latency. Range is 0..31
- 0, // Flag for determining if SYSREF on relink should be set. Where, if > 0 = set, '0' = not set
- 0, // Flag for determining if auto channel select for the xbar should be set. Where, if > 0 = set, '0' = not set
- 1, // Flag for determining if CMOS mode for TX Sync signal is used. Where, if > 0 = CMOS, '0' = LVDS
- 1, // Flag for determining if API will calculate the appropriate settings for deframer lane in to physical lanes. Where, if '0' = API will set automatic lane crossbar, '1' = set to manual mode and the value in deserializerLaneCrossbar will be used
+static const mykonosJesd204bDeframerConfig_t DEFAULT_DEFRAMER = {
+ 0, // bankId extension to Device ID (Valid 0..15)
+ 0, // deviceId link identification number. (Valid 0..255)
+ 0, // lane0Id Lane0 ID. (Valid 0..31)
+ 4, // M number of DACss (0, 2, or 4) - 2 DACs per transmit chain
+ 20, // K #frames in a multiframe (default=32), F*K=multiple of 4.
+ // (F=2*M/numberOfLanes)
+ 0, // Scrambling off if scramble = 0, if framerScramble > 0 scrambling is enabled
+ 1, // External SYSREF select. 0 = use internal SYSREF, 1 = external SYSREF
+ 0x0F, // Deserializer lane select bit field. Where, [0] = Lane0 enabled, [1] = Lane1
+ // enabled, etc
+ 0xD2, // Lane crossbar to map physical lanes to deframer lane inputs [1:0] = Deframer
+ // Input 0 Lane section, [3:2] = Deframer Input 1 lane select, etc
+ 1, // Equalizer setting. Applied to all deserializer lanes. Range is 0..4
+ 0, // PN inversion per each lane. bit[0] = 1 Invert PN of Lane 0, bit[1] = Invert PN
+ // of Lane 1, etc).
+ 0, // LMFC offset value to adjust deterministic latency. Range is 0..31
+ 0, // Flag for determining if SYSREF on relink should be set. Where, if > 0 = set, '0'
+ // = not set
+ 0, // Flag for determining if auto channel select for the xbar should be set. Where,
+ // if > 0 = set, '0' = not set
+ 1, // Flag for determining if CMOS mode for TX Sync signal is used. Where, if > 0 =
+ // CMOS, '0' = LVDS
+ 1, // Flag for determining if API will calculate the appropriate settings for deframer
+ // lane in to physical lanes. Where, if '0' = API will set automatic lane crossbar,
+ // '1' = set to manual mode and the value in deserializerLaneCrossbar will be used
};
-static const mykonosObsRxSettings_t DEFAULT_ORX_SETTINGS =
-{
- nullptr, // ORx datapath profile, 3dB corner frequencies, and digital filter enables
- nullptr, // ObsRx gain control settings structure
- nullptr, // ORx AGC control settings structure
- nullptr, // Sniffer datapath profile, 3dB corner frequencies, and digital filter enables
- nullptr, // SnRx gain control settings structure
- nullptr, // ObsRx JESD204b framer configuration structure
- MYK_ORX1, // obsRxChannel TODO: fix this garbage please
- OBSLO_TX_PLL, // (obsRxLoSource) The Obs Rx mixer can use the Tx Synth(TX_PLL) or Sniffer Synth (SNIFFER_PLL)
- 2600000000U, // SnRx PLL LO frequency in Hz
- 0, // Flag to choose if complex baseband or real IF data are selected for Rx and ObsRx paths. Where if > 0 = real IF data, '0' = complex data
- nullptr, // Custom Loopback ADC profile to set the bandwidth of the ADC response
- OBS_RXOFF // Default ObsRx channel to enter when radioOn called
+static const mykonosObsRxSettings_t DEFAULT_ORX_SETTINGS = {
+ nullptr, // ORx datapath profile, 3dB corner frequencies, and digital filter enables
+ nullptr, // ObsRx gain control settings structure
+ nullptr, // ORx AGC control settings structure
+ nullptr, // Sniffer datapath profile, 3dB corner frequencies, and digital filter
+ // enables
+ nullptr, // SnRx gain control settings structure
+ nullptr, // ObsRx JESD204b framer configuration structure
+ MYK_ORX1, // obsRxChannel TODO: fix this garbage please
+ OBSLO_TX_PLL, // (obsRxLoSource) The Obs Rx mixer can use the Tx Synth(TX_PLL) or
+ // Sniffer Synth (SNIFFER_PLL)
+ 2600000000U, // SnRx PLL LO frequency in Hz
+ 0, // Flag to choose if complex baseband or real IF data are selected for Rx and ObsRx
+ // paths. Where if > 0 = real IF data, '0' = complex data
+ nullptr, // Custom Loopback ADC profile to set the bandwidth of the ADC response
+ OBS_RXOFF // Default ObsRx channel to enter when radioOn called
};
-static const mykonosJesd204bFramerConfig_t DEFAULT_ORX_FRAMER =
-{
- 0, // JESD204B Configuration Bank ID -extension to Device ID (Valid 0..15)
- 0, // JESD204B Configuration Device ID - link identification number. (Valid 0..255)
- 0, // JESD204B Configuration starting Lane ID. If more than one lane used, each lane will increment from the Lane0 ID. (Valid 0..31)
- 2, // number of ADCs (0, 2, or 4) - 2 ADCs per receive chain
- 32, // number of frames in a multiframe (default=32), F*K must be a multiple of 4. (F=2*M/numberOfLanes)
- 1, // scrambling off if framerScramble= 0, if framerScramble>0 scramble is enabled.
- 1, // 0=use internal SYSREF, 1= use external SYSREF
- 0x00, // serializerLanesEnabled - bit per lane, [0] = Lane0 enabled, [1] = Lane1 enabled
- 0xE4, // Lane crossbar to map framer lane outputs to physical lanes
- 22, // serializerAmplitude - default 22 (valid (0-31)
- 4, // preEmphasis - < default 4 (valid 0 - 7)
- 0, // invertLanePolarity - default 0 ([0] will invert lane [0], bit1 will invert lane1)
- 0, // lmfcOffset - LMFC_Offset offset value for deterministic latency setting
- 0, // Flag for determining if SYSREF on relink should be set. Where, if > 0 = set, 0 = not set
- 0, // Flag for determining if auto channel select for the xbar should be set. Where, if > 0 = set, '0' = not set
- 1, // Selects SYNCb input source. Where, 0 = use RXSYNCB for this framer, 1 = use OBSRX_SYNCB for this framer
- 0, // Flag for determining if CMOS mode for RX Sync signal is used. Where, if > 0 = CMOS, '0' = LVDS
- 1, // Selects framer bit repeat or oversampling mode for lane rate matching. Where, 0 = bitRepeat mode (changes effective lanerate), 1 = overSample (maintains same lane rate between ObsRx framer and Rx framer and oversamples the ADC samples)
- 1 // Flag for determining if API will calculate the appropriate settings for framer lane outputs to physical lanes. Where, if '0' = API will set automatic lane crossbar, '1' = set to manual mode and the value in serializerLaneCrossbar will be used
+static const mykonosJesd204bFramerConfig_t DEFAULT_ORX_FRAMER = {
+ 0, // JESD204B Configuration Bank ID -extension to Device ID (Valid 0..15)
+ 0, // JESD204B Configuration Device ID - link identification number. (Valid 0..255)
+ 0, // JESD204B Configuration starting Lane ID. If more than one lane used, each lane
+ // will increment from the Lane0 ID. (Valid 0..31)
+ 2, // number of ADCs (0, 2, or 4) - 2 ADCs per receive chain
+ 32, // number of frames in a multiframe (default=32), F*K must be a multiple of 4.
+ // (F=2*M/numberOfLanes)
+ 1, // scrambling off if framerScramble= 0, if framerScramble>0 scramble is enabled.
+ 1, // 0=use internal SYSREF, 1= use external SYSREF
+ 0x00, // serializerLanesEnabled - bit per lane, [0] = Lane0 enabled, [1] = Lane1
+ // enabled
+ 0xE4, // Lane crossbar to map framer lane outputs to physical lanes
+ 22, // serializerAmplitude - default 22 (valid (0-31)
+ 4, // preEmphasis - < default 4 (valid 0 - 7)
+ 0, // invertLanePolarity - default 0 ([0] will invert lane [0], bit1 will invert
+ // lane1)
+ 0, // lmfcOffset - LMFC_Offset offset value for deterministic latency setting
+ 0, // Flag for determining if SYSREF on relink should be set. Where, if > 0 = set, 0 =
+ // not set
+ 0, // Flag for determining if auto channel select for the xbar should be set. Where,
+ // if > 0 = set, '0' = not set
+ 1, // Selects SYNCb input source. Where, 0 = use RXSYNCB for this framer, 1 = use
+ // OBSRX_SYNCB for this framer
+ 0, // Flag for determining if CMOS mode for RX Sync signal is used. Where, if > 0 =
+ // CMOS, '0' = LVDS
+ 1, // Selects framer bit repeat or oversampling mode for lane rate matching. Where, 0
+ // = bitRepeat mode (changes effective lanerate), 1 = overSample (maintains same
+ // lane rate between ObsRx framer and Rx framer and oversamples the ADC samples)
+ 1 // Flag for determining if API will calculate the appropriate settings for framer
+ // lane outputs to physical lanes. Where, if '0' = API will set automatic lane
+ // crossbar, '1' = set to manual mode and the value in serializerLaneCrossbar will
+ // be used
};
-static const mykonosORxGainControl_t DEFAULT_ORX_GAIN =
-{
- MGC, // Current ORx gain control mode setting
- 255, // ORx1 Gain Index, can be used in different ways for manual and AGC gain control
- 255, // ORx2 Gain Index, can be used in different ways for manual and AGC gain control
- 255, // Max gain index for the currently loaded ORx Gain table
- 237 // Min gain index for the currently loaded ORx Gain table
+static const mykonosORxGainControl_t DEFAULT_ORX_GAIN = {
+ MGC, // Current ORx gain control mode setting
+ 255, // ORx1 Gain Index, can be used in different ways for manual and AGC gain control
+ 255, // ORx2 Gain Index, can be used in different ways for manual and AGC gain control
+ 255, // Max gain index for the currently loaded ORx Gain table
+ 237 // Min gain index for the currently loaded ORx Gain table
};
-static const mykonosAgcCfg_t DEFAULT_ORX_AGC_CTRL =
-{
- 255, // agcRx1MaxGainIndex
- 195, // agcRx1MinGainIndex
- 255, // agcRx2MaxGainIndex
- 195, // agcRx2MinGainIndex:
- 255, // agcObsRxMaxGainIndex
- 203, // agcObsRxMinGainIndex
- 1, // agcObsRxSelect
- 1, // agcPeakThresholdMode
- 1, // agcLowThsPreventGainIncrease
- 30720, // agcGainUpdateCounter
- 3, // agcSlowLoopSettlingDelay
- 4, // agcPeakWaitTime
- 0, // agcResetOnRxEnable
- 0, // agcEnableSyncPulseForGainCounter
- nullptr,// *peakAgc
+static const mykonosAgcCfg_t DEFAULT_ORX_AGC_CTRL = {
+ 255, // agcRx1MaxGainIndex
+ 195, // agcRx1MinGainIndex
+ 255, // agcRx2MaxGainIndex
+ 195, // agcRx2MinGainIndex:
+ 255, // agcObsRxMaxGainIndex
+ 203, // agcObsRxMinGainIndex
+ 1, // agcObsRxSelect
+ 1, // agcPeakThresholdMode
+ 1, // agcLowThsPreventGainIncrease
+ 30720, // agcGainUpdateCounter
+ 3, // agcSlowLoopSettlingDelay
+ 4, // agcPeakWaitTime
+ 0, // agcResetOnRxEnable
+ 0, // agcEnableSyncPulseForGainCounter
+ nullptr, // *peakAgc
nullptr // *powerAgc
};
-static const mykonosPeakDetAgcCfg_t DEFAULT_ORX_PEAK_AGC =
-{
- 0x2A, // apdHighThresh:
- 0x16, // apdLowThresh
- 0xB5, // hb2HighThresh
- 0x72, // hb2LowThresh
- 0x40, // hb2VeryLowThresh
- 0x03, // apdHighThreshExceededCnt
- 0x03, // apdLowThreshExceededCnt
- 0x03, // hb2HighThreshExceededCnt
- 0x03, // hb2LowThreshExceededCnt
- 0x03, // hb2VeryLowThreshExceededCnt
- 0x4, // apdHighGainStepAttack
- 0x2, // apdLowGainStepRecovery
- 0x4, // hb2HighGainStepAttack
- 0x2, // hb2LowGainStepRecovery
- 0x4, // hb2VeryLowGainStepRecovery
- 0x0, // apdFastAttack
- 0x0, // hb2FastAttack
- 0x1, // hb2OverloadDetectEnable
- 0x1, // hb2OverloadDurationCnt
- 0x1 // hb2OverloadThreshCnt
+static const mykonosPeakDetAgcCfg_t DEFAULT_ORX_PEAK_AGC = {
+ 0x2A, // apdHighThresh:
+ 0x16, // apdLowThresh
+ 0xB5, // hb2HighThresh
+ 0x72, // hb2LowThresh
+ 0x40, // hb2VeryLowThresh
+ 0x03, // apdHighThreshExceededCnt
+ 0x03, // apdLowThreshExceededCnt
+ 0x03, // hb2HighThreshExceededCnt
+ 0x03, // hb2LowThreshExceededCnt
+ 0x03, // hb2VeryLowThreshExceededCnt
+ 0x4, // apdHighGainStepAttack
+ 0x2, // apdLowGainStepRecovery
+ 0x4, // hb2HighGainStepAttack
+ 0x2, // hb2LowGainStepRecovery
+ 0x4, // hb2VeryLowGainStepRecovery
+ 0x0, // apdFastAttack
+ 0x0, // hb2FastAttack
+ 0x1, // hb2OverloadDetectEnable
+ 0x1, // hb2OverloadDurationCnt
+ 0x1 // hb2OverloadThreshCnt
};
-static const mykonosPowerMeasAgcCfg_t DEFAULT_ORX_POWER_AGC =
-{
- 0x01, // pmdUpperHighThresh
- 0x03, // pmdUpperLowThresh
- 0x0C, // pmdLowerHighThresh
- 0x04, // pmdLowerLowThresh
- 0x0, // pmdUpperHighGainStepAttack
- 0x0, // pmdUpperLowGainStepAttack
- 0x0, // pmdLowerHighGainStepRecovery
- 0x0, // pmdLowerLowGainStepRecovery
- 0x08, // pmdMeasDuration
- 0x02 // pmdMeasConfig
+static const mykonosPowerMeasAgcCfg_t DEFAULT_ORX_POWER_AGC = {
+ 0x01, // pmdUpperHighThresh
+ 0x03, // pmdUpperLowThresh
+ 0x0C, // pmdLowerHighThresh
+ 0x04, // pmdLowerLowThresh
+ 0x0, // pmdUpperHighGainStepAttack
+ 0x0, // pmdUpperLowGainStepAttack
+ 0x0, // pmdLowerHighGainStepRecovery
+ 0x0, // pmdLowerLowGainStepRecovery
+ 0x08, // pmdMeasDuration
+ 0x02 // pmdMeasConfig
};
-static const mykonosSnifferGainControl_t DEFAULT_SNIFFER_GAIN =
-{
- MGC, // Current Sniffer gain control mode setting
- 255, // Current Sniffer gain index. Can be used differently for Manual Gain control/AGC
- 255, // Max gain index for the currently loaded Sniffer Gain table
- 203 // Min gain index for the currently loaded Sniffer Gain table
+static const mykonosSnifferGainControl_t DEFAULT_SNIFFER_GAIN = {
+ MGC, // Current Sniffer gain control mode setting
+ 255, // Current Sniffer gain index. Can be used differently for Manual Gain
+ // control/AGC
+ 255, // Max gain index for the currently loaded Sniffer Gain table
+ 203 // Min gain index for the currently loaded Sniffer Gain table
};
-static const mykonosRxProfile_t DEFAULT_ORX_PROFILE =
-{// ORX 100MHz, IQrate 125MSPS, Dec5
- 1, // The divider used to generate the ADC clock
- nullptr, // Pointer to Rx FIR filter structure or NULL
- 2, // Rx FIR decimation (1,2,4)
- 5, // Decimation of Dec5 or Dec4 filter (5,4)
- 0, // If set, and DEC5 filter used, will use a higher rejection DEC5 FIR filter (1=Enabled, 0=Disabled)
- 1, // RX Half band 1 decimation (1 or 2)
- 125000, // Rx IQ data rate in kHz
- 100000000, // The Rx RF passband bandwidth for the profile
- 102000, // Rx BBF 3dB corner in kHz
- nullptr // pointer to custom ADC profile
+static const mykonosRxProfile_t DEFAULT_ORX_PROFILE = {
+ // ORX 100MHz, IQrate 125MSPS, Dec5
+ 1, // The divider used to generate the ADC clock
+ nullptr, // Pointer to Rx FIR filter structure or NULL
+ 2, // Rx FIR decimation (1,2,4)
+ 5, // Decimation of Dec5 or Dec4 filter (5,4)
+ 0, // If set, and DEC5 filter used, will use a higher rejection DEC5 FIR filter
+ // (1=Enabled, 0=Disabled)
+ 1, // RX Half band 1 decimation (1 or 2)
+ 125000, // Rx IQ data rate in kHz
+ 100000000, // The Rx RF passband bandwidth for the profile
+ 102000, // Rx BBF 3dB corner in kHz
+ nullptr // pointer to custom ADC profile
};
-static const mykonosArmGpioConfig_t DEFAULT_ARM_GPIO =
-{
- 1, // useRx2EnablePin; //!< 0= RX1_ENABLE controls RX1 and RX2, 1 = separate RX1_ENABLE/RX2_ENABLE pins
- 1, // useTx2EnablePin; //!< 0= TX1_ENABLE controls TX1 and TX2, 1 = separate TX1_ENABLE/TX2_ENABLE pins
- 0, // txRxPinMode; //!< 0= ARM command mode, 1 = Pin mode to power up Tx/Rx chains
- 0, // orxPinMode; //!< 0= ARM command mode, 1 = Pin mode to power up ObsRx receiver
+static const mykonosArmGpioConfig_t DEFAULT_ARM_GPIO = {
+ 1, // useRx2EnablePin; //!< 0= RX1_ENABLE controls RX1 and RX2, 1 = separate
+ // RX1_ENABLE/RX2_ENABLE pins
+ 1, // useTx2EnablePin; //!< 0= TX1_ENABLE controls TX1 and TX2, 1 = separate
+ // TX1_ENABLE/TX2_ENABLE pins
+ 0, // txRxPinMode; //!< 0= ARM command mode, 1 = Pin mode to power up Tx/Rx chains
+ 0, // orxPinMode; //!< 0= ARM command mode, 1 = Pin mode to power up ObsRx
+ // receiver
- //Mykonos ARM input GPIO pins -- Only valid if orxPinMode = 1
- 0, // orxTriggerPin; //!< Select desired GPIO pin (valid 4-15)
- 0, // orxMode2Pin; //!< Select desired GPIO pin (valid 0-18)
- 0, // orxMode1Pin; //!< Select desired GPIO pin (valid 0-18)
- 0, // orxMode0Pin; //!< Select desired GPIO pin (valid 0-18)
+ // Mykonos ARM input GPIO pins -- Only valid if orxPinMode = 1
+ 0, // orxTriggerPin; //!< Select desired GPIO pin (valid 4-15)
+ 0, // orxMode2Pin; //!< Select desired GPIO pin (valid 0-18)
+ 0, // orxMode1Pin; //!< Select desired GPIO pin (valid 0-18)
+ 0, // orxMode0Pin; //!< Select desired GPIO pin (valid 0-18)
// Mykonos ARM output GPIO pins -- always available, even when pin mode not enabled
- 0, // rx1EnableAck; //!< Select desired GPIO pin (0-15), [4] = Output Enable
- 0, // rx2EnableAck; //!< Select desired GPIO pin (0-15), [4] = Output Enable
- 0, // tx1EnableAck; //!< Select desired GPIO pin (0-15), [4] = Output Enable
- 0, // tx2EnableAck; //!< Select desired GPIO pin (0-15), [4] = Output Enable
- 0, // orx1EnableAck; //!< Select desired GPIO pin (0-15), [4] = Output Enable
- 0, // orx2EnableAck; //!< Select desired GPIO pin (0-15), [4] = Output Enable
- 0, // srxEnableAck; //!< Select desired GPIO pin (0-15), [4] = Output Enable
- 0 // txObsSelect; //!< Select desired GPIO pin (0-15), [4] = Output Enable
- // When 2Tx are used with only 1 ORx input, this GPIO tells the BBIC which Tx channel is
- // active for calibrations, so BBIC can route correct RF Tx path into the single ORx input
+ 0, // rx1EnableAck; //!< Select desired GPIO pin (0-15), [4] = Output Enable
+ 0, // rx2EnableAck; //!< Select desired GPIO pin (0-15), [4] = Output Enable
+ 0, // tx1EnableAck; //!< Select desired GPIO pin (0-15), [4] = Output Enable
+ 0, // tx2EnableAck; //!< Select desired GPIO pin (0-15), [4] = Output Enable
+ 0, // orx1EnableAck; //!< Select desired GPIO pin (0-15), [4] = Output Enable
+ 0, // orx2EnableAck; //!< Select desired GPIO pin (0-15), [4] = Output Enable
+ 0, // srxEnableAck; //!< Select desired GPIO pin (0-15), [4] = Output Enable
+ 0 // txObsSelect; //!< Select desired GPIO pin (0-15), [4] = Output Enable
+ // When 2Tx are used with only 1 ORx input, this GPIO tells the BBIC which Tx
+ // channel is active for calibrations, so BBIC can route correct RF Tx path into the
+ // single ORx input
};
-static const mykonosGpio3v3_t DEFAULT_GPIO_3V3 =
-{
- 0, //!< Oe per pin, 1=output, 0 = input
- GPIO3V3_BITBANG_MODE, //!< Mode for GPIO3V3[3:0]
- GPIO3V3_BITBANG_MODE, //!< Mode for GPIO3V3[7:4]
- GPIO3V3_BITBANG_MODE, //!< Mode for GPIO3V3[11:8]
+static const mykonosGpio3v3_t DEFAULT_GPIO_3V3 = {
+ 0, //!< Oe per pin, 1=output, 0 = input
+ GPIO3V3_BITBANG_MODE, //!< Mode for GPIO3V3[3:0]
+ GPIO3V3_BITBANG_MODE, //!< Mode for GPIO3V3[7:4]
+ GPIO3V3_BITBANG_MODE, //!< Mode for GPIO3V3[11:8]
};
-static const mykonosGpioLowVoltage_t DEFAULT_GPIO =
-{
- 0, // Oe per pin, 1=output, 0 = input
- GPIO_MONITOR_MODE, // Mode for GPIO[3:0]
- GPIO_MONITOR_MODE, // Mode for GPIO[7:4]
- GPIO_MONITOR_MODE, // Mode for GPIO[11:8]
- GPIO_MONITOR_MODE, // Mode for GPIO[15:12]
- GPIO_MONITOR_MODE, // Mode for GPIO[18:16]
+static const mykonosGpioLowVoltage_t DEFAULT_GPIO = {
+ 0, // Oe per pin, 1=output, 0 = input
+ GPIO_MONITOR_MODE, // Mode for GPIO[3:0]
+ GPIO_MONITOR_MODE, // Mode for GPIO[7:4]
+ GPIO_MONITOR_MODE, // Mode for GPIO[11:8]
+ GPIO_MONITOR_MODE, // Mode for GPIO[15:12]
+ GPIO_MONITOR_MODE, // Mode for GPIO[18:16]
};
-static const mykonosAuxIo_t DEFAULT_AUX_IO =
-{
- 0, // auxDacEnable uint16_t
- { 0,0,0,0,0,0,0,0,0,0 }, // auxDacValue uint16[10]
- { 0,0,0,0,0,0,0,0,0,0 }, // auxDacSlope uint8[10]
- { 0,0,0,0,0,0,0,0,0,0 }, // auxDacVref uint8[10]
- nullptr, // *mykonosGpio3v3_t
- nullptr, // *mykonosGpioLowVoltage_t
- nullptr // *mykonosArmGpioConfig_t
+static const mykonosAuxIo_t DEFAULT_AUX_IO = {
+ 0, // auxDacEnable uint16_t
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, // auxDacValue uint16[10]
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, // auxDacSlope uint8[10]
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, // auxDacVref uint8[10]
+ nullptr, // *mykonosGpio3v3_t
+ nullptr, // *mykonosGpioLowVoltage_t
+ nullptr // *mykonosArmGpioConfig_t
};
-static const mykonosDigClocks_t DEFAULT_CLOCKS =
-{
- 125000, // CLKPLL and device reference clock frequency in kHz
- 10000000, // CLKPLL VCO frequency in kHz
- VCODIV_2, // CLKPLL VCO divider
- 4 // CLKPLL high speed clock divider
+static const mykonosDigClocks_t DEFAULT_CLOCKS = {
+ 125000, // CLKPLL and device reference clock frequency in kHz
+ 10000000, // CLKPLL VCO frequency in kHz
+ VCODIV_2, // CLKPLL VCO divider
+ 4 // CLKPLL high speed clock divider
};
-
-
diff --git a/mpm/lib/mykonos/config/ad937x_fir.cpp b/mpm/lib/mykonos/config/ad937x_fir.cpp
index 01c8772eb..6803f5369 100644
--- a/mpm/lib/mykonos/config/ad937x_fir.cpp
+++ b/mpm/lib/mykonos/config/ad937x_fir.cpp
@@ -6,21 +6,16 @@
#include "ad937x_fir.hpp"
-ad937x_fir::ad937x_fir() :
- ad937x_fir(0, { 1, 0 })
+ad937x_fir::ad937x_fir() : ad937x_fir(0, {1, 0}) {}
+
+ad937x_fir::ad937x_fir(int8_t gain, const std::vector<int16_t>& coefficients)
+ : // These two constructors will be run in the order they are declared in the class
+ // definition see C++ standard 12.6.2 section 13.3
+ _fir_coefficients(coefficients)
+ , _fir({gain,
+ static_cast<uint8_t>(_fir_coefficients.size()),
+ _fir_coefficients.data()})
{
-
-}
-
-ad937x_fir::ad937x_fir(int8_t gain, const std::vector<int16_t>& coefficients) :
- // These two constructors will be run in the order they are declared in the class definition
- // see C++ standard 12.6.2 section 13.3
- _fir_coefficients(coefficients),
- _fir({gain,
- static_cast<uint8_t>(_fir_coefficients.size()),
- _fir_coefficients.data()})
-{
-
}
// ad937x_fir.fir should not be accessed during this operation
@@ -29,11 +24,11 @@ void ad937x_fir::set_fir(int8_t gain, const std::vector<int16_t>& coefficients)
_fir.gain_dB = gain;
_fir_coefficients = coefficients;
- _fir.coefs = _fir_coefficients.data();
- _fir.numFirCoefs = static_cast<uint8_t>(_fir_coefficients.size());
+ _fir.coefs = _fir_coefficients.data();
+ _fir.numFirCoefs = static_cast<uint8_t>(_fir_coefficients.size());
}
-std::vector<int16_t> ad937x_fir::get_fir(int8_t &gain) const
+std::vector<int16_t> ad937x_fir::get_fir(int8_t& gain) const
{
gain = _fir.gain_dB;
return _fir_coefficients;
diff --git a/mpm/lib/mykonos/config/ad937x_fir.hpp b/mpm/lib/mykonos/config/ad937x_fir.hpp
index c3fda6fb7..df122701d 100644
--- a/mpm/lib/mykonos/config/ad937x_fir.hpp
+++ b/mpm/lib/mykonos/config/ad937x_fir.hpp
@@ -15,11 +15,12 @@ class ad937x_fir
{
std::vector<int16_t> _fir_coefficients;
mykonosFir_t _fir;
+
public:
mykonosFir_t* const fir = &_fir;
ad937x_fir();
ad937x_fir(int8_t gain, const std::vector<int16_t>& coefficients);
void set_fir(int8_t gain, const std::vector<int16_t>& coefficients);
- std::vector<int16_t> get_fir(int8_t &gain) const;
+ std::vector<int16_t> get_fir(int8_t& gain) const;
};
diff --git a/mpm/lib/mykonos/config/ad937x_gain_ctrl_config.cpp b/mpm/lib/mykonos/config/ad937x_gain_ctrl_config.cpp
index d4fbef0ad..bc8dcb21a 100644
--- a/mpm/lib/mykonos/config/ad937x_gain_ctrl_config.cpp
+++ b/mpm/lib/mykonos/config/ad937x_gain_ctrl_config.cpp
@@ -11,121 +11,158 @@ using namespace mpm::ad937x::device;
using namespace uhd;
const uint8_t ad937x_gain_ctrl_channel_t::DEFAULT_GAIN_STEP = 1;
-const bool ad937x_gain_ctrl_channel_t::DEFAULT_ENABLE = 0;
+const bool ad937x_gain_ctrl_channel_t::DEFAULT_ENABLE = 0;
// rx uses gain, tx uses attenuation
-enum class pin_direction_t
-{
+enum class pin_direction_t {
INCREASE,
DECREASE,
};
mykonosGpioSelect_t _convert_gain_pin(gain_pin_t pin)
{
- switch (pin)
- {
- case gain_pin_t::PIN0: return MYKGPIO0;
- case gain_pin_t::PIN1: return MYKGPIO1;
- case gain_pin_t::PIN2: return MYKGPIO2;
- case gain_pin_t::PIN3: return MYKGPIO3;
- case gain_pin_t::PIN4: return MYKGPIO4;
- case gain_pin_t::PIN5: return MYKGPIO5;
- case gain_pin_t::PIN6: return MYKGPIO6;
- case gain_pin_t::PIN7: return MYKGPIO7;
- case gain_pin_t::PIN8: return MYKGPIO8;
- case gain_pin_t::PIN9: return MYKGPIO9;
- case gain_pin_t::PIN10: return MYKGPIO10;
- case gain_pin_t::PIN11: return MYKGPIO11;
- case gain_pin_t::PIN12: return MYKGPIO12;
- case gain_pin_t::PIN13: return MYKGPIO13;
- case gain_pin_t::PIN14: return MYKGPIO14;
- case gain_pin_t::PIN15: return MYKGPIO15;
- case gain_pin_t::PIN16: return MYKGPIO16;
- case gain_pin_t::PIN17: return MYKGPIO17;
- case gain_pin_t::PIN18: return MYKGPIO18;
- default: return MYKGPIONAN;
+ switch (pin) {
+ case gain_pin_t::PIN0:
+ return MYKGPIO0;
+ case gain_pin_t::PIN1:
+ return MYKGPIO1;
+ case gain_pin_t::PIN2:
+ return MYKGPIO2;
+ case gain_pin_t::PIN3:
+ return MYKGPIO3;
+ case gain_pin_t::PIN4:
+ return MYKGPIO4;
+ case gain_pin_t::PIN5:
+ return MYKGPIO5;
+ case gain_pin_t::PIN6:
+ return MYKGPIO6;
+ case gain_pin_t::PIN7:
+ return MYKGPIO7;
+ case gain_pin_t::PIN8:
+ return MYKGPIO8;
+ case gain_pin_t::PIN9:
+ return MYKGPIO9;
+ case gain_pin_t::PIN10:
+ return MYKGPIO10;
+ case gain_pin_t::PIN11:
+ return MYKGPIO11;
+ case gain_pin_t::PIN12:
+ return MYKGPIO12;
+ case gain_pin_t::PIN13:
+ return MYKGPIO13;
+ case gain_pin_t::PIN14:
+ return MYKGPIO14;
+ case gain_pin_t::PIN15:
+ return MYKGPIO15;
+ case gain_pin_t::PIN16:
+ return MYKGPIO16;
+ case gain_pin_t::PIN17:
+ return MYKGPIO17;
+ case gain_pin_t::PIN18:
+ return MYKGPIO18;
+ default:
+ return MYKGPIONAN;
}
}
-ad937x_gain_ctrl_channel_t::ad937x_gain_ctrl_channel_t(mykonosGpioSelect_t inc_pin, mykonosGpioSelect_t dec_pin) :
- enable(DEFAULT_ENABLE),
- inc_step(DEFAULT_GAIN_STEP),
- dec_step(DEFAULT_GAIN_STEP),
- inc_pin(inc_pin),
- dec_pin(dec_pin)
+ad937x_gain_ctrl_channel_t::ad937x_gain_ctrl_channel_t(
+ mykonosGpioSelect_t inc_pin, mykonosGpioSelect_t dec_pin)
+ : enable(DEFAULT_ENABLE)
+ , inc_step(DEFAULT_GAIN_STEP)
+ , dec_step(DEFAULT_GAIN_STEP)
+ , inc_pin(inc_pin)
+ , dec_pin(dec_pin)
{
-
}
-mykonosGpioSelect_t _get_gain_pin(
- direction_t direction,
+mykonosGpioSelect_t _get_gain_pin(direction_t direction,
chain_t chain,
pin_direction_t pin_direction,
- const gain_pins_t & gain_pins)
+ const gain_pins_t& gain_pins)
{
- switch (direction)
- {
- case RX_DIRECTION:
- switch (chain)
- {
- case chain_t::ONE:
- switch (pin_direction)
- {
- case pin_direction_t::INCREASE: return _convert_gain_pin(gain_pins.rx1_inc_gain_pin);
- case pin_direction_t::DECREASE: return _convert_gain_pin(gain_pins.rx1_dec_gain_pin);
- }
- case chain_t::TWO:
- switch (pin_direction)
- {
- case pin_direction_t::INCREASE: return _convert_gain_pin(gain_pins.rx2_inc_gain_pin);
- case pin_direction_t::DECREASE: return _convert_gain_pin(gain_pins.rx2_dec_gain_pin);
+ switch (direction) {
+ case RX_DIRECTION:
+ switch (chain) {
+ case chain_t::ONE:
+ switch (pin_direction) {
+ case pin_direction_t::INCREASE:
+ return _convert_gain_pin(gain_pins.rx1_inc_gain_pin);
+ case pin_direction_t::DECREASE:
+ return _convert_gain_pin(gain_pins.rx1_dec_gain_pin);
+ }
+ case chain_t::TWO:
+ switch (pin_direction) {
+ case pin_direction_t::INCREASE:
+ return _convert_gain_pin(gain_pins.rx2_inc_gain_pin);
+ case pin_direction_t::DECREASE:
+ return _convert_gain_pin(gain_pins.rx2_dec_gain_pin);
+ }
}
- }
- // !!! TX is attenuation direction, so the pins are flipped !!!
- case TX_DIRECTION:
- switch (chain)
- {
- case chain_t::ONE:
- switch (pin_direction)
- {
- case pin_direction_t::INCREASE: return _convert_gain_pin(gain_pins.tx1_dec_gain_pin);
- case pin_direction_t::DECREASE: return _convert_gain_pin(gain_pins.tx1_inc_gain_pin);
+ // !!! TX is attenuation direction, so the pins are flipped !!!
+ case TX_DIRECTION:
+ switch (chain) {
+ case chain_t::ONE:
+ switch (pin_direction) {
+ case pin_direction_t::INCREASE:
+ return _convert_gain_pin(gain_pins.tx1_dec_gain_pin);
+ case pin_direction_t::DECREASE:
+ return _convert_gain_pin(gain_pins.tx1_inc_gain_pin);
+ }
+ case chain_t::TWO:
+ switch (pin_direction) {
+ case pin_direction_t::INCREASE:
+ return _convert_gain_pin(gain_pins.tx2_dec_gain_pin);
+ case pin_direction_t::DECREASE:
+ return _convert_gain_pin(gain_pins.tx2_inc_gain_pin);
+ }
}
- case chain_t::TWO:
- switch (pin_direction)
- {
- case pin_direction_t::INCREASE: return _convert_gain_pin(gain_pins.tx2_dec_gain_pin);
- case pin_direction_t::DECREASE: return _convert_gain_pin(gain_pins.tx2_inc_gain_pin);
- }
- }
- default:
- return MYKGPIONAN;
+ default:
+ return MYKGPIONAN;
}
}
ad937x_gain_ctrl_config_t::ad937x_gain_ctrl_config_t(gain_pins_t gain_pins)
{
- config.emplace(std::piecewise_construct, std::forward_as_tuple(RX_DIRECTION), std::forward_as_tuple());
- config.emplace(std::piecewise_construct, std::forward_as_tuple(TX_DIRECTION), std::forward_as_tuple());
+ config.emplace(std::piecewise_construct,
+ std::forward_as_tuple(RX_DIRECTION),
+ std::forward_as_tuple());
+ config.emplace(std::piecewise_construct,
+ std::forward_as_tuple(TX_DIRECTION),
+ std::forward_as_tuple());
- config.at(RX_DIRECTION).emplace(std::piecewise_construct, std::forward_as_tuple(chain_t::ONE),
- std::forward_as_tuple(
- _get_gain_pin(RX_DIRECTION, chain_t::ONE, pin_direction_t::INCREASE, gain_pins),
- _get_gain_pin(RX_DIRECTION, chain_t::ONE, pin_direction_t::DECREASE, gain_pins)));
- config.at(RX_DIRECTION).emplace(std::piecewise_construct, std::forward_as_tuple(chain_t::TWO),
- std::forward_as_tuple(
- _get_gain_pin(RX_DIRECTION, chain_t::TWO, pin_direction_t::INCREASE, gain_pins),
- _get_gain_pin(RX_DIRECTION, chain_t::TWO, pin_direction_t::DECREASE, gain_pins)));
+ config.at(RX_DIRECTION)
+ .emplace(std::piecewise_construct,
+ std::forward_as_tuple(chain_t::ONE),
+ std::forward_as_tuple(
+ _get_gain_pin(
+ RX_DIRECTION, chain_t::ONE, pin_direction_t::INCREASE, gain_pins),
+ _get_gain_pin(
+ RX_DIRECTION, chain_t::ONE, pin_direction_t::DECREASE, gain_pins)));
+ config.at(RX_DIRECTION)
+ .emplace(std::piecewise_construct,
+ std::forward_as_tuple(chain_t::TWO),
+ std::forward_as_tuple(
+ _get_gain_pin(
+ RX_DIRECTION, chain_t::TWO, pin_direction_t::INCREASE, gain_pins),
+ _get_gain_pin(
+ RX_DIRECTION, chain_t::TWO, pin_direction_t::DECREASE, gain_pins)));
- config.at(TX_DIRECTION).emplace(std::piecewise_construct, std::forward_as_tuple(chain_t::ONE),
- std::forward_as_tuple(
- _get_gain_pin(TX_DIRECTION, chain_t::ONE, pin_direction_t::INCREASE, gain_pins),
- _get_gain_pin(TX_DIRECTION, chain_t::ONE, pin_direction_t::DECREASE, gain_pins)));
- config.at(TX_DIRECTION).emplace(std::piecewise_construct, std::forward_as_tuple(chain_t::TWO),
- std::forward_as_tuple(
- _get_gain_pin(TX_DIRECTION, chain_t::TWO, pin_direction_t::INCREASE, gain_pins),
- _get_gain_pin(TX_DIRECTION, chain_t::TWO, pin_direction_t::DECREASE, gain_pins)));
+ config.at(TX_DIRECTION)
+ .emplace(std::piecewise_construct,
+ std::forward_as_tuple(chain_t::ONE),
+ std::forward_as_tuple(
+ _get_gain_pin(
+ TX_DIRECTION, chain_t::ONE, pin_direction_t::INCREASE, gain_pins),
+ _get_gain_pin(
+ TX_DIRECTION, chain_t::ONE, pin_direction_t::DECREASE, gain_pins)));
+ config.at(TX_DIRECTION)
+ .emplace(std::piecewise_construct,
+ std::forward_as_tuple(chain_t::TWO),
+ std::forward_as_tuple(
+ _get_gain_pin(
+ TX_DIRECTION, chain_t::TWO, pin_direction_t::INCREASE, gain_pins),
+ _get_gain_pin(
+ TX_DIRECTION, chain_t::TWO, pin_direction_t::DECREASE, gain_pins)));
}
-
diff --git a/mpm/lib/mykonos/config/ad937x_gain_ctrl_config.hpp b/mpm/lib/mykonos/config/ad937x_gain_ctrl_config.hpp
index 380efb0de..12851af92 100644
--- a/mpm/lib/mykonos/config/ad937x_gain_ctrl_config.hpp
+++ b/mpm/lib/mykonos/config/ad937x_gain_ctrl_config.hpp
@@ -8,31 +8,29 @@
#include "../ad937x_device_types.hpp"
#include "../adi/t_mykonos.h"
-
#include "mpm/ad937x/ad937x_ctrl_types.hpp"
-
-#include <vector>
#include <unordered_map>
+#include <vector>
-// C++14 requires std::hash includes a specialization for enums, but gcc doesn't do that yet
-// Remove this when that happens
+// C++14 requires std::hash includes a specialization for enums, but gcc doesn't do that
+// yet Remove this when that happens
namespace std {
- template <> struct hash<uhd::direction_t>
+template <> struct hash<uhd::direction_t>
+{
+ size_t operator()(const uhd::direction_t& x) const
{
- size_t operator()(const uhd::direction_t & x) const
- {
- return static_cast<std::size_t>(x);
- }
- };
+ return static_cast<std::size_t>(x);
+ }
+};
- template <> struct hash<mpm::ad937x::device::chain_t>
+template <> struct hash<mpm::ad937x::device::chain_t>
+{
+ size_t operator()(const mpm::ad937x::device::chain_t& x) const
{
- size_t operator()(const mpm::ad937x::device::chain_t & x) const
- {
- return static_cast<std::size_t>(x);
- }
- };
-}
+ return static_cast<std::size_t>(x);
+ }
+};
+} // namespace std
// collection of the 5 attributes that define the gain pins for a channel in Mykonos
struct ad937x_gain_ctrl_channel_t
@@ -54,9 +52,8 @@ private:
struct ad937x_gain_ctrl_config_t
{
std::unordered_map<uhd::direction_t,
- std::unordered_map<mpm::ad937x::device::chain_t, ad937x_gain_ctrl_channel_t>> config;
+ std::unordered_map<mpm::ad937x::device::chain_t, ad937x_gain_ctrl_channel_t>>
+ config;
ad937x_gain_ctrl_config_t(mpm::ad937x::gpio::gain_pins_t gain_pins);
};
-
-
diff --git a/mpm/lib/spi/spi_regs_iface.cpp b/mpm/lib/spi/spi_regs_iface.cpp
index a1b5d29f8..842f45d42 100644
--- a/mpm/lib/spi/spi_regs_iface.cpp
+++ b/mpm/lib/spi/spi_regs_iface.cpp
@@ -4,10 +4,10 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <mpm/types/regs_iface.hpp>
+#include <mpm/exception.hpp>
#include <mpm/spi/spi_iface.hpp>
#include <mpm/spi/spi_regs_iface.hpp>
-#include <mpm/exception.hpp>
+#include <mpm/types/regs_iface.hpp>
using mpm::types::regs_iface;
@@ -18,29 +18,23 @@ using mpm::types::regs_iface;
class spi_regs_iface_impl : public regs_iface
{
public:
-
- spi_regs_iface_impl(
- mpm::spi::spi_iface::sptr spi_iface,
+ spi_regs_iface_impl(mpm::spi::spi_iface::sptr spi_iface,
uint32_t addr_shift,
uint32_t data_shift,
uint32_t read_flags,
- uint32_t write_flags = 0
- ) : _spi_iface(spi_iface),
- _addr_shift(addr_shift),
- _data_shift(data_shift),
- _read_flags(read_flags),
- _write_flags(write_flags)
+ uint32_t write_flags = 0)
+ : _spi_iface(spi_iface)
+ , _addr_shift(addr_shift)
+ , _data_shift(data_shift)
+ , _read_flags(read_flags)
+ , _write_flags(write_flags)
{
/* nop */
}
- uint8_t peek8(
- const uint32_t addr
- ) {
- uint32_t transaction = 0
- | (addr << _addr_shift)
- | _read_flags
- ;
+ uint8_t peek8(const uint32_t addr)
+ {
+ uint32_t transaction = 0 | (addr << _addr_shift) | _read_flags;
uint32_t data = _spi_iface->transfer24_8(transaction);
if ((data & 0xFFFFFF00) != 0) {
@@ -50,26 +44,17 @@ public:
return data;
}
- void poke8(
- const uint32_t addr,
- const uint8_t data
- ) {
- uint32_t transaction = 0
- | _write_flags
- | (addr << _addr_shift)
- | (data << _data_shift)
- ;
+ void poke8(const uint32_t addr, const uint8_t data)
+ {
+ uint32_t transaction = 0 | _write_flags | (addr << _addr_shift)
+ | (data << _data_shift);
_spi_iface->transfer24_8(transaction);
}
- uint16_t peek16(
- const uint32_t addr
- ) {
- uint32_t transaction = 0
- | (addr << _addr_shift)
- | _read_flags
- ;
+ uint16_t peek16(const uint32_t addr)
+ {
+ uint32_t transaction = 0 | (addr << _addr_shift) | _read_flags;
uint32_t data = _spi_iface->transfer24_16(transaction);
if ((data & 0xFFFF0000) != 0) {
@@ -79,15 +64,10 @@ public:
return data;
}
- void poke16(
- const uint32_t addr,
- const uint16_t data
- ) {
- uint32_t transaction = 0
- | _write_flags
- | (addr << _addr_shift)
- | (data << _data_shift)
- ;
+ void poke16(const uint32_t addr, const uint16_t data)
+ {
+ uint32_t transaction = 0 | _write_flags | (addr << _addr_shift)
+ | (data << _data_shift);
_spi_iface->transfer24_16(transaction);
}
@@ -101,39 +81,25 @@ private:
uint32_t _write_flags;
};
-regs_iface::sptr mpm::spi::make_spi_regs_iface(
- mpm::spi::spi_iface::sptr spi_iface,
+regs_iface::sptr mpm::spi::make_spi_regs_iface(mpm::spi::spi_iface::sptr spi_iface,
uint32_t addr_shift,
uint32_t data_shift,
uint32_t read_flags,
- uint32_t write_flags
-) {
+ uint32_t write_flags)
+{
return std::make_shared<spi_regs_iface_impl>(
- spi_iface,
- addr_shift,
- data_shift,
- read_flags,
- write_flags
- );
+ spi_iface, addr_shift, data_shift, read_flags, write_flags);
}
-mpm::types::regs_iface::sptr mpm::spi::make_spidev_regs_iface(
- const std::string &device,
+mpm::types::regs_iface::sptr mpm::spi::make_spidev_regs_iface(const std::string& device,
const int speed_hz,
const int spi_mode,
uint32_t addr_shift,
uint32_t data_shift,
uint32_t read_flags,
- uint32_t write_flags
-) {
- auto spi_iface_sptr = mpm::spi::spi_iface::make_spidev(
- device, speed_hz, spi_mode
- );
+ uint32_t write_flags)
+{
+ auto spi_iface_sptr = mpm::spi::spi_iface::make_spidev(device, speed_hz, spi_mode);
return std::make_shared<spi_regs_iface_impl>(
- spi_iface_sptr,
- addr_shift,
- data_shift,
- read_flags,
- write_flags
- );
+ spi_iface_sptr, addr_shift, data_shift, read_flags, write_flags);
}
diff --git a/mpm/lib/spi/spidev_iface.cpp b/mpm/lib/spi/spidev_iface.cpp
index 8b629e7b6..c8a2133e8 100644
--- a/mpm/lib/spi/spidev_iface.cpp
+++ b/mpm/lib/spi/spidev_iface.cpp
@@ -5,14 +5,13 @@
//
-#include <mpm/spi/spi_iface.hpp>
#include <mpm/exception.hpp>
+#include <mpm/spi/spi_iface.hpp>
extern "C" {
#include "spidev.h"
}
#include <fcntl.h>
#include <linux/spi/spidev.h>
-
#include <boost/format.hpp>
#include <iostream>
@@ -24,29 +23,18 @@ using namespace mpm::spi;
class spidev_iface_impl : public spi_iface
{
public:
-
spidev_iface_impl(
- const std::string &device,
- const int max_speed_hz,
- const int spi_mode
- ) : _speed(max_speed_hz),
- _mode(spi_mode)
+ const std::string& device, const int max_speed_hz, const int spi_mode)
+ : _speed(max_speed_hz), _mode(spi_mode)
{
- if (init_spi(
- &_fd,
- device.c_str(),
- _mode, _speed, _bits, _delay) < 0)
- {
- throw mpm::runtime_error(str(
- boost::format("Could not initialize spidev device %s")
- % device));
+ if (init_spi(&_fd, device.c_str(), _mode, _speed, _bits, _delay) < 0) {
+ throw mpm::runtime_error(
+ str(boost::format("Could not initialize spidev device %s") % device));
}
- if (_fd < 0)
- {
- throw mpm::runtime_error(str(
- boost::format("Could not open spidev device %s")
- % device));
+ if (_fd < 0) {
+ throw mpm::runtime_error(
+ str(boost::format("Could not open spidev device %s") % device));
}
}
@@ -55,53 +43,37 @@ public:
close(_fd);
}
- uint32_t transfer24_8(
- const uint32_t data_
- ) {
+ uint32_t transfer24_8(const uint32_t data_)
+ {
int ret(0);
- uint32_t data = data_;
- uint8_t *tx_data = reinterpret_cast<uint8_t *>(&data);
+ uint32_t data = data_;
+ uint8_t* tx_data = reinterpret_cast<uint8_t*>(&data);
// Create tx and rx buffers:
uint8_t tx[] = {tx_data[2], tx_data[1], tx_data[0]}; // FIXME guarantee endianness
uint8_t rx[3]; // Buffer length must match tx buffer
- if (transfer(
- _fd,
- &tx[0], &rx[0],
- 3,
- _speed, _bits, _delay
- ) != 0) {
- throw mpm::runtime_error(str(
- boost::format("SPI Transaction failed!")
- ));
+ if (transfer(_fd, &tx[0], &rx[0], 3, _speed, _bits, _delay) != 0) {
+ throw mpm::runtime_error(str(boost::format("SPI Transaction failed!")));
}
return uint32_t(rx[2]);
}
- uint32_t transfer24_16(
- const uint32_t data_
- ) {
+ uint32_t transfer24_16(const uint32_t data_)
+ {
int ret(0);
- uint32_t data = data_;
- uint8_t *tx_data = reinterpret_cast<uint8_t *>(&data);
+ uint32_t data = data_;
+ uint8_t* tx_data = reinterpret_cast<uint8_t*>(&data);
// Create tx and rx buffers:
uint8_t tx[] = {tx_data[2], tx_data[1], tx_data[0]}; // FIXME guarantee endianness
uint8_t rx[3]; // Buffer length must match tx buffer
- if (transfer(
- _fd,
- &tx[0], &rx[0],
- 3,
- _speed, _bits, _delay
- ) != 0) {
- throw mpm::runtime_error(str(
- boost::format("SPI Transaction failed!")
- ));
+ if (transfer(_fd, &tx[0], &rx[0], 3, _speed, _bits, _delay) != 0) {
+ throw mpm::runtime_error(str(boost::format("SPI Transaction failed!")));
}
return uint32_t(rx[1] << 8 | rx[2]);
@@ -111,7 +83,7 @@ private:
int _fd;
const uint32_t _mode;
uint32_t _speed = 2000000;
- uint8_t _bits = 8;
+ uint8_t _bits = 8;
uint16_t _delay = 0;
};
@@ -119,12 +91,7 @@ private:
* Factory
*****************************************************************************/
spi_iface::sptr spi_iface::make_spidev(
- const std::string &device,
- const int speed_hz,
- const int spi_mode
-) {
- return std::make_shared<spidev_iface_impl>(
- device, speed_hz, spi_mode
- );
+ const std::string& device, const int speed_hz, const int spi_mode)
+{
+ return std::make_shared<spidev_iface_impl>(device, speed_hz, spi_mode);
}
-
diff --git a/mpm/lib/types/lockable.cpp b/mpm/lib/types/lockable.cpp
index 8710e8752..cdba9e335 100644
--- a/mpm/lib/types/lockable.cpp
+++ b/mpm/lib/types/lockable.cpp
@@ -11,9 +11,7 @@ using namespace mpm::types;
class lockable_impl : public lockable
{
public:
- lockable_impl(
- std::shared_ptr<std::mutex> spi_mutex
- ) : _spi_mutex(spi_mutex)
+ lockable_impl(std::shared_ptr<std::mutex> spi_mutex) : _spi_mutex(spi_mutex)
{
/* nop */
}
@@ -32,11 +30,7 @@ private:
std::shared_ptr<std::mutex> _spi_mutex;
};
-lockable::sptr lockable::make(
- std::shared_ptr<std::mutex> spi_mutex
-) {
- return std::make_shared<lockable_impl>(
- spi_mutex
- );
+lockable::sptr lockable::make(std::shared_ptr<std::mutex> spi_mutex)
+{
+ return std::make_shared<lockable_impl>(spi_mutex);
}
-
diff --git a/mpm/lib/types/log_buf.cpp b/mpm/lib/types/log_buf.cpp
index f1ef0cbee..8e3f183cc 100644
--- a/mpm/lib/types/log_buf.cpp
+++ b/mpm/lib/types/log_buf.cpp
@@ -9,15 +9,11 @@
using namespace mpm::types;
void log_buf::post(
- const log_level_t log_level,
- const std::string &component,
- const std::string &message
-) {
+ const log_level_t log_level, const std::string& component, const std::string& message)
+{
{
std::lock_guard<std::mutex> l(_buf_lock);
- _buf.push_back(
- log_message(log_level, component, message)
- );
+ _buf.push_back(log_message(log_level, component, message));
}
if (bool(_notify_callback)) {
@@ -25,9 +21,8 @@ void log_buf::post(
}
}
-void log_buf::set_notify_callback(
- std::function<void(void)> callback
-) {
+void log_buf::set_notify_callback(std::function<void(void)> callback)
+{
_notify_callback = callback;
}
@@ -35,20 +30,12 @@ std::tuple<log_level_t, std::string, std::string> log_buf::pop()
{
std::lock_guard<std::mutex> l(_buf_lock);
if (_buf.empty()) {
- return std::make_tuple(
- log_level_t::NONE,
- "",
- ""
- );
+ return std::make_tuple(log_level_t::NONE, "", "");
}
auto last_msg = _buf.front();
_buf.pop_front();
- return std::make_tuple(
- last_msg.log_level,
- last_msg.component,
- last_msg.message
- );
+ return std::make_tuple(last_msg.log_level, last_msg.component, last_msg.message);
}
log_buf::sptr log_buf::make()
@@ -61,4 +48,3 @@ log_buf::sptr log_buf::make_singleton()
static auto log_sptr = log_buf::make();
return log_sptr;
}
-
diff --git a/mpm/lib/types/mmap_regs_iface.cpp b/mpm/lib/types/mmap_regs_iface.cpp
index 96457d7ad..18fa2abfa 100644
--- a/mpm/lib/types/mmap_regs_iface.cpp
+++ b/mpm/lib/types/mmap_regs_iface.cpp
@@ -4,30 +4,26 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <mpm/types/mmap_regs_iface.hpp>
+#include <fcntl.h>
#include <mpm/exception.hpp>
-#include <boost/format.hpp>
-#include <iostream>
-#include <sys/types.h>
-#include <sys/stat.h>
+#include <mpm/types/mmap_regs_iface.hpp>
#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
-#include <fcntl.h>
+#include <boost/format.hpp>
+#include <iostream>
#include <sstream>
using namespace mpm::types;
-mmap_regs_iface::mmap_regs_iface(
- const std::string &path,
+mmap_regs_iface::mmap_regs_iface(const std::string& path,
const size_t length,
const size_t offset,
const bool read_only,
- const bool open_now
-) : _path(path)
- , _length(length)
- , _offset(offset)
- , _read_only(read_only)
+ const bool open_now)
+ : _path(path), _length(length), _offset(offset), _read_only(read_only)
{
if (open_now) {
open();
@@ -53,26 +49,23 @@ void mmap_regs_iface::open()
}
if (!_mmap) {
- _mmap = (uint32_t *) ::mmap(
- NULL,
+ _mmap = (uint32_t*)::mmap(NULL,
_length,
PROT_READ | (_read_only ? 0 : PROT_WRITE),
MAP_SHARED,
_fd,
- (off_t) _offset
- );
- if (((void *) _mmap) == MAP_FAILED) {
+ (off_t)_offset);
+ if (((void*)_mmap) == MAP_FAILED) {
throw mpm::runtime_error("Failed to mmap!");
}
}
- log(mpm::types::log_level_t::TRACE, _path,
- "Opened mmap_regs_iface");
+ log(mpm::types::log_level_t::TRACE, _path, "Opened mmap_regs_iface");
}
void mmap_regs_iface::close()
{
if (_mmap) {
- int err = munmap((void *) _mmap, _length);
+ int err = munmap((void*)_mmap, _length);
if (err) {
throw mpm::runtime_error("Couldn't munmap!");
}
@@ -85,14 +78,11 @@ void mmap_regs_iface::close()
}
_fd = -1;
}
- log(mpm::types::log_level_t::TRACE, _path,
- "Closed mmap_regs_iface");
+ log(mpm::types::log_level_t::TRACE, _path, "Closed mmap_regs_iface");
}
-void mmap_regs_iface::poke32(
- const uint32_t addr,
- const uint32_t data
-) {
+void mmap_regs_iface::poke32(const uint32_t addr, const uint32_t data)
+{
MPM_ASSERT_THROW(_mmap);
_mmap[addr / sizeof(uint32_t)] = data;
}
@@ -104,14 +94,8 @@ uint32_t mmap_regs_iface::peek32(const uint32_t addr)
}
void mmap_regs_iface::log(
- mpm::types::log_level_t level,
- const std::string path,
- const char *comment
-) {
+ mpm::types::log_level_t level, const std::string path, const char* comment)
+{
mpm::types::log_buf::make_singleton()->post(
- level,
- "MMAP_REGS_IFACE",
- str(boost::format("[UIO %s] %s")
- % path % comment)
- );
+ level, "MMAP_REGS_IFACE", str(boost::format("[UIO %s] %s") % path % comment));
}
diff --git a/mpm/lib/xbar_iface.cpp b/mpm/lib/xbar_iface.cpp
index cff5ed2e7..05d1e2053 100644
--- a/mpm/lib/xbar_iface.cpp
+++ b/mpm/lib/xbar_iface.cpp
@@ -5,41 +5,48 @@
//
#include "mpm/xbar_iface.hpp"
+#include <fcntl.h>
#include <mpm/exception.hpp>
-#include <boost/format.hpp>
#include <sys/ioctl.h>
-#include <fcntl.h>
+#include <boost/format.hpp>
using namespace mpm;
std::mutex xbar_iface::_lock; // Initialize lock for all objects
-xbar_iface::xbar_iface(const std::string &device){
+xbar_iface::xbar_iface(const std::string& device)
+{
_fd = open(device.c_str(), O_RDWR);
}
-xbar_iface::~xbar_iface(){
+xbar_iface::~xbar_iface()
+{
close(_fd);
}
-void xbar_iface::set_route(uint8_t dst_addr, uint8_t dst_port) {
+void xbar_iface::set_route(uint8_t dst_addr, uint8_t dst_port)
+{
std::lock_guard<std::mutex> lock(_lock);
rfnoc_crossbar_cmd cmd = {.dest_addr = dst_addr, .dest_port = dst_port};
- int err = ioctl(_fd, RFNCBWROUTIOC, &cmd);
+ int err = ioctl(_fd, RFNCBWROUTIOC, &cmd);
if (err < 0) {
- throw mpm::os_error(str(boost::format("setting crossbar route failed! Error: %d") % err));
+ throw mpm::os_error(
+ str(boost::format("setting crossbar route failed! Error: %d") % err));
}
}
-void xbar_iface::del_route(uint8_t dst_addr, uint8_t dst_port){
+void xbar_iface::del_route(uint8_t dst_addr, uint8_t dst_port)
+{
std::lock_guard<std::mutex> lock(_lock);
rfnoc_crossbar_cmd cmd = {.dest_addr = dst_addr, .dest_port = dst_port};
- int err = ioctl(_fd, RFNCDELROUTIOC, &cmd);
- if (err < 0){
- throw mpm::os_error(str(boost::format("deleting crossbar route failed! Error: %d") % err));
+ int err = ioctl(_fd, RFNCDELROUTIOC, &cmd);
+ if (err < 0) {
+ throw mpm::os_error(
+ str(boost::format("deleting crossbar route failed! Error: %d") % err));
}
}
-xbar_iface::sptr xbar_iface::make(const std::string &device){
+xbar_iface::sptr xbar_iface::make(const std::string& device)
+{
return std::make_shared<xbar_iface>(device);
}
diff --git a/mpm/python/lib_helper.cpp b/mpm/python/lib_helper.cpp
index 2d533f073..f4ac7870d 100644
--- a/mpm/python/lib_helper.cpp
+++ b/mpm/python/lib_helper.cpp
@@ -5,22 +5,24 @@
//
#include "lib_helper.hpp"
-#include "converters.hpp"
-#include "../lib/udev_helper.hpp"
#include "../lib/net_helper.hpp"
+#include "../lib/udev_helper.hpp"
+#include "converters.hpp"
#include <boost/python.hpp>
namespace bp = boost::python;
-void export_helper(){
- //Register submodule types
- bp::object helper_module(bp::handle<>(bp::borrowed(PyImport_AddModule("libpyusrp_periphs.helper"))));
+void export_helper()
+{
+ // Register submodule types
+ bp::object helper_module(
+ bp::handle<>(bp::borrowed(PyImport_AddModule("libpyusrp_periphs.helper"))));
bp::scope().attr("helper") = helper_module;
- bp::scope io_scope = helper_module;
+ bp::scope io_scope = helper_module;
bp::class_<mpm::udev_helper>("udev_helper", bp::init<>())
- .def("get_eeprom", &mpm::udev_helper::get_eeprom)
- ;
- bp::to_python_converter<std::vector< std::string >, iterable_to_python_list<std::vector< std::string > >, false>();
+ .def("get_eeprom", &mpm::udev_helper::get_eeprom);
+ bp::to_python_converter<std::vector<std::string>,
+ iterable_to_python_list<std::vector<std::string>>,
+ false>();
}
-
diff --git a/mpm/python/pyusrp_periphs/converters.hpp b/mpm/python/pyusrp_periphs/converters.hpp
index ede9507a9..849e8b90e 100644
--- a/mpm/python/pyusrp_periphs/converters.hpp
+++ b/mpm/python/pyusrp_periphs/converters.hpp
@@ -8,32 +8,29 @@
#include <boost/python.hpp>
#include <boost/python/stl_iterator.hpp>
-#include <vector>
#include <string>
+#include <vector>
namespace bp = boost::python;
-template<typename MapType>
-struct map_to_python_dict
+template <typename MapType> struct map_to_python_dict
{
static PyObject* convert(MapType const& input_map)
{
bp::dict py_dict;
- for (const auto& element: input_map){
+ for (const auto& element : input_map) {
py_dict[element.first] = element.second;
}
return bp::incref(py_dict.ptr());
}
-
};
-template<typename Container>
-struct iterable_to_python_list
+template <typename Container> struct iterable_to_python_list
{
static PyObject* convert(Container const& input)
{
bp::list py_list;
- for (const auto& element: input){
+ for (const auto& element : input) {
py_list.append(element);
}
return bp::incref(py_list.ptr());
@@ -43,52 +40,48 @@ struct iterable_to_python_list
// Converter for std::vector / std::list arguments from python iterables
struct iterable_converter
{
- template <typename Container>
- iterable_converter&
- from_python()
- {
- bp::converter::registry::push_back(
- &iterable_converter::convertible,
- &iterable_converter::construct<Container>,
- bp::type_id<Container>());
- return *this;
- }
+ template <typename Container> iterable_converter& from_python()
+ {
+ bp::converter::registry::push_back(&iterable_converter::convertible,
+ &iterable_converter::construct<Container>,
+ bp::type_id<Container>());
+ return *this;
+ }
- static void* convertible(PyObject* object)
- {
- return PyObject_GetIter(object) ? object : NULL;
- }
+ static void* convertible(PyObject* object)
+ {
+ return PyObject_GetIter(object) ? object : NULL;
+ }
- template <typename Container>
- static void construct(
- PyObject* object,
- bp::converter::rvalue_from_python_stage1_data* data)
- {
- // Object is a borrowed reference, so create a handle indicting it is
- // borrowed for proper reference counting.
- bp::handle<> handle(bp::borrowed(object));
+ template <typename Container>
+ static void construct(
+ PyObject* object, bp::converter::rvalue_from_python_stage1_data* data)
+ {
+ // Object is a borrowed reference, so create a handle indicting it is
+ // borrowed for proper reference counting.
+ bp::handle<> handle(bp::borrowed(object));
- // Obtain a handle to the memory block that the converter has allocated
- // for the C++ type.
- typedef bp::converter::rvalue_from_python_storage<Container>
- storage_type;
- void* storage = reinterpret_cast<storage_type*>(data)->storage.bytes;
+ // Obtain a handle to the memory block that the converter has allocated
+ // for the C++ type.
+ typedef bp::converter::rvalue_from_python_storage<Container> storage_type;
+ void* storage = reinterpret_cast<storage_type*>(data)->storage.bytes;
- typedef bp::stl_input_iterator<typename Container::value_type>
- iterator;
+ typedef bp::stl_input_iterator<typename Container::value_type> iterator;
- // Allocate the C++ type into the converter's memory block, and assign
- // its handle to the converter's convertible variable. The C++
- // container is populated by passing the begin and end iterators of
- // the python object to the container's constructor.
- new (storage) Container(
- iterator(bp::object(handle)), // begin
- iterator()); // end
- data->convertible = storage;
- }
+ // Allocate the C++ type into the converter's memory block, and assign
+ // its handle to the converter's convertible variable. The C++
+ // container is populated by passing the begin and end iterators of
+ // the python object to the container's constructor.
+ new (storage) Container(iterator(bp::object(handle)), // begin
+ iterator()); // end
+ data->convertible = storage;
+ }
};
-void export_converter(){
+void export_converter()
+{
// LIBMPM_BOOST_PREAMBLE("helper")
- bp::to_python_converter<std::vector< std::string >, iterable_to_python_list<std::vector< std::string > >, false>();
+ bp::to_python_converter<std::vector<std::string>,
+ iterable_to_python_list<std::vector<std::string>>,
+ false>();
}
diff --git a/mpm/python/pyusrp_periphs/e320/pyusrp_periphs.cpp b/mpm/python/pyusrp_periphs/e320/pyusrp_periphs.cpp
index b045b5909..97ccfc864 100644
--- a/mpm/python/pyusrp_periphs/e320/pyusrp_periphs.cpp
+++ b/mpm/python/pyusrp_periphs/e320/pyusrp_periphs.cpp
@@ -7,26 +7,27 @@
// include hackery to only include boost python and define the macro here
#include <boost/python.hpp>
#define LIBMPM_PYTHON
-#define LIBMPM_BOOST_PREAMBLE(module) \
- /* Register submodule types */ \
- namespace bp = boost::python; \
- bp::object py_module(bp::handle<>(bp::borrowed(PyImport_AddModule("libpyusrp_periphs." module)))); \
- bp::scope().attr(module) = py_module; \
- bp::scope io_scope = py_module;
+#define LIBMPM_BOOST_PREAMBLE(module) \
+ /* Register submodule types */ \
+ namespace bp = boost::python; \
+ bp::object py_module( \
+ bp::handle<>(bp::borrowed(PyImport_AddModule("libpyusrp_periphs." module)))); \
+ bp::scope().attr(module) = py_module; \
+ bp::scope io_scope = py_module;
#include "../converters.hpp"
-#include <mpm/xbar_iface.hpp>
-#include <mpm/types/types_python.hpp>
-#include <mpm/spi/spi_python.hpp>
#include <mpm/ad9361/ad9361_ctrl.hpp>
#include <mpm/dboards/neon_manager.hpp>
+#include <mpm/spi/spi_python.hpp>
+#include <mpm/types/types_python.hpp>
+#include <mpm/xbar_iface.hpp>
#include <boost/noncopyable.hpp>
namespace bp = boost::python;
BOOST_PYTHON_MODULE(libpyusrp_periphs)
{
- bp::object package = bp::scope();
+ bp::object package = bp::scope();
package.attr("__path__") = "libpyusrp_periphs";
export_converter();
export_types();
diff --git a/mpm/python/pyusrp_periphs/n3xx/pyusrp_periphs.cpp b/mpm/python/pyusrp_periphs/n3xx/pyusrp_periphs.cpp
index d6e66ad1e..85851677f 100644
--- a/mpm/python/pyusrp_periphs/n3xx/pyusrp_periphs.cpp
+++ b/mpm/python/pyusrp_periphs/n3xx/pyusrp_periphs.cpp
@@ -7,12 +7,13 @@
// include hackery to only include boost python and define the macro here
#include <boost/python.hpp>
#define LIBMPM_PYTHON
-#define LIBMPM_BOOST_PREAMBLE(module) \
- /* Register submodule types */ \
- namespace bp = boost::python; \
- bp::object py_module(bp::handle<>(bp::borrowed(PyImport_AddModule("libpyusrp_periphs." module)))); \
- bp::scope().attr(module) = py_module; \
- bp::scope io_scope = py_module;
+#define LIBMPM_BOOST_PREAMBLE(module) \
+ /* Register submodule types */ \
+ namespace bp = boost::python; \
+ bp::object py_module( \
+ bp::handle<>(bp::borrowed(PyImport_AddModule("libpyusrp_periphs." module)))); \
+ bp::scope().attr(module) = py_module; \
+ bp::scope io_scope = py_module;
//! RAII-style GIL release method
//
@@ -42,19 +43,19 @@ private:
//#include "types.hpp"
#include "../converters.hpp"
-#include <mpm/xbar_iface.hpp>
-#include <mpm/types/types_python.hpp>
-#include <mpm/i2c/i2c_python.hpp>
-#include <mpm/spi/spi_python.hpp>
#include <mpm/ad937x/ad937x_ctrl.hpp>
#include <mpm/dboards/magnesium_manager.hpp>
+#include <mpm/i2c/i2c_python.hpp>
+#include <mpm/spi/spi_python.hpp>
+#include <mpm/types/types_python.hpp>
+#include <mpm/xbar_iface.hpp>
#include <boost/noncopyable.hpp>
namespace bp = boost::python;
BOOST_PYTHON_MODULE(libpyusrp_periphs)
{
- bp::object package = bp::scope();
+ bp::object package = bp::scope();
package.attr("__path__") = "libpyusrp_periphs";
export_converter();
export_types();
diff --git a/mpm/python/tests_periphs.cpp b/mpm/python/tests_periphs.cpp
index c0446d87a..5b4a7c24d 100644
--- a/mpm/python/tests_periphs.cpp
+++ b/mpm/python/tests_periphs.cpp
@@ -5,20 +5,23 @@
//
#include "tests_periphs.hpp"
-#include <mpm/tests/tests_spi_iface.hpp>
#include <mpm/spi_iface.hpp>
+#include <mpm/tests/tests_spi_iface.hpp>
#include <boost/python.hpp>
namespace bp = boost::python;
-void export_tests(){
- //Register submodule types
- bp::object tests_module(bp::handle<>(bp::borrowed(PyImport_AddModule("libpyusrp_periphs.tests"))));
+void export_tests()
+{
+ // Register submodule types
+ bp::object tests_module(
+ bp::handle<>(bp::borrowed(PyImport_AddModule("libpyusrp_periphs.tests"))));
bp::scope().attr("tests") = tests_module;
- bp::scope io_scope = tests_module;
+ bp::scope io_scope = tests_module;
- bp::class_<mpm::tests_spi_iface, bp::bases<mpm::spi_iface>, boost::shared_ptr<mpm::tests_spi_iface> >("test_spi_iface", bp::init<>())
+ bp::class_<mpm::tests_spi_iface,
+ bp::bases<mpm::spi_iface>,
+ boost::shared_ptr<mpm::tests_spi_iface>>("test_spi_iface", bp::init<>())
.def("make", &mpm::tests_spi_iface::make)
- .staticmethod("make")
- ;
+ .staticmethod("make");
}
diff --git a/mpm/tests/tests_device.hpp b/mpm/tests/tests_device.hpp
index 390575178..75cc05b95 100644
--- a/mpm/tests/tests_device.hpp
+++ b/mpm/tests/tests_device.hpp
@@ -4,20 +4,19 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <mpm/tests/tests_spi_iface.hpp>
#include <mpm/spi_iface.hpp>
+#include <mpm/tests/tests_spi_iface.hpp>
#include <memory>
namespace mpm { namespace tests {
- class tests_dboard_periph_manager
- {
- public:
- typedef std::shared_ptr<tests_dboard_periph_manager> sptr;
- static sptr make();
+class tests_dboard_periph_manager
+{
+public:
+ typedef std::shared_ptr<tests_dboard_periph_manager> sptr;
+ static sptr make();
- private:
- mpm::spi_iface::sptr _dev1_spi;
- mpm::spi_iface::sptr _dev2_spi;
- };
-}
-}
+private:
+ mpm::spi_iface::sptr _dev1_spi;
+ mpm::spi_iface::sptr _dev2_spi;
+};
+}} // namespace mpm::tests
diff --git a/mpm/tests/tests_spi_iface.cpp b/mpm/tests/tests_spi_iface.cpp
index 063002fa9..40636a8fa 100644
--- a/mpm/tests/tests_spi_iface.cpp
+++ b/mpm/tests/tests_spi_iface.cpp
@@ -6,63 +6,59 @@
#include <mpm/tests/tests_spi_iface.hpp>
- /**************************************************************************
- * spi_iface API calls
- *************************************************************************/
-namespace mpm{
+/**************************************************************************
+ * spi_iface API calls
+ *************************************************************************/
+namespace mpm {
- void tests_spi_iface::write_byte(
- const uint16_t addr,
- const uint8_t data
- ) {
- _regs[addr] = data;
- }
+void tests_spi_iface::write_byte(const uint16_t addr, const uint8_t data)
+{
+ _regs[addr] = data;
+}
- void tests_spi_iface::write_bytes(
- const uint16_t *addr,
- const uint8_t *data,
- const uint32_t count
- ) {
- for (size_t i = 0; i < count; i++) {
- _regs[addr[i]] = data[i];
- }
- }
+void tests_spi_iface::write_bytes(
+ const uint16_t* addr, const uint8_t* data, const uint32_t count)
+{
+ for (size_t i = 0; i < count; i++) {
+ _regs[addr[i]] = data[i];
+ }
+}
- uint8_t tests_spi_iface::read_byte(const uint16_t addr)
- {
- if (_regs.count(addr)) {
- return _regs.at(addr);
- }
- return _default_val;
- }
+uint8_t tests_spi_iface::read_byte(const uint16_t addr)
+{
+ if (_regs.count(addr)) {
+ return _regs.at(addr);
+ }
+ return _default_val;
+}
- void tests_spi_iface::write_field(
- const uint16_t addr,
- const uint8_t field_val,
- const uint8_t mask,
- const uint8_t start_bit
- ) {
- const uint8_t old_value = read_byte(addr);
- _regs[addr] = (old_value & ~mask) | ((field_val << start_bit) & mask);
- }
+void tests_spi_iface::write_field(const uint16_t addr,
+ const uint8_t field_val,
+ const uint8_t mask,
+ const uint8_t start_bit)
+{
+ const uint8_t old_value = read_byte(addr);
+ _regs[addr] = (old_value & ~mask) | ((field_val << start_bit) & mask);
+}
- uint8_t tests_spi_iface::read_field(
- const uint16_t addr,
- const uint8_t mask,
- const uint8_t start_bit
- ) {
- return (read_byte(addr) & mask) >> start_bit;
- }
+uint8_t tests_spi_iface::read_field(
+ const uint16_t addr, const uint8_t mask, const uint8_t start_bit)
+{
+ return (read_byte(addr) & mask) >> start_bit;
+}
- spi_iface::spi_wire_mode_t tests_spi_iface::get_wire_mode() const{
- return spi_iface::spi_wire_mode_t::THREE_WIRE_MODE;
- }
+spi_iface::spi_wire_mode_t tests_spi_iface::get_wire_mode() const
+{
+ return spi_iface::spi_wire_mode_t::THREE_WIRE_MODE;
+}
- spi_iface::spi_endianness_t tests_spi_iface::get_endianness() const{
- return spi_iface::spi_endianness_t::LSB_FIRST;
- }
- size_t tests_spi_iface::get_chip_select() const{
- return 0;
- }
+spi_iface::spi_endianness_t tests_spi_iface::get_endianness() const
+{
+ return spi_iface::spi_endianness_t::LSB_FIRST;
+}
+size_t tests_spi_iface::get_chip_select() const
+{
+ return 0;
}
+} // namespace mpm