Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cn0585_fmcz support #5

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions +adi/+AD3552R/Base.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
classdef (Abstract) Base < ...
adi.common.RxTx & ...
matlabshared.libiio.base & ...
adi.common.Attribute
% adi.AD3552R.Tx Transmit data to the AD3552R high speed DAC
% The adi.AD3552R.Tx System object is a signal source that can send
% complex data from the AD3552R.
%
% tx = adi.AD3552R.Tx;
% tx = adi.AD3552R.Tx('uri','192.168.2.1');
%
% <a href="http://www.analog.com/media/en/technical-documentation/data-sheets/AD3552R.pdf">AD3552R Datasheet</a>
%
% See also adi.CN0585.Tx

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 = 'uint16';
end

properties (Abstract, Hidden, Constant)
Type
end

properties (Hidden, Constant)
ComplexData = false;
end

properties
% InputSource
% Lists all the available input sources of the DAC.
% Options are: 'adc_input', 'dma_input', 'ramp_input'.
% Example: InputSource = 'dma_input';
InputSource = 'dma_input';
end

properties
% OutputRange
% Lists all the available voltage ranges of the output signal.
% Options are: '0/2.5V', '0/5V', '0/10V', '-5/+5V', '-10/+10V'.
% Example: OutputRange = '-10/+10V';
OutputRange = '-10/+10V';
end

properties
InputSourceSet = matlab.system.StringSet({...
'adc_input', 'dma_input', 'ramp_input'})
OutputRangeSet = matlab.system.StringSet({...
'0/2.5V', '0/5V', '0/10V', '-5/+5V', '-10/+10V'})
end

methods
%% Constructor
function obj = Base(varargin)
% Returns the matlabshared.libiio.base object
coder.allowpcode('plain');
obj = [email protected](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

% Set/Get Input Source
function result = get.InputSource(obj)
result = obj.InputSource;
end

function set.InputSource(obj, value)
obj.InputSource = value;
end

% Set/Get Output Range
function result = get.OutputRange(obj)
result = obj.OutputRange;
end

function set.OutputRange(obj, value)
obj.OutputRange = value;
end

end

%% API Functions
methods (Hidden, Access = protected)

function icon = getIconImpl(obj)
icon = sprintf(['AD3552R', obj.Type]);
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

function bName = getDescriptiveName(~)
bName = 'AD3552R';
end

end

end
88 changes: 88 additions & 0 deletions +adi/+AD3552R/Tx.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
classdef Tx < adi.common.Tx & adi.AD3552R.Base
% adi.AD3552R.Tx Transmit data to the AD3552R high speed DAC
% The adi.AD3552R.Tx System object is a signal source that can send
% complex data from the AD3552R.
%
% tx = adi.AD3552R.Tx;
% tx = adi.AD3552R.Tx('uri','192.168.2.1');
%
% <a href="http://www.analog.com/media/en/technical-documentation/data-sheets/AD3552R.pdf">AD3552R Datasheet</a>
%
% See also adi.CN0585.Tx

properties (Constant)
% SamplingRate Sampling Rate
% Baseband sampling rate in Hz, specified as a scalar
% in samples per second. This value is constant.
SamplingRate = 15e6;
end

properties (Hidden, Nontunable, Access = protected)
isOutput = true;
end

properties (Nontunable, Hidden, Constant)
Type = 'Tx';
end

properties (Nontunable, Hidden)
devName = 'axi-ad3552r';
phyDevName = 'axi-ad3552r';
channel_names = {'voltage0', 'voltage1'};
end

properties
% StreamStatus
% Describes the status of the data streaming.
% Options are: 'start_stream_synced', 'start_stream', 'stop_stream'.
% Example: StreamStatus = 'stop_stream';
StreamStatus = 'stop_stream';
end

properties (Hidden, Constant)
StreamStatusSet = matlab.system.StringSet({ ...
'start_stream_synced', 'start_stream', 'stop_stream'})
end

methods
%% Constructor
function obj = Tx(varargin)
% Returns the matlabshared.libiio.base object
coder.allowpcode('plain');
obj = [email protected](varargin{:});
end

%% Start or stop stream transfer
function set.StreamStatus(obj, value)

if obj.ConnectedToDevice
obj.setDeviceAttributeRAW('stream_status', value);
else
error(['StreamStatus cannot be set before initialization, ']);
end

obj.StreamStatus = value;

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

function bName = getDescriptiveName(~)
bName = 'AD3552R';
end

end

end
60 changes: 60 additions & 0 deletions +adi/+CN0585/Base.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
classdef (Abstract, Hidden = true) Base < ...
adi.common.RxTx & ...
adi.common.Attribute & ...
matlabshared.libiio.base
%adi.CN0585.Base Class
% This class contains shared parameters and methods between TX and RX
% classes

properties (Hidden)
iioOneBitADCDAC;
HDLSystemID

end

methods
%% Constructor
function obj = Base(varargin)
coder.allowpcode('plain');
obj = [email protected](varargin{:});
end

function result = CheckMathWorksCore(obj)
result = contains(obj.HDLSystemID, "matlab");
end

end

%% API Functions
methods (Hidden, Access = protected)

function setupInit(obj)

% GPIO CONTROLLER

obj.iioOneBitADCDAC = getDev(obj, 'one-bit-adc-dac');
obj.setAttributeBool('voltage0', 'raw', boolean(1), true, obj.iioOneBitADCDAC);
obj.setAttributeBool('voltage1', 'raw', boolean(1), true, obj.iioOneBitADCDAC);
obj.setAttributeBool('voltage2', 'raw', boolean(1), true, obj.iioOneBitADCDAC);
obj.setAttributeBool('voltage3', 'raw', boolean(1), true, obj.iioOneBitADCDAC);
obj.setAttributeBool('voltage4', 'raw', boolean(1), true, obj.iioOneBitADCDAC);
obj.setAttributeBool('voltage5', 'raw', boolean(1), true, obj.iioOneBitADCDAC);
obj.setAttributeBool('voltage6', 'raw', boolean(1), true, obj.iioOneBitADCDAC);
obj.setAttributeBool('voltage7', 'raw', boolean(1), true, obj.iioOneBitADCDAC);
obj.setAttributeBool('voltage8', 'raw', boolean(1), true, obj.iioOneBitADCDAC);
obj.setAttributeBool('voltage9', 'raw', boolean(1), true, obj.iioOneBitADCDAC);

% HDLSystemID SYSID STRING VALUE

obj.HDLSystemID = obj.iio_context_get_attr_value(obj.iioCtx, 'hdl_system_id');

% UPDATED PARAMETERS

obj.setDeviceAttributeRAW('input_source', obj.InputSource);
obj.setDeviceAttributeRAW('output_range', obj.OutputRange);

end

end

end
21 changes: 21 additions & 0 deletions +adi/+CN0585/Rx.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
classdef Rx < adi.LTC2387.Rx
% adi.CN0585.Rx Receive data from the LTC2387 evaluation platform
%
% rx = adi.CN0585.Rx;
% rx = adi.CN0585.Rx('uri','192.168.2.1');
%
% <a href="https://wiki.analog.com/resources/eval/user-guides/circuits-from-the-lab/cn0585">User Guide</a>
%
% See also adi.LTC2387.Rx

methods
%% Constructor
function obj = Rx(varargin)
% Returns the matlabshared.libiio.base object
coder.allowpcode('plain');
obj = [email protected](varargin{:});
end

end

end
23 changes: 23 additions & 0 deletions +adi/+CN0585/Tx0.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
classdef Tx0 < adi.AD3552R.Tx & adi.CN0585.Base
% adi.CN0585.Tx Transmit data from the AD3552R evaluation platform
%
% tx0 = adi.CN0585.Tx0;
% tx0 = adi.CN0585.Tx0('uri','192.168.2.1');
%
% <a href="https://wiki.analog.com/resources/eval/user-guides/circuits-from-the-lab/cn0585">User Guide</a>
%
% See also adi.AD3552R.Tx0

methods
%% Constructor
function obj = Tx0(varargin)
% Returns the matlabshared.libiio.base object
coder.allowpcode('plain');
obj = [email protected](varargin{:});
obj.devName = 'axi-ad3552r-0';
obj.phyDevName = 'axi-ad3552r-0';
end

end

end
22 changes: 22 additions & 0 deletions +adi/+CN0585/Tx1.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
classdef Tx1 < adi.AD3552R.Tx & adi.CN0585.Base
% adi.CN0585.Tx Transmit data from the AD3552R evaluation platform
%
% tx1 = adi.CN0585.Tx1;
% tx1 = adi.CN0585.Tx1('uri','192.168.2.1');
%
% <a href="https://wiki.analog.com/resources/eval/user-guides/circuits-from-the-lab/cn0585">User Guide</a>
%
% See also adi.AD3552R.Tx1

methods
%% Constructor
function obj = Tx1(varargin)
% Returns the matlabshared.libiio.base object
coder.allowpcode('plain');
obj = [email protected](varargin{:});
obj.devName = 'axi-ad3552r-1';
obj.phyDevName = 'axi-ad3552r-1';
end
end

end
Loading
Loading