Skip to content

Commit 453b248

Browse files
committed
STM32: gpio SPEED - always set High Speed by default
Up to now, speed was set for outputs and alternate, but this is also valid for input configuration. By default, let's configure high speed. This is done firts, because speed for some families like F1 is mixed with Input/Output mode settings, so can be later over-ridden if needed.
1 parent 3a27568 commit 453b248

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)