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) {
230
230
bool mgos_gpio_set_pull (int pin , enum mgos_gpio_pull_type pull ) {
231
231
GPIO_TypeDef * regs = stm32_gpio_port_base (pin );
232
232
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 ;
235
235
switch (pull ) {
236
236
case MGOS_GPIO_PULL_NONE :
237
237
break ;
@@ -244,7 +244,7 @@ bool mgos_gpio_set_pull(int pin, enum mgos_gpio_pull_type pull) {
244
244
default :
245
245
return false;
246
246
}
247
- MODIFY_REG (regs -> PUPDR , pupdr_msk , (pupdr_val << pin_num ));
247
+ MODIFY_REG (regs -> PUPDR , ( 3 << shift ) , (pupdr_val << shift ));
248
248
return true;
249
249
}
250
250
You can’t perform that action at this time.
0 commit comments