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

zephyrCommon: Implement analogRead()/analogReference() #54

Merged
merged 2 commits into from
Oct 5, 2022

Conversation

soburi
Copy link
Member

@soburi soburi commented Sep 23, 2022

The 'io-channels' node under the 'zephyr,user' defines
available ADC channels.

The 'io-channel-pins' defines the mapping of ADC channels
to pin numbers. API looks up the 'io-channel-pins' when
querying the ADC channel by digital pin number.
So it should be in the same order as 'io-channels' node.

For original Arduino API compatibility, ADC resolution
should configure as 10-bit.

ADC that is on MCU supported by Zephyr exists
only 16-bit resolution currently.
So it supports resolutions up to 16-bit.

Signed-off-by: TOKITA Hiroshi [email protected]

Copy link
Collaborator

@DhruvaG2000 DhruvaG2000 left a comment

Choose a reason for hiding this comment

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

This PR adds a big chunk of code to overlay files, hence for adding further variants it maybe useful to have documentation for what all is needed to get analog working in these overlays.
Do you think you can also add documentation for the same?

@@ -0,0 +1,4 @@
CONFIG_GPIO=y
CONFIG_ADC=y
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think all this can be shifted into the project's global KConfig

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed it.

:goals: build flash
:compact:

Change ``arduino_nano_33_ble`` appropriately for other supported boards.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This README needs updating.

Copy link
Member Author

Choose a reason for hiding this comment

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

I forgot it.😱

Update README did.

The 'io-channels' node under the 'zephyr,user' defines
available ADC channels.

The 'io-channel-pins' defines the mapping of ADC channels
to pin numbers.  API looks up the 'io-channel-pins' when
querying the ADC channel by digital pin number.
So it should be in the same order as 'io-channels' node.

For original Arduino API compatibility, adc resolution
should configure as 10-bit.

ADC that is on MCU supported by Zephyr exists
only 16-bit resolution currently.
So it supports resolutions up to 16-bit.

Signed-off-by: TOKITA Hiroshi <[email protected]>
Add a sample to demonstrate how to use analogRead API

Signed-off-by: TOKITA Hiroshi <[email protected]>
@soburi
Copy link
Member Author

soburi commented Sep 26, 2022

@DhruvaG2000
Rebase to newest main branch done.
Could you please review again?

@DhruvaG2000 DhruvaG2000 requested a review from szczys September 26, 2022 14:03
@DhruvaG2000
Copy link
Collaborator

Code looks good, but let me test this patch on real hardware before approving and merging.

@soburi
Copy link
Member Author

soburi commented Sep 26, 2022

Code looks good, but let me test this patch on real hardware before approving and merging.

Okay, No need to hurry

Copy link
Collaborator

@DhruvaG2000 DhruvaG2000 left a comment

Choose a reason for hiding this comment

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

Built and tested on my arduino nano 33 ble sense, and it works OK.

@DhruvaG2000 DhruvaG2000 merged commit fda91b4 into zephyrproject-rtos:main Oct 5, 2022
@soburi soburi deleted the adc branch November 19, 2022 21:55
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.

2 participants