Skip to content

Commit

Permalink
temp working
Browse files Browse the repository at this point in the history
Signed-off-by: AlexandraTrifan <[email protected]>
  • Loading branch information
AlexandraTrifan committed May 30, 2024
1 parent 4f29af7 commit ab06d96
Show file tree
Hide file tree
Showing 20 changed files with 3,856 additions and 241 deletions.
4 changes: 4 additions & 0 deletions bindings/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ if(ENABLE_DOC)
endif()
endif()

if(LIBIIO_V1)
set(CMAKE_SWIG_FLAGS -DLIBIIO_V1)
endif()

SET_SOURCE_FILES_PROPERTIES(../${PROJECT_NAME}.i PROPERTIES CPLUSPLUS ON)

set(CMAKE_SWIG_OUTDIR ${CMAKE_BINARY_DIR})
Expand Down
6 changes: 3 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ endif()

SET(CMAKE_EXE_LINKER_FLAGS "/FORCE")

FILE(GLOB_RECURSE SRC_LIST *.cpp *_impl.hpp */*_impl.hpp)
FILE(GLOB_RECURSE SRC_LIST *.hpp *.cpp *_impl.hpp */*_impl.hpp)
IF(DEFINED LIBIIO_V1 AND NOT DEFINED CACHE{LIBIIO_V1})
# TBD separate a diff if to check if cached and display an error msg
LIST(FILTER SRC_LIST EXCLUDE REGEX ".*_v0.cpp")
LIST(FILTER SRC_LIST EXCLUDE REGEX ".*_v0.cpp|.*_v0.hpp")
ELSE()
LIST(FILTER SRC_LIST EXCLUDE REGEX ".*_v1.cpp")
LIST(FILTER SRC_LIST EXCLUDE REGEX ".*_v1.cpp|.*_v1.hpp")
ENDIF()

FILE(GLOB_RECURSE HEADERS_LIST ${CMAKE_SOURCE_DIR}/include/libm2k/*.hpp)
Expand Down
8 changes: 7 additions & 1 deletion src/analog/m2kanalogin_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ M2kAnalogInImpl::M2kAnalogInImpl(iio_context * ctx, std::string adc_dev, bool sy
m_trigger->setCalibParameters(i, getScalingFactor(i), m_adc_hw_vert_offset.at(i));
}

#ifndef LIBIIO_V1
// data_available attribute exists only in firmware versions newer than 0.23
m_data_available = m_m2k_adc->hasBufferAttribute("data_available");
#endif

if (sync) {
syncDevice();
Expand Down Expand Up @@ -156,6 +158,9 @@ void M2kAnalogInImpl::syncDevice()

void M2kAnalogInImpl::loadNbKernelBuffers()
{
#ifdef LIBIIO_V1
m_nb_kernel_buffers = 4;
#else
if (m_data_available) {
const unsigned int buffersize = 16;
handleChannelsEnableState(true);
Expand All @@ -168,6 +173,7 @@ void M2kAnalogInImpl::loadNbKernelBuffers()
} else {
m_nb_kernel_buffers = 4;
}
#endif
}

void M2kAnalogInImpl::setAdcCalibGain(ANALOG_IN_CHANNEL channel, double gain)
Expand Down Expand Up @@ -962,4 +968,4 @@ void M2kAnalogInImpl::setCalibrateHDL(std::string calibrate_val)
std::string M2kAnalogInImpl::getCalibrateHDL()
{
return m_m2k_adc->getStringValue("calibrate");
}
}
9 changes: 8 additions & 1 deletion src/analog/m2kanalogout_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ M2kAnalogOutImpl::M2kAnalogOutImpl(iio_context *ctx, std::vector<std::string> da
// dma_start_sync attribute is only available in firmware versions newer than 0.24
m_dma_start_sync_available = getDacDevice(0)->hasGlobalAttribute("dma_sync_start");

#ifndef LIBIIO_V1
// data_available attribute exists only in firmware versions newer than 0.23
m_dma_data_available = getDacDevice(0)->hasBufferAttribute("data_available");

#endif
m_raw_enable_available.push_back(getDacDevice(0)->getChannel(0, true)->hasAttribute("raw_enable"));
m_raw_enable_available.push_back(getDacDevice(1)->getChannel(0, true)->hasAttribute("raw_enable"));
m_raw_available.push_back(getDacDevice(0)->getChannel(0, true)->hasAttribute("raw"));
Expand Down Expand Up @@ -124,6 +125,11 @@ void M2kAnalogOutImpl::syncDevice()

void M2kAnalogOutImpl::loadNbKernelBuffers()
{
#ifdef LIBIIO_V1
for (unsigned int chn = 0; chn < m_dac_devices.size(); chn++) {
m_nb_kernel_buffers[chn] = 4;
}
#else
if (m_dma_data_available) {
const unsigned int buffersize = 16;
for (unsigned int chn = 0; chn < m_dac_devices.size(); chn++) {
Expand All @@ -141,6 +147,7 @@ void M2kAnalogOutImpl::loadNbKernelBuffers()
m_nb_kernel_buffers[chn] = 4;
}
}
#endif
}

unsigned short M2kAnalogOutImpl::setVoltage(unsigned int chn_idx, double volts)
Expand Down
Loading

0 comments on commit ab06d96

Please sign in to comment.