From 9d27d8c94bc012633346cbe8bb6ccd4b5fdc5a9d Mon Sep 17 00:00:00 2001 From: greedyhao Date: Mon, 8 Nov 2021 10:06:44 +0800 Subject: [PATCH] [bluetrum] add gpio input nopull --- bsp/bluetrum/libraries/hal_drivers/drv_gpio.c | 3 +++ .../hal_libraries/ab32vg1_hal/source/ab32vg1_hal_gpio.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/bsp/bluetrum/libraries/hal_drivers/drv_gpio.c b/bsp/bluetrum/libraries/hal_drivers/drv_gpio.c index a99f5561ca..0ba351d584 100644 --- a/bsp/bluetrum/libraries/hal_drivers/drv_gpio.c +++ b/bsp/bluetrum/libraries/hal_drivers/drv_gpio.c @@ -128,6 +128,9 @@ static void ab32_pin_mode(rt_device_t dev, rt_base_t pin, rt_base_t mode) switch (mode) { case PIN_MODE_INPUT: + gpio_init.pull = GPIO_NOPULL; + gpio_init.dir = GPIO_DIR_INPUT; + break; case PIN_MODE_INPUT_PULLUP: gpio_init.pull = GPIO_PULLUP; gpio_init.dir = GPIO_DIR_INPUT; diff --git a/bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/source/ab32vg1_hal_gpio.c b/bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/source/ab32vg1_hal_gpio.c index 0a3fe31844..7b1601befd 100644 --- a/bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/source/ab32vg1_hal_gpio.c +++ b/bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/source/ab32vg1_hal_gpio.c @@ -72,12 +72,16 @@ void hal_gpio_init(hal_sfr_t gpiox, gpio_init_t gpio_init) switch (gpio_init->pull) { case GPIO_PULLUP: + gpiox[GPIOxPD] &= ~BIT(iocurrent); gpiox[GPIOxPU] |= BIT(iocurrent); break; case GPIO_PULLDOWN: + gpiox[GPIOxPU] &= ~BIT(iocurrent); gpiox[GPIOxPD] |= BIT(iocurrent); break; case GPIO_NOPULL: + gpiox[GPIOxPU] &= ~BIT(iocurrent); + gpiox[GPIOxPD] &= ~BIT(iocurrent); default: break; }