Skip to content

Commit f4f34a0

Browse files
committed
Merge pull request #9 from spectaclelabs/fix-gpio-mode
Fix setting STM32 GPIO input/output mode.
2 parents 585b369 + fac01e3 commit f4f34a0

File tree

1 file changed

+3
-3
lines changed
  • libraries/mbed/targets/hal/STM/TARGET_STM32F4XX

1 file changed

+3
-3
lines changed

libraries/mbed/targets/hal/STM/TARGET_STM32F4XX/gpio_api.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ uint32_t gpio_set(PinName pin) {
2222
// Enable GPIO peripheral clock
2323
RCC->AHB1ENR |= 1 << port_index;
2424

25-
pin_function(pin, 0);
25+
pin_function(pin, STM_PIN_DATA(0, 0));
2626
return 1 << ((uint32_t) pin & 0xF);
2727
}
2828

@@ -55,7 +55,7 @@ void gpio_mode(gpio_t *obj, PinMode mode) {
5555

5656
void gpio_dir(gpio_t *obj, PinDirection direction) {
5757
switch (direction) {
58-
case PIN_INPUT : pin_function(obj->pin, 0); break;
59-
case PIN_OUTPUT: pin_function(obj->pin, 1); break;
58+
case PIN_INPUT : pin_function(obj->pin, STM_PIN_DATA(0, 0)); break;
59+
case PIN_OUTPUT: pin_function(obj->pin, STM_PIN_DATA(1, 0)); break;
6060
}
6161
}

0 commit comments

Comments
 (0)