File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -90,20 +90,21 @@ void pin_function(PinName pin, int data) {
90
90
// Enable GPIO clock
91
91
uint32_t gpio_add = Set_GPIO_Clock (port_index );
92
92
gpio = (GPIO_TypeDef * )gpio_add ;
93
-
93
+
94
94
// Enable AFIO clock
95
95
RCC_APB2PeriphClockCmd (RCC_APB2Periph_AFIO , ENABLE );
96
+
97
+ // Configure Alternate Function
98
+ // Warning: Must be done before the GPIO is initialized
99
+ if (afnum > 0 ) {
100
+ GPIO_PinRemapConfig (AF_mapping [afnum ], ENABLE );
101
+ }
96
102
97
103
// Configure GPIO
98
104
GPIO_InitStructure .GPIO_Pin = (uint16_t )(1 << pin_index );
99
105
GPIO_InitStructure .GPIO_Mode = (GPIOMode_TypeDef )mode ;
100
106
GPIO_InitStructure .GPIO_Speed = GPIO_Speed_50MHz ;
101
107
GPIO_Init (gpio , & GPIO_InitStructure );
102
-
103
- // Configure Alternate Function
104
- if (afnum > 0 ) {
105
- GPIO_PinRemapConfig (AF_mapping [afnum ], ENABLE );
106
- }
107
108
108
109
// Disconnect JTAG-DP + SW-DP signals.
109
110
// Warning: Need to reconnect under reset
You can’t perform that action at this time.
0 commit comments