aboutsummaryrefslogtreecommitdiffstats
path: root/mpm/lib/chips
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2017-04-25 17:00:34 -0700
committerMartin Braun <martin.braun@ettus.com>2017-12-22 15:03:52 -0800
commit151ba5fb06dfdb6fcc46ccfdabf5f1e064236981 (patch)
treefa941b0589b09a22957e8b7e3966679748a9b202 /mpm/lib/chips
parent1262dfb3ccf5a9916685b3399587593174c6583e (diff)
downloaduhd-151ba5fb06dfdb6fcc46ccfdabf5f1e064236981.tar.gz
uhd-151ba5fb06dfdb6fcc46ccfdabf5f1e064236981.tar.bz2
uhd-151ba5fb06dfdb6fcc46ccfdabf5f1e064236981.zip
mpm: Major refactoring
- Created clean interfaces for SPI and registers - Severed most links to UHD - Added a lockable class which allows exposing mutexes into Python
Diffstat (limited to 'mpm/lib/chips')
-rw-r--r--mpm/lib/chips/CMakeLists.txt55
-rw-r--r--mpm/lib/chips/lmk04828_spi_iface.cpp40
2 files changed, 95 insertions, 0 deletions
diff --git a/mpm/lib/chips/CMakeLists.txt b/mpm/lib/chips/CMakeLists.txt
new file mode 100644
index 000000000..519ab1fe8
--- /dev/null
+++ b/mpm/lib/chips/CMakeLists.txt
@@ -0,0 +1,55 @@
+#
+# Copyright 2017 Ettus Research (National Instruments)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+#MACRO(ETTUS_PYTHON_GEN_SOURCE pyfile outfile)
+ ##ensure that the directory exists for outfile
+ #GET_FILENAME_COMPONENT(outfile_dir ${outfile} PATH)
+ #FILE(MAKE_DIRECTORY ${outfile_dir})
+ #IF(NOT PYTHON_EXECUTABLE)
+ #MESSAGE( FATAL_ERROR "No python executable found to generate ic_regmaps!" )
+ #ENDIF(NOT PYTHON_EXECUTABLE)
+ ##make the outfile depend on the python script
+ #ADD_CUSTOM_COMMAND(
+ #OUTPUT ${outfile} DEPENDS ${pyfile} ${ETTUS_PYTHON_GEN_SOURCE_DEPS}
+ #COMMAND ${PYTHON_EXECUTABLE} -B ${pyfile} ${outfile}
+ #COMMENT "Generating ${outfile}"
+ #)
+
+ ##make lmk04828 depend on the outfile
+ #LIST(APPEND lmk04828_srcs ${ARGV})
+#ENDMACRO(ETTUS_PYTHON_GEN_SOURCE)
+
+####################################################
+# LMK04828
+####################################################
+
+# Register definitions need to be generated
+#SET(UHD_HOST_ROOT ${CMAKE_SOURCE_DIR}/../host)
+#MESSAGE("uhd host root: ${UHD_HOST_ROOT}")
+#SET(UHD_IC_REG_MAP_PATH ${UHD_HOST_ROOT}/lib/ic_reg_maps)
+
+#SET(ETTUS_PYTHON_GEN_SOURCE_DEPS ${UHD_IC_REG_MAP_PATH}/common.py)
+#ETTUS_PYTHON_GEN_SOURCE(
+ #${UHD_IC_REG_MAP_PATH}/gen_lmk04828_regs.py
+ #${CMAKE_CURRENT_BINARY_DIR}/lmk04828_regs.hpp
+#)
+#SET(LIBUHD_PYTHON_GEN_SOURCE_DEPS)
+
+# Define the object
+USRP_PERIPHS_ADD_OBJECT(chips
+ lmk04828_spi_iface.cpp
+)
diff --git a/mpm/lib/chips/lmk04828_spi_iface.cpp b/mpm/lib/chips/lmk04828_spi_iface.cpp
new file mode 100644
index 000000000..6f21a0f46
--- /dev/null
+++ b/mpm/lib/chips/lmk04828_spi_iface.cpp
@@ -0,0 +1,40 @@
+//
+// Copyright 2017 Ettus Research (National Instruments)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#include <mpm/chips/lmk04828_spi_iface.hpp>
+#include <mpm/spi/spi_regs_iface.hpp>
+
+using namespace mpm::spi;
+
+static const int LMK_SPI_SPEED_HZ = 1000000;
+static const size_t LMK_ADDR_SHIFT = 8;
+static const size_t LMK_DATA_SHIFT = 0;
+static const size_t LMK_READ_FLAG = 1 << 23;
+static const size_t LMK_WRITE_FLAG = 0;
+
+mpm::types::regs_iface::sptr mpm::chips::make_lmk04828_iface(
+ const std::string &spi_device
+) {
+ return make_spi_regs_iface(
+ spi_iface::make_spidev(spi_device, LMK_SPI_SPEED_HZ),
+ LMK_ADDR_SHIFT,
+ LMK_DATA_SHIFT,
+ LMK_READ_FLAG,
+ LMK_WRITE_FLAG
+ );
+}
+