From 6dbddb1c2a23464a47366a40161b06ca8c16da20 Mon Sep 17 00:00:00 2001 From: "Ionut.Muthi" Date: Wed, 15 Mar 2023 11:46:26 +0200 Subject: [PATCH 1/2] add streaming for AD917x board family --- +adi/+internal/+AD917x/Base.m | 65 +++++++++++++++++++++++++++++++++++ +adi/+internal/+AD917x/Tx.m | 45 ++++++++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 +adi/+internal/+AD917x/Base.m create mode 100644 +adi/+internal/+AD917x/Tx.m diff --git a/+adi/+internal/+AD917x/Base.m b/+adi/+internal/+AD917x/Base.m new file mode 100644 index 00000000..f368efee --- /dev/null +++ b/+adi/+internal/+AD917x/Base.m @@ -0,0 +1,65 @@ +classdef (Abstract) Base < ... + adi.common.RxTx & ... + matlabshared.libiio.base + %AD917x Base Summary of this class goes here + % Detailed explanation goes here + + properties (Nontunable) + %SamplesPerFrame Samples Per Frame + % Number of samples per frame, specified as an even positive + % integer from 2 to 16,777,216. Using values less than 3660 can + % yield poor performance. + SamplesPerFrame = 2^15; + end + + properties(Nontunable, Hidden) + Timeout = Inf; + kernelBuffersCount = 2; + dataTypeStr = 'int16'; + end + + properties (Abstract, Hidden, Constant) + Type + end + + properties (Hidden, Constant) + ComplexData = true; + end + + methods + %% Constructor + function obj = Base(varargin) + % Returns the matlabshared.libiio.base object + coder.allowpcode('plain'); + obj = obj@matlabshared.libiio.base(varargin{:}); + end + % Check SamplesPerFrame + function set.SamplesPerFrame(obj, value) + validateattributes( value, { 'double','single' }, ... + { 'real', 'positive','scalar', 'finite', 'nonnan', 'nonempty','integer','>',0,'<',2^20+1}, ... + '', 'SamplesPerFrame'); + obj.SamplesPerFrame = value; + end + end + + %% API Functions + methods (Hidden, Access = protected) + function setupInit(~) + % Unused + end + end + + %% External Dependency Methods + methods (Hidden, Static) + + function tf = isSupportedContext(bldCfg) + tf = matlabshared.libiio.ExternalDependency.isSupportedContext(bldCfg); + end + + function updateBuildInfo(buildInfo, bldCfg) + % Call the matlabshared.libiio.method first + matlabshared.libiio.ExternalDependency.updateBuildInfo(buildInfo, bldCfg); + end + end +end + diff --git a/+adi/+internal/+AD917x/Tx.m b/+adi/+internal/+AD917x/Tx.m new file mode 100644 index 00000000..f939e6d4 --- /dev/null +++ b/+adi/+internal/+AD917x/Tx.m @@ -0,0 +1,45 @@ +classdef Tx < adi.common.Tx & adi.AD917x.Base & adi.common.DDS + % adi.AD917x.Tx + % + % AD917x + % + + + properties (Constant) + %SamplingRate Sampling Rate + % Baseband sampling rate in Hz, specified as a scalar + % in samples per second. This value is constant + SamplingRate = 1e9; + end + + properties (Hidden, Nontunable, Access = protected) + isOutput = true; + end + + properties(Nontunable, Hidden, Constant) + Type = 'Tx'; + end + + methods + %% Constructor + function obj = Tx(varargin) + % Returns the matlabshared.libiio.base object + coder.allowpcode('plain'); + obj = obj@adi.AD917x.Base(varargin{:}); + end + end + + %% External Dependency Methods + methods (Hidden, Static) + + function tf = isSupportedContext(bldCfg) + tf = matlabshared.libiio.ExternalDependency.isSupportedContext(bldCfg); + end + + function updateBuildInfo(buildInfo, bldCfg) + % Call the matlabshared.libiio.method first + matlabshared.libiio.ExternalDependency.updateBuildInfo(buildInfo, bldCfg); + end + end +end + From 5c4d726908c59d0acf4310055b8a453e0c921760 Mon Sep 17 00:00:00 2001 From: "Ionut.Muthi" Date: Wed, 15 Mar 2023 11:47:20 +0200 Subject: [PATCH 2/2] add streaming support for AD9172 --- +adi/+AD9172/Tx.m | 32 ++++++++++++++++++++++++++++++++ test/AD9172Test.m | 21 +++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 +adi/+AD9172/Tx.m create mode 100644 test/AD9172Test.m diff --git a/+adi/+AD9172/Tx.m b/+adi/+AD9172/Tx.m new file mode 100644 index 00000000..452688a2 --- /dev/null +++ b/+adi/+AD9172/Tx.m @@ -0,0 +1,32 @@ +classdef Tx < adi.AD917x.Tx & adi.AD917x.Base + % adi.AD9172.Tx Transmit data to the AD9172 high speed DAC + % + % tx = adi.AD9172.Tx; + % tx = adi.AD9172.Tx('uri','192.168.2.1'); + % + % AD9172 Datasheet + % + + properties (Nontunable, Hidden) + devName = 'axi-ad9172-hpc'; + channel_names = {'voltage0_i','voltage0_q'}; + end + + %% API Functions + methods (Hidden, Access = protected) + + function icon = getIconImpl(obj) + icon = sprintf(['AD9172 ',obj.Type]); + end + end + + + %% External Dependency Methods + methods (Hidden, Static) + function bName = getDescriptiveName(~) + bName = 'AD9172'; + end + + end +end + diff --git a/test/AD9172Test.m b/test/AD9172Test.m new file mode 100644 index 00000000..47bbb41e --- /dev/null +++ b/test/AD9172Test.m @@ -0,0 +1,21 @@ +classdef AD9172Test < matlab.unittest.TestCase + properties + uri = 'ip:analog.local'; + author = 'ADI'; + end + + + methods(Test) + function testAD9172Tx(testCase) + tx = adi.AD9172.Tx('uri',testCase.uri); + tx.EnableCyclicBuffers = true; + x = linspace(-pi,pi,2^15).'; + + b1 = sin(x); + tx(b1); + tx.step(b1); + end + end + +end +