aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple/gpio.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmaple/gpio.c')
-rw-r--r--libmaple/gpio.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/libmaple/gpio.c b/libmaple/gpio.c
index 5484e21..c250f68 100644
--- a/libmaple/gpio.c
+++ b/libmaple/gpio.c
@@ -174,3 +174,17 @@ void afio_exti_select(afio_exti_num exti, afio_exti_port gpio_port) {
cr |= gpio_port << shift;
*exti_cr = cr;
}
+
+/**
+ * @brief Remap an alternate function peripheral to a different pin
+ * mapping
+ * @param peripheral to remap
+ */
+void afio_remap(AFIORemapPeripheral p) {
+ if (p & AFIO_REMAP_USE_MAPR2) {
+ p &= ~AFIO_REMAP_USE_MAPR2;
+ AFIO_BASE->MAPR2 |= p;
+ } else {
+ AFIO_BASE->MAPR |= p;
+ }
+}