[bluetrum] add gpio input nopull

This commit is contained in:
greedyhao 2021-11-08 10:06:44 +08:00
parent 8e0c469d0c
commit 9d27d8c94b
2 changed files with 7 additions and 0 deletions

View File

@ -128,6 +128,9 @@ static void ab32_pin_mode(rt_device_t dev, rt_base_t pin, rt_base_t mode)
switch (mode) switch (mode)
{ {
case PIN_MODE_INPUT: case PIN_MODE_INPUT:
gpio_init.pull = GPIO_NOPULL;
gpio_init.dir = GPIO_DIR_INPUT;
break;
case PIN_MODE_INPUT_PULLUP: case PIN_MODE_INPUT_PULLUP:
gpio_init.pull = GPIO_PULLUP; gpio_init.pull = GPIO_PULLUP;
gpio_init.dir = GPIO_DIR_INPUT; gpio_init.dir = GPIO_DIR_INPUT;

View File

@ -72,12 +72,16 @@ void hal_gpio_init(hal_sfr_t gpiox, gpio_init_t gpio_init)
switch (gpio_init->pull) switch (gpio_init->pull)
{ {
case GPIO_PULLUP: case GPIO_PULLUP:
gpiox[GPIOxPD] &= ~BIT(iocurrent);
gpiox[GPIOxPU] |= BIT(iocurrent); gpiox[GPIOxPU] |= BIT(iocurrent);
break; break;
case GPIO_PULLDOWN: case GPIO_PULLDOWN:
gpiox[GPIOxPU] &= ~BIT(iocurrent);
gpiox[GPIOxPD] |= BIT(iocurrent); gpiox[GPIOxPD] |= BIT(iocurrent);
break; break;
case GPIO_NOPULL: case GPIO_NOPULL:
gpiox[GPIOxPU] &= ~BIT(iocurrent);
gpiox[GPIOxPD] &= ~BIT(iocurrent);
default: default:
break; break;
} }