Skip to content

Commit ede2a11

Browse files
authored
Merge pull request #3840 from LMESTM/fix_smt32_gpio_default_speed
STM32: gpio SPEED - always set High Speed by default
2 parents 1be7418 + 453b248 commit ede2a11

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

targets/TARGET_STM/pinmap.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ void pin_function(PinName pin, int data)
7171
// Enable GPIO clock
7272
GPIO_TypeDef *gpio = Set_GPIO_Clock(port);
7373

74+
/* Set default speed to high.
75+
* This is done before other settings on purpose:
76+
* For most families there are dedicated registers so it is
77+
* not so important, register can be set at any time.
78+
* But for families like F1, speed only applies to output. so we set
79+
* it here, and then if input is selected, this setting might be
80+
* overriden by the input one.
81+
*/
82+
LL_GPIO_SetPinSpeed(gpio, ll_pin, LL_GPIO_SPEED_FREQ_HIGH);
83+
7484
switch (mode) {
7585
case STM_PIN_INPUT:
7686
ll_mode = LL_GPIO_MODE_INPUT;
@@ -103,7 +113,6 @@ void pin_function(PinName pin, int data)
103113

104114
/* For now by default use Speed HIGH for output or alt modes */
105115
if ((mode == STM_PIN_OUTPUT) ||(mode == STM_PIN_ALTERNATE)) {
106-
LL_GPIO_SetPinSpeed(gpio, ll_pin, LL_GPIO_SPEED_FREQ_HIGH);
107116
if (STM_PIN_OD(data)) {
108117
LL_GPIO_SetPinOutputType(gpio, ll_pin, LL_GPIO_OUTPUT_OPENDRAIN);
109118
} else {

0 commit comments

Comments
 (0)