mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-16 18:13:49 +01:00
cpu/stm32/periph_qdec: support pin remap for F1
Add support to route peripheral to alternative pins for the STM32F1 family.
This commit is contained in:
parent
16df27c51d
commit
b6845cef79
@ -52,7 +52,10 @@ typedef struct {
|
|||||||
uint32_t rcc_mask; /**< bit in clock enable register */
|
uint32_t rcc_mask; /**< bit in clock enable register */
|
||||||
qdec_chan_t chan[QDEC_CHAN]; /**< channel mapping, set to {GPIO_UNDEF, 0}
|
qdec_chan_t chan[QDEC_CHAN]; /**< channel mapping, set to {GPIO_UNDEF, 0}
|
||||||
* if not used */
|
* 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 */
|
gpio_af_t af; /**< alternate function used */
|
||||||
#endif
|
#endif
|
||||||
uint8_t bus; /**< APB bus */
|
uint8_t bus; /**< APB bus */
|
||||||
|
|||||||
@ -26,6 +26,9 @@
|
|||||||
#include "periph/qdec.h"
|
#include "periph/qdec.h"
|
||||||
#include "periph/gpio.h"
|
#include "periph/gpio.h"
|
||||||
|
|
||||||
|
#define ENABLE_DEBUG 0
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
#ifdef QDEC_NUMOF
|
#ifdef QDEC_NUMOF
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -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 */
|
/* Power on the used timer */
|
||||||
periph_clk_en(qdec_config[qdec].bus, qdec_config[qdec].rcc_mask);
|
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 */
|
/* Reset configuration and CC channels */
|
||||||
dev(qdec)->CR1 = 0;
|
dev(qdec)->CR1 = 0;
|
||||||
dev(qdec)->CR2 = 0;
|
dev(qdec)->CR2 = 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user