aboutsummaryrefslogtreecommitdiffstats
path: root/mpm/include
diff options
context:
space:
mode:
authorBrent Stapleton <brent.stapleton@ettus.com>2019-01-14 10:35:25 -0800
committerBrent Stapleton <brent.stapleton@ettus.com>2019-01-16 11:40:23 -0800
commit967be2a4e82b1a125b26bb72a60318a4fb2b50c4 (patch)
tree8a24954b54d1546dc8049a17e485adb0a605f74f /mpm/include
parentaafe4e8b742a0e21d3818f21f34e3c8613132530 (diff)
downloaduhd-967be2a4e82b1a125b26bb72a60318a4fb2b50c4.tar.gz
uhd-967be2a4e82b1a125b26bb72a60318a4fb2b50c4.tar.bz2
uhd-967be2a4e82b1a125b26bb72a60318a4fb2b50c4.zip
uhd: mpm: apply clang-format to all files
Applying formatting changes to all .cpp and .hpp files in the following directories: ``` find host/examples/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/tests/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/dboard/neon/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/dboard/magnesium/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/device3/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/mpmd/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/x300/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/utils/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find mpm/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file ``` Also formatted host/include/, except Cpp03 was used as a the language standard instead of Cpp11. ``` sed -i 's/ Cpp11/ Cpp03/g' .clang-format find host/include/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file ``` Formatting style was designated by the .clang-format file.
Diffstat (limited to 'mpm/include')
-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
22 files changed, 670 insertions, 738 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
-