From b33e1cbf68bbc5abd06a5a326d5e33c1826bb7d8 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sun, 19 Mar 2023 21:10:02 -0400 Subject: [PATCH] =?UTF-8?q?[stm32][pin]=20=E4=BF=AE=E5=A4=8DGPIO=E9=A9=B1?= =?UTF-8?q?=E5=8A=A8=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/stm32/libraries/HAL_Drivers/drv_gpio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_gpio.c b/bsp/stm32/libraries/HAL_Drivers/drv_gpio.c index 6fee543607..061396e1d3 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_gpio.c +++ b/bsp/stm32/libraries/HAL_Drivers/drv_gpio.c @@ -217,16 +217,16 @@ static rt_int8_t stm32_pin_read(rt_device_t dev, rt_base_t pin) { GPIO_TypeDef *gpio_port; uint16_t gpio_pin; - GPIO_PinState value = PIN_LOW; + GPIO_PinState state; if (PIN_PORT(pin) < PIN_STPORT_MAX) { gpio_port = PIN_STPORT(pin); gpio_pin = PIN_STPIN(pin); - value = HAL_GPIO_ReadPin(gpio_port, gpio_pin); + state = HAL_GPIO_ReadPin(gpio_port, gpio_pin); } - return value; + return (state == GPIO_PIN_RESET) ? PIN_LOW : PIN_HIGH; } static void stm32_pin_mode(rt_device_t dev, rt_base_t pin, rt_uint8_t mode)