diff --git a/+adi/+common b/+adi/+common index 847122c6..3cfecec1 160000 --- a/+adi/+common +++ b/+adi/+common @@ -1 +1 @@ -Subproject commit 847122c65828df2849236c34ec10375c4dab3689 +Subproject commit 3cfecec155f97c9625fede39031d89e252a49e54 diff --git a/+adi/+libiio/base.m b/+adi/+libiio/base.m new file mode 100644 index 00000000..85cc1165 --- /dev/null +++ b/+adi/+libiio/base.m @@ -0,0 +1,23 @@ +classdef (Abstract) base < adi.libiio.device & ... + adi.libiio.channel & ... + adi.libiio.context & ... + adi.libiio.top & ... + adi.libiio.low_level & ... + matlab.System + properties(Hidden, Access = protected, Nontunable, Dependent) + libraryVersion_v1 + end + + methods + function version = get.libraryVersion_v1(obj) + version = '1.0'; + end + end + + %{ + methods (Hidden, Access = {?handle}) + function devPtr = getDev(obj, name) + end + end + %} +end \ No newline at end of file diff --git a/+adi/+libiio/channel.m b/+adi/+libiio/channel.m new file mode 100644 index 00000000..e3d31a7a --- /dev/null +++ b/+adi/+libiio/channel.m @@ -0,0 +1,95 @@ +classdef (Abstract) channel < handle & matlabshared.libiio.channel + % matlabshared.libiio.channel_V1p0 channel class for base matlabshared.libiio.support + % + % This abstract system object defines the APIs necessary to use libIIO + % V1.0 for MATLAB/Simulink simulation as well as codegen on a Linux + % target + + % Copyright 2024 Analog Devices Inc. + %#codegen + + %% Abstract Properties + properties(Abstract, Hidden, Access = protected) + libName + end + + methods + function obj = channel() + % CHANNEL constructor method for matlabshared.libiio.context + % + % Returns the matlabshared.libiio.context object + coder.allowpcode('plain'); + end + end + + %% Internal Helper Functions + methods (Hidden, Access = {?handle}) + function iio_channel_get_device(obj) + end + + function iio_channel_get_id(obj) + end + + function iio_channel_get_name(obj) + end + + function iio_channel_is_output(obj) + end + + function iio_channel_is_scan_element(obj) + end + + function iio_channel_get_attrs_count(obj) + end + + function iio_channel_get_attr(obj) + end + + function iio_channel_find_attr(obj) + end + + function iio_channel_enable(obj) + end + + function iio_channel_disable(obj) + end + + function iio_channel_is_enabled(obj) + end + + function iio_channel_read(obj) + end + + function iio_channel_write(obj) + end + + function iio_channel_set_data(obj) + end + + function iio_channel_get_data(obj) + end + + function iio_channel_get_type(obj) + end + + function iio_channel_get_modifier(obj) + end + + function status = iio_channel_attr_write_longlong(obj,chanPtr,attr,value) + % This function is a wrapper. Its name is chosen to match the + % corresponding version in < v1.0 to support compatibility + % through Compat.m. + + attrPtr = calllib(obj.libName, 'iio_channel_find_attr', chanPtr, attr); + status = calllib(obj.libName, 'iio_attr_write_longlong', attrPtr,value); + end + + function iio_channel_attr_read_longlong(obj) + % This function is a wrapper. It calls iio_channel_read() for + % longlong input. Its name is chosen to match the + % corresponding version in < v1.0 to support compatibility + % through Compat.m. + iio_channel_read(obj); + end + end +end \ No newline at end of file diff --git a/+adi/+libiio/context.m b/+adi/+libiio/context.m new file mode 100644 index 00000000..51430f01 --- /dev/null +++ b/+adi/+libiio/context.m @@ -0,0 +1,94 @@ +classdef (Abstract) context < matlabshared.libiio.context & ... + matlabshared.libiio.device + % matlabshared.libiio.contextV1p0 context class for base matlabshared.libiio.support + % + % This abstract system object defines the APIs necessary to use libIIO + % V1.0 for MATLAB/Simulink simulation as well as codegen on a Linux + % target + + % Copyright 2024 Analog Devices Inc. + %#codegen + + %% Abstract Properties + properties(Abstract, Hidden, Access = protected) + libName + end + + methods + function obj = context() + % CONTEXT constructor method for matlabshared.libiio.context + % + % Returns the matlabshared.libiio.context object + coder.allowpcode('plain'); + end + end + + %% Internal Helper Functions + methods (Hidden, Access = {?handle}) + %% Context Methods + function ctxPtr = iio_create_context(obj, ctxParamsPtr, uri) + % iio_create_context_from_uri (const char *uri) + % + % Create a context from a URI description. + if useCalllib(obj) + ctxPtr = calllib(obj.libName, 'iio_create_context', ctxParamsPtr, uri); + else + ctxPtr = coder.opaque('struct iio_context*', 'NULL'); + if useCodegen(obj) + ctxPtr = coder.ceval('iio_create_context', ctxParamsPtr, obj.ntstr(uri)); + end + end + end + + function iio_context_destroy(obj) + end + + function iio_context_get_version_major(obj) + end + + function iio_context_get_version_minor(obj) + end + + function iio_context_get_version_tag(obj) + end + + function iio_context_get_xml(obj) + end + + function iio_context_get_name(obj) + end + + function iio_context_get_description(obj) + end + + function iio_context_get_attrs_count(obj) + end + + function iio_context_get_attr(obj) + end + + function iio_context_find_attr(obj) + end + + function iio_context_get_devices_count(obj) + end + + function iio_context_get_device(obj) + end + + function iio_context_find_device(obj) + end + + function iio_context_set_timeout(obj) + end + + function iio_context_get_params(obj) + end + + function iio_context_set_data(obj) + end + + function iio_context_get_data(obj) + end + end +end \ No newline at end of file diff --git a/+adi/+libiio/device.m b/+adi/+libiio/device.m new file mode 100644 index 00000000..0df0f869 --- /dev/null +++ b/+adi/+libiio/device.m @@ -0,0 +1,85 @@ +classdef (Abstract) device < handle & matlabshared.libiio.device + % matlabshared.libiio.contextV1p0 context class for base matlabshared.libiio.support + % + % This abstract system object defines the APIs necessary to use libIIO + % V1.0 for MATLAB/Simulink simulation as well as codegen on a Linux + % target + + % Copyright 2024 Analog Devices Inc. + %#codegen + + %% Abstract Properties + properties(Abstract, Hidden, Access = protected) + libName + end + + methods + function obj = device() + % CONTEXT constructor method for matlabshared.libiio.context + % + % Returns the matlabshared.libiio.context object + coder.allowpcode('plain'); + end + end + + %% Internal Helper Functions + methods (Hidden, Access = {?handle}) + %% Device Methods + function ctxPtr = iio_device_get_context(obj, devPtr) + % iio_device_get_context (const char *uri) + % + % Get context from device pointer. + if useCalllib(obj) + ctxPtr = calllib(obj.libName, 'iio_device_get_context', devPtr); + else + ctxPtr = coder.opaque('struct iio_context*', 'NULL'); + if useCodegen(obj) + ctxPtr = coder.ceval('iio_device_get_context', devPtr); + end + end + end + + function iio_device_get_id(obj) + end + + function iio_device_get_name(obj) + end + + function iio_device_get_label(obj) + end + + function iio_device_get_channels_count(obj) + end + + function iio_device_get_attrs_count(obj) + end + + function iio_device_get_channel(obj) + % iio_device_get_channel@matlabshared.libiio.device(obj); + end + + function iio_device_get_attr(obj) + end + + function chanPtr = iio_device_find_channel(obj,dev,id,output) + end + + function iio_device_find_attr(obj) + end + + function iio_device_set_data(obj) + end + + function iio_device_get_data(obj) + end + + function iio_device_get_trigger(obj) + end + + function iio_device_set_trigger(obj) + end + + function iio_device_is_trigger(obj) + end + end +end \ No newline at end of file diff --git a/+adi/+libiio/low_level.m b/+adi/+libiio/low_level.m new file mode 100644 index 00000000..a18f338e --- /dev/null +++ b/+adi/+libiio/low_level.m @@ -0,0 +1,95 @@ +classdef (Abstract) low_level < matlabshared.libiio.device + % matlabshared.libiio.contextV1p0 context class for base matlabshared.libiio.support + % + % This abstract system object defines the APIs necessary to use libIIO + % V1.0 for MATLAB/Simulink simulation as well as codegen on a Linux + % target + + % Copyright 2024 Analog Devices Inc. + %#codegen + + %% Abstract Properties + properties(Abstract, Hidden, Access = protected) + libName + end + + methods + function obj = low_level() + % CONTEXT constructor method for matlabshared.libiio.context + % + % Returns the matlabshared.libiio.context object + coder.allowpcode('plain'); + end + end + + %% Internal Helper Functions + methods (Hidden, Access = {?handle}) + %% Low-level Methods + function iio_create_channels_mask(obj) + end + + function iio_channels_mask_destroy(obj) + end + + function iio_device_get_sample_size(obj) + end + + function iio_channel_get_index(obj) + end + + function iio_channel_get_data_format(obj) + end + + function iio_channel_convert(obj, chanPtr, dst, src) + end + + function iio_channel_convert_inverse(obj) + end + + function iio_device_get_debug_attrs_count(obj) + end + + function iio_device_get_debug_attr(obj) + end + + function attr = iio_device_find_debug_attr(obj, devPtr, name) + % iio_device_find_debug_attr (const struct iio_device *devPtr, const char *name) + % + % Get context from device pointer. + if useCalllib(obj) + attr = calllib(obj.libName, 'iio_device_find_debug_attr', devPtr, name); + else + if useCodegen(obj) + attr = coder.ceval('iio_device_find_debug_attr', devPtr, obj.ntstr(name)); + end + end + end + + function iio_device_reg_write(obj) + end + + function iio_device_reg_read(obj) + end + + function iio_attr_read_bool(obj) + end + + function iio_attr_read_longlong(obj) + end + + function iio_attr_read_double(obj) + end + + function iio_attr_write_string(obj) + end + + function iio_attr_write_bool(obj) + end + + function iio_attr_write_longlong(obj) + end + + function iio_attr_write_double(obj) + end + end +end \ No newline at end of file diff --git a/+adi/+libiio/top.m b/+adi/+libiio/top.m new file mode 100644 index 00000000..fb150d55 --- /dev/null +++ b/+adi/+libiio/top.m @@ -0,0 +1,50 @@ +classdef (Abstract) top < matlabshared.libiio.top + % matlabshared.libiio.top device class for base matlabshared.libiio.support + % + % This abstract system object defines the APIs necessary to use libIIO + % for MATLAB/Simulink simulation as well as codegen on a Linux target + + % Copyright 2018 The MathWorks, Inc. + %#codegen + + %% Abstract Properties + properties(Abstract, Hidden, Access = protected) + libName + end + + methods + function obj = top() + % TOP constructor method for matlabshared.libiio.buffer + % + % Returns the matlabshared.libiio.top object + coder.allowpcode('plain'); + end + end + + %% Internal Helper Functions + methods (Hidden, Access = {?handle}) + %% Top-level functions + function [major, minor, gitTag] = iio_library_get_version(obj) + % iio_library_get_version(unsigned int *major,unsigned int *minor,char git_tag[8]) + % + % Get the version of the libiio library. + if useCalllib(obj) + majorPtr = libpointer('uint32Ptr',0); + minorPtr = libpointer('uint32Ptr',0); + gitTagPtr = libpointer('int8Ptr',zeros(1,8)); + + calllib(obj.libName, 'iio_library_get_version', majorPtr, minorPtr, gitTagPtr); + + major = majorPtr.Value; + minor = minorPtr.Value; + gitTag = char(gitTagPtr.Value); + elseif useCodegen(obj) + major = coder.nullcopy(int32(0)); + minor = coder.nullcopy(int32(0)); + gitTag = coder.nullcopy(char(zeros(1,8, 'uint8'))); + + coder.ceval('iio_library_get_version', coder.wref(major), coder.wref(minor), coder.wref(gitTag)); + end + end + end +end