aboutsummaryrefslogtreecommitdiffstats
path: root/mpm/lib/lmk04828
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/lmk04828
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/lmk04828')
-rw-r--r--mpm/lib/lmk04828/CMakeLists.txt49
-rw-r--r--mpm/lib/lmk04828/lmk04828_spi_iface.cpp48
2 files changed, 0 insertions, 97 deletions
diff --git a/mpm/lib/lmk04828/CMakeLists.txt b/mpm/lib/lmk04828/CMakeLists.txt
deleted file mode 100644
index b3621034a..000000000
--- a/mpm/lib/lmk04828/CMakeLists.txt
+++ /dev/null
@@ -1,49 +0,0 @@
-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)
-
-
-# LMK04828 driver files
-LIST(APPEND lmk04828_srcs
- ${UHD_HOST_ROOT}/lib/usrp/common/lmk04828.cpp
- ${UHD_HOST_ROOT}/lib/types/serial.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/lmk04828_spi_iface.cpp
- )
-
-# Extra files needed
-LIST(APPEND lmk04828_srcs ${UHD_HOST_ROOT}/lib/exception.cpp)
-
-# For include/uhd/exception.hpp and include/uhd/config.h
-
-USRP_PERIPHS_ADD_OBJECT(lmk04828 ${lmk04828_srcs})
-TARGET_INCLUDE_DIRECTORIES(lmk04828 PUBLIC ${UHD_HOST_ROOT}/include ${CMAKE_CURRENT_BINARY_DIR} ${UHD_HOST_ROOT}/lib/usrp/common)
diff --git a/mpm/lib/lmk04828/lmk04828_spi_iface.cpp b/mpm/lib/lmk04828/lmk04828_spi_iface.cpp
deleted file mode 100644
index 1251f4535..000000000
--- a/mpm/lib/lmk04828/lmk04828_spi_iface.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-#include <mpm/lmk04828/lmk04828_spi_iface.hpp>
-#include <uhd/exception.hpp>
-#include <boost/make_shared.hpp>
-#include <functional>
-
-lmk04828_spi_iface::lmk04828_spi_iface(uhd::spi_iface::sptr iface) : _spi_iface(iface)
- {
- // Use default SPI Config options
- config = uhd::spi_config_t(uhd::spi_config_t::EDGE_RISE);
- }
-
-lmk04828_iface::write_fn_t lmk04828_spi_iface::get_write_fn()
- {
- return std::bind(&lmk04828_spi_iface::spi_write, this, std::placeholders::_1);
- }
-
-lmk04828_iface::read_fn_t lmk04828_spi_iface::get_read_fn()
- {
- return std::bind(&lmk04828_spi_iface::spi_read, this, std::placeholders::_1);
- }
-
-void lmk04828_spi_iface::spi_write(std::vector<uint32_t> writes) {
- for (uint32_t write : writes) {
- _spi_iface->write_spi(DEFAULT_SLAVE, config, write, LMK_SPI_NUM_BITS);
- }
- }
-
-uint8_t lmk04828_spi_iface::spi_read(uint32_t addr) {
- // Format LMK SPI read transaction
- // r/w[23] 0[22:21] addr[20:8] data[7:0] = 24 bits
- uint32_t transaction = 0;
- transaction |= LMK_SPI_READ_FLAG << LMK_SPI_READ_FLAG_OFFSET;
- //transaction &= LMK_SPI_RESERVED_FIELD_MASK;
- transaction |= addr << LMK_SPI_READ_ADDR_OFFSET;
-
- uint32_t data = _spi_iface->read_spi(DEFAULT_SLAVE, config, transaction, LMK_SPI_NUM_BITS);
-
- if ((data & 0xFFFFFF00) != 0) {
- // There's more than 8 bits of data!
- throw uhd::runtime_error("LMK SPI read returned too much data");
- }
-
- return data & 0xFF;
- }
-
-lmk04828_spi_iface::sptr lmk04828_spi_iface::make(uhd::spi_iface::sptr iface){
- return boost::make_shared<lmk04828_spi_iface>(iface);
-}