Skip to content

Commit edb8650

Browse files
committed
Fix bug for issue 5462, initial pin value not retained
For api usage like DigitalOut led(LED1, 1) the hal function gpio_write() sets the output before f. gpio_mode() is called. gpio_mode() clears the output as it take never writen parameters (gpio_cfg_t.init_hight). This patch use internal hardware register of GPIO output instedad of above paramiter latch for retaining proper writen state.
1 parent 47bae16 commit edb8650

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

targets/TARGET_NORDIC/TARGET_NRF5/gpio_api.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
typedef struct {
3434
bool used_as_gpio : 1;
3535
PinDirection direction : 1;
36-
bool init_high : 1;
3736
PinMode pull : 2;
3837
bool used_as_irq : 1;
3938
bool irq_fall : 1;
@@ -156,7 +155,7 @@ static void gpio_apply_config(uint8_t pin)
156155
}
157156
else {
158157
// Configure as output.
159-
nrf_drv_gpiote_out_config_t cfg = GPIOTE_CONFIG_OUT_SIMPLE(m_gpio_cfg[pin].init_high);
158+
nrf_drv_gpiote_out_config_t cfg = GPIOTE_CONFIG_OUT_SIMPLE(nrf_gpio_pin_out_read(pin));
160159
nrf_drv_gpiote_out_init(pin, &cfg);
161160
}
162161
m_gpio_initialized |= ((gpio_mask_t)1UL << pin);

0 commit comments

Comments
 (0)