File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -230,8 +230,8 @@ bool mgos_gpio_set_mode(int pin, enum mgos_gpio_mode mode) {
230230bool mgos_gpio_set_pull (int pin , enum mgos_gpio_pull_type pull ) {
231231 GPIO_TypeDef * regs = stm32_gpio_port_base (pin );
232232 if (regs == NULL ) return false;
233- const uint32_t pin_num = STM32_PIN_NUM (pin );
234- uint32_t pupdr_msk = ( 3 << pin_num ), pupdr_val = 0 ;
233+ const uint32_t shift = STM32_PIN_NUM (pin ) * 2 ;
234+ uint32_t pupdr_val = 0 ;
235235 switch (pull ) {
236236 case MGOS_GPIO_PULL_NONE :
237237 break ;
@@ -244,7 +244,7 @@ bool mgos_gpio_set_pull(int pin, enum mgos_gpio_pull_type pull) {
244244 default :
245245 return false;
246246 }
247- MODIFY_REG (regs -> PUPDR , pupdr_msk , (pupdr_val << pin_num ));
247+ MODIFY_REG (regs -> PUPDR , ( 3 << shift ) , (pupdr_val << shift ));
248248 return true;
249249}
250250
You can’t perform that action at this time.
0 commit comments