diff --git a/arch/arm/soc/st_stm32/stm32f4/soc_gpio.c b/arch/arm/soc/st_stm32/stm32f4/soc_gpio.c index 03c9bfe8f54a24..875fdcee7b5520 100644 --- a/arch/arm/soc/st_stm32/stm32f4/soc_gpio.c +++ b/arch/arm/soc/st_stm32/stm32f4/soc_gpio.c @@ -210,12 +210,12 @@ int stm32_gpio_set(uint32_t *base, int pin, int value) { struct stm32f4x_gpio *gpio = (struct stm32f4x_gpio *)base; - int pval = 1 << (pin & 0xf); - if (value) { - gpio->odr |= pval; + /* atomic set */ + gpio->bsr = (1 << (pin & 0x0f)); } else { - gpio->odr &= ~pval; + /* atomic reset */ + gpio->bsr = (1 << ((pin & 0x0f) + 0x10)); } return 0;