Skip to content

Commit 5009ff5

Browse files
authored
Merge pull request #2787 from particle-iot/fix/sc124967/pin-mode-glitch
[gen3] hal: fix gpio glitch
2 parents 7d155c8 + 96e38ce commit 5009ff5

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

hal/src/nRF52840/gpio_hal.cpp

+10-5
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,17 @@ int hal_gpio_configure(hal_pin_t pin, const hal_gpio_config_t* conf, void* reser
7676
}
7777

7878
// Pre-set the output value if requested to avoid a glitch
79-
if (conf->set_value && (mode == OUTPUT || mode == OUTPUT_OPEN_DRAIN || mode == OUTPUT_OPEN_DRAIN_PULLUP)) {
80-
if (conf->value) {
81-
nrf_gpio_pin_set(nrfPin);
82-
} else {
83-
nrf_gpio_pin_clear(nrfPin);
79+
if (conf->set_value) {
80+
if (mode == OUTPUT || mode == OUTPUT_OPEN_DRAIN || mode == OUTPUT_OPEN_DRAIN_PULLUP) {
81+
if (conf->value) {
82+
nrf_gpio_pin_set(nrfPin);
83+
} else {
84+
nrf_gpio_pin_clear(nrfPin);
85+
}
8486
}
87+
} else if (mode == OUTPUT_OPEN_DRAIN || mode == OUTPUT_OPEN_DRAIN_PULLUP) {
88+
// Release the pin control by default
89+
nrf_gpio_pin_set(nrfPin);
8590
}
8691

8792
switch (mode) {

0 commit comments

Comments
 (0)