-
Notifications
You must be signed in to change notification settings - Fork 134
Add esp_dac, for now only with oneshot mode #1998
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
Signed-off-by: schnittchen <schnittchen@das-labor.org>
Signed-off-by: schnittchen <schnittchen@das-labor.org>
bettio
left a comment
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.
Did you take the code verbatim from the component, or did you apply any change? If so, can you let me know which changes?
Also, let's add this to our sdkconfig so we can make it optional when building AtomVM from scratch.
I don't understand what you mean here, which component? |
I saw the following copyright: So my assumption is that this PR is based on this code: https://github.com/atomvm/atomvm_adc . Am I right? If so, what kind of changes did you do to it? |
bettio
left a comment
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.
In order to merge this code this issue has to be fixed: esp_dac.erl:19: Call to missing or unexported function esp_dac:oneshot_new_channel_p/1
Ah, thanks for clarifying. The new code started out as the adc code but with most of the details removed. Few things should really have survived: some of the #include lines; create_pair and error_return_tuple; how to expose the resource to the Erlang world (although with significantly different code). The happy case result building on nif_oneshot_new_channel_p should be 1:1 the same. I don't really know the implications on the copyright. |
Where did you see that? |
Most CI is red eg. https://github.com/atomvm/AtomVM/actions/runs/19595789851/job/56245058688?pr=1998 |
Signed-off-by: schnittchen <schnittchen@das-labor.org>
Signed-off-by: schnittchen <schnittchen@das-labor.org>
This comment was marked as outdated.
This comment was marked as outdated.
|
Looks like DAC is only on esp32 and esp32-s2, so we need some guards in the proper places, so let's make a CONFIG_AVM_ENABLE_DAC_NIF guard in the dac_driver.c: then in the kconfig: |
Signed-off-by: schnittchen <schnittchen@das-labor.org>
Signed-off-by: schnittchen <schnittchen@das-labor.org>
Signed-off-by: schnittchen <schnittchen@das-labor.org>
Signed-off-by: schnittchen <schnittchen@das-labor.org>
66abfa0 to
4825580
Compare
|
The remaining failed checks seem unrelated. Also, I think I've taken care of all comments so far |
| set(AVM_BUILTIN_COMPONENT_SRCS "adc_driver.c" ${AVM_BUILTIN_COMPONENT_SRCS}) | ||
| if(CONFIG_AVM_ENABLE_DAC_NIF) | ||
| set(ADDITIONAL_PRIV_REQUIRES "esp_adc" ${ADDITIONAL_PRIV_REQUIRES}) | ||
| set(AVM_BUILTIN_COMPONENT_SRCS "adc_driver.c" ${AVM_BUILTIN_COMPONENT_SRCS}) |
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 putting the esp_adc under the CONFIG_AVM_ENABLE_DAC_NIF flag which we don't want..
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.
Why so? My thinking was, if the DAC nif is disabled, we don't need to add that dependency...
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.
AVM_ENABLE_DAC_NIF is only true for esp32/esp32s2 - the adc is available all boards..
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.
Oh! I see it now.
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.
Should be fixed now.
Signed-off-by: schnittchen <schnittchen@das-labor.org>
Signed-off-by: schnittchen <schnittchen@das-labor.org>
| // References | ||
| // https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/peripherals/dac.html | ||
|
|
||
| #include <context.h> |
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.
#include <sdkconfig.h>
#ifdef CONFIG_AVM_ENABLE_DAC_NIF
on top? just to follow all/most other nifs pattern?
These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).
SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later