Skip to content

Commit 3ace84a

Browse files
committed
[NUCLEO_F030R8] Change AF setting before GPIO setting
1 parent 955223f commit 3ace84a

File tree

1 file changed

+6
-5
lines changed
  • libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8

1 file changed

+6
-5
lines changed

libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/pinmap.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ void pin_function(PinName pin, int data) {
8383
// Enable GPIO clock
8484
uint32_t gpio_add = Set_GPIO_Clock(port_index);
8585
gpio = (GPIO_TypeDef *)gpio_add;
86+
87+
// Configure Alternate Function
88+
// Warning: Must be done before the GPIO is initialized
89+
if (afnum != 0xFF) {
90+
GPIO_PinAFConfig(gpio, (uint16_t)pin_index, afnum);
91+
}
8692

8793
// Configure GPIO
8894
GPIO_InitStructure.GPIO_Pin = (uint16_t)(1 << pin_index);
@@ -91,11 +97,6 @@ void pin_function(PinName pin, int data) {
9197
GPIO_InitStructure.GPIO_OType = (GPIOOType_TypeDef)otype;
9298
GPIO_InitStructure.GPIO_PuPd = (GPIOPuPd_TypeDef)pupd;
9399
GPIO_Init(gpio, &GPIO_InitStructure);
94-
95-
// Configure Alternate Function
96-
if (afnum != 0xFF) {
97-
GPIO_PinAFConfig(gpio, (uint16_t)pin_index, afnum);
98-
}
99100

100101
// *** TODO ***
101102
// Disconnect JTAG-DP + SW-DP signals.

0 commit comments

Comments
 (0)