Skip to content

Conversation

@adiceline
Copy link
Collaborator

@adiceline adiceline commented Nov 3, 2025

Pull Request Description

This PR adds driver support for the ADAQ776x-1 ADC with IIO attributes and example usage.

PR Type

  • Bug fix (change that fixes an issue)
  • New feature (change that adds new functionality)
  • Breaking change (has dependencies in other repos or will cause CI to fail)

PR Checklist

  • I have followed the Coding style guidelines
  • I have complied with the Submission Checklist
  • I have performed a self-review of the changes
  • I have commented my code, at least hard-to-understand parts
  • I have build all projects affected by the changes in this PR
  • I have tested in hardware affected projects, at the relevant boards
  • I have signed off all commits from this PR
  • I have updated the documentation (wiki pages, ReadMe etc), if applies

@CLAassistant
Copy link

CLAassistant commented Nov 3, 2025

CLA assistant check
All committers have signed the CLA.

@adiceline adiceline force-pushed the dev/adaq776x-1 branch 4 times, most recently from d1ee533 to 7b0ba02 Compare November 3, 2025 08:12
Added helper functions and enums to handle PGA, AAF, and SINC3 decimation
rate configuration

Signed-off-by: adiceline <[email protected]>
@adiceline adiceline changed the title drivers:adc:ada7768-1: Add support for ADAQ776x-1 Family drivers:adc:ad7768-1: Add support for ADAQ776x-1 Family Nov 3, 2025
@adiceline adiceline marked this pull request as ready for review November 3, 2025 08:54
Add initial header and source file for ada7768-1 IIO driver.

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]>
*
* @return 0 in case of success, errno errors otherwise
*/
int ad77681_iio_remove(struct ad77681_iio_dev *dev)
Copy link
Contributor

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.

Copy link
Collaborator

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);
Copy link
Contributor

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.

Comment on lines +568 to +573
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])
);
Copy link
Contributor

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

Suggested change
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;
Copy link
Contributor

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 */
Copy link
Contributor

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;
Copy link
Contributor

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",
Copy link
Contributor

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

@buha
Copy link
Contributor

buha commented Nov 20, 2025

also, typo in 1st commit title

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants