diff --git a/+adi/+AD9361/Base.m b/+adi/+AD9361/Base.m index b47fc854..c525ed44 100644 --- a/+adi/+AD9361/Base.m +++ b/+adi/+AD9361/Base.m @@ -4,151 +4,156 @@ adi.common.DebugAttribute & ... matlabshared.libiio.base - %adi.AD9361.Base Class + % adi.AD9361.Base Class % This class contains shared parameters and methods between TX and RX % classes properties (Nontunable) - %SamplesPerFrame Samples Per Frame + % 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; + SamplesPerFrame = 2^15 end - + properties (Nontunable, Logical) - %EnableCustomFilter Enable Custom Filter - % Enable use of custom filter file to set SamplingRate, + % EnableCustomFilter Enable Custom Filter + % Enable use of custom filter file to set SamplingRate, % RFBandwidth, and FIR in datapaths - EnableCustomFilter = false; + EnableCustomFilter = false end - + properties (Nontunable) - %CustomFilterFileName Custom Filter File Name + % CustomFilterFileName Custom Filter File Name % Path to custom filter file created from filter wizard - CustomFilterFileName = ''; + CustomFilterFileName = '' end - + properties (Abstract) - %CenterFrequency Center Frequency + % CenterFrequency Center Frequency % RF center frequency, specified in Hz as a scalar. The % default is 2.4e9. This property is tunable. CenterFrequency - %SamplingRate Sampling Rate + % SamplingRate Sampling Rate % Baseband sampling rate in Hz, specified as a scalar % from 65105 to 61.44e6 samples per second. SamplingRate - %RFBandwidth RF Bandwidth + % RFBandwidth RF Bandwidth % RF Bandwidth of front-end analog filter in Hz, specified as a % scalar from 200 kHz to 56 MHz. RFBandwidth end - - properties(Nontunable, Hidden) - Timeout = Inf; - kernelBuffersCount = 2; - dataTypeStr = 'int16'; - phyDevName = 'ad9361-phy'; + + properties (Nontunable, Hidden) + Timeout = Inf + kernelBuffersCount = 2 + dataTypeStr = 'int16' + phyDevName = 'ad9361-phy' iioDevPHY end - + properties (Hidden, Constant) - ComplexData = true; + ComplexData = true end - + methods + %% Constructor function obj = Base(varargin) coder.allowpcode('plain'); obj = obj@matlabshared.libiio.base(varargin{:}); end + % Destructor function delete(obj) teardownLibad9361(obj); delete@adi.common.RxTx(obj); end + % Check SamplesPerFrame function set.SamplesPerFrame(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'positive','scalar', 'finite', 'nonnan', 'nonempty','integer','>',0,'<=',2^20}, ... - '', 'SamplesPerFrame'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'positive', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>', 0, '<=', 2^20}, ... + '', 'SamplesPerFrame'); obj.SamplesPerFrame = value; end + % Check EnableCustomFilter function set.EnableCustomFilter(obj, value) - validateattributes( value, { 'logical' }, ... - { }, ... - '', 'EnableCustomFilter'); + validateattributes(value, { 'logical' }, ... + { }, ... + '', 'EnableCustomFilter'); obj.EnableCustomFilter = value; end + % Check CustomFilterFileName function set.CustomFilterFileName(obj, value) - validateattributes( value, { 'char' }, ... - { }, ... - '', 'CustomFilterFileName'); + validateattributes(value, { 'char' }, ... + { }, ... + '', 'CustomFilterFileName'); obj.CustomFilterFileName = value; if obj.EnableCustomFilter && obj.ConnectedToDevice %#ok writeFilterFile(obj); end end + end - + %% API Functions methods (Hidden, Access = protected) - + function icon = getIconImpl(obj) - icon = sprintf(['AD9361 ',obj.Type]); + icon = sprintf(['AD9361 ', obj.Type]); end - + function setupLibad9361(obj) libName = 'libad9361'; ad9361wrapperh = 'ad9361-wrapper.h'; ad9361h = 'ad9361.h'; fp = fileparts(which(ad9361h)); - loadlibraryArgs = {ad9361wrapperh,'includepath',fp,'addheader',ad9361h}; + loadlibraryArgs = {ad9361wrapperh, 'includepath', fp, 'addheader', ad9361h}; if ~libisloaded(libName) msgID = 'MATLAB:loadlibrary:StructTypeExists'; - warnStruct = warning('off',msgID); + warnStruct = warning('off', msgID); [~, ~] = loadlibrary(libName, loadlibraryArgs{:}); warning(warnStruct); end - obj.iioDevPHY = calllib('libiio', 'iio_context_find_device',obj.iioCtx,'ad9361-phy'); + obj.iioDevPHY = calllib('libiio', 'iio_context_find_device', obj.iioCtx, 'ad9361-phy'); end - + function teardownLibad9361(~) libName = 'libad9361'; if libisloaded(libName) unloadlibrary(libName); end end - + function writeFilterFile(obj) fir_data_file = obj.CustomFilterFileName; fir_data_str = fileread(fir_data_file); - obj.setAttributeRAW('voltage0','filter_fir_en','0',false); - obj.setAttributeRAW('voltage0','filter_fir_en','0',true); - obj.setDeviceAttributeRAW('filter_fir_config',fir_data_str); - obj.setAttributeRAW('voltage0','filter_fir_en','1',true); - obj.setAttributeRAW('voltage0','filter_fir_en','1',false); + obj.setAttributeRAW('voltage0', 'filter_fir_en', '0', false); + obj.setAttributeRAW('voltage0', 'filter_fir_en', '0', true); + obj.setDeviceAttributeRAW('filter_fir_config', fir_data_str); + obj.setAttributeRAW('voltage0', 'filter_fir_en', '1', true); + obj.setAttributeRAW('voltage0', 'filter_fir_en', '1', false); 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 = 'AD9361'; end - + end end - diff --git a/+adi/+AD9361/Rx.m b/+adi/+AD9361/Rx.m index 87340d71..024de060 100644 --- a/+adi/+AD9361/Rx.m +++ b/+adi/+AD9361/Rx.m @@ -10,82 +10,82 @@ % AD9361 Datasheet % % See also adi.FMComms2.Rx, adi.FMComms3.Rx, adi.FMComms5.Rx - + properties - %CenterFrequency Center Frequency + % CenterFrequency Center Frequency % RF center frequency, specified in Hz as a scalar. The % default is 2.4e9. This property is tunable. - CenterFrequency = 2.4e9; - %SamplingRate Sampling Rate - % Baseband sampling rate in Hz, specified as a scalar + CenterFrequency = 2.4e9 + % SamplingRate Sampling Rate + % Baseband sampling rate in Hz, specified as a scalar % from 65105 to 61.44e6 samples per second. - SamplingRate = 3e6; - %RFBandwidth RF Bandwidth + SamplingRate = 3e6 + % RFBandwidth RF Bandwidth % RF Bandwidth of front-end analog filter in Hz, specified as a % scalar from 200 kHz to 56 MHz. - RFBandwidth = 3e6; + RFBandwidth = 3e6 end - + properties - %GainControlModeChannel0 Gain Control Mode Channel 0 + % GainControlModeChannel0 Gain Control Mode Channel 0 % specified as one of the following: - % 'slow_attack' — For signals with slowly changing power levels - % 'fast_attack' — For signals with rapidly changing power levels - % 'manual' — For setting the gain manually with the Gain property - % 'hybrid' — For configuring hybrid AGC mode - GainControlModeChannel0 = 'slow_attack'; - %GainChannel0 Gain Channel 0 + % 'slow_attack' - For signals with slowly changing power levels + % 'fast_attack' - For signals with rapidly changing power levels + % 'manual' - For setting the gain manually with the Gain property + % 'hybrid' - For configuring hybrid AGC mode + GainControlModeChannel0 = 'slow_attack' + % GainChannel0 Gain Channel 0 % Channel 0 gain, specified as a scalar from -3 dB to 71 dB. The acceptable % minimum and maximum gain setting depends on the center % frequency. - GainChannel0 = 10; - %GainControlModeChannel1 Gain Control Mode Channel 1 + GainChannel0 = 10 + % GainControlModeChannel1 Gain Control Mode Channel 1 % specified as one of the following: - % 'slow_attack' — For signals with slowly changing power levels - % 'fast_attack' — For signals with rapidly changing power levels - % 'manual' — For setting the gain manually with the Gain property - % 'hybrid' — For configuring hybrid AGC mode - GainControlModeChannel1 = 'slow_attack'; - %GainChannel1 Gain Channel 1 + % 'slow_attack' - For signals with slowly changing power levels + % 'fast_attack' - For signals with rapidly changing power levels + % 'manual' - For setting the gain manually with the Gain property + % 'hybrid' - For configuring hybrid AGC mode + GainControlModeChannel1 = 'slow_attack' + % GainChannel1 Gain Channel 1 % Channel 1 gain, specified as a scalar from -3 dB to 71 dB. The acceptable % minimum and maximum gain setting depends on the center % frequency. - GainChannel1 = 10; + GainChannel1 = 10 end - + properties (Nontunable) - %DigitalLoopbackMode Digital Loopback Mode + % DigitalLoopbackMode Digital Loopback Mode % Option to set digital loopback mode, specified as 0, - % 1 or 2. Allows either to digitally loopback TX data + % 1 or 2. Allows either to digitally loopback TX data % into the RX path or vice versa. % Value | Mode % --------------------------- % 0 | Disable % 1 | Digital TX -> Digital RX - % 2 | RF RX -> RF TX - LoopbackMode = 0; + % 2 | RF RX -> RF TX + LoopbackMode = 0 end - + properties (Nontunable, Logical) % MUST BE NONTUNABLE OR SIMULINK WARNS - %EnableQuadratureTracking Enable Quadrature Tracking + % EnableQuadratureTracking Enable Quadrature Tracking % Option to enable quadrature tracking, specified as true or % false. When this property is true, IQ imbalance compensation is % applied to the input signal. - EnableQuadratureTracking = true; - %EnableRFDCTracking Enable RFDC Tracking + EnableQuadratureTracking = true + % EnableRFDCTracking Enable RFDC Tracking % Option to enable RF DC tracking, specified as true or false. % When this property is true, an RF DC blocking filter is applied % to the input signal. - EnableRFDCTracking = true; - %EnableBasebandDCTracking Enable Baseband DC Tracking + EnableRFDCTracking = true + % EnableBasebandDCTracking Enable Baseband DC Tracking % Option to enable baseband DC tracking, specified as true or % false. When this property is true, a baseband DC blocking % filter is applied to the input signal. - EnableBasebandDCTracking = true; + EnableBasebandDCTracking = true end - + properties - %RFPortSelect RF Port Select + % RFPortSelect RF Port Select % 'A_BALANCED' % 'B_BALANCED' % 'C_BALANCED' @@ -98,185 +98,199 @@ % 'TX_MONITOR1' % 'TX_MONITOR2' % 'TX_MONITOR1_2' - RFPortSelect = 'A_BALANCED'; + RFPortSelect = 'A_BALANCED' end - - properties(Constant, Hidden) + + properties (Constant, Hidden) GainControlModeChannel0Set = matlab.system.StringSet({ ... - 'manual','fast_attack','slow_attack','hybrid'}); + 'manual', 'fast_attack', 'slow_attack', 'hybrid'}) GainControlModeChannel1Set = matlab.system.StringSet({ ... - 'manual','fast_attack','slow_attack','hybrid'}); + 'manual', 'fast_attack', 'slow_attack', 'hybrid'}) RFPortSelectSet = matlab.system.StringSet({ ... - 'A_BALANCED', 'B_BALANCED', 'C_BALANCED',... - 'A_N', 'A_P', 'B_N', 'B_P', 'C_N', 'C_P',... - 'TX_MONITOR1', 'TX_MONITOR2', 'TX_MONITOR1_2'}); + 'A_BALANCED', 'B_BALANCED', 'C_BALANCED', ... + 'A_N', 'A_P', 'B_N', 'B_P', 'C_N', 'C_P', ... + 'TX_MONITOR1', 'TX_MONITOR2', 'TX_MONITOR1_2'}) end - + properties (Hidden, Nontunable, Access = protected) - isOutput = false; + isOutput = false end - - properties(Nontunable, Hidden, Constant) - Type = 'Rx'; + + properties (Nontunable, Hidden, Constant) + Type = 'Rx' end - properties(Nontunable, Hidden) - channel_names = {'voltage0','voltage1','voltage2','voltage3'}; + properties (Nontunable, Hidden) + channel_names = {'voltage0', 'voltage1', 'voltage2', 'voltage3'} end - + properties (Nontunable, Hidden) - devName = 'cf-ad9361-lpc'; + devName = 'cf-ad9361-lpc' end - + methods + %% Constructor function obj = Rx(varargin) coder.allowpcode('plain'); obj = obj@adi.AD9361.Base(varargin{:}); end + % Check RFPortSelect function set.RFPortSelect(obj, value) obj.RFPortSelect = value; if obj.ConnectedToDevice - obj.setAttributeRAW('voltage0','rf_port_select',value,false); + obj.setAttributeRAW('voltage0', 'rf_port_select', value, false); end end + % Check GainControlModeChannel0 function set.GainControlModeChannel0(obj, value) obj.GainControlModeChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeRAW(id,'gain_control_mode',value,false); + obj.setAttributeRAW(id, 'gain_control_mode', value, false); end end + % Check GainControlModeChannel1 function set.GainControlModeChannel1(obj, value) obj.GainControlModeChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeRAW(id,'gain_control_mode',value,false); + obj.setAttributeRAW(id, 'gain_control_mode', value, false); end end + % Check GainChannel0 function set.GainChannel0(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', -3,'<=', 71}, ... - '', 'Gain'); - assert(mod(value,1)==0, 'Gain must be an integer'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', -3, '<=', 71}, ... + '', 'Gain'); + assert(mod(value, 1) == 0, 'Gain must be an integer'); obj.GainChannel0 = value; - if obj.ConnectedToDevice && strcmp(obj.GainControlModeChannel0,'manual') %#ok + if obj.ConnectedToDevice && strcmp(obj.GainControlModeChannel0, 'manual') %#ok id = 'voltage0'; - obj.setAttributeDouble(id,'hardwaregain',value,false); + obj.setAttributeDouble(id, 'hardwaregain', value, false); end end + % Check GainChannel1 function set.GainChannel1(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', -3,'<=', 71}, ... - '', 'Gain'); - assert(mod(value,1)==0, 'Gain must be an integer'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', -3, '<=', 71}, ... + '', 'Gain'); + assert(mod(value, 1) == 0, 'Gain must be an integer'); obj.GainChannel1 = value; - if obj.ConnectedToDevice && strcmp(obj.GainControlModeChannel1,'manual') %#ok + if obj.ConnectedToDevice && strcmp(obj.GainControlModeChannel1, 'manual') %#ok id = 'voltage1'; - obj.setAttributeDouble(id,'hardwaregain',value,false); + obj.setAttributeDouble(id, 'hardwaregain', value, false); end end + % Check EnableQuadratureTracking function set.EnableQuadratureTracking(obj, value) obj.EnableQuadratureTracking = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'quadrature_tracking_en',value,false); + obj.setAttributeBool(id, 'quadrature_tracking_en', value, false); end end + % Check EnableRFDCTracking function set.EnableRFDCTracking(obj, value) obj.EnableRFDCTracking = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'rf_dc_offset_tracking_en',value,false); + obj.setAttributeBool(id, 'rf_dc_offset_tracking_en', value, false); end end + % Check EnableRFDCTracking function set.EnableBasebandDCTracking(obj, value) obj.EnableBasebandDCTracking = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'bb_dc_offset_tracking_en',value,false); + obj.setAttributeBool(id, 'bb_dc_offset_tracking_en', value, false); end end + % Check CenterFrequency function set.CenterFrequency(obj, value) - if isa(obj,'adi.AD9363.Rx') - validateattributes( value, { 'double','single' }, ... - { 'real', 'positive','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',325e6,'<=',3.8e9}, ... - '', 'CenterFrequency'); + if isa(obj, 'adi.AD9363.Rx') + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'positive', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 325e6, '<=', 3.8e9}, ... + '', 'CenterFrequency'); else - validateattributes( value, { 'double','single' }, ... - { 'real', 'positive','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',70e6,'<=',6e9}, ... - '', 'CenterFrequency'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'positive', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 70e6, '<=', 6e9}, ... + '', 'CenterFrequency'); end obj.CenterFrequency = value; if obj.ConnectedToDevice - id = sprintf('altvoltage%d',strcmp(obj.Type,'Tx')); - obj.setAttributeLongLong(id,'frequency',value,true,4); + id = sprintf('altvoltage%d', strcmp(obj.Type, 'Tx')); + obj.setAttributeLongLong(id, 'frequency', value, true, 4); end end + % Check RFBandwidth function set.RFBandwidth(obj, value) - if isa(obj,'adi.AD9363.Rx') - validateattributes( value, { 'double','single' }, ... - { 'real', 'positive','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',200e3,'<=',20e6}, ... - '', 'RFBandwidth'); + if isa(obj, 'adi.AD9363.Rx') + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'positive', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 200e3, '<=', 20e6}, ... + '', 'RFBandwidth'); else - validateattributes( value, { 'double','single' }, ... - { 'real', 'positive','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',200e3,'<=',56e6}, ... - '', 'RFBandwidth'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'positive', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 200e3, '<=', 56e6}, ... + '', 'RFBandwidth'); end obj.RFBandwidth = value; if obj.ConnectedToDevice && ~obj.EnableCustomFilter id = 'voltage0'; - obj.setAttributeLongLong(id,'rf_bandwidth',value,strcmp(obj.Type,'Tx'),30); + obj.setAttributeLongLong(id, 'rf_bandwidth', value, strcmp(obj.Type, 'Tx'), 30); end end + % Check SampleRate function set.SamplingRate(obj, value) - if isa(obj,'adi.AD9363.Rx') - validateattributes( value, { 'double','single' }, ... - { 'real', 'positive','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',520833,'<=',20e6}, ... - '', 'SamplesPerFrame'); + if isa(obj, 'adi.AD9363.Rx') + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'positive', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 520833, '<=', 20e6}, ... + '', 'SamplesPerFrame'); else - validateattributes( value, { 'double','single' }, ... - { 'real', 'positive','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',520833,'<=',61.44e6}, ... - '', 'SamplesPerFrame'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'positive', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 520833, '<=', 61.44e6}, ... + '', 'SamplesPerFrame'); end - + obj.SamplingRate = value; if obj.ConnectedToDevice && ~obj.EnableCustomFilter id = 'voltage0'; p = 'sampling_frequency'; if libisloaded('libad9361') - calllib('libad9361','ad9361_set_bb_rate',obj.iioDevPHY,int32(value)); + calllib('libad9361', 'ad9361_set_bb_rate', obj.iioDevPHY, int32(value)); else - obj.setAttributeLongLong(id,p,value,true,4); + obj.setAttributeLongLong(id, p, value, true, 4); end - obj.SamplingRate = double(obj.getAttributeLongLong(id,p,true)); + obj.SamplingRate = double(obj.getAttributeLongLong(id, p, true)); end - end + end + function set.LoopbackMode(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',2}, ... - '', 'LoopbackMode'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 2}, ... + '', 'LoopbackMode'); obj.LoopbackMode = value; if obj.ConnectedToDevice - obj.setDebugAttributeLongLong('loopback',value); + obj.setDebugAttributeLongLong('loopback', value); end - end + end + end - + %% API Functions methods (Hidden, Access = protected) - + function setupInit(obj) % Write all attributes to device once connected through set % methods @@ -284,50 +298,49 @@ function setupInit(obj) % Do writes directly to hardware without using set methods. % This is required sine Simulink support doesn't support % modification to nontunable variables at SetupImpl - + % Gains - obj.setAttributeRAW('voltage0','gain_control_mode',obj.GainControlModeChannel0,false); - if obj.channelCount>2 - obj.setAttributeRAW('voltage1','gain_control_mode',obj.GainControlModeChannel1,false); + obj.setAttributeRAW('voltage0', 'gain_control_mode', obj.GainControlModeChannel0, false); + if obj.channelCount > 2 + obj.setAttributeRAW('voltage1', 'gain_control_mode', obj.GainControlModeChannel1, false); end - if strcmp(obj.GainControlModeChannel0,'manual') - obj.setAttributeDouble('voltage0','hardwaregain',obj.GainChannel0,false); + if strcmp(obj.GainControlModeChannel0, 'manual') + obj.setAttributeDouble('voltage0', 'hardwaregain', obj.GainChannel0, false); end - if strcmp(obj.GainControlModeChannel1,'manual') && (obj.channelCount>2) - obj.setAttributeDouble('voltage1','hardwaregain',obj.GainChannel1,false); + if strcmp(obj.GainControlModeChannel1, 'manual') && (obj.channelCount > 2) + obj.setAttributeDouble('voltage1', 'hardwaregain', obj.GainChannel1, false); end % Trackings - obj.setAttributeBool('voltage0','quadrature_tracking_en',obj.EnableQuadratureTracking,false); - obj.setAttributeBool('voltage0','rf_dc_offset_tracking_en',obj.EnableRFDCTracking,false); - obj.setAttributeBool('voltage0','bb_dc_offset_tracking_en',obj.EnableBasebandDCTracking,false); - id = sprintf('altvoltage%d',strcmp(obj.Type,'Tx')); - obj.setAttributeLongLong(id,'frequency',obj.CenterFrequency ,true,4); + obj.setAttributeBool('voltage0', 'quadrature_tracking_en', obj.EnableQuadratureTracking, false); + obj.setAttributeBool('voltage0', 'rf_dc_offset_tracking_en', obj.EnableRFDCTracking, false); + obj.setAttributeBool('voltage0', 'bb_dc_offset_tracking_en', obj.EnableBasebandDCTracking, false); + id = sprintf('altvoltage%d', strcmp(obj.Type, 'Tx')); + obj.setAttributeLongLong(id, 'frequency', obj.CenterFrequency, true, 4); % Loopback Mode - obj.setDebugAttributeLongLong('loopback', obj.LoopbackMode); - + obj.setDebugAttributeLongLong('loopback', obj.LoopbackMode); + % Sample rates and RF bandwidth if ~obj.EnableCustomFilter if libisloaded('libad9361') - calllib('libad9361','ad9361_set_bb_rate',obj.iioDevPHY,int32(obj.SamplingRate)); + calllib('libad9361', 'ad9361_set_bb_rate', obj.iioDevPHY, int32(obj.SamplingRate)); else - obj.setAttributeLongLong('voltage0','sampling_frequency',obj.SamplingRate,true,4); - obj.setAttributeLongLong('voltage0','rf_bandwidth',obj.RFBandwidth ,strcmp(obj.Type,'Tx')); + obj.setAttributeLongLong('voltage0', 'sampling_frequency', obj.SamplingRate, true, 4); + obj.setAttributeLongLong('voltage0', 'rf_bandwidth', obj.RFBandwidth, strcmp(obj.Type, 'Tx')); end else writeFilterFile(obj); end - obj.setAttributeRAW('voltage0','rf_port_select',obj.RFPortSelect,false); + obj.setAttributeRAW('voltage0', 'rf_port_select', obj.RFPortSelect, false); - if (obj.CustomAGC) + if obj.CustomAGC % Initialize hardware to reflect debug attribute changes obj.WriteDebugAttributes(); - obj.setDebugAttributeBool('initialize',1); + obj.setDebugAttributeBool('initialize', 1); obj.WriteToRegisters(); end - + end - + end - -end +end diff --git a/+adi/+AD9361/TuneAGC.m b/+adi/+AD9361/TuneAGC.m index 36b23bb8..ee7e0445 100644 --- a/+adi/+AD9361/TuneAGC.m +++ b/+adi/+AD9361/TuneAGC.m @@ -2,289 +2,310 @@ adi.common.RxTx & ... adi.common.RegisterReadWrite properties (Nontunable, Hidden) - CustomAGC = 0; - - AttackDelay = 1; - PeakOverloadWaitTime = 10; - AGCLockLevel = 10; - DecStepSizeFullTableCase3 = 3; - ADCLargeOverloadThresh = 58; - ADCSmallOverloadThresh = 47; - DecStepSizeFullTableCase2 = 3; - DecStepSizeFullTableCase1 = 3; - LargeLMTOverloadThresh = 35; - SmallLMTOverloadThresh = 25; - SettlingDelay = 3; - EnergyLostThresh = 3; - LowPowerThresh = 15; + CustomAGC = 0 + + AttackDelay = 1 + PeakOverloadWaitTime = 10 + AGCLockLevel = 10 + DecStepSizeFullTableCase3 = 3 + ADCLargeOverloadThresh = 58 + ADCSmallOverloadThresh = 47 + DecStepSizeFullTableCase2 = 3 + DecStepSizeFullTableCase1 = 3 + LargeLMTOverloadThresh = 35 + SmallLMTOverloadThresh = 25 + SettlingDelay = 3 + EnergyLostThresh = 3 + LowPowerThresh = 15 IncrementGainStep - FAGCLockLevelGainIncreaseUpperLimit = 7; - FAGCLPThreshIncrementTime = 3; - DecPowMeasurementDuration = 16; + FAGCLockLevelGainIncreaseUpperLimit = 7 + FAGCLPThreshIncrementTime = 3 + DecPowMeasurementDuration = 16 end - + properties (Constant, Hidden, Access = private) % Register addresses in hexadecimal - AttackDelay_Reg = '022'; - PeakOverloadWaitTime_Reg = '0FE'; - AGCLockLevel_Reg = '101'; - DecStepSizeFullTableCase3_Reg = '103'; - ADCSmallOverloadThresh_Reg = '104'; - ADCLargeOverloadThresh_Reg = '105'; - DecStepSizeFullTableCase2_Reg = '106'; - DecStepSizeFullTableCase1_Reg = '106'; - LargeLMTOverloadThresh_Reg = '108'; - SmallLMTOverloadThresh_Reg = '107'; - SettlingDelay_Reg = '111'; - EnergyLostThresh_Reg = '112'; - LowPowerThresh_Reg = '114'; - IncrementGainStep_Reg = '117'; - FAGCLockLevelGainIncreaseUpperLimit_Reg = '118'; - FAGCLPThreshIncrementTime_Reg = '11B'; - DecPowMeasurementDuration_Reg = '15C'; - + AttackDelay_Reg = '022' + PeakOverloadWaitTime_Reg = '0FE' + AGCLockLevel_Reg = '101' + DecStepSizeFullTableCase3_Reg = '103' + ADCSmallOverloadThresh_Reg = '104' + ADCLargeOverloadThresh_Reg = '105' + DecStepSizeFullTableCase2_Reg = '106' + DecStepSizeFullTableCase1_Reg = '106' + LargeLMTOverloadThresh_Reg = '108' + SmallLMTOverloadThresh_Reg = '107' + SettlingDelay_Reg = '111' + EnergyLostThresh_Reg = '112' + LowPowerThresh_Reg = '114' + IncrementGainStep_Reg = '117' + FAGCLockLevelGainIncreaseUpperLimit_Reg = '118' + FAGCLPThreshIncrementTime_Reg = '11B' + DecPowMeasurementDuration_Reg = '15C' + % Register mask in binary - AttackDelay_Mask = '11000000'; - PeakOverloadWaitTime_Mask = '11100000'; - AGCLockLevel_Mask = '10000000'; - DecStepSizeFullTableCase3_Mask = '11100011'; - DecStepSizeFullTableCase2_Mask = '10001111'; - DecStepSizeFullTableCase1_Mask = '11110000'; - LargeLMTOverloadThresh_Mask = '11000000'; - SmallLMTOverloadThresh_Mask = '11000000'; - SettlingDelay_Mask = '11100000'; - EnergyLostThresh_Mask = '11000000'; - LowPowerThresh_Mask = '10000000'; - IncrementGainStep_Mask = '00011111'; - FAGCLockLevelGainIncreaseUpperLimit_Mask = '11000000'; - DecPowMeasurementDuration_Mask = '11110000'; - + AttackDelay_Mask = '11000000' + PeakOverloadWaitTime_Mask = '11100000' + AGCLockLevel_Mask = '10000000' + DecStepSizeFullTableCase3_Mask = '11100011' + DecStepSizeFullTableCase2_Mask = '10001111' + DecStepSizeFullTableCase1_Mask = '11110000' + LargeLMTOverloadThresh_Mask = '11000000' + SmallLMTOverloadThresh_Mask = '11000000' + SettlingDelay_Mask = '11100000' + EnergyLostThresh_Mask = '11000000' + LowPowerThresh_Mask = '10000000' + IncrementGainStep_Mask = '00011111' + FAGCLockLevelGainIncreaseUpperLimit_Mask = '11000000' + DecPowMeasurementDuration_Mask = '11110000' + % Bit-shifts to be applied - DecStepSizeFullTableCase3_BitShift = 2; - DecStepSizeFullTableCase2_BitShift = 4; - IncrementGainStep_BitShift = 5; + DecStepSizeFullTableCase3_BitShift = 2 + DecStepSizeFullTableCase2_BitShift = 4 + IncrementGainStep_BitShift = 5 end - + methods + function set.AttackDelay(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',63}, ... - '', 'AttackDelay'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 63}, ... + '', 'AttackDelay'); obj.AttackDelay = value; if obj.ConnectedToDevice - obj.setRegisterExtended(value, obj.AttackDelay_Reg, obj.AttackDelay_Mask); + obj.setRegisterExtended(value, obj.AttackDelay_Reg, obj.AttackDelay_Mask); end end + function set.PeakOverloadWaitTime(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',31}, ... - '', 'PeakOverloadWaitTime'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 31}, ... + '', 'PeakOverloadWaitTime'); obj.PeakOverloadWaitTime = value; if obj.ConnectedToDevice - obj.setRegisterExtended(value, obj.PeakOverloadWaitTime_Reg, obj.PeakOverloadWaitTime_Mask); + obj.setRegisterExtended(value, obj.PeakOverloadWaitTime_Reg, obj.PeakOverloadWaitTime_Mask); end end + function set.AGCLockLevel(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',127}, ... - '', 'AGCLockLevel'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 127}, ... + '', 'AGCLockLevel'); obj.AGCLockLevel = value; if obj.ConnectedToDevice - obj.setRegisterExtended(value, obj.AGCLockLevel_Reg, obj.AGCLockLevel_Mask); + obj.setRegisterExtended(value, obj.AGCLockLevel_Reg, obj.AGCLockLevel_Mask); end - end + end + function set.DecStepSizeFullTableCase3(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',7}, ... - '', 'DecStepSizeFullTableCase3'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 7}, ... + '', 'DecStepSizeFullTableCase3'); obj.DecStepSizeFullTableCase3 = value; if obj.ConnectedToDevice - obj.setRegisterExtended(value, obj.DecStepSizeFullTableCase3_Reg, obj.DecStepSizeFullTableCase3_Mask, obj.DecStepSizeFullTableCase3_BitShift); + obj.setRegisterExtended(value, obj.DecStepSizeFullTableCase3_Reg, obj.DecStepSizeFullTableCase3_Mask, obj.DecStepSizeFullTableCase3_BitShift); end end + function set.ADCLargeOverloadThresh(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',255}, ... - '', 'ADCLargeOverloadThresh'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 255}, ... + '', 'ADCLargeOverloadThresh'); obj.ADCLargeOverloadThresh = value; if obj.ConnectedToDevice - obj.setDebugAttributeLongLong('adi,gc-adc-large-overload-thresh',value); + obj.setDebugAttributeLongLong('adi,gc-adc-large-overload-thresh', value); end - end + end + function set.ADCSmallOverloadThresh(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',obj.ADCLargeOverloadThresh}, ... - '', 'ADCSmallOverloadThresh'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', obj.ADCLargeOverloadThresh}, ... + '', 'ADCSmallOverloadThresh'); obj.ADCSmallOverloadThresh = value; if obj.ConnectedToDevice - obj.setDebugAttributeLongLong('adi,gc-adc-small-overload-thresh',value); + obj.setDebugAttributeLongLong('adi,gc-adc-small-overload-thresh', value); end end + function set.DecStepSizeFullTableCase2(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',7}, ... - '', 'DecStepSizeFullTableCase2'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 7}, ... + '', 'DecStepSizeFullTableCase2'); obj.DecStepSizeFullTableCase2 = value; if obj.ConnectedToDevice - obj.setRegisterExtended(value, obj.DecStepSizeFullTableCase2_Reg, obj.DecStepSizeFullTableCase2_Mask, obj.DecStepSizeFullTableCase2_BitShift); + obj.setRegisterExtended(value, obj.DecStepSizeFullTableCase2_Reg, obj.DecStepSizeFullTableCase2_Mask, obj.DecStepSizeFullTableCase2_BitShift); end - end + end + function set.DecStepSizeFullTableCase1(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',15}, ... - '', 'DecStepSizeFullTableCase1'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 15}, ... + '', 'DecStepSizeFullTableCase1'); obj.DecStepSizeFullTableCase1 = value; if obj.ConnectedToDevice - obj.setRegisterExtended(value, obj.DecStepSizeFullTableCase1_Reg, obj.DecStepSizeFullTableCase1_Mask); + obj.setRegisterExtended(value, obj.DecStepSizeFullTableCase1_Reg, obj.DecStepSizeFullTableCase1_Mask); end - end + end + function set.LargeLMTOverloadThresh(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',63}, ... - '', 'LargeLMTOverloadThresh'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 63}, ... + '', 'LargeLMTOverloadThresh'); obj.LargeLMTOverloadThresh = value; if obj.ConnectedToDevice - obj.setRegisterExtended(value, obj.LargeLMTOverloadThresh_Reg, obj.LargeLMTOverloadThresh_Mask); + obj.setRegisterExtended(value, obj.LargeLMTOverloadThresh_Reg, obj.LargeLMTOverloadThresh_Mask); end - end + end + function set.SmallLMTOverloadThresh(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',obj.LargeLMTOverloadThresh}, ... - '', 'SmallLMTOverloadThresh'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', obj.LargeLMTOverloadThresh}, ... + '', 'SmallLMTOverloadThresh'); obj.SmallLMTOverloadThresh = value; if obj.ConnectedToDevice - obj.setRegisterExtended(value, obj.SmallLMTOverloadThresh_Reg, obj.SmallLMTOverloadThresh_Mask); + obj.setRegisterExtended(value, obj.SmallLMTOverloadThresh_Reg, obj.SmallLMTOverloadThresh_Mask); end - end + end + function set.SettlingDelay(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',31}, ... - '', 'SettlingDelay'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 31}, ... + '', 'SettlingDelay'); obj.SettlingDelay = value; if obj.ConnectedToDevice - obj.setRegisterExtended(value, obj.SettlingDelay_Reg, obj.SettlingDelay_Mask); + obj.setRegisterExtended(value, obj.SettlingDelay_Reg, obj.SettlingDelay_Mask); end - end + end + function set.EnergyLostThresh(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',63}, ... - '', 'SettlingDelay'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 63}, ... + '', 'SettlingDelay'); obj.EnergyLostThresh = value; if obj.ConnectedToDevice - obj.setRegisterExtended(value, obj.EnergyLostThresh_Reg, obj.EnergyLostThresh_Mask); + obj.setRegisterExtended(value, obj.EnergyLostThresh_Reg, obj.EnergyLostThresh_Mask); end - end + end + function set.LowPowerThresh(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',63}, ... - '', 'LowPowerThresh'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 63}, ... + '', 'LowPowerThresh'); obj.LowPowerThresh = value; if obj.ConnectedToDevice - obj.setDebugAttributeLongLong('adi,gc-low-power-thresh',value); + obj.setDebugAttributeLongLong('adi,gc-low-power-thresh', value); end - end + end + function set.IncrementGainStep(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',7}, ... - '', 'IncrementGainStep'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 7}, ... + '', 'IncrementGainStep'); obj.IncrementGainStep = value; if obj.ConnectedToDevice - obj.setRegisterExtended(value, obj.IncrementGainStep_Reg, obj.IncrementGainStep_Mask, obj.IncrementGainStep_BitShift); + obj.setRegisterExtended(value, obj.IncrementGainStep_Reg, obj.IncrementGainStep_Mask, obj.IncrementGainStep_BitShift); end - end + end + function set.FAGCLockLevelGainIncreaseUpperLimit(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',63}, ... - '', 'FAGCLockLevelGainIncreaseUpperLimit'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 63}, ... + '', 'FAGCLockLevelGainIncreaseUpperLimit'); obj.FAGCLockLevelGainIncreaseUpperLimit = value; if obj.ConnectedToDevice - obj.setDebugAttributeLongLong('adi,fagc-lock-level-gain-increase-upper-limit',value); + obj.setDebugAttributeLongLong('adi,fagc-lock-level-gain-increase-upper-limit', value); end - end + end + function set.FAGCLPThreshIncrementTime(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',255}, ... - '', 'FAGCLPThreshIncrementTime'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 255}, ... + '', 'FAGCLPThreshIncrementTime'); obj.FAGCLPThreshIncrementTime = value; if obj.ConnectedToDevice - obj.setDebugAttributeLongLong('adi,fagc-lp-thresh-increment-time',value); + obj.setDebugAttributeLongLong('adi,fagc-lp-thresh-increment-time', value); end - end + end + function set.DecPowMeasurementDuration(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',15}, ... - '', 'DecPowMeasurementDuration'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 15}, ... + '', 'DecPowMeasurementDuration'); obj.DecPowMeasurementDuration = value; if obj.ConnectedToDevice - obj.setRegisterExtended(value, obj.DecPowMeasurementDuration_Reg, obj.DecPowMeasurementDuration_Mask); + obj.setRegisterExtended(value, obj.DecPowMeasurementDuration_Reg, obj.DecPowMeasurementDuration_Mask); end - end + end + function WriteDebugAttributes(obj) if obj.ConnectedToDevice - obj.setDebugAttributeLongLong('adi,gc-adc-large-overload-thresh',obj.ADCLargeOverloadThresh); - obj.setDebugAttributeLongLong('adi,gc-adc-small-overload-thresh',obj.ADCSmallOverloadThresh); - obj.setDebugAttributeLongLong('adi,gc-low-power-thresh',obj.LowPowerThresh); - obj.setDebugAttributeLongLong('adi,fagc-lock-level-gain-increase-upper-limit',obj.FAGCLockLevelGainIncreaseUpperLimit); - obj.setDebugAttributeLongLong('adi,fagc-lp-thresh-increment-time',obj.FAGCLPThreshIncrementTime); + obj.setDebugAttributeLongLong('adi,gc-adc-large-overload-thresh', obj.ADCLargeOverloadThresh); + obj.setDebugAttributeLongLong('adi,gc-adc-small-overload-thresh', obj.ADCSmallOverloadThresh); + obj.setDebugAttributeLongLong('adi,gc-low-power-thresh', obj.LowPowerThresh); + obj.setDebugAttributeLongLong('adi,fagc-lock-level-gain-increase-upper-limit', obj.FAGCLockLevelGainIncreaseUpperLimit); + obj.setDebugAttributeLongLong('adi,fagc-lp-thresh-increment-time', obj.FAGCLPThreshIncrementTime); end end + function WriteToRegisters(obj) if obj.ConnectedToDevice - obj.setRegisterExtended(obj.AttackDelay, obj.AttackDelay_Reg, obj.AttackDelay_Mask); - obj.setRegisterExtended(obj.PeakOverloadWaitTime, obj.PeakOverloadWaitTime_Reg, obj.PeakOverloadWaitTime_Mask); - obj.setRegisterExtended(obj.AGCLockLevel, obj.AGCLockLevel_Reg, obj.AGCLockLevel_Mask); - obj.setRegisterExtended(obj.DecStepSizeFullTableCase3, obj.DecStepSizeFullTableCase3_Reg, obj.DecStepSizeFullTableCase3_Mask, obj.DecStepSizeFullTableCase3_BitShift); - obj.setRegisterExtended(obj.DecStepSizeFullTableCase2, obj.DecStepSizeFullTableCase2_Reg, obj.DecStepSizeFullTableCase2_Mask, obj.DecStepSizeFullTableCase2_BitShift); - obj.setRegisterExtended(obj.DecStepSizeFullTableCase1, obj.DecStepSizeFullTableCase1_Reg, obj.DecStepSizeFullTableCase1_Mask); - obj.setRegisterExtended(obj.LargeLMTOverloadThresh, obj.LargeLMTOverloadThresh_Reg, obj.LargeLMTOverloadThresh_Mask); - obj.setRegisterExtended(obj.SmallLMTOverloadThresh, obj.SmallLMTOverloadThresh_Reg, obj.SmallLMTOverloadThresh_Mask); - obj.setRegisterExtended(obj.SettlingDelay, obj.SettlingDelay_Reg, obj.SettlingDelay_Mask); - obj.setRegisterExtended(obj.EnergyLostThresh, obj.EnergyLostThresh_Reg, obj.EnergyLostThresh_Mask); - obj.setRegisterExtended(obj.IncrementGainStep, obj.IncrementGainStep_Reg, obj.IncrementGainStep_Mask, obj.IncrementGainStep_BitShift); - obj.setRegisterExtended(obj.DecPowMeasurementDuration, obj.DecPowMeasurementDuration_Reg, obj.DecPowMeasurementDuration_Mask); + obj.setRegisterExtended(obj.AttackDelay, obj.AttackDelay_Reg, obj.AttackDelay_Mask); + obj.setRegisterExtended(obj.PeakOverloadWaitTime, obj.PeakOverloadWaitTime_Reg, obj.PeakOverloadWaitTime_Mask); + obj.setRegisterExtended(obj.AGCLockLevel, obj.AGCLockLevel_Reg, obj.AGCLockLevel_Mask); + obj.setRegisterExtended(obj.DecStepSizeFullTableCase3, obj.DecStepSizeFullTableCase3_Reg, obj.DecStepSizeFullTableCase3_Mask, obj.DecStepSizeFullTableCase3_BitShift); + obj.setRegisterExtended(obj.DecStepSizeFullTableCase2, obj.DecStepSizeFullTableCase2_Reg, obj.DecStepSizeFullTableCase2_Mask, obj.DecStepSizeFullTableCase2_BitShift); + obj.setRegisterExtended(obj.DecStepSizeFullTableCase1, obj.DecStepSizeFullTableCase1_Reg, obj.DecStepSizeFullTableCase1_Mask); + obj.setRegisterExtended(obj.LargeLMTOverloadThresh, obj.LargeLMTOverloadThresh_Reg, obj.LargeLMTOverloadThresh_Mask); + obj.setRegisterExtended(obj.SmallLMTOverloadThresh, obj.SmallLMTOverloadThresh_Reg, obj.SmallLMTOverloadThresh_Mask); + obj.setRegisterExtended(obj.SettlingDelay, obj.SettlingDelay_Reg, obj.SettlingDelay_Mask); + obj.setRegisterExtended(obj.EnergyLostThresh, obj.EnergyLostThresh_Reg, obj.EnergyLostThresh_Mask); + obj.setRegisterExtended(obj.IncrementGainStep, obj.IncrementGainStep_Reg, obj.IncrementGainStep_Mask, obj.IncrementGainStep_BitShift); + obj.setRegisterExtended(obj.DecPowMeasurementDuration, obj.DecPowMeasurementDuration_Reg, obj.DecPowMeasurementDuration_Mask); end end + function value = ReadFromRegister(obj, prop_name) if obj.ConnectedToDevice switch prop_name case 'AttackDelay' - value = obj.getRegisterExtended(obj.AttackDelay_Reg, obj.AttackDelay_Mask); + value = obj.getRegisterExtended(obj.AttackDelay_Reg, obj.AttackDelay_Mask); case 'PeakOverloadWaitTime' - value = obj.getRegisterExtended(obj.PeakOverloadWaitTime_Reg, obj.PeakOverloadWaitTime_Mask); + value = obj.getRegisterExtended(obj.PeakOverloadWaitTime_Reg, obj.PeakOverloadWaitTime_Mask); case 'AGCLockLevel' - value = obj.getRegisterExtended(obj.AGCLockLevel_Reg, obj.AGCLockLevel_Mask); + value = obj.getRegisterExtended(obj.AGCLockLevel_Reg, obj.AGCLockLevel_Mask); case 'DecStepSizeFullTableCase3' - value = obj.getRegisterExtended(obj.DecStepSizeFullTableCase3_Reg, obj.DecStepSizeFullTableCase3_Mask, obj.DecStepSizeFullTableCase3_BitShift); + value = obj.getRegisterExtended(obj.DecStepSizeFullTableCase3_Reg, obj.DecStepSizeFullTableCase3_Mask, obj.DecStepSizeFullTableCase3_BitShift); case 'ADCSmallOverloadThresh' - value = obj.getRegisterExtended(obj.ADCSmallOverloadThresh_Reg); + value = obj.getRegisterExtended(obj.ADCSmallOverloadThresh_Reg); case 'ADCLargeOverloadThresh' - value = obj.getRegisterExtended(obj.ADCLargeOverloadThresh_Reg); + value = obj.getRegisterExtended(obj.ADCLargeOverloadThresh_Reg); case 'DecStepSizeFullTableCase2' - value = obj.getRegisterExtended(obj.DecStepSizeFullTableCase2_Reg, obj.DecStepSizeFullTableCase2_Mask, obj.DecStepSizeFullTableCase2_BitShift); + value = obj.getRegisterExtended(obj.DecStepSizeFullTableCase2_Reg, obj.DecStepSizeFullTableCase2_Mask, obj.DecStepSizeFullTableCase2_BitShift); case 'DecStepSizeFullTableCase1' - value = obj.getRegisterExtended(obj.DecStepSizeFullTableCase1_Reg, obj.DecStepSizeFullTableCase1_Mask); + value = obj.getRegisterExtended(obj.DecStepSizeFullTableCase1_Reg, obj.DecStepSizeFullTableCase1_Mask); case 'LargeLMTOverloadThresh' - value = obj.getRegisterExtended(obj.LargeLMTOverloadThresh_Reg, obj.LargeLMTOverloadThresh_Mask); + value = obj.getRegisterExtended(obj.LargeLMTOverloadThresh_Reg, obj.LargeLMTOverloadThresh_Mask); case 'SmallLMTOverloadThresh' - value = obj.getRegisterExtended(obj.SmallLMTOverloadThresh_Reg, obj.SmallLMTOverloadThresh_Mask); + value = obj.getRegisterExtended(obj.SmallLMTOverloadThresh_Reg, obj.SmallLMTOverloadThresh_Mask); case 'SettlingDelay' - value = obj.getRegisterExtended(obj.SettlingDelay_Reg, obj.SettlingDelay_Mask); + value = obj.getRegisterExtended(obj.SettlingDelay_Reg, obj.SettlingDelay_Mask); case 'EnergyLostThresh' - value = obj.getRegisterExtended(obj.EnergyLostThresh_Reg, obj.EnergyLostThresh_Mask); + value = obj.getRegisterExtended(obj.EnergyLostThresh_Reg, obj.EnergyLostThresh_Mask); case 'LowPowerThresh' - value = obj.getRegisterExtended(obj.LowPowerThresh_Reg, obj.LowPowerThresh_Mask); + value = obj.getRegisterExtended(obj.LowPowerThresh_Reg, obj.LowPowerThresh_Mask); case 'IncrementGainStep' - value = obj.getRegisterExtended(obj.IncrementGainStep_Reg, obj.IncrementGainStep_Mask, obj.IncrementGainStep_BitShift); + value = obj.getRegisterExtended(obj.IncrementGainStep_Reg, obj.IncrementGainStep_Mask, obj.IncrementGainStep_BitShift); case 'FAGCLockLevelGainIncreaseUpperLimit' - value = obj.getRegisterExtended(obj.FAGCLockLevelGainIncreaseUpperLimit_Reg, obj.FAGCLockLevelGainIncreaseUpperLimit_Mask); + value = obj.getRegisterExtended(obj.FAGCLockLevelGainIncreaseUpperLimit_Reg, obj.FAGCLockLevelGainIncreaseUpperLimit_Mask); case 'FAGCLPThreshIncrementTime' - value = obj.getRegisterExtended(obj.FAGCLPThreshIncrementTime_Reg); + value = obj.getRegisterExtended(obj.FAGCLPThreshIncrementTime_Reg); case 'DecPowMeasurementDuration' - value = obj.getRegisterExtended(obj.DecPowMeasurementDuration_Reg, obj.DecPowMeasurementDuration_Mask); + value = obj.getRegisterExtended(obj.DecPowMeasurementDuration_Reg, obj.DecPowMeasurementDuration_Mask); otherwise error('Attempted to read unknown property %s\n', prop_name); end - end - end + end + end + end -end \ No newline at end of file +end diff --git a/+adi/+AD9361/Tx.m b/+adi/+AD9361/Tx.m index 1fb518f4..bb54aed6 100644 --- a/+adi/+AD9361/Tx.m +++ b/+adi/+AD9361/Tx.m @@ -9,161 +9,169 @@ % AD9361 Datasheet % % See also adi.FMComms2.Tx, adi.FMComms3.Tx, adi.FMComms5.Tx - + properties - %CenterFrequency Center Frequency + % CenterFrequency Center Frequency % RF center frequency, specified in Hz as a scalar. The % default is 2.4e9. This property is tunable. - CenterFrequency = 2.4e9; - %SamplingRate Sampling Rate - % Baseband sampling rate in Hz, specified as a scalar + CenterFrequency = 2.4e9 + % SamplingRate Sampling Rate + % Baseband sampling rate in Hz, specified as a scalar % from 65105 to 61.44e6 samples per second. - SamplingRate = 3e6; - %RFBandwidth RF Bandwidth + SamplingRate = 3e6 + % RFBandwidth RF Bandwidth % RF Bandwidth of front-end analog filter in Hz, specified as a % scalar from 200 kHz to 56 MHz. - RFBandwidth = 3e6; + RFBandwidth = 3e6 end - + properties - %AttenuationChannel0 Attenuation Channel 0 + % AttenuationChannel0 Attenuation Channel 0 % Attenuation specified as a scalar from -89.75 to 0 dB with a % resolution of 0.25 dB. - AttenuationChannel0 = -30; - %AttenuationChannel1 Attenuation Channel 1 + AttenuationChannel0 = -30 + % AttenuationChannel1 Attenuation Channel 1 % Attenuation specified as a scalar from -89.75 to 0 dB with a % resolution of 0.25 dB. - AttenuationChannel1 = -30; + AttenuationChannel1 = -30 end - + properties (Hidden, Nontunable, Access = protected) - isOutput = true; + isOutput = true end - - properties(Nontunable, Hidden, Constant) - Type = 'Tx'; + + properties (Nontunable, Hidden, Constant) + Type = 'Tx' end - - properties(Nontunable, Hidden) - channel_names = {'voltage0','voltage1','voltage2','voltage3'}; + + properties (Nontunable, Hidden) + channel_names = {'voltage0', 'voltage1', 'voltage2', 'voltage3'} end - + properties (Nontunable, Hidden) - devName = 'cf-ad9361-dds-core-lpc'; + devName = 'cf-ad9361-dds-core-lpc' end - + properties - %RFPortSelect RF Port Select + % RFPortSelect RF Port Select % 'A' % 'B' - RFPortSelect = 'A'; + RFPortSelect = 'A' + end + + properties (Constant, Hidden) + RFPortSelectSet = matlab.system.StringSet({'A', 'B'}) end - - properties(Constant, Hidden) - RFPortSelectSet = matlab.system.StringSet({'A', 'B'}); - end - + methods + %% Constructor function obj = Tx(varargin) coder.allowpcode('plain'); obj = obj@adi.AD9361.Base(varargin{:}); end + % Check RFPortSelect function set.RFPortSelect(obj, value) obj.RFPortSelect = value; if obj.ConnectedToDevice - obj.setAttributeRAW('voltage0','rf_port_select',value,false); + obj.setAttributeRAW('voltage0', 'rf_port_select', value, false); end end + % Check Attenuation function set.AttenuationChannel0(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', -89.75,'<=', 0}, ... - '', 'Attenuation'); - assert(mod(value,1/4)==0, 'Attenuation must be a multiple of 0.25'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', -89.75, '<=', 0}, ... + '', 'Attenuation'); + assert(mod(value, 1 / 4) == 0, 'Attenuation must be a multiple of 0.25'); obj.AttenuationChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeDouble(id,'hardwaregain',value,true); + obj.setAttributeDouble(id, 'hardwaregain', value, true); end end + % Check Attenuation function set.AttenuationChannel1(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', -89.75,'<=', 0}, ... - '', 'Attenuation'); - assert(mod(value,1/4)==0, 'Attenuation must be a multiple of 0.25'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', -89.75, '<=', 0}, ... + '', 'Attenuation'); + assert(mod(value, 1 / 4) == 0, 'Attenuation must be a multiple of 0.25'); obj.AttenuationChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeDouble(id,'hardwaregain',value,true); + obj.setAttributeDouble(id, 'hardwaregain', value, true); end end + % Check CenterFrequency function set.CenterFrequency(obj, value) - if isa(obj,'adi.AD9363.Tx') - validateattributes( value, { 'double','single' }, ... - { 'real', 'positive','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',325e6,'<=',3.8e9}, ... - '', 'CenterFrequency'); + if isa(obj, 'adi.AD9363.Tx') + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'positive', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 325e6, '<=', 3.8e9}, ... + '', 'CenterFrequency'); else - validateattributes( value, { 'double','single' }, ... - { 'real', 'positive','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',47e6,'<=',6e9}, ... - '', 'CenterFrequency'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'positive', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 47e6, '<=', 6e9}, ... + '', 'CenterFrequency'); end obj.CenterFrequency = value; if obj.ConnectedToDevice - id = sprintf('altvoltage%d',strcmp(obj.Type,'Tx')); - obj.setAttributeLongLong(id,'frequency',value,true,8); + id = sprintf('altvoltage%d', strcmp(obj.Type, 'Tx')); + obj.setAttributeLongLong(id, 'frequency', value, true, 8); end end + % Check RFBandwidth function set.RFBandwidth(obj, value) - if isa(obj,'adi.AD9363.Tx') - validateattributes( value, { 'double','single' }, ... - { 'real', 'positive','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',200e3,'<=',20e6}, ... - '', 'RFBandwidth'); + if isa(obj, 'adi.AD9363.Tx') + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'positive', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 200e3, '<=', 20e6}, ... + '', 'RFBandwidth'); else - validateattributes( value, { 'double','single' }, ... - { 'real', 'positive','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',200e3,'<=',56e6}, ... - '', 'RFBandwidth'); - + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'positive', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 200e3, '<=', 56e6}, ... + '', 'RFBandwidth'); + end obj.RFBandwidth = value; if obj.ConnectedToDevice && ~obj.EnableCustomFilter id = 'voltage0'; - obj.setAttributeLongLong(id,'rf_bandwidth',value,strcmp(obj.Type,'Tx'),30); + obj.setAttributeLongLong(id, 'rf_bandwidth', value, strcmp(obj.Type, 'Tx'), 30); end end + % Check SampleRate function set.SamplingRate(obj, value) - if isa(obj,'adi.AD9363.Tx') - validateattributes( value, { 'double','single' }, ... - { 'real', 'positive','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',520833,'<=',20e6}, ... - '', 'SamplingRate'); + if isa(obj, 'adi.AD9363.Tx') + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'positive', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 520833, '<=', 20e6}, ... + '', 'SamplingRate'); else - validateattributes( value, { 'double','single' }, ... - { 'real', 'positive','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',520833,'<=',61.44e6}, ... - '', 'SamplingRate'); - + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'positive', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 520833, '<=', 61.44e6}, ... + '', 'SamplingRate'); + end obj.SamplingRate = value; if obj.ConnectedToDevice && ~obj.EnableCustomFilter id = 'voltage0'; p = 'sampling_frequency'; if libisloaded('libad9361') - calllib('libad9361','ad9361_set_bb_rate',obj.iioDevPHY,int32(value)); + calllib('libad9361', 'ad9361_set_bb_rate', obj.iioDevPHY, int32(value)); else - obj.setAttributeLongLong(id,p,value,true,4); + obj.setAttributeLongLong(id, p, value, true, 4); end - obj.SamplingRate = double(obj.getAttributeLongLong(id,p,true)); + obj.SamplingRate = double(obj.getAttributeLongLong(id, p, true)); end end + end - + %% API Functions methods (Hidden, Access = protected) - + function setupInit(obj) % Write all attributes to device once connected through set % methods @@ -172,30 +180,29 @@ function setupInit(obj) % This is required sine Simulink support doesn't support % modification to nontunable variables at SetupImpl id = 'altvoltage1'; - obj.setAttributeLongLong(id,'frequency',obj.CenterFrequency ,true,8); + obj.setAttributeLongLong(id, 'frequency', obj.CenterFrequency, true, 8); if ~obj.EnableCustomFilter if libisloaded('libad9361') - calllib('libad9361','ad9361_set_bb_rate',obj.iioDevPHY,int32(obj.SamplingRate)); + calllib('libad9361', 'ad9361_set_bb_rate', obj.iioDevPHY, int32(obj.SamplingRate)); else - obj.setAttributeLongLong('voltage0','sampling_frequency',obj.SamplingRate,true,4); - obj.setAttributeLongLong('voltage0','rf_bandwidth',obj.RFBandwidth ,strcmp(obj.Type,'Tx')); + obj.setAttributeLongLong('voltage0', 'sampling_frequency', obj.SamplingRate, true, 4); + obj.setAttributeLongLong('voltage0', 'rf_bandwidth', obj.RFBandwidth, strcmp(obj.Type, 'Tx')); end else writeFilterFile(obj); end - - obj.setAttributeDouble('voltage0','hardwaregain',obj.AttenuationChannel0,true); - if obj.channelCount>2 - obj.setAttributeDouble('voltage1','hardwaregain',obj.AttenuationChannel1,true); + + obj.setAttributeDouble('voltage0', 'hardwaregain', obj.AttenuationChannel0, true); + if obj.channelCount > 2 + obj.setAttributeDouble('voltage1', 'hardwaregain', obj.AttenuationChannel1, true); end - obj.ToggleDDS(strcmp(obj.DataSource,'DDS')); - if strcmp(obj.DataSource,'DDS') + obj.ToggleDDS(strcmp(obj.DataSource, 'DDS')); + if strcmp(obj.DataSource, 'DDS') obj.DDSUpdate(); end - obj.setAttributeRAW('voltage0','rf_port_select',obj.RFPortSelect,true); + obj.setAttributeRAW('voltage0', 'rf_port_select', obj.RFPortSelect, true); end - + end - -end +end diff --git a/+adi/+AD9363/Rx.m b/+adi/+AD9363/Rx.m index 4ef14d7a..9ceac7d1 100644 --- a/+adi/+AD9363/Rx.m +++ b/+adi/+AD9363/Rx.m @@ -9,15 +9,16 @@ % AD9363 Datasheet % % See also adi.Pluto.Rx - + methods + %% Constructor function obj = Rx(varargin) % Returns the matlabshared.libiio.base object coder.allowpcode('plain'); obj = obj@adi.AD9361.Rx(varargin{:}); end + end - -end +end diff --git a/+adi/+AD9363/Tx.m b/+adi/+AD9363/Tx.m index c4f38083..9597c135 100644 --- a/+adi/+AD9363/Tx.m +++ b/+adi/+AD9363/Tx.m @@ -9,15 +9,16 @@ % AD9363 Datasheet % % See also adi.Pluto.Tx - + methods + %% Constructor function obj = Tx(varargin) % Returns the matlabshared.libiio.base object coder.allowpcode('plain'); obj = obj@adi.AD9361.Tx(varargin{:}); end + end - -end +end diff --git a/+adi/+AD9364/Rx.m b/+adi/+AD9364/Rx.m index 1e8c6019..9582f0bd 100644 --- a/+adi/+AD9364/Rx.m +++ b/+adi/+AD9364/Rx.m @@ -9,15 +9,16 @@ % AD9364 Datasheet % % See also adi.FMComms4.Rx - + methods + %% Constructor function obj = Rx(varargin) % Returns the matlabshared.libiio.base object coder.allowpcode('plain'); obj = obj@adi.AD9361.Rx(varargin{:}); end + end - -end +end diff --git a/+adi/+AD9364/Tx.m b/+adi/+AD9364/Tx.m index c1dfb903..d0e6ed45 100644 --- a/+adi/+AD9364/Tx.m +++ b/+adi/+AD9364/Tx.m @@ -11,13 +11,14 @@ % See also adi.FMComms4.Tx methods + %% Constructor function obj = Tx(varargin) % Returns the matlabshared.libiio.base object coder.allowpcode('plain'); obj = obj@adi.AD9361.Tx(varargin{:}); end + end - -end +end diff --git a/+adi/+AD9371/Base.m b/+adi/+AD9371/Base.m index a061e4cb..418d3d3c 100644 --- a/+adi/+AD9371/Base.m +++ b/+adi/+AD9371/Base.m @@ -3,190 +3,194 @@ adi.common.Attribute & ... adi.common.DebugAttribute & ... matlabshared.libiio.base - %adi.AD9371.Base Class + % adi.AD9371.Base Class % This class contains shared parameters and methods between TX and RX % classes properties (Nontunable) - %SamplesPerFrame Samples Per Frame + % 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; + SamplesPerFrame = 2^15 end - + properties (Nontunable, Logical) - %EnableCustomProfile Enable Custom Profile - % Enable use of custom Profile file to set SamplingRate, + % EnableCustomProfile Enable Custom Profile + % Enable use of custom Profile file to set SamplingRate, % RFBandwidth, and FIR in datapaths - EnableCustomProfile = false; + EnableCustomProfile = false end - + properties (Nontunable) - %CustomProfileFileName Custom Profile File Name + % CustomProfileFileName Custom Profile File Name % Path to custom Profile file created from profile wizard - CustomProfileFileName = ''; + CustomProfileFileName = '' end - + properties (Hidden, Constant) - %SamplingRate Sampling Rate - % Baseband sampling rate in Hz, specified as a scalar + % SamplingRate Sampling Rate + % Baseband sampling rate in Hz, specified as a scalar % in samples per second. - SamplingRate = 122.88e6; + SamplingRate = 122.88e6 end - + properties - %CenterFrequency Center Frequency + % CenterFrequency Center Frequency % RF center frequency, specified in Hz as a scalar. The % default is 2.4e9. This property is tunable. - CenterFrequency = 2.4e9; + CenterFrequency = 2.4e9 end - - properties(Nontunable, Hidden) - Timeout = Inf; - kernelBuffersCount = 2; - dataTypeStr = 'int16'; - phyDevName = 'ad9371-phy'; + + properties (Nontunable, Hidden) + Timeout = Inf + kernelBuffersCount = 2 + dataTypeStr = 'int16' + phyDevName = 'ad9371-phy' iioDevPHY end properties (Hidden, Constant) - ComplexData = true; + ComplexData = true end - + methods + %% Constructor function obj = Base(varargin) 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}, ... - '', 'SamplesPerFrame'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'positive', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>', 0, '<=', 2^20}, ... + '', 'SamplesPerFrame'); obj.SamplesPerFrame = value; end + % Check CenterFrequency function set.CenterFrequency(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'positive','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',70e6,'<=',6e9}, ... - '', 'CenterFrequency'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'positive', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 70e6, '<=', 6e9}, ... + '', 'CenterFrequency'); obj.CenterFrequency = value; obj.CenterFrequencySet(value); end + % Check EnableCustomProfile function set.EnableCustomProfile(obj, value) - validateattributes( value, { 'logical' }, ... - { }, ... - '', 'EnableCustomProfile'); + validateattributes(value, { 'logical' }, ... + { }, ... + '', 'EnableCustomProfile'); obj.EnableCustomProfile = value; end + % Check CustomFilterFileName function set.CustomProfileFileName(obj, value) - validateattributes( value, { 'char' }, ... - { }, ... - '', 'CustomProfileFileName'); + validateattributes(value, { 'char' }, ... + { }, ... + '', 'CustomProfileFileName'); obj.CustomProfileFileName = value; if obj.EnableCustomProfile && obj.ConnectedToDevice %#ok writeProfileFile(obj); end end + end - + %% API Functions methods (Hidden, Access = protected) - + % Set CenterFrequency for hardware function CenterFrequencySet(obj, value) if obj.ConnectedToDevice - id = sprintf('altvoltage%d',strcmp(obj.Type,'Tx')); - obj.setAttributeLongLong(id,'frequency',value,true); + id = sprintf('altvoltage%d', strcmp(obj.Type, 'Tx')); + obj.setAttributeLongLong(id, 'frequency', value, true); end end - + function icon = getIconImpl(obj) - icon = sprintf(['AD9371 ',obj.Type]); + icon = sprintf(['AD9371 ', obj.Type]); end - + function state = savePartState(obj) id = 'voltage0'; - state.in1.hardwaregain = getAttributeDouble(obj,id,'hardwaregain',false); - state.in1.quadrature_tracking_en = getAttributeLongLong(obj,id,'quadrature_tracking_en',false); - state.out1.hardwaregain = getAttributeDouble(obj,id,'hardwaregain',true); - state.out1.quadrature_tracking_en = getAttributeLongLong(obj,id,'quadrature_tracking_en',true); - state.out1.lo_leakage_tracking_en = getAttributeLongLong(obj,id,'lo_leakage_tracking_en',true); + state.in1.hardwaregain = getAttributeDouble(obj, id, 'hardwaregain', false); + state.in1.quadrature_tracking_en = getAttributeLongLong(obj, id, 'quadrature_tracking_en', false); + state.out1.hardwaregain = getAttributeDouble(obj, id, 'hardwaregain', true); + state.out1.quadrature_tracking_en = getAttributeLongLong(obj, id, 'quadrature_tracking_en', true); + state.out1.lo_leakage_tracking_en = getAttributeLongLong(obj, id, 'lo_leakage_tracking_en', true); id = 'voltage1'; - state.in2.hardwaregain = getAttributeDouble(obj,id,'hardwaregain',false); - state.in2.quadrature_tracking_en = getAttributeLongLong(obj,id,'quadrature_tracking_en',false); - state.out2.hardwaregain = getAttributeDouble(obj,id,'hardwaregain',true); - state.out2.quadrature_tracking_en = getAttributeLongLong(obj,id,'quadrature_tracking_en',true); - state.out2.lo_leakage_tracking_en = getAttributeLongLong(obj,id,'lo_leakage_tracking_en',true); - + state.in2.hardwaregain = getAttributeDouble(obj, id, 'hardwaregain', false); + state.in2.quadrature_tracking_en = getAttributeLongLong(obj, id, 'quadrature_tracking_en', false); + state.out2.hardwaregain = getAttributeDouble(obj, id, 'hardwaregain', true); + state.out2.quadrature_tracking_en = getAttributeLongLong(obj, id, 'quadrature_tracking_en', true); + state.out2.lo_leakage_tracking_en = getAttributeLongLong(obj, id, 'lo_leakage_tracking_en', true); + id = 'altvoltage0'; - state.out.RX_LO_frequency = getAttributeLongLong(obj,id,'RX_LO_frequency',true); + state.out.RX_LO_frequency = getAttributeLongLong(obj, id, 'RX_LO_frequency', true); id = 'altvoltage1'; - state.in.TX_LO_frequency = getAttributeLongLong(obj,id,'TX_LO_frequency',true); + state.in.TX_LO_frequency = getAttributeLongLong(obj, id, 'TX_LO_frequency', true); end - function returnPartState(obj,state) + function returnPartState(obj, state) id = 'voltage0'; - setAttributeDouble(obj,id,'hardwaregain',state.in1.hardwaregain,false); - setAttributeLongLong(obj,id,'quadrature_tracking_en',state.in1.quadrature_tracking_en,false); - setAttributeDouble(obj,id,'hardwaregain',state.out1.hardwaregain,true); - setAttributeLongLong(obj,id,'quadrature_tracking_en',state.out1.quadrature_tracking_en,true); - setAttributeLongLong(obj,id,'lo_leakage_tracking_en',state.out1.lo_leakage_tracking_en,true); - + setAttributeDouble(obj, id, 'hardwaregain', state.in1.hardwaregain, false); + setAttributeLongLong(obj, id, 'quadrature_tracking_en', state.in1.quadrature_tracking_en, false); + setAttributeDouble(obj, id, 'hardwaregain', state.out1.hardwaregain, true); + setAttributeLongLong(obj, id, 'quadrature_tracking_en', state.out1.quadrature_tracking_en, true); + setAttributeLongLong(obj, id, 'lo_leakage_tracking_en', state.out1.lo_leakage_tracking_en, true); + id = 'voltage1'; - setAttributeDouble(obj,id,'hardwaregain',state.in2.hardwaregain,false); - setAttributeLongLong(obj,id,'quadrature_tracking_en',state.in2.quadrature_tracking_en,false); - setAttributeDouble(obj,id,'hardwaregain',state.out2.hardwaregain,true); - setAttributeLongLong(obj,id,'quadrature_tracking_en',state.out2.quadrature_tracking_en,true); - setAttributeLongLong(obj,id,'lo_leakage_tracking_en',state.out2.lo_leakage_tracking_en,true); - + setAttributeDouble(obj, id, 'hardwaregain', state.in2.hardwaregain, false); + setAttributeLongLong(obj, id, 'quadrature_tracking_en', state.in2.quadrature_tracking_en, false); + setAttributeDouble(obj, id, 'hardwaregain', state.out2.hardwaregain, true); + setAttributeLongLong(obj, id, 'quadrature_tracking_en', state.out2.quadrature_tracking_en, true); + setAttributeLongLong(obj, id, 'lo_leakage_tracking_en', state.out2.lo_leakage_tracking_en, true); + id = 'altvoltage0'; - setAttributeLongLong(obj,id,'RX_LO_frequency',state.out.RX_LO_frequency,true); + setAttributeLongLong(obj, id, 'RX_LO_frequency', state.out.RX_LO_frequency, true); id = 'altvoltage1'; - setAttributeLongLong(obj,id,'TX_LO_frequency',state.in.TX_LO_frequency,true); + setAttributeLongLong(obj, id, 'TX_LO_frequency', state.in.TX_LO_frequency, true); end - function writeProfileFile(obj) if obj.Count() > 1 - [~,props] = obj.Count(0,obj,'EnableCustomProfile'); + [~, props] = obj.Count(0, obj, 'EnableCustomProfile'); if any(props{:}) - warning('AD9371:Profile:RXTX',... - ['Existing objects in the workspace have written profiles.\n',... - 'Doing so again can have undesirable side affects.\n',... - 'First stepped object should only set profile.']); + warning('AD9371:Profile:RXTX', ... + ['Existing objects in the workspace have written profiles.\n', ... + 'Doing so again can have undesirable side affects.\n', ... + 'First stepped object should only set profile.']); end - end + end profle_data_str = fileread(obj.CustomProfileFileName); % Wrap update in read writes since once profiles are loaded % some attributes get lost state = savePartState(obj); - obj.setDeviceAttributeRAW('profile_config',profle_data_str); - returnPartState(obj,state) + obj.setDeviceAttributeRAW('profile_config', profle_data_str); + returnPartState(obj, state); 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 = 'AD9371'; end - + end end - diff --git a/+adi/+AD9371/ORx.m b/+adi/+AD9371/ORx.m index b957af5d..0ff38fba 100644 --- a/+adi/+AD9371/ORx.m +++ b/+adi/+AD9371/ORx.m @@ -8,48 +8,48 @@ % rx = adi.AD9371.ORx; % rx = adi.AD9371.ORx('uri','192.168.2.1'); % - % AD9371 Datasheet + % AD9371 Datasheet properties - %GainControlMode Gain Control Mode + % GainControlMode Gain Control Mode % specified as one of the following: - % 'automatic' — For signals with changing power levels - % 'manual' — For setting the gain manually with the Gain property - % 'hybrid' — For configuring hybrid AGC mode - GainControlMode = 'automatic'; - %Gain Gain + % 'automatic' - For signals with changing power levels + % 'manual' - For setting the gain manually with the Gain property + % 'hybrid' - For configuring hybrid AGC mode + GainControlMode = 'automatic' + % Gain Gain % Rx gain, specified as a scalar from 0 dB to 52 dB. The acceptable % minimum and maximum gain setting depends on the center % frequency. - Gain = 10; + Gain = 10 end - + properties (Nontunable) - %DigitalLoopbackMode Digital Loopback Mode + % DigitalLoopbackMode Digital Loopback Mode % Option to set digital loopback mode, specified as 0 or 1. % Allows digital loopback of TX data into the ORX path. % Value | Mode % --------------------------- % 0 | Disable % 1 | Enable - LoopbackMode = 0; + LoopbackMode = 0 end - + properties (Nontunable, Logical) % MUST BE NONTUNABLE OR SIMULINK WARNS - %EnableQuadratureTracking Enable Quadrature Tracking + % EnableQuadratureTracking Enable Quadrature Tracking % Option to enable quadrature tracking, specified as true or % false. When this property is true, IQ imbalance compensation is % applied to the input signal. - EnableQuadratureTracking = true; + EnableQuadratureTracking = true end - + properties - %RFPortSelect RF Port Select + % RFPortSelect RF Port Select % 'OFF' - SnRx path is disabled - % 'ORX1_TX_LO' – SnRx operates in observation mode on ORx1 with + % 'ORX1_TX_LO' - SnRx operates in observation mode on ORx1 with % Tx LO synthesizer - % 'ORX2_TX_LO' – SnRx operates in observation mode on ORx2 with + % 'ORX2_TX_LO' - SnRx operates in observation mode on ORx2 with % Tx LO synthesizer - % 'INTERNALCALS' – enables scheduled Tx calibrations while using + % 'INTERNALCALS' - enables scheduled Tx calibrations while using % SnRx path. The enableTrackingCals function needs to be called % in RADIO_OFF state. It sets the calibration mask, which the % scheduler will later use to schedule the desired calibrations. @@ -59,160 +59,166 @@ % based on the state of the transceiver. The Tx calibrations % will not be scheduled until INTERNALCALS is selected and the % Tx calibrations are enabled in the cal mask. - % 'OBS_SNIFFER' – SnRx operates in sniffer mode with latest - % selected Sniffer Input – for hardware pin control operation. + % 'OBS_SNIFFER' - SnRx operates in sniffer mode with latest + % selected Sniffer Input - for hardware pin control operation. % In pin mode, the GPIO pins designated for ORX_MODE would % select SNIFFER mode. Then MYKONOS_setSnifferChannel function % would choose the channel. - % 'ORX1_SN_LO' – SnRx operates in observation mode on ORx1 with + % 'ORX1_SN_LO' - SnRx operates in observation mode on ORx1 with % SNIFFER LO synthesizer - % 'ORX2_SN_LO' – SnRx operates in observation mode on ORx2 with + % 'ORX2_SN_LO' - SnRx operates in observation mode on ORx2 with % SNIFFER LO synthesizer - % 'SN_A' – SnRx operates in sniffer mode on SnRxA with SNIFFER + % 'SN_A' - SnRx operates in sniffer mode on SnRxA with SNIFFER % LO synthesizer - % 'SN_B' – SnRx operates in sniffer mode on SnRxB with SNIFFER + % 'SN_B' - SnRx operates in sniffer mode on SnRxB with SNIFFER % LO synthesizer - % 'SN_C' – SnRx operates in sniffer mode on SnRxC with SNIFFER + % 'SN_C' - SnRx operates in sniffer mode on SnRxC with SNIFFER % LO synthesizer - RFPortSelect = 'SN_A'; + RFPortSelect = 'SN_A' end - - properties(Constant, Hidden) + + properties (Constant, Hidden) GainControlModeSet = matlab.system.StringSet({ ... - 'manual','automatic','hybrid'}); + 'manual', 'automatic', 'hybrid'}) RFPortSelectSet = matlab.system.StringSet({ ... - 'OFF',... - 'ORX1_TX_LO','ORX2_TX_LO',... - 'INTERNALCALS',... - 'OBS_SNIFFER',... - 'ORX1_SN_LO','ORX2_SN_LO',... - 'SN_A','SN_B','SN_C'}); + 'OFF', ... + 'ORX1_TX_LO', 'ORX2_TX_LO', ... + 'INTERNALCALS', ... + 'OBS_SNIFFER', ... + 'ORX1_SN_LO', 'ORX2_SN_LO', ... + 'SN_A', 'SN_B', 'SN_C'}) end - + properties (Hidden, Nontunable, Access = protected) - isOutput = false; + isOutput = false end - - properties(Nontunable, Hidden, Constant) - Type = 'Rx'; - channel_names = {'voltage0_i','voltage0_q'}; + + properties (Nontunable, Hidden, Constant) + Type = 'Rx' + channel_names = {'voltage0_i', 'voltage0_q'} end - + properties (Nontunable, Hidden) - devName = 'axi-ad9371-rx-obs-hpc'; + devName = 'axi-ad9371-rx-obs-hpc' end - + methods + %% Constructor function obj = ORx(varargin) coder.allowpcode('plain'); obj = obj@adi.AD9371.Base(varargin{:}); end + % Check RFPortSelect function set.RFPortSelect(obj, value) obj.RFPortSelect = value; if obj.ConnectedToDevice - obj.setAttributeRAW('voltage2','rf_port_select',value,false); + obj.setAttributeRAW('voltage2', 'rf_port_select', value, false); end end + % Check GainControlMode function set.GainControlMode(obj, value) obj.GainControlMode = value; if obj.ConnectedToDevice - obj.setAttributeRAW('voltage2','rf_port_select','OFF',false); - obj.setAttributeRAW('voltage2','gain_control_mode',value,false) - obj.setAttributeRAW('voltage2','rf_port_select',obj.RFPortSelect,false); %#ok + obj.setAttributeRAW('voltage2', 'rf_port_select', 'OFF', false); + obj.setAttributeRAW('voltage2', 'gain_control_mode', value, false); + obj.setAttributeRAW('voltage2', 'rf_port_select', obj.RFPortSelect, false); %#ok end end + % Check Gain function set.Gain(obj, value) - - invalid = ['INTERNALCALS','OFF']; - if contains(invalid,obj.RFPortSelect) || ~strcmp(obj.GainControlMode,'manual') - error('Cannot set gain when in manual mode or if RFPort in OFF/INTERNALCALS') + + invalid = ['INTERNALCALS', 'OFF']; + if contains(invalid, obj.RFPortSelect) || ~strcmp(obj.GainControlMode, 'manual') + error('Cannot set gain when in manual mode or if RFPort in OFF/INTERNALCALS'); end - sniff = ['OBS_SNIFFER','SN_A','SN_B','SN_C']; - if contains(sniff,obj.RFPortSelect) - validateattributes( value, { 'double','single' }, ... - { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', 0,'<=', 52}, ... - '', 'Gain'); + sniff = ['OBS_SNIFFER', 'SN_A', 'SN_B', 'SN_C']; + if contains(sniff, obj.RFPortSelect) + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', 0, '<=', 52}, ... + '', 'Gain'); end - orx = ['ORX1_SN_LO','ORX2_SN_LO','ORX1_TX_LO','ORX2_TX_LO']; - if contains(orx,obj.RFPortSelect) - validateattributes( value, { 'double','single' }, ... - { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', 0,'<=', 18}, ... - '', 'Gain'); + orx = ['ORX1_SN_LO', 'ORX2_SN_LO', 'ORX1_TX_LO', 'ORX2_TX_LO']; + if contains(orx, obj.RFPortSelect) + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', 0, '<=', 18}, ... + '', 'Gain'); end - assert(mod(value,1/4)==0, 'Gain must be a multiple of 0.25'); + assert(mod(value, 1 / 4) == 0, 'Gain must be a multiple of 0.25'); obj.Gain = value; - if obj.ConnectedToDevice && strcmp(obj.GainControlMode,'manual') %#ok - obj.setAttributeDouble('voltage2','hardwaregain',value,false); + if obj.ConnectedToDevice && strcmp(obj.GainControlMode, 'manual') %#ok + obj.setAttributeDouble('voltage2', 'hardwaregain', value, false); end end + % Check EnableQuadratureTracking function set.EnableQuadratureTracking(obj, value) obj.EnableQuadratureTracking = value; if obj.ConnectedToDevice - obj.setAttributeRAW('voltage2','rf_port_select','OFF',false); - obj.setAttributeBool('voltage2','quadrature_tracking_en',value,false); - obj.setAttributeRAW('voltage2','rf_port_select',obj.RFPortSelect,false); %#ok + obj.setAttributeRAW('voltage2', 'rf_port_select', 'OFF', false); + obj.setAttributeBool('voltage2', 'quadrature_tracking_en', value, false); + obj.setAttributeRAW('voltage2', 'rf_port_select', obj.RFPortSelect, false); %#ok end end + function set.LoopbackMode(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',1}, ... - '', 'LoopbackMode'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 1}, ... + '', 'LoopbackMode'); obj.LoopbackMode = value; if obj.ConnectedToDevice - obj.setDebugAttributeLongLong('loopback_tx_obs',value); + obj.setDebugAttributeLongLong('loopback_tx_obs', value); end end + end - - methods (Access=protected) - - function CenterFrequencySet(obj,value) + + methods (Access = protected) + + function CenterFrequencySet(obj, value) if obj.ConnectedToDevice - obj.setAttributeRAW('voltage2','rf_port_select','OFF',false); - obj.setAttributeLongLong('altvoltage2','RX_SN_LO_frequency',value,true); - obj.setAttributeRAW('voltage2','rf_port_select',obj.RFPortSelect,false); + obj.setAttributeRAW('voltage2', 'rf_port_select', 'OFF', false); + obj.setAttributeLongLong('altvoltage2', 'RX_SN_LO_frequency', value, true); + obj.setAttributeRAW('voltage2', 'rf_port_select', obj.RFPortSelect, false); end end end - + %% API Functions methods (Hidden, Access = protected) - + function setupInit(obj) % Write all attributes to device once connected through set % methods % Do writes directly to hardware without using set methods. % This is required sine Simulink support doesn't support % modification to nontunable variables at SetupImpl - + if obj.EnableCustomProfile writeProfileFile(obj); end - - obj.setAttributeRAW('voltage2','rf_port_select','OFF',false); - - obj.setAttributeRAW('voltage2','gain_control_mode',obj.GainControlMode,false); - obj.setAttributeBool('voltage2','quadrature_tracking_en',obj.EnableQuadratureTracking,false); - obj.setAttributeLongLong('altvoltage2','RX_SN_LO_frequency',obj.CenterFrequency ,true); + + obj.setAttributeRAW('voltage2', 'rf_port_select', 'OFF', false); + + obj.setAttributeRAW('voltage2', 'gain_control_mode', obj.GainControlMode, false); + obj.setAttributeBool('voltage2', 'quadrature_tracking_en', obj.EnableQuadratureTracking, false); + obj.setAttributeLongLong('altvoltage2', 'RX_SN_LO_frequency', obj.CenterFrequency, true); % Loopback Mode - obj.setDebugAttributeLongLong('loopback_tx_obs', obj.LoopbackMode); - - obj.setAttributeRAW('voltage2','rf_port_select',obj.RFPortSelect,false); + obj.setDebugAttributeLongLong('loopback_tx_obs', obj.LoopbackMode); - invalid = ['INTERNALCALS','OFF']; - if strcmp(obj.GainControlMode,'manual') && ~contains(invalid,obj.RFPortSelect) - obj.setAttributeDouble('voltage2','hardwaregain',obj.Gain,false); + obj.setAttributeRAW('voltage2', 'rf_port_select', obj.RFPortSelect, false); + + invalid = ['INTERNALCALS', 'OFF']; + if strcmp(obj.GainControlMode, 'manual') && ~contains(invalid, obj.RFPortSelect) + obj.setAttributeDouble('voltage2', 'hardwaregain', obj.Gain, false); end - + end - + end - -end +end diff --git a/+adi/+AD9371/Rx.m b/+adi/+AD9371/Rx.m index c959178c..a0d0aea5 100644 --- a/+adi/+AD9371/Rx.m +++ b/+adi/+AD9371/Rx.m @@ -6,137 +6,145 @@ % rx = adi.AD9371.Rx; % rx = adi.AD9371.Rx('uri','192.168.2.1'); % - % AD9371 Datasheet + % AD9371 Datasheet properties - %GainControlMode Gain Control Mode + % GainControlMode Gain Control Mode % specified as one of the following: - % 'slow_attack' — For signals with slowly changing power levels - % 'fast_attack' — For signals with rapidly changing power levels - % 'manual' — For setting the gain manually with the Gain property - % 'hybrid' — For configuring hybrid AGC mode - GainControlMode = 'automatic'; - %GainChannel0 Gain Channel 0 + % 'slow_attack' - For signals with slowly changing power levels + % 'fast_attack' - For signals with rapidly changing power levels + % 'manual' - For setting the gain manually with the Gain property + % 'hybrid' - For configuring hybrid AGC mode + GainControlMode = 'automatic' + % GainChannel0 Gain Channel 0 % Channel 0 gain, specified as a scalar from -4 dB to 71 dB. The acceptable % minimum and maximum gain setting depends on the center % frequency. - GainChannel0 = 10; - %GainChannel1 Gain Channel 1 + GainChannel0 = 10 + % GainChannel1 Gain Channel 1 % Channel 1 gain, specified as a scalar from -4 dB to 71 dB. The acceptable % minimum and maximum gain setting depends on the center % frequency. - GainChannel1 = 10; + GainChannel1 = 10 end - + properties (Nontunable) - %DigitalLoopbackMode Digital Loopback Mode + % DigitalLoopbackMode Digital Loopback Mode % Option to set digital loopback mode, specified as 0 or 1. % Allows digital loopback of TX data into the RX path. % Value | Mode % --------------------------- % 0 | Disable % 1 | Enable - LoopbackMode = 0; + LoopbackMode = 0 end - + properties (Nontunable, Logical) % MUST BE NONTUNABLE OR SIMULINK WARNS - %EnableQuadratureTrackingChannel0 Enable Quadrature Tracking Channel 0 + % EnableQuadratureTrackingChannel0 Enable Quadrature Tracking Channel 0 % Option to enable quadrature tracking, specified as true or % false. When this property is true, IQ imbalance compensation is % applied to the input signal. - EnableQuadratureTrackingChannel0 = true; - %EnableQuadratureTrackingChannel1 Enable Quadrature Tracking Channel 1 + EnableQuadratureTrackingChannel0 = true + % EnableQuadratureTrackingChannel1 Enable Quadrature Tracking Channel 1 % Option to enable quadrature tracking, specified as true or % false. When this property is true, IQ imbalance compensation is % applied to the input signal. - EnableQuadratureTrackingChannel1 = true; + EnableQuadratureTrackingChannel1 = true end - - properties(Constant, Hidden) + + properties (Constant, Hidden) GainControlModeSet = matlab.system.StringSet({ ... - 'manual','automatic','hybrid'}); + 'manual', 'automatic', 'hybrid'}) end - + properties (Hidden, Nontunable, Access = protected) - isOutput = false; + isOutput = false end - - properties(Nontunable, Hidden, Constant) - Type = 'Rx'; - channel_names = {'voltage0_i','voltage0_q','voltage1_i','voltage1_q'}; + + properties (Nontunable, Hidden, Constant) + Type = 'Rx' + channel_names = {'voltage0_i', 'voltage0_q', 'voltage1_i', 'voltage1_q'} end - + properties (Nontunable, Hidden) - devName = 'axi-ad9371-rx-hpc'; + devName = 'axi-ad9371-rx-hpc' end - + methods + %% Constructor function obj = Rx(varargin) coder.allowpcode('plain'); obj = obj@adi.AD9371.Base(varargin{:}); end + % Check GainControlMode function set.GainControlMode(obj, value) obj.GainControlMode = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeRAW(id,'gain_control_mode',value,false); + obj.setAttributeRAW(id, 'gain_control_mode', value, false); end end + % Check GainChannel0 function set.GainChannel0(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', 0,'<=', 30}, ... - '', 'Gain'); - assert(mod(value,1/4)==0, 'Gain must be a multiple of 0.25'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', 0, '<=', 30}, ... + '', 'Gain'); + assert(mod(value, 1 / 4) == 0, 'Gain must be a multiple of 0.25'); obj.GainChannel0 = value; - if obj.ConnectedToDevice && strcmp(obj.GainControlMode,'manual') + if obj.ConnectedToDevice && strcmp(obj.GainControlMode, 'manual') id = 'voltage0'; - obj.setAttributeDouble(id,'hardwaregain',value,false); + obj.setAttributeDouble(id, 'hardwaregain', value, false); end end + % Check GainChannel1 function set.GainChannel1(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', 0,'<=', 30}, ... - '', 'Gain'); - assert(mod(value,1/4)==0, 'Gain must be a multiple of 0.25'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', 0, '<=', 30}, ... + '', 'Gain'); + assert(mod(value, 1 / 4) == 0, 'Gain must be a multiple of 0.25'); obj.GainChannel1 = value; - if obj.ConnectedToDevice && strcmp(obj.GainControlMode,'manual') + if obj.ConnectedToDevice && strcmp(obj.GainControlMode, 'manual') id = 'voltage1'; - obj.setAttributeDouble(id,'hardwaregain',value,false); + obj.setAttributeDouble(id, 'hardwaregain', value, false); end end + % Check EnableQuadratureTrackingChannel0 function set.EnableQuadratureTrackingChannel0(obj, value) obj.EnableQuadratureTrackingChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'quadrature_tracking_en',value,false); + obj.setAttributeBool(id, 'quadrature_tracking_en', value, false); end end + % Check EnableQuadratureTrackingChannel1 function set.EnableQuadratureTrackingChannel1(obj, value) obj.EnableQuadratureTrackingChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeBool(id,'quadrature_tracking_en',value,false); + obj.setAttributeBool(id, 'quadrature_tracking_en', value, false); end - end + end + function set.LoopbackMode(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',1}, ... - '', 'LoopbackMode'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 1}, ... + '', 'LoopbackMode'); obj.LoopbackMode = value; if obj.ConnectedToDevice - obj.setDebugAttributeLongLong('loopback_tx_rx',value); + obj.setDebugAttributeLongLong('loopback_tx_rx', value); end - end + end + end - + %% API Functions methods (Hidden, Access = protected) - + function setupInit(obj) % Write all attributes to device once connected through set % methods @@ -146,22 +154,21 @@ function setupInit(obj) if obj.EnableCustomProfile writeProfileFile(obj); end - - obj.setAttributeRAW('voltage0','gain_control_mode',obj.GainControlMode,false); - obj.setAttributeBool('voltage0','quadrature_tracking_en',obj.EnableQuadratureTrackingChannel0,false); - obj.setAttributeBool('voltage1','quadrature_tracking_en',obj.EnableQuadratureTrackingChannel1,false); - id = sprintf('altvoltage%d',strcmp(obj.Type,'Tx')); - obj.setAttributeLongLong(id,'RX_LO_frequency',obj.CenterFrequency ,true); + + obj.setAttributeRAW('voltage0', 'gain_control_mode', obj.GainControlMode, false); + obj.setAttributeBool('voltage0', 'quadrature_tracking_en', obj.EnableQuadratureTrackingChannel0, false); + obj.setAttributeBool('voltage1', 'quadrature_tracking_en', obj.EnableQuadratureTrackingChannel1, false); + id = sprintf('altvoltage%d', strcmp(obj.Type, 'Tx')); + obj.setAttributeLongLong(id, 'RX_LO_frequency', obj.CenterFrequency, true); % Loopback Mode - obj.setDebugAttributeLongLong('loopback_tx_rx', obj.LoopbackMode); - - if strcmp(obj.GainControlMode,'manual') - obj.setAttributeDouble('voltage0','hardwaregain',obj.GainChannel0,false); - obj.setAttributeDouble('voltage1','hardwaregain',obj.GainChannel1,false); + obj.setDebugAttributeLongLong('loopback_tx_rx', obj.LoopbackMode); + + if strcmp(obj.GainControlMode, 'manual') + obj.setAttributeDouble('voltage0', 'hardwaregain', obj.GainChannel0, false); + obj.setAttributeDouble('voltage1', 'hardwaregain', obj.GainChannel1, false); end end - + end - -end +end diff --git a/+adi/+AD9371/Tx.m b/+adi/+AD9371/Tx.m index f964eae0..2011d1cb 100644 --- a/+adi/+AD9371/Tx.m +++ b/+adi/+AD9371/Tx.m @@ -7,93 +7,95 @@ % tx = adi.AD9371.Tx('uri','192.168.2.1'); % % AD9371 Datasheet - + properties - %AttenuationChannel0 Attenuation Channel 0 + % AttenuationChannel0 Attenuation Channel 0 % Attenuation specified as a scalar from -89.75 to 0 dB with a % resolution of 0.25 dB. - AttenuationChannel0 = -30; - %AttenuationChannel1 Attenuation Channel 1 + AttenuationChannel0 = -30 + % AttenuationChannel1 Attenuation Channel 1 % Attenuation specified as a scalar from -89.75 to 0 dB with a % resolution of 0.25 dB. - AttenuationChannel1 = -30; + AttenuationChannel1 = -30 end - + properties (Hidden, Nontunable, Access = protected) - isOutput = true; + isOutput = true end - - properties(Nontunable, Hidden, Constant) - Type = 'Tx'; + + properties (Nontunable, Hidden, Constant) + Type = 'Tx' end - - properties(Nontunable, Hidden) - channel_names = {'voltage0','voltage1','voltage2','voltage3'}; + + properties (Nontunable, Hidden) + channel_names = {'voltage0', 'voltage1', 'voltage2', 'voltage3'} end - + properties (Nontunable, Hidden) - devName = 'axi-ad9371-tx-hpc'; + devName = 'axi-ad9371-tx-hpc' end - + methods + %% Constructor function obj = Tx(varargin) coder.allowpcode('plain'); obj = obj@adi.AD9371.Base(varargin{:}); end + % Check Attenuation function set.AttenuationChannel0(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', -89.75,'<=', 0}, ... - '', 'Attenuation'); - assert(mod(value,1/4)==0, 'Attenuation must be a multiple of 0.25'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', -89.75, '<=', 0}, ... + '', 'Attenuation'); + assert(mod(value, 1 / 4) == 0, 'Attenuation must be a multiple of 0.25'); obj.AttenuationChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeDouble(id,'hardwaregain',value,true); + obj.setAttributeDouble(id, 'hardwaregain', value, true); end end + % Check Attenuation function set.AttenuationChannel1(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', -89.75,'<=', 0}, ... - '', 'Attenuation'); - assert(mod(value,1/4)==0, 'Attenuation must be a multiple of 0.25'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', -89.75, '<=', 0}, ... + '', 'Attenuation'); + assert(mod(value, 1 / 4) == 0, 'Attenuation must be a multiple of 0.25'); obj.AttenuationChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeDouble(id,'hardwaregain',value,true); + obj.setAttributeDouble(id, 'hardwaregain', value, true); end end - + end - + %% API Functions methods (Hidden, Access = protected) - + function setupInit(obj) % Write all attributes to device once connected through set % methods % Do writes directly to hardware without using set methods. % This is required sine Simulink support doesn't support % modification to nontunable variables at SetupImpl - + if obj.EnableCustomProfile writeProfileFile(obj); end - - id = sprintf('altvoltage%d',strcmp(obj.Type,'Tx')); - obj.setAttributeLongLong(id,'TX_LO_frequency',obj.CenterFrequency ,true); - obj.setAttributeDouble('voltage0','hardwaregain',obj.AttenuationChannel0,true); - obj.setAttributeDouble('voltage1','hardwaregain',obj.AttenuationChannel1,true); - - obj.ToggleDDS(strcmp(obj.DataSource,'DDS')); - if strcmp(obj.DataSource,'DDS') + + id = sprintf('altvoltage%d', strcmp(obj.Type, 'Tx')); + obj.setAttributeLongLong(id, 'TX_LO_frequency', obj.CenterFrequency, true); + obj.setAttributeDouble('voltage0', 'hardwaregain', obj.AttenuationChannel0, true); + obj.setAttributeDouble('voltage1', 'hardwaregain', obj.AttenuationChannel1, true); + + obj.ToggleDDS(strcmp(obj.DataSource, 'DDS')); + if strcmp(obj.DataSource, 'DDS') obj.DDSUpdate(); end end - + end - -end +end diff --git a/+adi/+ADRV9002/Base.m b/+adi/+ADRV9002/Base.m index 62cc573b..587b70db 100644 --- a/+adi/+ADRV9002/Base.m +++ b/+adi/+ADRV9002/Base.m @@ -3,98 +3,101 @@ adi.common.Attribute & ... adi.common.DebugAttribute & ... matlabshared.libiio.base - %adi.ADRV9002.Base Class + % adi.ADRV9002.Base Class % This class contains shared parameters and methods between TX and RX % classes properties (Nontunable) - %SamplesPerFrame Samples Per Frame + % 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; + SamplesPerFrame = 2^15 end - + properties (Nontunable, Logical) - %EnableCustomProfile Enable Custom Profile - % Enable use of custom Profile file to set SamplingRate, + % EnableCustomProfile Enable Custom Profile + % Enable use of custom Profile file to set SamplingRate, % RFBandwidth, and other features of transceiver - EnableCustomProfile = false; + EnableCustomProfile = false end - + properties (Nontunable) - %CustomProfileFileName Custom Profile File Name + % CustomProfileFileName Custom Profile File Name % Path to custom Profile file created from profile wizard - CustomProfileFileName = ''; - %CustomStreamFileName Custom Stream File Name + CustomProfileFileName = '' + % CustomStreamFileName Custom Stream File Name % Path to custom stream file created from profile wizard - CustomStreamFileName = ''; + CustomStreamFileName = '' end - + properties (Dependent) - %SamplingRate Sampling Rate - % Baseband sampling rate in Hz, specified as a scalar + % SamplingRate Sampling Rate + % Baseband sampling rate in Hz, specified as a scalar % in samples per second. This is a read-only property SamplingRate end - + properties - %CenterFrequencyChannel0 Center Frequency Channel0 + % CenterFrequencyChannel0 Center Frequency Channel0 % RF center frequency, specified in Hz as a scalar. The % default is 2.4e9. This property is tunable. - CenterFrequencyChannel0 = 2.4e9; - %CenterFrequencyChannel1 Center Frequency Channel 1 + CenterFrequencyChannel0 = 2.4e9 + % CenterFrequencyChannel1 Center Frequency Channel 1 % RF center frequency, specified in Hz as a scalar. The % default is 2.4e9. This property is tunable. - CenterFrequencyChannel1 = 2.4e9; - - %NCOCorrectionFrequencyChannel0 NCO Correction Frequency Channel 0 + CenterFrequencyChannel1 = 2.4e9 + + % NCOCorrectionFrequencyChannel0 NCO Correction Frequency Channel 0 % NCO correction frequency, specified in Hz as a scalar. The % default is 0. This property is tunable. - NCOCorrectionFrequencyChannel0 = 0; - %NCOCorrectionFrequencyChannel1 NCO Correction Frequency Channel 1 + NCOCorrectionFrequencyChannel0 = 0 + % NCOCorrectionFrequencyChannel1 NCO Correction Frequency Channel 1 % NCO correction frequency, specified in Hz as a scalar. The % default is 0. This property is tunable. - NCOCorrectionFrequencyChannel1 = 0; + NCOCorrectionFrequencyChannel1 = 0 end - - properties(Nontunable, Hidden) - Timeout = Inf; - kernelBuffersCount = 2; - dataTypeStr = 'int16'; - phyDevName = 'adrv9002-phy'; + + properties (Nontunable, Hidden) + Timeout = Inf + kernelBuffersCount = 2 + dataTypeStr = 'int16' + phyDevName = 'adrv9002-phy' iioDevPHY - newAPI = false; + newAPI = false end properties (Hidden, Constant) - ComplexData = true; + ComplexData = true end - + methods + %% Constructor function obj = Base(varargin) coder.allowpcode('plain'); obj = obj@matlabshared.libiio.base(varargin{:}); end + function value = get.SamplingRate(obj) if obj.ConnectedToDevice - value = obj.getAttributeLongLong('voltage0','sampling_frequency',strcmpi(obj.Type,'Tx')); + value = obj.getAttributeLongLong('voltage0', 'sampling_frequency', strcmpi(obj.Type, 'Tx')); else value = NaN; end end - + % Check SamplesPerFrame function set.SamplesPerFrame(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'positive','scalar', 'finite', 'nonnan', 'nonempty','integer','>',0,'<=',2^20}, ... - '', 'SamplesPerFrame'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'positive', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>', 0, '<=', 2^20}, ... + '', 'SamplesPerFrame'); obj.SamplesPerFrame = value; end + % Check CenterFrequencyChannel0 function set.CenterFrequencyChannel0(obj, value) obj.CenterFrequencyChannel0 = value; - if strcmpi(obj.Type,'Tx') + if strcmpi(obj.Type, 'Tx') id = 'altvoltage2'; if obj.newAPI prop = 'frequency'; @@ -110,13 +113,14 @@ end end if obj.ConnectedToDevice - obj.setAttributeLongLong(id,prop,value,true); + obj.setAttributeLongLong(id, prop, value, true); end end + % Check CenterFrequencyChannel1 function set.CenterFrequencyChannel1(obj, value) obj.CenterFrequencyChannel1 = value; - if strcmpi(obj.Type,'Tx') + if strcmpi(obj.Type, 'Tx') id = 'altvoltage3'; if obj.newAPI prop = 'frequency'; @@ -132,200 +136,202 @@ end end if obj.ConnectedToDevice - obj.setAttributeLongLong(id,prop,value,true); + obj.setAttributeLongLong(id, prop, value, true); end end - + % Check NCOCorrectionFrequencyChannel0 function set.NCOCorrectionFrequencyChannel0(obj, value) obj.NCOCorrectionFrequencyChannel0 = value; id = 'voltage0'; prop = 'nco_frequency'; if obj.ConnectedToDevice - obj.setAttributeLongLong(id,prop,value,strcmpi(obj.Type,'Tx')); + obj.setAttributeLongLong(id, prop, value, strcmpi(obj.Type, 'Tx')); end end + % Check NCOCorrectionFrequencyChannel1 function set.NCOCorrectionFrequencyChannel1(obj, value) obj.NCOCorrectionFrequencyChannel1 = value; id = 'voltage1'; prop = 'nco_frequency'; if obj.ConnectedToDevice - obj.setAttributeLongLong(id,prop,value,strcmpi(obj.Type,'Tx')); + obj.setAttributeLongLong(id, prop, value, strcmpi(obj.Type, 'Tx')); end end - + % Check EnableCustomProfile function set.EnableCustomProfile(obj, value) - validateattributes( value, { 'logical' }, ... - { }, ... - '', 'EnableCustomProfile'); + validateattributes(value, { 'logical' }, ... + { }, ... + '', 'EnableCustomProfile'); obj.EnableCustomProfile = value; end + % Check CustomFilterFileName function set.CustomProfileFileName(obj, value) - validateattributes( value, { 'char' }, ... - { }, ... - '', 'CustomProfileFileName'); + validateattributes(value, { 'char' }, ... + { }, ... + '', 'CustomProfileFileName'); obj.CustomProfileFileName = value; if obj.EnableCustomProfile && obj.ConnectedToDevice %#ok writeProfileFile(obj); end end + % Check CustomStreamFileName function set.CustomStreamFileName(obj, value) - validateattributes( value, { 'char' }, ... - { }, ... - '', 'CustomStreamFileName'); + validateattributes(value, { 'char' }, ... + { }, ... + '', 'CustomStreamFileName'); obj.CustomStreamFileName = value; if obj.EnableCustomProfile && obj.ConnectedToDevice %#ok writeProfileFile(obj); end end + end - + %% API Functions methods (Hidden, Access = protected) + function checkDriverAPI(obj) % Due to driver updates between version there are 2 names for % the LO props. We need to check which one we are using phydev = getDev(obj, obj.phyDevName); chanPtr = iio_device_find_channel(obj, phydev, 'altvoltage0', true); - status = cPtrCheck(obj,chanPtr); + status = cPtrCheck(obj, chanPtr); if status ~= 0 - error("Cannot find channel altvoltage0") + error("Cannot find channel altvoltage0"); end - status = iio_channel_attr_read(obj,chanPtr,'frequency',1024); + status = iio_channel_attr_read(obj, chanPtr, 'frequency', 1024); obj.newAPI = status >= 0; end - function lowerDDSs(obj,singleDDS) + function lowerDDSs(obj, singleDDS) % Since calibrations are sensitive, DDSs need to be powered % down anytime a profile is loaded - - dev = getDev(obj,'axi-adrv9002-tx-lpc'); + + dev = getDev(obj, 'axi-adrv9002-tx-lpc'); if singleDDS numChannels = 8; else numChannels = 4; end - - for channel=0:numChannels-1 - id = sprintf('altvoltage%d',channel); - chanPtr = getChan(obj, dev,id,true); - iio_channel_attr_write_double(obj,chanPtr,'scale',0); + + for channel = 0:numChannels - 1 + id = sprintf('altvoltage%d', channel); + chanPtr = getChan(obj, dev, id, true); + iio_channel_attr_write_double(obj, chanPtr, 'scale', 0); end - + if ~singleDDS dev = getDev(obj, 'axi-adrv9002-tx2-lpc'); - for channel=0:numChannels-1 - id = sprintf('altvoltage%d',channel); - chanPtr = getChan(obj, dev,id,true); - iio_channel_attr_write_double(obj,chanPtr,'scale',0); + for channel = 0:numChannels - 1 + id = sprintf('altvoltage%d', channel); + chanPtr = getChan(obj, dev, id, true); + iio_channel_attr_write_double(obj, chanPtr, 'scale', 0); end end - + end - - function r = checkIfDevExists(obj,name) + + function r = checkIfDevExists(obj, name) devPtr = iio_context_find_device(obj, obj.iioCtx, name); - status = cPtrCheck(obj,devPtr); - r = status==0; + status = cPtrCheck(obj, devPtr); + r = status == 0; end - + function icon = getIconImpl(obj) - icon = sprintf(['ADRV9002 ',obj.Type]); + icon = sprintf(['ADRV9002 ', obj.Type]); end - + function state = savePartState(obj) id = 'voltage0'; - state.in1.hardwaregain = getAttributeDouble(obj,id,'hardwaregain',false); - state.in1.quadrature_tracking_en = getAttributeLongLong(obj,id,'quadrature_tracking_en',false); - state.out1.hardwaregain = getAttributeDouble(obj,id,'hardwaregain',true); - state.out1.quadrature_tracking_en = getAttributeLongLong(obj,id,'quadrature_tracking_en',true); - state.out1.lo_leakage_tracking_en = getAttributeLongLong(obj,id,'lo_leakage_tracking_en',true); + state.in1.hardwaregain = getAttributeDouble(obj, id, 'hardwaregain', false); + state.in1.quadrature_tracking_en = getAttributeLongLong(obj, id, 'quadrature_tracking_en', false); + state.out1.hardwaregain = getAttributeDouble(obj, id, 'hardwaregain', true); + state.out1.quadrature_tracking_en = getAttributeLongLong(obj, id, 'quadrature_tracking_en', true); + state.out1.lo_leakage_tracking_en = getAttributeLongLong(obj, id, 'lo_leakage_tracking_en', true); id = 'voltage1'; - state.in2.hardwaregain = getAttributeDouble(obj,id,'hardwaregain',false); - state.in2.quadrature_tracking_en = getAttributeLongLong(obj,id,'quadrature_tracking_en',false); - state.out2.hardwaregain = getAttributeDouble(obj,id,'hardwaregain',true); - state.out2.quadrature_tracking_en = getAttributeLongLong(obj,id,'quadrature_tracking_en',true); - state.out2.lo_leakage_tracking_en = getAttributeLongLong(obj,id,'lo_leakage_tracking_en',true); - + state.in2.hardwaregain = getAttributeDouble(obj, id, 'hardwaregain', false); + state.in2.quadrature_tracking_en = getAttributeLongLong(obj, id, 'quadrature_tracking_en', false); + state.out2.hardwaregain = getAttributeDouble(obj, id, 'hardwaregain', true); + state.out2.quadrature_tracking_en = getAttributeLongLong(obj, id, 'quadrature_tracking_en', true); + state.out2.lo_leakage_tracking_en = getAttributeLongLong(obj, id, 'lo_leakage_tracking_en', true); + id = 'altvoltage0'; - state.out.RX_LO_frequency = getAttributeLongLong(obj,id,'frequency',true); + state.out.RX_LO_frequency = getAttributeLongLong(obj, id, 'frequency', true); id = 'altvoltage1'; - state.in.TX_LO_frequency = getAttributeLongLong(obj,id,'frequency',true); + state.in.TX_LO_frequency = getAttributeLongLong(obj, id, 'frequency', true); end - function returnPartState(obj,state) + function returnPartState(obj, state) id = 'voltage0'; - setAttributeDouble(obj,id,'hardwaregain',state.in1.hardwaregain,false); - setAttributeLongLong(obj,id,'quadrature_tracking_en',state.in1.quadrature_tracking_en,false); - setAttributeDouble(obj,id,'hardwaregain',state.out1.hardwaregain,true); - setAttributeLongLong(obj,id,'quadrature_tracking_en',state.out1.quadrature_tracking_en,true); - setAttributeLongLong(obj,id,'lo_leakage_tracking_en',state.out1.lo_leakage_tracking_en,true); - + setAttributeDouble(obj, id, 'hardwaregain', state.in1.hardwaregain, false); + setAttributeLongLong(obj, id, 'quadrature_tracking_en', state.in1.quadrature_tracking_en, false); + setAttributeDouble(obj, id, 'hardwaregain', state.out1.hardwaregain, true); + setAttributeLongLong(obj, id, 'quadrature_tracking_en', state.out1.quadrature_tracking_en, true); + setAttributeLongLong(obj, id, 'lo_leakage_tracking_en', state.out1.lo_leakage_tracking_en, true); + id = 'voltage1'; - setAttributeDouble(obj,id,'hardwaregain',state.in2.hardwaregain,false); - setAttributeLongLong(obj,id,'quadrature_tracking_en',state.in2.quadrature_tracking_en,false); - setAttributeDouble(obj,id,'hardwaregain',state.out2.hardwaregain,true); - setAttributeLongLong(obj,id,'quadrature_tracking_en',state.out2.quadrature_tracking_en,true); - setAttributeLongLong(obj,id,'lo_leakage_tracking_en',state.out2.lo_leakage_tracking_en,true); - + setAttributeDouble(obj, id, 'hardwaregain', state.in2.hardwaregain, false); + setAttributeLongLong(obj, id, 'quadrature_tracking_en', state.in2.quadrature_tracking_en, false); + setAttributeDouble(obj, id, 'hardwaregain', state.out2.hardwaregain, true); + setAttributeLongLong(obj, id, 'quadrature_tracking_en', state.out2.quadrature_tracking_en, true); + setAttributeLongLong(obj, id, 'lo_leakage_tracking_en', state.out2.lo_leakage_tracking_en, true); + id = 'altvoltage0'; - setAttributeLongLong(obj,id,'frequency',state.out.RX_LO_frequency,true); + setAttributeLongLong(obj, id, 'frequency', state.out.RX_LO_frequency, true); id = 'altvoltage1'; - setAttributeLongLong(obj,id,'frequency',state.in.TX_LO_frequency,true); + setAttributeLongLong(obj, id, 'frequency', state.in.TX_LO_frequency, true); end - function writeProfileFile(obj) if obj.Count() > 1 - [~,props] = obj.Count(0,obj,'EnableCustomProfile'); + [~, props] = obj.Count(0, obj, 'EnableCustomProfile'); if any(props{:}) - warning('ADRV9002:Profile:RXTX',... - ['Existing objects in the workspace have written profiles.\n',... - 'Doing so again can have undesirable side affects.\n',... - 'First stepped object should only set profile.']); + warning('ADRV9002:Profile:RXTX', ... + ['Existing objects in the workspace have written profiles.\n', ... + 'Doing so again can have undesirable side affects.\n', ... + 'First stepped object should only set profile.']); end end - - assert(~isempty(obj.CustomStreamFileName),'A custom stream file must be defined for custom profiles'); - assert(~isempty(obj.CustomProfileFileName),'A custom profile file must be defined for custom profiles'); - - - obj.lowerDDSs(strcmpi(obj.channel_names(3),'voltage1_i') || ... - strcmpi(obj.channel_names(3),'voltage2')); - + + assert(~isempty(obj.CustomStreamFileName), 'A custom stream file must be defined for custom profiles'); + assert(~isempty(obj.CustomProfileFileName), 'A custom profile file must be defined for custom profiles'); + + obj.lowerDDSs(strcmpi(obj.channel_names(3), 'voltage1_i') || ... + strcmpi(obj.channel_names(3), 'voltage2')); + % Wrap update in read writes since once profiles are loaded % some attributes get lost -% state = savePartState(obj); + % state = savePartState(obj); stream_data_str = fileread(obj.CustomStreamFileName); - obj.setDeviceAttributeRAW('stream_config',stream_data_str); + obj.setDeviceAttributeRAW('stream_config', stream_data_str); profle_data_str = fileread(obj.CustomProfileFileName); - obj.setDeviceAttributeRAW('profile_config',profle_data_str); -% returnPartState(obj,state) + obj.setDeviceAttributeRAW('profile_config', profle_data_str); + % returnPartState(obj,state) 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 = 'ADRV9002'; end - + end end - diff --git a/+adi/+ADRV9002/Rx.m b/+adi/+ADRV9002/Rx.m index 37e2e6af..8d3a069a 100644 --- a/+adi/+ADRV9002/Rx.m +++ b/+adi/+ADRV9002/Rx.m @@ -8,26 +8,26 @@ % % Significant configuration of the transceiver is done by loading profiles % created through the Transceiver Evaluation Software (TES). This includes - % settings such as sample rate, bandwidth, data interface format, and TDD + % settings such as sample rate, bandwidth, data interface format, and TDD % or FDD operation. For more information on creating and loading profiles, % refer to the ADRV9002 documentation. % - % ADRV9002 Datasheet + % ADRV9002 Datasheet properties - %ENSMModeChannel0 State Machine Mode Channel 0 + % ENSMModeChannel0 State Machine Mode Channel 0 % specified as one of the following: % 'calibrated' % 'primed' % 'rf_enabled' - ENSMModeChannel0 = 'rf_enabled'; - %ENSMModeModeChannel1 State Machine Mode Channel 1 + ENSMModeChannel0 = 'rf_enabled' + % ENSMModeModeChannel1 State Machine Mode Channel 1 % specified as one of the following: % 'calibrated' % 'primed' % 'rf_enabled' - ENSMModeChannel1 = 'rf_enabled'; - - %InterfaceGainChannel0 Interface Gain Channel 0 + ENSMModeChannel1 = 'rf_enabled' + + % InterfaceGainChannel0 Interface Gain Channel 0 % This is the final gain in the digital path with possible % values: -36:6:18 % This gain should be selected based on primary signal bandwidth. @@ -38,8 +38,8 @@ % available options for this gain depend on the profile loaded % and picking an option outside of those options generates an % error. - InterfaceGainChannel0 = '0dB'; - %InterfaceGainChannel1 Interface Gain Channel 1 + InterfaceGainChannel0 = '0dB' + % InterfaceGainChannel1 Interface Gain Channel 1 % This is the final gain in the digital path with possible % values: -36:6:18 % This gain should be selected based on primary signal bandwidth. @@ -50,9 +50,9 @@ % available options for this gain depend on the profile loaded % and picking an option outside of those options generates an % error. - InterfaceGainChannel1 = '0dB'; - - %DigitalGainControlModeChannel0 Digital Gain Control Mode Channel 0 + InterfaceGainChannel1 = '0dB' + + % DigitalGainControlModeChannel0 Digital Gain Control Mode Channel 0 % The digital gain control has two major purposes, one for gain % correction which is to correct the small step size inaccuracy % in analog front-end attenuation and the other for gain @@ -63,7 +63,7 @@ % gain table has a unique front-end attenuator setting, with a % corresponding amount of digital gain, programmed at each index % of the table. In the end of the Rx data path, the interface - % gain could be further applied by using a “Slicer” block for 2 + % gain could be further applied by using a "Slicer" block for 2 % major purposes. One is to avoid digital saturation in gain % compensation mode. The other one is to ensure the overall SNR % is limited only by analog noise and unaffected by quantization @@ -73,11 +73,11 @@ % DSA) does not need to be controlled. Compensation should be % used for external LNA or DSA control. % - % Gain control is specified as one of the following: + % Gain control is specified as one of the following: % 'automatic' - Automatically adjust interface gain % 'spi' - Manually adjust interface gain - DigitalGainControlModeChannel0 = 'automatic'; - %DigitalGainControlModeChannel1 Digital Gain Control Mode Channel 1 + DigitalGainControlModeChannel0 = 'automatic' + % DigitalGainControlModeChannel1 Digital Gain Control Mode Channel 1 % The digital gain control has two major purposes, one for gain % correction which is to correct the small step size inaccuracy % in analog front-end attenuation and the other for gain @@ -88,7 +88,7 @@ % gain table has a unique front-end attenuator setting, with a % corresponding amount of digital gain, programmed at each index % of the table. In the end of the Rx data path, the interface - % gain could be further applied by using a “Slicer” block for 2 + % gain could be further applied by using a "Slicer" block for 2 % major purposes. One is to avoid digital saturation in gain % compensation mode. The other one is to ensure the overall SNR % is limited only by analog noise and unaffected by quantization @@ -98,330 +98,341 @@ % DSA) does not need to be controlled. Compensation should be % used for external LNA or DSA control. % - % Gain control is specified as one of the following: + % Gain control is specified as one of the following: % 'automatic' - Automatically adjust interface gain % 'spi' - Manually adjust interface gain - DigitalGainControlModeChannel1 = 'automatic'; - - %AttenuationChannel0 Attenuation Channel 0 + DigitalGainControlModeChannel1 = 'automatic' + + % AttenuationChannel0 Attenuation Channel 0 % Must be greater than 0 - AttenuationChannel0 = 3; - %AttenuationChannel1 Attenuation Channel 1 + AttenuationChannel0 = 3 + % AttenuationChannel1 Attenuation Channel 1 % Must be greater than 0 - AttenuationChannel1 = 3; + AttenuationChannel1 = 3 end - + properties % ADVANCED - %ENSMPortModeChannel0 Enable State Machine Port Mode Channel 0 + % ENSMPortModeChannel0 Enable State Machine Port Mode Channel 0 % specified as one of the following: % 'spi' % 'pin' - ENSMPortModeChannel0 = 'spi'; - %ENSMPortModeChannel1 Enable State Machine Port Mode Channel 0 + ENSMPortModeChannel0 = 'spi' + % ENSMPortModeChannel1 Enable State Machine Port Mode Channel 0 % specified as one of the following: % 'spi' % 'pin' - ENSMPortModeChannel1 = 'spi'; - %GainControllerSourceChannel0 Gain Controller Source Channel 0 + ENSMPortModeChannel1 = 'spi' + % GainControllerSourceChannel0 Gain Controller Source Channel 0 % specified as one of the following: % 'spi' % 'pin' % 'automatic' - GainControllerSourceChannel0 = 'automatic'; - %GainControllerSourceChannel1 Gain Controller Source Channel 1 + GainControllerSourceChannel0 = 'automatic' + % GainControllerSourceChannel1 Gain Controller Source Channel 1 % specified as one of the following: % 'spi' % 'pin' % 'automatic' - GainControllerSourceChannel1 = 'automatic'; + GainControllerSourceChannel1 = 'automatic' end - + properties (Logical) % ADVANCED - %PowerdownChannel0 Powerdown Channel 0 - PowerdownChannel0 = false; - %PowerdownChannel0 Powerdown Channel 1 - PowerdownChannel1 = false; - - %AGCTrackingChannel0 AGC Tracking Channel 0 + % PowerdownChannel0 Powerdown Channel 0 + PowerdownChannel0 = false + % PowerdownChannel0 Powerdown Channel 1 + PowerdownChannel1 = false + + % AGCTrackingChannel0 AGC Tracking Channel 0 % AGC on the fly tracking calibration for Channel 0 - AGCTrackingChannel0 = true; - %AGCTrackingChannel1 AGC Tracking Channel 1 + AGCTrackingChannel0 = true + % AGCTrackingChannel1 AGC Tracking Channel 1 % AGC on the fly tracking calibration for Channel 1 - AGCTrackingChannel1 = true; - - %BBDCRejectionTrackingChannel0 BBDC Rejection Tracking Channel 0 + AGCTrackingChannel1 = true + + % BBDCRejectionTrackingChannel0 BBDC Rejection Tracking Channel 0 % Baseband DC rejection on the fly tracking calibration for % Channel 0 - BBDCRejectionTrackingChannel0 = true; - %BBDCRejectionTrackingChannel1 BBDC Rejection Tracking Channel 1 + BBDCRejectionTrackingChannel0 = true + % BBDCRejectionTrackingChannel1 BBDC Rejection Tracking Channel 1 % Baseband DC rejection on the fly tracking calibration for % Channel 1 - BBDCRejectionTrackingChannel1 = true; - - %HDTrackingChannel0 HD Tracking Channel 0 + BBDCRejectionTrackingChannel1 = true + + % HDTrackingChannel0 HD Tracking Channel 0 % Harmonic Distortion on the fly tracking calibration for Channel % 0 - HDTrackingChannel0 = true; - %HDTrackingChannel1 HD Tracking Channel 1 + HDTrackingChannel0 = true + % HDTrackingChannel1 HD Tracking Channel 1 % Harmonic Distortion on the fly tracking calibration for Channel % 1 - HDTrackingChannel1 = true; - - %QuadratureFICTrackingChannel0 Quadrature FIC Tracking Channel 0 + HDTrackingChannel1 = true + + % QuadratureFICTrackingChannel0 Quadrature FIC Tracking Channel 0 % Quadrature Error Correction Narrowband FIC on the fly tracking % calibration for channel 0 - QuadratureFICTrackingChannel0 = true; - %QuadratureFICTrackingChannel1 Quadrature FIC Tracking Channel 1 + QuadratureFICTrackingChannel0 = true + % QuadratureFICTrackingChannel1 Quadrature FIC Tracking Channel 1 % Quadrature Error Correction Narrowband FIC on the fly tracking % calibration for channel 1 - QuadratureFICTrackingChannel1 = true; - - %QuadratureWidebandPolyTrackingChannel0 Quadrature Wideband Poly Tracking Channel 0 + QuadratureFICTrackingChannel1 = true + + % QuadratureWidebandPolyTrackingChannel0 Quadrature Wideband Poly Tracking Channel 0 % Quadrature Error Correction Wideband Poly on the fly tracking % calibration for channel 0 - QuadratureWidebandPolyTrackingChannel0 = true; - %QuadratureWidebandPolyTrackingChannel1 Quadrature Wideband Poly Tracking Channel 1 + QuadratureWidebandPolyTrackingChannel0 = true + % QuadratureWidebandPolyTrackingChannel1 Quadrature Wideband Poly Tracking Channel 1 % Quadrature Error Correction Wideband Poly on the fly tracking % calibration for channel 1 - QuadratureWidebandPolyTrackingChannel1 = true; - - %RFDCTrackingChannel0 RF DC Tracking Channel 0 + QuadratureWidebandPolyTrackingChannel1 = true + + % RFDCTrackingChannel0 RF DC Tracking Channel 0 % RF DC on the fly tracking calibration for channel 0 - RFDCTrackingChannel0 = true; - %RFDCTrackingChannel1 RF DC Tracking Channel 1 + RFDCTrackingChannel0 = true + % RFDCTrackingChannel1 RF DC Tracking Channel 1 % RF DC on the fly tracking calibration for channel 1 - RFDCTrackingChannel1 = true; - - %RSSITrackingChannel0 RSSI Tracking Channel 0 + RFDCTrackingChannel1 = true + + % RSSITrackingChannel0 RSSI Tracking Channel 0 % RSSI on the fly tracking calibration for channel 0 - RSSITrackingChannel0 = true; - %RSSITrackingChannel1 RSSI Tracking Channel 1 + RSSITrackingChannel0 = true + % RSSITrackingChannel1 RSSI Tracking Channel 1 % RSSI on the fly tracking calibration for channel 1 - RSSITrackingChannel1 = true; + RSSITrackingChannel1 = true end - + properties (Dependent) - %RSSIChannel0 RSSI Channel 0 + % RSSIChannel0 RSSI Channel 0 % Received signal strength indicator. This valid is only valid % once the object has been stepped and MATLAB connects to % hardware RSSIChannel0 - %RSSIChannel1 RSSI Channel 1 + % RSSIChannel1 RSSI Channel 1 % Received signal strength indicator. This valid is only valid % once the object has been stepped and MATLAB connects to % hardware RSSIChannel1 end - properties(Constant, Hidden) + properties (Constant, Hidden) ENSMModeChannel0Set = matlab.system.StringSet({ ... - 'calibrated','primed','rf_enabled'}); + 'calibrated', 'primed', 'rf_enabled'}) ENSMModeChannel1Set = matlab.system.StringSet({ ... - 'calibrated','primed','rf_enabled'}); - + 'calibrated', 'primed', 'rf_enabled'}) + ENSMPortModeChannel0Set = matlab.system.StringSet({ ... - 'spi','pin'}); + 'spi', 'pin'}) ENSMPortModeChannel1Set = matlab.system.StringSet({ ... - 'spi','pin'}); - + 'spi', 'pin'}) + GainControllerSourceChannel0Set = matlab.system.StringSet({ ... - 'spi','pin','automatic'}); + 'spi', 'pin', 'automatic'}) GainControllerSourceChannel1Set = matlab.system.StringSet({ ... - 'spi','pin','automatic'}); + 'spi', 'pin', 'automatic'}) DigitalGainControlModeChannel0Set = matlab.system.StringSet({ ... - 'automatic','spi'}); + 'automatic', 'spi'}) DigitalGainControlModeChannel1Set = matlab.system.StringSet({ ... - 'automatic','spi'}); - - InterfaceGainChannel0Set = matlab.system.StringSet({... - '18dB', '12dB', '6dB', '0dB', '-6dB', '-12dB', '-18dB',... - '-24dB', '-30dB','-36dB'}); - InterfaceGainChannel1Set = matlab.system.StringSet({... - '18dB', '12dB', '6dB', '0dB', '-6dB', '-12dB', '-18dB',... - '-24dB', '-30dB','-36dB'}); + 'automatic', 'spi'}) + + InterfaceGainChannel0Set = matlab.system.StringSet({ ... + '18dB', '12dB', '6dB', '0dB', '-6dB', '-12dB', '-18dB', ... + '-24dB', '-30dB', '-36dB'}) + InterfaceGainChannel1Set = matlab.system.StringSet({ ... + '18dB', '12dB', '6dB', '0dB', '-6dB', '-12dB', '-18dB', ... + '-24dB', '-30dB', '-36dB'}) end - - properties(Hidden) + + properties (Hidden) InterfaceGainAvailableChannel0 InterfaceGainAvailableChannel1 end properties (Hidden, Nontunable, Access = protected) - isOutput = false; + isOutput = false end - - properties(Nontunable, Hidden, Constant) - Type = 'Rx'; + + properties (Nontunable, Hidden, Constant) + Type = 'Rx' end - + properties (Nontunable, Hidden) - devName = 'axi-adrv9002-rx-lpc'; - channel_names = {'voltage0_i','voltage0_q','voltage1_i','voltage1_q'}; + devName = 'axi-adrv9002-rx-lpc' + channel_names = {'voltage0_i', 'voltage0_q', 'voltage1_i', 'voltage1_q'} end - + methods + %% Constructor function obj = Rx(varargin) coder.allowpcode('plain'); obj = obj@adi.ADRV9002.Base(varargin{:}); end - + function value = get.RSSIChannel0(obj) if obj.ConnectedToDevice - value = obj.getAttributeDouble('voltage0','rssi',false); + value = obj.getAttributeDouble('voltage0', 'rssi', false); else value = NaN; end end + function value = get.RSSIChannel1(obj) if obj.ConnectedToDevice - value = obj.getAttributeDouble('voltage1','rssi',false); + value = obj.getAttributeDouble('voltage1', 'rssi', false); else value = NaN; end end + function values = get.InterfaceGainAvailableChannel0(obj) if obj.ConnectedToDevice - values = obj.getAttributeRAW('voltage0','interface_gain_available',false); + values = obj.getAttributeRAW('voltage0', 'interface_gain_available', false); values = strsplit(values); else values = NaN; end end + function values = get.InterfaceGainAvailableChannel1(obj) if obj.ConnectedToDevice - values = obj.getAttributeRAW('voltage0','interface_gain_available',false); + values = obj.getAttributeRAW('voltage0', 'interface_gain_available', false); values = strsplit(values); else values = NaN; end end - + % Check ENSMModeChannel0 function set.ENSMModeChannel0(obj, value) obj.ENSMModeChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeRAW(id,'ensm_mode',value,false); + obj.setAttributeRAW(id, 'ensm_mode', value, false); end end + % Check ENSMModeChannel1 function set.ENSMModeChannel1(obj, value) obj.ENSMModeChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeRAW(id,'ensm_mode',value,false); + obj.setAttributeRAW(id, 'ensm_mode', value, false); end end - + % Check ENSMPortModeChannel0 function set.ENSMPortModeChannel0(obj, value) obj.ENSMPortModeChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeRAW(id,'port_en_mode',value,false); + obj.setAttributeRAW(id, 'port_en_mode', value, false); end end + % Check ENSMPortModeChannel1 function set.ENSMPortModeChannel1(obj, value) obj.ENSMPortModeChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeRAW(id,'port_en_mode',value,false); + obj.setAttributeRAW(id, 'port_en_mode', value, false); end end - + % Check GainControllerSourceChannel0 function set.GainControllerSourceChannel0(obj, value) obj.GainControllerSourceChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeRAW(id,'gain_control_mode',value,false); + obj.setAttributeRAW(id, 'gain_control_mode', value, false); end end + % Check GainControllerSourceChannel1 function set.GainControllerSourceChannel1(obj, value) obj.GainControllerSourceChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeRAW(id,'gain_control_mode',value,false); + obj.setAttributeRAW(id, 'gain_control_mode', value, false); end end - + % Check DigitalGainControlModeChannel0 function set.DigitalGainControlModeChannel0(obj, value) obj.DigitalGainControlModeChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeRAW(id,'digital_gain_control_mode',obj.DigitalGainControlModeChannel0,false); + obj.setAttributeRAW(id, 'digital_gain_control_mode', obj.DigitalGainControlModeChannel0, false); end end + % Check DigitalGainControlModeChannel1 function set.DigitalGainControlModeChannel1(obj, value) obj.DigitalGainControlModeChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeRAW(id,'digital_gain_control_mode',obj.DigitalGainControlModeChannel1,false); + obj.setAttributeRAW(id, 'digital_gain_control_mode', obj.DigitalGainControlModeChannel1, false); end end - + % Check Attenuation function set.AttenuationChannel0(obj, value) obj.AttenuationChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeDouble(id,'hardwaregain',value,false); + obj.setAttributeDouble(id, 'hardwaregain', value, false); end end + % Check Attenuation function set.AttenuationChannel1(obj, value) obj.AttenuationChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeDouble(id,'hardwaregain',value,false); + obj.setAttributeDouble(id, 'hardwaregain', value, false); end end - + % Check InterfaceGainChannel0 function set.InterfaceGainChannel0(obj, value) obj.InterfaceGainChannel0 = value; if obj.ConnectedToDevice - mustBeMember(value,obj.InterfaceGainAvailableChannel0); + mustBeMember(value, obj.InterfaceGainAvailableChannel0); id = 'voltage0'; - if strcmpi(obj.DigitalGainControlModeChannel0,'spi') &&... - strcmpi(obj.ENSMModeChannel0,'rf_enabled') - obj.setAttributeRAW(id,'interface_gain',value,false); + if strcmpi(obj.DigitalGainControlModeChannel0, 'spi') && ... + strcmpi(obj.ENSMModeChannel0, 'rf_enabled') + obj.setAttributeRAW(id, 'interface_gain', value, false); end end end + % Check InterfaceGainChannel1 function set.InterfaceGainChannel1(obj, value) obj.InterfaceGainChannel1 = value; if obj.ConnectedToDevice - mustBeMember(value,obj.InterfaceGainAvailableChannel1); + mustBeMember(value, obj.InterfaceGainAvailableChannel1); id = 'voltage1'; - if strcmpi(obj.DigitalGainControlModeChannel1,'spi') &&... - strcmpi(obj.ENSMModeChannel1,'rf_enabled') - obj.setAttributeRAW(id,'interface_gain',value,false); + if strcmpi(obj.DigitalGainControlModeChannel1, 'spi') && ... + strcmpi(obj.ENSMModeChannel1, 'rf_enabled') + obj.setAttributeRAW(id, 'interface_gain', value, false); end end end - + % Check AGCTrackingChannel0 function set.AGCTrackingChannel0(obj, value) obj.AGCTrackingChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'agc_tracking_en',value,false); + obj.setAttributeBool(id, 'agc_tracking_en', value, false); end end + % Check AGCTrackingChannel1 function set.AGCTrackingChannel1(obj, value) obj.AGCTrackingChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeBool(id,'agc_tracking_en',value,false); + obj.setAttributeBool(id, 'agc_tracking_en', value, false); end end @@ -430,198 +441,202 @@ obj.BBDCRejectionTrackingChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'bbdc_rejection_tracking_en',value,false); + obj.setAttributeBool(id, 'bbdc_rejection_tracking_en', value, false); end end + % Check BBDCRejectionTrackingChannel1 function set.BBDCRejectionTrackingChannel1(obj, value) obj.BBDCRejectionTrackingChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeBool(id,'bbdc_rejection_tracking_en',value,false); + obj.setAttributeBool(id, 'bbdc_rejection_tracking_en', value, false); end end - + % Check HDTrackingChannel0 function set.HDTrackingChannel0(obj, value) obj.HDTrackingChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'hd_tracking_en',value,false); + obj.setAttributeBool(id, 'hd_tracking_en', value, false); end end + % Check HDTrackingChannel1 function set.HDTrackingChannel1(obj, value) obj.HDTrackingChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeBool(id,'hd_tracking_en',value,false); + obj.setAttributeBool(id, 'hd_tracking_en', value, false); end end - + % Check QuadratureFICTrackingChannel0 function set.QuadratureFICTrackingChannel0(obj, value) obj.QuadratureFICTrackingChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'quadrature_fic_tracking_en',value,false); + obj.setAttributeBool(id, 'quadrature_fic_tracking_en', value, false); end end + % Check QuadratureFICTrackingChannel1 function set.QuadratureFICTrackingChannel1(obj, value) obj.QuadratureFICTrackingChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeBool(id,'quadrature_fic_tracking_en',value,false); + obj.setAttributeBool(id, 'quadrature_fic_tracking_en', value, false); end end - + % Check QuadratureWidebandPolyTrackingChannel0 function set.QuadratureWidebandPolyTrackingChannel0(obj, value) obj.QuadratureWidebandPolyTrackingChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'quadrature_w_poly_tracking_en',value,false); + obj.setAttributeBool(id, 'quadrature_w_poly_tracking_en', value, false); end end + % Check QuadratureWidebandPolyTrackingChannel1 function set.QuadratureWidebandPolyTrackingChannel1(obj, value) obj.QuadratureWidebandPolyTrackingChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeBool(id,'quadrature_w_poly_tracking_en',value,false); + obj.setAttributeBool(id, 'quadrature_w_poly_tracking_en', value, false); end end - + % Check RFDCTrackingChannel0 function set.RFDCTrackingChannel0(obj, value) obj.RFDCTrackingChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'rfdc_tracking_en',value,false); + obj.setAttributeBool(id, 'rfdc_tracking_en', value, false); end end + % Check RFDCTrackingChannel1 function set.RFDCTrackingChannel1(obj, value) obj.RFDCTrackingChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeBool(id,'rfdc_tracking_en',value,false); + obj.setAttributeBool(id, 'rfdc_tracking_en', value, false); end end - + % Check RSSITrackingChannel0 function set.RSSITrackingChannel0(obj, value) obj.RSSITrackingChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'rssi_tracking_en',value,false); + obj.setAttributeBool(id, 'rssi_tracking_en', value, false); end end + % Check RSSITrackingChannel1 function set.RSSITrackingChannel1(obj, value) obj.RSSITrackingChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeBool(id,'rssi_tracking_en',value,false); + obj.setAttributeBool(id, 'rssi_tracking_en', value, false); end end - + end - + %% API Functions methods (Hidden, Access = protected) - + function setupInit(obj) % Write all attributes to device once connected through set % methods % Do writes directly to hardware without using set methods. % This is required sine Simulink support doesn't support % modification to nontunable variables at SetupImpl - + % Handle split vs MIMO buffer case if obj.checkIfDevExists('axi-adrv9002-rx2-lpc') % This naming is a bit strange due to the internal indexing % but duplicated channel names make it work obj.channel_names = ... - {'voltage0_i','voltage0_q',... - 'voltage0_i','voltage0_q'}; + {'voltage0_i', 'voltage0_q', ... + 'voltage0_i', 'voltage0_q'}; % Update - if numel(obj.EnabledChannels)>1 - error(['Driver is in split DMA mode (two separate DMAs axi-adrv9002-rx-lpc and axi-adrv9002-rx2-lpc)',newline,... - 'Only available options for EnabledChannels are:',newline,... - ' [1],[2]']); + if numel(obj.EnabledChannels) > 1 + error(['Driver is in split DMA mode (two separate DMAs axi-adrv9002-rx-lpc and axi-adrv9002-rx2-lpc)', newline, ... + 'Only available options for EnabledChannels are:', newline, ... + ' [1],[2]']); end - if any(obj.EnabledChannels==2) + if any(obj.EnabledChannels == 2) obj.devName = 'axi-adrv9002-rx2-lpc'; obj.iioDev = obj.getDev(obj.devName); end else obj.channel_names = ... - {'voltage0_i','voltage0_q','voltage1_i','voltage1_q'}; + {'voltage0_i', 'voltage0_q', 'voltage1_i', 'voltage1_q'}; end - - + if obj.EnableCustomProfile writeProfileFile(obj); end - + % Check if channel exists with new profile phydev = getDev(obj, obj.phyDevName); chanPtr = iio_device_find_channel(obj, phydev, 'voltage1', false); - status = cPtrCheck(obj,chanPtr); + status = cPtrCheck(obj, chanPtr); if status ~= 0 - error("Cannot find channel voltage1") + error("Cannot find channel voltage1"); end - [status, rValue] = iio_channel_attr_read(obj,chanPtr,'ensm_mode',1024); + [status, rValue] = iio_channel_attr_read(obj, chanPtr, 'ensm_mode', 1024); if status == -19 channelsAval = 1; elseif status < 0 - cstatus(obj,rValue,'Attribute read failed for : ensm_mode'); + cstatus(obj, rValue, 'Attribute read failed for : ensm_mode'); else channelsAval = 2; end - + % Check if property naming updated for LOs frequency vs % XLOX_frequency obj.checkDriverAPI(); - obj.setAttributeRAW('voltage0','ensm_mode',obj.ENSMModeChannel0,false); + obj.setAttributeRAW('voltage0', 'ensm_mode', obj.ENSMModeChannel0, false); if channelsAval == 2 - obj.setAttributeRAW('voltage1','ensm_mode',obj.ENSMModeChannel1,false); + obj.setAttributeRAW('voltage1', 'ensm_mode', obj.ENSMModeChannel1, false); end - obj.setAttributeRAW('voltage0','gain_control_mode',obj.GainControllerSourceChannel0,false); + obj.setAttributeRAW('voltage0', 'gain_control_mode', obj.GainControllerSourceChannel0, false); if channelsAval == 2 - obj.setAttributeRAW('voltage1','gain_control_mode',obj.GainControllerSourceChannel1,false); + obj.setAttributeRAW('voltage1', 'gain_control_mode', obj.GainControllerSourceChannel1, false); end - obj.setAttributeRAW('voltage0','digital_gain_control_mode',obj.DigitalGainControlModeChannel0,false); + obj.setAttributeRAW('voltage0', 'digital_gain_control_mode', obj.DigitalGainControlModeChannel0, false); if channelsAval == 2 - obj.setAttributeRAW('voltage1','digital_gain_control_mode',obj.DigitalGainControlModeChannel1,false); + obj.setAttributeRAW('voltage1', 'digital_gain_control_mode', obj.DigitalGainControlModeChannel1, false); end - if strcmpi(obj.DigitalGainControlModeChannel0,'spi') && strcmpi(obj.ENSMModeChannel0,'rf_enabled') - mustBeMember(obj.InterfaceGainChannel0,obj.InterfaceGainAvailableChannel0); - obj.setAttributeRAW('voltage0','interface_gain',obj.InterfaceGainChannel0,false); + if strcmpi(obj.DigitalGainControlModeChannel0, 'spi') && strcmpi(obj.ENSMModeChannel0, 'rf_enabled') + mustBeMember(obj.InterfaceGainChannel0, obj.InterfaceGainAvailableChannel0); + obj.setAttributeRAW('voltage0', 'interface_gain', obj.InterfaceGainChannel0, false); end - - if strcmpi(obj.DigitalGainControlModeChannel1,'spi') && strcmpi(obj.ENSMModeChannel1,'rf_enabled') && channelsAval == 2 - mustBeMember(obj.InterfaceGainChannel1,obj.InterfaceGainAvailableChannel1); - obj.setAttributeRAW('voltage1','interface_gain',obj.InterfaceGainChannel1,false); - end - - - obj.setAttributeRAW('voltage0','port_en_mode',obj.ENSMPortModeChannel0,false); + + if strcmpi(obj.DigitalGainControlModeChannel1, 'spi') && strcmpi(obj.ENSMModeChannel1, 'rf_enabled') && channelsAval == 2 + mustBeMember(obj.InterfaceGainChannel1, obj.InterfaceGainAvailableChannel1); + obj.setAttributeRAW('voltage1', 'interface_gain', obj.InterfaceGainChannel1, false); + end + + obj.setAttributeRAW('voltage0', 'port_en_mode', obj.ENSMPortModeChannel0, false); if channelsAval == 2 - obj.setAttributeRAW('voltage1','port_en_mode',obj.ENSMPortModeChannel0,false); + obj.setAttributeRAW('voltage1', 'port_en_mode', obj.ENSMPortModeChannel0, false); end - - if strcmpi(obj.GainControllerSourceChannel0,'spi') - obj.setAttributeDouble('voltage0','hardwaregain',obj.AttenuationChannel0,false); + + if strcmpi(obj.GainControllerSourceChannel0, 'spi') + obj.setAttributeDouble('voltage0', 'hardwaregain', obj.AttenuationChannel0, false); end - if strcmpi(obj.GainControllerSourceChannel1,'spi') && channelsAval == 2 - obj.setAttributeDouble('voltage1','hardwaregain',obj.AttenuationChannel1,false); + if strcmpi(obj.GainControllerSourceChannel1, 'spi') && channelsAval == 2 + obj.setAttributeDouble('voltage1', 'hardwaregain', obj.AttenuationChannel1, false); end if obj.newAPI @@ -631,91 +646,90 @@ function setupInit(obj) name1 = 'RX1_LO_frequency'; name2 = 'RX2_LO_frequency'; end - obj.setAttributeLongLong('altvoltage0',name1,obj.CenterFrequencyChannel0 ,true); + obj.setAttributeLongLong('altvoltage0', name1, obj.CenterFrequencyChannel0, true); if channelsAval == 2 - obj.setAttributeLongLong('altvoltage1',name2,obj.CenterFrequencyChannel1 ,true); + obj.setAttributeLongLong('altvoltage1', name2, obj.CenterFrequencyChannel1, true); end - + % Calibrations - agc_tracking_en_voltage0_state = obj.getAttributeBool('voltage0','agc_tracking_en',false); - if (agc_tracking_en_voltage0_state ~= obj.AGCTrackingChannel0) - obj.setAttributeBool('voltage0','agc_tracking_en',obj.AGCTrackingChannel0,false); + agc_tracking_en_voltage0_state = obj.getAttributeBool('voltage0', 'agc_tracking_en', false); + if agc_tracking_en_voltage0_state ~= obj.AGCTrackingChannel0 + obj.setAttributeBool('voltage0', 'agc_tracking_en', obj.AGCTrackingChannel0, false); end if channelsAval == 2 - agc_tracking_en_voltage1_state = obj.getAttributeBool('voltage1','agc_tracking_en',false); - if (agc_tracking_en_voltage1_state ~= obj.AGCTrackingChannel1) - obj.setAttributeBool('voltage1','agc_tracking_en',obj.AGCTrackingChannel1,false); - end + agc_tracking_en_voltage1_state = obj.getAttributeBool('voltage1', 'agc_tracking_en', false); + if agc_tracking_en_voltage1_state ~= obj.AGCTrackingChannel1 + obj.setAttributeBool('voltage1', 'agc_tracking_en', obj.AGCTrackingChannel1, false); + end end - bbdc_rejection_tracking_en_voltage0_state = obj.getAttributeBool('voltage0','bbdc_rejection_tracking_en',false); - if (bbdc_rejection_tracking_en_voltage0_state ~= obj.BBDCRejectionTrackingChannel0) - obj.setAttributeBool('voltage0','bbdc_rejection_tracking_en',obj.BBDCRejectionTrackingChannel0,false); + bbdc_rejection_tracking_en_voltage0_state = obj.getAttributeBool('voltage0', 'bbdc_rejection_tracking_en', false); + if bbdc_rejection_tracking_en_voltage0_state ~= obj.BBDCRejectionTrackingChannel0 + obj.setAttributeBool('voltage0', 'bbdc_rejection_tracking_en', obj.BBDCRejectionTrackingChannel0, false); end if channelsAval == 2 - bbdc_rejection_tracking_en_voltage1_state = obj.getAttributeBool('voltage1','bbdc_rejection_tracking_en',false); - if (bbdc_rejection_tracking_en_voltage1_state ~= obj.BBDCRejectionTrackingChannel1) && channelsAval == 2 - obj.setAttributeBool('voltage1','bbdc_rejection_tracking_en',obj.BBDCRejectionTrackingChannel1,false); - end + bbdc_rejection_tracking_en_voltage1_state = obj.getAttributeBool('voltage1', 'bbdc_rejection_tracking_en', false); + if (bbdc_rejection_tracking_en_voltage1_state ~= obj.BBDCRejectionTrackingChannel1) && channelsAval == 2 + obj.setAttributeBool('voltage1', 'bbdc_rejection_tracking_en', obj.BBDCRejectionTrackingChannel1, false); + end end - hd_tracking_en_voltage0_state = obj.getAttributeBool('voltage0','hd_tracking_en',false); - if (hd_tracking_en_voltage0_state ~= obj.HDTrackingChannel0) - obj.setAttributeBool('voltage0','hd_tracking_en',obj.HDTrackingChannel0,false); + hd_tracking_en_voltage0_state = obj.getAttributeBool('voltage0', 'hd_tracking_en', false); + if hd_tracking_en_voltage0_state ~= obj.HDTrackingChannel0 + obj.setAttributeBool('voltage0', 'hd_tracking_en', obj.HDTrackingChannel0, false); end if channelsAval == 2 - hd_tracking_en_voltage1_state = obj.getAttributeBool('voltage1','hd_tracking_en',false); - if (hd_tracking_en_voltage1_state ~= obj.HDTrackingChannel1) && channelsAval == 2 - obj.setAttributeBool('voltage1','hd_tracking_en',obj.HDTrackingChannel1,false); - end + hd_tracking_en_voltage1_state = obj.getAttributeBool('voltage1', 'hd_tracking_en', false); + if (hd_tracking_en_voltage1_state ~= obj.HDTrackingChannel1) && channelsAval == 2 + obj.setAttributeBool('voltage1', 'hd_tracking_en', obj.HDTrackingChannel1, false); + end end - quadrature_fic_tracking_en_voltage0_state = obj.getAttributeBool('voltage0','quadrature_fic_tracking_en',false); - if (quadrature_fic_tracking_en_voltage0_state ~= obj.QuadratureFICTrackingChannel0) - obj.setAttributeBool('voltage0','quadrature_fic_tracking_en',obj.QuadratureFICTrackingChannel0,false); + quadrature_fic_tracking_en_voltage0_state = obj.getAttributeBool('voltage0', 'quadrature_fic_tracking_en', false); + if quadrature_fic_tracking_en_voltage0_state ~= obj.QuadratureFICTrackingChannel0 + obj.setAttributeBool('voltage0', 'quadrature_fic_tracking_en', obj.QuadratureFICTrackingChannel0, false); end if channelsAval == 2 - quadrature_fic_tracking_en_voltage1_state = obj.getAttributeBool('voltage1','quadrature_fic_tracking_en',false); - if (quadrature_fic_tracking_en_voltage1_state ~= obj.QuadratureFICTrackingChannel1) && channelsAval == 2 - obj.setAttributeBool('voltage1','quadrature_fic_tracking_en',obj.QuadratureFICTrackingChannel1,false); - end + quadrature_fic_tracking_en_voltage1_state = obj.getAttributeBool('voltage1', 'quadrature_fic_tracking_en', false); + if (quadrature_fic_tracking_en_voltage1_state ~= obj.QuadratureFICTrackingChannel1) && channelsAval == 2 + obj.setAttributeBool('voltage1', 'quadrature_fic_tracking_en', obj.QuadratureFICTrackingChannel1, false); + end end - quadrature_w_poly_tracking_en_voltage0_state = obj.getAttributeBool('voltage0','quadrature_w_poly_tracking_en',false); - if (quadrature_w_poly_tracking_en_voltage0_state ~= obj.QuadratureWidebandPolyTrackingChannel0) - obj.setAttributeBool('voltage0','quadrature_w_poly_tracking_en',obj.QuadratureWidebandPolyTrackingChannel0,false); + quadrature_w_poly_tracking_en_voltage0_state = obj.getAttributeBool('voltage0', 'quadrature_w_poly_tracking_en', false); + if quadrature_w_poly_tracking_en_voltage0_state ~= obj.QuadratureWidebandPolyTrackingChannel0 + obj.setAttributeBool('voltage0', 'quadrature_w_poly_tracking_en', obj.QuadratureWidebandPolyTrackingChannel0, false); end if channelsAval == 2 - quadrature_w_poly_tracking_en_voltage1_state = obj.getAttributeBool('voltage1','quadrature_w_poly_tracking_en',false); - if (quadrature_w_poly_tracking_en_voltage1_state ~= obj.QuadratureWidebandPolyTrackingChannel1) && channelsAval == 2 - obj.setAttributeBool('voltage1','quadrature_w_poly_tracking_en',obj.QuadratureWidebandPolyTrackingChannel1,false); - end + quadrature_w_poly_tracking_en_voltage1_state = obj.getAttributeBool('voltage1', 'quadrature_w_poly_tracking_en', false); + if (quadrature_w_poly_tracking_en_voltage1_state ~= obj.QuadratureWidebandPolyTrackingChannel1) && channelsAval == 2 + obj.setAttributeBool('voltage1', 'quadrature_w_poly_tracking_en', obj.QuadratureWidebandPolyTrackingChannel1, false); + end end - rfdc_tracking_en_voltage0_state = obj.getAttributeBool('voltage0','rfdc_tracking_en',false); - if (rfdc_tracking_en_voltage0_state ~= obj.RFDCTrackingChannel0) - obj.setAttributeBool('voltage0','rfdc_tracking_en',obj.RFDCTrackingChannel0,false); + rfdc_tracking_en_voltage0_state = obj.getAttributeBool('voltage0', 'rfdc_tracking_en', false); + if rfdc_tracking_en_voltage0_state ~= obj.RFDCTrackingChannel0 + obj.setAttributeBool('voltage0', 'rfdc_tracking_en', obj.RFDCTrackingChannel0, false); end if channelsAval == 2 - rfdc_tracking_en_voltage1_state = obj.getAttributeBool('voltage1','rfdc_tracking_en',false); - if (rfdc_tracking_en_voltage1_state ~= obj.RFDCTrackingChannel1) && channelsAval == 2 - obj.setAttributeBool('voltage1','rfdc_tracking_en',obj.RFDCTrackingChannel1,false); - end + rfdc_tracking_en_voltage1_state = obj.getAttributeBool('voltage1', 'rfdc_tracking_en', false); + if (rfdc_tracking_en_voltage1_state ~= obj.RFDCTrackingChannel1) && channelsAval == 2 + obj.setAttributeBool('voltage1', 'rfdc_tracking_en', obj.RFDCTrackingChannel1, false); + end end - rssi_tracking_en_voltage0_state = obj.getAttributeBool('voltage0','rssi_tracking_en',false); - if (rssi_tracking_en_voltage0_state ~= obj.RSSITrackingChannel0) - obj.setAttributeBool('voltage0','rssi_tracking_en',obj.RSSITrackingChannel0,false); + rssi_tracking_en_voltage0_state = obj.getAttributeBool('voltage0', 'rssi_tracking_en', false); + if rssi_tracking_en_voltage0_state ~= obj.RSSITrackingChannel0 + obj.setAttributeBool('voltage0', 'rssi_tracking_en', obj.RSSITrackingChannel0, false); end if channelsAval == 2 - rssi_tracking_en_voltage1_state = obj.getAttributeBool('voltage1','rssi_tracking_en',false); - if (rssi_tracking_en_voltage1_state ~= obj.RSSITrackingChannel1) && channelsAval == 2 - obj.setAttributeBool('voltage1','rssi_tracking_en',obj.RSSITrackingChannel1,false); - end + rssi_tracking_en_voltage1_state = obj.getAttributeBool('voltage1', 'rssi_tracking_en', false); + if (rssi_tracking_en_voltage1_state ~= obj.RSSITrackingChannel1) && channelsAval == 2 + obj.setAttributeBool('voltage1', 'rssi_tracking_en', obj.RSSITrackingChannel1, false); + end end end - + end - -end +end diff --git a/+adi/+ADRV9002/Tx.m b/+adi/+ADRV9002/Tx.m index 32f3c4eb..2c6a17c1 100644 --- a/+adi/+ADRV9002/Tx.m +++ b/+adi/+ADRV9002/Tx.m @@ -8,354 +8,366 @@ % % Significant configuration of the transceiver is done by loading profiles % created through the Transceiver Evaluation Software (TES). This includes - % settings such as sample rate, bandwidth, data interface format, and TDD + % settings such as sample rate, bandwidth, data interface format, and TDD % or FDD operation. For more information on creating and loading profiles, % refer to the ADRV9002 documentation. % % ADRV9002 Datasheet - + properties - %ENSMModeChannel0 Enable State Machine Mode Channel 0 + % ENSMModeChannel0 Enable State Machine Mode Channel 0 % specified as one of the following: % 'calibrated' % 'primed' % 'rf_enabled' - ENSMModeChannel0 = 'rf_enabled'; - %ENSMModeModeChannel1 Enable State Machine Mode Channel 1 + ENSMModeChannel0 = 'rf_enabled' + % ENSMModeModeChannel1 Enable State Machine Mode Channel 1 % specified as one of the following: % 'calibrated' % 'primed' % 'rf_enabled' - ENSMModeChannel1 = 'rf_enabled'; - - %AttenuationChannel0 Attenuation Channel 0 + ENSMModeChannel1 = 'rf_enabled' + + % AttenuationChannel0 Attenuation Channel 0 % Attenuation specified as a scalar from -89.75 to 0 dB with a % resolution of 0.25 dB. - AttenuationChannel0 = -30; - %AttenuationChannel1 Attenuation Channel 1 + AttenuationChannel0 = -30 + % AttenuationChannel1 Attenuation Channel 1 % Attenuation specified as a scalar from -89.75 to 0 dB with a % resolution of 0.25 dB. - AttenuationChannel1 = -30; - - %AttenuationControlModeChannel0 Attenuation Control Mode Channel 0 + AttenuationChannel1 = -30 + + % AttenuationControlModeChannel0 Attenuation Control Mode Channel 0 % Control attenuation through: % - bypass % - spi % - pin - AttenuationControlModeChannel0 = 'spi'; - %AttenuationControlModeChannel0 Attenuation Control Mode Channel 1 + AttenuationControlModeChannel0 = 'spi' + % AttenuationControlModeChannel0 Attenuation Control Mode Channel 1 % Control attenuation through: % - bypass % - spi % - pin - AttenuationControlModeChannel1 = 'spi'; - - %PortEnableControlChannel0 Port Enable Control Channel 0 + AttenuationControlModeChannel1 = 'spi' + + % PortEnableControlChannel0 Port Enable Control Channel 0 % specified as one of the following: % 'spi' % 'pin' - PortEnableControlChannel0 = 'spi'; - %PortEnableControlChannel1 Port Enable Control Channel 1 + PortEnableControlChannel0 = 'spi' + % PortEnableControlChannel1 Port Enable Control Channel 1 % specified as one of the following: % 'spi' % 'pin' - PortEnableControlChannel1 = 'spi'; + PortEnableControlChannel1 = 'spi' end properties (Logical) % ADVANCED - %ClosedLoopTrackingChannel0 Closed Loop Tracking Channel 0 - ClosedLoopTrackingChannel0 = true; - %ClosedLoopTrackingChannel1 Closed Loop Tracking Channel 1 - ClosedLoopTrackingChannel1 = true; - - %LOLeakageTrackingChannel0 LO Leakage Tracking Channel 0 - LOLeakageTrackingChannel0 = true; - %LOLeakageTrackingChannel1 LO Leakage Tracking Channel 1 - LOLeakageTrackingChannel1 = true; - - %LoopbackDelayTrackingChannel0 Loopback Delay Tracking Channel 0 - LoopbackDelayTrackingChannel0 = false; - %LoopbackDelayTrackingChannel1 Loopback Delay Tracking Channel 1 - LoopbackDelayTrackingChannel1 = false; - - %PACorrectionTrackingChannel0 PA Correction Tracking Channel 0 - PACorrectionTrackingChannel0 = false; - %PACorrectionTrackingChannel1 PA Correction Tracking Channel 1 - PACorrectionTrackingChannel1 = false; - - %QuadratureTrackingChannel0 Quadrature Tracking Channel 0 + % ClosedLoopTrackingChannel0 Closed Loop Tracking Channel 0 + ClosedLoopTrackingChannel0 = true + % ClosedLoopTrackingChannel1 Closed Loop Tracking Channel 1 + ClosedLoopTrackingChannel1 = true + + % LOLeakageTrackingChannel0 LO Leakage Tracking Channel 0 + LOLeakageTrackingChannel0 = true + % LOLeakageTrackingChannel1 LO Leakage Tracking Channel 1 + LOLeakageTrackingChannel1 = true + + % LoopbackDelayTrackingChannel0 Loopback Delay Tracking Channel 0 + LoopbackDelayTrackingChannel0 = false + % LoopbackDelayTrackingChannel1 Loopback Delay Tracking Channel 1 + LoopbackDelayTrackingChannel1 = false + + % PACorrectionTrackingChannel0 PA Correction Tracking Channel 0 + PACorrectionTrackingChannel0 = false + % PACorrectionTrackingChannel1 PA Correction Tracking Channel 1 + PACorrectionTrackingChannel1 = false + + % QuadratureTrackingChannel0 Quadrature Tracking Channel 0 % Quadrature Error Correction on the fly tracking % calibration for channel 0 - QuadratureTrackingChannel0 = true; - %QuadratureTrackingEnableChannel1 Quadrature Tracking Channel 1 + QuadratureTrackingChannel0 = true + % QuadratureTrackingEnableChannel1 Quadrature Tracking Channel 1 % Quadrature Error Correction on the fly tracking % calibration for channel 1 - QuadratureTrackingChannel1 = true; - -% %PowerdownChannel0 Powerdown Channel 0 -% PowerdownChannel0 = false; -% -% %PowerdownChannel0 Powerdown Channel 1 -% PowerdownChannel1 = false; + QuadratureTrackingChannel1 = true + + % %PowerdownChannel0 Powerdown Channel 0 + % PowerdownChannel0 = false; + % + % %PowerdownChannel0 Powerdown Channel 1 + % PowerdownChannel1 = false; end - - properties(Constant, Hidden) + + properties (Constant, Hidden) ENSMModeChannel0Set = matlab.system.StringSet({ ... - 'calibrated','primed','rf_enabled'}); + 'calibrated', 'primed', 'rf_enabled'}) ENSMModeChannel1Set = matlab.system.StringSet({ ... - 'calibrated','primed','rf_enabled'}); - + 'calibrated', 'primed', 'rf_enabled'}) + PortEnableControlChannel0Set = matlab.system.StringSet({ ... - 'pin','spi'}); + 'pin', 'spi'}) PortEnableControlChannel1Set = matlab.system.StringSet({ ... - 'pin','spi'}); - + 'pin', 'spi'}) + AttenuationControlModeChannel0Set = matlab.system.StringSet({ ... - 'bypass','pin','spi'}); + 'bypass', 'pin', 'spi'}) AttenuationControlModeChannel1Set = matlab.system.StringSet({ ... - 'bypass','pin','spi'}); - + 'bypass', 'pin', 'spi'}) + end - + properties (Hidden, Nontunable, Access = protected) - isOutput = true; + isOutput = true end - - properties(Nontunable, Hidden, Constant) - Type = 'Tx'; + + properties (Nontunable, Hidden, Constant) + Type = 'Tx' end - - properties(Nontunable, Hidden) - channel_names = {'voltage0','voltage1','voltage2','voltage3'}; + + properties (Nontunable, Hidden) + channel_names = {'voltage0', 'voltage1', 'voltage2', 'voltage3'} end - + properties (Nontunable, Hidden) - devName = 'axi-adrv9002-tx-lpc'; + devName = 'axi-adrv9002-tx-lpc' end - + methods + %% Constructor function obj = Tx(varargin) coder.allowpcode('plain'); obj = obj@adi.ADRV9002.Base(varargin{:}); end + % Check AttentuationChannel0 function set.AttenuationChannel0(obj, value) obj.AttenuationChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeDouble(id,'hardwaregain',value,true); + obj.setAttributeDouble(id, 'hardwaregain', value, true); end end + % Check AttentuationChannel1 function set.AttenuationChannel1(obj, value) obj.AttenuationChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeDouble(id,'hardwaregain',value,true); + obj.setAttributeDouble(id, 'hardwaregain', value, true); end end + % Check ENSMModeChannel0 function set.ENSMModeChannel0(obj, value) obj.ENSMModeChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeRAW(id,'ensm_mode',value,true); + obj.setAttributeRAW(id, 'ensm_mode', value, true); end end + % Check ENSMModeChannel1 function set.ENSMModeChannel1(obj, value) obj.ENSMModeChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeRAW(id,'ensm_mode',value,true); + obj.setAttributeRAW(id, 'ensm_mode', value, true); end end - + % Check AttenuationControlModeChannel0 function set.AttenuationControlModeChannel0(obj, value) obj.AttenuationControlModeChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeRAW(id,'atten_control_mode',value,true); + obj.setAttributeRAW(id, 'atten_control_mode', value, true); end end + % Check AttenuationControlModeChannel1 function set.AttenuationControlModeChannel1(obj, value) obj.AttenuationControlModeChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeRAW(id,'atten_control_mode',value,true); + obj.setAttributeRAW(id, 'atten_control_mode', value, true); end end - + % Check PortEnableControlChannel0 function set.PortEnableControlChannel0(obj, value) obj.PortEnableControlChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeRAW(id,'port_en_mode',value,true); + obj.setAttributeRAW(id, 'port_en_mode', value, true); end end + % Check PortEnableControlChannel1 function set.PortEnableControlChannel1(obj, value) obj.PortEnableControlChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeRAW(id,'port_en_mode',value,true); + obj.setAttributeRAW(id, 'port_en_mode', value, true); end end - + % Check ClosedLoopTrackingChannel0 function set.ClosedLoopTrackingChannel0(obj, value) obj.ClosedLoopTrackingChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'close_loop_gain_tracking_en',value,true); + obj.setAttributeBool(id, 'close_loop_gain_tracking_en', value, true); end end + % Check ClosedLoopTrackingChannel1 function set.ClosedLoopTrackingChannel1(obj, value) obj.ClosedLoopTrackingChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeBool(id,'close_loop_gain_tracking_en',value,true); + obj.setAttributeBool(id, 'close_loop_gain_tracking_en', value, true); end end - + % Check LOLeakageTrackingChannel0 function set.LOLeakageTrackingChannel0(obj, value) obj.LOLeakageTrackingChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'lo_leakage_tracking_en',value,true); + obj.setAttributeBool(id, 'lo_leakage_tracking_en', value, true); end end + % Check LOLeakageTrackingChannel1 function set.LOLeakageTrackingChannel1(obj, value) obj.LOLeakageTrackingChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeBool(id,'lo_leakage_tracking_en',value,true); + obj.setAttributeBool(id, 'lo_leakage_tracking_en', value, true); end end - + % Check LoopbackDelayTrackingChannel0 function set.LoopbackDelayTrackingChannel0(obj, value) obj.LoopbackDelayTrackingChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'loopback_delay_tracking_en',value,true); + obj.setAttributeBool(id, 'loopback_delay_tracking_en', value, true); end end + % Check LoopbackDelayTrackingChannel1 function set.LoopbackDelayTrackingChannel1(obj, value) obj.LoopbackDelayTrackingChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeBool(id,'loopback_delay_tracking_en',value,true); + obj.setAttributeBool(id, 'loopback_delay_tracking_en', value, true); end end - + % Check PACorrectionTrackingChannel0 function set.PACorrectionTrackingChannel0(obj, value) obj.PACorrectionTrackingChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'pa_correction_tracking_en',value,true); + obj.setAttributeBool(id, 'pa_correction_tracking_en', value, true); end end + % Check PACorrectionTrackingChannel1 function set.PACorrectionTrackingChannel1(obj, value) obj.PACorrectionTrackingChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeBool(id,'pa_correction_tracking_en',value,true); + obj.setAttributeBool(id, 'pa_correction_tracking_en', value, true); end end - + % Check PACorrectionTrackingChannel0 function set.QuadratureTrackingChannel0(obj, value) obj.QuadratureTrackingChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'quadrature_tracking_en',value,true); + obj.setAttributeBool(id, 'quadrature_tracking_en', value, true); end end + % Check QuadratureTrackingChannel1 function set.QuadratureTrackingChannel1(obj, value) obj.QuadratureTrackingChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeBool(id,'quadrature_tracking_en',value,true); + obj.setAttributeBool(id, 'quadrature_tracking_en', value, true); end end - -% % Check PowerdownChannel0 -% function set.PowerdownChannel0(obj, value) -% obj.PowerdownChannel0 = value; -% if obj.ConnectedToDevice -% id = 'voltage0'; -% obj.setAttributeBool(id,'en',value,true); -% end -% end -% % Check PowerdownChannel1 -% function set.PowerdownChannel1(obj, value) -% obj.PowerdownChannel1 = value; -% if obj.ConnectedToDevice -% id = 'voltage1'; -% obj.setAttributeBool(id,'en',value,true); -% end -% end - + + % % Check PowerdownChannel0 + % function set.PowerdownChannel0(obj, value) + % obj.PowerdownChannel0 = value; + % if obj.ConnectedToDevice + % id = 'voltage0'; + % obj.setAttributeBool(id,'en',value,true); + % end + % end + % % Check PowerdownChannel1 + % function set.PowerdownChannel1(obj, value) + % obj.PowerdownChannel1 = value; + % if obj.ConnectedToDevice + % id = 'voltage1'; + % obj.setAttributeBool(id,'en',value,true); + % end + % end + end - + %% API Functions methods (Hidden, Access = protected) - + function setupInit(obj) % Write all attributes to device once connected through set % methods % Do writes directly to hardware without using set methods. % This is required sine Simulink support doesn't support % modification to nontunable variables at SetupImpl - + % Handle split vs MIMO buffer case if obj.checkIfDevExists('axi-adrv9002-tx2-lpc') % This naming is a bit strange due to the internal indexing % but duplicated channel names make it work obj.channel_names = ... - {'voltage0','voltage1',... - 'voltage0','voltage1'}; + {'voltage0', 'voltage1', ... + 'voltage0', 'voltage1'}; obj.dds_channel_names = ... - {'altvoltage0',... - 'altvoltage1',... - 'altvoltage2',... - 'altvoltage3'}; + {'altvoltage0', ... + 'altvoltage1', ... + 'altvoltage2', ... + 'altvoltage3'}; % Update - if numel(obj.EnabledChannels)>1 - error(['Driver is in split DMA mode (two separate DMAs axi-adrv9002-tx-lpc and axi-adrv9002-tx2-lpc)',newline,... - 'Only available options for EnabledChannels are:',newline,... - ' [1],[2]']); + if numel(obj.EnabledChannels) > 1 + error(['Driver is in split DMA mode (two separate DMAs axi-adrv9002-tx-lpc and axi-adrv9002-tx2-lpc)', newline, ... + 'Only available options for EnabledChannels are:', newline, ... + ' [1],[2]']); end - if any(obj.EnabledChannels==2) + if any(obj.EnabledChannels == 2) obj.devName = 'axi-adrv9002-tx2-lpc'; obj.iioDev = obj.getDev(obj.devName); end else obj.channel_names = ... - {'voltage0','voltage1','voltage2','voltage3'}; + {'voltage0', 'voltage1', 'voltage2', 'voltage3'}; obj.dds_channel_names = ... - {'altvoltage0',... - 'altvoltage1',... - 'altvoltage2',... - 'altvoltage3',... - 'altvoltage4',... - 'altvoltage5',... - 'altvoltage6',... - 'altvoltage7'}; - end - + {'altvoltage0', ... + 'altvoltage1', ... + 'altvoltage2', ... + 'altvoltage3', ... + 'altvoltage4', ... + 'altvoltage5', ... + 'altvoltage6', ... + 'altvoltage7'}; + end + if obj.EnableCustomProfile writeProfileFile(obj); end @@ -363,15 +375,15 @@ function setupInit(obj) % Check if channel exists with new profile phydev = getDev(obj, obj.phyDevName); chanPtr = iio_device_find_channel(obj, phydev, 'voltage1', true); - status = cPtrCheck(obj,chanPtr); + status = cPtrCheck(obj, chanPtr); if status ~= 0 - error("Cannot find channel voltage1") + error("Cannot find channel voltage1"); end - [status, rValue] = iio_channel_attr_read(obj,chanPtr,'ensm_mode',1024); + [status, rValue] = iio_channel_attr_read(obj, chanPtr, 'ensm_mode', 1024); if status == -19 channelsAval = 1; elseif status < 0 - cstatus(obj,rValue,'Attribute read failed for : ensm_mode'); + cstatus(obj, rValue, 'Attribute read failed for : ensm_mode'); else channelsAval = 2; end @@ -386,100 +398,99 @@ function setupInit(obj) else name1 = 'TX1_LO_frequency'; name2 = 'TX2_LO_frequency'; - end - obj.setAttributeLongLong('altvoltage2',name1,obj.CenterFrequencyChannel0 ,true); + end + obj.setAttributeLongLong('altvoltage2', name1, obj.CenterFrequencyChannel0, true); if channelsAval == 2 - obj.setAttributeLongLong('altvoltage3',name2,obj.CenterFrequencyChannel1 ,true); + obj.setAttributeLongLong('altvoltage3', name2, obj.CenterFrequencyChannel1, true); end - obj.setAttributeRAW('voltage0','ensm_mode',obj.ENSMModeChannel0,true); + obj.setAttributeRAW('voltage0', 'ensm_mode', obj.ENSMModeChannel0, true); if channelsAval == 2 - obj.setAttributeRAW('voltage1','ensm_mode',obj.ENSMModeChannel1,true); + obj.setAttributeRAW('voltage1', 'ensm_mode', obj.ENSMModeChannel1, true); end % Controls - obj.setAttributeRAW('voltage0','port_en_mode',obj.PortEnableControlChannel0,true); + obj.setAttributeRAW('voltage0', 'port_en_mode', obj.PortEnableControlChannel0, true); if channelsAval == 2 - obj.setAttributeRAW('voltage1','port_en_mode',obj.PortEnableControlChannel1,true); + obj.setAttributeRAW('voltage1', 'port_en_mode', obj.PortEnableControlChannel1, true); end - - obj.setAttributeRAW('voltage0','atten_control_mode',obj.AttenuationControlModeChannel0,true); + + obj.setAttributeRAW('voltage0', 'atten_control_mode', obj.AttenuationControlModeChannel0, true); if channelsAval == 2 - obj.setAttributeRAW('voltage1','atten_control_mode',obj.AttenuationControlModeChannel1,true); + obj.setAttributeRAW('voltage1', 'atten_control_mode', obj.AttenuationControlModeChannel1, true); end % Gains - obj.setAttributeDouble('voltage0','hardwaregain',obj.AttenuationChannel0,true); + obj.setAttributeDouble('voltage0', 'hardwaregain', obj.AttenuationChannel0, true); if channelsAval == 2 - obj.setAttributeDouble('voltage1','hardwaregain',obj.AttenuationChannel1,true); + obj.setAttributeDouble('voltage1', 'hardwaregain', obj.AttenuationChannel1, true); end - + % Calibrations - close_loop_gain_tracking_en_voltage0_state = obj.getAttributeBool('voltage0','close_loop_gain_tracking_en',true); - if (close_loop_gain_tracking_en_voltage0_state ~= obj.ClosedLoopTrackingChannel0) - obj.setAttributeBool('voltage0','close_loop_gain_tracking_en',obj.ClosedLoopTrackingChannel0,true); + close_loop_gain_tracking_en_voltage0_state = obj.getAttributeBool('voltage0', 'close_loop_gain_tracking_en', true); + if close_loop_gain_tracking_en_voltage0_state ~= obj.ClosedLoopTrackingChannel0 + obj.setAttributeBool('voltage0', 'close_loop_gain_tracking_en', obj.ClosedLoopTrackingChannel0, true); end if channelsAval == 2 - close_loop_gain_tracking_en_voltage1_state = obj.getAttributeBool('voltage1','close_loop_gain_tracking_en',true); - if (close_loop_gain_tracking_en_voltage1_state ~= obj.ClosedLoopTrackingChannel1) - obj.setAttributeBool('voltage1','close_loop_gain_tracking_en',obj.ClosedLoopTrackingChannel1,true); + close_loop_gain_tracking_en_voltage1_state = obj.getAttributeBool('voltage1', 'close_loop_gain_tracking_en', true); + if close_loop_gain_tracking_en_voltage1_state ~= obj.ClosedLoopTrackingChannel1 + obj.setAttributeBool('voltage1', 'close_loop_gain_tracking_en', obj.ClosedLoopTrackingChannel1, true); end end - lo_leakage_tracking_en_voltage0_state = obj.getAttributeBool('voltage0','lo_leakage_tracking_en',true); - if (lo_leakage_tracking_en_voltage0_state ~= obj.LOLeakageTrackingChannel0) - obj.setAttributeBool('voltage0','lo_leakage_tracking_en',obj.LOLeakageTrackingChannel0,true); + lo_leakage_tracking_en_voltage0_state = obj.getAttributeBool('voltage0', 'lo_leakage_tracking_en', true); + if lo_leakage_tracking_en_voltage0_state ~= obj.LOLeakageTrackingChannel0 + obj.setAttributeBool('voltage0', 'lo_leakage_tracking_en', obj.LOLeakageTrackingChannel0, true); end if channelsAval == 2 - lo_leakage_tracking_en_voltage1_state = obj.getAttributeBool('voltage1','lo_leakage_tracking_en',true); - if (lo_leakage_tracking_en_voltage1_state ~= obj.LOLeakageTrackingChannel1) - obj.setAttributeBool('voltage1','lo_leakage_tracking_en',obj.LOLeakageTrackingChannel1,true); + lo_leakage_tracking_en_voltage1_state = obj.getAttributeBool('voltage1', 'lo_leakage_tracking_en', true); + if lo_leakage_tracking_en_voltage1_state ~= obj.LOLeakageTrackingChannel1 + obj.setAttributeBool('voltage1', 'lo_leakage_tracking_en', obj.LOLeakageTrackingChannel1, true); end end - loopback_delay_tracking_en_voltage0_state = obj.getAttributeBool('voltage0','loopback_delay_tracking_en',true); - if (loopback_delay_tracking_en_voltage0_state ~= obj.LoopbackDelayTrackingChannel0) - obj.setAttributeBool('voltage0','loopback_delay_tracking_en',obj.LoopbackDelayTrackingChannel0,true); + loopback_delay_tracking_en_voltage0_state = obj.getAttributeBool('voltage0', 'loopback_delay_tracking_en', true); + if loopback_delay_tracking_en_voltage0_state ~= obj.LoopbackDelayTrackingChannel0 + obj.setAttributeBool('voltage0', 'loopback_delay_tracking_en', obj.LoopbackDelayTrackingChannel0, true); end if channelsAval == 2 - loopback_delay_tracking_en_voltage1_state = obj.getAttributeBool('voltage1','loopback_delay_tracking_en',true); - if (loopback_delay_tracking_en_voltage1_state ~= obj.LoopbackDelayTrackingChannel1) - obj.setAttributeBool('voltage1','loopback_delay_tracking_en',obj.LoopbackDelayTrackingChannel1,true); + loopback_delay_tracking_en_voltage1_state = obj.getAttributeBool('voltage1', 'loopback_delay_tracking_en', true); + if loopback_delay_tracking_en_voltage1_state ~= obj.LoopbackDelayTrackingChannel1 + obj.setAttributeBool('voltage1', 'loopback_delay_tracking_en', obj.LoopbackDelayTrackingChannel1, true); end end - - pa_correction_tracking_en_voltage0_state = obj.getAttributeBool('voltage0','pa_correction_tracking_en',true); - if (pa_correction_tracking_en_voltage0_state ~= obj.PACorrectionTrackingChannel0) - obj.setAttributeBool('voltage0','pa_correction_tracking_en',obj.PACorrectionTrackingChannel0,true); + + pa_correction_tracking_en_voltage0_state = obj.getAttributeBool('voltage0', 'pa_correction_tracking_en', true); + if pa_correction_tracking_en_voltage0_state ~= obj.PACorrectionTrackingChannel0 + obj.setAttributeBool('voltage0', 'pa_correction_tracking_en', obj.PACorrectionTrackingChannel0, true); end if channelsAval == 2 - pa_correction_tracking_en_voltage1_state = obj.getAttributeBool('voltage1','pa_correction_tracking_en',true); - if (pa_correction_tracking_en_voltage1_state ~= obj.PACorrectionTrackingChannel1) - obj.setAttributeBool('voltage1','pa_correction_tracking_en',obj.PACorrectionTrackingChannel1,true); + pa_correction_tracking_en_voltage1_state = obj.getAttributeBool('voltage1', 'pa_correction_tracking_en', true); + if pa_correction_tracking_en_voltage1_state ~= obj.PACorrectionTrackingChannel1 + obj.setAttributeBool('voltage1', 'pa_correction_tracking_en', obj.PACorrectionTrackingChannel1, true); end end - - quadrature_tracking_en_voltage0_state = obj.getAttributeBool('voltage0','quadrature_tracking_en',true); - if (quadrature_tracking_en_voltage0_state ~= obj.QuadratureTrackingChannel0) - obj.setAttributeBool('voltage0','quadrature_tracking_en',obj.QuadratureTrackingChannel0,true); + + quadrature_tracking_en_voltage0_state = obj.getAttributeBool('voltage0', 'quadrature_tracking_en', true); + if quadrature_tracking_en_voltage0_state ~= obj.QuadratureTrackingChannel0 + obj.setAttributeBool('voltage0', 'quadrature_tracking_en', obj.QuadratureTrackingChannel0, true); end if channelsAval == 2 - quadrature_tracking_en_voltage1_state = obj.getAttributeBool('voltage1','quadrature_tracking_en',true); - if (quadrature_tracking_en_voltage1_state ~= obj.QuadratureTrackingChannel1) - obj.setAttributeBool('voltage1','quadrature_tracking_en',obj.QuadratureTrackingChannel1,true); + quadrature_tracking_en_voltage1_state = obj.getAttributeBool('voltage1', 'quadrature_tracking_en', true); + if quadrature_tracking_en_voltage1_state ~= obj.QuadratureTrackingChannel1 + obj.setAttributeBool('voltage1', 'quadrature_tracking_en', obj.QuadratureTrackingChannel1, true); end end - -% obj.setAttributeBool('voltage0','en',obj.PowerdownChannel0,true); -% obj.setAttributeBool('voltage1','en',obj.PowerdownChannel1,true); - - obj.ToggleDDS(strcmp(obj.DataSource,'DDS')); - if strcmp(obj.DataSource,'DDS') + + % obj.setAttributeBool('voltage0','en',obj.PowerdownChannel0,true); + % obj.setAttributeBool('voltage1','en',obj.PowerdownChannel1,true); + + obj.ToggleDDS(strcmp(obj.DataSource, 'DDS')); + if strcmp(obj.DataSource, 'DDS') obj.DDSUpdate(); end end - + end - -end +end diff --git a/+adi/+ADRV9009/Base.m b/+adi/+ADRV9009/Base.m index 78c3b106..158ce3df 100644 --- a/+adi/+ADRV9009/Base.m +++ b/+adi/+ADRV9009/Base.m @@ -3,139 +3,143 @@ adi.common.Attribute & ... adi.common.DebugAttribute & ... matlabshared.libiio.base - %adi.ADRV9009.Base Class + % adi.ADRV9009.Base Class % This class contains shared parameters and methods between TX and RX % classes properties (Nontunable) - %SamplesPerFrame Samples Per Frame + % 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; + SamplesPerFrame = 2^15 end - + properties (Nontunable, Logical) - %EnableCustomProfile Enable Custom Profile - % Enable use of custom Profile file to set SamplingRate, + % EnableCustomProfile Enable Custom Profile + % Enable use of custom Profile file to set SamplingRate, % RFBandwidth, and FIR in datapaths - EnableCustomProfile = false; - %EnableFrequencyHoppingModeCalibration Enable Frequency Hopping Mode Calibration - % Option to enable frequency hopping mode VCO calibration, + EnableCustomProfile = false + % EnableFrequencyHoppingModeCalibration Enable Frequency Hopping Mode Calibration + % Option to enable frequency hopping mode VCO calibration, % specified as true or false. When this property is true, at % initialization VCO calibration lookup table is populated - EnableFrequencyHoppingModeCalibration = false; + EnableFrequencyHoppingModeCalibration = false end - + properties (Nontunable) - %CustomProfileFileName Custom Profile File Name + % CustomProfileFileName Custom Profile File Name % Path to custom Profile file created from profile wizard - CustomProfileFileName = ''; + CustomProfileFileName = '' end - + properties (Hidden, Constant) - %SamplingRate Sampling Rate - % Baseband sampling rate in Hz, specified as a scalar + % SamplingRate Sampling Rate + % Baseband sampling rate in Hz, specified as a scalar % in samples per second. - SamplingRate = 245.76e6; + SamplingRate = 245.76e6 end - + properties - %CenterFrequency Center Frequency + % CenterFrequency Center Frequency % RF center frequency, specified in Hz as a scalar. The % default is 2.4e9. This property is tunable. - CenterFrequency = 2.4e9; + CenterFrequency = 2.4e9 end - - properties(Nontunable, Hidden) - Timeout = Inf; - kernelBuffersCount = 2; - dataTypeStr = 'int16'; - phyDevName = 'adrv9009-phy'; + + properties (Nontunable, Hidden) + Timeout = Inf + kernelBuffersCount = 2 + dataTypeStr = 'int16' + phyDevName = 'adrv9009-phy' iioDevPHY end - + properties (Hidden, Constant) - ComplexData = true; + ComplexData = true end - methods + %% Constructor function obj = Base(varargin) 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}, ... - '', 'SamplesPerFrame'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'positive', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>', 0, '<=', 2^20}, ... + '', 'SamplesPerFrame'); obj.SamplesPerFrame = value; end + % Check CenterFrequency function set.CenterFrequency(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'positive','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',113e6,'<=',6e9}, ... - '', 'CenterFrequency'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'positive', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 113e6, '<=', 6e9}, ... + '', 'CenterFrequency'); obj.CenterFrequency = value; if obj.ConnectedToDevice id = 'altvoltage0'; - obj.setAttributeLongLong(id,'frequency',value,true); + obj.setAttributeLongLong(id, 'frequency', value, true); end end + % Check EnableCustomProfile function set.EnableCustomProfile(obj, value) - validateattributes( value, { 'logical' }, ... - { }, ... - '', 'EnableCustomProfile'); + validateattributes(value, { 'logical' }, ... + { }, ... + '', 'EnableCustomProfile'); obj.EnableCustomProfile = value; end + % Check CustomFilterFileName function set.CustomProfileFileName(obj, value) - validateattributes( value, { 'char' }, ... - { }, ... - '', 'CustomProfileFileName'); + validateattributes(value, { 'char' }, ... + { }, ... + '', 'CustomProfileFileName'); obj.CustomProfileFileName = value; if obj.EnableCustomProfile && obj.ConnectedToDevice %#ok writeProfileFile(obj); end end + end - + %% API Functions methods (Hidden, Access = protected) - + function icon = getIconImpl(obj) - icon = sprintf(['ADRV9009 ',obj.Type]); + icon = sprintf(['ADRV9009 ', obj.Type]); end - - function writeProfileFile(obj,phy) + + function writeProfileFile(obj, phy) profle_data_str = fileread(obj.CustomProfileFileName); if nargin < 2 - obj.setDeviceAttributeRAW('profile_config',profle_data_str); + obj.setDeviceAttributeRAW('profile_config', profle_data_str); else - obj.setDeviceAttributeRAW('profile_config',profle_data_str,phy); + obj.setDeviceAttributeRAW('profile_config', profle_data_str, phy); end 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 = 'ADRV9009'; end - + end end - diff --git a/+adi/+ADRV9009/ORx.m b/+adi/+ADRV9009/ORx.m index e745f9ac..eac219ee 100644 --- a/+adi/+ADRV9009/ORx.m +++ b/+adi/+ADRV9009/ORx.m @@ -8,158 +8,164 @@ % rx = adi.ADRV9009.ORx; % rx = adi.ADRV9009.ORx('uri','192.168.2.1'); % - % ADRV9009 Datasheet + % ADRV9009 Datasheet properties - %Gain Gain + % Gain Gain % Rx gain, specified as a scalar from 1 dB to 30 dB. The acceptable % minimum and maximum gain setting depends on the center % frequency. - Gain = 10; - %AUXFrequency AUX Center Frequency + Gain = 10 + % AUXFrequency AUX Center Frequency % RF center frequency of AUX PLL, specified in Hz as a scalar. The % default is 2.4e9. This property is tunable. - AUXFrequency = 2.4e9; + AUXFrequency = 2.4e9 end properties (Nontunable, Logical) % MUST BE NONTUNABLE OR SIMULINK WARNS - %EnableQuadratureTracking Enable Quadrature Tracking + % EnableQuadratureTracking Enable Quadrature Tracking % Option to enable quadrature tracking, specified as true or % false. When this property is true, IQ imbalance compensation is % applied to the input signal. - EnableQuadratureTracking = true; + EnableQuadratureTracking = true end - - properties(Logical) - %PowerdownChannel0 Powerdown Channel 0 + + properties (Logical) + % PowerdownChannel0 Powerdown Channel 0 % Logical which will power down RX channel 0 when set - PowerdownChannel0 = false; - %PowerdownChannel1 Powerdown Channel 1 + PowerdownChannel0 = false + % PowerdownChannel1 Powerdown Channel 1 % Logical which will power down RX channel 1 when set - PowerdownChannel1 = false; + PowerdownChannel1 = false end - + properties - %LOSourceSelect LO Source Select - % 'OBS_TX_LO' – ORx operates in observation mode on ORx1 with + % LOSourceSelect LO Source Select + % 'OBS_TX_LO' - ORx operates in observation mode on ORx1 with % RxTx LO synthesizer - % 'OBS_AUX_LO' – ORx operates in observation mode on ORx2 with + % 'OBS_AUX_LO' - ORx operates in observation mode on ORx2 with % AUX LO synthesizer - LOSourceSelect = 'OBS_TX_LO'; + LOSourceSelect = 'OBS_TX_LO' end - - properties(Constant, Hidden) + + properties (Constant, Hidden) LOSourceSelectSet = matlab.system.StringSet({ ... - 'OBS_TX_LO','OBS_AUX_LO'}); + 'OBS_TX_LO', 'OBS_AUX_LO'}) end - + properties (Hidden, Nontunable, Access = protected) - isOutput = false; + isOutput = false end - - properties(Nontunable, Hidden, Constant) - Type = 'Rx'; - channel_names = {'voltage0_i','voltage0_q','voltage1_i','voltage1_q'}; + + properties (Nontunable, Hidden, Constant) + Type = 'Rx' + channel_names = {'voltage0_i', 'voltage0_q', 'voltage1_i', 'voltage1_q'} end - + properties (Nontunable, Hidden) - devName = 'axi-adrv9009-rx-obs-hpc'; + devName = 'axi-adrv9009-rx-obs-hpc' end - + methods + %% Constructor function obj = ORx(varargin) coder.allowpcode('plain'); obj = obj@adi.ADRV9009.Base(varargin{:}); end + % Check LOSourceSelect function set.LOSourceSelect(obj, value) obj.LOSourceSelect = value; if obj.ConnectedToDevice - obj.setAttributeRAW('voltage2','rf_port_select',value,false); + obj.setAttributeRAW('voltage2', 'rf_port_select', value, false); end end + % Check Gain function set.Gain(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', 1,'<=', 30}, ... - '', 'Gain'); - assert(mod(value,1/2)==0, 'Gain must be a multiple of 0.5'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', 1, '<=', 30}, ... + '', 'Gain'); + assert(mod(value, 1 / 2) == 0, 'Gain must be a multiple of 0.5'); obj.Gain = value; if obj.ConnectedToDevice - obj.setAttributeDouble('voltage2','hardwaregain',value,false); + obj.setAttributeDouble('voltage2', 'hardwaregain', value, false); end end + % Check EnableQuadratureTracking function set.EnableQuadratureTracking(obj, value) obj.EnableQuadratureTracking = value; if obj.ConnectedToDevice - obj.setAttributeBool('voltage2','quadrature_tracking_en',value,false); + obj.setAttributeBool('voltage2', 'quadrature_tracking_en', value, false); end end - + % Check PowerdownChannel0 function set.PowerdownChannel0(obj, value) obj.PowerdownChannel0 = value; if obj.ConnectedToDevice id = 'voltage2'; - obj.setAttributeBool(id,'powerdown',value,false); + obj.setAttributeBool(id, 'powerdown', value, false); end end + % Check PowerdownChannel1 function set.PowerdownChannel1(obj, value) obj.PowerdownChannel1 = value; if obj.ConnectedToDevice id = 'voltage3'; - obj.setAttributeBool(id,'powerdown',value,false); + obj.setAttributeBool(id, 'powerdown', value, false); end end % Check AUXFrequency function set.AUXFrequency(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'positive','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',113e6,'<=',6e9}, ... - '', 'AUXFrequency'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'positive', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 113e6, '<=', 6e9}, ... + '', 'AUXFrequency'); obj.AUXFrequency = value; if obj.ConnectedToDevice id = 'altvoltage1'; - obj.setAttributeLongLong(id,'AUX_OBS_RX_LO_frequency',value,true); + obj.setAttributeLongLong(id, 'AUX_OBS_RX_LO_frequency', value, true); end - if ~strcmp(obj.LOSourceSelect,'OBS_AUX_LO') + if ~strcmp(obj.LOSourceSelect, 'OBS_AUX_LO') warning('The AUXFrequency property is not relevant in this configuration of the System object.'); - end + end end - + end - - methods (Access=protected) - - function AUXFrequencySet(obj,value) + + methods (Access = protected) + + function AUXFrequencySet(obj, value) if obj.ConnectedToDevice - obj.setAttributeLongLong('altvoltage1','AUX_OBS_RX_LO_frequency',value,true); + obj.setAttributeLongLong('altvoltage1', 'AUX_OBS_RX_LO_frequency', value, true); end end - function CenterFrequencySet(obj,value) + + function CenterFrequencySet(obj, value) if obj.ConnectedToDevice - obj.setAttributeLongLong('altvoltage0','frequency',value,true); + obj.setAttributeLongLong('altvoltage0', 'frequency', value, true); end end end - + %% API Functions methods (Hidden, Access = protected) - + function setupInit(obj) % Write all attributes to device once connected through set % methods % Do writes directly to hardware without using set methods. % This is required sine Simulink support doesn't support % modification to nontunable variables at SetupImpl - + if obj.EnableCustomProfile writeProfileFile(obj); end - + % Power everything down first obj.setAttributeBool('voltage0', 'powerdown', true, false); obj.setAttributeBool('voltage1', 'powerdown', true, false); @@ -167,24 +173,23 @@ function setupInit(obj) obj.setAttributeBool('voltage3', 'powerdown', true, false); % Only bring ORx back up obj.setAttributeBool('voltage2', 'powerdown', false, false); - if obj.getAttributeLongLong('voltage0','sampling_frequency',true) < 250e6 + if obj.getAttributeLongLong('voltage0', 'sampling_frequency', true) < 250e6 obj.setAttributeBool('voltage3', 'powerdown', false, false); end % Set all remaining attributes - obj.setAttributeBool('voltage2','quadrature_tracking_en',obj.EnableQuadratureTracking,false); - obj.setAttributeLongLong('altvoltage1','AUX_OBS_RX_LO_frequency',obj.AUXFrequency,true); - obj.setAttributeLongLong('altvoltage0','frequency',obj.CenterFrequency,true); - obj.setAttributeRAW('voltage2','rf_port_select',obj.LOSourceSelect,false); - obj.setAttributeDouble('voltage2','hardwaregain',obj.Gain,false); - obj.setDeviceAttributeRAW('calibrate_fhm_en',num2str(obj.EnableFrequencyHoppingModeCalibration)); - + obj.setAttributeBool('voltage2', 'quadrature_tracking_en', obj.EnableQuadratureTracking, false); + obj.setAttributeLongLong('altvoltage1', 'AUX_OBS_RX_LO_frequency', obj.AUXFrequency, true); + obj.setAttributeLongLong('altvoltage0', 'frequency', obj.CenterFrequency, true); + obj.setAttributeRAW('voltage2', 'rf_port_select', obj.LOSourceSelect, false); + obj.setAttributeDouble('voltage2', 'hardwaregain', obj.Gain, false); + obj.setDeviceAttributeRAW('calibrate_fhm_en', num2str(obj.EnableFrequencyHoppingModeCalibration)); + % Bring stuff back up as desired - obj.setAttributeBool('voltage2','powerdown',obj.PowerdownChannel0,false); - obj.setAttributeBool('voltage3','powerdown',obj.PowerdownChannel1,false); - + obj.setAttributeBool('voltage2', 'powerdown', obj.PowerdownChannel0, false); + obj.setAttributeBool('voltage3', 'powerdown', obj.PowerdownChannel1, false); + end - + end - -end +end diff --git a/+adi/+ADRV9009/Rx.m b/+adi/+ADRV9009/Rx.m index 9274dd27..d919a966 100644 --- a/+adi/+ADRV9009/Rx.m +++ b/+adi/+ADRV9009/Rx.m @@ -6,181 +6,191 @@ % rx = adi.ADRV9009.Rx; % rx = adi.ADRV9009.Rx('uri','192.168.2.1'); % - % ADRV9009 Datasheet + % ADRV9009 Datasheet properties - %GainControlMode Gain Control Mode + % GainControlMode Gain Control Mode % specified as one of the following: - % 'slow_attack' — For signals with slowly changing power levels - % 'manual' — For setting the gain manually with the Gain property - GainControlMode = 'slow_attack'; - %GainChannel0 Gain Channel 0 + % 'slow_attack' - For signals with slowly changing power levels + % 'manual' - For setting the gain manually with the Gain property + GainControlMode = 'slow_attack' + % GainChannel0 Gain Channel 0 % Channel 0 gain, specified as a scalar from 1 dB to 30 dB. The acceptable % minimum and maximum gain setting depends on the center % frequency. - GainChannel0 = 10; - %GainChannel1 Gain Channel 1 + GainChannel0 = 10 + % GainChannel1 Gain Channel 1 % Channel 1 gain, specified as a scalar from 1 dB to 30 dB. The acceptable % minimum and maximum gain setting depends on the center % frequency. - GainChannel1 = 10; + GainChannel1 = 10 end - + properties (Logical) % MUST BE NONTUNABLE OR SIMULINK WARNS - %EnableQuadratureTrackingChannel0 Enable Quadrature Tracking Channel 0 + % EnableQuadratureTrackingChannel0 Enable Quadrature Tracking Channel 0 % Option to enable quadrature tracking, specified as true or % false. When this property is true, IQ imbalance compensation is % applied to the input signal. - EnableQuadratureTrackingChannel0 = true; - %EnableQuadratureTrackingChannel1 Enable Quadrature Tracking Channel 1 + EnableQuadratureTrackingChannel0 = true + % EnableQuadratureTrackingChannel1 Enable Quadrature Tracking Channel 1 % Option to enable quadrature tracking, specified as true or % false. When this property is true, IQ imbalance compensation is % applied to the input signal. - EnableQuadratureTrackingChannel1 = true; - %EnableHarmonicDistortionTrackingChannel0 Enable Harmonic Distortion Tracking Channel 0 + EnableQuadratureTrackingChannel1 = true + % EnableHarmonicDistortionTrackingChannel0 Enable Harmonic Distortion Tracking Channel 0 % Option to enable quadrature tracking, specified as true or % false. When this property is true, IQ imbalance compensation is % applied to the input signal. - EnableHarmonicDistortionTrackingChannel0 = false; - %EnableHarmonicDistortionTrackingChannel1 Enable Harmonic Distortion Tracking Channel 1 + EnableHarmonicDistortionTrackingChannel0 = false + % EnableHarmonicDistortionTrackingChannel1 Enable Harmonic Distortion Tracking Channel 1 % Option to enable quadrature tracking, specified as true or % false. When this property is true, IQ imbalance compensation is % applied to the input signal. - EnableHarmonicDistortionTrackingChannel1 = false; + EnableHarmonicDistortionTrackingChannel1 = false end - - properties(Logical, Nontunable) - %EnableQuadratureCalibration Enable Quadrature Calibration - % Option to enable quadrature calibration on initialization, - % specified as true or false. When this property is true, IQ + + properties (Logical, Nontunable) + % EnableQuadratureCalibration Enable Quadrature Calibration + % Option to enable quadrature calibration on initialization, + % specified as true or false. When this property is true, IQ % imbalance compensation is applied to the input signal. - EnableQuadratureCalibration = true; - %EnablePhaseCorrection Enable Phase Correction + EnableQuadratureCalibration = true + % EnablePhaseCorrection Enable Phase Correction % Option to enable phase tracking, specified as true or % false. When this property is true, Phase differences between % transceivers will be deterministic across power cycles and LO % changes - EnablePhaseCorrection = false; + EnablePhaseCorrection = false end - - properties(Logical) - %PowerdownChannel0 Powerdown Channel 0 + + properties (Logical) + % PowerdownChannel0 Powerdown Channel 0 % Logical which will power down RX channel 0 when set - PowerdownChannel0 = false; - %PowerdownChannel1 Powerdown Channel 1 + PowerdownChannel0 = false + % PowerdownChannel1 Powerdown Channel 1 % Logical which will power down RX channel 1 when set - PowerdownChannel1 = false; + PowerdownChannel1 = false end - - properties(Constant, Hidden) + + properties (Constant, Hidden) GainControlModeSet = matlab.system.StringSet({ ... - 'manual','slow_attack'}); + 'manual', 'slow_attack'}) end - + properties (Hidden, Nontunable, Access = protected) - isOutput = false; + isOutput = false end - - properties(Nontunable, Hidden, Constant) - Type = 'Rx'; + + properties (Nontunable, Hidden, Constant) + Type = 'Rx' end - - properties(Nontunable, Hidden) - channel_names = {'voltage0_i','voltage0_q','voltage1_i','voltage1_q'}; + + properties (Nontunable, Hidden) + channel_names = {'voltage0_i', 'voltage0_q', 'voltage1_i', 'voltage1_q'} end - + properties (Nontunable, Hidden) - devName = 'axi-adrv9009-rx-hpc'; + devName = 'axi-adrv9009-rx-hpc' end - + methods + %% Constructor function obj = Rx(varargin) coder.allowpcode('plain'); obj = obj@adi.ADRV9009.Base(varargin{:}); end + % Check GainControlMode function set.GainControlMode(obj, value) obj.GainControlMode = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeRAW(id,'gain_control_mode',value,false); + obj.setAttributeRAW(id, 'gain_control_mode', value, false); end end + % Check GainChannel0 function set.GainChannel0(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', 0,'<=', 30}, ... - '', 'Gain'); - assert(mod(value,1/2)==0, 'Gain must be a multiple of 0.5'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', 0, '<=', 30}, ... + '', 'Gain'); + assert(mod(value, 1 / 2) == 0, 'Gain must be a multiple of 0.5'); obj.GainChannel0 = value; - if obj.ConnectedToDevice && strcmp(obj.GainControlMode,'manual') + if obj.ConnectedToDevice && strcmp(obj.GainControlMode, 'manual') id = 'voltage0'; - obj.setAttributeDouble(id,'hardwaregain',value,false); + obj.setAttributeDouble(id, 'hardwaregain', value, false); end end + % Check GainChannel1 function set.GainChannel1(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', 0,'<=', 30}, ... - '', 'Gain'); - assert(mod(value,1/2)==0, 'Gain must be a multiple of 0.5'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', 0, '<=', 30}, ... + '', 'Gain'); + assert(mod(value, 1 / 2) == 0, 'Gain must be a multiple of 0.5'); obj.GainChannel1 = value; - if obj.ConnectedToDevice && strcmp(obj.GainControlMode,'manual') + if obj.ConnectedToDevice && strcmp(obj.GainControlMode, 'manual') id = 'voltage1'; - obj.setAttributeDouble(id,'hardwaregain',value,false); + obj.setAttributeDouble(id, 'hardwaregain', value, false); end end + % Check EnableQuadratureTrackingChannel0 function set.EnableQuadratureTrackingChannel0(obj, value) obj.EnableQuadratureTrackingChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'quadrature_tracking_en',value,false); + obj.setAttributeBool(id, 'quadrature_tracking_en', value, false); end end + % Check EnableQuadratureTrackingChannel1 function set.EnableQuadratureTrackingChannel1(obj, value) obj.EnableQuadratureTrackingChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeBool(id,'quadrature_tracking_en',value,false); + obj.setAttributeBool(id, 'quadrature_tracking_en', value, false); end end - + % Check EnableHarmonicDistortionTrackingChannel0 function set.EnableHarmonicDistortionTrackingChannel0(obj, value) obj.EnableHarmonicDistortionTrackingChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'hd2_tracking_en',value,false); + obj.setAttributeBool(id, 'hd2_tracking_en', value, false); end end + % Check EnableHarmonicDistortionTrackingChannel1 function set.EnableHarmonicDistortionTrackingChannel1(obj, value) obj.EnableHarmonicDistortionTrackingChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeBool(id,'hd2_tracking_en',value,false); + obj.setAttributeBool(id, 'hd2_tracking_en', value, false); end end + % Check PowerdownChannel0 function set.PowerdownChannel0(obj, value) obj.PowerdownChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'powerdown',value,false); + obj.setAttributeBool(id, 'powerdown', value, false); end end + % Check PowerdownChannel1 function set.PowerdownChannel1(obj, value) obj.PowerdownChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeBool(id,'powerdown',value,false); + obj.setAttributeBool(id, 'powerdown', value, false); end end + end - + %% API Functions methods (Hidden, Access = protected) @@ -194,38 +204,37 @@ function setupInit(obj) if obj.EnableCustomProfile writeProfileFile(obj); end - + % Channels need to be powered up first so we can changed things - obj.setAttributeBool('voltage0','powerdown',false,false); - obj.setAttributeBool('voltage1','powerdown',false,false); - - obj.setAttributeRAW('voltage0','gain_control_mode',obj.GainControlMode,false); - obj.setAttributeBool('voltage0','quadrature_tracking_en',obj.EnableQuadratureTrackingChannel0,false); - obj.setAttributeBool('voltage1','quadrature_tracking_en',obj.EnableQuadratureTrackingChannel1,false); - obj.setAttributeBool('voltage0','hd2_tracking_en',obj.EnableHarmonicDistortionTrackingChannel0,false); - obj.setAttributeBool('voltage1','hd2_tracking_en',obj.EnableHarmonicDistortionTrackingChannel1,false); - + obj.setAttributeBool('voltage0', 'powerdown', false, false); + obj.setAttributeBool('voltage1', 'powerdown', false, false); + + obj.setAttributeRAW('voltage0', 'gain_control_mode', obj.GainControlMode, false); + obj.setAttributeBool('voltage0', 'quadrature_tracking_en', obj.EnableQuadratureTrackingChannel0, false); + obj.setAttributeBool('voltage1', 'quadrature_tracking_en', obj.EnableQuadratureTrackingChannel1, false); + obj.setAttributeBool('voltage0', 'hd2_tracking_en', obj.EnableHarmonicDistortionTrackingChannel0, false); + obj.setAttributeBool('voltage1', 'hd2_tracking_en', obj.EnableHarmonicDistortionTrackingChannel1, false); + id = 'altvoltage0'; - obj.setAttributeLongLong(id,'frequency',obj.CenterFrequency ,true); + obj.setAttributeLongLong(id, 'frequency', obj.CenterFrequency, true); - if strcmp(obj.GainControlMode,'manual') - obj.setAttributeDouble('voltage0','hardwaregain',obj.GainChannel0,false); - obj.setAttributeDouble('voltage1','hardwaregain',obj.GainChannel1,false); + if strcmp(obj.GainControlMode, 'manual') + obj.setAttributeDouble('voltage0', 'hardwaregain', obj.GainChannel0, false); + obj.setAttributeDouble('voltage1', 'hardwaregain', obj.GainChannel1, false); end - + % Do one shot cals - obj.setDeviceAttributeRAW('calibrate_rx_qec_en',num2str(obj.EnableQuadratureCalibration)); - obj.setDeviceAttributeRAW('calibrate_rx_phase_correction_en',num2str(obj.EnablePhaseCorrection)); - obj.setDeviceAttributeRAW('calibrate_fhm_en',num2str(obj.EnableFrequencyHoppingModeCalibration)); - obj.setDeviceAttributeRAW('calibrate',num2str(true)); - + obj.setDeviceAttributeRAW('calibrate_rx_qec_en', num2str(obj.EnableQuadratureCalibration)); + obj.setDeviceAttributeRAW('calibrate_rx_phase_correction_en', num2str(obj.EnablePhaseCorrection)); + obj.setDeviceAttributeRAW('calibrate_fhm_en', num2str(obj.EnableFrequencyHoppingModeCalibration)); + obj.setDeviceAttributeRAW('calibrate', num2str(true)); + % Bring stuff back up as desired - obj.setAttributeBool('voltage0','powerdown',obj.PowerdownChannel0,false); - obj.setAttributeBool('voltage1','powerdown',obj.PowerdownChannel1,false); + obj.setAttributeBool('voltage0', 'powerdown', obj.PowerdownChannel0, false); + obj.setAttributeBool('voltage1', 'powerdown', obj.PowerdownChannel1, false); end - + end - -end +end diff --git a/+adi/+ADRV9009/Tx.m b/+adi/+ADRV9009/Tx.m index f9cf3f5a..440fb2a5 100644 --- a/+adi/+ADRV9009/Tx.m +++ b/+adi/+ADRV9009/Tx.m @@ -7,213 +7,218 @@ % tx = adi.ADRV9009.Tx('uri','192.168.2.1'); % % ADRV9009 Datasheet - + properties - %AttenuationChannel0 Attenuation Channel 0 + % AttenuationChannel0 Attenuation Channel 0 % Attenuation specified as a scalar from -41.95 to 0 dB with a % resolution of 0.05 dB. - AttenuationChannel0 = -30; - %AttenuationChannel1 Attenuation Channel 1 + AttenuationChannel0 = -30 + % AttenuationChannel1 Attenuation Channel 1 % Attenuation specified as a scalar from -41.95 to 0 dB with a % resolution of 0.05 dB. - AttenuationChannel1 = -30; + AttenuationChannel1 = -30 end - + properties (Logical) - %EnableQuadratureTrackingChannel0 Enable Quadrature Tracking Channel 0 + % EnableQuadratureTrackingChannel0 Enable Quadrature Tracking Channel 0 % Option to enable quadrature tracking, specified as true or % false. When this property is true, IQ imbalance compensation is % applied to the transmitted signal. - EnableQuadratureTrackingChannel0 = true; - %EnableQuadratureTrackingChannel1 Enable Quadrature Tracking Channel 1 + EnableQuadratureTrackingChannel0 = true + % EnableQuadratureTrackingChannel1 Enable Quadrature Tracking Channel 1 % Option to enable quadrature tracking, specified as true or % false. When this property is true, IQ imbalance compensation is % applied to the transmitted signal. - EnableQuadratureTrackingChannel1 = true; - %EnableLOLeakageTrackingChannel0 Enable LO Leakage Tracking Channel 0 + EnableQuadratureTrackingChannel1 = true + % EnableLOLeakageTrackingChannel0 Enable LO Leakage Tracking Channel 0 % Option to enable quadrature tracking, specified as true or % false. When this property is true, LO leakage compensation is % applied to the transmitted signal. - EnableLOLeakageTrackingChannel0 = true; - %EnableLOLeakageTrackingChannel1 Enable LO Leakage Tracking Channel 1 + EnableLOLeakageTrackingChannel0 = true + % EnableLOLeakageTrackingChannel1 Enable LO Leakage Tracking Channel 1 % Option to enable quadrature tracking, specified as true or % false. When this property is true, LO leakage compensation is % applied to the transmitted signal. - EnableLOLeakageTrackingChannel1 = true; + EnableLOLeakageTrackingChannel1 = true end - - properties(Logical, Nontunable) - %EnableQuadratureCalibration Enable Quadrature Calibration - % Option to enable quadrature calibration on initialization, - % specified as true or false. When this property is true, IQ + + properties (Logical, Nontunable) + % EnableQuadratureCalibration Enable Quadrature Calibration + % Option to enable quadrature calibration on initialization, + % specified as true or false. When this property is true, IQ % imbalance compensation is applied to the input signal. - EnableQuadratureCalibration = true; - %EnableLOLeakageCorrection Enable LO Leakage Correction + EnableQuadratureCalibration = true + % EnableLOLeakageCorrection Enable LO Leakage Correction % Option to enable phase tracking, specified as true or % false. When this property is true, at initialization LO leakage % correction will be applied - EnableLOLeakageCorrection = true; - %EnableLOLeakageCorrectionExternal Enable LO Leakage Correction External + EnableLOLeakageCorrection = true + % EnableLOLeakageCorrectionExternal Enable LO Leakage Correction External % Option to enable phase tracking, specified as true or % false. When this property is true, at initialization LO leakage % correction will be applied within an external loopback path. % Note this requires external cabling. - EnableLOLeakageCorrectionExternal = false; + EnableLOLeakageCorrectionExternal = false end - - properties(Logical) - %PowerdownChannel0 Powerdown Channel 0 + + properties (Logical) + % PowerdownChannel0 Powerdown Channel 0 % Logical which will power down TX channel 0 when set - PowerdownChannel0 = false; - %PowerdownChannel1 Powerdown Channel 1 + PowerdownChannel0 = false + % PowerdownChannel1 Powerdown Channel 1 % Logical which will power down TX channel 1 when set - PowerdownChannel1 = false; + PowerdownChannel1 = false end - + properties (Hidden, Nontunable, Access = protected) - isOutput = true; + isOutput = true end - - properties(Nontunable, Hidden, Constant) - Type = 'Tx'; + + properties (Nontunable, Hidden, Constant) + Type = 'Tx' end - - properties(Nontunable, Hidden) - channel_names = {'voltage0','voltage1','voltage2','voltage3'}; + + properties (Nontunable, Hidden) + channel_names = {'voltage0', 'voltage1', 'voltage2', 'voltage3'} end - - + properties (Nontunable, Hidden) - devName = 'axi-adrv9009-tx-hpc'; + devName = 'axi-adrv9009-tx-hpc' end - + methods + %% Constructor function obj = Tx(varargin) coder.allowpcode('plain'); obj = obj@adi.ADRV9009.Base(varargin{:}); end + % Check Attenuation function set.AttenuationChannel0(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', -41.95,'<=', 0}, ... - '', 'Attenuation'); - assert(mod(value,1/20)==0, 'Attenuation must be a multiple of 0.05'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', -41.95, '<=', 0}, ... + '', 'Attenuation'); + assert(mod(value, 1 / 20) == 0, 'Attenuation must be a multiple of 0.05'); obj.AttenuationChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeDouble(id,'hardwaregain',value,true); + obj.setAttributeDouble(id, 'hardwaregain', value, true); end end + % Check Attenuation function set.AttenuationChannel1(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', -41.95,'<=', 0}, ... - '', 'Attenuation'); - assert(mod(value,1/20)==0, 'Attenuation must be a multiple of 0.05'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', -41.95, '<=', 0}, ... + '', 'Attenuation'); + assert(mod(value, 1 / 20) == 0, 'Attenuation must be a multiple of 0.05'); obj.AttenuationChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeDouble(id,'hardwaregain',value,true); + obj.setAttributeDouble(id, 'hardwaregain', value, true); end end + % Check PowerdownChannel0 function set.PowerdownChannel0(obj, value) obj.PowerdownChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'powerdown',value,true); + obj.setAttributeBool(id, 'powerdown', value, true); end end + % Check PowerdownChannel1 function set.PowerdownChannel1(obj, value) obj.PowerdownChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeBool(id,'powerdown',value,true); + obj.setAttributeBool(id, 'powerdown', value, true); end end - + % Check EnableQuadratureTrackingChannel0 function set.EnableQuadratureTrackingChannel0(obj, value) obj.EnableQuadratureTrackingChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'quadrature_tracking_en',value,true); + obj.setAttributeBool(id, 'quadrature_tracking_en', value, true); end end + % Check EnableQuadratureTrackingChannel1 function set.EnableQuadratureTrackingChannel1(obj, value) obj.EnableQuadratureTrackingChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeBool(id,'quadrature_tracking_en',value,true); + obj.setAttributeBool(id, 'quadrature_tracking_en', value, true); end end + % Check EnableLOLeakageTrackingChannel0 function set.EnableLOLeakageTrackingChannel0(obj, value) obj.EnableLOLeakageTrackingChannel0 = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'lo_leakage_tracking_en',value,true); + obj.setAttributeBool(id, 'lo_leakage_tracking_en', value, true); end end + % Check EnableLOLeakageTrackingChannel1 function set.EnableLOLeakageTrackingChannel1(obj, value) obj.EnableLOLeakageTrackingChannel1 = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeBool(id,'lo_leakage_tracking_en',value,true); + obj.setAttributeBool(id, 'lo_leakage_tracking_en', value, true); end end - + end - + %% API Functions methods (Hidden, Access = protected) - + function setupInit(obj) % Write all attributes to device once connected through set % methods % Do writes directly to hardware without using set methods. % This is required sine Simulink support doesn't support % modification to nontunable variables at SetupImpl - + if obj.EnableCustomProfile writeProfileFile(obj); end % Channels need to be powered up first so we can changed things - obj.setAttributeBool('voltage0','powerdown',false,true); - obj.setAttributeBool('voltage1','powerdown',false,true); - - obj.setAttributeLongLong('altvoltage0','frequency',obj.CenterFrequency ,true); - obj.setAttributeDouble('voltage0','hardwaregain',obj.AttenuationChannel0,true); - obj.setAttributeDouble('voltage1','hardwaregain',obj.AttenuationChannel1,true); - - obj.setAttributeBool('voltage0','quadrature_tracking_en',obj.EnableQuadratureTrackingChannel0,true); - obj.setAttributeBool('voltage1','quadrature_tracking_en',obj.EnableQuadratureTrackingChannel1,true); - obj.setAttributeBool('voltage0','lo_leakage_tracking_en',obj.EnableLOLeakageTrackingChannel0,true); - obj.setAttributeBool('voltage1','lo_leakage_tracking_en',obj.EnableLOLeakageTrackingChannel1,true); - + obj.setAttributeBool('voltage0', 'powerdown', false, true); + obj.setAttributeBool('voltage1', 'powerdown', false, true); + + obj.setAttributeLongLong('altvoltage0', 'frequency', obj.CenterFrequency, true); + obj.setAttributeDouble('voltage0', 'hardwaregain', obj.AttenuationChannel0, true); + obj.setAttributeDouble('voltage1', 'hardwaregain', obj.AttenuationChannel1, true); + + obj.setAttributeBool('voltage0', 'quadrature_tracking_en', obj.EnableQuadratureTrackingChannel0, true); + obj.setAttributeBool('voltage1', 'quadrature_tracking_en', obj.EnableQuadratureTrackingChannel1, true); + obj.setAttributeBool('voltage0', 'lo_leakage_tracking_en', obj.EnableLOLeakageTrackingChannel0, true); + obj.setAttributeBool('voltage1', 'lo_leakage_tracking_en', obj.EnableLOLeakageTrackingChannel1, true); + % Do one shot cals - obj.setDeviceAttributeRAW('calibrate_tx_qec_en',num2str(obj.EnableQuadratureCalibration)); - obj.setDeviceAttributeRAW('calibrate_tx_lol_en',num2str(obj.EnableLOLeakageCorrection)); - obj.setDeviceAttributeRAW('calibrate_tx_lol_ext_en',num2str(obj.EnableLOLeakageCorrectionExternal)); - obj.setDeviceAttributeRAW('calibrate_fhm_en',num2str(obj.EnableFrequencyHoppingModeCalibration)); - obj.setDeviceAttributeRAW('calibrate',num2str(true)); + obj.setDeviceAttributeRAW('calibrate_tx_qec_en', num2str(obj.EnableQuadratureCalibration)); + obj.setDeviceAttributeRAW('calibrate_tx_lol_en', num2str(obj.EnableLOLeakageCorrection)); + obj.setDeviceAttributeRAW('calibrate_tx_lol_ext_en', num2str(obj.EnableLOLeakageCorrectionExternal)); + obj.setDeviceAttributeRAW('calibrate_fhm_en', num2str(obj.EnableFrequencyHoppingModeCalibration)); + obj.setDeviceAttributeRAW('calibrate', num2str(true)); % Bring stuff back up as desired - obj.setAttributeBool('voltage0','powerdown',obj.PowerdownChannel0,true); - obj.setAttributeBool('voltage1','powerdown',obj.PowerdownChannel1,true); + obj.setAttributeBool('voltage0', 'powerdown', obj.PowerdownChannel0, true); + obj.setAttributeBool('voltage1', 'powerdown', obj.PowerdownChannel1, true); - - obj.ToggleDDS(strcmp(obj.DataSource,'DDS')); - if strcmp(obj.DataSource,'DDS') + obj.ToggleDDS(strcmp(obj.DataSource, 'DDS')); + if strcmp(obj.DataSource, 'DDS') obj.DDSUpdate(); end end - + end - -end +end diff --git a/+adi/+ADRV9009ZU11EG/Base.m b/+adi/+ADRV9009ZU11EG/Base.m index 882d71c9..e8be65e2 100644 --- a/+adi/+ADRV9009ZU11EG/Base.m +++ b/+adi/+ADRV9009ZU11EG/Base.m @@ -1,54 +1,55 @@ classdef (Abstract, Hidden = true) Base < adi.ADRV9009.Base - - %adi.ADRV9009ZU11EG.Base Class + + % adi.ADRV9009ZU11EG.Base Class % This class contains shared parameters and methods between TX and RX % classes - + properties - %CenterFrequencyChipB Center Frequency Chip B + % CenterFrequencyChipB Center Frequency Chip B % RF center frequency, specified in Hz as a scalar. The % default is 2.4e9. This property is tunable. - CenterFrequencyChipB = 2.4e9; + CenterFrequencyChipB = 2.4e9 end - + properties (Nontunable, Logical) - %EnableFrequencyHoppingModeCalibrationChipB Enable Frequency Hopping Mode Calibration Chip B - % Option to enable frequency hopping mode VCO calibration, + % EnableFrequencyHoppingModeCalibrationChipB Enable Frequency Hopping Mode Calibration Chip B + % Option to enable frequency hopping mode VCO calibration, % specified as true or false. When this property is true, at % initialization VCO calibration lookup table is populated - EnableFrequencyHoppingModeCalibrationChipB = false; + EnableFrequencyHoppingModeCalibrationChipB = false end - + methods + % Check CenterFrequencyChipB function set.CenterFrequencyChipB(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'positive','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',70e6,'<=',6e9}, ... - '', 'CenterFrequencyChipB'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'positive', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 70e6, '<=', 6e9}, ... + '', 'CenterFrequencyChipB'); obj.CenterFrequencyChipB = value; if obj.ConnectedToDevice id = 'altvoltage0'; - obj.setAttributeLongLong(id,'frequency',value,true); + obj.setAttributeLongLong(id, 'frequency', value, true); end end + end - + %% API Functions methods (Hidden, Access = protected) - + function icon = getIconImpl(obj) - icon = sprintf(['ADRV9009ZU11EG ',obj.Type]); + icon = sprintf(['ADRV9009ZU11EG ', obj.Type]); end - + end - + %% External Dependency Methods methods (Hidden, Static) - + function bName = getDescriptiveName(~) bName = 'ADRV9009ZU11EG'; end - + end end - diff --git a/+adi/+ADRV9009ZU11EG/Rx.m b/+adi/+ADRV9009ZU11EG/Rx.m index bc556e62..eb72248c 100644 --- a/+adi/+ADRV9009ZU11EG/Rx.m +++ b/+adi/+ADRV9009ZU11EG/Rx.m @@ -6,93 +6,94 @@ % rx = adi.ADRV9009ZU11EG.Rx; % rx = adi.ADRV9009ZU11EG.Rx('uri','192.168.2.1'); % - % ADRV9009 Datasheet + % ADRV9009 Datasheet properties - %GainControlModeChipB Gain Control Mode + % GainControlModeChipB Gain Control Mode % specified as one of the following: - % 'slow_attack' — For signals with slowly changing power levels - % 'manual' — For setting the gain manually with the Gain property - GainControlModeChipB = 'slow_attack'; - %GainChannel0 Gain Channel 0 Chip B + % 'slow_attack' - For signals with slowly changing power levels + % 'manual' - For setting the gain manually with the Gain property + GainControlModeChipB = 'slow_attack' + % GainChannel0 Gain Channel 0 Chip B % Channel 0 gain, specified as a scalar from -4 dB to 71 dB. The acceptable % minimum and maximum gain setting depends on the center % frequency. - GainChannel0ChipB = 10; - %GainChannel1 Gain Channel 1 Chip B + GainChannel0ChipB = 10 + % GainChannel1 Gain Channel 1 Chip B % Channel 1 gain, specified as a scalar from -4 dB to 71 dB. The acceptable % minimum and maximum gain setting depends on the center % frequency. - GainChannel1ChipB = 10; + GainChannel1ChipB = 10 end - + properties (Logical) % MUST BE NONTUNABLE OR SIMULINK WARNS - %EnableQuadratureTrackingChannel0ChipB Enable Quadrature Tracking Channel 0 Chip B + % EnableQuadratureTrackingChannel0ChipB Enable Quadrature Tracking Channel 0 Chip B % Option to enable quadrature tracking, specified as true or % false. When this property is true, IQ imbalance compensation is % applied to the input signal. - EnableQuadratureTrackingChannel0ChipB = true; - %EnableQuadratureTrackingChannel0ChipB Enable Quadrature Tracking Channel 1 Chip B + EnableQuadratureTrackingChannel0ChipB = true + % EnableQuadratureTrackingChannel0ChipB Enable Quadrature Tracking Channel 1 Chip B % Option to enable quadrature tracking, specified as true or % false. When this property is true, IQ imbalance compensation is % applied to the input signal. - EnableQuadratureTrackingChannel1ChipB = true; - %EnableHarmonicDistortionTrackingChannel0ChipB Enable Harmonic Distortion Tracking Channel 0 Chip B + EnableQuadratureTrackingChannel1ChipB = true + % EnableHarmonicDistortionTrackingChannel0ChipB Enable Harmonic Distortion Tracking Channel 0 Chip B % Option to enable quadrature tracking, specified as true or % false. When this property is true, IQ imbalance compensation is % applied to the input signal. - EnableHarmonicDistortionTrackingChannel0ChipB = false; - %EnableHarmonicDistortionTrackingChannel1 Enable Harmonic Distortion Tracking Channel 1 Chip B + EnableHarmonicDistortionTrackingChannel0ChipB = false + % EnableHarmonicDistortionTrackingChannel1 Enable Harmonic Distortion Tracking Channel 1 Chip B % Option to enable quadrature tracking, specified as true or % false. When this property is true, IQ imbalance compensation is % applied to the input signal. - EnableHarmonicDistortionTrackingChannel1ChipB = false; + EnableHarmonicDistortionTrackingChannel1ChipB = false end - - properties(Logical, Nontunable) - %EnableQuadratureCalibrationChipB Enable Quadrature Calibration Chip B - % Option to enable quadrature calibration on initialization, - % specified as true or false. When this property is true, IQ + + properties (Logical, Nontunable) + % EnableQuadratureCalibrationChipB Enable Quadrature Calibration Chip B + % Option to enable quadrature calibration on initialization, + % specified as true or false. When this property is true, IQ % imbalance compensation is applied to the input signal. - EnableQuadratureCalibrationChipB = true; - %EnablePhaseCorrectionChipB Enable Phase Correction Chip B + EnableQuadratureCalibrationChipB = true + % EnablePhaseCorrectionChipB Enable Phase Correction Chip B % Option to enable phase tracking, specified as true or % false. When this property is true, Phase differences between % transceivers will be deterministic across power cycles and LO % changes - EnablePhaseCorrectionChipB = false; + EnablePhaseCorrectionChipB = false end - - properties(Logical) - %PowerdownChannel0ChipB Powerdown Channel 0 Chip B + + properties (Logical) + % PowerdownChannel0ChipB Powerdown Channel 0 Chip B % Logical which will power down RX channel 0 when set - PowerdownChannel0ChipB = false; - %PowerdownChannel1ChipB Powerdown Channel 1 Chip B + PowerdownChannel0ChipB = false + % PowerdownChannel1ChipB Powerdown Channel 1 Chip B % Logical which will power down RX channel 1 when set - PowerdownChannel1ChipB = false; + PowerdownChannel1ChipB = false end - - properties(Constant, Hidden) + + properties (Constant, Hidden) GainControlModeChipBSet = matlab.system.StringSet({ ... - 'manual','slow_attack'}); + 'manual', 'slow_attack'}) end - - properties(Nontunable, Hidden, Constant) - channel_names_runtime = {... - 'voltage0_i','voltage0_q',... - 'voltage1_i','voltage1_q',... - 'voltage2_i','voltage2_q',... - 'voltage3_i','voltage3_q'}; + + properties (Nontunable, Hidden, Constant) + channel_names_runtime = { ... + 'voltage0_i', 'voltage0_q', ... + 'voltage1_i', 'voltage1_q', ... + 'voltage2_i', 'voltage2_q', ... + 'voltage3_i', 'voltage3_q'} end - - properties(Nontunable, Hidden) - phyDevNameChipB = 'adrv9009-phy-b'; + + properties (Nontunable, Hidden) + phyDevNameChipB = 'adrv9009-phy-b' end - - properties(Hidden) - iioDevChipB; + + properties (Hidden) + iioDevChipB end - + methods + %% Constructor function obj = Rx(varargin) coder.allowpcode('plain'); @@ -100,207 +101,215 @@ obj = obj@adi.ADRV9009ZU11EG.Base(varargin{:}); obj.channel_names = obj.channel_names_runtime; end + %% Destructor function delete(obj) end + % Check GainControlModeChipB function set.GainControlModeChipB(obj, value) obj.GainControlModeChipB = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeRAW(id,'gain_control_mode',value,false,obj.iioDevChipB); %#ok + obj.setAttributeRAW(id, 'gain_control_mode', value, false, obj.iioDevChipB); %#ok end end + % Check GainChannel0ChipB function set.GainChannel0ChipB(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', 0,'<=', 30}, ... - '', 'Gain'); - assert(mod(value,1/4)==0, 'Gain must be a multiple of 0.25'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', 0, '<=', 30}, ... + '', 'Gain'); + assert(mod(value, 1 / 4) == 0, 'Gain must be a multiple of 0.25'); obj.GainChannel0ChipB = value; - if obj.ConnectedToDevice && strcmp(obj.GainControlModeChipB,'manual') %#ok + if obj.ConnectedToDevice && strcmp(obj.GainControlModeChipB, 'manual') %#ok id = 'voltage0'; - obj.setAttributeDouble(id,'hardwaregain',value,false,0,obj.iioDevChipB); %#ok + obj.setAttributeDouble(id, 'hardwaregain', value, false, 0, obj.iioDevChipB); %#ok end end + % Check GainChannel1ChipB function set.GainChannel1ChipB(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', 0,'<=', 30}, ... - '', 'Gain'); - assert(mod(value,1/4)==0, 'Gain must be a multiple of 0.25'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', 0, '<=', 30}, ... + '', 'Gain'); + assert(mod(value, 1 / 4) == 0, 'Gain must be a multiple of 0.25'); obj.GainChannel1ChipB = value; - if obj.ConnectedToDevice && strcmp(obj.GainControlModeChipB,'manual') %#ok + if obj.ConnectedToDevice && strcmp(obj.GainControlModeChipB, 'manual') %#ok id = 'voltage1'; - obj.setAttributeDouble(id,'hardwaregain',value,false,0,obj.iioDevChipB); %#ok + obj.setAttributeDouble(id, 'hardwaregain', value, false, 0, obj.iioDevChipB); %#ok end end + % Check EnableQuadratureTrackingChannel0ChipB function set.EnableQuadratureTrackingChannel0ChipB(obj, value) obj.EnableQuadratureTrackingChannel0ChipB = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'quadrature_tracking_en',value,false,obj.iioDevChipB); + obj.setAttributeBool(id, 'quadrature_tracking_en', value, false, obj.iioDevChipB); end end + % Check EnableQuadratureTrackingChannel1ChipB function set.EnableQuadratureTrackingChannel1ChipB(obj, value) obj.EnableQuadratureTrackingChannel1ChipB = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeBool(id,'quadrature_tracking_en',value,false,obj.iioDevChipB); + obj.setAttributeBool(id, 'quadrature_tracking_en', value, false, obj.iioDevChipB); end end - + % Check EnableHarmonicDistortionTrackingChannel0ChipB function set.EnableHarmonicDistortionTrackingChannel0ChipB(obj, value) obj.EnableHarmonicDistortionTrackingChannel0ChipB = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'hd2_tracking_en',value,false,obj.iioDevChipB); + obj.setAttributeBool(id, 'hd2_tracking_en', value, false, obj.iioDevChipB); end end + % Check EnableHarmonicDistortionTrackingChannel1ChipB function set.EnableHarmonicDistortionTrackingChannel1ChipB(obj, value) obj.EnableHarmonicDistortionTrackingChannel1ChipB = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeBool(id,'hd2_tracking_en',value,false,obj.iioDevChipB); + obj.setAttributeBool(id, 'hd2_tracking_en', value, false, obj.iioDevChipB); end end - + % Check PowerdownChannel0 function set.PowerdownChannel0ChipB(obj, value) obj.PowerdownChannel0ChipB = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'powerdown',value,false,obj.iioDevChipB); + obj.setAttributeBool(id, 'powerdown', value, false, obj.iioDevChipB); end end + % Check PowerdownChannel1 function set.PowerdownChannel1ChipB(obj, value) obj.PowerdownChannel1ChipB = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeBool(id,'powerdown',value,false,obj.iioDevChipB); + obj.setAttributeBool(id, 'powerdown', value, false, obj.iioDevChipB); end - end + end + end - - methods (Access=protected) + + methods (Access = protected) + % Hide unused parameters when in specific modes function flag = isInactivePropertyImpl(obj, prop) % Call the superclass method - flag = isInactivePropertyImpl@adi.common.RxTx(obj,prop); - + flag = isInactivePropertyImpl@adi.common.RxTx(obj, prop); + if ~any(obj.EnabledChannels == 1) - flag = flag || strcmpi(prop,'EnableQuadratureTrackingChannel0'); - flag = flag || strcmpi(prop,'EnableHarmonicDistortionTrackingChannel0'); + flag = flag || strcmpi(prop, 'EnableQuadratureTrackingChannel0'); + flag = flag || strcmpi(prop, 'EnableHarmonicDistortionTrackingChannel0'); end if ~any(obj.EnabledChannels == 2) - flag = flag || strcmpi(prop,'EnableQuadratureTrackingChannel1'); + flag = flag || strcmpi(prop, 'EnableQuadratureTrackingChannel1'); end if ~any(obj.EnabledChannels == 3) - flag = flag || strcmpi(prop,'GainChannel0ChipB'); - flag = flag || strcmpi(prop,'EnableQuadratureTrackingChannel0ChipB'); - flag = flag || strcmpi(prop,'EnableHarmonicDistortionTrackingChannel0ChipB'); + flag = flag || strcmpi(prop, 'GainChannel0ChipB'); + flag = flag || strcmpi(prop, 'EnableQuadratureTrackingChannel0ChipB'); + flag = flag || strcmpi(prop, 'EnableHarmonicDistortionTrackingChannel0ChipB'); end if ~any(obj.EnabledChannels == 4) - flag = flag || strcmpi(prop,'GainChannel1ChipB'); - flag = flag || strcmpi(prop,'EnableQuadratureTrackingChannel1ChipB'); - flag = flag || strcmpi(prop,'EnableHarmonicDistortionTrackingChannel1ChipB'); + flag = flag || strcmpi(prop, 'GainChannel1ChipB'); + flag = flag || strcmpi(prop, 'EnableQuadratureTrackingChannel1ChipB'); + flag = flag || strcmpi(prop, 'EnableHarmonicDistortionTrackingChannel1ChipB'); end if ~any(obj.EnabledChannels == 1) && ~any(obj.EnabledChannels == 2) - flag = flag || ~contains(prop,'ChipB'); + flag = flag || ~contains(prop, 'ChipB'); end if ~any(obj.EnabledChannels == 3) && ~any(obj.EnabledChannels == 4) - flag = flag || contains(prop,'ChipB'); + flag = flag || contains(prop, 'ChipB'); else - flag = flag || strcmpi(prop,'GainChannel1ChipB') &&... - ~strcmpi(obj.GainControlModeChipB, 'manual'); + flag = flag || strcmpi(prop, 'GainChannel1ChipB') && ... + ~strcmpi(obj.GainControlModeChipB, 'manual'); end if ~strcmpi(obj.GainControlModeChipB, 'manual') - flag = flag || strcmpi(prop,'GainChannel1ChipB'); - flag = flag || strcmpi(prop,'GainChannel0ChipB'); + flag = flag || strcmpi(prop, 'GainChannel1ChipB'); + flag = flag || strcmpi(prop, 'GainChannel0ChipB'); end end - + end - + %% API Functions methods (Hidden, Access = protected) - + function setupInit(obj) % Write all attributes to device once connected through set % methods % Do writes directly to hardware without using set methods. % This is required sine Simulink support doesn't support % modification to nontunable variables at SetupImpl - + obj.iioDevChipB = getDev(obj, obj.phyDevNameChipB); - + if obj.EnableCustomProfile writeProfileFile(obj); - writeProfileFile(obj,obj.iioDevChipB); + writeProfileFile(obj, obj.iioDevChipB); end - + % Channels need to be powered up first so we can changed things - obj.setAttributeBool('voltage0','powerdown',false,false); - obj.setAttributeBool('voltage1','powerdown',false,false); - obj.setAttributeBool('voltage0','powerdown',false,false,obj.iioDevChipB); - obj.setAttributeBool('voltage1','powerdown',false,false,obj.iioDevChipB); - - obj.setAttributeRAW('voltage0','gain_control_mode',obj.GainControlMode,false); - obj.setAttributeRAW('voltage0','gain_control_mode',obj.GainControlModeChipB,false,obj.iioDevChipB); - - obj.setAttributeBool('voltage0','quadrature_tracking_en',obj.EnableQuadratureTrackingChannel0,false); - obj.setAttributeBool('voltage1','quadrature_tracking_en',obj.EnableQuadratureTrackingChannel1,false); - obj.setAttributeBool('voltage0','quadrature_tracking_en',obj.EnableQuadratureTrackingChannel0ChipB,false,obj.iioDevChipB); - obj.setAttributeBool('voltage1','quadrature_tracking_en',obj.EnableQuadratureTrackingChannel1ChipB,false,obj.iioDevChipB); - - obj.setAttributeBool('voltage0','hd2_tracking_en',obj.EnableHarmonicDistortionTrackingChannel0,false); - obj.setAttributeBool('voltage1','hd2_tracking_en',obj.EnableHarmonicDistortionTrackingChannel0,false); - obj.setAttributeBool('voltage0','hd2_tracking_en',obj.EnableHarmonicDistortionTrackingChannel0ChipB,false,obj.iioDevChipB); - obj.setAttributeBool('voltage1','hd2_tracking_en',obj.EnableHarmonicDistortionTrackingChannel1ChipB,false,obj.iioDevChipB); - + obj.setAttributeBool('voltage0', 'powerdown', false, false); + obj.setAttributeBool('voltage1', 'powerdown', false, false); + obj.setAttributeBool('voltage0', 'powerdown', false, false, obj.iioDevChipB); + obj.setAttributeBool('voltage1', 'powerdown', false, false, obj.iioDevChipB); + + obj.setAttributeRAW('voltage0', 'gain_control_mode', obj.GainControlMode, false); + obj.setAttributeRAW('voltage0', 'gain_control_mode', obj.GainControlModeChipB, false, obj.iioDevChipB); + + obj.setAttributeBool('voltage0', 'quadrature_tracking_en', obj.EnableQuadratureTrackingChannel0, false); + obj.setAttributeBool('voltage1', 'quadrature_tracking_en', obj.EnableQuadratureTrackingChannel1, false); + obj.setAttributeBool('voltage0', 'quadrature_tracking_en', obj.EnableQuadratureTrackingChannel0ChipB, false, obj.iioDevChipB); + obj.setAttributeBool('voltage1', 'quadrature_tracking_en', obj.EnableQuadratureTrackingChannel1ChipB, false, obj.iioDevChipB); + + obj.setAttributeBool('voltage0', 'hd2_tracking_en', obj.EnableHarmonicDistortionTrackingChannel0, false); + obj.setAttributeBool('voltage1', 'hd2_tracking_en', obj.EnableHarmonicDistortionTrackingChannel0, false); + obj.setAttributeBool('voltage0', 'hd2_tracking_en', obj.EnableHarmonicDistortionTrackingChannel0ChipB, false, obj.iioDevChipB); + obj.setAttributeBool('voltage1', 'hd2_tracking_en', obj.EnableHarmonicDistortionTrackingChannel1ChipB, false, obj.iioDevChipB); + id = 'altvoltage0'; - obj.setAttributeLongLong(id,'frequency',obj.CenterFrequency ,true); - obj.setAttributeLongLong(id,'frequency',obj.CenterFrequencyChipB ,true, 10, obj.iioDevChipB); + obj.setAttributeLongLong(id, 'frequency', obj.CenterFrequency, true); + obj.setAttributeLongLong(id, 'frequency', obj.CenterFrequencyChipB, true, 10, obj.iioDevChipB); - if strcmp(obj.GainControlMode,'manual') - obj.setAttributeDouble('voltage0','hardwaregain',obj.GainChannel0,false); - obj.setAttributeDouble('voltage1','hardwaregain',obj.GainChannel1,false); + if strcmp(obj.GainControlMode, 'manual') + obj.setAttributeDouble('voltage0', 'hardwaregain', obj.GainChannel0, false); + obj.setAttributeDouble('voltage1', 'hardwaregain', obj.GainChannel1, false); end - if strcmp(obj.GainControlModeChipB,'manual') - obj.setAttributeDouble('voltage0','hardwaregain',obj.GainChannel0ChipB,false,obj.iioDevChipB); - obj.setAttributeDouble('voltage1','hardwaregain',obj.GainChannel1ChipB,false,obj.iioDevChipB); + if strcmp(obj.GainControlModeChipB, 'manual') + obj.setAttributeDouble('voltage0', 'hardwaregain', obj.GainChannel0ChipB, false, obj.iioDevChipB); + obj.setAttributeDouble('voltage1', 'hardwaregain', obj.GainChannel1ChipB, false, obj.iioDevChipB); end - + % Do one shot cals - obj.setDeviceAttributeRAW('calibrate_rx_qec_en',num2str(obj.EnableQuadratureCalibration)); - obj.setDeviceAttributeRAW('calibrate_rx_phase_correction_en',num2str(obj.EnablePhaseCorrection)); - if strcmpi(class(obj),'adi.ADRV9009ZU11EG.Rx') - obj.setDeviceAttributeRAW('calibrate_fhm_en',num2str(obj.EnableFrequencyHoppingModeCalibration)); + obj.setDeviceAttributeRAW('calibrate_rx_qec_en', num2str(obj.EnableQuadratureCalibration)); + obj.setDeviceAttributeRAW('calibrate_rx_phase_correction_en', num2str(obj.EnablePhaseCorrection)); + if strcmpi(class(obj), 'adi.ADRV9009ZU11EG.Rx') + obj.setDeviceAttributeRAW('calibrate_fhm_en', num2str(obj.EnableFrequencyHoppingModeCalibration)); end - obj.setDeviceAttributeRAW('calibrate',num2str(true)); + obj.setDeviceAttributeRAW('calibrate', num2str(true)); - obj.setDeviceAttributeRAW('calibrate_rx_qec_en',num2str(obj.EnableQuadratureCalibrationChipB),obj.iioDevChipB); - obj.setDeviceAttributeRAW('calibrate_rx_phase_correction_en',num2str(obj.EnablePhaseCorrectionChipB),obj.iioDevChipB); - if strcmpi(class(obj),'adi.ADRV9009ZU11EG.Rx') - obj.setDeviceAttributeRAW('calibrate_fhm_en',num2str(obj.EnableFrequencyHoppingModeCalibrationChipB),obj.iioDevChipB); + obj.setDeviceAttributeRAW('calibrate_rx_qec_en', num2str(obj.EnableQuadratureCalibrationChipB), obj.iioDevChipB); + obj.setDeviceAttributeRAW('calibrate_rx_phase_correction_en', num2str(obj.EnablePhaseCorrectionChipB), obj.iioDevChipB); + if strcmpi(class(obj), 'adi.ADRV9009ZU11EG.Rx') + obj.setDeviceAttributeRAW('calibrate_fhm_en', num2str(obj.EnableFrequencyHoppingModeCalibrationChipB), obj.iioDevChipB); end - obj.setDeviceAttributeRAW('calibrate',num2str(true),obj.iioDevChipB); + obj.setDeviceAttributeRAW('calibrate', num2str(true), obj.iioDevChipB); - % Bring stuff back up as desired - obj.setAttributeBool('voltage0','powerdown',obj.PowerdownChannel0,false); - obj.setAttributeBool('voltage1','powerdown',obj.PowerdownChannel1,false); - obj.setAttributeBool('voltage0','powerdown',obj.PowerdownChannel0ChipB,false,obj.iioDevChipB); - obj.setAttributeBool('voltage1','powerdown',obj.PowerdownChannel1ChipB,false,obj.iioDevChipB); - + obj.setAttributeBool('voltage0', 'powerdown', obj.PowerdownChannel0, false); + obj.setAttributeBool('voltage1', 'powerdown', obj.PowerdownChannel1, false); + obj.setAttributeBool('voltage0', 'powerdown', obj.PowerdownChannel0ChipB, false, obj.iioDevChipB); + obj.setAttributeBool('voltage1', 'powerdown', obj.PowerdownChannel1ChipB, false, obj.iioDevChipB); + end - + end - -end +end diff --git a/+adi/+ADRV9009ZU11EG/Tx.m b/+adi/+ADRV9009ZU11EG/Tx.m index d59b192d..daf49cc6 100644 --- a/+adi/+ADRV9009ZU11EG/Tx.m +++ b/+adi/+ADRV9009ZU11EG/Tx.m @@ -7,83 +7,84 @@ % tx = adi.ADRV9009ZU11EG.Tx('uri','192.168.2.1'); % % ADRV9009 Datasheet - + properties - %AttenuationChannel0ChipB Attenuation Channel 0 ChipB + % AttenuationChannel0ChipB Attenuation Channel 0 ChipB % Attenuation specified as a scalar from -41.95 to 0 dB with a % resolution of 0.05 dB. - AttenuationChannel0ChipB = -30; - %AttenuationChannel1ChipB Attenuation Channel 1 ChipB + AttenuationChannel0ChipB = -30 + % AttenuationChannel1ChipB Attenuation Channel 1 ChipB % Attenuation specified as a scalar from -41.95 to 0 dB with a % resolution of 0.05 dB. - AttenuationChannel1ChipB = -30; + AttenuationChannel1ChipB = -30 end properties (Logical) - %EnableQuadratureTrackingChannel0ChipB Enable Quadrature Tracking Channel 0 Chip B + % EnableQuadratureTrackingChannel0ChipB Enable Quadrature Tracking Channel 0 Chip B % Option to enable quadrature tracking, specified as true or % false. When this property is true, IQ imbalance compensation is % applied to the transmitted signal. - EnableQuadratureTrackingChannel0ChipB = true; - %EnableQuadratureTrackingChannel1ChipB Enable Quadrature Tracking Channel 1 Chip B + EnableQuadratureTrackingChannel0ChipB = true + % EnableQuadratureTrackingChannel1ChipB Enable Quadrature Tracking Channel 1 Chip B % Option to enable quadrature tracking, specified as true or % false. When this property is true, IQ imbalance compensation is % applied to the transmitted signal. - EnableQuadratureTrackingChannel1ChipB = true; - %EnableLOLeakageTrackingChannel0ChipB Enable LO Leakage Tracking Channel 0 Chip B + EnableQuadratureTrackingChannel1ChipB = true + % EnableLOLeakageTrackingChannel0ChipB Enable LO Leakage Tracking Channel 0 Chip B % Option to enable quadrature tracking, specified as true or % false. When this property is true, LO leakage compensation is % applied to the transmitted signal. - EnableLOLeakageTrackingChannel0ChipB = true; - %EnableLOLeakageTrackingChannel1ChipB Enable LO Leakage Tracking Channel 1 Chip B + EnableLOLeakageTrackingChannel0ChipB = true + % EnableLOLeakageTrackingChannel1ChipB Enable LO Leakage Tracking Channel 1 Chip B % Option to enable quadrature tracking, specified as true or % false. When this property is true, LO leakage compensation is % applied to the transmitted signal. - EnableLOLeakageTrackingChannel1ChipB = true; + EnableLOLeakageTrackingChannel1ChipB = true end - - properties(Logical, Nontunable) - %EnableQuadratureCalibrationChipB Enable Quadrature Calibration Chip B - % Option to enable quadrature calibration on initialization, - % specified as true or false. When this property is true, IQ + + properties (Logical, Nontunable) + % EnableQuadratureCalibrationChipB Enable Quadrature Calibration Chip B + % Option to enable quadrature calibration on initialization, + % specified as true or false. When this property is true, IQ % imbalance compensation is applied to the input signal. - EnableQuadratureCalibrationChipB = true; - %EnableLOLeakageCorrectionChipB Enable LO Leakage Correction Chip B + EnableQuadratureCalibrationChipB = true + % EnableLOLeakageCorrectionChipB Enable LO Leakage Correction Chip B % Option to enable phase tracking, specified as true or % false. When this property is true, at initialization LO leakage % correction will be applied - EnableLOLeakageCorrectionChipB = true; - %EnableLOLeakageCorrectionExternalChipB Enable LO Leakage Correction External Chip B + EnableLOLeakageCorrectionChipB = true + % EnableLOLeakageCorrectionExternalChipB Enable LO Leakage Correction External Chip B % Option to enable phase tracking, specified as true or % false. When this property is true, at initialization LO leakage % correction will be applied within an external loopback path. % Note this requires external cabling. - EnableLOLeakageCorrectionExternalChipB = false; + EnableLOLeakageCorrectionExternalChipB = false end - - properties(Logical) - %PowerdownChannel0ChipB Powerdown Channel 0 Chip B + + properties (Logical) + % PowerdownChannel0ChipB Powerdown Channel 0 Chip B % Logical which will power down TX channel 0 when set - PowerdownChannel0ChipB = false; - %PowerdownChannel1ChipB Powerdown Channel 1 Chip B + PowerdownChannel0ChipB = false + % PowerdownChannel1ChipB Powerdown Channel 1 Chip B % Logical which will power down TX channel 1 when set - PowerdownChannel1ChipB = false; + PowerdownChannel1ChipB = false end - - properties(Nontunable, Hidden, Constant) - channel_names_runtime = {'voltage0','voltage1','voltage2','voltage3',... - 'voltage4','voltage5','voltage6','voltage7'}; + + properties (Nontunable, Hidden, Constant) + channel_names_runtime = {'voltage0', 'voltage1', 'voltage2', 'voltage3', ... + 'voltage4', 'voltage5', 'voltage6', 'voltage7'} end - - properties(Nontunable, Hidden) - phyDevNameChipB = 'adrv9009-phy-b'; + + properties (Nontunable, Hidden) + phyDevNameChipB = 'adrv9009-phy-b' end - - properties(Hidden) - iioDevChipB; + + properties (Hidden) + iioDevChipB end - + methods + %% Constructor function obj = Tx(varargin) coder.allowpcode('plain'); @@ -91,191 +92,195 @@ obj = obj@adi.ADRV9009ZU11EG.Base(varargin{:}); obj.channel_names = obj.channel_names_runtime; end + % Check AttenuationChannel0ChipB function set.AttenuationChannel0ChipB(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', -41.95,'<=', 0}, ... - '', 'AttenuationChannel0ChipB'); - assert(mod(value,1/20)==0, 'Attenuation must be a multiple of 0.05'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', -41.95, '<=', 0}, ... + '', 'AttenuationChannel0ChipB'); + assert(mod(value, 1 / 20) == 0, 'Attenuation must be a multiple of 0.05'); obj.AttenuationChannel0ChipB = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeDouble(id,'hardwaregain',value,true,0,obj.iioDevChipB); %#ok + obj.setAttributeDouble(id, 'hardwaregain', value, true, 0, obj.iioDevChipB); %#ok end end + % Check AttenuationChannel1ChipB function set.AttenuationChannel1ChipB(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', -41.95,'<=', 0}, ... - '', 'AttenuationChannel1ChipB'); - assert(mod(value,1/20)==0, 'Attenuation must be a multiple of 0.05'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', -41.95, '<=', 0}, ... + '', 'AttenuationChannel1ChipB'); + assert(mod(value, 1 / 20) == 0, 'Attenuation must be a multiple of 0.05'); obj.AttenuationChannel1ChipB = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeDouble(id,'hardwaregain',value,true,0,obj.iioDevChipB); %#ok + obj.setAttributeDouble(id, 'hardwaregain', value, true, 0, obj.iioDevChipB); %#ok end end - + % Check PowerdownChannel0ChipB function set.PowerdownChannel0ChipB(obj, value) obj.PowerdownChannel0ChipB = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'powerdown',value,true,obj.iioDevChipB); + obj.setAttributeBool(id, 'powerdown', value, true, obj.iioDevChipB); end end + % Check PowerdownChannel1ChipB function set.PowerdownChannel1ChipB(obj, value) obj.PowerdownChannel1ChipB = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeBool(id,'powerdown',value,true,obj.iioDevChipB); + obj.setAttributeBool(id, 'powerdown', value, true, obj.iioDevChipB); end end - + % Check EnableQuadratureTrackingChannel0ChipB function set.EnableQuadratureTrackingChannel0ChipB(obj, value) obj.EnableQuadratureTrackingChannel0ChipB = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'quadrature_tracking_en',value,true,obj.iioDevChipB); + obj.setAttributeBool(id, 'quadrature_tracking_en', value, true, obj.iioDevChipB); end end + % Check EnableQuadratureTrackingChannel1ChipB function set.EnableQuadratureTrackingChannel1ChipB(obj, value) obj.EnableQuadratureTrackingChannel1ChipB = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeBool(id,'quadrature_tracking_en',value,true,obj.iioDevChipB); + obj.setAttributeBool(id, 'quadrature_tracking_en', value, true, obj.iioDevChipB); end end + % Check EnableLOLeakageTrackingChannel0ChipB function set.EnableLOLeakageTrackingChannel0ChipB(obj, value) obj.EnableLOLeakageTrackingChannel0ChipB = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'lo_leakage_tracking_en',value,true,obj.iioDevChipB); + obj.setAttributeBool(id, 'lo_leakage_tracking_en', value, true, obj.iioDevChipB); end end + % Check EnableLOLeakageTrackingChannel1ChipB function set.EnableLOLeakageTrackingChannel1ChipB(obj, value) obj.EnableLOLeakageTrackingChannel1ChipB = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeBool(id,'lo_leakage_tracking_en',value,true,obj.iioDevChipB); + obj.setAttributeBool(id, 'lo_leakage_tracking_en', value, true, obj.iioDevChipB); end end - - end - - methods (Access=protected) + + methods (Access = protected) % Hide unused parameters when in specific modes function flag = isInactivePropertyImpl(obj, prop) % Call the superclass method - flag = isInactivePropertyImpl@adi.common.RxTx(obj,prop); + flag = isInactivePropertyImpl@adi.common.RxTx(obj, prop); if ~any(obj.EnabledChannels == 1) - flag = flag || strcmpi(prop,'AttenuationChannel0'); + flag = flag || strcmpi(prop, 'AttenuationChannel0'); end if ~any(obj.EnabledChannels == 2) - flag = flag || strcmpi(prop,'AttenuationChannel1'); + flag = flag || strcmpi(prop, 'AttenuationChannel1'); end if ~any(obj.EnabledChannels == 3) - flag = flag || strcmpi(prop,'AttenuationChannel0ChipB'); + flag = flag || strcmpi(prop, 'AttenuationChannel0ChipB'); end if ~any(obj.EnabledChannels == 4) - flag = flag || strcmpi(prop,'AttenuationChannel1ChipB'); + flag = flag || strcmpi(prop, 'AttenuationChannel1ChipB'); end if ~any(obj.EnabledChannels == 3) && ~any(obj.EnabledChannels == 4) - flag = flag || strcmpi(prop,'CenterFrequencyChipB'); + flag = flag || strcmpi(prop, 'CenterFrequencyChipB'); end end + end - + %% API Functions methods (Hidden, Access = protected) - + function numIn = getNumInputsImpl(obj) - if strcmp(obj.DataSource,'DDS') + if strcmp(obj.DataSource, 'DDS') numIn = 0; else - numIn = obj.channelCount/2; + numIn = obj.channelCount / 2; end end - + function setupInit(obj) % Write all attributes to device once connected through set % methods % Do writes directly to hardware without using set methods. % This is required sine Simulink support doesn't support % modification to nontunable variables at SetupImpl - + obj.iioDevChipB = getDev(obj, obj.phyDevNameChipB); if obj.EnableCustomProfile writeProfileFile(obj); - writeProfileFile(obj,obj.iioDevChipB); + writeProfileFile(obj, obj.iioDevChipB); end - + % Channels need to be powered up first so we can changed things - obj.setAttributeBool('voltage0','powerdown',false,true); - obj.setAttributeBool('voltage1','powerdown',false,true); - obj.setAttributeBool('voltage0','powerdown',false,true,obj.iioDevChipB); - obj.setAttributeBool('voltage1','powerdown',false,true,obj.iioDevChipB); - + obj.setAttributeBool('voltage0', 'powerdown', false, true); + obj.setAttributeBool('voltage1', 'powerdown', false, true); + obj.setAttributeBool('voltage0', 'powerdown', false, true, obj.iioDevChipB); + obj.setAttributeBool('voltage1', 'powerdown', false, true, obj.iioDevChipB); + % LO - obj.setAttributeLongLong('altvoltage0','frequency',obj.CenterFrequency ,true); - obj.setAttributeLongLong('altvoltage0','frequency',obj.CenterFrequencyChipB ,true, 10, obj.iioDevChipB); + obj.setAttributeLongLong('altvoltage0', 'frequency', obj.CenterFrequency, true); + obj.setAttributeLongLong('altvoltage0', 'frequency', obj.CenterFrequencyChipB, true, 10, obj.iioDevChipB); % Gain - obj.setAttributeDouble('voltage0','hardwaregain',obj.AttenuationChannel0,true); - obj.setAttributeDouble('voltage1','hardwaregain',obj.AttenuationChannel1,true); - obj.setAttributeDouble('voltage0','hardwaregain',obj.AttenuationChannel0ChipB,true,10,obj.iioDevChipB); - obj.setAttributeDouble('voltage1','hardwaregain',obj.AttenuationChannel1ChipB,true,10,obj.iioDevChipB); - - obj.setAttributeBool('voltage0','quadrature_tracking_en',obj.EnableQuadratureTrackingChannel0,true); - obj.setAttributeBool('voltage1','quadrature_tracking_en',obj.EnableQuadratureTrackingChannel1,true); - obj.setAttributeBool('voltage0','lo_leakage_tracking_en',obj.EnableLOLeakageTrackingChannel0,true); - obj.setAttributeBool('voltage1','lo_leakage_tracking_en',obj.EnableLOLeakageTrackingChannel1,true); - - obj.setAttributeBool('voltage0','quadrature_tracking_en',obj.EnableQuadratureTrackingChannel0ChipB,true,obj.iioDevChipB); - obj.setAttributeBool('voltage1','quadrature_tracking_en',obj.EnableQuadratureTrackingChannel1ChipB,true,obj.iioDevChipB); - obj.setAttributeBool('voltage0','lo_leakage_tracking_en',obj.EnableLOLeakageTrackingChannel0ChipB,true,obj.iioDevChipB); - obj.setAttributeBool('voltage1','lo_leakage_tracking_en',obj.EnableLOLeakageTrackingChannel1ChipB,true,obj.iioDevChipB); - + obj.setAttributeDouble('voltage0', 'hardwaregain', obj.AttenuationChannel0, true); + obj.setAttributeDouble('voltage1', 'hardwaregain', obj.AttenuationChannel1, true); + obj.setAttributeDouble('voltage0', 'hardwaregain', obj.AttenuationChannel0ChipB, true, 10, obj.iioDevChipB); + obj.setAttributeDouble('voltage1', 'hardwaregain', obj.AttenuationChannel1ChipB, true, 10, obj.iioDevChipB); + + obj.setAttributeBool('voltage0', 'quadrature_tracking_en', obj.EnableQuadratureTrackingChannel0, true); + obj.setAttributeBool('voltage1', 'quadrature_tracking_en', obj.EnableQuadratureTrackingChannel1, true); + obj.setAttributeBool('voltage0', 'lo_leakage_tracking_en', obj.EnableLOLeakageTrackingChannel0, true); + obj.setAttributeBool('voltage1', 'lo_leakage_tracking_en', obj.EnableLOLeakageTrackingChannel1, true); + + obj.setAttributeBool('voltage0', 'quadrature_tracking_en', obj.EnableQuadratureTrackingChannel0ChipB, true, obj.iioDevChipB); + obj.setAttributeBool('voltage1', 'quadrature_tracking_en', obj.EnableQuadratureTrackingChannel1ChipB, true, obj.iioDevChipB); + obj.setAttributeBool('voltage0', 'lo_leakage_tracking_en', obj.EnableLOLeakageTrackingChannel0ChipB, true, obj.iioDevChipB); + obj.setAttributeBool('voltage1', 'lo_leakage_tracking_en', obj.EnableLOLeakageTrackingChannel1ChipB, true, obj.iioDevChipB); + % Do one shot cals - obj.setDeviceAttributeRAW('calibrate_tx_qec_en',num2str(obj.EnableQuadratureCalibration)); - obj.setDeviceAttributeRAW('calibrate_tx_lol_en',num2str(obj.EnableLOLeakageCorrection)); - obj.setDeviceAttributeRAW('calibrate_tx_lol_ext_en',num2str(obj.EnableLOLeakageCorrectionExternal)); - if strcmpi(class(obj),'adi.ADRV9009ZU11EG.Tx') - obj.setDeviceAttributeRAW('calibrate_fhm_en',num2str(obj.EnableFrequencyHoppingModeCalibration)); + obj.setDeviceAttributeRAW('calibrate_tx_qec_en', num2str(obj.EnableQuadratureCalibration)); + obj.setDeviceAttributeRAW('calibrate_tx_lol_en', num2str(obj.EnableLOLeakageCorrection)); + obj.setDeviceAttributeRAW('calibrate_tx_lol_ext_en', num2str(obj.EnableLOLeakageCorrectionExternal)); + if strcmpi(class(obj), 'adi.ADRV9009ZU11EG.Tx') + obj.setDeviceAttributeRAW('calibrate_fhm_en', num2str(obj.EnableFrequencyHoppingModeCalibration)); end - obj.setDeviceAttributeRAW('calibrate',num2str(true)); - - obj.setDeviceAttributeRAW('calibrate_tx_qec_en',num2str(obj.EnableQuadratureCalibrationChipB),obj.iioDevChipB); - obj.setDeviceAttributeRAW('calibrate_tx_lol_en',num2str(obj.EnableLOLeakageCorrectionChipB),obj.iioDevChipB); - obj.setDeviceAttributeRAW('calibrate_tx_lol_ext_en',num2str(obj.EnableLOLeakageCorrectionExternalChipB),obj.iioDevChipB); - if strcmpi(class(obj),'adi.ADRV9009ZU11EG.Tx') - obj.setDeviceAttributeRAW('calibrate_fhm_en',num2str(obj.EnableFrequencyHoppingModeCalibrationChipB),obj.iioDevChipB); + obj.setDeviceAttributeRAW('calibrate', num2str(true)); + + obj.setDeviceAttributeRAW('calibrate_tx_qec_en', num2str(obj.EnableQuadratureCalibrationChipB), obj.iioDevChipB); + obj.setDeviceAttributeRAW('calibrate_tx_lol_en', num2str(obj.EnableLOLeakageCorrectionChipB), obj.iioDevChipB); + obj.setDeviceAttributeRAW('calibrate_tx_lol_ext_en', num2str(obj.EnableLOLeakageCorrectionExternalChipB), obj.iioDevChipB); + if strcmpi(class(obj), 'adi.ADRV9009ZU11EG.Tx') + obj.setDeviceAttributeRAW('calibrate_fhm_en', num2str(obj.EnableFrequencyHoppingModeCalibrationChipB), obj.iioDevChipB); end - obj.setDeviceAttributeRAW('calibrate',num2str(true),obj.iioDevChipB); - + obj.setDeviceAttributeRAW('calibrate', num2str(true), obj.iioDevChipB); + % Bring stuff back up as desired - obj.setAttributeBool('voltage0','powerdown',obj.PowerdownChannel0,true); - obj.setAttributeBool('voltage1','powerdown',obj.PowerdownChannel1,true); - obj.setAttributeBool('voltage0','powerdown',obj.PowerdownChannel0ChipB,true,obj.iioDevChipB); - obj.setAttributeBool('voltage1','powerdown',obj.PowerdownChannel1ChipB,true,obj.iioDevChipB); - + obj.setAttributeBool('voltage0', 'powerdown', obj.PowerdownChannel0, true); + obj.setAttributeBool('voltage1', 'powerdown', obj.PowerdownChannel1, true); + obj.setAttributeBool('voltage0', 'powerdown', obj.PowerdownChannel0ChipB, true, obj.iioDevChipB); + obj.setAttributeBool('voltage1', 'powerdown', obj.PowerdownChannel1ChipB, true, obj.iioDevChipB); + % DDS - obj.ToggleDDS(strcmp(obj.DataSource,'DDS')); - if strcmp(obj.DataSource,'DDS') + obj.ToggleDDS(strcmp(obj.DataSource, 'DDS')); + if strcmp(obj.DataSource, 'DDS') obj.DDSUpdate(); end end - + end - -end +end diff --git a/+adi/+ADRV9361Z7035/Rx.m b/+adi/+ADRV9361Z7035/Rx.m index c82c2dbb..ea3f04ca 100644 --- a/+adi/+ADRV9361Z7035/Rx.m +++ b/+adi/+ADRV9361Z7035/Rx.m @@ -1,6 +1,6 @@ classdef Rx < adi.AD9361.Rx % adi.ADRV9361Z7035.Rx Receive data from the ADRV9361Z7035 SOM - % The adi.ADRV9361Z7035.Rx System object is a signal source that can + % The adi.ADRV9361Z7035.Rx System object is a signal source that can % receive complex data from the ADRV9361Z7035. % % rx = adi.ADRV9361Z7035.Rx; @@ -10,13 +10,14 @@ % % See also adi.AD9361.Rx methods + %% Constructor function obj = Rx(varargin) % Returns the matlabshared.libiio.base object coder.allowpcode('plain'); obj = obj@adi.AD9361.Rx(varargin{:}); end + end - -end +end diff --git a/+adi/+ADRV9361Z7035/Tx.m b/+adi/+ADRV9361Z7035/Tx.m index 10c8fc33..9bc28fe1 100644 --- a/+adi/+ADRV9361Z7035/Tx.m +++ b/+adi/+ADRV9361Z7035/Tx.m @@ -1,6 +1,6 @@ classdef Tx < adi.AD9361.Tx % adi.ADRV9361Z7035.Tx Transmit data from the ADRV9361Z7035 SOM - % The adi.ADRV9361Z7035.Tx System object is a signal source that can + % The adi.ADRV9361Z7035.Tx System object is a signal source that can % send complex data to the FMComms2. % % tx = adi.ADRV9361Z7035.Tx; @@ -10,13 +10,14 @@ % % See also adi.AD9361.Tx methods + %% Constructor function obj = Tx(varargin) % Returns the matlabshared.libiio.base object coder.allowpcode('plain'); obj = obj@adi.AD9361.Tx(varargin{:}); end + end - -end +end diff --git a/+adi/+ADRV9364Z7020/Rx.m b/+adi/+ADRV9364Z7020/Rx.m index 989c0a5c..1c6c4756 100644 --- a/+adi/+ADRV9364Z7020/Rx.m +++ b/+adi/+ADRV9364Z7020/Rx.m @@ -1,6 +1,6 @@ classdef Rx < adi.AD9364.Rx % adi.ADRV9364Z7020.Tx Transmit data from the ADRV9364Z7020 SOM - % The adi.ADRV9364Z7020.Tx System object is a signal source that can + % The adi.ADRV9364Z7020.Tx System object is a signal source that can % send complex data to the FMComms4. % % tx = adi.ADRV9364Z7020.Tx; @@ -10,13 +10,14 @@ % % See also adi.AD9364.Tx methods + %% Constructor function obj = Rx(varargin) % Returns the matlabshared.libiio.base object coder.allowpcode('plain'); obj = obj@adi.AD9364.Rx(varargin{:}); end + end - -end +end diff --git a/+adi/+ADRV9364Z7020/Tx.m b/+adi/+ADRV9364Z7020/Tx.m index 27a93605..7fbca190 100644 --- a/+adi/+ADRV9364Z7020/Tx.m +++ b/+adi/+ADRV9364Z7020/Tx.m @@ -10,13 +10,14 @@ % % See also adi.AD9364.Tx methods + %% Constructor function obj = Tx(varargin) % Returns the matlabshared.libiio.base object coder.allowpcode('plain'); obj = obj@adi.AD9364.Tx(varargin{:}); end + end - -end +end diff --git a/+adi/+ADRV9371/Rx.m b/+adi/+ADRV9371/Rx.m index 547dbf5a..fb613740 100644 --- a/+adi/+ADRV9371/Rx.m +++ b/+adi/+ADRV9371/Rx.m @@ -6,17 +6,18 @@ % rx = adi.AD9371.Rx; % rx = adi.AD9371.Rx('uri','192.168.2.1'); % - % Product Page + % Product Page % % See also adi.AD9371.Rx methods + %% Constructor function obj = Rx(varargin) % Returns the matlabshared.libiio.base object coder.allowpcode('plain'); obj = obj@adi.AD9371.Rx(varargin{:}); end + end - -end +end diff --git a/+adi/+ADRV9371/Tx.m b/+adi/+ADRV9371/Tx.m index afe041eb..e6e4d0a2 100644 --- a/+adi/+ADRV9371/Tx.m +++ b/+adi/+ADRV9371/Tx.m @@ -6,17 +6,18 @@ % tx = adi.AD9371.Tx; % tx = adi.AD9371.Tx('uri','192.168.2.1'); % - % Product Page + % Product Page % % See also adi.AD9371.Tx methods + %% Constructor function obj = Tx(varargin) % Returns the matlabshared.libiio.base object coder.allowpcode('plain'); obj = obj@adi.AD9371.Tx(varargin{:}); end + end - -end +end diff --git a/+adi/+FMComms2/Rx.m b/+adi/+FMComms2/Rx.m index c4df11bb..7767da9d 100644 --- a/+adi/+FMComms2/Rx.m +++ b/+adi/+FMComms2/Rx.m @@ -1,6 +1,6 @@ classdef Rx < adi.AD9361.Rx % adi.FMComms2.Rx Receive data from the FMComms2 evaluation platform - % The adi.FMComms2.Rx System object is a signal source that can + % The adi.FMComms2.Rx System object is a signal source that can % receive complex data from the FMComms2. % % rx = adi.FMComms2.Rx; @@ -10,13 +10,14 @@ % % See also adi.AD9361.Rx methods + %% Constructor function obj = Rx(varargin) % Returns the matlabshared.libiio.base object coder.allowpcode('plain'); obj = obj@adi.AD9361.Rx(varargin{:}); end + end - -end +end diff --git a/+adi/+FMComms2/Tx.m b/+adi/+FMComms2/Tx.m index ca7e770e..5e01de53 100644 --- a/+adi/+FMComms2/Tx.m +++ b/+adi/+FMComms2/Tx.m @@ -1,6 +1,6 @@ classdef Tx < adi.AD9361.Tx % adi.FMComms2.Tx Transmit data from the FMComms2 evaluation platform - % The adi.FMComms2.Tx System object is a signal source that can + % The adi.FMComms2.Tx System object is a signal source that can % send complex data to the FMComms2. % % tx = adi.FMComms2.Tx; @@ -10,13 +10,14 @@ % % See also adi.AD9361.Tx methods + %% Constructor function obj = Tx(varargin) % Returns the matlabshared.libiio.base object coder.allowpcode('plain'); obj = obj@adi.AD9361.Tx(varargin{:}); end + end - -end +end diff --git a/+adi/+FMComms3/Rx.m b/+adi/+FMComms3/Rx.m index 49f323ab..0302c2b3 100644 --- a/+adi/+FMComms3/Rx.m +++ b/+adi/+FMComms3/Rx.m @@ -10,13 +10,14 @@ % % See also adi.AD9361.Rx methods + %% Constructor function obj = Rx(varargin) % Returns the matlabshared.libiio.base object coder.allowpcode('plain'); obj = obj@adi.AD9361.Rx(varargin{:}); end + end - -end +end diff --git a/+adi/+FMComms3/Tx.m b/+adi/+FMComms3/Tx.m index 7a389465..9e356282 100644 --- a/+adi/+FMComms3/Tx.m +++ b/+adi/+FMComms3/Tx.m @@ -1,6 +1,6 @@ classdef Tx < adi.AD9361.Tx % adi.FMComms3.Tx Transmit data from the FMComms3 evaluation platform - % The adi.FMComms3.Tx System object is a signal source that can + % The adi.FMComms3.Tx System object is a signal source that can % send complex data to the FMComms2. % % tx = adi.FMComms3.Tx; @@ -10,13 +10,14 @@ % % See also adi.AD9361.Tx methods + %% Constructor function obj = Tx(varargin) % Returns the matlabshared.libiio.base object coder.allowpcode('plain'); obj = obj@adi.AD9361.Tx(varargin{:}); end + end - -end +end diff --git a/+adi/+FMComms4/Rx.m b/+adi/+FMComms4/Rx.m index 6edfe45c..0ade8a26 100644 --- a/+adi/+FMComms4/Rx.m +++ b/+adi/+FMComms4/Rx.m @@ -1,6 +1,6 @@ classdef Rx < adi.AD9364.Rx % adi.FMComms4.Tx Transmit data from the FMComms4 evaluation platform - % The adi.FMComms4.Tx System object is a signal source that can + % The adi.FMComms4.Tx System object is a signal source that can % send complex data to the FMComms4. % % tx = adi.FMComms4.Tx; @@ -10,13 +10,14 @@ % % See also adi.AD9364.Tx methods + %% Constructor function obj = Rx(varargin) % Returns the matlabshared.libiio.base object coder.allowpcode('plain'); obj = obj@adi.AD9364.Rx(varargin{:}); end + end - -end +end diff --git a/+adi/+FMComms4/Tx.m b/+adi/+FMComms4/Tx.m index aea7713d..40a0472e 100644 --- a/+adi/+FMComms4/Tx.m +++ b/+adi/+FMComms4/Tx.m @@ -10,13 +10,14 @@ % % See also adi.AD9364.Tx methods + %% Constructor function obj = Tx(varargin) % Returns the matlabshared.libiio.base object coder.allowpcode('plain'); obj = obj@adi.AD9364.Tx(varargin{:}); end + end - -end +end diff --git a/+adi/+FMComms5/Base.m b/+adi/+FMComms5/Base.m index 2a931adb..5f900158 100644 --- a/+adi/+FMComms5/Base.m +++ b/+adi/+FMComms5/Base.m @@ -1,40 +1,39 @@ -classdef (Abstract, Hidden = true) Base < adi.AD9361.Base - - %adi.FMComms5.Base Class +classdef (Abstract, Hidden = true) Base < adi.AD9361.Base + + % adi.FMComms5.Base Class % This class contains shared parameters and methods between TX and RX % classes properties (Abstract) - %CenterFrequencyChipB Center Frequency + % CenterFrequencyChipB Center Frequency % RF center frequency, specified in Hz as a scalar. The % default is 2.4e9. This property is tunable. CenterFrequencyChipB - %RFBandwidthChipB RF Bandwidth + % RFBandwidthChipB RF Bandwidth % RF Bandwidth of front-end analog filter in Hz, specified as a % scalar from 200 kHz to 56 MHz. RFBandwidthChipB end - - properties(Nontunable, Hidden) + + properties (Nontunable, Hidden) iioDevPHYChipB end - + %% API Functions methods (Hidden, Access = protected) - + function icon = getIconImpl(obj) - icon = sprintf(['FMComms5 ',obj.Type]); + icon = sprintf(['FMComms5 ', obj.Type]); end - + function writeFilterFileFMComms5ChipB(obj) fir_data_file = obj.CustomFilterFileName; fir_data_str = fileread(fir_data_file); - obj.setAttributeRAW('voltage0','filter_fir_en','0',false,obj.iioDevPHYChipB); - obj.setAttributeRAW('voltage0','filter_fir_en','0',true,obj.iioDevPHYChipB); - obj.setDeviceAttributeRAW('filter_fir_config',fir_data_str,obj.iioDevPHYChipB); - obj.setAttributeRAW('voltage0','filter_fir_en','1',true,obj.iioDevPHYChipB); - obj.setAttributeRAW('voltage0','filter_fir_en','1',false,obj.iioDevPHYChipB); + obj.setAttributeRAW('voltage0', 'filter_fir_en', '0', false, obj.iioDevPHYChipB); + obj.setAttributeRAW('voltage0', 'filter_fir_en', '0', true, obj.iioDevPHYChipB); + obj.setDeviceAttributeRAW('filter_fir_config', fir_data_str, obj.iioDevPHYChipB); + obj.setAttributeRAW('voltage0', 'filter_fir_en', '1', true, obj.iioDevPHYChipB); + obj.setAttributeRAW('voltage0', 'filter_fir_en', '1', false, obj.iioDevPHYChipB); end - + end end - diff --git a/+adi/+FMComms5/Rx.m b/+adi/+FMComms5/Rx.m index a1201185..1d9e4b74 100644 --- a/+adi/+FMComms5/Rx.m +++ b/+adi/+FMComms5/Rx.m @@ -10,110 +10,111 @@ % AD9361 Datasheet % % See also adi.FMComms2.Rx, adi.FMComms3.Rx, adi.AD9361.Rx - + properties - %CenterFrequency Center Frequency + % CenterFrequency Center Frequency % RF center frequency, specified in Hz as a scalar. The % default is 2.4e9. This property is tunable. - CenterFrequencyChipB = 2.4e9; - %RFBandwidth RF Bandwidth + CenterFrequencyChipB = 2.4e9 + % RFBandwidth RF Bandwidth % RF Bandwidth of front-end analog filter in Hz, specified as a % scalar from 200 kHz to 56 MHz. - RFBandwidthChipB = 3e6; + RFBandwidthChipB = 3e6 end - + properties - %GainControlModeChannel0ChipB Gain Control Mode Channel 0 Chip B + % GainControlModeChannel0ChipB Gain Control Mode Channel 0 Chip B % specified as one of the following: - % 'slow_attack' — For signals with slowly changing power levels - % 'fast_attack' — For signals with rapidly changing power levels - % 'manual' — For setting the gain manually with the Gain property - % 'hybrid' — For configuring hybrid AGC mode - GainControlModeChannel0ChipB = 'slow_attack'; - %GainChannel0ChipB Gain Channel 0 Chip B + % 'slow_attack' - For signals with slowly changing power levels + % 'fast_attack' - For signals with rapidly changing power levels + % 'manual' - For setting the gain manually with the Gain property + % 'hybrid' - For configuring hybrid AGC mode + GainControlModeChannel0ChipB = 'slow_attack' + % GainChannel0ChipB Gain Channel 0 Chip B % Channel 0 gain, specified as a scalar from -4 dB to 71 dB. The acceptable % minimum and maximum gain setting depends on the center % frequency. - GainChannel0ChipB = 10; - %GainControlModeChannel1ChipB Gain Control Mode Channel 1 Chip B + GainChannel0ChipB = 10 + % GainControlModeChannel1ChipB Gain Control Mode Channel 1 Chip B % specified as one of the following: - % 'slow_attack' — For signals with slowly changing power levels - % 'fast_attack' — For signals with rapidly changing power levels - % 'manual' — For setting the gain manually with the Gain property - % 'hybrid' — For configuring hybrid AGC mode - GainControlModeChannel1ChipB = 'slow_attack'; - %GainChannel1ChipB Gain Channel 1 Chip B + % 'slow_attack' - For signals with slowly changing power levels + % 'fast_attack' - For signals with rapidly changing power levels + % 'manual' - For setting the gain manually with the Gain property + % 'hybrid' - For configuring hybrid AGC mode + GainControlModeChannel1ChipB = 'slow_attack' + % GainChannel1ChipB Gain Channel 1 Chip B % Channel 1 gain, specified as a scalar from -4 dB to 71 dB. The acceptable % minimum and maximum gain setting depends on the center % frequency. - GainChannel1ChipB = 10; + GainChannel1ChipB = 10 end - + properties (Nontunable) - %DigitalLoopbackModeChipB Digital Loopback Mode Chip B + % DigitalLoopbackModeChipB Digital Loopback Mode Chip B % Option to set digital loopback mode, specified as 0, - % 1 or 2. Allows either to digitally loopback TX data + % 1 or 2. Allows either to digitally loopback TX data % into the RX path or vice versa. % Value | Mode % --------------------------- % 0 | Disable % 1 | Digital TX -> Digital RX - % 2 | RF RX -> RF TX - LoopbackModeChipB = 0; + % 2 | RF RX -> RF TX + LoopbackModeChipB = 0 end - + properties (Nontunable, Logical) % MUST BE NONTUNABLE OR SIMULINK WARNS - %EnableQuadratureTracking Enable Quadrature Tracking + % EnableQuadratureTracking Enable Quadrature Tracking % Option to enable quadrature tracking, specified as true or % false. When this property is true, IQ imbalance compensation is % applied to the input signal. - EnableQuadratureTrackingChipB = true; - %EnableRFDCTracking Enable RFDC Tracking + EnableQuadratureTrackingChipB = true + % EnableRFDCTracking Enable RFDC Tracking % Option to enable RF DC tracking, specified as true or false. % When this property is true, an RF DC blocking filter is applied % to the input signal. - EnableRFDCTrackingChipB = true; - %EnableBasebandDCTracking Enable Baseband DC Tracking + EnableRFDCTrackingChipB = true + % EnableBasebandDCTracking Enable Baseband DC Tracking % Option to enable baseband DC tracking, specified as true or % false. When this property is true, a baseband DC blocking % filter is applied to the input signal. - EnableBasebandDCTrackingChipB = true; + EnableBasebandDCTrackingChipB = true end - + properties - RFPortSelectChipB = 'A_BALANCED'; + RFPortSelectChipB = 'A_BALANCED' end - - properties(Constant, Hidden) + + properties (Constant, Hidden) GainControlModeChannel0ChipBSet = matlab.system.StringSet({ ... - 'manual','fast_attack','slow_attack','hybrid'}); + 'manual', 'fast_attack', 'slow_attack', 'hybrid'}) GainControlModeChannel1ChipBSet = matlab.system.StringSet({ ... - 'manual','fast_attack','slow_attack','hybrid'}); + 'manual', 'fast_attack', 'slow_attack', 'hybrid'}) RFPortSelectChipBSet = matlab.system.StringSet({ ... - 'A_BALANCED', 'B_BALANCED', 'C_BALANCED',... - 'A_N', 'A_P', 'B_N', 'B_P', 'C_N', 'C_P',... - 'TX_MONITOR1', 'TX_MONITOR2', 'TX_MONITOR1_2'}); + 'A_BALANCED', 'B_BALANCED', 'C_BALANCED', ... + 'A_N', 'A_P', 'B_N', 'B_P', 'C_N', 'C_P', ... + 'TX_MONITOR1', 'TX_MONITOR2', 'TX_MONITOR1_2'}) end - + properties (Hidden, Nontunable, Access = protected) - isOutputChipB = false; + isOutputChipB = false end - - properties(Nontunable, Hidden, Constant) - TypeChipB = 'Rx'; + + properties (Nontunable, Hidden, Constant) + TypeChipB = 'Rx' end - + properties (Nontunable, Hidden) - devNameChipB = 'cf-ad9361-B'; + devNameChipB = 'cf-ad9361-B' end - - properties(Nontunable, Hidden, Constant) - channel_names_runtime = {'voltage0','voltage1','voltage2','voltage3',... - 'voltage4','voltage5','voltage6','voltage7'}; - phyDevNameChipB = 'ad9361-phy-B'; + + properties (Nontunable, Hidden, Constant) + channel_names_runtime = {'voltage0', 'voltage1', 'voltage2', 'voltage3', ... + 'voltage4', 'voltage5', 'voltage6', 'voltage7'} + phyDevNameChipB = 'ad9361-phy-B' end - + methods + %% Constructor function obj = Rx(varargin) coder.allowpcode('plain'); @@ -121,193 +122,207 @@ obj.channel_names = obj.channel_names_runtime; obj.devName = 'cf-ad9361-A'; end + % Check RFPortSelect function set.RFPortSelectChipB(obj, value) obj.RFPortSelectChipB = value; if obj.ConnectedToDevice - obj.setAttributeRAW('voltage0','rf_port_select',value,false,obj.iioDevPHYChipB); %#ok + obj.setAttributeRAW('voltage0', 'rf_port_select', value, false, obj.iioDevPHYChipB); %#ok end end + % Check GainControlModeChannel0 function set.GainControlModeChannel0ChipB(obj, value) obj.GainControlModeChannel0ChipB = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeRAW(id,'gain_control_mode',value,false,obj.iioDevPHYChipB); %#ok + obj.setAttributeRAW(id, 'gain_control_mode', value, false, obj.iioDevPHYChipB); %#ok end end + % Check GainControlModeChannel1 function set.GainControlModeChannel1ChipB(obj, value) obj.GainControlModeChannel1ChipB = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeRAW(id,'gain_control_mode',value,false,obj.iioDevPHYChipB); %#ok + obj.setAttributeRAW(id, 'gain_control_mode', value, false, obj.iioDevPHYChipB); %#ok end end + % Check GainChannel0 function set.GainChannel0ChipB(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', -4,'<=', 71}, ... - '', 'Gain'); - assert(mod(value,1/4)==0, 'Gain must be a multiple of 0.25'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', -4, '<=', 71}, ... + '', 'Gain'); + assert(mod(value, 1 / 4) == 0, 'Gain must be a multiple of 0.25'); obj.GainChannel0ChipB = value; - if obj.ConnectedToDevice && strcmp(obj.GainControlModeChannel0ChipB,'manual') %#ok + if obj.ConnectedToDevice && strcmp(obj.GainControlModeChannel0ChipB, 'manual') %#ok id = 'voltage0'; - obj.setAttributeDouble(id,'hardwaregain',value,false,0,obj.iioDevPHYChipB); %#ok + obj.setAttributeDouble(id, 'hardwaregain', value, false, 0, obj.iioDevPHYChipB); %#ok end end + % Check GainChannel1 function set.GainChannel1ChipB(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', -4,'<=', 71}, ... - '', 'Gain'); - assert(mod(value,1/4)==0, 'Gain must be a multiple of 0.25'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', -4, '<=', 71}, ... + '', 'Gain'); + assert(mod(value, 1 / 4) == 0, 'Gain must be a multiple of 0.25'); obj.GainChannel1ChipB = value; - if obj.ConnectedToDevice && strcmp(obj.GainControlModeChannel1ChipB,'manual') %#ok + if obj.ConnectedToDevice && strcmp(obj.GainControlModeChannel1ChipB, 'manual') %#ok id = 'voltage1'; - obj.setAttributeDouble(id,'hardwaregain',value,false,0,obj.iioDevPHYChipB); %#ok + obj.setAttributeDouble(id, 'hardwaregain', value, false, 0, obj.iioDevPHYChipB); %#ok end end + % Check EnableQuadratureTracking function set.EnableQuadratureTrackingChipB(obj, value) obj.EnableQuadratureTrackingChipB = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'quadrature_tracking_en',value,false,obj.iioDevPHYChipB); %#ok + obj.setAttributeBool(id, 'quadrature_tracking_en', value, false, obj.iioDevPHYChipB); %#ok end end + % Check EnableRFDCTracking function set.EnableRFDCTrackingChipB(obj, value) obj.EnableRFDCTrackingChipB = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'rf_dc_offset_tracking_en',value,false,obj.iioDevPHYChipB); %#ok + obj.setAttributeBool(id, 'rf_dc_offset_tracking_en', value, false, obj.iioDevPHYChipB); %#ok end end + % Check EnableRFDCTracking function set.EnableBasebandDCTrackingChipB(obj, value) obj.EnableBasebandDCTrackingChipB = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeBool(id,'bb_dc_offset_tracking_en',value,false,obj.iioDevPHYChipB); %#ok + obj.setAttributeBool(id, 'bb_dc_offset_tracking_en', value, false, obj.iioDevPHYChipB); %#ok end end + % Check CenterFrequency function set.CenterFrequencyChipB(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'positive','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',70e6,'<=',6e9}, ... - '', 'CenterFrequency'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'positive', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 70e6, '<=', 6e9}, ... + '', 'CenterFrequency'); obj.CenterFrequencyChipB = value; if obj.ConnectedToDevice - id = sprintf('altvoltage%d',strcmp(obj.Type,'Tx')); - obj.setAttributeLongLong(id,'frequency',value,true,4,obj.iioDevPHYChipB); %#ok + id = sprintf('altvoltage%d', strcmp(obj.Type, 'Tx')); + obj.setAttributeLongLong(id, 'frequency', value, true, 4, obj.iioDevPHYChipB); %#ok end end + % Check RFBandwidth function set.RFBandwidthChipB(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'positive','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',200e3,'<=',56e6}, ... - '', 'RFBandwidth'); - + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'positive', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 200e3, '<=', 56e6}, ... + '', 'RFBandwidth'); + obj.RFBandwidthChipB = value; if obj.ConnectedToDevice && ~obj.EnableCustomFilter id = 'voltage0'; - obj.setAttributeLongLong(id,'rf_bandwidth',value,strcmp(obj.Type,'Tx'),30,obj.iioDevPHYChipB); %#ok + obj.setAttributeLongLong(id, 'rf_bandwidth', value, strcmp(obj.Type, 'Tx'), 30, obj.iioDevPHYChipB); %#ok end end + function set.LoopbackModeChipB(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',2}, ... - '', 'LoopbackMode'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 2}, ... + '', 'LoopbackMode'); obj.LoopbackModeChipB = value; if obj.ConnectedToDevice - obj.setDebugAttributeLongLong('loopback',value,1,obj.iioDevPHYChipB); %#ok + obj.setDebugAttributeLongLong('loopback', value, 1, obj.iioDevPHYChipB); %#ok end end + end - + %% API Functions methods (Hidden, Access = protected) + function setupInit(obj) % Write all attributes to device once connected through set % methods setupLibad9361(obj); - obj.iioDevPHYChipB = calllib('libiio', 'iio_context_find_device',obj.iioCtx,'ad9361-phy-B'); + obj.iioDevPHYChipB = calllib('libiio', 'iio_context_find_device', obj.iioCtx, 'ad9361-phy-B'); % Do writes directly to hardware without using set methods. % This is required sine Simulink support doesn't support % modification to nontunable variables at SetupImpl - + % Gains - if (any(obj.EnabledChannels == 1)) - obj.setAttributeRAW('voltage0','gain_control_mode',obj.GainControlModeChannel0,false); + if any(obj.EnabledChannels == 1) + obj.setAttributeRAW('voltage0', 'gain_control_mode', obj.GainControlModeChannel0, false); end - if (any(obj.EnabledChannels == 2)) - obj.setAttributeRAW('voltage1','gain_control_mode',obj.GainControlModeChannel1,false); + if any(obj.EnabledChannels == 2) + obj.setAttributeRAW('voltage1', 'gain_control_mode', obj.GainControlModeChannel1, false); end - if (any(obj.EnabledChannels == 3)) - obj.setAttributeRAW('voltage0','gain_control_mode',obj.GainControlModeChannel0ChipB,false,obj.iioDevPHYChipB); + if any(obj.EnabledChannels == 3) + obj.setAttributeRAW('voltage0', 'gain_control_mode', obj.GainControlModeChannel0ChipB, false, obj.iioDevPHYChipB); end - if (any(obj.EnabledChannels == 4)) - obj.setAttributeRAW('voltage1','gain_control_mode',obj.GainControlModeChannel1ChipB,false,obj.iioDevPHYChipB); + if any(obj.EnabledChannels == 4) + obj.setAttributeRAW('voltage1', 'gain_control_mode', obj.GainControlModeChannel1ChipB, false, obj.iioDevPHYChipB); end - if (strcmp(obj.GainControlModeChannel0,'manual') && any(obj.EnabledChannels == 1)) - obj.setAttributeDouble('voltage0','hardwaregain',obj.GainChannel0,false); + if strcmp(obj.GainControlModeChannel0, 'manual') && any(obj.EnabledChannels == 1) + obj.setAttributeDouble('voltage0', 'hardwaregain', obj.GainChannel0, false); end - if (strcmp(obj.GainControlModeChannel1,'manual') && any(obj.EnabledChannels == 2)) - obj.setAttributeDouble('voltage1','hardwaregain',obj.GainChannel1,false); + if strcmp(obj.GainControlModeChannel1, 'manual') && any(obj.EnabledChannels == 2) + obj.setAttributeDouble('voltage1', 'hardwaregain', obj.GainChannel1, false); end - if (strcmp(obj.GainControlModeChannel0ChipB,'manual') && any(obj.EnabledChannels == 3)) - obj.setAttributeDouble('voltage0','hardwaregain',obj.GainChannel0ChipB,false,0,obj.iioDevPHYChipB); + if strcmp(obj.GainControlModeChannel0ChipB, 'manual') && any(obj.EnabledChannels == 3) + obj.setAttributeDouble('voltage0', 'hardwaregain', obj.GainChannel0ChipB, false, 0, obj.iioDevPHYChipB); end - if (strcmp(obj.GainControlModeChannel1ChipB,'manual') && any(obj.EnabledChannels == 4)) - obj.setAttributeDouble('voltage1','hardwaregain',obj.GainChannel1ChipB,false,0,obj.iioDevPHYChipB); + if strcmp(obj.GainControlModeChannel1ChipB, 'manual') && any(obj.EnabledChannels == 4) + obj.setAttributeDouble('voltage1', 'hardwaregain', obj.GainChannel1ChipB, false, 0, obj.iioDevPHYChipB); end % Trackings - obj.setAttributeBool('voltage0','quadrature_tracking_en',obj.EnableQuadratureTracking,false); - obj.setAttributeBool('voltage0','rf_dc_offset_tracking_en',obj.EnableRFDCTracking,false); - obj.setAttributeBool('voltage0','bb_dc_offset_tracking_en',obj.EnableBasebandDCTracking,false); - obj.setAttributeBool('voltage0','quadrature_tracking_en',obj.EnableQuadratureTrackingChipB,false,obj.iioDevPHYChipB); - obj.setAttributeBool('voltage0','rf_dc_offset_tracking_en',obj.EnableRFDCTrackingChipB,false,obj.iioDevPHYChipB); - obj.setAttributeBool('voltage0','bb_dc_offset_tracking_en',obj.EnableBasebandDCTrackingChipB,false,obj.iioDevPHYChipB); - id = sprintf('altvoltage%d',strcmp(obj.Type,'Tx')); - obj.setAttributeLongLong(id,'frequency',obj.CenterFrequency ,true,4); - obj.setAttributeLongLong(id,'frequency',obj.CenterFrequencyChipB ,true,4,obj.iioDevPHYChipB); + obj.setAttributeBool('voltage0', 'quadrature_tracking_en', obj.EnableQuadratureTracking, false); + obj.setAttributeBool('voltage0', 'rf_dc_offset_tracking_en', obj.EnableRFDCTracking, false); + obj.setAttributeBool('voltage0', 'bb_dc_offset_tracking_en', obj.EnableBasebandDCTracking, false); + obj.setAttributeBool('voltage0', 'quadrature_tracking_en', obj.EnableQuadratureTrackingChipB, false, obj.iioDevPHYChipB); + obj.setAttributeBool('voltage0', 'rf_dc_offset_tracking_en', obj.EnableRFDCTrackingChipB, false, obj.iioDevPHYChipB); + obj.setAttributeBool('voltage0', 'bb_dc_offset_tracking_en', obj.EnableBasebandDCTrackingChipB, false, obj.iioDevPHYChipB); + id = sprintf('altvoltage%d', strcmp(obj.Type, 'Tx')); + obj.setAttributeLongLong(id, 'frequency', obj.CenterFrequency, true, 4); + obj.setAttributeLongLong(id, 'frequency', obj.CenterFrequencyChipB, true, 4, obj.iioDevPHYChipB); % Loopback Mode obj.setDebugAttributeLongLong('loopback', obj.LoopbackMode); - obj.setDebugAttributeLongLong('loopback', obj.LoopbackModeChipB,1,obj.iioDevPHYChipB); - + obj.setDebugAttributeLongLong('loopback', obj.LoopbackModeChipB, 1, obj.iioDevPHYChipB); + % Sample rates and RF bandwidth if ~obj.EnableCustomFilter if libisloaded('libad9361') - calllib('libad9361','ad9361_set_bb_rate',obj.iioDevPHY,int32(obj.SamplingRate)); - calllib('libad9361','ad9361_set_bb_rate',obj.iioDevPHYChipB,int32(obj.SamplingRate)); + calllib('libad9361', 'ad9361_set_bb_rate', obj.iioDevPHY, int32(obj.SamplingRate)); + calllib('libad9361', 'ad9361_set_bb_rate', obj.iioDevPHYChipB, int32(obj.SamplingRate)); else - obj.setAttributeLongLong('voltage0','sampling_frequency',obj.SamplingRate,true,4); - obj.setAttributeLongLong('voltage0','rf_bandwidth',obj.RFBandwidth,strcmp(obj.Type,'Tx')); - obj.setAttributeLongLong('voltage0','sampling_frequency',obj.SamplingRate,true,4,obj.iioDevPHYChipB); - obj.setAttributeLongLong('voltage0','rf_bandwidth',obj.RFBandwidthChipB,strcmp(obj.Type,'Tx'),0,obj.iioDevPHYChipB); + obj.setAttributeLongLong('voltage0', 'sampling_frequency', obj.SamplingRate, true, 4); + obj.setAttributeLongLong('voltage0', 'rf_bandwidth', obj.RFBandwidth, strcmp(obj.Type, 'Tx')); + obj.setAttributeLongLong('voltage0', 'sampling_frequency', obj.SamplingRate, true, 4, obj.iioDevPHYChipB); + obj.setAttributeLongLong('voltage0', 'rf_bandwidth', obj.RFBandwidthChipB, strcmp(obj.Type, 'Tx'), 0, obj.iioDevPHYChipB); end else writeFilterFile(obj); writeFilterFileFMComms5ChipB(obj); end - obj.setAttributeRAW('voltage0','rf_port_select',obj.RFPortSelect,false); - obj.setAttributeRAW('voltage0','rf_port_select',obj.RFPortSelectChipB,false,obj.iioDevPHYChipB); - calllib('libad9361','ad9361_fmcomms5_multichip_sync',obj.iioCtx,uint32(3)); - - if (obj.CustomAGC) + obj.setAttributeRAW('voltage0', 'rf_port_select', obj.RFPortSelect, false); + obj.setAttributeRAW('voltage0', 'rf_port_select', obj.RFPortSelectChipB, false, obj.iioDevPHYChipB); + calllib('libad9361', 'ad9361_fmcomms5_multichip_sync', obj.iioCtx, uint32(3)); + + if obj.CustomAGC % Initialize hardware to reflect debug attribute changes obj.WriteDebugAttributes(); - obj.setDebugAttributeBool('initialize',1); + obj.setDebugAttributeBool('initialize', 1); obj.WriteToRegisters(); end - if (obj.CustomAGCChipB) + if obj.CustomAGCChipB % Initialize hardware to reflect debug attribute changes obj.WriteDebugAttributesFMComms5ChipB(); - obj.setDebugAttributeBool('initialize',1,0,obj.iioDevPHYChipB); + obj.setDebugAttributeBool('initialize', 1, 0, obj.iioDevPHYChipB); obj.WriteToRegistersFMComms5ChipB(); end end + end -end \ No newline at end of file +end diff --git a/+adi/+FMComms5/TuneAGCFMComms5ChipB.m b/+adi/+FMComms5/TuneAGCFMComms5ChipB.m index 914459c2..02c7a8e5 100644 --- a/+adi/+FMComms5/TuneAGCFMComms5ChipB.m +++ b/+adi/+FMComms5/TuneAGCFMComms5ChipB.m @@ -1,288 +1,309 @@ -classdef TuneAGCFMComms5ChipB < adi.common.DebugAttribute & adi.common.RegisterReadWrite +classdef TuneAGCFMComms5ChipB < adi.common.DebugAttribute & adi.common.RegisterReadWrite properties (Nontunable, Hidden) - CustomAGCChipB = 0; - - AttackDelayChipB = 1; - PeakOverloadWaitTimeChipB = 10; - AGCLockLevelChipB = 10; - DecStepSizeFullTableCase3ChipB = 3; - ADCLargeOverloadThreshChipB = 58; - ADCSmallOverloadThreshChipB = 47; - DecStepSizeFullTableCase2ChipB = 3; - DecStepSizeFullTableCase1ChipB = 3; - LargeLMTOverloadThreshChipB = 35; - SmallLMTOverloadThreshChipB = 25; - SettlingDelayChipB = 3; - EnergyLostThreshChipB = 3; - LowPowerThreshChipB = 15; + CustomAGCChipB = 0 + + AttackDelayChipB = 1 + PeakOverloadWaitTimeChipB = 10 + AGCLockLevelChipB = 10 + DecStepSizeFullTableCase3ChipB = 3 + ADCLargeOverloadThreshChipB = 58 + ADCSmallOverloadThreshChipB = 47 + DecStepSizeFullTableCase2ChipB = 3 + DecStepSizeFullTableCase1ChipB = 3 + LargeLMTOverloadThreshChipB = 35 + SmallLMTOverloadThreshChipB = 25 + SettlingDelayChipB = 3 + EnergyLostThreshChipB = 3 + LowPowerThreshChipB = 15 IncrementGainStepChipB - FAGCLockLevelGainIncreaseUpperLimitChipB = 7; - FAGCLPThreshIncrementTimeChipB = 3; - DecPowMeasurementDurationChipB = 16; + FAGCLockLevelGainIncreaseUpperLimitChipB = 7 + FAGCLPThreshIncrementTimeChipB = 3 + DecPowMeasurementDurationChipB = 16 end - + properties (Constant, Hidden, Access = private) % Register addresses in hexadecimal - AttackDelay_Reg = '022'; - PeakOverloadWaitTime_Reg = '0FE'; - AGCLockLevel_Reg = '101'; - DecStepSizeFullTableCase3_Reg = '103'; - ADCSmallOverloadThresh_Reg = '104'; - ADCLargeOverloadThresh_Reg = '105'; - DecStepSizeFullTableCase2_Reg = '106'; - DecStepSizeFullTableCase1_Reg = '106'; - LargeLMTOverloadThresh_Reg = '108'; - SmallLMTOverloadThresh_Reg = '107'; - SettlingDelay_Reg = '111'; - EnergyLostThresh_Reg = '112'; - LowPowerThresh_Reg = '114'; - IncrementGainStep_Reg = '117'; - FAGCLockLevelGainIncreaseUpperLimit_Reg = '118'; - FAGCLPThreshIncrementTime_Reg = '11B'; - DecPowMeasurementDuration_Reg = '15C'; - + AttackDelay_Reg = '022' + PeakOverloadWaitTime_Reg = '0FE' + AGCLockLevel_Reg = '101' + DecStepSizeFullTableCase3_Reg = '103' + ADCSmallOverloadThresh_Reg = '104' + ADCLargeOverloadThresh_Reg = '105' + DecStepSizeFullTableCase2_Reg = '106' + DecStepSizeFullTableCase1_Reg = '106' + LargeLMTOverloadThresh_Reg = '108' + SmallLMTOverloadThresh_Reg = '107' + SettlingDelay_Reg = '111' + EnergyLostThresh_Reg = '112' + LowPowerThresh_Reg = '114' + IncrementGainStep_Reg = '117' + FAGCLockLevelGainIncreaseUpperLimit_Reg = '118' + FAGCLPThreshIncrementTime_Reg = '11B' + DecPowMeasurementDuration_Reg = '15C' + % Register mask in binary - AttackDelay_Mask = '11000000'; - PeakOverloadWaitTime_Mask = '11100000'; - AGCLockLevel_Mask = '10000000'; - DecStepSizeFullTableCase3_Mask = '11100011'; - DecStepSizeFullTableCase2_Mask = '10001111'; - DecStepSizeFullTableCase1_Mask = '11110000'; - LargeLMTOverloadThresh_Mask = '11000000'; - SmallLMTOverloadThresh_Mask = '11000000'; - SettlingDelay_Mask = '11100000'; - EnergyLostThresh_Mask = '11000000'; - LowPowerThresh_Mask = '10000000'; - IncrementGainStep_Mask = '00011111'; - FAGCLockLevelGainIncreaseUpperLimit_Mask = '11000000'; - DecPowMeasurementDuration_Mask = '11110000'; - + AttackDelay_Mask = '11000000' + PeakOverloadWaitTime_Mask = '11100000' + AGCLockLevel_Mask = '10000000' + DecStepSizeFullTableCase3_Mask = '11100011' + DecStepSizeFullTableCase2_Mask = '10001111' + DecStepSizeFullTableCase1_Mask = '11110000' + LargeLMTOverloadThresh_Mask = '11000000' + SmallLMTOverloadThresh_Mask = '11000000' + SettlingDelay_Mask = '11100000' + EnergyLostThresh_Mask = '11000000' + LowPowerThresh_Mask = '10000000' + IncrementGainStep_Mask = '00011111' + FAGCLockLevelGainIncreaseUpperLimit_Mask = '11000000' + DecPowMeasurementDuration_Mask = '11110000' + % Bit-shifts to be applied - DecStepSizeFullTableCase3_BitShift = 2; - DecStepSizeFullTableCase2_BitShift = 4; - IncrementGainStep_BitShift = 5; + DecStepSizeFullTableCase3_BitShift = 2 + DecStepSizeFullTableCase2_BitShift = 4 + IncrementGainStep_BitShift = 5 end - + methods + function set.AttackDelayChipB(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',63}, ... - '', 'AttackDelay'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 63}, ... + '', 'AttackDelay'); obj.AttackDelay = value; if obj.ConnectedToDevice - obj.setRegisterExtended(value, obj.AttackDelay_Reg, obj.AttackDelay_Mask,0,obj.phyDevNameChipB); + obj.setRegisterExtended(value, obj.AttackDelay_Reg, obj.AttackDelay_Mask, 0, obj.phyDevNameChipB); end end + function set.PeakOverloadWaitTimeChipB(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',31}, ... - '', 'PeakOverloadWaitTime'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 31}, ... + '', 'PeakOverloadWaitTime'); obj.PeakOverloadWaitTime = value; if obj.ConnectedToDevice - obj.setRegisterExtended(value, obj.PeakOverloadWaitTime_Reg, obj.PeakOverloadWaitTime_Mask,0,obj.phyDevNameChipB); + obj.setRegisterExtended(value, obj.PeakOverloadWaitTime_Reg, obj.PeakOverloadWaitTime_Mask, 0, obj.phyDevNameChipB); end end + function set.AGCLockLevelChipB(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',127}, ... - '', 'AGCLockLevel'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 127}, ... + '', 'AGCLockLevel'); obj.AGCLockLevel = value; if obj.ConnectedToDevice - obj.setRegisterExtended(value, obj.AGCLockLevel_Reg, obj.AGCLockLevel_Mask,0,obj.phyDevNameChipB); + obj.setRegisterExtended(value, obj.AGCLockLevel_Reg, obj.AGCLockLevel_Mask, 0, obj.phyDevNameChipB); end - end + end + function set.DecStepSizeFullTableCase3ChipB(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',7}, ... - '', 'DecStepSizeFullTableCase3'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 7}, ... + '', 'DecStepSizeFullTableCase3'); obj.DecStepSizeFullTableCase3 = value; if obj.ConnectedToDevice - obj.setRegisterExtended(value, obj.DecStepSizeFullTableCase3_Reg, obj.DecStepSizeFullTableCase3_Mask, obj.DecStepSizeFullTableCase3_BitShift,obj.phyDevNameChipB); + obj.setRegisterExtended(value, obj.DecStepSizeFullTableCase3_Reg, obj.DecStepSizeFullTableCase3_Mask, obj.DecStepSizeFullTableCase3_BitShift, obj.phyDevNameChipB); end end + function set.ADCLargeOverloadThreshChipB(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',255}, ... - '', 'ADCLargeOverloadThresh'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 255}, ... + '', 'ADCLargeOverloadThresh'); obj.ADCLargeOverloadThresh = value; if obj.ConnectedToDevice - obj.setDebugAttributeLongLong('adi,gc-adc-large-overload-thresh',value,0,obj.phyDevNameChipB); + obj.setDebugAttributeLongLong('adi,gc-adc-large-overload-thresh', value, 0, obj.phyDevNameChipB); end - end + end + function set.ADCSmallOverloadThreshChipB(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',obj.ADCLargeOverloadThresh}, ... - '', 'ADCSmallOverloadThresh'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', obj.ADCLargeOverloadThresh}, ... + '', 'ADCSmallOverloadThresh'); obj.ADCSmallOverloadThresh = value; if obj.ConnectedToDevice - obj.setDebugAttributeLongLong('adi,gc-adc-small-overload-thresh',value,0,obj.phyDevNameChipB); + obj.setDebugAttributeLongLong('adi,gc-adc-small-overload-thresh', value, 0, obj.phyDevNameChipB); end end + function set.DecStepSizeFullTableCase2ChipB(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',7}, ... - '', 'DecStepSizeFullTableCase2'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 7}, ... + '', 'DecStepSizeFullTableCase2'); obj.DecStepSizeFullTableCase2 = value; if obj.ConnectedToDevice - obj.setRegisterExtended(value, obj.DecStepSizeFullTableCase2_Reg, obj.DecStepSizeFullTableCase2_Mask, obj.DecStepSizeFullTableCase2_BitShift,obj.phyDevNameChipB); + obj.setRegisterExtended(value, obj.DecStepSizeFullTableCase2_Reg, obj.DecStepSizeFullTableCase2_Mask, obj.DecStepSizeFullTableCase2_BitShift, obj.phyDevNameChipB); end - end + end + function set.DecStepSizeFullTableCase1ChipB(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',15}, ... - '', 'DecStepSizeFullTableCase1'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 15}, ... + '', 'DecStepSizeFullTableCase1'); obj.DecStepSizeFullTableCase1 = value; if obj.ConnectedToDevice - obj.setRegisterExtended(value, obj.DecStepSizeFullTableCase1_Reg, obj.DecStepSizeFullTableCase1_Mask,obj.phyDevNameChipB); + obj.setRegisterExtended(value, obj.DecStepSizeFullTableCase1_Reg, obj.DecStepSizeFullTableCase1_Mask, obj.phyDevNameChipB); end - end + end + function set.LargeLMTOverloadThreshChipB(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',63}, ... - '', 'LargeLMTOverloadThresh'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 63}, ... + '', 'LargeLMTOverloadThresh'); obj.LargeLMTOverloadThresh = value; if obj.ConnectedToDevice - obj.setRegisterExtended(value, obj.LargeLMTOverloadThresh_Reg, obj.LargeLMTOverloadThresh_Mask,obj.phyDevNameChipB); + obj.setRegisterExtended(value, obj.LargeLMTOverloadThresh_Reg, obj.LargeLMTOverloadThresh_Mask, obj.phyDevNameChipB); end - end + end + function set.SmallLMTOverloadThreshChipB(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',obj.LargeLMTOverloadThresh}, ... - '', 'SmallLMTOverloadThresh'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', obj.LargeLMTOverloadThresh}, ... + '', 'SmallLMTOverloadThresh'); obj.SmallLMTOverloadThresh = value; if obj.ConnectedToDevice - obj.setRegisterExtended(value, obj.SmallLMTOverloadThresh_Reg, obj.SmallLMTOverloadThresh_Mask,obj.phyDevNameChipB); + obj.setRegisterExtended(value, obj.SmallLMTOverloadThresh_Reg, obj.SmallLMTOverloadThresh_Mask, obj.phyDevNameChipB); end - end + end + function set.SettlingDelayChipB(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',31}, ... - '', 'SettlingDelay'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 31}, ... + '', 'SettlingDelay'); obj.SettlingDelay = value; if obj.ConnectedToDevice - obj.setRegisterExtended(value, obj.SettlingDelay_Reg, obj.SettlingDelay_Mask,obj.phyDevNameChipB); + obj.setRegisterExtended(value, obj.SettlingDelay_Reg, obj.SettlingDelay_Mask, obj.phyDevNameChipB); end - end + end + function set.EnergyLostThreshChipB(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',63}, ... - '', 'SettlingDelay'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 63}, ... + '', 'SettlingDelay'); obj.EnergyLostThresh = value; if obj.ConnectedToDevice - obj.setRegisterExtended(value, obj.EnergyLostThresh_Reg, obj.EnergyLostThresh_Mask,obj.phyDevNameChipB); + obj.setRegisterExtended(value, obj.EnergyLostThresh_Reg, obj.EnergyLostThresh_Mask, obj.phyDevNameChipB); end - end + end + function set.LowPowerThreshChipB(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',63}, ... - '', 'LowPowerThresh'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 63}, ... + '', 'LowPowerThresh'); obj.LowPowerThresh = value; if obj.ConnectedToDevice - obj.setDebugAttributeLongLong('adi,gc-low-power-thresh',value,0,obj.phyDevNameChipB); + obj.setDebugAttributeLongLong('adi,gc-low-power-thresh', value, 0, obj.phyDevNameChipB); end - end + end + function set.IncrementGainStepChipB(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',7}, ... - '', 'IncrementGainStep'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 7}, ... + '', 'IncrementGainStep'); obj.IncrementGainStep = value; if obj.ConnectedToDevice - obj.setRegisterExtended(value, obj.IncrementGainStep_Reg, obj.IncrementGainStep_Mask, obj.IncrementGainStep_BitShift,obj.phyDevNameChipB); + obj.setRegisterExtended(value, obj.IncrementGainStep_Reg, obj.IncrementGainStep_Mask, obj.IncrementGainStep_BitShift, obj.phyDevNameChipB); end - end + end + function set.FAGCLockLevelGainIncreaseUpperLimitChipB(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',63}, ... - '', 'FAGCLockLevelGainIncreaseUpperLimit'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 63}, ... + '', 'FAGCLockLevelGainIncreaseUpperLimit'); obj.FAGCLockLevelGainIncreaseUpperLimit = value; if obj.ConnectedToDevice - obj.setDebugAttributeLongLong('adi,fagc-lock-level-gain-increase-upper-limit',value,0,obj.phyDevNameChipB); + obj.setDebugAttributeLongLong('adi,fagc-lock-level-gain-increase-upper-limit', value, 0, obj.phyDevNameChipB); end - end + end + function set.FAGCLPThreshIncrementTimeChipB(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',255}, ... - '', 'FAGCLPThreshIncrementTime'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 255}, ... + '', 'FAGCLPThreshIncrementTime'); obj.FAGCLPThreshIncrementTime = value; if obj.ConnectedToDevice - obj.setDebugAttributeLongLong('adi,fagc-lp-thresh-increment-time',value,0,obj.phyDevNameChipB); + obj.setDebugAttributeLongLong('adi,fagc-lp-thresh-increment-time', value, 0, obj.phyDevNameChipB); end - end + end + function set.DecPowMeasurementDurationChipB(obj, value) - validateattributes( value, { 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',15}, ... - '', 'DecPowMeasurementDuration'); + validateattributes(value, { 'double', 'single', 'uint32' }, ... + { 'real', 'nonnegative', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 0, '<=', 15}, ... + '', 'DecPowMeasurementDuration'); obj.DecPowMeasurementDuration = value; if obj.ConnectedToDevice - obj.setRegisterExtended(value, obj.DecPowMeasurementDuration_Reg, obj.DecPowMeasurementDuration_Mask,0,obj.phyDevNameChipB); + obj.setRegisterExtended(value, obj.DecPowMeasurementDuration_Reg, obj.DecPowMeasurementDuration_Mask, 0, obj.phyDevNameChipB); end - end + end + function WriteDebugAttributesFMComms5ChipB(obj) if obj.ConnectedToDevice - obj.setDebugAttributeLongLong('adi,gc-adc-large-overload-thresh',obj.ADCLargeOverloadThreshChipB,0,obj.phyDevNameChipB); - obj.setDebugAttributeLongLong('adi,gc-adc-small-overload-thresh',obj.ADCSmallOverloadThreshChipB,0,obj.phyDevNameChipB); - obj.setDebugAttributeLongLong('adi,gc-low-power-thresh',obj.LowPowerThreshChipB,0,obj.phyDevNameChipB); - obj.setDebugAttributeLongLong('adi,fagc-lock-level-gain-increase-upper-limit',obj.FAGCLockLevelGainIncreaseUpperLimitChipB,0,obj.phyDevNameChipB); - obj.setDebugAttributeLongLong('adi,fagc-lp-thresh-increment-time',obj.FAGCLPThreshIncrementTimeChipB,0,obj.phyDevNameChipB); + obj.setDebugAttributeLongLong('adi,gc-adc-large-overload-thresh', obj.ADCLargeOverloadThreshChipB, 0, obj.phyDevNameChipB); + obj.setDebugAttributeLongLong('adi,gc-adc-small-overload-thresh', obj.ADCSmallOverloadThreshChipB, 0, obj.phyDevNameChipB); + obj.setDebugAttributeLongLong('adi,gc-low-power-thresh', obj.LowPowerThreshChipB, 0, obj.phyDevNameChipB); + obj.setDebugAttributeLongLong('adi,fagc-lock-level-gain-increase-upper-limit', obj.FAGCLockLevelGainIncreaseUpperLimitChipB, 0, obj.phyDevNameChipB); + obj.setDebugAttributeLongLong('adi,fagc-lp-thresh-increment-time', obj.FAGCLPThreshIncrementTimeChipB, 0, obj.phyDevNameChipB); end end + function WriteToRegistersFMComms5ChipB(obj) if obj.ConnectedToDevice - obj.setRegisterExtended(obj.AttackDelayChipB, obj.AttackDelay_Reg, obj.AttackDelay_Mask,0,obj.phyDevNameChipB); - obj.setRegisterExtended(obj.PeakOverloadWaitTimeChipB, obj.PeakOverloadWaitTime_Reg, obj.PeakOverloadWaitTime_Mask,0,obj.phyDevNameChipB); - obj.setRegisterExtended(obj.AGCLockLevelChipB, obj.AGCLockLevel_Reg, obj.AGCLockLevel_Mask,0,obj.phyDevNameChipB); - obj.setRegisterExtended(obj.DecStepSizeFullTableCase3ChipB, obj.DecStepSizeFullTableCase3_Reg, obj.DecStepSizeFullTableCase3_Mask, obj.DecStepSizeFullTableCase3_BitShift,obj.phyDevNameChipB); - obj.setRegisterExtended(obj.DecStepSizeFullTableCase2ChipB, obj.DecStepSizeFullTableCase2_Reg, obj.DecStepSizeFullTableCase2_Mask, obj.DecStepSizeFullTableCase2_BitShift,obj.phyDevNameChipB); - obj.setRegisterExtended(obj.DecStepSizeFullTableCase1ChipB, obj.DecStepSizeFullTableCase1_Reg, obj.DecStepSizeFullTableCase1_Mask,0,obj.phyDevNameChipB); - obj.setRegisterExtended(obj.LargeLMTOverloadThreshChipB, obj.LargeLMTOverloadThresh_Reg, obj.LargeLMTOverloadThresh_Mask,0,obj.phyDevNameChipB); - obj.setRegisterExtended(obj.SmallLMTOverloadThreshChipB, obj.SmallLMTOverloadThresh_Reg, obj.SmallLMTOverloadThresh_Mask,0,obj.phyDevNameChipB); - obj.setRegisterExtended(obj.SettlingDelayChipB, obj.SettlingDelay_Reg, obj.SettlingDelay_Mask,0,obj.phyDevNameChipB); - obj.setRegisterExtended(obj.EnergyLostThreshChipB, obj.EnergyLostThresh_Reg, obj.EnergyLostThresh_Mask,0,obj.phyDevNameChipB); - obj.setRegisterExtended(obj.IncrementGainStepChipB, obj.IncrementGainStep_Reg, obj.IncrementGainStep_Mask, obj.IncrementGainStep_BitShift,obj.phyDevNameChipB); - obj.setRegisterExtended(obj.DecPowMeasurementDurationChipB, obj.DecPowMeasurementDuration_Reg, obj.DecPowMeasurementDuration_Mask,0,obj.phyDevNameChipB); + obj.setRegisterExtended(obj.AttackDelayChipB, obj.AttackDelay_Reg, obj.AttackDelay_Mask, 0, obj.phyDevNameChipB); + obj.setRegisterExtended(obj.PeakOverloadWaitTimeChipB, obj.PeakOverloadWaitTime_Reg, obj.PeakOverloadWaitTime_Mask, 0, obj.phyDevNameChipB); + obj.setRegisterExtended(obj.AGCLockLevelChipB, obj.AGCLockLevel_Reg, obj.AGCLockLevel_Mask, 0, obj.phyDevNameChipB); + obj.setRegisterExtended(obj.DecStepSizeFullTableCase3ChipB, obj.DecStepSizeFullTableCase3_Reg, obj.DecStepSizeFullTableCase3_Mask, obj.DecStepSizeFullTableCase3_BitShift, obj.phyDevNameChipB); + obj.setRegisterExtended(obj.DecStepSizeFullTableCase2ChipB, obj.DecStepSizeFullTableCase2_Reg, obj.DecStepSizeFullTableCase2_Mask, obj.DecStepSizeFullTableCase2_BitShift, obj.phyDevNameChipB); + obj.setRegisterExtended(obj.DecStepSizeFullTableCase1ChipB, obj.DecStepSizeFullTableCase1_Reg, obj.DecStepSizeFullTableCase1_Mask, 0, obj.phyDevNameChipB); + obj.setRegisterExtended(obj.LargeLMTOverloadThreshChipB, obj.LargeLMTOverloadThresh_Reg, obj.LargeLMTOverloadThresh_Mask, 0, obj.phyDevNameChipB); + obj.setRegisterExtended(obj.SmallLMTOverloadThreshChipB, obj.SmallLMTOverloadThresh_Reg, obj.SmallLMTOverloadThresh_Mask, 0, obj.phyDevNameChipB); + obj.setRegisterExtended(obj.SettlingDelayChipB, obj.SettlingDelay_Reg, obj.SettlingDelay_Mask, 0, obj.phyDevNameChipB); + obj.setRegisterExtended(obj.EnergyLostThreshChipB, obj.EnergyLostThresh_Reg, obj.EnergyLostThresh_Mask, 0, obj.phyDevNameChipB); + obj.setRegisterExtended(obj.IncrementGainStepChipB, obj.IncrementGainStep_Reg, obj.IncrementGainStep_Mask, obj.IncrementGainStep_BitShift, obj.phyDevNameChipB); + obj.setRegisterExtended(obj.DecPowMeasurementDurationChipB, obj.DecPowMeasurementDuration_Reg, obj.DecPowMeasurementDuration_Mask, 0, obj.phyDevNameChipB); end end + function value = ReadFromRegisterFMComms5ChipB(obj, prop_name) if obj.ConnectedToDevice switch prop_name case 'AttackDelay' - value = obj.getRegisterExtended(obj.AttackDelay_Reg, obj.AttackDelay_Mask,0,obj.phyDevNameChipB); + value = obj.getRegisterExtended(obj.AttackDelay_Reg, obj.AttackDelay_Mask, 0, obj.phyDevNameChipB); case 'PeakOverloadWaitTime' - value = obj.getRegisterExtended(obj.PeakOverloadWaitTime_Reg, obj.PeakOverloadWaitTime_Mask,0,obj.phyDevNameChipB); + value = obj.getRegisterExtended(obj.PeakOverloadWaitTime_Reg, obj.PeakOverloadWaitTime_Mask, 0, obj.phyDevNameChipB); case 'AGCLockLevel' - value = obj.getRegisterExtended(obj.AGCLockLevel_Reg, obj.AGCLockLevel_Mask,0,obj.phyDevNameChipB); + value = obj.getRegisterExtended(obj.AGCLockLevel_Reg, obj.AGCLockLevel_Mask, 0, obj.phyDevNameChipB); case 'DecStepSizeFullTableCase3' - value = obj.getRegisterExtended(obj.DecStepSizeFullTableCase3_Reg, obj.DecStepSizeFullTableCase3_Mask, obj.DecStepSizeFullTableCase3_BitShift,obj.phyDevNameChipB); + value = obj.getRegisterExtended(obj.DecStepSizeFullTableCase3_Reg, obj.DecStepSizeFullTableCase3_Mask, obj.DecStepSizeFullTableCase3_BitShift, obj.phyDevNameChipB); case 'ADCSmallOverloadThresh' - value = obj.getRegisterExtended(obj.ADCSmallOverloadThresh_Reg,0,obj.phyDevNameChipB); + value = obj.getRegisterExtended(obj.ADCSmallOverloadThresh_Reg, 0, obj.phyDevNameChipB); case 'ADCLargeOverloadThresh' - value = obj.getRegisterExtended(obj.ADCLargeOverloadThresh_Reg,0,obj.phyDevNameChipB); + value = obj.getRegisterExtended(obj.ADCLargeOverloadThresh_Reg, 0, obj.phyDevNameChipB); case 'DecStepSizeFullTableCase2' - value = obj.getRegisterExtended(obj.DecStepSizeFullTableCase2_Reg, obj.DecStepSizeFullTableCase2_Mask, obj.DecStepSizeFullTableCase2_BitShift,obj.phyDevNameChipB); + value = obj.getRegisterExtended(obj.DecStepSizeFullTableCase2_Reg, obj.DecStepSizeFullTableCase2_Mask, obj.DecStepSizeFullTableCase2_BitShift, obj.phyDevNameChipB); case 'DecStepSizeFullTableCase1' - value = obj.getRegisterExtended(obj.DecStepSizeFullTableCase1_Reg, obj.DecStepSizeFullTableCase1_Mask,0,obj.phyDevNameChipB); + value = obj.getRegisterExtended(obj.DecStepSizeFullTableCase1_Reg, obj.DecStepSizeFullTableCase1_Mask, 0, obj.phyDevNameChipB); case 'LargeLMTOverloadThresh' - value = obj.getRegisterExtended(obj.LargeLMTOverloadThresh_Reg, obj.LargeLMTOverloadThresh_Mask,0,obj.phyDevNameChipB); + value = obj.getRegisterExtended(obj.LargeLMTOverloadThresh_Reg, obj.LargeLMTOverloadThresh_Mask, 0, obj.phyDevNameChipB); case 'SmallLMTOverloadThresh' - value = obj.getRegisterExtended(obj.SmallLMTOverloadThresh_Reg, obj.SmallLMTOverloadThresh_Mask,0,obj.phyDevNameChipB); + value = obj.getRegisterExtended(obj.SmallLMTOverloadThresh_Reg, obj.SmallLMTOverloadThresh_Mask, 0, obj.phyDevNameChipB); case 'SettlingDelay' - value = obj.getRegisterExtended(obj.SettlingDelay_Reg, obj.SettlingDelay_Mask,0,obj.phyDevNameChipB); + value = obj.getRegisterExtended(obj.SettlingDelay_Reg, obj.SettlingDelay_Mask, 0, obj.phyDevNameChipB); case 'EnergyLostThresh' - value = obj.getRegisterExtended(obj.EnergyLostThresh_Reg, obj.EnergyLostThresh_Mask,0,obj.phyDevNameChipB); + value = obj.getRegisterExtended(obj.EnergyLostThresh_Reg, obj.EnergyLostThresh_Mask, 0, obj.phyDevNameChipB); case 'LowPowerThresh' - value = obj.getRegisterExtended(obj.LowPowerThresh_Reg, obj.LowPowerThresh_Mask,0,obj.phyDevNameChipB); + value = obj.getRegisterExtended(obj.LowPowerThresh_Reg, obj.LowPowerThresh_Mask, 0, obj.phyDevNameChipB); case 'IncrementGainStep' - value = obj.getRegisterExtended(obj.IncrementGainStep_Reg, obj.IncrementGainStep_Mask, obj.IncrementGainStep_BitShift,obj.phyDevNameChipB); + value = obj.getRegisterExtended(obj.IncrementGainStep_Reg, obj.IncrementGainStep_Mask, obj.IncrementGainStep_BitShift, obj.phyDevNameChipB); case 'FAGCLockLevelGainIncreaseUpperLimit' - value = obj.getRegisterExtended(obj.FAGCLockLevelGainIncreaseUpperLimit_Reg, obj.FAGCLockLevelGainIncreaseUpperLimit_Mask,0,obj.phyDevNameChipB); + value = obj.getRegisterExtended(obj.FAGCLockLevelGainIncreaseUpperLimit_Reg, obj.FAGCLockLevelGainIncreaseUpperLimit_Mask, 0, obj.phyDevNameChipB); case 'FAGCLPThreshIncrementTime' - value = obj.getRegisterExtended(obj.FAGCLPThreshIncrementTime_Reg,0,0,obj.phyDevNameChipB); + value = obj.getRegisterExtended(obj.FAGCLPThreshIncrementTime_Reg, 0, 0, obj.phyDevNameChipB); case 'DecPowMeasurementDuration' - value = obj.getRegisterExtended(obj.DecPowMeasurementDuration_Reg, obj.DecPowMeasurementDuration_Mask,0,obj.phyDevNameChipB); + value = obj.getRegisterExtended(obj.DecPowMeasurementDuration_Reg, obj.DecPowMeasurementDuration_Mask, 0, obj.phyDevNameChipB); otherwise error('Attempted to read unknown property %s\n', prop_name); end - end - end + end + end + end -end \ No newline at end of file +end diff --git a/+adi/+FMComms5/Tx.m b/+adi/+FMComms5/Tx.m index 338c983a..1504a7f0 100644 --- a/+adi/+FMComms5/Tx.m +++ b/+adi/+FMComms5/Tx.m @@ -7,331 +7,345 @@ % tx = adi.FMComms5.Tx('uri','192.168.2.1'); % % Product Page - + properties - %CenterFrequencyChipB Center Frequency + % CenterFrequencyChipB Center Frequency % RF center frequency, specified in Hz as a scalar. The % default is 2.4e9. This property is tunable. - CenterFrequencyChipB = 2.4e9; - %RFBandwidthChipB RF Bandwidth + CenterFrequencyChipB = 2.4e9 + % RFBandwidthChipB RF Bandwidth % RF Bandwidth of front-end analog filter in Hz, specified as a % scalar from 200 kHz to 56 MHz. - RFBandwidthChipB = 3e6; + RFBandwidthChipB = 3e6 end - + properties - %AttenuationChannel0ChipB Attenuation Channel 0 ChipB + % AttenuationChannel0ChipB Attenuation Channel 0 ChipB % Attenuation specified as a scalar from -89.75 to 0 dB with a % resolution of 0.25 dB. - AttenuationChannel0ChipB = -30; - %AttenuationChannel1ChipB Attenuation Channel 1 ChipB + AttenuationChannel0ChipB = -30 + % AttenuationChannel1ChipB Attenuation Channel 1 ChipB % Attenuation specified as a scalar from -89.75 to 0 dB with a % resolution of 0.25 dB. - AttenuationChannel1ChipB = -30; + AttenuationChannel1ChipB = -30 end - + properties - %DDSFrequenciesChipB DDS Frequencies + % DDSFrequenciesChipB DDS Frequencies % Frequencies values in Hz of the DDS tone generators. - % For complex data devices the input is a [2xN] matrix where - % N is the available channels on the board. For complex data - % devices this is at most max(EnabledChannels)*2. - % For non-complex data devices this is at most - % max(EnabledChannels). If N < this upper limit, other DDSs + % For complex data devices the input is a [2xN] matrix where + % N is the available channels on the board. For complex data + % devices this is at most max(EnabledChannels)*2. + % For non-complex data devices this is at most + % max(EnabledChannels). If N < this upper limit, other DDSs % are not set. - DDSFrequenciesChipB = [5e5,5e5; 5e5,5e5]; - %DDSScalesChipB DDS Scales + DDSFrequenciesChipB = [5e5, 5e5; 5e5, 5e5] + % DDSScalesChipB DDS Scales % Scale of DDS tones in range [0,1]. - % For complex data devices the input is a [2xN] matrix where - % N is the available channels on the board. For complex data - % devices this is at most max(EnabledChannels)*2. - % For non-complex data devices this is at most - % max(EnabledChannels). If N < this upper limit, other DDSs + % For complex data devices the input is a [2xN] matrix where + % N is the available channels on the board. For complex data + % devices this is at most max(EnabledChannels)*2. + % For non-complex data devices this is at most + % max(EnabledChannels). If N < this upper limit, other DDSs % are not set. - DDSScalesChipB = [1,0;0,0]; - %DDSPhasesChipB DDS Phases + DDSScalesChipB = [1, 0; 0, 0] + % DDSPhasesChipB DDS Phases % Phases of DDS tones in range [0,360000]. - % For complex data devices the input is a [2xN] matrix where - % N is the available channels on the board. For complex data - % devices this is at most max(EnabledChannels)*2. - % For non-complex data devices this is at most - % max(EnabledChannels). If N < this upper limit, other DDSs + % For complex data devices the input is a [2xN] matrix where + % N is the available channels on the board. For complex data + % devices this is at most max(EnabledChannels)*2. + % For non-complex data devices this is at most + % max(EnabledChannels). If N < this upper limit, other DDSs % are not set. - DDSPhasesChipB = [0,0;0,0]; + DDSPhasesChipB = [0, 0; 0, 0] end - + properties (Hidden, Nontunable, Access = protected) - isOutputChipB = true; + isOutputChipB = true end - - properties(Nontunable, Hidden, Constant) - TypeChipB = 'Tx'; + + properties (Nontunable, Hidden, Constant) + TypeChipB = 'Tx' end - + properties (Nontunable, Hidden) - devNameChipB = 'cf-ad9361-dds-core-B'; + devNameChipB = 'cf-ad9361-dds-core-B' end - + properties - %RFPortSelect RF Port Select + % RFPortSelect RF Port Select % 'A' % 'B' - RFPortSelectChipB = 'A'; + RFPortSelectChipB = 'A' end - - properties(Constant, Hidden) - RFPortSelectSetChipB = matlab.system.StringSet({'A', 'B'}); - end - - properties(Hidden) - iioDevChipB; + + properties (Constant, Hidden) + RFPortSelectSetChipB = matlab.system.StringSet({'A', 'B'}) + end + + properties (Hidden) + iioDevChipB end - - properties(Nontunable, Hidden, Constant) - channel_names_runtime = {'voltage0','voltage1','voltage2','voltage3',... - 'voltage4','voltage5','voltage6','voltage7'}; - phyDevNameChipB = 'ad9361-phy-B'; + + properties (Nontunable, Hidden, Constant) + channel_names_runtime = {'voltage0', 'voltage1', 'voltage2', 'voltage3', ... + 'voltage4', 'voltage5', 'voltage6', 'voltage7'} + phyDevNameChipB = 'ad9361-phy-B' end - + methods + %% Constructor function obj = Tx(varargin) coder.allowpcode('plain'); obj = obj@adi.FMComms5.Base(varargin{:}); obj.channel_names = obj.channel_names_runtime; end + % Check RFPortSelect function set.RFPortSelectChipB(obj, value) obj.RFPortSelect = value; if obj.ConnectedToDevice - obj.setAttributeRAW('voltage0','rf_port_select',value,false,obj.iioDevPHYChipB); %#ok + obj.setAttributeRAW('voltage0', 'rf_port_select', value, false, obj.iioDevPHYChipB); %#ok end end + % Check Attenuation function set.AttenuationChannel0ChipB(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', -89.75,'<=', 0}, ... - '', 'Attenuation'); - assert(mod(value,1/4)==0, 'Attenuation must be a multiple of 0.25'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', -89.75, '<=', 0}, ... + '', 'Attenuation'); + assert(mod(value, 1 / 4) == 0, 'Attenuation must be a multiple of 0.25'); obj.AttenuationChannel0ChipB = value; if obj.ConnectedToDevice id = 'voltage0'; - obj.setAttributeDouble(id,'hardwaregain',value,true,0,obj.iioDevPHYChipB); %#ok + obj.setAttributeDouble(id, 'hardwaregain', value, true, 0, obj.iioDevPHYChipB); %#ok end end + % Check Attenuation function set.AttenuationChannel1ChipB(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', -89.75,'<=', 0}, ... - '', 'Attenuation'); - assert(mod(value,1/4)==0, 'Attenuation must be a multiple of 0.25'); + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'scalar', 'finite', 'nonnan', 'nonempty', '>=', -89.75, '<=', 0}, ... + '', 'Attenuation'); + assert(mod(value, 1 / 4) == 0, 'Attenuation must be a multiple of 0.25'); obj.AttenuationChannel1ChipB = value; if obj.ConnectedToDevice id = 'voltage1'; - obj.setAttributeDouble(id,'hardwaregain',value,true,0,obj.iioDevPHYChipB); %#ok + obj.setAttributeDouble(id, 'hardwaregain', value, true, 0, obj.iioDevPHYChipB); %#ok end end + % Check CenterFrequency - function set.CenterFrequencyChipB(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'positive','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',70e6,'<=',6e9}, ... - '', 'CenterFrequency'); + function set.CenterFrequencyChipB(obj, value) + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'positive', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 70e6, '<=', 6e9}, ... + '', 'CenterFrequency'); obj.CenterFrequencyChipB = value; if obj.ConnectedToDevice - id = sprintf('altvoltage%d',strcmp(obj.Type,'Tx')); - obj.setAttributeLongLong(id,'frequency',value,true,8,obj.iioDevPHYChipB); %#ok + id = sprintf('altvoltage%d', strcmp(obj.Type, 'Tx')); + obj.setAttributeLongLong(id, 'frequency', value, true, 8, obj.iioDevPHYChipB); %#ok end end + % Check RFBandwidth - function set.RFBandwidthChipB(obj, value) - validateattributes( value, { 'double','single' }, ... - { 'real', 'positive','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',200e3,'<=',40e6}, ... - '', 'RFBandwidth'); + function set.RFBandwidthChipB(obj, value) + validateattributes(value, { 'double', 'single' }, ... + { 'real', 'positive', 'scalar', 'finite', 'nonnan', 'nonempty', 'integer', '>=', 200e3, '<=', 40e6}, ... + '', 'RFBandwidth'); obj.RFBandwidthChipB = value; if obj.ConnectedToDevice && ~obj.EnableCustomFilter id = 'voltage0'; - obj.setAttributeLongLong(id,'rf_bandwidth',value,strcmp(obj.Type,'Tx'),30,obj.iioDevPHYChipB); %#ok + obj.setAttributeLongLong(id, 'rf_bandwidth', value, strcmp(obj.Type, 'Tx'), 30, obj.iioDevPHYChipB); %#ok end end + % Check DDSFrequenciesChipB function set.DDSFrequenciesChipB(obj, value) s = size(value); c1 = s(1) == 2; c2 = s(2) > 0; if isempty(obj.dds_channel_names) - chans = length(obj.channel_names); - else - chans = length(obj.dds_channel_names); + chans = length(obj.channel_names); + else + chans = length(obj.dds_channel_names); end c3 = s(2) <= chans; - assert(c1 && c2 && c3,... - sprintf(['DDSFrequenciesChipB expected to be size [2xN]',... - ' where 1<=N<=%d'],... - chans)); - + assert(c1 && c2 && c3, ... + sprintf(['DDSFrequenciesChipB expected to be size [2xN]', ... + ' where 1<=N<=%d'], ... + chans)); + obj.DDSFrequenciesChipB = value; if obj.ConnectedToDevice obj.DDSUpdateChipB(); end end + % Check DDSScalesChipB function set.DDSScalesChipB(obj, value) s = size(value); c1 = s(1) == 2; c2 = s(2) > 0; if isempty(obj.dds_channel_names) - chans = length(obj.channel_names); - else - chans = length(obj.dds_channel_names); + chans = length(obj.channel_names); + else + chans = length(obj.dds_channel_names); end c3 = s(2) <= chans; - assert(c1 && c2 && c3,... - sprintf(['DDSScalesChipB expected to be size [2xN]',... - ' where 1<=N<=%d'],... - chans)); - assert(~any(value>1,'all'),'DDSScalesChipB cannot > 1'); - assert(~any(value<0,'all'),'DDSScalesChipB cannot < 0'); - + assert(c1 && c2 && c3, ... + sprintf(['DDSScalesChipB expected to be size [2xN]', ... + ' where 1<=N<=%d'], ... + chans)); + assert(~any(value > 1, 'all'), 'DDSScalesChipB cannot > 1'); + assert(~any(value < 0, 'all'), 'DDSScalesChipB cannot < 0'); + obj.DDSScalesChipB = value; if obj.ConnectedToDevice obj.DDSUpdateChipB(); end end + % Check DDSPhasesChipB function set.DDSPhasesChipB(obj, value) s = size(value); c1 = s(1) == 2; c2 = s(2) > 0; if isempty(obj.dds_channel_names) - chans = length(obj.channel_names); - else - chans = length(obj.dds_channel_names); + chans = length(obj.channel_names); + else + chans = length(obj.dds_channel_names); end c3 = s(2) <= chans; - assert(c1 && c2 && c3,... - sprintf(['DDSPhasesChipB expected to be size [2xN]',... - ' where 1<=N<=%d'],... - chans)); - assert(~any(value>360000,'all'),'DDSPhasesChipB cannot > 360000'); - assert(~any(value<0,'all'),'DDSPhasesChipB cannot < 0'); - + assert(c1 && c2 && c3, ... + sprintf(['DDSPhasesChipB expected to be size [2xN]', ... + ' where 1<=N<=%d'], ... + chans)); + assert(~any(value > 360000, 'all'), 'DDSPhasesChipB cannot > 360000'); + assert(~any(value < 0, 'all'), 'DDSPhasesChipB cannot < 0'); + obj.DDSPhasesChipB = value; if obj.ConnectedToDevice obj.DDSUpdateChipB(); end end + end - - methods (Access=protected) + + methods (Access = protected) + % Hide unused parameters when in specific modes function flag = isInactivePropertyImpl(obj, prop) % Call the superclass method - flag = isInactivePropertyImpl@adi.common.RxTx(obj,prop); + flag = isInactivePropertyImpl@adi.common.RxTx(obj, prop); if ~any(obj.EnabledChannels == 1) - flag = flag || strcmpi(prop,'AttenuationChannel0'); + flag = flag || strcmpi(prop, 'AttenuationChannel0'); end if ~any(obj.EnabledChannels == 2) - flag = flag || strcmpi(prop,'AttenuationChannel1'); + flag = flag || strcmpi(prop, 'AttenuationChannel1'); end if ~any(obj.EnabledChannels == 3) - flag = flag || strcmpi(prop,'AttenuationChannel0ChipB'); + flag = flag || strcmpi(prop, 'AttenuationChannel0ChipB'); end if ~any(obj.EnabledChannels == 4) - flag = flag || strcmpi(prop,'AttenuationChannel1ChipB'); + flag = flag || strcmpi(prop, 'AttenuationChannel1ChipB'); end if ~any(obj.EnabledChannels == 3) && ~any(obj.EnabledChannels == 4) - flag = flag || strcmpi(prop,'CenterFrequencyChipB'); + flag = flag || strcmpi(prop, 'CenterFrequencyChipB'); end end + end - + %% API Functions methods (Hidden, Access = protected) + function DDSUpdateChipB(obj) %% Set frequencies s = size(obj.DDSFrequenciesChipB); indx = 0; - for channel=1:s(2) + for channel = 1:s(2) for toneIdx = 1:2 - id = sprintf('altvoltage%d',indx); + id = sprintf('altvoltage%d', indx); indx = indx + 1; - chanPtr = getChan(obj,obj.iioDevChipB,id,true); - iio_channel_attr_write_double(obj,chanPtr,'frequency',obj.DDSFrequenciesChipB(toneIdx,channel)); + chanPtr = getChan(obj, obj.iioDevChipB, id, true); + iio_channel_attr_write_double(obj, chanPtr, 'frequency', obj.DDSFrequenciesChipB(toneIdx, channel)); end end %% Set scales s = size(obj.DDSScalesChipB); indx = 0; - for channel=1:s(2) + for channel = 1:s(2) for toneIdx = 1:2 - id = sprintf('altvoltage%d',indx); + id = sprintf('altvoltage%d', indx); indx = indx + 1; - chanPtr = getChan(obj,obj.iioDevChipB,id,true); - iio_channel_attr_write_double(obj,chanPtr,'scale',obj.DDSScalesChipB(toneIdx,channel)); + chanPtr = getChan(obj, obj.iioDevChipB, id, true); + iio_channel_attr_write_double(obj, chanPtr, 'scale', obj.DDSScalesChipB(toneIdx, channel)); end end %% Set phases s = size(obj.DDSPhasesChipB); indx = 0; - for channel=1:s(2) + for channel = 1:s(2) for toneIdx = 1:2 - id = sprintf('altvoltage%d',indx); + id = sprintf('altvoltage%d', indx); indx = indx + 1; - chanPtr = getChan(obj,obj.iioDevChipB,id,true); - iio_channel_attr_write_double(obj,chanPtr,'phase',obj.DDSPhasesChipB(toneIdx,channel)); + chanPtr = getChan(obj, obj.iioDevChipB, id, true); + iio_channel_attr_write_double(obj, chanPtr, 'phase', obj.DDSPhasesChipB(toneIdx, channel)); end end end - + function setupInit(obj) obj.iioDevChipB = getDev(obj, obj.devNameChipB); - + % Write all attributes to device once connected through set % methods setupLibad9361(obj); - obj.iioDevPHYChipB = calllib('libiio', 'iio_context_find_device',obj.iioCtx,'ad9361-phy-B'); - + obj.iioDevPHYChipB = calllib('libiio', 'iio_context_find_device', obj.iioCtx, 'ad9361-phy-B'); + % Do writes directly to hardware without using set methods. % This is required sine Simulink support doesn't support % modification to nontunable variables at SetupImpl id = 'altvoltage1'; - obj.setAttributeLongLong(id,'frequency',obj.CenterFrequency,true,8); - obj.setAttributeLongLong(id,'frequency',obj.CenterFrequencyChipB,true,8,obj.iioDevPHYChipB); + obj.setAttributeLongLong(id, 'frequency', obj.CenterFrequency, true, 8); + obj.setAttributeLongLong(id, 'frequency', obj.CenterFrequencyChipB, true, 8, obj.iioDevPHYChipB); if ~obj.EnableCustomFilter if libisloaded('libad9361') - calllib('libad9361','ad9361_set_bb_rate',obj.iioDevPHY,int32(obj.SamplingRate)); - calllib('libad9361','ad9361_set_bb_rate',obj.iioDevPHYChipB,int32(obj.SamplingRate)); + calllib('libad9361', 'ad9361_set_bb_rate', obj.iioDevPHY, int32(obj.SamplingRate)); + calllib('libad9361', 'ad9361_set_bb_rate', obj.iioDevPHYChipB, int32(obj.SamplingRate)); else - obj.setAttributeLongLong('voltage0','sampling_frequency',obj.SamplingRate,true,4); - obj.setAttributeLongLong('voltage0','rf_bandwidth',obj.RFBandwidth,strcmp(obj.Type,'Tx')); - obj.setAttributeLongLong('voltage0','sampling_frequency',obj.SamplingRate,true,4,obj.iioDevPHYChipB); - obj.setAttributeLongLong('voltage0','rf_bandwidth',obj.RFBandwidthChipB,strcmp(obj.Type,'Tx'),[],obj.iioDevPHYChipB); + obj.setAttributeLongLong('voltage0', 'sampling_frequency', obj.SamplingRate, true, 4); + obj.setAttributeLongLong('voltage0', 'rf_bandwidth', obj.RFBandwidth, strcmp(obj.Type, 'Tx')); + obj.setAttributeLongLong('voltage0', 'sampling_frequency', obj.SamplingRate, true, 4, obj.iioDevPHYChipB); + obj.setAttributeLongLong('voltage0', 'rf_bandwidth', obj.RFBandwidthChipB, strcmp(obj.Type, 'Tx'), [], obj.iioDevPHYChipB); end else writeFilterFile(obj); writeFilterFileFMComms5ChipB(obj); - end - - if (any(obj.EnabledChannels == 1)) - obj.setAttributeDouble('voltage0','hardwaregain',obj.AttenuationChannel0,true); end - if (any(obj.EnabledChannels == 2)) - obj.setAttributeDouble('voltage1','hardwaregain',obj.AttenuationChannel1,true); + + if any(obj.EnabledChannels == 1) + obj.setAttributeDouble('voltage0', 'hardwaregain', obj.AttenuationChannel0, true); + end + if any(obj.EnabledChannels == 2) + obj.setAttributeDouble('voltage1', 'hardwaregain', obj.AttenuationChannel1, true); end - if (any(obj.EnabledChannels == 3)) - obj.setAttributeDouble('voltage0','hardwaregain',obj.AttenuationChannel0ChipB,true,obj.iioDevPHYChipB); + if any(obj.EnabledChannels == 3) + obj.setAttributeDouble('voltage0', 'hardwaregain', obj.AttenuationChannel0ChipB, true, obj.iioDevPHYChipB); end - if (any(obj.EnabledChannels == 4)) - obj.setAttributeDouble('voltage1','hardwaregain',obj.AttenuationChannel1ChipB,true,obj.iioDevPHYChipB); + if any(obj.EnabledChannels == 4) + obj.setAttributeDouble('voltage1', 'hardwaregain', obj.AttenuationChannel1ChipB, true, obj.iioDevPHYChipB); end - obj.ToggleDDS(strcmp(obj.DataSource,'DDS')); - if strcmp(obj.DataSource,'DDS') - obj.DDSUpdate(); + obj.ToggleDDS(strcmp(obj.DataSource, 'DDS')); + if strcmp(obj.DataSource, 'DDS') + obj.DDSUpdate(); obj.DDSUpdateChipB(); end - obj.setAttributeRAW('voltage0','rf_port_select',obj.RFPortSelect,true); - obj.setAttributeRAW('voltage0','rf_port_select',obj.RFPortSelectChipB,true,obj.iioDevPHYChipB); + obj.setAttributeRAW('voltage0', 'rf_port_select', obj.RFPortSelect, true); + obj.setAttributeRAW('voltage0', 'rf_port_select', obj.RFPortSelectChipB, true, obj.iioDevPHYChipB); end + end -end \ No newline at end of file +end diff --git a/+adi/+Pluto/Rx.m b/+adi/+Pluto/Rx.m index 1a7f4930..3446495c 100644 --- a/+adi/+Pluto/Rx.m +++ b/+adi/+Pluto/Rx.m @@ -1,6 +1,6 @@ classdef Rx < adi.AD9363.Rx % adi.Pluto.Tx Transmit data from the Pluto evaluation platform - % The adi.Pluto.Tx System object is a signal source that can + % The adi.Pluto.Tx System object is a signal source that can % send complex data to the Pluto. % % tx = adi.Pluto.Tx; @@ -8,15 +8,16 @@ % % Product Page % - % See also adi.AD9363.Tx + % See also adi.AD9363.Tx methods + %% Constructor function obj = Rx(varargin) % Returns the matlabshared.libiio.base object coder.allowpcode('plain'); obj = obj@adi.AD9363.Rx(varargin{:}); end + end - -end +end diff --git a/+adi/+Pluto/Tx.m b/+adi/+Pluto/Tx.m index 2a32fac7..d4b64a85 100644 --- a/+adi/+Pluto/Tx.m +++ b/+adi/+Pluto/Tx.m @@ -10,13 +10,14 @@ % % See also adi.AD9363.Tx methods + %% Constructor function obj = Tx(varargin) % Returns the matlabshared.libiio.base object coder.allowpcode('plain'); obj = obj@adi.AD9363.Tx(varargin{:}); end + end - -end +end diff --git a/+adi/+utils/ADIWorkFlow.m b/+adi/+utils/ADIWorkFlow.m index fd46b8ff..44fded89 100644 --- a/+adi/+utils/ADIWorkFlow.m +++ b/+adi/+utils/ADIWorkFlow.m @@ -1,172 +1,176 @@ classdef ADIWorkFlow < matlab.hwmgr.internal.hwsetup.Workflow - - properties(Constant) - % Properties inherited from Workflow class - BaseCode = 'ADIBSP'; - end - - properties - % Properties inherited from Workflow class - Name = 'Hardware Setup App for Analog Devices Board Support Packages' - FirstScreenID - ResourceDir - ShowExamples = true; - InstalledUdevRule - DriverInstalled - CompilerConfigured - InstallDriverWorkflow = false - ExpectedFirmwareVersion = '' - CurrentFirmwareVersion = '' - UpdateFirmwareWorkflow = false - UpdateFirmwareSelected = true - HardwareInterface - Testing = false - end - - methods - % Class Constructor - function obj = ADIWorkFlow(varargin) - obj@matlab.hwmgr.internal.hwsetup.Workflow(varargin{:}) - -% obj.HardwareInterface = plutoradio.internal.hwsetup.HardwareInterface; - -% obj.DriverInstalled = ... -% matlab.hwmgr.internal.hwsetup.register.PlutoRadioWorkFlow.checkDriver(); - - determineFirstScreen(obj); - -% obj.ResourceDir = fullfile(plutoradio.internal.getRootDir, 'resources'); - - % Setup MATLAB session for PlutoSDR HSP -% dev = sdrdev('Pluto'); - - % Consider saving path, etc. - + + properties (Constant) + % Properties inherited from Workflow class + BaseCode = 'ADIBSP' end - - function determineFirstScreen(obj) -% arch = computer('arch'); -% if (obj.DriverInstalled || strcmp(arch, 'maci64')) -% firstScreen = 'plutoradio.internal.hwsetup.ConnectHardware'; -% else -% switch arch -% case 'win64' -% firstScreen = 'plutoradio.internal.hwsetup.InstallDriverWindows'; -% case 'glnxa64' -% firstScreen = 'plutoradio.internal.hwsetup.InstallDriverLinux'; -% end -% end - -% firstScreen = 'adi.InstallDriverLinux'; - - firstScreen = 'adi.Step1'; - obj.FirstScreenID = firstScreen; + + properties + % Properties inherited from Workflow class + Name = 'Hardware Setup App for Analog Devices Board Support Packages' + FirstScreenID + ResourceDir + ShowExamples = true + InstalledUdevRule + DriverInstalled + CompilerConfigured + InstallDriverWorkflow = false + ExpectedFirmwareVersion = '' + CurrentFirmwareVersion = '' + UpdateFirmwareWorkflow = false + UpdateFirmwareSelected = true + HardwareInterface + Testing = false end - - function refocus(obj) - f = findall(0, 'type', 'figure', 'Name', 'Hardware Setup'); - idx = strfind(obj.FirstScreenID, '.'); - tag = strrep(obj.FirstScreenID(1:idx(end)), '.', '_'); - for p=1:length(f) - if contains(f(p).Tag, tag) - pause(3); - figure(f(1)); + + methods + + % Class Constructor + function obj = ADIWorkFlow(varargin) + obj@matlab.hwmgr.internal.hwsetup.Workflow(varargin{:}); + + % obj.HardwareInterface = plutoradio.internal.hwsetup.HardwareInterface; + + % obj.DriverInstalled = ... + % matlab.hwmgr.internal.hwsetup.register.PlutoRadioWorkFlow.checkDriver(); + + determineFirstScreen(obj); + + % obj.ResourceDir = fullfile(plutoradio.internal.getRootDir, 'resources'); + + % Setup MATLAB session for PlutoSDR HSP + % dev = sdrdev('Pluto'); + + % Consider saving path, etc. + end - end - end - - function success = isFirmwareCompatible(obj) - success = false; - - [expVer,curVer] = getFirmwareVersion(obj.HardwareInterface); - if isempty(curVer) - errordlg(obj, ... - message('plutoradio:hwsetup:UpdateFirmware_USBSearchFailed', '').getString); - else - obj.CurrentFirmwareVersion = curVer; - obj.ExpectedFirmwareVersion = expVer; - if expVer == curVer - success = true; + + function determineFirstScreen(obj) + % arch = computer('arch'); + % if (obj.DriverInstalled || strcmp(arch, 'maci64')) + % firstScreen = 'plutoradio.internal.hwsetup.ConnectHardware'; + % else + % switch arch + % case 'win64' + % firstScreen = 'plutoradio.internal.hwsetup.InstallDriverWindows'; + % case 'glnxa64' + % firstScreen = 'plutoradio.internal.hwsetup.InstallDriverLinux'; + % end + % end + + % firstScreen = 'adi.InstallDriverLinux'; + + firstScreen = 'adi.Step1'; + obj.FirstScreenID = firstScreen; end - end - end - - function setSerialNum(obj, serialNum) - obj.HardwareInterface.SerialNum = serialNum; - end - - function serialNum = getSerialNum(obj) - serialNum = obj.HardwareInterface.SerialNum; - end - - function setRadioID(obj, radioID) - obj.HardwareInterface.RadioID = radioID; - end - - function radioID = getRadioID(obj) - radioID = obj.HardwareInterface.RadioID; - end - - function varargout = warndlg(~, msg) - dlgHandle = warndlg(msg, ... - message('plutoradio:hwsetup:UpdateFirmware_Title').getString); - if nargout > 0 - varargout{1} = dlgHandle; - end - end - - function varargout = errordlg(~, msg) - dlgHandle = errordlg(msg, ... - message('plutoradio:hwsetup:UpdateFirmware_Title').getString); - if nargout > 0 - varargout{1} = dlgHandle; - end - end - end - - methods (Static) - function flag = checkDriver() - % Assume driver is installed - flag = true; - - switch computer('arch') - case 'win64' - try - installPath = winqueryreg(... - 'HKEY_LOCAL_MACHINE',... - 'SOFTWARE\Analog Devices\PlutoSDR-M2k-USB-Win-Drivers\Settings',... - 'InstallPath'); %#ok - catch me - if strcmp(me.identifier, 'MATLAB:WINQUERYREG:invalidkey') - flag = false; + + function refocus(obj) + f = findall(0, 'type', 'figure', 'Name', 'Hardware Setup'); + idx = strfind(obj.FirstScreenID, '.'); + tag = strrep(obj.FirstScreenID(1:idx(end)), '.', '_'); + for p = 1:length(f) + if contains(f(p).Tag, tag) + pause(3); + figure(f(1)); + end end - end - case 'glnxa64' - udevFileName = '90-plutosdr-mw.rules'; - udevFile = fullfile('/lib/udev/rules.d', udevFileName); - if ~exist(udevFile, 'file') - flag = false; - else - % Check the content - expectedContent = sprintf('%s\n%s\n', ... - '# PlutoSDR', ... - ['SUBSYSTEMS=="usb", ATTRS{idVendor}=="0456", '... - 'ATTRS{idProduct}=="b673", MODE:="0666"']); - fid = fopen(udevFile, 'r'); - fileContent = fscanf(fid, '%s', inf); - fclose(fid); - if ~strcmp(replace(expectedContent, {' ', newline}, ''), fileContent) - flag = false; + end + + function success = isFirmwareCompatible(obj) + success = false; + + [expVer, curVer] = getFirmwareVersion(obj.HardwareInterface); + if isempty(curVer) + errordlg(obj, ... + message('plutoradio:hwsetup:UpdateFirmware_USBSearchFailed', '').getString); + else + obj.CurrentFirmwareVersion = curVer; + obj.ExpectedFirmwareVersion = expVer; + if expVer == curVer + success = true; + end + end + end + + function setSerialNum(obj, serialNum) + obj.HardwareInterface.SerialNum = serialNum; + end + + function serialNum = getSerialNum(obj) + serialNum = obj.HardwareInterface.SerialNum; + end + + function setRadioID(obj, radioID) + obj.HardwareInterface.RadioID = radioID; + end + + function radioID = getRadioID(obj) + radioID = obj.HardwareInterface.RadioID; + end + + function varargout = warndlg(~, msg) + dlgHandle = warndlg(msg, ... + message('plutoradio:hwsetup:UpdateFirmware_Title').getString); + if nargout > 0 + varargout{1} = dlgHandle; end - end - case 'maci64' - rootDir = plutoradio.internal.getRootDir; - command = sprintf('%s/bin/maci64/iio_info -s | grep Analog', rootDir); - [status, out] = system(command); - if status || ~contains(out, 'Analog Devices Inc. PlutoSDR (ADALM-PLUTO)') - flag = false; - end - end + end + + function varargout = errordlg(~, msg) + dlgHandle = errordlg(msg, ... + message('plutoradio:hwsetup:UpdateFirmware_Title').getString); + if nargout > 0 + varargout{1} = dlgHandle; + end + end + + end + + methods (Static) + + function flag = checkDriver() + % Assume driver is installed + flag = true; + + switch computer('arch') + case 'win64' + try + installPath = winqueryreg( ... + 'HKEY_LOCAL_MACHINE', ... + 'SOFTWARE\Analog Devices\PlutoSDR-M2k-USB-Win-Drivers\Settings', ... + 'InstallPath'); %#ok + catch me + if strcmp(me.identifier, 'MATLAB:WINQUERYREG:invalidkey') + flag = false; + end + end + case 'glnxa64' + udevFileName = '90-plutosdr-mw.rules'; + udevFile = fullfile('/lib/udev/rules.d', udevFileName); + if ~exist(udevFile, 'file') + flag = false; + else + % Check the content + expectedContent = sprintf('%s\n%s\n', ... + '# PlutoSDR', ... + ['SUBSYSTEMS=="usb", ATTRS{idVendor}=="0456", '... + 'ATTRS{idProduct}=="b673", MODE:="0666"']); + fid = fopen(udevFile, 'r'); + fileContent = fscanf(fid, '%s', inf); + fclose(fid); + if ~strcmp(replace(expectedContent, {' ', newline}, ''), fileContent) + flag = false; + end + end + case 'maci64' + rootDir = plutoradio.internal.getRootDir; + command = sprintf('%s/bin/maci64/iio_info -s | grep Analog', rootDir); + [status, out] = system(command); + if status || ~contains(out, 'Analog Devices Inc. PlutoSDR (ADALM-PLUTO)') + flag = false; + end + end + end + end - end end diff --git a/+adi/+utils/ConnectHardware.m b/+adi/+utils/ConnectHardware.m index 9fe120e0..e42c8026 100644 --- a/+adi/+utils/ConnectHardware.m +++ b/+adi/+utils/ConnectHardware.m @@ -1,113 +1,117 @@ classdef ConnectHardware < matlab.hwmgr.internal.hwsetup.ManualConfiguration - % ConnectHardware - Screen implementation to enable users to connect - % the PlutoSDR device to the host - - % Copyright 2017-2018 The MathWorks, Inc. - - properties - end - - methods - function obj = ConnectHardware(varargin) - % Call to the base class constructor - obj@matlab.hwmgr.internal.hwsetup.ManualConfiguration(varargin{:}); - - % Set the Title Text - obj.Title.Text = 'Connect Hardware';%message('plutoradio:hwsetup:ConnectHardwareTitle').getString; - - obj.ConfigurationInstructions.Text = 'Text1'; - %message('plutoradio:hwsetup:ConnectHardware_Instruction').getString; - obj.ConfigurationInstructions.Position = [20 280 430 85]; - - % Increase the Height and Width of the Image before setting the - % ImageFile - obj.ConfigurationImage.ImageFile = fullfile(obj.Workflow.ResourceDir,... - 'adalm-pluto_connect.png'); - obj.ConfigurationImage.addHeight(80); - obj.ConfigurationImage.addWidth(80); - - if isunix - if ~ismac - obj.ConfigurationInstructions.addWidth(15); - end - end - - % Set the HelpText - obj.HelpText.WhatToConsider = [... - message('plutoradio:hwsetup:ConnectHardware_WhatToConsider').getString]; - obj.HelpText.AboutSelection = ''; - obj.HelpText.Additional = ''; - - if strcmp(obj.Workflow.FirstScreenID, class(obj)) - obj.BackButton.Visible = 'off'; - obj.BackButton.Enable = 'off'; - end + % ConnectHardware - Screen implementation to enable users to connect + % the PlutoSDR device to the host + % Copyright 2017-2018 The MathWorks, Inc. + + properties end - - function restoreScreen(obj) - obj.enableScreen(); - end - - function out = getPreviousScreenID(obj) %#ok - switch computer('arch') - case 'win64' - out = 'plutoradio.internal.hwsetup.InstallDriverWindows'; - case 'maci64' - out = ''; - case 'glnxa64' - out = 'plutoradio.internal.hwsetup.InstallDriverLinux'; - end - end - - function out = getNextScreenID(obj) - % Find the connected radio - findRadio(obj); - - % Create a BusyOverlay inside the window - busyOverlay = matlab.hwmgr.internal.hwsetup.BusyOverlay.getInstance(obj.ContentPanel); - busyOverlay.Text = 'Checking firmware version'; - restoreOnCleanup = onCleanup(@()removeOverlay(busyOverlay)); - - % Check radio firmware version - success = isFirmwareCompatible(obj.Workflow); - - logMessage(obj, sprintf('isFirmwareCompatible returned %d', success)); - - if ~success - obj.Workflow.UpdateFirmwareWorkflow = true; - out = 'plutoradio.internal.hwsetup.UnexpectedFirmware'; - else - obj.Workflow.UpdateFirmwareWorkflow = false; - out = 'plutoradio.internal.hwsetup.TestConnection'; - end + + methods + + function obj = ConnectHardware(varargin) + % Call to the base class constructor + obj@matlab.hwmgr.internal.hwsetup.ManualConfiguration(varargin{:}); + + % Set the Title Text + obj.Title.Text = 'Connect Hardware'; % message('plutoradio:hwsetup:ConnectHardwareTitle').getString; + + obj.ConfigurationInstructions.Text = 'Text1'; + % message('plutoradio:hwsetup:ConnectHardware_Instruction').getString; + obj.ConfigurationInstructions.Position = [20 280 430 85]; + + % Increase the Height and Width of the Image before setting the + % ImageFile + obj.ConfigurationImage.ImageFile = fullfile(obj.Workflow.ResourceDir, ... + 'adalm-pluto_connect.png'); + obj.ConfigurationImage.addHeight(80); + obj.ConfigurationImage.addWidth(80); + + if isunix + if ~ismac + obj.ConfigurationInstructions.addWidth(15); + end + end + + % Set the HelpText + obj.HelpText.WhatToConsider = [ ... + message('plutoradio:hwsetup:ConnectHardware_WhatToConsider').getString]; + obj.HelpText.AboutSelection = ''; + obj.HelpText.Additional = ''; + + if strcmp(obj.Workflow.FirstScreenID, class(obj)) + obj.BackButton.Visible = 'off'; + obj.BackButton.Enable = 'off'; + end + + end + + function restoreScreen(obj) + obj.enableScreen(); + end + + function out = getPreviousScreenID(obj) %#ok + switch computer('arch') + case 'win64' + out = 'plutoradio.internal.hwsetup.InstallDriverWindows'; + case 'maci64' + out = ''; + case 'glnxa64' + out = 'plutoradio.internal.hwsetup.InstallDriverLinux'; + end + end + + function out = getNextScreenID(obj) + % Find the connected radio + findRadio(obj); + + % Create a BusyOverlay inside the window + busyOverlay = matlab.hwmgr.internal.hwsetup.BusyOverlay.getInstance(obj.ContentPanel); + busyOverlay.Text = 'Checking firmware version'; + restoreOnCleanup = onCleanup(@()removeOverlay(busyOverlay)); + + % Check radio firmware version + success = isFirmwareCompatible(obj.Workflow); + + logMessage(obj, sprintf('isFirmwareCompatible returned %d', success)); + + if ~success + obj.Workflow.UpdateFirmwareWorkflow = true; + out = 'plutoradio.internal.hwsetup.UnexpectedFirmware'; + else + obj.Workflow.UpdateFirmwareWorkflow = false; + out = 'plutoradio.internal.hwsetup.TestConnection'; + end + end + end - end - - methods (Access = private) - function findRadio(obj) - radios = getConnectedRadios(obj.Workflow.HardwareInterface); - numRadios = length(radios); - if numRadios == 0 - error(message('plutoradio:hwsetup:ConnectHardware_NoRadio').getString); - elseif numRadios > 1 - error(message('plutoradio:hwsetup:ConnectHardware_MoreThanOneRadio').getString); - else - if isRadioBusy(obj.Workflow.HardwareInterface, radios.RadioID) - error(message('plutoradio:hwsetup:ConnectHardware_RadioBusy', radios.RadioID)); - else - setRadioID(obj.Workflow, radios.RadioID); - setSerialNum(obj.Workflow, radios.SerialNum); - logMessage(obj, ... - sprintf('Found radio with ID: %s and SN: %s', ... - radios.RadioID, radios.SerialNum)); - end + + methods (Access = private) + + function findRadio(obj) + radios = getConnectedRadios(obj.Workflow.HardwareInterface); + numRadios = length(radios); + if numRadios == 0 + error(message('plutoradio:hwsetup:ConnectHardware_NoRadio').getString); + elseif numRadios > 1 + error(message('plutoradio:hwsetup:ConnectHardware_MoreThanOneRadio').getString); + else + if isRadioBusy(obj.Workflow.HardwareInterface, radios.RadioID) + error(message('plutoradio:hwsetup:ConnectHardware_RadioBusy', radios.RadioID)); + else + setRadioID(obj.Workflow, radios.RadioID); + setSerialNum(obj.Workflow, radios.SerialNum); + logMessage(obj, ... + sprintf('Found radio with ID: %s and SN: %s', ... + radios.RadioID, radios.SerialNum)); + end + end + end + end - end -end end function removeOverlay(busyOverlay) -busyOverlay.Visible = 'off'; -delete(busyOverlay) + busyOverlay.Visible = 'off'; + delete(busyOverlay); end diff --git a/+adi/+utils/Downloader.m b/+adi/+utils/Downloader.m index 9d24c934..58ffca5e 100644 --- a/+adi/+utils/Downloader.m +++ b/+adi/+utils/Downloader.m @@ -1,23 +1,22 @@ classdef Downloader < adi.utils.libad9361 - + properties (Constant) - PossibleDependencies = {'libad9361'}; + PossibleDependencies = {'libad9361'} end - - methods - - function download(obj,dep) + + methods + + function download(obj, dep) if nargin == 0 - fprintf('Specific dependency name on input. Options are:\n%s',obj.PossibleDependencies); + fprintf('Specific dependency name on input. Options are:\n%s', obj.PossibleDependencies); end switch dep case 'libad9361' download_libad9361(obj); otherwise - error('Unknown dependency %s',dep); + error('Unknown dependency %s', dep); end end - + end end - diff --git a/+adi/+utils/InstallDriverBase.m b/+adi/+utils/InstallDriverBase.m index a2d33286..c13c75e4 100644 --- a/+adi/+utils/InstallDriverBase.m +++ b/+adi/+utils/InstallDriverBase.m @@ -1,78 +1,82 @@ classdef InstallDriverBase < matlab.hwmgr.internal.hwsetup.TemplateBase -% Copyright 2017 The MathWorks, Inc. - - properties - InfoText1 - InfoText2 - InfoText3 - end - - methods - function obj = InstallDriverBase(varargin) - obj@matlab.hwmgr.internal.hwsetup.TemplateBase(varargin{:}); - - obj.Workflow.InstallDriverWorkflow = true; - - parentContainer = obj.ContentPanel; - - obj.InfoText1 = matlab.hwmgr.internal.hwsetup.Label.getInstance(parentContainer); - obj.InfoText1.Position = [20 290 400 80]; - obj.InfoText1.Text = ''; - obj.InfoText1.Color = matlab.hwmgr.internal.hwsetup.util.Color.WHITE; - - obj.InfoText2 = matlab.hwmgr.internal.hwsetup.Label.getInstance(parentContainer); - obj.InfoText2.Position = [20 230 400 50]; - obj.InfoText2.Text = ''; - obj.InfoText2.Color = matlab.hwmgr.internal.hwsetup.util.Color.WHITE; - - obj.InfoText3 = matlab.hwmgr.internal.hwsetup.Label.getInstance(parentContainer); - obj.InfoText3.Position = [20 170 400 50]; - obj.InfoText3.Text = ''; - obj.InfoText3.Color = matlab.hwmgr.internal.hwsetup.util.Color.WHITE; - - obj.HelpText.AboutSelection = ''; - obj.HelpText.WhatToConsider = ''; - - if strcmp(obj.Workflow.FirstScreenID, class(obj)) - obj.BackButton.Visible = 'off'; - obj.BackButton.Enable = 'off'; - end + % Copyright 2017 The MathWorks, Inc. + + properties + InfoText1 + InfoText2 + InfoText3 end - - function restoreScreen(obj) - obj.enableScreen(); + + methods + + function obj = InstallDriverBase(varargin) + obj@matlab.hwmgr.internal.hwsetup.TemplateBase(varargin{:}); + + obj.Workflow.InstallDriverWorkflow = true; + + parentContainer = obj.ContentPanel; + + obj.InfoText1 = matlab.hwmgr.internal.hwsetup.Label.getInstance(parentContainer); + obj.InfoText1.Position = [20 290 400 80]; + obj.InfoText1.Text = ''; + obj.InfoText1.Color = matlab.hwmgr.internal.hwsetup.util.Color.WHITE; + + obj.InfoText2 = matlab.hwmgr.internal.hwsetup.Label.getInstance(parentContainer); + obj.InfoText2.Position = [20 230 400 50]; + obj.InfoText2.Text = ''; + obj.InfoText2.Color = matlab.hwmgr.internal.hwsetup.util.Color.WHITE; + + obj.InfoText3 = matlab.hwmgr.internal.hwsetup.Label.getInstance(parentContainer); + obj.InfoText3.Position = [20 170 400 50]; + obj.InfoText3.Text = ''; + obj.InfoText3.Color = matlab.hwmgr.internal.hwsetup.util.Color.WHITE; + + obj.HelpText.AboutSelection = ''; + obj.HelpText.WhatToConsider = ''; + + if strcmp(obj.Workflow.FirstScreenID, class(obj)) + obj.BackButton.Visible = 'off'; + obj.BackButton.Enable = 'off'; + end + end + + function restoreScreen(obj) + obj.enableScreen(); + end + end - end - - methods (Access = protected, Abstract) - status = installDriverImpl(obj) - end - - methods (Access = protected) - function installDriver(obj) - obj.disableScreen(); - restoreOnCleanup = onCleanup(@obj.restoreScreen); - - p = matlab.hwmgr.internal.hwsetup.Panel.getInstance(obj.ContentPanel); - p.Title = ''; - b = matlab.hwmgr.internal.hwsetup.BusyOverlay.getInstance(p); - b.Text = 'Installing USB driver...'; - b.show(); - deleteOverlayOnCleanup = onCleanup(@()delete(p)); - - [status,msg] = installDriverImpl(obj); - - if status - error(message('plutoradio:hwsetup:DriverInstallFailed', msg)); - end - - refocus(obj.Workflow); + + methods (Access = protected, Abstract) + status = installDriverImpl(obj) end - - function out = getNextScreenIDImpl(obj) - out = 'adi.ConnectHardware'; - installDriver(obj); + + methods (Access = protected) + + function installDriver(obj) + obj.disableScreen(); + restoreOnCleanup = onCleanup(@obj.restoreScreen); + + p = matlab.hwmgr.internal.hwsetup.Panel.getInstance(obj.ContentPanel); + p.Title = ''; + b = matlab.hwmgr.internal.hwsetup.BusyOverlay.getInstance(p); + b.Text = 'Installing USB driver...'; + b.show(); + deleteOverlayOnCleanup = onCleanup(@()delete(p)); + + [status, msg] = installDriverImpl(obj); + + if status + error(message('plutoradio:hwsetup:DriverInstallFailed', msg)); + end + + refocus(obj.Workflow); + end + + function out = getNextScreenIDImpl(obj) + out = 'adi.ConnectHardware'; + installDriver(obj); + end + end - end end diff --git a/+adi/+utils/InstallDriverLinux.m b/+adi/+utils/InstallDriverLinux.m index 25970c56..a3c40764 100644 --- a/+adi/+utils/InstallDriverLinux.m +++ b/+adi/+utils/InstallDriverLinux.m @@ -1,60 +1,64 @@ classdef InstallDriverLinux < adi.InstallDriverBase -% Copyright 2017 The MathWorks, Inc. - - methods - function obj = InstallDriverLinux(varargin) - obj@adi.InstallDriverBase(varargin{:}); - - obj.Title.Text = 'ADI Board Support Package Installer'; - - obj.InfoText1.Position = [20 340 400 30]; - obj.InfoText1.Text = 'Test1';%message('plutoradio:hwsetup:InstallDriverLinux_InfoText1').getString; - - obj.InfoText2.Position = [20 290 400 50]; - obj.InfoText2.Text = 'Test2';%message('plutoradio:hwsetup:InstallDriverLinux_InfoText2').getString; - - obj.HelpText.AboutSelection = ''; - obj.HelpText.WhatToConsider = 'Test3';%message('plutoradio:hwsetup:InstallDriverLinux_WhatToConsider').getString; - end - - function out = getNextScreenID(obj) - % HSA infrastructure requires a "getNextScreenID" method implemented - % in the leaf class. Otherwise, it renders "Finish" button instead of - % "Next". - out = getNextScreenIDImpl(obj); + % Copyright 2017 The MathWorks, Inc. + + methods + + function obj = InstallDriverLinux(varargin) + obj@adi.InstallDriverBase(varargin{:}); + + obj.Title.Text = 'ADI Board Support Package Installer'; + + obj.InfoText1.Position = [20 340 400 30]; + obj.InfoText1.Text = 'Test1'; % message('plutoradio:hwsetup:InstallDriverLinux_InfoText1').getString; + + obj.InfoText2.Position = [20 290 400 50]; + obj.InfoText2.Text = 'Test2'; % message('plutoradio:hwsetup:InstallDriverLinux_InfoText2').getString; + + obj.HelpText.AboutSelection = ''; + obj.HelpText.WhatToConsider = 'Test3'; % message('plutoradio:hwsetup:InstallDriverLinux_WhatToConsider').getString; + end + + function out = getNextScreenID(obj) + % HSA infrastructure requires a "getNextScreenID" method implemented + % in the leaf class. Otherwise, it renders "Finish" button instead of + % "Next". + out = getNextScreenIDImpl(obj); + end + end - end - - methods (Access = protected) - function [status,out] = installDriverImpl(obj) - udevFileName = '90-plutosdr-mw.rules'; - udevrules = fullfile(tempdir, udevFileName); - fid = fopen(udevrules, 'wt'); - fprintf(fid, '%s\n%s\n', ... - '# PlutoSDR', ... - ['SUBSYSTEMS=="usb", ATTRS{idVendor}=="0456", '... - 'ATTRS{idProduct}=="b673", MODE:="0666"']); - fclose(fid); - - commandwindow - [status,out] = run(obj.Workflow.HardwareInterface, 'sudo echo', '-echo'); - - if ~status - [status,out] = run(obj.Workflow.HardwareInterface, ['sudo cp ' udevrules ' /lib/udev/rules.d']); - if ~status - [status,out] = run(obj.Workflow.HardwareInterface, 'sudo udevadm control --reload'); - if ~status - [status,out] = run(obj.Workflow.HardwareInterface, 'sudo udevadm trigger'); - end + + methods (Access = protected) + + function [status, out] = installDriverImpl(obj) + udevFileName = '90-plutosdr-mw.rules'; + udevrules = fullfile(tempdir, udevFileName); + fid = fopen(udevrules, 'wt'); + fprintf(fid, '%s\n%s\n', ... + '# PlutoSDR', ... + ['SUBSYSTEMS=="usb", ATTRS{idVendor}=="0456", '... + 'ATTRS{idProduct}=="b673", MODE:="0666"']); + fclose(fid); + + commandwindow; + [status, out] = run(obj.Workflow.HardwareInterface, 'sudo echo', '-echo'); + + if ~status + [status, out] = run(obj.Workflow.HardwareInterface, ['sudo cp ' udevrules ' /lib/udev/rules.d']); + if ~status + [status, out] = run(obj.Workflow.HardwareInterface, 'sudo udevadm control --reload'); + if ~status + [status, out] = run(obj.Workflow.HardwareInterface, 'sudo udevadm trigger'); + end + end + end + run(obj.Workflow.HardwareInterface, sprintf('rm %s', udevrules)); + + if ~status + obj.Workflow.InstalledUdevRule = ... + fullfile('/lib/udev/rules.d', udevFileName); + end end - end - run(obj.Workflow.HardwareInterface, sprintf('rm %s', udevrules)); - - if ~status - obj.Workflow.InstalledUdevRule = ... - fullfile('/lib/udev/rules.d', udevFileName); - end + end - end -end \ No newline at end of file +end diff --git a/+adi/+utils/Step1.m b/+adi/+utils/Step1.m index f8733faa..cbb85313 100644 --- a/+adi/+utils/Step1.m +++ b/+adi/+utils/Step1.m @@ -1,56 +1,58 @@ classdef Step1 < adi.StepBase - + % Copyright 2017 The MathWorks, Inc. properties (Hidden) - InstallButton + InstallButton end - + methods + function obj = Step1(varargin) obj@adi.StepBase(varargin{:}); - + % obj.Workflow.InstallDriverWorkflow = true; - + parentContainer = obj.ContentPanel; - + obj.Title.Text = 'ADI Board Support Package Installer'; - + obj.InfoText1.Position = [20 340 400 30]; obj.InfoText1.Text = 'Step 1: Installing drivers'; - + obj.InfoText2.Position = [20 290 400 50]; obj.InfoText2.Text = 'Test2'; - + obj.InstallButton = matlab.hwmgr.internal.hwsetup.Button.getInstance(parentContainer); obj.InstallButton.ButtonPushedFcn = @obj.LinuxInstall; obj.InstallButton.Text = 'WINNER'; - + obj.HelpText.AboutSelection = 'About Selection'; obj.HelpText.WhatToConsider = 'Test3'; end - + function out = getNextScreenID(obj) % HSA infrastructure requires a "getNextScreenID" method implemented % in the leaf class. Otherwise, it renders "Finish" button instead of % "Next". out = getNextScreenIDImpl(obj); end - + function restoreScreen(obj) obj.enableScreen(); end + end methods (Access = protected) - + function out = getNextScreenIDImpl(~) out = 'adi.Step2'; end - - function LinuxInstall(~,~,~) + + function LinuxInstall(~, ~, ~) system('sudo whoami'); end - + end - + end diff --git a/+adi/+utils/Step2.m b/+adi/+utils/Step2.m index d8f364d8..980377e2 100644 --- a/+adi/+utils/Step2.m +++ b/+adi/+utils/Step2.m @@ -1,43 +1,45 @@ classdef Step2 < adi.StepBase - + % Copyright 2017 The MathWorks, Inc. - + methods + function obj = Step2(varargin) obj@adi.StepBase(varargin{:}); - + % obj.Workflow.InstallDriverWorkflow = true; - + obj.Title.Text = 'ADI Board Support Package Installer: Step2'; - + obj.InfoText1.Position = [20 340 400 30]; obj.InfoText1.Text = 'Test1: Step2'; - + obj.InfoText2.Position = [20 290 400 50]; obj.InfoText2.Text = 'Test2: Step2'; - + obj.HelpText.AboutSelection = 'About Selection: Step2'; obj.HelpText.WhatToConsider = 'Test3: Step2'; end - + function out = getNextScreenID(obj) % HSA infrastructure requires a "getNextScreenID" method implemented % in the leaf class. Otherwise, it renders "Finish" button instead of % "Next". out = getNextScreenIDImpl(obj); end - + function restoreScreen(obj) obj.enableScreen(); end + end - + methods (Access = protected) - + function out = getNextScreenIDImpl(~) out = 'adi.Step3'; end - + end - + end diff --git a/+adi/+utils/Step3.m b/+adi/+utils/Step3.m index 6153fe0c..0891c7c8 100644 --- a/+adi/+utils/Step3.m +++ b/+adi/+utils/Step3.m @@ -1,43 +1,45 @@ classdef Step3 < adi.StepBase - + % Copyright 2017 The MathWorks, Inc. - + methods + function obj = Step3(varargin) obj@adi.StepBase(varargin{:}); - + % obj.Workflow.InstallDriverWorkflow = true; - + obj.Title.Text = 'ADI Board Support Package Installer: Step3'; - + obj.InfoText1.Position = [20 340 400 30]; obj.InfoText1.Text = 'Test1: Step3'; - + obj.InfoText2.Position = [20 290 400 50]; obj.InfoText2.Text = 'Test2: Step3'; - + obj.HelpText.AboutSelection = 'About Selection: Step3'; obj.HelpText.WhatToConsider = 'Test3: Step3'; end - -% function out = getNextScreenID(obj) -% % HSA infrastructure requires a "getNextScreenID" method implemented -% % in the leaf class. Otherwise, it renders "Finish" button instead of -% % "Next". -% out = getNextScreenIDImpl(obj); -% end - + + % function out = getNextScreenID(obj) + % % HSA infrastructure requires a "getNextScreenID" method implemented + % % in the leaf class. Otherwise, it renders "Finish" button instead of + % % "Next". + % out = getNextScreenIDImpl(obj); + % end + function restoreScreen(obj) obj.enableScreen(); end + end - + methods (Access = protected) - + function out = getNextScreenIDImpl(~) out = 'adi.Step3'; end - + end - + end diff --git a/+adi/+utils/StepBase.m b/+adi/+utils/StepBase.m index cbe5e8c4..d6410c1d 100644 --- a/+adi/+utils/StepBase.m +++ b/+adi/+utils/StepBase.m @@ -1,49 +1,50 @@ classdef StepBase < matlab.hwmgr.internal.hwsetup.TemplateBase - properties - InfoText1 - InfoText2 - InfoText3 - end - - methods - function obj = StepBase(varargin) - obj@matlab.hwmgr.internal.hwsetup.TemplateBase(varargin{:}); - - parentContainer = obj.ContentPanel; - - obj.InfoText1 = matlab.hwmgr.internal.hwsetup.Label.getInstance(parentContainer); - obj.InfoText1.Position = [20 290 400 80]; - obj.InfoText1.Text = ''; - obj.InfoText1.Color = matlab.hwmgr.internal.hwsetup.util.Color.WHITE; - - obj.InfoText2 = matlab.hwmgr.internal.hwsetup.Label.getInstance(parentContainer); - obj.InfoText2.Position = [20 230 400 50]; - obj.InfoText2.Text = ''; - obj.InfoText2.Color = matlab.hwmgr.internal.hwsetup.util.Color.WHITE; - - obj.InfoText3 = matlab.hwmgr.internal.hwsetup.Label.getInstance(parentContainer); - obj.InfoText3.Position = [20 170 400 50]; - obj.InfoText3.Text = ''; - obj.InfoText3.Color = matlab.hwmgr.internal.hwsetup.util.Color.WHITE; - - - obj.HelpText.AboutSelection = ''; - obj.HelpText.WhatToConsider = ''; - - if strcmp(obj.Workflow.FirstScreenID, class(obj)) - obj.BackButton.Visible = 'off'; - obj.BackButton.Enable = 'off'; - end + properties + InfoText1 + InfoText2 + InfoText3 end - - function restoreScreen(obj) - obj.enableScreen(); + + methods + + function obj = StepBase(varargin) + obj@matlab.hwmgr.internal.hwsetup.TemplateBase(varargin{:}); + + parentContainer = obj.ContentPanel; + + obj.InfoText1 = matlab.hwmgr.internal.hwsetup.Label.getInstance(parentContainer); + obj.InfoText1.Position = [20 290 400 80]; + obj.InfoText1.Text = ''; + obj.InfoText1.Color = matlab.hwmgr.internal.hwsetup.util.Color.WHITE; + + obj.InfoText2 = matlab.hwmgr.internal.hwsetup.Label.getInstance(parentContainer); + obj.InfoText2.Position = [20 230 400 50]; + obj.InfoText2.Text = ''; + obj.InfoText2.Color = matlab.hwmgr.internal.hwsetup.util.Color.WHITE; + + obj.InfoText3 = matlab.hwmgr.internal.hwsetup.Label.getInstance(parentContainer); + obj.InfoText3.Position = [20 170 400 50]; + obj.InfoText3.Text = ''; + obj.InfoText3.Color = matlab.hwmgr.internal.hwsetup.util.Color.WHITE; + + obj.HelpText.AboutSelection = ''; + obj.HelpText.WhatToConsider = ''; + + if strcmp(obj.Workflow.FirstScreenID, class(obj)) + obj.BackButton.Visible = 'off'; + obj.BackButton.Enable = 'off'; + end + end + + function restoreScreen(obj) + obj.enableScreen(); + end + end - end - -% methods (Access = protected, Abstract) -% status = installDriverImpl(obj) -% end - + + % methods (Access = protected, Abstract) + % status = installDriverImpl(obj) + % end + end diff --git a/+adi/+utils/libad9361.m b/+adi/+utils/libad9361.m index b1a34eeb..d4bc4b48 100644 --- a/+adi/+utils/libad9361.m +++ b/+adi/+utils/libad9361.m @@ -1,112 +1,111 @@ classdef libad9361 < handle properties (Hidden) - libad9361_win = 'https://github.com/analogdevicesinc/libad9361-iio/releases/download/v0.2/libad9361-0.2-win64.zip'; - libad9361_osx = 'https://github.com/analogdevicesinc/libad9361-iio/releases/download/v0.2/ad9361-0.2-Darwin.tar.gz'; - libad9361_linux= 'http://swdownloads.analog.com/cse/travis_builds/master_latest_libad9361-iio-trusty.tar.gz'; + libad9361_win = 'https://github.com/analogdevicesinc/libad9361-iio/releases/download/v0.2/libad9361-0.2-win64.zip' + libad9361_osx = 'https://github.com/analogdevicesinc/libad9361-iio/releases/download/v0.2/ad9361-0.2-Darwin.tar.gz' + libad9361_linux = 'http://swdownloads.analog.com/cse/travis_builds/master_latest_libad9361-iio-trusty.tar.gz' os - headerFileNames = {'ad9361.h','ad9361-wrapper.h'}; - libraryFileNames = {'ad9361','libad9361.so','libad9361.dll'}; - tmpdir = 'tmp_deps_install'; + headerFileNames = {'ad9361.h', 'ad9361-wrapper.h'} + libraryFileNames = {'ad9361', 'libad9361.so', 'libad9361.dll'} + tmpdir = 'tmp_deps_install' end - - methods (Access=protected, Hidden) - + + methods (Access = protected, Hidden) + function loc = getDependencyTargetLocation(~) rootDir = fileparts(strtok(mfilename('fullpath'), '+')); - loc = fullfile(rootDir,'deps','ad9361'); + loc = fullfile(rootDir, 'deps', 'ad9361'); end - - function [files,dlfn,fulltmp] = downloadFiles(obj) + + function [files, dlfn, fulltmp] = downloadFiles(obj) if ismac - dlfn = websave('dl.tar.gz',obj.libad9361_osx); - fulltmp = fullfile(pwd,obj.tmpdir); - files = untar(dlfn,fulltmp); + dlfn = websave('dl.tar.gz', obj.libad9361_osx); + fulltmp = fullfile(pwd, obj.tmpdir); + files = untar(dlfn, fulltmp); elseif ispc - dlfn = websave('dl.zip',obj.libad9361_win); - fulltmp = fullfile(pwd,obj.tmpdir); - files = unzip(dlfn,fulltmp); + dlfn = websave('dl.zip', obj.libad9361_win); + fulltmp = fullfile(pwd, obj.tmpdir); + files = unzip(dlfn, fulltmp); else - dlfn = websave('dl.tar.gz',obj.libad9361_linux); - fulltmp = fullfile(pwd,obj.tmpdir); - files = untar(dlfn,fulltmp); + dlfn = websave('dl.tar.gz', obj.libad9361_linux); + fulltmp = fullfile(pwd, obj.tmpdir); + files = untar(dlfn, fulltmp); end end - + end - - methods - - function [check,lib,head] = checkForDependencies(obj) + + methods + + function [check, lib, head] = checkForDependencies(obj) loc = getDependencyTargetLocation(obj); lib = false; for l = 1:length(obj.libraryFileNames) - lib = lib || exist(fullfile(loc,obj.libraryFileNames{l}),'file'); + lib = lib || exist(fullfile(loc, obj.libraryFileNames{l}), 'file'); end head = true; for h = 1:length(obj.headerFileNames) - head = head && exist(fullfile(loc,'include',obj.headerFileNames{h}),'file'); + head = head && exist(fullfile(loc, 'include', obj.headerFileNames{h}), 'file'); end check = lib && head; end - + function download_libad9361(obj) if obj.checkForDependencies() fprintf('Dependencies already installed, not reinstalling\n'); return end fprintf('Downloading libad9361 library\n'); - [files,dlfn,fulltmp] = downloadFiles(obj); + [files, dlfn, fulltmp] = downloadFiles(obj); target = obj.getDependencyTargetLocation(); - if ~exist(target,'dir') + if ~exist(target, 'dir') mkdir(target); end - if ~exist(fullfile(target,'include'),'dir') - mkdir(fullfile(target,'include')); + if ~exist(fullfile(target, 'include'), 'dir') + mkdir(fullfile(target, 'include')); end % Includes for f = 1:length(files) - if contains(files{f},obj.headerFileNames) - copyfile(files{f},fullfile(target,'include')); + if contains(files{f}, obj.headerFileNames) + copyfile(files{f}, fullfile(target, 'include')); end end % Libraries for f = 1:length(files) - if exist(files{f},'dir') - continue; + if exist(files{f}, 'dir') + continue end - fp = split(files{f}, '/'); fp = fp{end}; + fp = split(files{f}, '/'); + fp = fp{end}; s = dir(files{f}); - if contains(fp,obj.libraryFileNames) && s.bytes>0 - if ismac && ~contains(fp,'.') - copyfile(files{f},fullfile(target,'libad9361.dylib')); + if contains(fp, obj.libraryFileNames) && s.bytes > 0 + if ismac && ~contains(fp, '.') + copyfile(files{f}, fullfile(target, 'libad9361.dylib')); end - if ispc && contains(files{f},'.dll') - copyfile(files{f},target); + if ispc && contains(files{f}, '.dll') + copyfile(files{f}, target); end if isunix - copyfile(files{f},fullfile(target,'libad9361.so')); + copyfile(files{f}, fullfile(target, 'libad9361.so')); end end end % Cleanup - rmdir(fulltmp,'s'); - delete(dlfn); + rmdir(fulltmp, 's'); + delete(dlfn); fprintf('Installing libad9361 complete\n'); % Path stuff fprintf('Adding libad9361 to path\n'); addpath(genpath(target)); try - warning('error','MATLAB:SavePath:PathNotSaved'); + warning('error', 'MATLAB:SavePath:PathNotSaved'); savepath(); catch - warning(['savepath failed. libad9361 is currently on path, '... - 'but is likely to not be across MATLAB restarts.',... - 'Please add "',target,'" to path']); + warning(['savepath failed. libad9361 is currently on path, '... + 'but is likely to not be across MATLAB restarts.', ... + 'Please add "', target, '" to path']); end end + end end - - - diff --git a/+adi/Contents.m b/+adi/Contents.m index 19faaf52..99a146fe 100644 --- a/+adi/Contents.m +++ b/+adi/Contents.m @@ -27,4 +27,3 @@ % ADRV9002 - FMC development board based on the ADRV9002 % ADRV9009 - FMC development board based on the ADRV9009 % ADRV9009-ZU11EG- SOM based on the ADRV9009 with Zynq-Ultrascale 11EG - diff --git a/+adi/Version.m b/+adi/Version.m index 6e7c3175..c3c1c65e 100644 --- a/+adi/Version.m +++ b/+adi/Version.m @@ -1,25 +1,26 @@ classdef Version - %Version + % Version % BSP Version information - properties(Constant) - HDL = 'hdl_2022_r2'; - Vivado = '2022.2'; - MATLAB = 'R2023b'; - Release = '23.2.2'; - AppName = 'Analog Devices, Inc. Transceiver Toolbox'; - ToolboxName = 'TransceiverToolbox'; - ToolboxNameShort = 'trx'; - ExamplesDir = 'trx_examples'; - HasHDL = true; + properties (Constant) + HDL = 'hdl_2022_r2' + Vivado = '2022.2' + MATLAB = 'R2023b' + Release = '23.2.2' + AppName = 'Analog Devices, Inc. Transceiver Toolbox' + ToolboxName = 'TransceiverToolbox' + ToolboxNameShort = 'trx' + ExamplesDir = 'trx_examples' + HasHDL = true end - properties(Dependent) + properties (Dependent) VivadoShort end - + methods + function value = get.VivadoShort(obj) - value = obj.Vivado(1:6); + value = obj.Vivado(1:6); end + end end - diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..0aefff30 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,24 @@ +# EditorConfig — https://editorconfig.org +# Top-most EditorConfig file +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = space +indent_size = 4 + +[*.{md,yml,yaml,json,toml}] +indent_size = 2 + +[*.py] +indent_size = 4 + +# Makefiles require literal tabs +[Makefile] +indent_style = tab + +[**/Makefile] +indent_style = tab diff --git a/.github/doc/styles/config/vocabularies/Sphinx/accept.txt b/.github/doc/styles/config/vocabularies/Sphinx/accept.txt index c0856077..16e0168e 100644 --- a/.github/doc/styles/config/vocabularies/Sphinx/accept.txt +++ b/.github/doc/styles/config/vocabularies/Sphinx/accept.txt @@ -88,3 +88,5 @@ spi [nN]arrowband [Ww]ideband rf_enabled +[kK]uiper +[bB]uildroot diff --git a/.github/workflows/docs-lint.yml b/.github/workflows/docs-lint.yml new file mode 100644 index 00000000..f6fb743b --- /dev/null +++ b/.github/workflows/docs-lint.yml @@ -0,0 +1,41 @@ +name: Documentation Lint + +on: [push, pull_request] + +jobs: + vale: + name: Vale prose lint + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Install Vale + run: | + VALE_VERSION=3.9.1 + curl -sfL "https://github.com/errata-ai/vale/releases/download/v${VALE_VERSION}/vale_${VALE_VERSION}_Linux_64-bit.tar.gz" \ + | sudo tar -xz -C /usr/local/bin vale + vale --version + + # Styles are committed under .github/doc/styles; .vale.ini drives the rules. + # Vale exits non-zero only on error-level alerts, so warnings do not fail CI. + - name: Run Vale + run: vale CI/doc/source + + mdformat: + name: Markdown format check + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install mdformat + run: pip install -r CI/doc/requirements_lint.txt + + - name: Check Markdown formatting + run: make -C CI/doc format-check diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..35687a05 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,44 @@ +name: Lint + +on: [push, pull_request] + +jobs: + LintCode: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + pip install -r requirements_dev.txt + - name: Check code styling + run: | + mh_style +adi + + RunMetrics: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + pip install -r requirements_dev.txt + - name: Check code styling + run: | + mh_metric +adi --html=metrics.html + + - name: Archive report + uses: actions/upload-artifact@v4 + with: + name: Metrics + path: metrics.html diff --git a/.mdformat.toml b/.mdformat.toml new file mode 100644 index 00000000..40f6236b --- /dev/null +++ b/.mdformat.toml @@ -0,0 +1,5 @@ +# mdformat configuration — https://mdformat.readthedocs.io +# Do not reflow prose; only normalize structure (lists, spacing, tables). +wrap = "keep" +number = false +end_of_line = "lf" diff --git a/CI/doc/Makefile b/CI/doc/Makefile index d3392f87..d44316e7 100644 --- a/CI/doc/Makefile +++ b/CI/doc/Makefile @@ -9,12 +9,18 @@ SOURCEDIR = source BUILDDIR = build PYTHON = python +VALE ?= vale +MDFORMAT ?= mdformat + +# Authored Markdown sources to lint/format. The index pages objects.md and +# allrefdesigns.md are regenerated by gen_autodocs, so they are excluded. +DOCSRC := $(filter-out $(SOURCEDIR)/objects.md $(SOURCEDIR)/allrefdesigns.md, $(wildcard $(SOURCEDIR)/*.md)) # Put it first so that "make" without argument is like "make help". help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -.PHONY: help Makefile +.PHONY: help Makefile lint format format-check # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). @@ -26,3 +32,15 @@ gen_autodocs: $(PYTHON) gen_sysobj_pages.py ; \ $(PYTHON) gen_rd_svg.py ; \ $(PYTHON) gen_hdl_refdesigns.py + +# Prose linting with Vale (styles live in .github/doc/styles, config in .vale.ini) +lint: + $(VALE) $(SOURCEDIR) + +# Auto-format the authored Markdown sources in place +format: + $(MDFORMAT) $(DOCSRC) + +# Verify the authored Markdown sources are formatted (used by CI) +format-check: + $(MDFORMAT) --check $(DOCSRC) diff --git a/CI/doc/README_doc.md b/CI/doc/README_doc.md index b13505de..ac8b4a1a 100644 --- a/CI/doc/README_doc.md +++ b/CI/doc/README_doc.md @@ -22,3 +22,25 @@ The system object documentation is generated from the MATLAB code and comments, cd CI/doc/gen_pages gen_sysobj_doc ``` + +## Linting and Formatting + +The documentation is prose-linted with [Vale](https://vale.sh) and the Markdown is +formatted with [mdformat](https://mdformat.readthedocs.io). Both run automatically on push +and pull request through the *Documentation Lint* workflow, and can be run locally: + +```bash +# Prose linting (requires the Vale binary on PATH). +# Styles are committed under .github/doc/styles and configured by the root .vale.ini. +# Only error-level alerts fail; warnings are advisory. +make -C CI/doc lint + +# Markdown formatting of the authored source files. +pip install -r CI/doc/requirements_lint.txt +make -C CI/doc format # rewrite files in place +make -C CI/doc format-check # verify only (used by CI) +``` + +The generated index pages `objects.md` and `allrefdesigns.md` are produced by `gen_autodocs` +and are intentionally excluded from formatting. To refresh the bundled Google style rules, run +`.github/doc/scripts/get_styles.sh`. diff --git a/CI/doc/requirements_doc.txt b/CI/doc/requirements_doc.txt index a00cef0f..e23ac323 100644 --- a/CI/doc/requirements_doc.txt +++ b/CI/doc/requirements_doc.txt @@ -7,4 +7,5 @@ sphinx-simplepdf pillow numpy jinja2 -sphinx_design \ No newline at end of file +sphinx_design +sphinx-copybutton \ No newline at end of file diff --git a/CI/doc/requirements_lint.txt b/CI/doc/requirements_lint.txt new file mode 100644 index 00000000..7d1ebd0a --- /dev/null +++ b/CI/doc/requirements_lint.txt @@ -0,0 +1,2 @@ +mdformat +mdformat-gfm diff --git a/CI/doc/source/conf.py b/CI/doc/source/conf.py index d1dc5603..e1818de8 100644 --- a/CI/doc/source/conf.py +++ b/CI/doc/source/conf.py @@ -12,8 +12,10 @@ # import contextlib import os +import re import shutil import sys +from datetime import datetime from typing import List sys.path.insert(0, os.path.abspath("../..")) @@ -43,11 +45,30 @@ # -- Project information ----------------------------------------------------- project = "Analog Devices, Inc. Transceiver Toolbox" -copyright = "2019-2022, Analog Devices, Inc" +copyright = f"2019-{datetime.now().year}, Analog Devices, Inc" author = "Analog Devices, Inc." + +def _toolbox_release() -> str: + """Return the toolbox release, read from the source of truth +adi/Version.m. + + Falls back to a literal so the docs always build even if the file moves. + """ + version_file = os.path.join( + os.path.dirname(__file__), "..", "..", "..", "+adi", "Version.m" + ) + try: + with open(version_file, encoding="utf-8") as fh: + match = re.search(r"Release\s*=\s*'([^']+)'", fh.read()) + if match: + return f"v{match.group(1)}" + except OSError: + pass + return "v23.2.2" + + # The full version, including alpha/beta/rc tags -release = "v22.2.1" +release = _toolbox_release() # -- General configuration --------------------------------------------------- @@ -59,14 +80,12 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - # "sphinx.ext.autodoc", "sphinx.ext.coverage", "sphinx.ext.githubpages", "myst_parser", "sphinx_favicon", "sphinxcontrib.mermaid", - # "sphinx_copybutton", - # "sphinx_togglebutton", # Using this? + "sphinx_copybutton", "sphinx_design", ] @@ -82,9 +101,6 @@ # This pattern also affects html_static_path and html_extra_path. exclude_patterns: List[str] = [] -# Configuration of sphinx.ext.coverage -#coverage_show_missing_items = True - # -- Options for HTML output ------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for @@ -93,7 +109,6 @@ html_theme = "furo" html_title = f"{project} {release}" -#favicons = ["favicon.png"] # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, diff --git a/CI/doc/source/dev_hdl_workflow.md b/CI/doc/source/dev_hdl_workflow.md index 6fda924f..541c21d5 100644 --- a/CI/doc/source/dev_hdl_workflow.md +++ b/CI/doc/source/dev_hdl_workflow.md @@ -6,17 +6,18 @@ This content is meant for developers or advanced users and is not meant for gene This page discusses the HDL targeting support from the perspective of the HDL source repository and HDL-Coder itself. It is not necessary for users to understand these details but for those managing the toolbox or developers extending support to new platforms this information is valuable. -This page assumes a basic understanding of MathWork's [HDL Workflow Advisor (HWA)](https://www.mathworks.com/help/hdlcoder/ug/overview-of-workflows-in-hdl-workflow-advisor.html) and its different steps for creating IP, creating a HDL project, and generating a bitstream. +This page assumes a basic understanding of MathWork's [HDL Workflow Advisor (HWA)](https://www.mathworks.com/help/hdlcoder/ug/overview-of-workflows-in-hdl-workflow-advisor.html) and its different steps for creating IP, creating a HDL project, and generating a bitstream. ## HDL Repository Preparation -When the toolbox is built it will clone a specific branch of the [ADI HDL repository](https://github.com/analogdevicesinc/hdl) and apply certain changes to support the [IP-Core Generation HDL-Coder](https://www.mathworks.com/discovery/ip-core-generation.html) workflow. However, with the current flow there are minimal changes required which makes moving between release simpler. This is currently done by simply replacing certain TCL scripts within the HDL repository. +When the toolbox is built it will clone a specific branch of the [ADI HDL repository](https://github.com/analogdevicesinc/hdl) and apply certain changes to support the [IP-Core Generation HDL-Coder](https://www.mathworks.com/discovery/ip-core-generation.html) workflow. However, with the current flow there are minimal changes required which makes moving between release simpler. This is currently done by simply replacing certain TCL scripts within the HDL repository. Creation of the toolbox, cloning of the HDL source, and applying the necessary update is driven through a Makefile in the **CI/scripts** folder. The toolbox is built in source form with the **build** as follows: ```bash make -C CI/scripts build ``` + After the above command completes the HDL source will be in place with necessary changes. The changes primarily required of the HDL source are interceptions of the build functions (procs) to skip synthesis when building a project. This is done by inserting environmental variable checks into the [adi_project_xilinx.tcl](https://github.com/analogdevicesinc/TransceiverToolbox/blob/master/CI/scripts/adi_project_xilinx.tcl#L138) script. At build time these environmental variables are set and will prevent synthesis. This way an HDL project can be built, then handed off to HDL-Coder for IP insertion and eventual synthesis. @@ -44,6 +45,7 @@ style E fill:#f9f,stroke:#333,stroke-width:4px style C fill:#FF0,stroke:#333,stroke-width:4px,stroke-dasharray: 5 5 style D fill:#FF0,stroke:#333,stroke-width:4px,stroke-dasharray: 5 5 ``` +
Figure 1: Details IP-Core Generation flow with Toolbox
At a high-level there are six main steps, two of which are optional. From the far left stage "Generate Verilog From Simulink IP" occurs in Stage 3 "HDL Code Generation" within HWA as outlined in red below. This will create Verilog within the defined project folder and then be copied into the full HDL project later on. @@ -55,27 +57,22 @@ HDL Workflow Advisor IP verilog generation. Within the largest central block of the flowchart labeled **vivado_create_prj.tcl** are all the core steps related the HWA Step 4.1, where the reference HDL project folder is built and necessary cores and nets removed to make room for IP from Simulink generated in HWA Step 3. This stage is highlighted in the figure below. The purple boxes are optional stages that are used in certain customized examples when additional work is required to prepare a reference design. The [Frequency Hopping example](https://github.com/analogdevicesinc/TransceiverToolbox/tree/master/trx_examples/targeting/frequency-hopping) leverages these stages. Once the project is prepared the IP is inserted and bitstream generated, which occurs through HWA Step 4.3. - ```{figure} /_static/assets/HWA_project_gen.png HDL Workflow Advisor project generation step. ``` - ### Vivado Project Perspective Based on the flow in Figure 1, there are a three main states the HDL reference design enters from a high level. These states will be discussed more from the Vivado project perspective, specifically the data path of an FMComms2 project. Other HDL projects will be similar. The first state is just the initial creation of the standard unmodified block design. Looking at Figure 4, the three IPs show the dataflow from the interface core (axi_ad9361), through the ADC FIFO, and finally into the pack core. In orange are the data buses and valid signal highlighted. These are important since the generated IP needs to be inserted where these nets are connected. Therefore, in the second state of the design these nets are removed to make room from the new IP. - ```{figure} /_static/assets/stock_reference_design.png RX path in unmodified standard reference design. ``` - - Once the IP is inserted into the project by HDL-Coder it is connected to the FIFO and pack cores where the nets in Figure 4 were highlighted. The new inserted and connected IP can be see in Figure 5. ```{figure} /_static/assets/reference_design_with_IP.png @@ -87,9 +84,8 @@ The connecting of the IPs and insertion are entirely managed by HDL-Coder and th ### Generated TCL Scripts - The following scripts outlined in the figure above have certain purposes: - **vivado_create_prj.tcl**: This is the first TCL scripted called in Stage 4 of HWA and is responsible for setting up a standard reference design and trimming nets and IPs to make room for IP from Simulink - **vivado_custom_block_design.tcl**: This is a carbon copy of the **system_project_rxtx.tcl** script and is called by **vivado_create_prj.tcl**. This script will call [adi_make.tcl](https://wiki.analog.com/resources/fpga/docs/build#xilinx_auto_tcl_build), the correct system_project.tcl file, and finally matlab_processor.tcl. It will optionally call the pre/post processor TCL scripts. -- **vivado_insert_ip.tcl**: This script is fully generated by MATLAB based on the [add_io](https://github.com/analogdevicesinc/TransceiverToolbox/blob/master/hdl/vendor/AnalogDevices/+AnalogDevices/add_io.m) definitions in MATLAB to insert the custom IP into the prepared reference design. \ No newline at end of file +- **vivado_insert_ip.tcl**: This script is fully generated by MATLAB based on the [add_io](https://github.com/analogdevicesinc/TransceiverToolbox/blob/master/hdl/vendor/AnalogDevices/+AnalogDevices/add_io.m) definitions in MATLAB to insert the custom IP into the prepared reference design. diff --git a/CI/doc/source/examples.md b/CI/doc/source/examples.md index 9dee6e37..0110a2f9 100644 --- a/CI/doc/source/examples.md +++ b/CI/doc/source/examples.md @@ -1,4 +1,3 @@ - # Examples Examples for streaming data and targeting FPGAs are listed within the Toolbox documentation itself. To view run the following with MATLAB: @@ -9,8 +8,8 @@ doc adi They can also be viewed on GitHub: - - [Targeting examples](https://github.com/analogdevicesinc/TransceiverToolbox/tree/master/trx_examples/targeting) - - [Streaming examples](https://github.com/analogdevicesinc/TransceiverToolbox/tree/master/trx_examples/streaming) +- [Targeting examples](https://github.com/analogdevicesinc/TransceiverToolbox/tree/master/trx_examples/targeting) +- [Streaming examples](https://github.com/analogdevicesinc/TransceiverToolbox/tree/master/trx_examples/streaming) ## Highlighted Demos @@ -19,4 +18,4 @@ Certain examples have full articles that discuss different applications - [Frequency hopping](https://wiki.analog.com/resources/eval/user-guides/adrv936x_rfsom/tutorials/frequency_hopping) - [Loopback delay estimation](https://wiki.analog.com/resources/eval/user-guides/adrv936x_rfsom/tutorials/loopback_delay_estimation) - [AGC Optimization](https://wiki.analog.com/resources/eval/user-guides/ad9361_agc_tuning) -- [Pluto LTE App](https://wiki.analog.com/resources/tools-software/transceiver-toolbox/examples/pluto_lte_app) \ No newline at end of file +- [Pluto LTE App](https://wiki.analog.com/resources/tools-software/transceiver-toolbox/examples/pluto_lte_app) diff --git a/CI/doc/source/index.md b/CI/doc/source/index.md index c8c68e01..35317527 100644 --- a/CI/doc/source/index.md +++ b/CI/doc/source/index.md @@ -1,4 +1,5 @@ +