diff --git a/+adi/+internal/ADAR100x.m b/+adi/+internal/ADAR100x.m index ffb3bb9..7cee7c4 100644 --- a/+adi/+internal/ADAR100x.m +++ b/+adi/+internal/ADAR100x.m @@ -46,7 +46,7 @@ end properties - %Mode Mode + %Mode ADAR1000 Mode % Mode is a cellarray where each element addresses individual ADAR1000's. % Each cell must contain a string of value % 'Rx', 'Tx', or 'disabled' to set the modes. @@ -110,7 +110,7 @@ % External Bias for External LNAs. LNABiasOff is an array % where each element addresses individual ADAR1000's. LNABiasOff = -2 - %PolState Pol State + %PolState ADAR1000 Switch Polarity % Control for External Polarity Switch Drivers. % PolSwitchEnable is an array where each element addresses % individual ADAR1000's. Each element must be a logical diff --git a/+adi/+internal/ADF4159.m b/+adi/+internal/ADF4159.m index 6c805c1..ffbee4d 100644 --- a/+adi/+internal/ADF4159.m +++ b/+adi/+internal/ADF4159.m @@ -4,23 +4,23 @@ % IIO Driver: https://wiki.analog.com/resources/tools-software/linux-drivers properties - %Frequency Frequency + %Frequency LO Output Frequency % Set output frequency of synthesizer in Hz. When the synthesizer % is ramping this is the start frequency Frequency = 1e9; - %FrequencyDeviationRange Frequency Deviation Range + %FrequencyDeviationRange LO Chirp Frequency BW % Set upper bound on frequency ramp from Frequency property in Hz. % This is only applicable when RampMode is not set to "disabled" FrequencyDeviationRange = 1e6; - %FrequencyDeviationStep Frequency Deviation Step + %FrequencyDeviationStep LO Chirp Frequency Steps % Set step size in Hz of synthesizer ramp. This is only % applicable when RampMode is not set to "disabled". FrequencyDeviationStep = 500e6 / 4 / 1000; - %FrequencyDeviationTime Frequency Deviation Time + %FrequencyDeviationTime LO Chirp Time % Set time in uSeconds to reach ramp peak value. This is only % applicable when RampMode is not set to "disabled" FrequencyDeviationTime = 0; - %RampMode Ramp Mode + %RampMode LO Chirp Ramp Mode % Set ramp waveform. Options are: % - "disabled" % - "continuous_sawtooth" @@ -31,18 +31,18 @@ end properties(Logical) - %Powerdown + %Powerdown ADF4159 PLL Powerdown % When true output will be disabled. Writing to this value will % also update all settings of device Powerdown = false; end properties% Advanced - %DelayStartWord Delay Start Word + %DelayStartWord LO Ramp Delay Start % Set start delay of each ramp in PFD or PFD*CLK1 clock cycles. % This is a 12-bit number DelayStartWord = 0; - %DelayClockSource Delay Clock Source + %DelayClockSource LO Ramp Delay Clock Selection % Set clock use to determine ramp delay. Options are: % - "PFD" % - "PFD*CLK1" @@ -50,19 +50,19 @@ end properties(Logical)%Advanced - %DelayStartEnable Ramp Delay Enable + %DelayStartEnable LO Ramp Start Delay Enable % Enable delaying of ramp signal at start of first ramp generation DelayStartEnable = false; - %RampDelayEnable Ramp Delay Enable + %RampDelayEnable LO Ramp Delay Enable % Enable delaying of ramp signal at start of each ramp generation RampDelayEnable = false; - %TriggerDelayEnable Trigger Delay Enable + %TriggerDelayEnable LO Ramp Trigger Delay Enable % Enable ramp start delay when controlled by external trigger TriggerDelayEnable = false; - %TriggerEnable Trigger Enable + %TriggerEnable LO Ramp Trigger Enable % Allow for use of external trigger on TX Data pin to start ramp TriggerEnable = false; - %SingleFullTriangleEnable Single Full Triangle Enable + %SingleFullTriangleEnable LO Ramp Full Triangle Enable % Enable sending of single full triangular wave. This is % applicable when RampMode is in "single_ramp_burst" SingleFullTriangleEnable = false; @@ -91,8 +91,14 @@ obj.FrequencyDeviationStep = rvalue; end function set.FrequencyDeviationTime(obj,value) - setAttributeLongLong(obj, 'altvoltage0', 'frequency_deviation_time', int64(value), true, 40, obj.iioDeviceADF4159); + setAttributeLongLong(obj, 'altvoltage0', 'frequency_deviation_time', int64(value), true, 40, obj.iioDeviceADF4159, false); rvalue = obj.getAttributeLongLong('altvoltage0', 'frequency_deviation_time',true, obj.iioDeviceADF4159); + if rvalue ~= value + disp(['[', 8, 'Warning: Requested FrequencyDeviationTime is not possible for the given value of FrequencyDeviationStep.]', 8]) + fprintf(' You requested %d us, but %d us is the closest available FrequencyDeviationTime.\n', value, rvalue) + fprintf(' FrequencyDeviationTime has been changed to %d us.\n', rvalue) + fprintf(' For a value closer to the %d us, try choosing a different FrequencyDeviationStep.\n', value) + end obj.FrequencyDeviationTime = rvalue; end function set.RampMode(obj,value) diff --git a/+adi/+internal/ADF4371.m b/+adi/+internal/ADF4371.m index 7d3570b..a1d8811 100644 --- a/+adi/+internal/ADF4371.m +++ b/+adi/+internal/ADF4371.m @@ -6,7 +6,7 @@ %ADF4371Name ADF4371 Name % Configure programmable divider for ADF4371 % Options: 'RF16x' or 'RF32x' - ADF4371Name = 'RF16x' + ADF4371Name (1,1) string {mustBeMember(ADF4371Name, ["RF16x", "RF32x"])} = "RF16x"; %ADF4371Frequency ADF4371 Frequency % Configure ADF4371 output frequency % Allowed range: @@ -46,52 +46,52 @@ methods function set.ADF4371Name(obj, value) - obj.ADF4371Name = value; if obj.ConnectedToDevice switch value % inverted logic to enable the correct channel case 'RF16x' - setAttributeBool(obj,'altvoltage0','powerdown',true,true,obj.ADF4371Device); - setAttributeBool(obj,'altvoltage1','powerdown',true,true,obj.ADF4371Device); - setAttributeBool(obj,'altvoltage2','powerdown',false,true,obj.ADF4371Device); - setAttributeBool(obj,'altvoltage3','powerdown',true,true,obj.ADF4371Device); + setAttributeBool(obj,'altvoltage0','powerdown',true,true,obj.ADF4371Device,false); + setAttributeBool(obj,'altvoltage1','powerdown',true,true,obj.ADF4371Device,false); + setAttributeBool(obj,'altvoltage2','powerdown',false,true,obj.ADF4371Device,false); + setAttributeBool(obj,'altvoltage3','powerdown',true,true,obj.ADF4371Device,false); obj.ADF4371Channel = 'altvoltage2'; case 'RF32x' - setAttributeBool(obj,'altvoltage0','powerdown',true,true,obj.ADF4371Device); - setAttributeBool(obj,'altvoltage1','powerdown',true,true,obj.ADF4371Device); - setAttributeBool(obj,'altvoltage2','powerdown',true,true,obj.ADF4371Device); - setAttributeBool(obj,'altvoltage3','powerdown',false,true,obj.ADF4371Device); + setAttributeBool(obj,'altvoltage0','powerdown',true,true,obj.ADF4371Device,false); + setAttributeBool(obj,'altvoltage1','powerdown',true,true,obj.ADF4371Device,false); + setAttributeBool(obj,'altvoltage2','powerdown',true,true,obj.ADF4371Device,false); + setAttributeBool(obj,'altvoltage3','powerdown',false,true,obj.ADF4371Device,false); obj.ADF4371Channel = 'altvoltage3'; otherwise error('Invalid setting chosen for ADF4371Name'); end end + obj.ADF4371Name = value; end function set.ADF4371Frequency(obj, value) switch obj.ADF4371Name case 'RF16x' - validateattributes( obj.ADF4371Frequency,{ 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar','finite','nonnan', 'nonempty','integer',... + validateattributes( value,{ 'double','single', 'uint64' }, ... + { 'real', 'nonnegative','scalar','finite','nonnan', 'nonempty',... '>=',8000000000,'<=',16000000000},'', 'ADF4371Frequency'); case 'RF32x' - validateattributes( obj.ADF4371Frequency,{ 'double','single', 'uint32' }, ... - { 'real', 'nonnegative','scalar','finite','nonnan', 'nonempty','integer',... + validateattributes( value,{ 'double','single', 'uint64' }, ... + { 'real', 'nonnegative','scalar','finite','nonnan', 'nonempty',... '>=',16000000000,'<=',32000000000},'', 'ADF4371Frequency'); end obj.ADF4371Frequency = value; if obj.ConnectedToDevice - setAttributeLongLong(obj,obj.ADF4371Channel,'frequency',value,true,0,obj.ADF4371Device); + setAttributeLongLong(obj,obj.ADF4371Channel,'frequency',value,true,0,obj.ADF4371Device,false); end end function set.ADF4371Phase(obj, value) - validateattributes( obj.ADF4371Phase, { 'double','single', 'uint32' }, ... + validateattributes( value, { 'double','single', 'uint32' }, ... { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',359999}, ... '', 'ADF4371Phase'); obj.ADF4371Phase = value; if obj.ConnectedToDevice - setAttributeLongLong(obj,obj.ADF4371Channel,'phase',value,true,1,obj.ADF4371Device); + setAttributeLongLong(obj,obj.ADF4371Channel,'phase',value,true,1,obj.ADF4371Device,false); end end @@ -111,15 +111,7 @@ methods (Hidden, Access = protected) function setupInit(obj) - numDevs = obj.iio_context_get_devices_count(obj.iioCtx); - obj.ADF4371Device = cell(1,length(obj.ADF4371DeviceName)); - for k = 1:numDevs - devPtr = obj.iio_context_get_device(obj.iioCtx, k-1); - name = obj.iio_device_get_name(devPtr); - if strcmpi(obj.ADF4371DeviceName,name) - obj.ADF4371Device = devPtr; - end - end + obj.ADF4371Device = obj.getDev(obj.ADF4371DeviceName); if isempty(obj.ADF4371Device) error('%s not found',obj.ADF4371DeviceName); end @@ -134,10 +126,10 @@ function setupInit(obj) otherwise error('Invalid setting chosen for ADF4371Name'); end - setAttributeBool(obj,'altvoltage0','powerdown',true,true,obj.ADF4371Device); - setAttributeBool(obj,'altvoltage1','powerdown',true,true,obj.ADF4371Device); - setAttributeBool(obj,'altvoltage2','powerdown',false,true,obj.ADF4371Device); - setAttributeBool(obj,'altvoltage3','powerdown',true,true,obj.ADF4371Device); + setAttributeBool(obj,'altvoltage0','powerdown',true,true,obj.ADF4371Device, false); + setAttributeBool(obj,'altvoltage1','powerdown',true,true,obj.ADF4371Device, false); + setAttributeBool(obj,'altvoltage2','powerdown',false,true,obj.ADF4371Device, false); + setAttributeBool(obj,'altvoltage3','powerdown',true,true,obj.ADF4371Device, false); obj.setAttributeLongLong(obj.ADF4371Channel,'frequency',obj.ADF4371Frequency,true,0,obj.ADF4371Device); obj.setAttributeLongLong(obj.ADF4371Channel,'phase',obj.ADF4371Phase,true,1,obj.ADF4371Device); obj.setDeviceAttributeRAW('muxout_enable', num2str(obj.MUXOutEnable), obj.ADF4371Device); diff --git a/+adi/+internal/AXICoreTDD.m b/+adi/+internal/AXICoreTDD.m index e5c55c7..566a69e 100644 --- a/+adi/+internal/AXICoreTDD.m +++ b/+adi/+internal/AXICoreTDD.m @@ -4,93 +4,114 @@ % Reference https://wiki.analog.com/resources/fpga/docs/axi_tdd properties + %PhaserEnable Enable Phaser Mode on Pluto + % Sets Phaser Enable bit + % true = enables the TDD feature to be controlled with external pins + % false = normal (non TDD) Pluto functionality + PhaserEnable; + %BurstCount Burst Count % Configure number of bursts in TDD controller + % 0 means repeat indefinetly BurstCount - %CounterInt Counter Int - % Configure TDD internal counter start value - CounterInt - %DMAGateingMode DMA Gateing Mode - % Configure TDD DMA gate - % 0 - none, 1 - rx_only, 2 - tx_only, 3 - rx_tx - DMAGateingMode = 0; + %CoreID core id + % Instance identification number + % Read only. Useful for multiple TDD instances + CoreID % Enable Enable TDD % Enable or disable the TDD engine Enable - %EnableMode Enable Mode - % Configure TDD controller RX/TX mode - % 1 - rx_only, 2 - tx_only, 3 - rx_tx - EnableMode = 3; %FrameLength Frame Length - % TDD Frame Length + % TDD Frame Length (ms) FrameLength - %Secondary Secondary - % Enable secondary times. Allows one signal to go high - % twice at two times within a single frame. - Secondary - %SyncTerminalType Sync Terminal Type - % Sync Terminal Type - SyncTerminalType - - %TxDPoff Tx DP Off (ms) - % TDD: TX DMA port timing parameters in ms. - % Format [primary_off secondary_off] - TxDPoff = [0 0]; - %TxDPon Tx DP On (ms) - % TDD: TX DMA port timing parameters in ms. - % Format [primary_on secondary_on] - TxDPon = [0 0]; - %TxOff Tx Off (ms) - % TDD: TX RF port timing parameters in ms. - % Format [primary_off secondary_off] - TxOff = [0 0]; - %TxOn Tx Off (ms) - % TDD: TX RF port timing parameters in ms. - % Format [primary_on secondary_on] - TxOn = [0 0]; - %TxVCOoff Tx VCO Off (ms) - % TDD: TX VCO port timing parameters in ms. - % Format [primary_off secondary_off] - TxVCOoff = [0 0]; - %TxVCOon Tx VCO On (ms) - % TDD: TX VCO port timing parameters in ms. - % Format [primary_on secondary_on] - TxVCOon = [0 0]; - %RxDPoff Rx DP Off (ms) - % TDD: RX DMA port timing parameters in ms. - % Format [primary_off secondary_off] - RxDPoff = [0 0]; - %RxDPon Rx DP On (ms) - % TDD: RX DMA port timing parameters in ms. - % Format [primary_on secondary_on] - RxDPon = [0 0]; - %RxOff Rx Off (ms) - % TDD: RX RF port timing parameters in ms. - % Format [primary_off secondary_off] - RxOff = [0 0]; - %RxOn Rx On (ms) - % TDD: RX RF port timing parameters in ms. - % Format [primary_on secondary_on] - RxOn = [0 0]; - %RxVCOoff Rx VCO Off (ms) - % TDD: RX VCO port timing parameters in ms. - % Format [primary_off secondary_off] - RxVCOoff = [0 0]; - %RxVCOon Rx VCO On (ms) - % TDD: RX VCO port timing parameters in ms. - % Format [primary_on secondary_on] - RxVCOon = [0 0]; + %StartupDelay startup delay ms + % Initial delay before the first frame (ms) + StartupDelay + %State state + % The current state of the internal FSM + % Read only. Useful for debugging. + State + %EnSyncExternal sync external + % Enable the external sync trigger + EnSyncExternal + %SyncReset sync reset + % Reset the internal counter when receiving a sync event + % Useful to align the beginning of the frame to multiple recurring sync events + SyncReset + %SyncSoft sync soft + % Trigger the TDD core through a register write. + % This bit self clears. + SyncSoft + + %Ch0Enable enable + % Channel 0 output enable + Ch0Enable = 0; + %Ch0Polarity polarity + % Channel 0 output polarity + Ch0Polarity = 0; + %Ch0On on ms + % The offset from the beggining of a new frame when Channel 0 is set (ms) + Ch0On = 0; + %Ch0Off off ms + % The offset from the beggining of a new frame when Channel 0 is reset (ms) + Ch0Off = 0; + + %Ch1Enable enable + % Channel 1 output enable + % Channel 1 is connected to the Rx DMA transfer start sync input + Ch1Enable = 0; + %Ch1Polarity polarity + % Channel 1 output polarity + Ch1Polarity = 0; + %Ch1On on ms + % The offset from the beggining of a new frame when Channel 1 is set (ms) + % Channel 1 is connected to the Rx DMA transfer start sync input + Ch1On = 0; + %Ch1Off off ms + % The offset from the beggining of a new frame when Channel 1 is reset (ms) + % Channel 1 is connected to the Rx DMA transfer start sync input + Ch1Off = 0; + + %Ch2Enable enable + % Channel 2 output enable + % Channel 2 is connected to the Tx packer reset + Ch2Enable = 0; + %Ch2Polarity polarity + % Channel 2 output polarity + Ch2Polarity = 0; + %Ch2On on ms + % The offset from the beggining of a new frame when Channel 2 is set (ms) + Ch2On = 0; + %Ch2Off off ms + % The offset from the beggining of a new frame when Channel 2 is reset (ms) + Ch2Off = 0; end properties(Hidden) - AXICoreTDDDevPtrNames = {'axi-core-tdd'}; + %AXICoreTDDDevPtrNames = {'iio-axi-tdd-0'}; + AXICoreTDDDevPtrNames = {'adi-iio-fakedev'}; + %Matlab can't read iio names, so we call TDD "adi-iio-fakedev" + %We'll fix this in the next rev of Matlab AXICoreTDDDevPtr + GPIODevIIO end % Get/Set Methods for Device Attributes methods + function result = get.PhaserEnable(obj) + result = nan; + if ~isempty(obj.GPIODevIIO) + %result = str2double(obj.getDeviceAttributeRAW('phaser_enable', 128, obj.GPIODevIIO)); + result = obj.getAttributeBool('voltage0', 'raw', true, obj.GPIODevIIO); + + end + end + function set.PhaserEnable(obj, value) + setAttributeBool(obj, 'voltage0', 'raw', value, true, obj.GPIODevIIO); + end + function result = get.BurstCount(obj) - result = 0; + result = nan; if ~isempty(obj.AXICoreTDDDevPtr) result = str2double(obj.getDeviceAttributeRAW('burst_count', 128, obj.AXICoreTDDDevPtr)); end @@ -102,331 +123,260 @@ end end - function result = get.CounterInt(obj) - result = 0; + function result = get.CoreID(obj) + result = nan; if ~isempty(obj.AXICoreTDDDevPtr) - result = str2double(obj.getDeviceAttributeRAW('counter_int', 128, obj.AXICoreTDDDevPtr)); - end - end - - function set.CounterInt(obj, value) - if obj.ConnectedToDevice - obj.setDeviceAttributeRAW('counter_int', num2str(value), obj.AXICoreTDDDevPtr); + result = str2double(obj.getDeviceAttributeRAW('core_id', 128, obj.AXICoreTDDDevPtr)); end end - - function result = get.DMAGateingMode(obj) - result = 0; + + function result = get.Enable(obj) + result = nan; if ~isempty(obj.AXICoreTDDDevPtr) - ResultStr = obj.getDeviceAttributeRAW('dma_gateing_mode', 128, obj.AXICoreTDDDevPtr); - switch ResultStr - case "none" - result = 0; - case "rx_only" - result = 1; - case "tx_only" - result = 2; - case "rx_tx" - result = 3; - end + result = str2double(obj.getDeviceAttributeRAW('enable', 128, obj.AXICoreTDDDevPtr)); end end - function set.DMAGateingMode(obj, value) - validateattributes( value, { 'double', 'single', 'uint32'}, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',3}, ... - '', 'DMAGateingMode'); + function set.Enable(obj, value) if obj.ConnectedToDevice - switch value - case 0 - ValueStr = 'none'; - case 1 - ValueStr = 'rx_only'; - case 2 - ValueStr = 'rx_only'; - case 3 - ValueStr = 'rx_tx'; - end - obj.setDeviceAttributeRAW('dma_gateing_mode', ValueStr, obj.AXICoreTDDDevPtr); + obj.setDeviceAttributeRAW('enable', num2str(value), obj.AXICoreTDDDevPtr); end end - function result = get.Enable(obj) - result = 0; + function result = get.FrameLength(obj) + result = nan; if ~isempty(obj.AXICoreTDDDevPtr) - result = str2double(obj.getDeviceAttributeRAW('en', 128, obj.AXICoreTDDDevPtr)); + result = str2double(obj.getDeviceAttributeRAW('frame_length_ms', 128, obj.AXICoreTDDDevPtr)); end end - function set.Enable(obj, value) + function set.FrameLength(obj, value) if obj.ConnectedToDevice - obj.setDeviceAttributeRAW('en', num2str(value), obj.AXICoreTDDDevPtr); + obj.setDeviceAttributeRAW('frame_length_ms', num2str(value), obj.AXICoreTDDDevPtr); end end - - function result = get.EnableMode(obj) - result = 3; + + function result = get.StartupDelay(obj) + result = nan; if ~isempty(obj.AXICoreTDDDevPtr) - ResultStr = obj.getDeviceAttributeRAW('en_mode', 128, obj.AXICoreTDDDevPtr); - switch ResultStr - case "rx_only" - result = 1; - case "tx_only" - result = 2; - case "rx_tx" - result = 3; - end + result = str2double(obj.getDeviceAttributeRAW('startup_delay_ms', 128, obj.AXICoreTDDDevPtr)); end end - function set.EnableMode(obj, value) - validateattributes( value, { 'double', 'single', 'uint32'}, ... - { 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',1,'<=',3}, ... - '', 'EnableMode'); + function set.StartupDelay(obj, value) if obj.ConnectedToDevice - switch value - case 1 - ValueStr = 'rx_only'; - case 2 - ValueStr = 'rx_only'; - case 3 - ValueStr = 'rx_tx'; - end - obj.setDeviceAttributeRAW('en_mode', ValueStr, obj.AXICoreTDDDevPtr); + obj.setDeviceAttributeRAW('startup_delay_ms', num2str(value), obj.AXICoreTDDDevPtr); end end - - function result = get.FrameLength(obj) - result = 0; + + function result = get.State(obj) + result = nan; if ~isempty(obj.AXICoreTDDDevPtr) - result = str2double(obj.getDeviceAttributeRAW('frame_length_ms', 128, obj.AXICoreTDDDevPtr)); - end - end - - function set.FrameLength(obj, value) - if obj.ConnectedToDevice - obj.setDeviceAttributeRAW('frame_length_ms', num2str(value), obj.AXICoreTDDDevPtr); + result = str2double(obj.getDeviceAttributeRAW('state', 128, obj.AXICoreTDDDevPtr)); end end - function result = get.Secondary(obj) - result = 0; + function result = get.EnSyncExternal(obj) + result = nan; if ~isempty(obj.AXICoreTDDDevPtr) - result = str2double(obj.getDeviceAttributeRAW('secondary', 128, obj.AXICoreTDDDevPtr)); + result = str2double(obj.getDeviceAttributeRAW('sync_external', 128, obj.AXICoreTDDDevPtr)); end end - function set.Secondary(obj, value) + function set.EnSyncExternal(obj, value) if obj.ConnectedToDevice - obj.setDeviceAttributeRAW('secondary', num2str(value), obj.AXICoreTDDDevPtr); + obj.setDeviceAttributeRAW('sync_external', num2str(value), obj.AXICoreTDDDevPtr); end end - - function result = get.SyncTerminalType(obj) - result = 0; + + function result = get.SyncReset(obj) + result = nan; if ~isempty(obj.AXICoreTDDDevPtr) - result = str2double(obj.getDeviceAttributeRAW('sync_terminal_type', 128, obj.AXICoreTDDDevPtr)); + result = str2double(obj.getDeviceAttributeRAW('sync_reset', 128, obj.AXICoreTDDDevPtr)); end end - function set.SyncTerminalType(obj, value) + function set.SyncReset(obj, value) + if obj.ConnectedToDevice + obj.setDeviceAttributeRAW('sync_reset', num2str(value), obj.AXICoreTDDDevPtr); + end + end + + function set.SyncSoft(obj, value) if obj.ConnectedToDevice - obj.setDeviceAttributeRAW('sync_terminal_type', num2str(value), obj.AXICoreTDDDevPtr); + obj.setDeviceAttributeRAW('sync_soft', num2str(value), obj.AXICoreTDDDevPtr); end end end + % Get/Set Methods for Channel Attributes methods - function result = get.TxDPoff(obj) - result = [0 0]; + function result = get.Ch0Enable(obj) + result = nan; if ~isempty(obj.AXICoreTDDDevPtr) - result(1) = str2double(obj.getAttributeRAW('data0', 'dp_off_ms', true, obj.AXICoreTDDDevPtr)); - result(2) = str2double(obj.getAttributeRAW('data1', 'dp_off_ms', true, obj.AXICoreTDDDevPtr)); + result = str2double(obj.getAttributeRAW('channel0', 'enable', true, obj.AXICoreTDDDevPtr)); end end - function set.TxDPoff(obj, value) - validateattributes(value, {'double', 'single', 'uint32'}, {'size', [1 2]}); + function set.Ch0Enable(obj, value) + validateattributes(value, {'double', 'single', 'uint32'}, {'nonnegative'}, 'Ch0Enable'); if obj.ConnectedToDevice - obj.setAttributeRAW('data0', 'dp_off_ms', num2str(value(1)), true, obj.AXICoreTDDDevPtr); - obj.setAttributeRAW('data1', 'dp_off_ms', num2str(value(2)), true, obj.AXICoreTDDDevPtr); + obj.setAttributeRAW('channel0', 'enable', num2str(value), true, obj.AXICoreTDDDevPtr); end end - function result = get.TxDPon(obj) - result = [0 0]; + function result = get.Ch0Polarity(obj) + result = nan; if ~isempty(obj.AXICoreTDDDevPtr) - result(1) = str2double(obj.getAttributeRAW('data0', 'dp_on_ms', true, obj.AXICoreTDDDevPtr)); - result(2) = str2double(obj.getAttributeRAW('data1', 'dp_on_ms', true, obj.AXICoreTDDDevPtr)); + result = str2double(obj.getAttributeRAW('channel0', 'polarity', true, obj.AXICoreTDDDevPtr)); end end - function set.TxDPon(obj, value) - validateattributes(value, {'double', 'single', 'uint32'}, {'size', [1 2]}); + function set.Ch0Polarity(obj, value) + validateattributes(value, {'double', 'single', 'uint32'}, {'nonnegative'}, 'Ch0Polarity'); if obj.ConnectedToDevice - obj.setAttributeRAW('data0', 'dp_on_ms', num2str(value(1)), true, obj.AXICoreTDDDevPtr); - obj.setAttributeRAW('data1', 'dp_on_ms', num2str(value(2)), true, obj.AXICoreTDDDevPtr); + obj.setAttributeRAW('channel0', 'polarity', num2str(value), true, obj.AXICoreTDDDevPtr); end end - - function result = get.TxOff(obj) - result = [0 0]; + + function result = get.Ch0On(obj) + result = nan; if ~isempty(obj.AXICoreTDDDevPtr) - result(1) = str2double(obj.getAttributeRAW('data0', 'off_ms', true, obj.AXICoreTDDDevPtr)); - result(2) = str2double(obj.getAttributeRAW('data1', 'off_ms', true, obj.AXICoreTDDDevPtr)); + result = str2double(obj.getAttributeRAW('channel0', 'on_ms', true, obj.AXICoreTDDDevPtr)); end end - function set.TxOff(obj, value) - validateattributes(value, {'double', 'single', 'uint32'}, {'size', [1 2]}); + function set.Ch0On(obj, value) + validateattributes(value, {'double', 'single', 'uint32'}, {'nonnegative'}, 'Ch0On'); if obj.ConnectedToDevice - obj.setAttributeRAW('data0', 'off_ms', num2str(value(1)), true, obj.AXICoreTDDDevPtr); - obj.setAttributeRAW('data1', 'off_ms', num2str(value(2)), true, obj.AXICoreTDDDevPtr); + obj.setAttributeRAW('channel0', 'on_ms', num2str(value), true, obj.AXICoreTDDDevPtr); end end - - function result = get.TxOn(obj) - result = [0 0]; + + function result = get.Ch0Off(obj) + result = nan; if ~isempty(obj.AXICoreTDDDevPtr) - result(1) = str2double(obj.getAttributeRAW('data0', 'on_ms', true, obj.AXICoreTDDDevPtr)); - result(2) = str2double(obj.getAttributeRAW('data1', 'on_ms', true, obj.AXICoreTDDDevPtr)); + result = str2double(obj.getAttributeRAW('channel0', 'off_ms', true, obj.AXICoreTDDDevPtr)); end end - function set.TxOn(obj, value) - validateattributes(value, {'double', 'single', 'uint32'}, {'size', [1 2]}); + function set.Ch0Off(obj, value) + validateattributes(value, {'double', 'single', 'uint32'}, {'nonnegative'}, 'Ch0Off'); if obj.ConnectedToDevice - obj.setAttributeRAW('data0', 'on_ms', num2str(value(1)), true, obj.AXICoreTDDDevPtr); - obj.setAttributeRAW('data1', 'on_ms', num2str(value(2)), true, obj.AXICoreTDDDevPtr); + obj.setAttributeRAW('channel0', 'off_ms', num2str(value), true, obj.AXICoreTDDDevPtr); end end - - function result = get.TxVCOoff(obj) - result = [0 0]; + + function result = get.Ch1Enable(obj) + result = nan; if ~isempty(obj.AXICoreTDDDevPtr) - result(1) = str2double(obj.getAttributeRAW('data0', 'vco_off_ms', true, obj.AXICoreTDDDevPtr)); - result(2) = str2double(obj.getAttributeRAW('data1', 'vco_off_ms', true, obj.AXICoreTDDDevPtr)); + result = str2double(obj.getAttributeRAW('channel1', 'enable', true, obj.AXICoreTDDDevPtr)); end end - function set.TxVCOoff(obj, value) - validateattributes(value, {'double', 'single', 'uint32'}, {'size', [1 2]}); + function set.Ch1Enable(obj, value) + validateattributes(value, {'double', 'single', 'uint32'}, {'nonnegative'}, 'Ch1Enable'); if obj.ConnectedToDevice - obj.setAttributeRAW('data0', 'vco_off_ms', num2str(value(1)), true, obj.AXICoreTDDDevPtr); - obj.setAttributeRAW('data1', 'vco_off_ms', num2str(value(2)), true, obj.AXICoreTDDDevPtr); + obj.setAttributeRAW('channel1', 'enable', num2str(value), true, obj.AXICoreTDDDevPtr); end end - function result = get.TxVCOon(obj) - result = [0 0]; + function result = get.Ch1Polarity(obj) + result = nan; if ~isempty(obj.AXICoreTDDDevPtr) - result(1) = str2double(obj.getAttributeRAW('data0', 'vco_on_ms', true, obj.AXICoreTDDDevPtr)); - result(2) = str2double(obj.getAttributeRAW('data1', 'vco_on_ms', true, obj.AXICoreTDDDevPtr)); + result = str2double(obj.getAttributeRAW('channel1', 'polarity', true, obj.AXICoreTDDDevPtr)); end end - function set.TxVCOon(obj, value) - validateattributes(value, {'double', 'single', 'uint32'}, {'size', [1 2]}); + function set.Ch1Polarity(obj, value) + validateattributes(value, {'double', 'single', 'uint32'}, {'nonnegative'}, 'Ch1Polarity'); if obj.ConnectedToDevice - obj.setAttributeRAW('data0', 'vco_on_ms', num2str(value(1)), true, obj.AXICoreTDDDevPtr); - obj.setAttributeRAW('data1', 'vco_on_ms', num2str(value(2)), true, obj.AXICoreTDDDevPtr); + obj.setAttributeRAW('channel1', 'polarity', num2str(value), true, obj.AXICoreTDDDevPtr); end end - - function result = get.RxDPoff(obj) - result = [0 0]; + + function result = get.Ch1On(obj) + result = nan; if ~isempty(obj.AXICoreTDDDevPtr) - result(1) = str2double(obj.getAttributeRAW('data0', 'dp_off_ms', false, obj.AXICoreTDDDevPtr)); - result(2) = str2double(obj.getAttributeRAW('data1', 'dp_off_ms', false, obj.AXICoreTDDDevPtr)); + result = str2double(obj.getAttributeRAW('channel1', 'on_ms', true, obj.AXICoreTDDDevPtr)); end end - function set.RxDPoff(obj, value) - validateattributes(value, {'double', 'single', 'uint32'}, {'size', [1 2]}); + function set.Ch1On(obj, value) + validateattributes(value, {'double', 'single', 'uint32'}, {'nonnegative'}, 'Ch1On'); if obj.ConnectedToDevice - obj.setAttributeRAW('data0', 'dp_off_ms', num2str(value(1)), false, obj.AXICoreTDDDevPtr); - obj.setAttributeRAW('data1', 'dp_off_ms', num2str(value(2)), false, obj.AXICoreTDDDevPtr); + obj.setAttributeRAW('channel1', 'on_ms', num2str(value), true, obj.AXICoreTDDDevPtr); end end - - function result = get.RxDPon(obj) - result = [0 0]; + + function result = get.Ch1Off(obj) + result = nan; if ~isempty(obj.AXICoreTDDDevPtr) - result(1) = str2double(obj.getAttributeRAW('data0', 'dp_on_ms', false, obj.AXICoreTDDDevPtr)); - result(2) = str2double(obj.getAttributeRAW('data1', 'dp_on_ms', false, obj.AXICoreTDDDevPtr)); + result = str2double(obj.getAttributeRAW('channel1', 'off_ms', true, obj.AXICoreTDDDevPtr)); end end - function set.RxDPon(obj, value) - validateattributes(value, {'double', 'single', 'uint32'}, {'size', [1 2]}); + function set.Ch1Off(obj, value) + validateattributes(value, {'double', 'single', 'uint32'}, {'nonnegative'}, 'Ch1Off'); if obj.ConnectedToDevice - obj.setAttributeRAW('data0', 'dp_on_ms', num2str(value(1)), false, obj.AXICoreTDDDevPtr); - obj.setAttributeRAW('data1', 'dp_on_ms', num2str(value(2)), false, obj.AXICoreTDDDevPtr); + obj.setAttributeRAW('channel1', 'off_ms', num2str(value), true, obj.AXICoreTDDDevPtr); end end - - function result = get.RxOff(obj) - result = [0 0]; + + function result = get.Ch2Enable(obj) + result = nan; if ~isempty(obj.AXICoreTDDDevPtr) - result(1) = str2double(obj.getAttributeRAW('data0', 'off_ms', false, obj.AXICoreTDDDevPtr)); - result(2) = str2double(obj.getAttributeRAW('data1', 'off_ms', false, obj.AXICoreTDDDevPtr)); + result = str2double(obj.getAttributeRAW('channel2', 'enable', true, obj.AXICoreTDDDevPtr)); end end - function set.RxOff(obj, value) - validateattributes(value, {'double', 'single', 'uint32'}, {'size', [1 2]}); + function set.Ch2Enable(obj, value) + validateattributes(value, {'double', 'single', 'uint32'}, {'nonnegative'}, 'Ch2Enable'); if obj.ConnectedToDevice - obj.setAttributeRAW('data0', 'off_ms', num2str(value(1)), false, obj.AXICoreTDDDevPtr); - obj.setAttributeRAW('data1', 'off_ms', num2str(value(2)), false, obj.AXICoreTDDDevPtr); + obj.setAttributeRAW('channel2', 'enable', num2str(value), true, obj.AXICoreTDDDevPtr); end end - function result = get.RxOn(obj) - result = [0 0]; + function result = get.Ch2Polarity(obj) + result = nan; if ~isempty(obj.AXICoreTDDDevPtr) - result(1) = str2double(obj.getAttributeRAW('data0', 'on_ms', false, obj.AXICoreTDDDevPtr)); - result(2) = str2double(obj.getAttributeRAW('data1', 'on_ms', false, obj.AXICoreTDDDevPtr)); + result = str2double(obj.getAttributeRAW('channel2', 'polarity', true, obj.AXICoreTDDDevPtr)); end end - function set.RxOn(obj, value) - validateattributes(value, {'double', 'single', 'uint32'}, {'size', [1 2]}); + function set.Ch2Polarity(obj, value) + validateattributes(value, {'double', 'single', 'uint32'}, {'nonnegative'}, 'Ch2Polarity'); if obj.ConnectedToDevice - obj.setAttributeRAW('data0', 'on_ms', num2str(value(1)), false, obj.AXICoreTDDDevPtr); - obj.setAttributeRAW('data1', 'on_ms', num2str(value(2)), false, obj.AXICoreTDDDevPtr); + obj.setAttributeRAW('channel2', 'polarity', num2str(value), true, obj.AXICoreTDDDevPtr); end end - - function result = get.RxVCOoff(obj) - result = [0 0]; + + function result = get.Ch2On(obj) + result = nan; if ~isempty(obj.AXICoreTDDDevPtr) - result(1) = str2double(obj.getAttributeRAW('data0', 'vco_off_ms', false, obj.AXICoreTDDDevPtr)); - result(2) = str2double(obj.getAttributeRAW('data1', 'vco_off_ms', false, obj.AXICoreTDDDevPtr)); + result = str2double(obj.getAttributeRAW('channel2', 'on_ms', true, obj.AXICoreTDDDevPtr)); end end - function set.RxVCOoff(obj, value) - validateattributes(value, {'double', 'single', 'uint32'}, {'size', [1 2]}); + function set.Ch2On(obj, value) + validateattributes(value, {'double', 'single', 'uint32'}, {'nonnegative'}, 'Ch2On'); if obj.ConnectedToDevice - obj.setAttributeRAW('data0', 'vco_off_ms', num2str(value(1)), false, obj.AXICoreTDDDevPtr); - obj.setAttributeRAW('data1', 'vco_off_ms', num2str(value(2)), false, obj.AXICoreTDDDevPtr); + obj.setAttributeRAW('channel2', 'on_ms', num2str(value), true, obj.AXICoreTDDDevPtr); end end - - function result = get.RxVCOon(obj) - result = [0 0]; + + function result = get.Ch2Off(obj) + result = nan; if ~isempty(obj.AXICoreTDDDevPtr) - result(1) = str2double(obj.getAttributeRAW('data0', 'vco_on_ms', false, obj.AXICoreTDDDevPtr)); - result(2) = str2double(obj.getAttributeRAW('data1', 'vco_on_ms', false, obj.AXICoreTDDDevPtr)); + result = str2double(obj.getAttributeRAW('channel2', 'off_ms', true, obj.AXICoreTDDDevPtr)); end end - function set.RxVCOon(obj, value) - validateattributes(value, {'double', 'single', 'uint32'}, {'size', [1 2]}); + function set.Ch2Off(obj, value) + validateattributes(value, {'double', 'single', 'uint32'}, {'nonnegative'}, 'Ch2Off'); if obj.ConnectedToDevice - obj.setAttributeRAW('data0', 'vco_on_ms', num2str(value(1)), false, obj.AXICoreTDDDevPtr); - obj.setAttributeRAW('data1', 'vco_on_ms', num2str(value(2)), false, obj.AXICoreTDDDevPtr); + obj.setAttributeRAW('channel2', 'off_ms', num2str(value), true, obj.AXICoreTDDDevPtr); end end end @@ -441,6 +391,9 @@ function setupInit(obj) if strcmpi(obj.AXICoreTDDDevPtrNames{dn},name) obj.AXICoreTDDDevPtr = devPtr; end + if strcmpi('one-bit-adc-dac',name) + obj.GPIODevIIO = devPtr; + end end if isempty(obj.AXICoreTDDDevPtr) error('%s not found',obj.AXICoreTDDDevPtrNames{dn}); diff --git a/+adi/+internal/StingrayControl.m b/+adi/+internal/StingrayControl.m index 2eadb3a..b99050e 100644 --- a/+adi/+internal/StingrayControl.m +++ b/+adi/+internal/StingrayControl.m @@ -18,70 +18,54 @@ end properties(Hidden) - SRayCtrlDeviceNames = {'one-bit-adc-dac'}; - SRayCtrlDevLabel = 'stingray_control'; - SRayCtrlDevices + SRayCtrlDeviceName = 'stingray_control'; + SRayCtrlDevice end methods function result = get.PowerUpDown(obj) result = false; - if ~isempty(obj.SRayCtrlDevices) - result = obj.getAttributeRAW('voltage5', 'raw', true, obj.SRayCtrlDevices); + if ~isempty(obj.SRayCtrlDevice) + result = obj.getAttributeRAW('voltage5', 'raw', true, obj.SRayCtrlDevice); end end function set.PowerUpDown(obj, value) - obj.setAttributeRAW('voltage5', 'raw', num2str(value), true, obj.SRayCtrlDevices); + if obj.ConnectedToDevice + obj.setAttributeRAW('voltage5', 'raw', num2str(value), true, obj.SRayCtrlDevice); + end end function result = get.Ctrl5V(obj) result = false; - if ~isempty(obj.SRayCtrlDevices) - result = obj.getAttributeRAW('voltage4', 'raw', true, obj.SRayCtrlDevices); + if ~isempty(obj.SRayCtrlDevice) + result = obj.getAttributeRAW('voltage4', 'raw', true, obj.SRayCtrlDevice); end end function set.Ctrl5V(obj, value) - obj.setAttributeRAW('voltage4', 'raw', num2str(value), true, obj.SRayCtrlDevices); + if obj.ConnectedToDevice + obj.setAttributeRAW('voltage4', 'raw', num2str(value), true, obj.SRayCtrlDevice); + end end function result = get.PAOn(obj) result = false; - if ~isempty(obj.SRayCtrlDevices) - result = obj.getAttributeRAW('voltage0', 'raw', true, obj.SRayCtrlDevices); + if ~isempty(obj.SRayCtrlDevice) + result = obj.getAttributeRAW('voltage0', 'raw', true, obj.SRayCtrlDevice); end end function set.PAOn(obj, value) - obj.setAttributeRAW('voltage0', 'raw', num2str(value), true, obj.SRayCtrlDevices); + if obj.ConnectedToDevice + obj.setAttributeRAW('voltage0', 'raw', num2str(value), true, obj.SRayCtrlDevice); + end end end methods (Hidden, Access = protected) function setupInit(obj) - numDevs = obj.iio_context_get_devices_count(obj.iioCtx); - for dn = 1:length(obj.SRayCtrlDeviceNames) - for k = 1:numDevs - devPtr = obj.iio_context_get_device(obj.iioCtx, k-1); - name = obj.iio_device_get_name(devPtr); - if strcmpi(obj.SRayCtrlDeviceNames{dn},name) - attr = obj.iio_device_get_attr(devPtr,0); - if strcmpi(attr,'label') - val = obj.getDeviceAttributeRAW(attr,128,devPtr); - if strcmpi(val, obj.SRayCtrlDevLabel) - obj.SRayCtrlDevices = devPtr; - break; - else - continue; - end - end - end - end - if isempty(obj.SRayCtrlDevices) - error('%s not found',obj.SRayCtrlDeviceNames{dn}); - end - end + obj.SRayCtrlDevice = obj.getDev(obj.SRayCtrlDeviceName); end end end \ No newline at end of file diff --git a/+adi/+internal/XUD1aControl.m b/+adi/+internal/XUD1aControl.m index a7408a3..f7d3167 100644 --- a/+adi/+internal/XUD1aControl.m +++ b/+adi/+internal/XUD1aControl.m @@ -1,145 +1,208 @@ -classdef XUD1aControl < adi.common.Attribute +classdef XUD1aControl < adi.common.Attribute & adi.common.Rx % ADXUD1AEBZ quad channel Up and Down converter % % https://wiki.analog.com/resources/eval/user-guides/xud1a/user-guide properties + %SelectChannelSetMode SelectChannelSetMode + % Select Channel and set Mode + % Usage: + % Channel A in Tx Mode - Set SelectChannelSetMode to "A_Tx" + % Channel A in Rx Low Gain Mode - Set SelectChannelSetMode to "A_RxLG" + % Channel A in Rx High Gain Mode - Set SelectChannelSetMode to "A_RxHG" + % Channel B in Tx Mode - Set SelectChannelSetMode to "B_Tx" + % Channel B in Rx Low Gain Mode - Set SelectChannelSetMode to "B_RxLG" + % Channel B in Rx High Gain Mode - Set SelectChannelSetMode to "B_RxHG" + % Channel C in Tx Mode - Set SelectChannelSetMode to "C_Tx" + % Channel C in Rx Low Gain Mode - Set SelectChannelSetMode to "C_RxLG" + % Channel C in Rx High Gain Mode - Set SelectChannelSetMode to "C_RxHG" + % Channel D in Tx Mode - Set SelectChannelSetMode to "D_Tx" + % Channel D in Rx Low Gain Mode - Set SelectChannelSetMode to "D_RxLG" + % Channel D in Rx High Gain Mode - Set SelectChannelSetMode to "D_RxHG" + SelectChannelSetMode (1,1) string {... + mustBeMember(SelectChannelSetMode, [... + "A_Tx", "A_RxLG", "A_RxHG", ... + "B_Tx", "B_RxLG", "B_RxHG", ... + "C_Tx", "C_RxLG", "C_RxHG", ... + "D_Tx", "D_RxLG", "D_RxHG" ... + ])} = "A_RxLG"; + %PllOutputSel PLL Output Select + % Configure ADF4371 output frequency + % 1: 8-16 GHz + % 0: 16-32 GHz + PllOutputSel = 1; + end + + properties (Hidden) %TXRX0 TXRX0 % Select Channel A for XUD1A Up and Down converter % Usage: % Channel A in Tx Mode - Set TXRX0 to 0, RxGainMode to 0 % Channel A in Rx Low Gain Mode - Set TXRX0 to 1, RxGainMode to 0 % Channel A in Rx High Gain Mode - Set TXRX0 to 1, RxGainMode to 1 - TXRX0 + TXRX0 = 1; %TXRX1 TXRX1 % Select Channel B for XUD1A Up and Down converter % Usage: % Channel B in Tx Mode - Set TXRX1 to 0, RxGainMode to 0 % Channel B in Rx Low Gain Mode - Set TXRX1 to 1, RxGainMode to 0 % Channel B in Rx High Gain Mode - Set TXRX1 to 1, RxGainMode to 1 - TXRX1 + TXRX1 = 0; %TXRX2 TXRX2 % Select Channel C for XUD1A Up and Down converter % Usage: % Channel C in Tx Mode - Set TXRX2 to 0, RxGainMode to 0 % Channel C in Rx Low Gain Mode - Set TXRX2 to 1, RxGainMode to 0 % Channel C in Rx High Gain Mode - Set TXRX2 to 1, RxGainMode to 1 - TXRX2 + TXRX2 = 0; %TXRX3 TXRX3 % Select Channel D for XUD1A Up and Down converter % Usage: % Channel D in Tx Mode - Set TXRX3 to 0, RxGainMode to 0 % Channel D in Rx Low Gain Mode - Set TXRX3 to 1, RxGainMode to 0 % Channel D in Rx High Gain Mode - Set TXRX3 to 1, RxGainMode to 1 - TXRX3 - %PllOutputSel PLL Output Select - % Configure ADF4371 output frequency - % 1: 8-16 GHz - % 0: 16-32 GHz - PllOutputSel + TXRX3 = 0; %RxGainMode Rx Gain Mode % For usage, see usage of TXRX[0-3] - RxGainMode + RxGainMode = 0; end properties(Hidden) - XUD1aCtrlDeviceNames = {'one-bit-adc-dac'}; - XUD1aCtrlDevLabel = 'xud_control'; - XUD1aCtrlDevices + XUD1aCtrlDeviceName = 'xud_control'; + XUD1aCtrlDevice end methods + function set.SelectChannelSetMode(obj, value) + if obj.ConnectedToDevice + switch value + case "A_Tx" + obj.TXRX0 = 0; + obj.RxGainMode = 0; + case "A_RxLG" + obj.TXRX0 = 1; + obj.RxGainMode = 0; + case "A_RxHG" + obj.TXRX0 = 1; + obj.RxGainMode = 1; + case "B_Tx" + obj.TXRX1 = 0; + obj.RxGainMode = 0; + case "B_RxLG" + obj.TXRX1 = 1; + obj.RxGainMode = 0; + case "B_RxHG" + obj.TXRX1 = 1; + obj.RxGainMode = 1; + case "C_Tx" + obj.TXRX2 = 0; + obj.RxGainMode = 0; + case "C_RxLG" + obj.TXRX2 = 1; + obj.RxGainMode = 0; + case "C_RxHG" + obj.TXRX2 = 1; + obj.RxGainMode = 1; + case "D_Tx" + obj.TXRX3 = 0; + obj.RxGainMode = 0; + case "D_RxLG" + obj.TXRX3 = 1; + obj.RxGainMode = 0; + case "D_RxHG" + obj.TXRX3 = 1; + obj.RxGainMode = 1; + end + end + end + function result = get.RxGainMode(obj) result = false; - if ~isempty(obj.XUD1aCtrlDevices) - result = obj.getAttributeRAW('voltage0', 'raw', true, obj.XUD1aCtrlDevices); + if ~isempty(obj.XUD1aCtrlDevice) + result = obj.getAttributeRAW('voltage0', 'raw', true, obj.XUD1aCtrlDevice); end end function set.RxGainMode(obj, value) - obj.setAttributeRAW('voltage0', 'raw', num2str(value), true, obj.XUD1aCtrlDevices); + if obj.ConnectedToDevice + obj.setAttributeRAW('voltage0', 'raw', num2str(value), true, obj.XUD1aCtrlDevice); + end end function result = get.TXRX0(obj) result = false; - if ~isempty(obj.XUD1aCtrlDevices) - result = obj.getAttributeRAW('voltage1', 'raw', true, obj.XUD1aCtrlDevices); + if ~isempty(obj.XUD1aCtrlDevice) + result = obj.getAttributeRAW('voltage1', 'raw', true, obj.XUD1aCtrlDevice); end end function set.TXRX0(obj, value) - obj.setAttributeRAW('voltage1', 'raw', num2str(value), true, obj.XUD1aCtrlDevices); + if obj.ConnectedToDevice + obj.setAttributeRAW('voltage1', 'raw', num2str(value), true, obj.XUD1aCtrlDevice); + end end function result = get.TXRX1(obj) result = false; - if ~isempty(obj.XUD1aCtrlDevices) - result = obj.getAttributeRAW('voltage2', 'raw', true, obj.XUD1aCtrlDevices); + if ~isempty(obj.XUD1aCtrlDevice) + result = obj.getAttributeRAW('voltage2', 'raw', true, obj.XUD1aCtrlDevice); end end function set.TXRX1(obj, value) - obj.setAttributeRAW('voltage2', 'raw', num2str(value), true, obj.XUD1aCtrlDevices); + if obj.ConnectedToDevice + obj.setAttributeRAW('voltage2', 'raw', num2str(value), true, obj.XUD1aCtrlDevice); + end end function result = get.TXRX2(obj) result = false; - if ~isempty(obj.XUD1aCtrlDevices) - result = obj.getAttributeRAW('voltage3', 'raw', true, obj.XUD1aCtrlDevices); + if ~isempty(obj.XUD1aCtrlDevice) + result = obj.getAttributeRAW('voltage3', 'raw', true, obj.XUD1aCtrlDevice); end end function set.TXRX2(obj, value) - obj.setAttributeRAW('voltage3', 'raw', num2str(value), true, obj.XUD1aCtrlDevices); + if obj.ConnectedToDevice + obj.setAttributeRAW('voltage3', 'raw', num2str(value), true, obj.XUD1aCtrlDevice); + end end function result = get.TXRX3(obj) result = false; - if ~isempty(obj.XUD1aCtrlDevices) - result = obj.getAttributeRAW('voltage4', 'raw', true, obj.XUD1aCtrlDevices); + if ~isempty(obj.XUD1aCtrlDevice) + result = obj.getAttributeRAW('voltage4', 'raw', true, obj.XUD1aCtrlDevice); end end function set.TXRX3(obj, value) - obj.setAttributeRAW('voltage4', 'raw', num2str(value), true, obj.XUD1aCtrlDevices); + if obj.ConnectedToDevice + obj.setAttributeRAW('voltage4', 'raw', num2str(value), true, obj.XUD1aCtrlDevice); + end end function result = get.PllOutputSel(obj) result = false; - if ~isempty(obj.XUD1aCtrlDevices) - result = obj.getAttributeRAW('voltage5', 'raw', true, obj.XUD1aCtrlDevices); + if ~isempty(obj.XUD1aCtrlDevice) + result = obj.getAttributeRAW('voltage5', 'raw', true, obj.XUD1aCtrlDevice); end end function set.PllOutputSel(obj, value) - obj.setAttributeRAW('voltage5', 'raw', num2str(value), true, obj.XUD1aCtrlDevices); + if obj.ConnectedToDevice + obj.setAttributeRAW('voltage5', 'raw', num2str(value), true, obj.XUD1aCtrlDevice); + end end end methods (Hidden, Access = protected) function setupInit(obj) - numDevs = obj.iio_context_get_devices_count(obj.iioCtx); - for dn = 1:length(obj.XUD1aCtrlDeviceNames) - for k = 1:numDevs - devPtr = obj.iio_context_get_device(obj.iioCtx, k-1); - name = obj.iio_device_get_name(devPtr); - if strcmpi(obj.XUD1aCtrlDeviceNames{dn},name) - attr = obj.iio_device_get_attr(devPtr,0); - if strcmpi(attr,'label') - val = obj.getDeviceAttributeRAW(attr,128,devPtr); - if strcmpi(val, obj.XUD1aCtrlDevLabel) - obj.XUD1aCtrlDevices = devPtr; - break; - else - continue; - end - end - end - end - if isempty(obj.SRayCtrlDevices) - error('%s not found',obj.XUD1aCtrlDeviceNames{dn}); - end - end + obj.XUD1aCtrlDevice = obj.getDev(obj.XUD1aCtrlDeviceName); + + % Set defaults + obj.setAttributeRAW('voltage1', 'raw', num2str(1), true, obj.XUD1aCtrlDevice); + obj.setAttributeRAW('voltage0', 'raw', num2str(0), true, obj.XUD1aCtrlDevice); + obj.setAttributeRAW('voltage5', 'raw', num2str(1), true, obj.XUD1aCtrlDevice); end end end \ No newline at end of file diff --git a/+adi/Contents.m b/+adi/Contents.m index 4c61c07..ed4a5ed 100644 --- a/+adi/Contents.m +++ b/+adi/Contents.m @@ -1,5 +1,5 @@ -% Analog Devices, Inc. High Speed Converter Toolbox -% Version 21.2.2 (R2021b) +% Analog Devices, Inc. RF and Microwave Toolbox +% Version 22.1.2 (R2022a) % % ==== Table of Contents (TOC) ==== % diff --git a/+adi/Phaser.m b/+adi/Phaser.m index 0f2bcd4..60ba3c2 100644 --- a/+adi/Phaser.m +++ b/+adi/Phaser.m @@ -1,6 +1,5 @@ classdef Phaser < adi.internal.ADAR100x & ... - adi.internal.ADF4159 & ... - adi.internal.AXICoreTDD + adi.internal.ADF4159 % adi.Phaser Analog Devices Inc. ADALM-PHASER beamformer development platform % The adi.Phaser system object is an API to control the % ADALM-PHASER X/Ku Band Beamforming Developer Platform. @@ -17,19 +16,72 @@ properties(Logical) %EnablePLL Enable PLL - % Enable onboard PLL which is the main LO source. This controls - % V_CTRL_1 - EnablePLL= true; + % This controls V_CTRL_1 + % true = enable onboard PLL which is the main LO source. + % false = disable onboard PLL and enable external LO path + EnablePLL = true; + %EnableTxPLL Enable Tx PLL - % Enable PLL to feed the Tx LO. This controls V_CTRL_2 - EnableTxPLL= true; + % This controls V_CTRL_2 + % true = send LO to transmit circuits + % false = disable transmit path + EnableTxPLL = true; + + %EnableOut1 Enable Tx SW + % This controls TX_SW (GPIO_W) + % true = send transmit to OUT1 SMA port + % false = send transmit to OUT2 SMA port + EnableOut1 = true; + + %Burst TDD Burst Trigger Input + % Low to high on BURST triggers external input of TDD engine + Burst = false; end - + + properties + %MonitorVDD1V8 1.8V Power Supply + % 1.8V power supply voltage monitor + MonitorVDD1V8 = 1.8; + + %MonitorVDD3V0 3.0V Power Supply + % 3.0V power supply voltage monitor + MonitorVDD3V0 = 3.0; + + %MonitorVDD3V3 3.3V Power Supply + % 3.3V power supply voltage monitor + MonitorVDD3V3 = 3.3; + + %MonitorVDD4V5 4.5V Power Supply + % 4.5V power supply voltage monitor + MonitorVDD4V5 = 4.5; + + %MonitorVDDAmp 14V Power Supply + % 14V boost power supply voltage monitor + MonitorVDDAmp = 14; + + %MonitorVinput 5V Input Power Supply + % USB-C 5V input power supply voltage monitor + MonitorVinput = 5.0; + + %MonitorImon Board Input Current + % USB-C Input current monitor in Amps + MonitorImon = 2.0; + + %MonitorVtune VCO Vtune Voltage + % Vtune voltage directly relates to VCO frequency + MonitorVtune = 10.0; + + %MonitorBoardTemp Board Temp + % Board temperature monitor in deg C + MonitorBoardTemp = 25.0; + end + properties(Hidden) deviceNames = {... 'adar1000_0',... 'adar1000_1'}; GPIODevIIO; + housekeepingADC; end properties @@ -51,10 +103,132 @@ function delete(obj) % VCTRL_1 setAttributeBool(obj, 'voltage6', 'raw', value, true, obj.GPIODevIIO); end + function result = get.EnablePLL(obj) + result = nan; + if ~isempty(obj.GPIODevIIO) + result = obj.getAttributeBool('voltage6', 'raw', true, obj.GPIODevIIO); + end + end function set.EnableTxPLL(obj, value) % VCTRL_2 setAttributeBool(obj, 'voltage7', 'raw', value, true, obj.GPIODevIIO); end + function result = get.EnableTxPLL(obj) + result = nan; + if ~isempty(obj.GPIODevIIO) + result = obj.getAttributeBool('voltage7', 'raw', true, obj.GPIODevIIO); + end + end + function set.EnableOut1(obj, value) + % TX_SW + setAttributeRAW(obj, 'voltage8', 'raw', num2str(value), true, obj.GPIODevIIO); + end + function result = get.EnableOut1(obj) + result = nan; + if ~isempty(obj.GPIODevIIO) + result = obj.getAttributeBool('voltage8', 'raw', true, obj.GPIODevIIO); + end + end + + function set.Burst(obj, value) + % BURST + setAttributeBool(obj, 'voltage9', 'raw', value, true, obj.GPIODevIIO); + end + function result = get.Burst(obj) + result = nan; + if ~isempty(obj.GPIODevIIO) + result = obj.getAttributeBool('voltage9', 'raw', true, obj.GPIODevIIO); + end + end + + function result = get.MonitorVDD1V8(obj) + result = nan; + if ~isempty(obj.housekeepingADC) + rvalue = str2double(obj.getAttributeRAW('voltage0', 'raw', false, obj.housekeepingADC)); + scale = str2double(obj.getAttributeRAW('voltage0', 'scale', false, obj.housekeepingADC)); + Rdivider = 1.0 + (10.0 / 10.0); % resistor divider to AD7291 ADC input + result = rvalue * scale * Rdivider / 1000; + end + end + + function result = get.MonitorVDD3V0(obj) + result = nan; + if ~isempty(obj.housekeepingADC) + rvalue = str2double(obj.getAttributeRAW('voltage1', 'raw', false, obj.housekeepingADC)); + scale = str2double(obj.getAttributeRAW('voltage1', 'scale', false, obj.housekeepingADC)); + Rdivider = 1.0 + (10.0 / 10.0); % resistor divider to AD7291 ADC input + result = rvalue * scale * Rdivider / 1000; + end + end + + function result = get.MonitorVDD3V3(obj) + result = nan; + if ~isempty(obj.housekeepingADC) + rvalue = str2double(obj.getAttributeRAW('voltage2', 'raw', false, obj.housekeepingADC)); + scale = str2double(obj.getAttributeRAW('voltage2', 'scale', false, obj.housekeepingADC)); + Rdivider = 1.0 + (10.0 / 10.0); % resistor divider to AD7291 ADC input + result = rvalue * scale * Rdivider / 1000; + end + end + + function result = get.MonitorVDD4V5(obj) + result = nan; + if ~isempty(obj.housekeepingADC) + rvalue = str2double(obj.getAttributeRAW('voltage3', 'raw', false, obj.housekeepingADC)); + scale = str2double(obj.getAttributeRAW('voltage3', 'scale', false, obj.housekeepingADC)); + Rdivider = 1.0 + (30.1 / 10.0); % resistor divider to AD7291 ADC input + result = rvalue * scale * Rdivider / 1000; + end + end + + function result = get.MonitorVDDAmp(obj) + result = nan; + if ~isempty(obj.housekeepingADC) + rvalue = str2double(obj.getAttributeRAW('voltage4', 'raw', false, obj.housekeepingADC)); + scale = str2double(obj.getAttributeRAW('voltage4', 'scale', false, obj.housekeepingADC)); + Rdivider = 1.0 + (69.8 / 10.0); % resistor divider to AD7291 ADC input + result = rvalue * scale * Rdivider / 1000; + end + end + + function result = get.MonitorVinput(obj) + result = nan; + if ~isempty(obj.housekeepingADC) + rvalue = str2double(obj.getAttributeRAW('voltage5', 'raw', false, obj.housekeepingADC)); + scale = str2double(obj.getAttributeRAW('voltage5', 'scale', false, obj.housekeepingADC)); + Rdivider = 1.0 + (30.1 / 10.0); % resistor divider to AD7291 ADC input + result = rvalue * scale * Rdivider / 1000; + end + end + + function result = get.MonitorImon(obj) + result = nan; + if ~isempty(obj.housekeepingADC) + rvalue = str2double(obj.getAttributeRAW('voltage6', 'raw', false, obj.housekeepingADC)); + scale = str2double(obj.getAttributeRAW('voltage6', 'scale', false, obj.housekeepingADC)); + Rdivider = 1.0; % LTC4217 IMON=50uA/A*20k = 1V/A + result = rvalue * scale * Rdivider / 1000; + end + end + + function result = get.MonitorVtune(obj) + result = nan; + if ~isempty(obj.housekeepingADC) + rvalue = str2double(obj.getAttributeRAW('voltage7', 'raw', false, obj.housekeepingADC)); + scale = str2double(obj.getAttributeRAW('voltage7', 'scale', false, obj.housekeepingADC)); + Rdivider = 1.0 + (69.8 / 10.0); % resistor divider to AD7291 ADC input + result = rvalue * scale * Rdivider / 1000; + end + end + + function result = get.MonitorBoardTemp(obj) + result = nan; + if ~isempty(obj.housekeepingADC) + rvalue = str2double(obj.getAttributeRAW('temp0', 'raw', false, obj.housekeepingADC)); + scale = str2double(obj.getAttributeRAW('temp0', 'scale', false, obj.housekeepingADC)); + result = rvalue * scale / 1000; + end + end end methods (Hidden, Access = protected) @@ -62,12 +236,21 @@ function setupInit(obj) setupInit@adi.internal.ADAR100x(obj); % PLL setupInit@adi.internal.ADF4159(obj); - % AXI-Core-TDD -% setupInit@adi.internal.AXICoreTDD(obj); % GPIO control pins obj.GPIODevIIO = obj.getDev('one-bit-adc-dac'); - setAttributeBool(obj, 'voltage6', 'raw', obj.EnablePLL, true, obj.GPIODevIIO); - setAttributeBool(obj, 'voltage7', 'raw', obj.EnableTxPLL, true, obj.GPIODevIIO); + setAttributeRAW(obj, 'voltage6', 'raw', num2str(obj.EnablePLL), true, obj.GPIODevIIO); + setAttributeRAW(obj, 'voltage7', 'raw', num2str(obj.EnableTxPLL), true, obj.GPIODevIIO); + setAttributeRAW(obj, 'voltage9', 'raw', num2str(obj.Burst), true, obj.GPIODevIIO); + + % Set voltages on MR, s0, s1, and s2 for OUT1/OUT2 selection + setAttributeBool(obj, 'voltage5', 'raw', true, true, obj.GPIODevIIO); %MR GPIO_V + setAttributeBool(obj, 'voltage0', 'raw', false, true, obj.GPIODevIIO); %s0 GPIO_X + setAttributeBool(obj, 'voltage3', 'raw', false, true, obj.GPIODevIIO); %s1 GPIO_Y + setAttributeBool(obj, 'voltage4', 'raw', false, true, obj.GPIODevIIO); %s2 GPIO_Z + setAttributeBool(obj, 'voltage8', 'raw', false, true, obj.GPIODevIIO); %voltage8 is TX_SW GPIO_W + + % Houskeeping ADC to monitor voltages and current + obj.housekeepingADC = obj.getDev('ad7291'); end end end diff --git a/+adi/PlutoTDD.m b/+adi/PlutoTDD.m new file mode 100644 index 0000000..f897d98 --- /dev/null +++ b/+adi/PlutoTDD.m @@ -0,0 +1,82 @@ +classdef PlutoTDD < adi.internal.AXICoreTDD + % adi.PlutoTDD Analog Devices Inc. + % TDD Engine Controller + % The adi.PlutoTDD system object is an API to control the + % Pluto transmit and receive timing + % + % rx = adi.PlutoTDD; + % rx = adi.PlutoTDD('uri','ip:192.168.2.1'); + % + % https://wiki.analog.com/resources/fpga/docs/axi_tdd + + properties(Nontunable, Hidden) + kernelBuffersCount = 0; + dataTypeStr = 'int16'; + iioDriverName = 'TDDPluto'; + devName = 'TDDPluto'; + SamplesPerFrame = 0; + SkipInit = false; + end + + properties (Hidden, Constant, Logical) + ComplexData = false; + end + + properties(Nontunable, Hidden, Constant) + Type = 'Rx'; + end + + properties (Hidden, Nontunable, Access = protected) + isOutput = false; + end + + methods + %% Constructor + function obj = PlutoTDD(varargin) + coder.allowpcode('plain'); + obj = obj@adi.internal.AXICoreTDD(varargin{:}); + end + % Destructor + function delete(obj) + end + + end + + methods (Hidden, Access = protected) + function setupImpl(obj) + setupLib(obj); + initPointers(obj); + getContext(obj); + setContextTimeout(obj); + obj.needsTeardown = true; + obj.ConnectedToDevice = true; + setupInit(obj); + end + + function setupInit(obj) + % AXI-Core-TDD + setupInit@adi.internal.AXICoreTDD(obj); + end + + function v = stepImpl(~) + v = true; + end + + function flag = isInactivePropertyImpl(obj, prop) + % Return false if property is visible based on object + flag = false; + if strcmpi('EnabledChannels',prop) + flag = true; + end + % Call the base class method + flag = flag || isInactivePropertyImpl@adi.common.RxTx(obj, prop); + + end + end + + methods (Access=protected) + function numOut = getNumOutputsImpl(~) + numOut = 1; + end + end +end diff --git a/+adi/Version.m b/+adi/Version.m index ab2ec66..a55a5da 100644 --- a/+adi/Version.m +++ b/+adi/Version.m @@ -2,8 +2,8 @@ %Version % BSP Version information properties(Constant) - MATLAB = 'R2021b'; - Release = '21.2.2'; + MATLAB = 'R2022a'; + Release = '22.1.2'; AppName = 'Analog Devices, Inc. RF Microwave Toolbox'; ToolboxName = 'RFMicrowaveToolbox'; ToolboxNameShort = 'rfuw'; diff --git a/CI/gen_doc/Makefile b/CI/gen_doc/Makefile index 130af15..6826e0c 100644 --- a/CI/gen_doc/Makefile +++ b/CI/gen_doc/Makefile @@ -8,11 +8,11 @@ SHELL := /bin/bash MLFLAGS := -nodisplay -nodesktop -nosplash ifeq ($(MLRELEASE),) -MLRELEASE := R2021b +MLRELEASE := R2022a endif ifeq ($(HDLBRANCH),) -HDLBRANCH := hdl_2018_r2 +HDLBRANCH := hdl_2021_r2 endif ifeq ($(OS),Windows_NT) diff --git a/CI/gen_doc/source/conf.py b/CI/gen_doc/source/conf.py index f54a09c..aabc667 100644 --- a/CI/gen_doc/source/conf.py +++ b/CI/gen_doc/source/conf.py @@ -18,11 +18,11 @@ # -- Project information ----------------------------------------------------- project = 'Transceiver Toolbox' -copyright = '2021, Travis F. Collins' +copyright = '2022, Travis F. Collins' author = 'Travis F. Collins' # The full version, including alpha/beta/rc tags -release = '21.1.1' +release = '22.1.1' # -- General configuration --------------------------------------------------- diff --git a/CI/scripts/Makefile b/CI/scripts/Makefile index 4e91c39..3c1fa46 100644 --- a/CI/scripts/Makefile +++ b/CI/scripts/Makefile @@ -8,11 +8,11 @@ SHELL := /bin/bash MLFLAGS := -nodisplay -nodesktop -nosplash ifeq ($(MLRELEASE),) -MLRELEASE := R2021b +MLRELEASE := R2022a endif ifeq ($(HDLBRANCH),) -HDLBRANCH := hdl_2019_r1 +HDLBRANCH := hdl_2021_r2 endif ifeq ($(OS),Windows_NT) diff --git a/CI/scripts/build_bsp.sh b/CI/scripts/build_bsp.sh index 5a7d1a8..128b68f 100644 --- a/CI/scripts/build_bsp.sh +++ b/CI/scripts/build_bsp.sh @@ -2,7 +2,7 @@ set -x if [ -z "${HDLBRANCH}" ]; then -HDLBRANCH='hdl_2019_r2' +HDLBRANCH='hdl_2021_r2' fi diff --git a/CI/scripts/genTlbx.m b/CI/scripts/genTlbx.m index 604a69a..d21fd17 100644 --- a/CI/scripts/genTlbx.m +++ b/CI/scripts/genTlbx.m @@ -4,7 +4,7 @@ function genTlbx(examples) examples = 0; end -version = '21.2.2'; +version = '22.1.2'; ml = ver('MATLAB'); ml = ml.Release(2:end-1); uuid = matlab.lang.internal.uuid; diff --git a/Jenkinsfile b/Jenkinsfile index 2d72d1a..6f52e08 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,7 @@ @Library('tfc-lib') _ dockerConfig = getDockerConfig(['MATLAB','Vivado'], matlabHSPro=false) -dockerConfig.add("-e MLRELEASE=R2021b") +dockerConfig.add("-e MLRELEASE=R2022a") dockerHost = 'docker' //////////////////////////// @@ -46,7 +46,7 @@ node { unstash "builtSources" uploadArtifactory('RFMicrowaveToolbox','*.mltbx') } - if (env.BRANCH_NAME == 'master') { + if (env.BRANCH_NAME == 'main') { stage('Deploy Production') { unstash "builtSources" uploadFTP('RFMicrowaveToolbox','*.mltbx') diff --git a/README.md b/README.md index c1f0dec..8284c59 100644 --- a/README.md +++ b/README.md @@ -12,14 +12,15 @@ As with many open source packages, we use [GitHub](https://github.com/analogdevi | MATLAB Release | Installer Package | |:--------------:|:-------------------:| -| R2021b | | +| R2022a | | If you use it, and like it - please let us know. If you use it, and hate it - please let us know that too. ## Supported Tools and Releases We provide support across two releases of MATLAB. This does not mean older releases will not work but they are not maintained. Currently supported tools are: -- Bug fixes and new features: MATLAB R2021b +- Bug fixes and new features: MATLAB R2022a with 2021_R2 Kuiper +- Bug fixes: MATLAB R2021b with 2021_R1 Kuiper ## Support and Documentation diff --git a/info.xml b/info.xml index d712454..0736613 100644 --- a/info.xml +++ b/info.xml @@ -8,7 +8,7 @@ - R2021b + R2022a Analog Devices, Inc. RF and Microwave Toolbox diff --git a/rfm_examples/XBDP_SimpleRx.m b/rfm_examples/XBDP_SimpleRx.m index fd11b33..bf1f1d2 100644 --- a/rfm_examples/XBDP_SimpleRx.m +++ b/rfm_examples/XBDP_SimpleRx.m @@ -47,10 +47,10 @@ rxPhaseCalOffsets = zeros(size(sray.RxGain)); sray.Mode(:) = {'Rx'}; %set mode, 'Rx', 'Tx, 'Disabled' sray.RxAttn(:) = 1; %1: Attenuation Off, 0: Attenuation On -sray.SteerRx(0,0,rxPhaseCalOffsets); %Broadside sray.RxGain(:) = 127; %127: Highest Gain, 0: Lowest Gain, Decimal Value -sray.LatchRxSettings; %Latch SPI settings to devices sray(); %constructor to write properties to hardware +sray.SteerRx(0,0,rxPhaseCalOffsets); %Broadside +sray.LatchRxSettings; %Latch SPI settings to devices %Setup ADXUD1AEBZ, %Rx High Gain Mode sray.TXRX0 = 0; %0: RX, 1: TX diff --git a/rfm_examples/XBDP_SimpleTx.m b/rfm_examples/XBDP_SimpleTx.m index ff26129..f366d24 100644 --- a/rfm_examples/XBDP_SimpleTx.m +++ b/rfm_examples/XBDP_SimpleTx.m @@ -67,11 +67,11 @@ sray.uri = uri; sray.Mode(:) = {'Tx'}; %set mode, 'Rx', 'Tx, 'Disabled' txPhaseCalOffsets = zeros(size(sray.TxGain)); -sray.TxAttn(:) = true; %1: Attenuation Off, 0: Attenuation On -sray.SteerTx(0,0,txPhaseCalOffsets); %Broadside +sray.TxAttn(:) = 1; %1: Attenuation Off, 0: Attenuation On sray.TxGain(:) = 127; %127: Highest Gain, 0: Lowest Gain, Decimal Value -sray.LatchTxSettings; %Latch settings to devices sray(); %Stingray Constructor +sray.SteerTx(0,0,txPhaseCalOffsets); %Broadside +sray.LatchTxSettings; %Latch settings to devices %Setup ADXUD1AEBZ, %Tx Mode sray.TXRX0 = 1; %0: RX, 1: TX @@ -84,7 +84,7 @@ sray.PABiasOn(:) = -1.06; sray.TxPAEnable(:) = true; -sray.TxPowerDown(1) = false; %Enable all channels for TX +sray.TxPowerDown(:) = false; %Enable all channels for TX detect = sray.LTC2314RFPower; %reads detected power (dBm) for J9 Input diff --git a/test/StingrayTests.m b/test/StingrayTests.m index a6d1b62..c9bc776 100644 --- a/test/StingrayTests.m +++ b/test/StingrayTests.m @@ -1,6 +1,6 @@ classdef StingrayTests < HardwareTests - properties - uri = 'ip:10.72.162.61'; + properties + uri = 'ip:192.168.1.101'; author = 'ADI'; sray end @@ -10,8 +10,7 @@ function SetupStingray(testCase) % Setup Stingray testCase.sray = adi.Stingray; testCase.sray.uri = testCase.uri; -% values(:) = {'Disabled'}; -% testCase.sray.Mode = values; + testCase.sray.EnableReadCheckOnWrite = false; testCase.sray(); end end @@ -22,13 +21,13 @@ function ResetStingray(testCase) end end - % Device Attribute Tests + % ADAR1000 Device Attribute Tests methods (Test) function testMode(testCase) - values = cell(1, size(testCase.sray.ArrayMap, 1)); + values = cell(size(testCase.sray.SubarrayToChipMap)); values(:) = {'Rx'}; - values(randi([1 size(testCase.sray.ArrayMap, 1)], 1, 3)) = {'Tx'}; - values(randi([1 size(testCase.sray.ArrayMap, 1)], 1, 3)) = {'Disabled'}; + values(randi([1 numel(testCase.sray.SubarrayToChipMap)], 1, 3)) = {'Tx'}; + values(randi([1 numel(testCase.sray.SubarrayToChipMap)], 1, 3)) = {'Disabled'}; testCase.sray.Mode = values; rvalues = testCase.sray.Mode; testCase.verifyEqual(rvalues,values); @@ -36,109 +35,83 @@ function testMode(testCase) testCase.sray.Mode = values; end - function testStateTxOrRx(testCase) - values = cell(1, size(testCase.sray.ArrayMap, 1)); - values(:) = {'Rx'}; - values(randi([1 size(testCase.sray.ArrayMap, 1)], 1, 3)) = {'Tx'}; - testCase.sray.StateTxOrRx = values; - rvalues = testCase.sray.StateTxOrRx; - testCase.verifyEqual(rvalues,values); - values(:) = {'Rx'}; - testCase.sray.StateTxOrRx = values; - end - - function testRxEnable(testCase) - values = logical(randi([0 1], 1, size(testCase.sray.ArrayMap, 1))); - testCase.sray.RxEnable = values; - rvalues = testCase.sray.RxEnable; - testCase.verifyEqual(rvalues,values); - testCase.sray.RxEnable = logical(false(1, size(testCase.sray.ArrayMap, 1))); - end - - function testTxEnable(testCase) - values = logical(randi([0 1], 1, size(testCase.sray.ArrayMap, 1))); - testCase.sray.TxEnable = values; - rvalues = testCase.sray.TxEnable; - testCase.verifyEqual(rvalues,values); - testCase.sray.TxEnable = logical(false(1, size(testCase.sray.ArrayMap, 1))); - end - function testLNABiasOutEnable(testCase) - values = logical(randi([0 1], 1, size(testCase.sray.ArrayMap, 1))); + values = logical(randi([0 1], size(testCase.sray.SubarrayToChipMap))); testCase.sray.LNABiasOutEnable = values; rvalues = testCase.sray.LNABiasOutEnable; testCase.verifyEqual(rvalues,values); end function testLNABiasOn(testCase) - values = randi([60 100], 1, size(testCase.sray.ArrayMap, 1))*... + values = randi([60 100], size(testCase.sray.SubarrayToChipMap))*... testCase.sray.BIAS_CODE_TO_VOLTAGE_SCALE; testCase.sray.LNABiasOn = values; rvalues = testCase.sray.LNABiasOn; testCase.verifyEqual(rvalues,values); - testCase.sray.LNABiasOn = 100*ones(1, size(testCase.sray.ArrayMap, 1))*... + testCase.sray.LNABiasOn = 100*ones(size(testCase.sray.SubarrayToChipMap))*... testCase.sray.BIAS_CODE_TO_VOLTAGE_SCALE; end function testBeamMemEnable(testCase) - values = logical(randi([0 1], 1, size(testCase.sray.ArrayMap, 1))); + values = logical(randi([0 1], size(testCase.sray.SubarrayToChipMap))); testCase.sray.BeamMemEnable = values; rvalues = testCase.sray.BeamMemEnable; testCase.verifyEqual(rvalues,values); end - %{ + function testBiasDACEnable(testCase) - values = logical(randi([0 1], 1, size(testCase.sray.ArrayMap, 1))); + values = logical(randi([0 1], size(testCase.sray.SubarrayToChipMap))); testCase.sray.BiasDACEnable = values; rvalues = testCase.sray.BiasDACEnable; testCase.verifyEqual(rvalues,values); end - %} + function testBiasDACMode(testCase) - values = cell(1, size(testCase.sray.ArrayMap, 1)); + values = cell(size(testCase.sray.SubarrayToChipMap)); values(:) = {'Toggle'}; - values(randi([1 size(testCase.sray.ArrayMap, 1)], 1, 3)) = {'On'}; + values(randi([1 numel(testCase.sray.SubarrayToChipMap)], 1, 3)) = {'On'}; testCase.sray.BiasDACMode = values; rvalues = testCase.sray.BiasDACMode; testCase.verifyEqual(rvalues,values); end - %{ + function testBiasMemEnable(testCase) - values = logical(randi([0 1], 1, size(testCase.sray.ArrayMap, 1))); + values = logical(randi([0 1], size(testCase.sray.SubarrayToChipMap))); testCase.sray.BiasMemEnable = values; + pause(2); rvalues = testCase.sray.BiasMemEnable; testCase.verifyEqual(rvalues,values); end - %} + function testCommonMemEnable(testCase) - values = logical(randi([0 1], 1, size(testCase.sray.ArrayMap, 1))); + values = logical(randi([0 1], size(testCase.sray.SubarrayToChipMap))); testCase.sray.CommonMemEnable = values; rvalues = testCase.sray.CommonMemEnable; testCase.verifyEqual(rvalues,values); end function testCommonRxBeamState(testCase) - values = randi([0 120])*ones(1, size(testCase.sray.ArrayMap, 1)); + values = randi([0 120])*ones(size(testCase.sray.SubarrayToChipMap)); testCase.sray.CommonRxBeamState = values; rvalues = testCase.sray.CommonRxBeamState; - testCase.verifyEqual(rvalues,values); + testCase.verifyEqual(rvalues,int32(values)); end function testCommonTxBeamState(testCase) - values = randi([0 120])*ones(1, size(testCase.sray.ArrayMap, 1)); + values = randi([0 120])*ones(size(testCase.sray.SubarrayToChipMap)); testCase.sray.CommonTxBeamState = values; rvalues = testCase.sray.CommonTxBeamState; - testCase.verifyEqual(rvalues,values); + testCase.verifyEqual(rvalues,int32(values)); end function testExternalTRPin(testCase) - values = cell(1, size(testCase.sray.ArrayMap, 1)); + values = cell(size(testCase.sray.SubarrayToChipMap)); values(:) = {'Pos'}; testCase.sray.ExternalTRPin = values; rvalues = testCase.sray.ExternalTRPin; testCase.verifyEqual(rvalues,values); - values = cell(1, size(testCase.sray.ArrayMap, 1)); + values = cell(size(testCase.sray.SubarrayToChipMap)); values(:) = {'Neg'}; testCase.sray.ExternalTRPin = values; rvalues = testCase.sray.ExternalTRPin; @@ -146,207 +119,207 @@ function testExternalTRPin(testCase) end function testExternalTRPolarity(testCase) - values = true(1, size(testCase.sray.ArrayMap, 1)); + values = true(size(testCase.sray.SubarrayToChipMap)); testCase.sray.ExternalTRPolarity = values; rvalues = testCase.sray.ExternalTRPolarity; testCase.verifyEqual(rvalues,values); - values = false(1, size(testCase.sray.ArrayMap, 1)); + values = false(size(testCase.sray.SubarrayToChipMap)); testCase.sray.ExternalTRPolarity = values; rvalues = testCase.sray.ExternalTRPolarity; testCase.verifyEqual(rvalues,values); end function testLNABiasOff(testCase) - values = randi([60 100], 1, size(testCase.sray.ArrayMap, 1))*... + values = randi([60 100], size(testCase.sray.SubarrayToChipMap))*... testCase.sray.BIAS_CODE_TO_VOLTAGE_SCALE; testCase.sray.LNABiasOff = values; rvalues = testCase.sray.LNABiasOff; testCase.verifyEqual(rvalues,values); - testCase.sray.LNABiasOn = 100*ones(size(testCase.sray.ArrayMap, 1))*... + testCase.sray.LNABiasOn = 100*ones(size(testCase.sray.SubarrayToChipMap))*... testCase.sray.BIAS_CODE_TO_VOLTAGE_SCALE; end function testPolState(testCase) - values = true(1, size(testCase.sray.ArrayMap, 1)); + values = true(size(testCase.sray.SubarrayToChipMap)); testCase.sray.PolState = values; rvalues = testCase.sray.PolState; testCase.verifyEqual(rvalues,values); - values = false(1, size(testCase.sray.ArrayMap, 1)); + values = false(size(testCase.sray.SubarrayToChipMap)); testCase.sray.PolState = values; rvalues = testCase.sray.PolState; testCase.verifyEqual(rvalues,values); end function testPolSwitchEnable(testCase) - values = true(1, size(testCase.sray.ArrayMap, 1)); + values = true(size(testCase.sray.SubarrayToChipMap)); testCase.sray.PolSwitchEnable = values; rvalues = testCase.sray.PolSwitchEnable; testCase.verifyEqual(rvalues,values); - values = false(1, size(testCase.sray.ArrayMap, 1)); + values = false(size(testCase.sray.SubarrayToChipMap)); testCase.sray.PolSwitchEnable = values; rvalues = testCase.sray.PolSwitchEnable; testCase.verifyEqual(rvalues,values); end function testRxLNABiasCurrent(testCase) - values = randi([5 8], 1, size(testCase.sray.ArrayMap, 1)); + values = randi([5 8], size(testCase.sray.SubarrayToChipMap)); testCase.sray.RxLNABiasCurrent = values; rvalues = testCase.sray.RxLNABiasCurrent; - testCase.verifyEqual(rvalues,values); - testCase.sray.RxLNABiasCurrent = 5*ones(size(testCase.sray.ArrayMap, 1)); + testCase.verifyEqual(rvalues,int32(values)); + testCase.sray.RxLNABiasCurrent = 5*ones(size(testCase.sray.SubarrayToChipMap)); end function testRxLNAEnable(testCase) - values = logical(randi([0 1], 1, size(testCase.sray.ArrayMap, 1))); + values = logical(randi([0 1], size(testCase.sray.SubarrayToChipMap))); testCase.sray.RxLNAEnable = values; rvalues = testCase.sray.RxLNAEnable; testCase.verifyEqual(rvalues,values); end function testRxToTxDelay1(testCase) - values = randi([0 15], 1, size(testCase.sray.ArrayMap, 1)); + values = randi([0 15], size(testCase.sray.SubarrayToChipMap)); testCase.sray.RxToTxDelay1 = values; rvalues = testCase.sray.RxToTxDelay1; - testCase.verifyEqual(rvalues,values); + testCase.verifyEqual(rvalues,int32(values)); end function testRxToTxDelay2(testCase) - values = randi([0 15], 1, size(testCase.sray.ArrayMap, 1)); + values = randi([0 15], size(testCase.sray.SubarrayToChipMap)); testCase.sray.RxToTxDelay2 = values; rvalues = testCase.sray.RxToTxDelay2; - testCase.verifyEqual(rvalues,values); + testCase.verifyEqual(rvalues,int32(values)); end function testRxVGAEnable(testCase) - values = logical(randi([0 1], 1, size(testCase.sray.ArrayMap, 1))); + values = logical(randi([0 1], size(testCase.sray.SubarrayToChipMap))); testCase.sray.RxVGAEnable = values; rvalues = testCase.sray.RxVGAEnable; testCase.verifyEqual(rvalues,values); end function testRxVGABiasCurrentVM(testCase) - values = randi([2 5], 1, size(testCase.sray.ArrayMap, 1)); + values = randi([2 5], size(testCase.sray.SubarrayToChipMap)); testCase.sray.RxVGABiasCurrentVM = values; rvalues = testCase.sray.RxVGABiasCurrentVM; - testCase.verifyEqual(rvalues,values); - testCase.sray.RxVGABiasCurrentVM = 2*ones(size(testCase.sray.ArrayMap, 1)); + testCase.verifyEqual(rvalues,int32(values)); + testCase.sray.RxVGABiasCurrentVM = 2*ones(size(testCase.sray.SubarrayToChipMap)); end function testRxVMEnable(testCase) - values = logical(randi([0 1], 1, size(testCase.sray.ArrayMap, 1))); + values = logical(randi([0 1], size(testCase.sray.SubarrayToChipMap))); testCase.sray.RxVMEnable = values; rvalues = testCase.sray.RxVMEnable; testCase.verifyEqual(rvalues,values); end function testSequencerEnable(testCase) - values = logical(randi([0 1], 1, size(testCase.sray.ArrayMap, 1))); + values = logical(randi([0 1], size(testCase.sray.SubarrayToChipMap))); testCase.sray.SequencerEnable = values; rvalues = testCase.sray.SequencerEnable; testCase.verifyEqual(rvalues,values); end function testTRSwitchEnable(testCase) - values = logical(randi([0 1], 1, size(testCase.sray.ArrayMap, 1))); + values = logical(randi([0 1], size(testCase.sray.SubarrayToChipMap))); testCase.sray.TRSwitchEnable = values; rvalues = testCase.sray.TRSwitchEnable; testCase.verifyEqual(rvalues,values); end function testTxPABiasCurrent(testCase) - values = randi([3 6], 1, size(testCase.sray.ArrayMap, 1)); + values = randi([3 6], size(testCase.sray.SubarrayToChipMap)); testCase.sray.TxPABiasCurrent = values; rvalues = testCase.sray.TxPABiasCurrent; - testCase.verifyEqual(rvalues,values); - testCase.sray.TxPABiasCurrent = 3*ones(size(testCase.sray.ArrayMap, 1)); + testCase.verifyEqual(rvalues,int32(values)); + testCase.sray.TxPABiasCurrent = 3*ones(size(testCase.sray.SubarrayToChipMap)); end function testTxPAEnable(testCase) - values = logical(randi([0 1], 1, size(testCase.sray.ArrayMap, 1))); + values = logical(randi([0 1], size(testCase.sray.SubarrayToChipMap))); testCase.sray.TxPAEnable = values; rvalues = testCase.sray.TxPAEnable; testCase.verifyEqual(rvalues,values); end function testTxToRxDelay1(testCase) - values = randi([0 15], 1, size(testCase.sray.ArrayMap, 1)); + values = randi([0 15], size(testCase.sray.SubarrayToChipMap)); testCase.sray.TxToRxDelay1 = values; rvalues = testCase.sray.TxToRxDelay1; - testCase.verifyEqual(rvalues,values); + testCase.verifyEqual(rvalues,int32(values)); end function testTxToRxDelay2(testCase) - values = randi([0 15], 1, size(testCase.sray.ArrayMap, 1)); + values = randi([0 15], size(testCase.sray.SubarrayToChipMap)); testCase.sray.TxToRxDelay2 = values; rvalues = testCase.sray.TxToRxDelay2; - testCase.verifyEqual(rvalues,values); + testCase.verifyEqual(rvalues,int32(values)); end function testTxVGAEnable(testCase) - values = logical(randi([0 1], 1, size(testCase.sray.ArrayMap, 1))); + values = logical(randi([0 1], size(testCase.sray.SubarrayToChipMap))); testCase.sray.TxVGAEnable = values; rvalues = testCase.sray.TxVGAEnable; testCase.verifyEqual(rvalues,values); end function testTxVGABiasCurrentVM(testCase) - values = randi([2 5], 1, size(testCase.sray.ArrayMap, 1)); + values = randi([2 5], size(testCase.sray.SubarrayToChipMap)); testCase.sray.TxVGABiasCurrentVM = values; rvalues = testCase.sray.TxVGABiasCurrentVM; - testCase.verifyEqual(rvalues,values); - testCase.sray.TxVGABiasCurrentVM = 2*ones(size(testCase.sray.ArrayMap, 1)); + testCase.verifyEqual(rvalues,int32(values)); + testCase.sray.TxVGABiasCurrentVM = 2*ones(size(testCase.sray.SubarrayToChipMap)); end function testTxVMEnable(testCase) - values = logical(randi([0 1], 1, size(testCase.sray.ArrayMap, 1))); + values = logical(randi([0 1], size(testCase.sray.SubarrayToChipMap))); testCase.sray.TxVMEnable = values; rvalues = testCase.sray.TxVMEnable; testCase.verifyEqual(rvalues,values); end end - % Channel Attribute Tests + % ADAR1000 Channel Attribute Tests methods (Test) - %{ + function testDetectorEnable(testCase) - values = logical(randi([0 1], size(testCase.sray.ArrayMap))); + values = logical(randi([0 1], size(testCase.sray.ElementToChipChannelMap))); testCase.sray.DetectorEnable = values; rvalues = testCase.sray.DetectorEnable; testCase.verifyEqual(rvalues,values); end - %} + function testPABiasOff(testCase) - values = randi([60 100], size(testCase.sray.ArrayMap))*... + values = randi([60 100], size(testCase.sray.ElementToChipChannelMap))*... testCase.sray.BIAS_CODE_TO_VOLTAGE_SCALE; testCase.sray.PABiasOff = values; rvalues = testCase.sray.PABiasOff; testCase.verifyEqual(rvalues,values); - testCase.sray.PABiasOff = 100*ones(size(testCase.sray.ArrayMap))*... + testCase.sray.PABiasOff = 100*ones(size(testCase.sray.ElementToChipChannelMap))*... testCase.sray.BIAS_CODE_TO_VOLTAGE_SCALE; end function testPABiasOn(testCase) - values = randi([60 100], size(testCase.sray.ArrayMap))*... + values = randi([60 100], size(testCase.sray.ElementToChipChannelMap))*... testCase.sray.BIAS_CODE_TO_VOLTAGE_SCALE; testCase.sray.PABiasOn = values; rvalues = testCase.sray.PABiasOn; testCase.verifyEqual(rvalues,values); - testCase.sray.PABiasOn = 100*ones(size(testCase.sray.ArrayMap))*... + testCase.sray.PABiasOn = 100*ones(size(testCase.sray.ElementToChipChannelMap))*... testCase.sray.BIAS_CODE_TO_VOLTAGE_SCALE; end function testRxAttn(testCase) - values = logical(randi([0 1], size(testCase.sray.ArrayMap))); + values = logical(randi([0 1], size(testCase.sray.ElementToChipChannelMap))); testCase.sray.RxAttn = values; rvalues = testCase.sray.RxAttn; testCase.verifyEqual(rvalues,values); end function testRxBeamState(testCase) - tmp_size = size(testCase.sray.ArrayMap); + tmp_size = size(testCase.sray.ElementToChipChannelMap); values = repmat(randi([0 120], 1, tmp_size(1)), tmp_size(2), 1).'; testCase.sray.RxBeamState = values; rvalues = testCase.sray.RxBeamState; @@ -354,37 +327,37 @@ function testRxBeamState(testCase) end function testRxPowerDown(testCase) - tmp_size = size(testCase.sray.ArrayMap); + tmp_size = size(testCase.sray.ElementToChipChannelMap); values = repmat(logical(randi([0 1], 1, tmp_size(1))), tmp_size(2), 1).'; testCase.sray.RxPowerDown = values; rvalues = testCase.sray.RxPowerDown; testCase.verifyEqual(rvalues,values); - testCase.sray.RxPowerDown = false(size(testCase.sray.ArrayMap)); + testCase.sray.RxPowerDown = true(size(testCase.sray.ElementToChipChannelMap)); end - %{ + function testRxGain(testCase) - values = randi([0 127], size(testCase.sray.ArrayMap)); + values = randi([0 127], size(testCase.sray.ElementToChipChannelMap)); testCase.sray.RxGain = values; rvalues = testCase.sray.RxGain; testCase.verifyEqual(rvalues,values); end - %} + function testRxPhase(testCase) - values = randi([0 127], size(testCase.sray.ArrayMap)); + values = randi([0 127], size(testCase.sray.ElementToChipChannelMap)); testCase.sray.RxPhase = values; rvalues = testCase.sray.RxPhase; testCase.verifyEqual(rvalues,values, "AbsTol", 4); end function testTxAttn(testCase) - values = logical(randi([0 1], size(testCase.sray.ArrayMap))); + values = logical(randi([0 1], size(testCase.sray.ElementToChipChannelMap))); testCase.sray.TxAttn = values; rvalues = testCase.sray.TxAttn; testCase.verifyEqual(rvalues,values); end function testTxBeamState(testCase) - tmp_size = size(testCase.sray.ArrayMap); + tmp_size = size(testCase.sray.ElementToChipChannelMap); values = repmat(randi([0 120], 1, tmp_size(1)), tmp_size(2), 1).'; testCase.sray.TxBeamState = values; rvalues = testCase.sray.TxBeamState; @@ -392,30 +365,30 @@ function testTxBeamState(testCase) end function testTxPowerDown(testCase) - tmp_size = size(testCase.sray.ArrayMap); + tmp_size = size(testCase.sray.ElementToChipChannelMap); values = repmat(logical(randi([0 1], 1, tmp_size(1))), tmp_size(2), 1).'; testCase.sray.TxPowerDown = values; rvalues = testCase.sray.TxPowerDown; testCase.verifyEqual(rvalues,values); - testCase.sray.TxPowerDown = false(size(testCase.sray.ArrayMap)); + testCase.sray.TxPowerDown = true(size(testCase.sray.ElementToChipChannelMap)); end - %{ + function testTxGain(testCase) - values = randi([0 127], size(testCase.sray.ArrayMap)); + values = randi([0 127], size(testCase.sray.ElementToChipChannelMap)); testCase.sray.TxGain = values; rvalues = testCase.sray.TxGain; testCase.verifyEqual(rvalues,values); end - %} + function testTxPhase(testCase) - values = randi([0 127], size(testCase.sray.ArrayMap)); + values = randi([0 127], size(testCase.sray.ElementToChipChannelMap)); testCase.sray.TxPhase = values; rvalues = testCase.sray.TxPhase; testCase.verifyEqual(rvalues,values, "AbsTol", 4); end %{ function testRxBiasState(testCase) - tmp_size = size(testCase.sray.ArrayMap); + tmp_size = size(testCase.sray.ElementToChipChannelMap); values = repmat(logical(randi([0 1], 1, tmp_size(2))), tmp_size(1), 1); testCase.sray.RxBiasState = values; rvalues = testCase.sray.RxBiasState; @@ -423,25 +396,25 @@ function testRxBiasState(testCase) end %} function testRxSequencerStart(testCase) - tmp_size = size(testCase.sray.ArrayMap); + tmp_size = size(testCase.sray.ElementToChipChannelMap); values = repmat(logical(randi([0 1], 1, tmp_size(1))), tmp_size(2), 1).'; testCase.sray.RxSequencerStart = values; rvalues = testCase.sray.RxSequencerStart; testCase.verifyEqual(rvalues,values); - testCase.sray.RxSequencerStart = false(size(testCase.sray.ArrayMap)); + testCase.sray.RxSequencerStart = false(size(testCase.sray.ElementToChipChannelMap)); end function testRxSequencerStop(testCase) - tmp_size = size(testCase.sray.ArrayMap); + tmp_size = size(testCase.sray.ElementToChipChannelMap); values = repmat(logical(randi([0 1], 1, tmp_size(1))), tmp_size(2), 1).'; testCase.sray.RxSequencerStop = values; rvalues = testCase.sray.RxSequencerStop; testCase.verifyEqual(rvalues,values); - testCase.sray.RxSequencerStop = false(size(testCase.sray.ArrayMap)); + testCase.sray.RxSequencerStop = false(size(testCase.sray.ElementToChipChannelMap)); end %{ function testTxBiasState(testCase) - tmp_size = size(testCase.sray.ArrayMap); + tmp_size = size(testCase.sray.SubarrayToChipMap); values = repmat(logical(randi([0 1], 1, tmp_size(2))), tmp_size(1), 1); testCase.sray.TxBiasState = values; rvalues = testCase.sray.TxBiasState; @@ -449,21 +422,100 @@ function testTxBiasState(testCase) end %} function testTxSequencerStart(testCase) - tmp_size = size(testCase.sray.ArrayMap); + tmp_size = size(testCase.sray.ElementToChipChannelMap); values = repmat(logical(randi([0 1], 1, tmp_size(1))), tmp_size(2), 1).'; testCase.sray.TxSequencerStart = values; rvalues = testCase.sray.TxSequencerStart; testCase.verifyEqual(rvalues,values); - testCase.sray.TxSequencerStart = false(size(testCase.sray.ArrayMap)); + testCase.sray.TxSequencerStart = false(size(testCase.sray.ElementToChipChannelMap)); end function testTxSequencerStop(testCase) - tmp_size = size(testCase.sray.ArrayMap); + tmp_size = size(testCase.sray.ElementToChipChannelMap); values = repmat(logical(randi([0 1], 1, tmp_size(1))), tmp_size(2), 1).'; testCase.sray.TxSequencerStop = values; rvalues = testCase.sray.TxSequencerStop; testCase.verifyEqual(rvalues,values); - testCase.sray.TxSequencerStop = false(size(testCase.sray.ArrayMap)); + testCase.sray.TxSequencerStop = false(size(testCase.sray.ElementToChipChannelMap)); + end + end + + % XUD1a tests + methods (Test) + function testSelectChannelSetMode(testCase) + SelectChannelSetMode = [... + "A_Tx", "A_RxLG", "A_RxHG", ... + "B_Tx", "B_RxLG", "B_RxHG", ... + "C_Tx", "C_RxLG", "C_RxHG", ... + "D_Tx", "D_RxLG", "D_RxHG"]; + index = randi(numel(SelectChannelSetMode)); + testCase.sray.SelectChannelSetMode = SelectChannelSetMode(index); + + % check Tx/Rx selected + % check Rx set to Low Gain/High Gain + switch index + case {1, 2, 3} + TxRxValue = testCase.sray.TXRX0; + case {4, 5, 6} + TxRxValue = testCase.sray.TXRX1; + case {7, 8, 9} + TxRxValue = testCase.sray.TXRX2; + case {10, 11, 12} + TxRxValue = testCase.sray.TXRX3; + end + RxGainModeValue = testCase.sray.RxGainMode; + + if any([1, 4, 7, 10] == index) + testCase.verifyEqual(TxRxValue, 0); + testCase.verifyEqual(RxGainModeValue, 0); + else + testCase.verifyEqual(TxRxValue, 1); + if contains(SelectChannelSetMode(index), 'LG') + testCase.verifyEqual(RxGainModeValue, 0); + else + testCase.verifyEqual(RxGainModeValue, 1); + end + end + end + + function testPllOutputSel(testCase) + value = randi(2)-1; + testCase.sray.PllOutputSel = value; + rvalue = testCase.sray.PllOutputSel; + testCase.verifyEqual(rvalue,value); + testCase.sray.PllOutputSel = 1; + end + end + + % ADF4371 tests + methods (Test) + function testADF4371Name(testCase) + ADF4371Name = ["RF16x", "RF32x"]; + index = randi(numel(ADF4371Name)); + value = ADF4371Name(index); + testCase.sray.ADF4371Name = value; + rvalue = testCase.sray.ADF4371Name; + testCase.verifyEqual(rvalue,value); + testCase.sray.ADF4371Name = "RF16x"; + end + + function testADF4371Frequency(testCase) + freq_a = 8000; + freq_b = 16000; + freq = (freq_b-freq_a).*rand(1,1) + freq_a; + ADF4371Frequency = freq*1e6; + testCase.sray.ADF4371Frequency = ADF4371Frequency; + rvalue = testCase.sray.ADF4371Frequency; + testCase.verifyEqual(rvalue,ADF4371Frequency); + testCase.sray.ADF4371Frequency = uint64(15000000000); + end + + function testADF4371Phase(testCase) + value = randi(359999); + testCase.sray.ADF4371Phase = value; + rvalue = testCase.sray.ADF4371Phase; + testCase.verifyEqual(rvalue,value); + testCase.sray.ADF4371Phase = 359999; end end end \ No newline at end of file