-
Notifications
You must be signed in to change notification settings - Fork 122
Update ESP32 GPIO driver errors to match other MCU platforms #1408
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
do we need to remove RISING_ATOM_INDEX et al in platform_defaultatoms.h ?
|
This is done in commit bede918 |
587b4d4
to
aca3489
Compare
My mistake, you are correct! Those changes should have been included in the commit I mentioned, but were not added. Correction has been pushed. |
aca3489
to
fa94ff3
Compare
c4c5343
to
24fdbf9
Compare
LGTM, but assume it needs rebasing to new defaultatoms setup. |
Indeed. I also realized that I should be using port_create_error_tuple, and remove the unnecessary error_tuple_maybe_gc and update/remove the usage of create_pair as well. |
24fdbf9
to
d2d259c
Compare
All fixed. This should be ready now. We needed to keep create_pair, because we need to preserve a root, if gc is necessary. |
f3a4ad8
to
8f81b88
Compare
Please, see also #1442 |
8f81b88
to
669c0f1
Compare
Standardizes STM32 error returns. Nif functions raise `Error`, port functions return `{error, Reason}` on errors. Addresses concerns raised in issue atomvm#1442. With atomvm#1408 this closes issue atomvm#894 Signed-off-by: Winford <[email protected]>
Standardizes stm32 gpio driver error returns. Nif functions raise `Error`, port functions return `{error, Reason}` on errors. Addresses some concerns raised in issue atomvm#1442. With atomvm#1408 this closes issue atomvm#894 Signed-off-by: Winford <[email protected]>
Standardizes stm32 gpio driver error returns. Nif functions raise `Error`, port functions return `{error, Reason}` on errors. Addresses some concerns raised in issue atomvm#1442. With atomvm#1408 this closes issue atomvm#894 Signed-off-by: Winford <[email protected]>
Standardizes stm32 gpio driver error returns. Nif functions raise `Error`, port functions return `{error, Reason}` on errors. Addresses some concerns raised in issue atomvm#1442. With atomvm#1408 this closes issue atomvm#894 Signed-off-by: Winford <[email protected]>
Standardizes stm32 gpio driver error returns. Nif functions raise `Error`, port functions return `{error, Reason}` on errors. Addresses some concerns raised in issue atomvm#1442. With atomvm#1408 this closes issue atomvm#894 Signed-off-by: Winford <[email protected]>
cb6e30e
to
35b5bb9
Compare
8400531
to
71e1443
Compare
fd4ebdc
to
cffd8ff
Compare
cffd8ff
to
c96029d
Compare
Reduce the number of GPIO related atoms created at boot by using more efficient matching to atom string where possible. Removes `static const char *const` declarations for atoms, replacing with `ATOM_STR()` in place for better readability. Handles the creations of atoms used by the driver in a safer way, checking their validity where necessary. Signed-off-by: Winford <[email protected]>
Adds the `internal_error` atom from OTP for returning errors for "thing that shouldn't happen". There are rare occasions where user inputs may be valid, but an internal operation fails for some reason (potentially an internal bug to the VM, not the users application code). For example, this may be an invalid internal state when setting the direction for a gpio pin. If the users inputs are valid `internal_error` should be returned rather than `badarg`, which could mislead application developers into chasing a bug in their application that isn't there. Signed-off-by: Winford <[email protected]>
Changes error returns to match the spec and ofther platforms. Nifs now raise any errors, and port function errors return `{error, Reason}`. Updates gpio.erl to reflect the correct returns, and make it more clear that errors for nifs will be raised. Closes atomvm#894 Signed-off-by: Winford <[email protected]>
Adds a test to run on hardware with a jumper wire, or in the wokwi simulator to test the basic esp32 gpio driver funtionality and error handling, with tests for all boards when full_sim_test is run. The sim-test for P4 depends on PR atomvm#1438 being merged to be able to select the correct pins for the device for the the GPIO tests. Signed-off-by: Winford <[email protected]>
c96029d
to
3590ef7
Compare
These changes move the GPIO specific atoms out of the ESP32 platform default atoms (created at boot) into the GPIO driver where they are only created as needed.
Breaking changes update the error returns to match the spec. Nifs raise
Error
, and port functions return{error, Reason}
when errors are encountered.Adds gpio driver tests to the Wokwi sim to test driver functionality and error return correctness for invalid parameters.
With #1448 closes #894
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