File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -83,19 +83,20 @@ void pin_function(PinName pin, int data) {
83
83
// Enable GPIO clock
84
84
uint32_t gpio_add = Set_GPIO_Clock (port_index );
85
85
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
+
87
93
// Configure GPIO
88
94
GPIO_InitStructure .GPIO_Pin = (uint16_t )(1 << pin_index );
89
95
GPIO_InitStructure .GPIO_Mode = (GPIOMode_TypeDef )mode ;
90
96
GPIO_InitStructure .GPIO_Speed = GPIO_Speed_40MHz ;
91
97
GPIO_InitStructure .GPIO_OType = (GPIOOType_TypeDef )otype ;
92
98
GPIO_InitStructure .GPIO_PuPd = (GPIOPuPd_TypeDef )pupd ;
93
99
GPIO_Init (gpio , & GPIO_InitStructure );
94
-
95
- // Configure Alternate Function
96
- if (afnum != 0xFF ) {
97
- GPIO_PinAFConfig (gpio , (uint16_t )pin_index , afnum );
98
- }
99
100
100
101
// *** TODO ***
101
102
// Disconnect JTAG-DP + SW-DP signals.
You can’t perform that action at this time.
0 commit comments