-
Notifications
You must be signed in to change notification settings - Fork 1.8k
drivers:adc:ad7768-1: Add support for ADAQ776x-1 Family #2807
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
base: main
Are you sure you want to change the base?
Conversation
d1ee533 to
7b0ba02
Compare
Added helper functions and enums to handle PGA, AAF, and SINC3 decimation rate configuration Signed-off-by: adiceline <[email protected]>
7b0ba02 to
e38ce70
Compare
e38ce70 to
4101fd1
Compare
Add initial header and source file for ada7768-1 IIO driver. Signed-off-by: adiceline <[email protected]>
Signed-off-by: adiceline <[email protected]>
Signed-off-by: adiceline <[email protected]>
Add initial project files for both basic and IIO examples for ADAQ776x-1 Signed-off-by: adiceline <[email protected]>
4101fd1 to
dbce1a3
Compare
| * | ||
| * @return 0 in case of success, errno errors otherwise | ||
| */ | ||
| int ad77681_iio_remove(struct ad77681_iio_dev *dev) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not necessarily linked to this PR, but might be worth addressing: during initialization, ad77681_dev is allocated but doesn't appear to be freed in this function, which could lead to a memory leak. Maybe it would make sense to add a remove function in ad77681.c and calling it from here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. @adiceline It can be added in this PR but put it in a separate commit.
|
|
||
| val = ad77681->vref / 1000; | ||
| /* Multiply by MILLI here to avoid losing precision */ | ||
| //val = mult_frac(val, denominator * MILLI, numerator); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace with a proper note or remove entirely.
| ad77681_sample_data = | ||
| ( | ||
| (ad77681_sample_data_buff[1] << AD77681_2_BYTES_SHIFT) | | ||
| (ad77681_sample_data_buff[2] << AD77681_1_BYTE_SHIFT) | | ||
| (ad77681_sample_data_buff[3]) | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check if you can use no_os_get_unaligned_be24 here
| ad77681_sample_data = | |
| ( | |
| (ad77681_sample_data_buff[1] << AD77681_2_BYTES_SHIFT) | | |
| (ad77681_sample_data_buff[2] << AD77681_1_BYTE_SHIFT) | | |
| (ad77681_sample_data_buff[3]) | |
| ); | |
| ad77681_sample_data = no_os_get_unaligned_be24(&ad77681_sample_data_buff[1]); |
| (ad77681_sample_data_buff[2] << AD77681_1_BYTE_SHIFT) | | ||
| (ad77681_sample_data_buff[3]) | ||
| ); | ||
| adc_data_raw = ad77681_sample_data & AD77681_24_BITS_SIGN_EXTENSION; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this masking for?
| tmp = NO_OS_DIV_ROUND_CLOSEST_ULL(gain_nano << precision, NANO); | ||
| gain_nano = NO_OS_DIV_ROUND_CLOSEST_ULL(dev->vref, tmp); | ||
| if (dev->has_variable_aaf) | ||
| /* remove the AAF gain from the gain */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i highly suggest you put brackets {} around the if branch even though functionally it's ok as is, that comment being there could be confusing for some and it might lead to bugs in the future if lines are added in the branch
| iio_ad77681 = (struct ad77681_iio_dev *)device; | ||
| ad77681 = iio_ad77681->ad77681_desc; | ||
|
|
||
| //scan_type = ad77681_iio_scan_type; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this comment
| { | ||
| "xilinx": { | ||
| "basic": { | ||
| "flags": "BASIC_EXAMPLE=y IIO_EXAMPLE=n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not how EXAMPLE infrastructure is supposed to be used, you should name the folders under src/examples: basic and iio and not basic_example and iio_example and then if you do it right, make EXAMPLE=basic or make EXAMPLE=iio
|
also, typo in 1st commit title |
Pull Request Description
This PR adds driver support for the ADAQ776x-1 ADC with IIO attributes and example usage.
PR Type
PR Checklist