Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit f0fc2c4

Browse files
authored
Merge pull request #40 from analogdevicesinc/dev
Pre-release updates
2 parents cedc27a + 37182b3 commit f0fc2c4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+2405
-160
lines changed

+adi/+AD9361/Base.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
classdef (Abstract, Hidden = true) Base < adi.common.Attribute & matlabshared.libiio.base & ...
2-
matlab.system.mixin.CustomIcon
1+
classdef (Abstract, Hidden = true) Base < adi.common.Attribute & ...
2+
adi.common.DebugAttribute & ...
3+
matlabshared.libiio.base & matlab.system.mixin.CustomIcon
4+
35
%adi.AD9361.Base Class
46
% This class contains shared parameters and methods between TX and RX
57
% classes

+adi/+AD9361/Rx.m

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
classdef Rx < adi.AD9361.Base & adi.common.Rx & matlab.system.mixin.SampleTime
1+
classdef Rx < adi.AD9361.Base & adi.AD9361.TuneAGC & ...
2+
adi.common.Rx & matlab.system.mixin.SampleTime
23
% adi.AD9361.Rx Receive data from the AD9361 transceiver
34
% The adi.AD9361.Rx System object is a signal source that can receive
45
% complex data from the AD9361.
@@ -215,7 +216,7 @@
215216
obj.setAttributeLongLong(id,'sampling_frequency',value,true,4);
216217
end
217218
end
218-
end
219+
end
219220
end
220221

221222
methods (Access=protected)
@@ -324,6 +325,14 @@ function setupInit(obj)
324325
writeFilterFile(obj);
325326
end
326327

328+
if (obj.CustomAGC)
329+
% Initialize hardware to reflect debug attribute changes
330+
obj.WriteDebugAttributes();
331+
obj.setDebugAttributeLongLong();
332+
obj.setDebugAttributeBool();
333+
obj.WriteToRegisters();
334+
end
335+
327336
end
328337

329338
end

+adi/+AD9361/TuneAGC.m

Lines changed: 288 additions & 0 deletions
Large diffs are not rendered by default.

+adi/+AD9371/Base.m

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@
1515
channelCount = 2;
1616
end
1717

18+
properties (Nontunable, Logical)
19+
%EnableCustomProfile Enable Custom Profile
20+
% Enable use of custom Profile file to set SamplingRate,
21+
% RFBandwidth, and FIR in datapaths
22+
EnableCustomProfile = false;
23+
end
24+
25+
properties (Nontunable)
26+
%CustomProfileFileName Custom Profile File Name
27+
% Path to custom Profile file created from profile wizard
28+
CustomProfileFileName = '';
29+
end
30+
1831
properties (Hidden, Constant)
1932
%SamplingRate Sampling Rate
2033
% Baseband sampling rate in Hz, specified as a scalar
@@ -72,6 +85,23 @@ function delete(~)
7285
obj.setAttributeLongLong(id,'frequency',value,true);
7386
end
7487
end
88+
% Check EnableCustomProfile
89+
function set.EnableCustomProfile(obj, value)
90+
validateattributes( value, { 'logical' }, ...
91+
{ }, ...
92+
'', 'EnableCustomProfile');
93+
obj.EnableCustomProfile = value;
94+
end
95+
% Check CustomFilterFileName
96+
function set.CustomProfileFileName(obj, value)
97+
validateattributes( value, { 'char' }, ...
98+
{ }, ...
99+
'', 'CustomProfileFileName');
100+
obj.CustomProfileFileName = value;
101+
if obj.EnableCustomProfile && obj.ConnectedToDevice %#ok<MCSUP>
102+
writeProfileFile(obj);
103+
end
104+
end
75105
end
76106

77107
%% API Functions
@@ -80,6 +110,12 @@ function delete(~)
80110
function icon = getIconImpl(obj)
81111
icon = sprintf(['AD9371 ',obj.Type]);
82112
end
113+
114+
115+
function writeProfileFile(obj)
116+
profle_data_str = fileread(obj.CustomProfileFileName);
117+
obj.setDeviceAttributeRAW('profile_config',profle_data_str);
118+
end
83119

84120
end
85121

+adi/+AD9371/Rx.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ function setupInit(obj)
196196
id = sprintf('altvoltage%d',strcmp(obj.Type,'Tx'));
197197
obj.setAttributeLongLong(id,'RX_LO_frequency',obj.CenterFrequency ,true);
198198

199+
if obj.EnableCustomProfile
200+
writeProfileFile(obj);
201+
end
202+
199203
if strcmp(obj.GainControlMode,'manual')
200204
obj.setAttributeLongLong('voltage0','hardwaregain',obj.GainChannel0,false);
201205
obj.setAttributeLongLong('voltage1','hardwaregain',obj.GainChannel1,false);

+adi/+common/Attribute.m

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
classdef (Abstract) Attribute < matlabshared.libiio.base
22
% Attribute IIO attribute function calls
33

4-
methods (Hidden, Access = protected)
4+
methods (Hidden)
55

66
function setAttributeLongLong(obj,id,attr,value,isOutput,tol)
77
phydev = getDev(obj, obj.phyDevName);
@@ -22,6 +22,15 @@ function setAttributeLongLong(obj,id,attr,value,isOutput,tol)
2222
end
2323
end
2424

25+
function rValue = getAttributeLongLong(obj,id,attr,isOutput)
26+
phydev = getDev(obj, obj.phyDevName);
27+
chanPtr = iio_device_find_channel(obj,phydev,id,isOutput);%FIXME (INVERSION)
28+
status = cPtrCheck(obj,chanPtr);
29+
cstatus(obj,status,['Channel: ' id ' not found']);
30+
[status, rValue] = iio_channel_attr_read_longlong(obj,chanPtr,attr);
31+
cstatus(obj,status,['Error reading attribute: ' attr]);
32+
end
33+
2534
function setAttributeBool(obj,id,attr,value,isOutput)
2635
phydev = getDev(obj, obj.phyDevName);
2736
chanPtr = iio_device_find_channel(obj,phydev,id,isOutput);%FIXME (INVERSION)
@@ -38,6 +47,15 @@ function setAttributeBool(obj,id,attr,value,isOutput)
3847
end
3948
end
4049

50+
function rValue = getAttributeBool(obj,id,attr,isOutput)
51+
phydev = getDev(obj, obj.phyDevName);
52+
chanPtr = iio_device_find_channel(obj,phydev,id,isOutput);%FIXME (INVERSION)
53+
status = cPtrCheck(obj,chanPtr);
54+
cstatus(obj,status,['Channel: ' id ' not found']);
55+
[status, rValue] = iio_channel_attr_read_bool(obj,chanPtr,attr);
56+
cstatus(obj,status,['Error reading attribute: ' attr]);
57+
end
58+
4159
function setAttributeRAW(obj,id,attr,value,isOutput)
4260
phydev = getDev(obj, obj.phyDevName);
4361
chanPtr = iio_device_find_channel(obj,phydev,id,isOutput);%FIXME (INVERSION)
@@ -50,6 +68,15 @@ function setAttributeRAW(obj,id,attr,value,isOutput)
5068
end
5169
end
5270

71+
function rValue = getAttributeRAW(obj,id,attr,isOutput)
72+
phydev = getDev(obj, obj.phyDevName);
73+
chanPtr = iio_device_find_channel(obj,phydev,id,isOutput);%FIXME (INVERSION)
74+
status = cPtrCheck(obj,chanPtr);
75+
cstatus(obj,status,['Channel: ' id ' not found']);
76+
[status, rValue] = iio_channel_attr_read(obj,chanPtr,attr);
77+
cstatus(obj,status,['Error reading attribute: ' attr]);
78+
end
79+
5380
function setDeviceAttributeRAW(obj,attr,value)
5481
phydev = getDev(obj, obj.phyDevName);
5582
bytes = iio_device_attr_write(obj,phydev,attr,value);
@@ -59,5 +86,11 @@ function setDeviceAttributeRAW(obj,attr,value)
5986
end
6087
end
6188

89+
function rValue = getDeviceAttributeRAW(obj,attr)
90+
phydev = getDev(obj, obj.phyDevName);
91+
[status, rValue] = iio_device_attr_read(obj,phydev,attr);
92+
cstatus(obj,status,['Error reading attribute: ' attr]);
93+
end
94+
6295
end
6396
end

+adi/+common/DebugAttribute.m

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
classdef (Abstract) DebugAttribute < matlabshared.libiio.base
2+
3+
methods (Hidden, Access = protected)
4+
function setDebugAttributeLongLong(obj,attr,value)
5+
phydev = getDev(obj, obj.phyDevName);
6+
if (nargin == 1)
7+
iio_device_debug_attr_write_longlong(obj,phydev, 'initialize',1);
8+
return;
9+
end
10+
status = iio_device_debug_attr_write_longlong(obj,phydev,attr,value);
11+
cstatus(obj,status,['Attribute write failed for : ' attr ' with value ' num2str(value)]);
12+
% Check
13+
[status, rValue] = iio_device_debug_attr_read_longlong(obj,phydev,attr);
14+
cstatus(obj,status,['Error reading attribute: ' attr]);
15+
if (value ~= rValue)
16+
status = -1;
17+
cstatus(obj,status,['Attribute ' attr ' return value ' num2str(rValue) ', expected ' num2str(value)]);
18+
end
19+
end
20+
21+
function setDebugAttributeBool(obj,attr,value)
22+
phydev = getDev(obj, obj.phyDevName);
23+
if (nargin == 1)
24+
iio_device_debug_attr_write_bool(obj,phydev, 'initialize',1);
25+
return;
26+
end
27+
status = iio_device_debug_attr_write_bool(obj,phydev,attr,value);
28+
cstatus(obj,status,['Attribute write failed for : ' attr]);
29+
% Check
30+
[status, rValue] = iio_device_debug_attr_read_bool(obj,phydev,attr);
31+
cstatus(obj,status,['Error reading attribute: ' attr]);
32+
if value ~= rValue
33+
status = -1;
34+
cstatus(obj,status,['Attribute ' attr ' return value ' num2str(rValue) ', expected ' num2str(value)]);
35+
end
36+
end
37+
end
38+
end

+adi/+common/RegisterReadWrite.m

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
classdef (Abstract) RegisterReadWrite < matlabshared.libiio.base
2+
3+
methods (Hidden, Access = protected)
4+
function setRegister(obj, value, addr, mask_bin, bit_shift)
5+
phydev = getDev(obj, obj.phyDevName);
6+
if (nargin == 5)
7+
value = value*2^(bit_shift);
8+
end
9+
addr_dec = hex2dec(addr);
10+
mask_dec = bin2dec(mask_bin);
11+
[status, curr_val] = iio_device_reg_read(obj,phydev,addr_dec);
12+
cstatus(obj,status,['Error reading address: ' addr]);
13+
new_val = bitxor(value, bitand(bitxor(value, curr_val), mask_dec));
14+
status = iio_device_reg_write(obj,phydev,addr_dec,new_val);
15+
cstatus(obj,status,['Address write failed for : ' addr ' with value ' num2str(value)]);
16+
% Check
17+
[status, rValue] = iio_device_reg_read(obj,phydev,addr_dec);
18+
cstatus(obj,status,['Error reading address: ' addr]);
19+
if (new_val ~= rValue)
20+
status = -1;
21+
cstatus(obj,status,['Address ' addr ' contents ' num2str(rValue) ', expected ' num2str(new_val)]);
22+
end
23+
end
24+
25+
function value = getRegister(obj, addr, mask_bin, bit_shift)
26+
phydev = getDev(obj, obj.phyDevName);
27+
addr_dec = hex2dec(addr);
28+
% Check
29+
[status, value] = iio_device_reg_read(obj,phydev,addr_dec);
30+
if (nargin >= 3)
31+
mask_dec = 255-bin2dec(mask_bin);
32+
value = bitand(value, mask_dec);
33+
if (nargin == 4)
34+
value = value/2^(bit_shift);
35+
end
36+
end
37+
cstatus(obj,status,['Error reading address: ' addr]);
38+
end
39+
end
40+
end

+adi/+common/RxTx.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@
2626
function flag = isInactivePropertyImpl(obj, prop)
2727
flag = strcmpi(prop,'enIO');
2828
% TX/RX
29+
if isprop(obj,'EnableCustomProfile')
30+
flag = flag || strcmpi(prop,'CustomProfileFileName') && ~obj.EnableCustomProfile;
31+
if obj.EnableCustomProfile
32+
flag = flag || strcmpi(prop,'RFBandwidth');
33+
flag = flag || strcmpi(prop,'SamplingRate');
34+
end
35+
end
2936
if isprop(obj,'EnableCustomFilter')
3037
flag = flag || strcmpi(prop,'CustomFilterFileName') && ~obj.EnableCustomFilter;
3138
if obj.EnableCustomFilter

+adi/Version.m

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
classdef Version
2+
%Version
3+
% BSP Version information
4+
properties(Constant)
5+
HDL = 'hdl_2018_r1';
6+
Vivado = '2017.4.1';
7+
MATLAB = 'R2018b';
8+
Release = '18.2';
9+
end
10+
properties(Dependent)
11+
VivadoShort
12+
end
13+
14+
methods
15+
function value = get.VivadoShort(obj)
16+
value = obj.Vivado(1:6);
17+
end
18+
end
19+
end
20+

0 commit comments

Comments
 (0)