Skip to content

Commit

Permalink
Handle LO attribute naming differences
Browse files Browse the repository at this point in the history
Signed-off-by: Travis F. Collins <[email protected]>
  • Loading branch information
tfcollins committed Oct 18, 2023
1 parent 28ac901 commit b2e3a90
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 10 deletions.
39 changes: 34 additions & 5 deletions +adi/+ADRV9002/Base.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
dataTypeStr = 'int16';
phyDevName = 'adrv9002-phy';
iioDevPHY
newAPI = false;
end

properties (Hidden, Constant)
Expand Down Expand Up @@ -95,10 +96,18 @@
obj.CenterFrequencyChannel0 = value;
if strcmpi(obj.Type,'Tx')
id = 'altvoltage2';
prop = 'frequency';
if obj.newAPI
prop = 'frequency';
else
prop = 'TX1_LO_frequency';
end
else
id = 'altvoltage0';
prop = 'frequency';
if obj.newAPI
prop = 'frequency';
else
prop = 'RX1_LO_frequency';
end
end
if obj.ConnectedToDevice
obj.setAttributeLongLong(id,prop,value,true);
Expand All @@ -109,10 +118,18 @@
obj.CenterFrequencyChannel1 = value;
if strcmpi(obj.Type,'Tx')
id = 'altvoltage3';
prop = 'frequency';
if obj.newAPI
prop = 'frequency';
else
prop = 'TX2_LO_frequency';
end
else
id = 'altvoltage1';
prop = 'frequency';
if obj.newAPI
prop = 'frequency';
else
prop = 'RX2_LO_frequency';
end
end
if obj.ConnectedToDevice
obj.setAttributeLongLong(id,prop,value,true);
Expand Down Expand Up @@ -169,7 +186,19 @@

%% 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);
if status ~= 0
error("Cannot find channel altvoltage0")
end
status = iio_channel_attr_read(obj,chanPtr,'frequency',1024);
obj.newAPI = status == 0;
end

function lowerDDSs(obj,singleDDS)
% Since calibrations are sensitive, DDSs need to be powered
% down anytime a profile is loaded
Expand Down
14 changes: 12 additions & 2 deletions +adi/+ADRV9002/Rx.m
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,9 @@ function setupInit(obj)
channelsAval = 2;
end

% Check if property naming updated for LOs frequency vs
% XLOX_frequency
obj.checkDriverAPI();

obj.setAttributeRAW('voltage0','ensm_mode',obj.ENSMModeChannel0,false);
if channelsAval == 2
Expand Down Expand Up @@ -584,9 +587,16 @@ function setupInit(obj)
obj.setAttributeDouble('voltage1','hardwaregain',obj.AttenuationChannel1,false);
end

obj.setAttributeLongLong('altvoltage0','frequency',obj.CenterFrequencyChannel0 ,true);
if obj.newAPI
name1 = 'frequency';
name2 = 'frequency';
else
name1 = 'RX1_LO_frequency';
name2 = 'RX2_LO_frequency';
end
obj.setAttributeLongLong('altvoltage0',name1,obj.CenterFrequencyChannel0 ,true);
if channelsAval == 2
obj.setAttributeLongLong('altvoltage1','frequency',obj.CenterFrequencyChannel1 ,true);
obj.setAttributeLongLong('altvoltage1',name2,obj.CenterFrequencyChannel1 ,true);
end

% Calibrations
Expand Down
17 changes: 14 additions & 3 deletions +adi/+ADRV9002/Tx.m
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,20 @@ function setupInit(obj)
if obj.EnableCustomProfile
writeProfileFile(obj);
end

obj.setAttributeLongLong('altvoltage2','frequency',obj.CenterFrequencyChannel0 ,true);
obj.setAttributeLongLong('altvoltage3','frequency',obj.CenterFrequencyChannel1 ,true);

% Check if property naming updated for LOs frequency vs
% XLOX_frequency
obj.checkDriverAPI();

if obj.newAPI
name1 = 'frequency';
name2 = 'frequency';
else
name1 = 'TX1_LO_frequency';
name2 = 'TX2_LO_frequency';
end
obj.setAttributeLongLong('altvoltage2',name1,obj.CenterFrequencyChannel0 ,true);
obj.setAttributeLongLong('altvoltage3',name2,obj.CenterFrequencyChannel1 ,true);

obj.setAttributeRAW('voltage0','ensm_mode',obj.ENSMModeChannel0,true);
obj.setAttributeRAW('voltage1','ensm_mode',obj.ENSMModeChannel1,true);
Expand Down

0 comments on commit b2e3a90

Please sign in to comment.