Skip to content

Commit

Permalink
add libad9361-iio library support
Browse files Browse the repository at this point in the history
  • Loading branch information
jocover committed Aug 25, 2017
1 parent bb0d64e commit 5b64a0c
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 3 deletions.
17 changes: 16 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,27 @@ if(CMAKE_COMPILER_IS_GNUCXX)

endif(CMAKE_COMPILER_IS_GNUCXX)

########################################################################
# Find libad9361
########################################################################
find_package(libad9361)

if (LIBAD9361_FOUND)
message(STATUS "LIBAD9361_INCLUDE_DIRS: ${LIBAD9361_INCLUDE_DIRS}")
message(STATUS "LIBAD9361_LIBRARIES: ${LIBAD9361_LIBRARIES}")
message(STATUS "LIBAD9361_DEFINITIONS: ${LIBAD9361_DEFINITIONS}")
include_directories(${LIBAD9361_INCLUDE_DIRS})
add_definitions(-DHAS_AD9361_IIO)
endif()




SOAPY_SDR_MODULE_UTIL(
TARGET PlutSDRSupport
SOURCES
PlutoSDR_Registation.cpp
PlutoSDR_Settings.cpp
PlutoSDR_Streaming.cpp
LIBRARIES ${LIBIIO_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}
LIBRARIES ${LIBIIO_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${LIBAD9361_LIBRARIES}
)
34 changes: 34 additions & 0 deletions Findlibad9361.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# - Try to find libad9361-iio
# Once done this will define
#
# LIBAD9361_FOUND - system has libiio
# LIBAD9361_INCLUDE_DIRS - the libiio include directory
# LIBAD9361_LIBRARIES - Link these to use libiio
# LIBAD9361_DEFINITIONS - Compiler switches required for using libiio
#
# Redistribution and use is allowed according to the terms of the New BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#

include(FindPkgConfig)
pkg_check_modules(PC_LIBAD9361 QUIET libad9361)
set(LIBAD9361_DEFINITIONS ${PC_LIBAD9361_CFLAGS_OTHER})

find_path(LIBAD9361_INCLUDE_DIR ad9361.h
HINTS ${PC_LIBAD9361_INCLUDEDIR} ${PC_LIBAD9361_INCLUDE_DIRS}
PATH_SUFFIXES libad9361-iio)

find_library(LIBAD9361_LIBRARY NAMES ad9361 libad9361
HINTS ${PC_LIBAD9361_LIBDIR} ${PC_LIBAD9361_LIBRARY_DIRS})

set(LIBAD9361_VERSION ${PC_LIBAD9361_VERSION})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(libad9361
REQUIRED_VARS LIBAD9361_LIBRARY LIBAD9361_INCLUDE_DIR
VERSION_VAR LIBAD9361_VERSION)

mark_as_advanced(LIBAD9361_INCLUDE_DIR LIBAD9361_LIBRARY)

set(LIBAD9361_LIBRARIES ${LIBAD9361_LIBRARY})
set(LIBAD9361_INCLUDE_DIRS ${LIBAD9361_INCLUDE_DIR})
9 changes: 8 additions & 1 deletion PlutoSDR_Settings.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "SoapyPlutoSDR.hpp"

#ifdef HAS_AD9361_IIO
#include <ad9361.h>
#endif

SoapyPlutoSDR::SoapyPlutoSDR( const SoapySDR::Kwargs &args ):
ctx(nullptr){
Expand Down Expand Up @@ -315,6 +317,11 @@ void SoapyPlutoSDR::setSampleRate( const int direction, const size_t channel, co
iio_channel_attr_write_longlong(iio_device_find_channel(dev, "voltage0", true),"sampling_frequency", samplerate);

}

#ifdef HAS_AD9361_IIO
if(ad9361_set_bb_rate(dev,samplerate))
throw std::runtime_error("Unable to set BB rate");
#endif

}

Expand Down
2 changes: 1 addition & 1 deletion PlutoSDR_Streaming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ int tx_streamer::send( const void * const *buffs,

float *samples_cf32 = (float *)buffs[0];
for (size_t j = 0; j < items; ++j) {
buffer[j]=(float)(samples_cf32[j*2+i]*2048);
buffer[j]=(int16_t)(samples_cf32[j*2+i]*2048);
}

channel_write(channel_list[i],buffer.data(),items);
Expand Down

0 comments on commit 5b64a0c

Please sign in to comment.