Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AD7124: update code to match newer linux drivers #39

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions +adi/+AD7124/Base.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ function delete(obj)
% Set device sampling rate
obj.SampleRate = value;
if obj.ConnectedToDevice
obj.setDeviceAttributeRAW('sampling_frequency', value);
for i=1:length(obj.channel_names)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@commodo, Can we update the driver to make sure the no-OS implementation doesn't break with these changes?
In the tinyIIOd-based Firmware implementation, this attribute is treated as a device-level attribute and I see that these changes align with the new Linux drivers.

We can have a new property for channel-sampling-rate attribute naming it as SampleRateCh (or something of that sort or a boolean property that tells if it's a device level or channel level) and this logic can go there (toward its setter function). This way we can have this driver compatible for both the implementations and the attributes can be set accordingly in the example script.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT, the no-Os drivers should be differential;
no idea how they show up in IIO

@buha @amiclaus any ideas?

i'll need to see if i can make some time to check this

if (ismember(i, obj.EnabledChannels))
obj.setAttributeRAW(obj.channel_names{i}, 'sampling_frequency', value, false);
end
end
end
end
end
Expand All @@ -79,7 +83,11 @@ function setupInit(obj)
% Do writes directly to hardware without using set methods.
% This is required since Simulink support doesn't support
% modification to nontunable variables at SetupImpl
obj.setDeviceAttributeRAW('sampling_frequency',num2str(obj.SampleRate));
for i=1:length(obj.channel_names)
if (ismember(i, obj.EnabledChannels))
obj.setAttributeRAW(obj.channel_names{i}, 'sampling_frequency', num2str(obj.SampleRate), false);
end
end
end
end

Expand Down
4 changes: 2 additions & 2 deletions +adi/+AD7124_4/Rx.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
% `AD7124-4 Datasheet <https://www.analog.com/media/en/technical-documentation/data-sheets/ad7124-4.pdf>`_

properties (Nontunable, Hidden)
channel_names = {'voltage0','voltage1','voltage2'...
'voltage3','voltage4','voltage5','voltage6','voltage7'};
channel_names = {'voltage0-voltage1','voltage2-voltage3',...
'voltage4-voltage5','voltage6-voltage7'};
end

methods
Expand Down
8 changes: 4 additions & 4 deletions +adi/+AD7124_8/Rx.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@


properties (Nontunable, Hidden)
channel_names = {'voltage0','voltage1','voltage2','voltage3',...
'voltage4','voltage5','voltage6','voltage7','voltage8','voltage9',...
'voltage10','voltage11','voltage12','voltage13','voltage14','voltage15'};
channel_names = {'voltage0-voltage1','voltage2-voltage3',...
'voltage4-voltage5','voltage6-voltage7','voltage8-voltage9',...
'voltage10-voltage11','voltage12-voltage13','voltage14-voltage15'};
end

methods
Expand All @@ -25,4 +25,4 @@
end
end

end
end