Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 195813d

Browse files
author
Daniel Campora
committed
mods/machpin.c: Always take the af_in and af_out values passed to pin_config()
Otherwise it's impossible to make a Pin a simple GPIO after it has been assigned to a peripheral function.
1 parent 9631161 commit 195813d

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

esp32/mods/machpin.c

+3-9
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,10 @@ pin_obj_t *pin_find(mp_obj_t user_obj) {
121121
void pin_config (pin_obj_t *self, int af_in, int af_out, uint mode, uint pull, int value) {
122122
self->mode = mode;
123123
self->pull = pull;
124+
self->af_in = af_in;
125+
self->af_out = af_out;
124126

125-
// if af is -1, then we want to keep it as it is
126-
if (af_in >= 0) {
127-
self->af_in = af_in;
128-
}
129-
if (af_out >= 0) {
130-
self->af_out = af_out;
131-
}
132-
133-
// if value is -1, then we want to keep it as it is
127+
// if value is < 0, then we want to keep it as it is
134128
if (value >= 0) {
135129
self->value = value;
136130
}

0 commit comments

Comments
 (0)