Skip to content

STM32: gpio SPEED - always set High Speed by default #3840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion targets/TARGET_STM/pinmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ void pin_function(PinName pin, int data)
// Enable GPIO clock
GPIO_TypeDef *gpio = Set_GPIO_Clock(port);

/* Set default speed to high.
* This is done before other settings on purpose:
* For most families there are dedicated registers so it is
* not so important, register can be set at any time.
* But for families like F1, speed only applies to output. so we set
* it here, and then if input is selected, this setting might be
* overriden by the input one.
*/
LL_GPIO_SetPinSpeed(gpio, ll_pin, LL_GPIO_SPEED_FREQ_HIGH);

switch (mode) {
case STM_PIN_INPUT:
ll_mode = LL_GPIO_MODE_INPUT;
Expand Down Expand Up @@ -103,7 +113,6 @@ void pin_function(PinName pin, int data)

/* For now by default use Speed HIGH for output or alt modes */
if ((mode == STM_PIN_OUTPUT) ||(mode == STM_PIN_ALTERNATE)) {
LL_GPIO_SetPinSpeed(gpio, ll_pin, LL_GPIO_SPEED_FREQ_HIGH);
if (STM_PIN_OD(data)) {
LL_GPIO_SetPinOutputType(gpio, ll_pin, LL_GPIO_OUTPUT_OPENDRAIN);
} else {
Expand Down