Skip to content

Commit

Permalink
Fix pull-up setting on STM32
Browse files Browse the repository at this point in the history
CL: Fix pull-up setting on STM32

PUBLISHED_FROM=d0e12a8068d247d608e24c49ccb4d61fb62127bf
  • Loading branch information
Deomid Ryabkov authored and cesantabot committed Feb 21, 2019
1 parent 67ffee0 commit dd403d6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fw/platforms/stm32/src/stm32_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ bool mgos_gpio_set_mode(int pin, enum mgos_gpio_mode mode) {
bool mgos_gpio_set_pull(int pin, enum mgos_gpio_pull_type pull) {
GPIO_TypeDef *regs = stm32_gpio_port_base(pin);
if (regs == NULL) return false;
const uint32_t pin_num = STM32_PIN_NUM(pin);
uint32_t pupdr_msk = (3 << pin_num), pupdr_val = 0;
const uint32_t shift = STM32_PIN_NUM(pin) * 2;
uint32_t pupdr_val = 0;
switch (pull) {
case MGOS_GPIO_PULL_NONE:
break;
Expand All @@ -244,7 +244,7 @@ bool mgos_gpio_set_pull(int pin, enum mgos_gpio_pull_type pull) {
default:
return false;
}
MODIFY_REG(regs->PUPDR, pupdr_msk, (pupdr_val << pin_num));
MODIFY_REG(regs->PUPDR, (3 << shift), (pupdr_val << shift));
return true;
}

Expand Down

0 comments on commit dd403d6

Please sign in to comment.