Skip to content

Commit 90f7a2b

Browse files
committed
[NUCLEO_L152RE] Change AF setting before GPIO setting
1 parent f712477 commit 90f7a2b

File tree

1 file changed

+7
-6
lines changed
  • libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE

1 file changed

+7
-6
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,20 @@ 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-
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+
}
92+
8793
// Configure GPIO
8894
GPIO_InitStructure.GPIO_Pin = (uint16_t)(1 << pin_index);
8995
GPIO_InitStructure.GPIO_Mode = (GPIOMode_TypeDef)mode;
9096
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;
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)