Skip to content
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

boards/common/blxxxpill: Fix pin conflicts in periph_conf #18785

Merged
merged 4 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
cpu/stm32/periph_qdec: support pin remap for F1
Add support to route peripheral to alternative pins for the STM32F1
family.
  • Loading branch information
Marian Buschsieweke committed Oct 27, 2022
commit b6845cef79b499d253a08aaaba869141b44b37f4
5 changes: 4 additions & 1 deletion cpu/stm32/include/periph/cpu_qdec.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ typedef struct {
uint32_t rcc_mask; /**< bit in clock enable register */
qdec_chan_t chan[QDEC_CHAN]; /**< channel mapping, set to {GPIO_UNDEF, 0}
* if not used */
#ifndef CPU_FAM_STM32F1
#ifdef CPU_FAM_STM32F1
uint32_t remap; /**< AFIO remap mask to route periph to other
pins (or zero, if not needed) */
#else
gpio_af_t af; /**< alternate function used */
#endif
uint8_t bus; /**< APB bus */
Expand Down
12 changes: 12 additions & 0 deletions cpu/stm32/periph/qdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#include "periph/qdec.h"
#include "periph/gpio.h"

#define ENABLE_DEBUG 0
#include "debug.h"

#ifdef QDEC_NUMOF

/**
Expand Down Expand Up @@ -59,6 +62,15 @@ int32_t qdec_init(qdec_t qdec, qdec_mode_t mode, qdec_cb_t cb, void *arg)
/* Power on the used timer */
periph_clk_en(qdec_config[qdec].bus, qdec_config[qdec].rcc_mask);

/* Route peripheral to correct pins (STM32F1 only, other MCU families route
* pins to peripheral rather than peripheral to pins */
#ifdef CPU_FAM_STM32F1
DEBUG("[qdec] AFIO->MAPR = 0x%" PRIx32 ", |= 0x%" PRIx32 "\n",
AFIO->MAPR, qdec_config[qdec].remap);
AFIO->MAPR |= qdec_config[qdec].remap;
DEBUG("[qdec] AFIO->MAPR = 0x%" PRIx32 "\n", AFIO->MAPR);
#endif

/* Reset configuration and CC channels */
dev(qdec)->CR1 = 0;
dev(qdec)->CR2 = 0;
Expand Down