Skip to content

Commit

Permalink
TEST: Add ad4630-24 attr tests
Browse files Browse the repository at this point in the history
Signed-off-by: Julia Pineda <[email protected]>
  • Loading branch information
jpineda3 committed Jan 15, 2024
1 parent ba4feaf commit 1cf45c9
Showing 1 changed file with 20 additions and 26 deletions.
46 changes: 20 additions & 26 deletions test/AD4630_24Tests.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
end

properties(TestParameter)
sample_rate = {{1000,2000000,30000,0.0015,10}};
sample_rate = {'10000', '50000', '100000', ...
'200000', '500000', '1000000', ...
'1760000', '2000000'};

sample_averaging_length = { ...
'2', '4', '8', '16', '32', '64', '128', '256', ...
'512', '1024', '2048', '4096', '8192', '16384', ...
Expand All @@ -31,35 +34,26 @@ function testAD4630_24Smoke(testCase)
testCase.assertTrue(sum(abs(double(data)))>0);
end

function testAD7768_1AttrSamplesPerFrame(testCase,sample_rate)
% TODO: Test this test
adc = adi.AD7768_1.Rx;
function testAD4630_24AttrSampleRate(testCase,sample_rate)
% '1750000' is set as '1754386'
adc = adi.AD4630_24.Rx('uri',testCase.uri);
adc.uri = testCase.uri;

start = sample_rate{1};
stop = sample_rate{2};
step = sample_rate{3};
tol = sample_rate{4};
repeats = sample_rate{5};
numints = round((stop-start)/step);
for ii = 1:repeats
ind = randi([0, numints]);
val = start+(step*ind);
adc.SampleRate = num2str(val);
[data, valid] = adc();
ret_val = adc.getDeviceAttributeRAW('sample_rate',8);
adc.release();
testCase.assertTrue(valid);
testCase.assertTrue(sum(abs(double(data)))>0);
testCase.verifyEqual(str2double(ret_val),val,'RelTol',tol,...
'Sample rate unexpected')
end
val = sample_rate;
adc.SampleRate = val;
[data,valid] = adc();
ret_val = adc.getDeviceAttributeRAW('sampling_frequency',9);
adc.release();
testCase.assertTrue(valid);
testCase.assertTrue(sum(abs(double(data)))>0);
% testCase.assertTrue(strcmp(val,string(ret_val)), ...
% 'Sample rate unexpected')
testCase.verifyEqual(str2double(ret_val),str2double(val), ...
'RelTol',0,'Sample rate unexpected')
end

function testAD4630_24AttrSampleAveragingLength(testCase,sample_averaging_length)
% TODO: Test this test
adc = adi.AD4630_24.Rx;
adc.uri = testCase.uri;
% The average mode works only with the output data mode set to 30-bit average
adc = adi.AD4630_24.Rx('uri',testCase.uri);
val = sample_averaging_length;
adc.SampleAveragingLength = val;
[data,valid] = adc();
Expand Down

0 comments on commit 1cf45c9

Please sign in to comment.