aboutsummaryrefslogtreecommitdiffstats
path: root/src/stm32/stm32f1.c
diff options
context:
space:
mode:
authorMichael Kurz <michi.kurz@gmail.com>2021-03-25 20:39:53 +0100
committerKevin O'Connor <kevin@koconnor.net>2021-03-26 12:04:51 -0400
commit59c4c498938f2c85c735034ed8f7b188725f07c9 (patch)
tree2f164d8a1ed33e75028158058dc3d9b1f3a9d0ca /src/stm32/stm32f1.c
parent39188e1cf3f84a8bbf039be4b327a032f551d3bd (diff)
downloadkutter-59c4c498938f2c85c735034ed8f7b188725f07c9.tar.gz
kutter-59c4c498938f2c85c735034ed8f7b188725f07c9.tar.xz
kutter-59c4c498938f2c85c735034ed8f7b188725f07c9.zip
stm32: Add hardware PWM support for STM32F1
This adds hardware PWM support for STM32F1 processors. This should also work for STM32 F0/F2/F4 processors, but I don't have one of those to test it. Signed-off-by: Michael Kurz <michi.kurz@gmail.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/stm32/stm32f1.c')
-rw-r--r--src/stm32/stm32f1.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/stm32/stm32f1.c b/src/stm32/stm32f1.c
index 6480b678..ae8fcd67 100644
--- a/src/stm32/stm32f1.c
+++ b/src/stm32/stm32f1.c
@@ -134,6 +134,35 @@ gpio_peripheral(uint32_t gpio, uint32_t mode, int pullup)
stm32f1_alternative_remap(AFIO_MAPR_I2C1_REMAP_Msk,
AFIO_MAPR_I2C1_REMAP);
}
+ } else if ((gpio == GPIO('A', 15)
+ || gpio == GPIO('B', 3)) && (func == 1)) {
+ // TIM2 CH1/2
+ stm32f1_alternative_remap(AFIO_MAPR_TIM2_REMAP_PARTIALREMAP1_Msk,
+ AFIO_MAPR_TIM2_REMAP_PARTIALREMAP1);
+ } else if ((gpio == GPIO('B', 10)
+ || gpio == GPIO('B', 11)) && (func == 1)) {
+ // TIM2 CH3/4
+ stm32f1_alternative_remap(AFIO_MAPR_TIM2_REMAP_PARTIALREMAP2_Msk,
+ AFIO_MAPR_TIM2_REMAP_PARTIALREMAP2);
+ } else if ((gpio == GPIO('B', 4)
+ || gpio == GPIO('B', 5)) && (func == 2)) {
+ // TIM3 partial remap
+ stm32f1_alternative_remap(AFIO_MAPR_TIM3_REMAP_PARTIALREMAP_Msk,
+ AFIO_MAPR_TIM3_REMAP_PARTIALREMAP);
+ } else if ((gpio == GPIO('C', 6)
+ || gpio == GPIO('C', 7)
+ || gpio == GPIO('C', 8)
+ || gpio == GPIO('C', 9)) && (func == 2)) {
+ // TIM3 full remap
+ stm32f1_alternative_remap(AFIO_MAPR_TIM3_REMAP_FULLREMAP_Msk,
+ AFIO_MAPR_TIM3_REMAP_FULLREMAP);
+ } else if ((gpio == GPIO('D', 12)
+ || gpio == GPIO('D', 13)
+ || gpio == GPIO('D', 14)
+ || gpio == GPIO('D', 15)) && (func == 2)) {
+ // TIM4
+ stm32f1_alternative_remap(AFIO_MAPR_TIM4_REMAP_Msk,
+ AFIO_MAPR_TIM4_REMAP);
}
// Add more as needed
}