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

Add ADC family MAX11102-MAX11117 #60328

Merged
merged 6 commits into from Sep 14, 2023

Conversation

benediktibk
Copy link
Collaborator

@benediktibk benediktibk commented Jul 13, 2023

Add support for devices of the ADC family MAX11102-MAX11117.

Unfortunately these ADCs require to select the channel a GPIO change within a SPI transaction. Therefore, I had to extend the SPI subsystem with an intermediate callback which is triggered after a SPI buffer has been transferred.

The naming of the driver files themselves is also a little bit unfortunate with max11102_17, but max111xx would be problematic as there are also exist the devices MAX11120-MAX11128 which will require a totally different driver implementation.

@benediktibk benediktibk force-pushed the add_max11102 branch 3 times, most recently from c8f7da9 to ea87f35 Compare July 13, 2023 09:17
@benediktibk benediktibk force-pushed the add_max11102 branch 7 times, most recently from a463310 to 92156db Compare July 21, 2023 11:21
@benediktibk benediktibk marked this pull request as ready for review July 21, 2023 12:40
@zephyrbot zephyrbot added area: Devicetree Binding PR modifies or adds a Device Tree binding area: ADC Analog-to-Digital Converter (ADC) area: SPI SPI bus labels Jul 21, 2023
@zephyrbot zephyrbot requested a review from teburd July 21, 2023 12:42
@benediktibk
Copy link
Collaborator Author

I've tested this driver with a MAX11102. The other ones are untested, but as they are fairly similar I'm confident enough to push them as well.

@benediktibk benediktibk force-pushed the add_max11102 branch 5 times, most recently from 6de5b01 to be461bf Compare July 25, 2023 08:12
@benediktibk benediktibk force-pushed the add_max11102 branch 2 times, most recently from 4335e24 to f6a6a1c Compare July 25, 2023 09:55
MaureenHelm
MaureenHelm previously approved these changes Sep 6, 2023
Copy link
Member

@MaureenHelm MaureenHelm left a comment

Choose a reason for hiding this comment

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

Looks good, but needs to be rebased

@benediktibk
Copy link
Collaborator Author

Rebased to resolve merge conflicts.

@benediktibk
Copy link
Collaborator Author

Rebased to resolve CI issues.

MaureenHelm
MaureenHelm previously approved these changes Sep 7, 2023
drivers/adc/Kconfig.max11102_17 Outdated Show resolved Hide resolved
#endif

#if CONFIG_ADC_ASYNC
static void max11102_17_acquisition_thread(struct device *dev)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
static void max11102_17_acquisition_thread(struct device *dev)
static void max11102_17_acquisition_thread(const struct device *dev)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done, BUT: Looking into this I realized that k_thread_entry_t is actually defined as (void)(void*, void*, void*). At this point I am not sure if it might fuck up the stack if the signature of the actual function and the function pointer through which the call happens do not match?
Anyway, this seems to be the common approach, so at least it is now consistently dangerous ;-).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

outsourced my concerns to #62637

drivers/adc/adc_max11102_17.c Outdated Show resolved Hide resolved
Add bindings for the following ADCs:
- MAX11102
- MAX11103
- MAX11105
- MAX11106
- MAX11110
- MAX11111
- MAX11115
- MAX11116
- MAX11117

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
Add a driver for the following ADCs:
- MAX11102
- MAX11103
- MAX11105
- MAX11106
- MAX11110
- MAX11111
- MAX11115
- MAX11116
- MAX11117

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
Add all available instances of the ADC series
MAX11102-MAX11117 to the ADC shell.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
Add instances of the ADC family MAX11102-MAX11117
to the build all tests.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
Increase the rodata section for build_all/adc to
successfully build on the platform atsame54_xpro.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
Add myself as codeowner of the previously committed ADC
driver for the MAX11102-17 series.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
Comment on lines +160 to +162
if (sequence_channel_count > 1) {
LOG_ERR("multiple channels selected");
return -EINVAL;
Copy link
Member

Choose a reason for hiding this comment

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

Why? Would it be that hard to support sequences with multiple channels?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought this feature was intended for ADCs which can actually read out multiple channels at once, which this IC definitely cannot. Of course I could simulate this via multiple reads in a row.

@MaureenHelm MaureenHelm merged commit 24ad40a into zephyrproject-rtos:main Sep 14, 2023
17 checks passed
@benediktibk benediktibk deleted the add_max11102 branch September 14, 2023 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: ADC Analog-to-Digital Converter (ADC) area: Devicetree Binding PR modifies or adds a Device Tree binding area: SPI SPI bus platform: ADI Analog Devices, Inc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants