Skip to content

Commit 3e846fc

Browse files
committed
Fix bugs in GPIO code
The GPIO input and direction mask would not change back to 0 once they were changed to 1.
1 parent caf90a6 commit 3e846fc

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

hw/gpio/stm32_gpio.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ static void stm32_gpio_in_trigger(void *opaque, int irq, int level)
8383
assert(pin < STM32_GPIO_PIN_COUNT);
8484

8585
/* Update internal pin state. */
86+
s->in &= ~(1 << pin);
8687
s->in |= (level ? 1 : 0) << pin;
8788

8889
/* Propagate the trigger to the input IRQs. */
@@ -125,6 +126,7 @@ static void stm32_gpio_update_dir(Stm32Gpio *s, int cr_index)
125126
/* If the mode is 0, the pin is input. Otherwise, it
126127
* is output.
127128
*/
129+
s->dir_mask &= ~(1 << pin);
128130
s->dir_mask |= (pin_dir ? 1 : 0) << pin;
129131
}
130132
}

0 commit comments

Comments
 (0)