stm32: Rework #if pin definition clauses in hard_pwm.c

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2021-10-11 21:43:37 -04:00
parent dbafeb8876
commit 9d9fe3cb1b
1 changed files with 83 additions and 87 deletions

View File

@ -20,7 +20,89 @@ struct gpio_pwm_info {
};
static const struct gpio_pwm_info pwm_regs[] = {
#if CONFIG_MACH_STM32H7
#if CONFIG_MACH_STM32F103
{TIM2, GPIO('A', 0), 1, GPIO_FUNCTION(2)},
{TIM2, GPIO('A', 1), 2, GPIO_FUNCTION(2)},
{TIM2, GPIO('A', 2), 3, GPIO_FUNCTION(2)},
{TIM2, GPIO('A', 3), 4, GPIO_FUNCTION(2)},
{TIM2, GPIO('A', 15), 1, GPIO_FUNCTION(1)},
{TIM2, GPIO('B', 3), 2, GPIO_FUNCTION(1)},
{TIM2, GPIO('B', 10), 3, GPIO_FUNCTION(1)},
{TIM2, GPIO('B', 11), 4, GPIO_FUNCTION(1)},
{TIM3, GPIO('A', 6), 1, GPIO_FUNCTION(1)},
{TIM3, GPIO('A', 7), 2, GPIO_FUNCTION(1)},
{TIM3, GPIO('B', 0), 3, GPIO_FUNCTION(1)},
{TIM3, GPIO('B', 1), 4, GPIO_FUNCTION(1)},
{TIM3, GPIO('C', 6), 1, GPIO_FUNCTION(2)},
{TIM3, GPIO('C', 7), 2, GPIO_FUNCTION(2)},
{TIM3, GPIO('C', 8), 3, GPIO_FUNCTION(2)},
{TIM3, GPIO('C', 9), 4, GPIO_FUNCTION(2)},
{TIM4, GPIO('D', 12), 1, GPIO_FUNCTION(2)},
{TIM4, GPIO('D', 13), 2, GPIO_FUNCTION(2)},
{TIM4, GPIO('D', 14), 3, GPIO_FUNCTION(2)},
{TIM4, GPIO('D', 15), 4, GPIO_FUNCTION(2)},
{TIM4, GPIO('B', 6), 1, GPIO_FUNCTION(2)},
{TIM4, GPIO('B', 7), 2, GPIO_FUNCTION(2)},
{TIM4, GPIO('B', 8), 3, GPIO_FUNCTION(2)},
{TIM4, GPIO('B', 9), 4, GPIO_FUNCTION(2)}
#elif CONFIG_MACH_STM32F4
#if CONFIG_MACH_STM32F401
{TIM3, GPIO('A', 6), 1, GPIO_FUNCTION(2)},
{TIM3, GPIO('C', 6), 1, GPIO_FUNCTION(3)},
{TIM3, GPIO('A', 7), 2, GPIO_FUNCTION(2)},
{TIM3, GPIO('C', 7), 2, GPIO_FUNCTION(3)},
{TIM3, GPIO('C', 8), 3, GPIO_FUNCTION(3)},
{TIM3, GPIO('C', 9), 4, GPIO_FUNCTION(3)},
#endif
#if CONFIG_MACH_STM32F446
{TIM2, GPIO('B', 2), 4, GPIO_FUNCTION(1)},
#endif
#if CONFIG_MACH_STM32F4x5 || CONFIG_MACH_STM32F446
{TIM8, GPIO('C', 6), 1, GPIO_FUNCTION(3)},
{TIM8, GPIO('C', 7), 2, GPIO_FUNCTION(3)},
{TIM8, GPIO('C', 8), 3, GPIO_FUNCTION(3)},
{TIM8, GPIO('C', 9), 4, GPIO_FUNCTION(3)},
{TIM11, GPIO('F', 7), 1, GPIO_FUNCTION(3)},
{TIM12, GPIO('B', 14), 1, GPIO_FUNCTION(9)},
{TIM12, GPIO('B', 15), 2, GPIO_FUNCTION(9)},
{TIM13, GPIO('A', 6), 1, GPIO_FUNCTION(9)},
{TIM13, GPIO('F', 8), 1, GPIO_FUNCTION(9)},
{TIM14, GPIO('A', 7), 1, GPIO_FUNCTION(9)},
{TIM14, GPIO('F', 9), 1, GPIO_FUNCTION(9)},
#endif
// Pins that map to all klipper defined STM32F4 procs
{TIM1, GPIO('A', 8), 1, GPIO_FUNCTION(1)},
{TIM1, GPIO('E', 9), 1, GPIO_FUNCTION(1)},
{TIM1, GPIO('A', 9), 2, GPIO_FUNCTION(1)},
{TIM1, GPIO('E', 11), 2, GPIO_FUNCTION(1)},
{TIM1, GPIO('A', 10), 3, GPIO_FUNCTION(1)},
{TIM1, GPIO('E', 13), 3, GPIO_FUNCTION(1)},
{TIM1, GPIO('A', 11), 4, GPIO_FUNCTION(1)},
{TIM1, GPIO('E', 14), 4, GPIO_FUNCTION(1)},
{TIM2, GPIO('A', 5), 1, GPIO_FUNCTION(1)},
{TIM2, GPIO('A', 15), 1, GPIO_FUNCTION(1)},
{TIM2, GPIO('B', 3), 2, GPIO_FUNCTION(1)},
{TIM2, GPIO('B', 10), 3, GPIO_FUNCTION(1)},
{TIM2, GPIO('B', 11), 4, GPIO_FUNCTION(1)},
{TIM3, GPIO('B', 4), 1, GPIO_FUNCTION(2)},
{TIM3, GPIO('B', 5), 2, GPIO_FUNCTION(2)},
{TIM3, GPIO('B', 0), 3, GPIO_FUNCTION(2)},
{TIM3, GPIO('B', 1), 4, GPIO_FUNCTION(2)},
{TIM4, GPIO('B', 6), 1, GPIO_FUNCTION(2)},
{TIM4, GPIO('D', 12), 1, GPIO_FUNCTION(2)},
{TIM4, GPIO('B', 7), 2, GPIO_FUNCTION(2)},
{TIM4, GPIO('D', 13), 2, GPIO_FUNCTION(2)},
{TIM4, GPIO('D', 14), 3, GPIO_FUNCTION(2)},
{TIM4, GPIO('D', 15), 4, GPIO_FUNCTION(2)},
{TIM5, GPIO('A', 0), 1, GPIO_FUNCTION(2)},
{TIM5, GPIO('A', 1), 2, GPIO_FUNCTION(2)},
{TIM5, GPIO('A', 2), 3, GPIO_FUNCTION(2)},
{TIM5, GPIO('A', 3), 4, GPIO_FUNCTION(2)},
{TIM9, GPIO('E', 5), 1, GPIO_FUNCTION(3)},
{TIM9, GPIO('E', 6), 2, GPIO_FUNCTION(3)},
{TIM10, GPIO('B', 8), 1, GPIO_FUNCTION(3)},
{TIM11, GPIO('B', 9), 1, GPIO_FUNCTION(3)}
#elif CONFIG_MACH_STM32H7
{TIM2, GPIO('A', 0), 1, GPIO_FUNCTION(1)},
{TIM2, GPIO('A', 5), 1, GPIO_FUNCTION(1)},
{TIM2, GPIO('A', 15), 1, GPIO_FUNCTION(1)},
@ -63,92 +145,6 @@ static const struct gpio_pwm_info pwm_regs[] = {
{TIM17, GPIO('F', 7), 1, GPIO_FUNCTION(1)},
{TIM17, GPIO('B', 9), 1, GPIO_FUNCTION(1)}
#endif
#if CONFIG_MACH_STM32F103
{TIM2, GPIO('A', 0), 1, GPIO_FUNCTION(2)},
{TIM2, GPIO('A', 1), 2, GPIO_FUNCTION(2)},
{TIM2, GPIO('A', 2), 3, GPIO_FUNCTION(2)},
{TIM2, GPIO('A', 3), 4, GPIO_FUNCTION(2)},
{TIM2, GPIO('A', 15), 1, GPIO_FUNCTION(1)},
{TIM2, GPIO('B', 3), 2, GPIO_FUNCTION(1)},
{TIM2, GPIO('B', 10), 3, GPIO_FUNCTION(1)},
{TIM2, GPIO('B', 11), 4, GPIO_FUNCTION(1)},
{TIM3, GPIO('A', 6), 1, GPIO_FUNCTION(1)},
{TIM3, GPIO('A', 7), 2, GPIO_FUNCTION(1)},
{TIM3, GPIO('B', 0), 3, GPIO_FUNCTION(1)},
{TIM3, GPIO('B', 1), 4, GPIO_FUNCTION(1)},
{TIM3, GPIO('C', 6), 1, GPIO_FUNCTION(2)},
{TIM3, GPIO('C', 7), 2, GPIO_FUNCTION(2)},
{TIM3, GPIO('C', 8), 3, GPIO_FUNCTION(2)},
{TIM3, GPIO('C', 9), 4, GPIO_FUNCTION(2)},
{TIM4, GPIO('D', 12), 1, GPIO_FUNCTION(2)},
{TIM4, GPIO('D', 13), 2, GPIO_FUNCTION(2)},
{TIM4, GPIO('D', 14), 3, GPIO_FUNCTION(2)},
{TIM4, GPIO('D', 15), 4, GPIO_FUNCTION(2)},
{TIM4, GPIO('B', 6), 1, GPIO_FUNCTION(2)},
{TIM4, GPIO('B', 7), 2, GPIO_FUNCTION(2)},
{TIM4, GPIO('B', 8), 3, GPIO_FUNCTION(2)},
{TIM4, GPIO('B', 9), 4, GPIO_FUNCTION(2)}
#endif
#if CONFIG_MACH_STM32F401
{TIM3, GPIO('A', 6), 1, GPIO_FUNCTION(2)},
{TIM3, GPIO('C', 6), 1, GPIO_FUNCTION(3)},
{TIM3, GPIO('A', 7), 2, GPIO_FUNCTION(2)},
{TIM3, GPIO('C', 7), 2, GPIO_FUNCTION(3)},
{TIM3, GPIO('C', 8), 3, GPIO_FUNCTION(3)},
{TIM3, GPIO('C', 9), 4, GPIO_FUNCTION(3)},
#endif
#if CONFIG_MACH_STM32F446
{TIM2, GPIO('B', 2), 4, GPIO_FUNCTION(1)},
#endif
#if CONFIG_MACH_STM32F405 || \
CONFIG_MACH_STM32F407 || \
CONFIG_MACH_STM32F429 || \
CONFIG_MACH_STM32F446
{TIM8, GPIO('C', 6), 1, GPIO_FUNCTION(3)},
{TIM8, GPIO('C', 7), 2, GPIO_FUNCTION(3)},
{TIM8, GPIO('C', 8), 3, GPIO_FUNCTION(3)},
{TIM8, GPIO('C', 9), 4, GPIO_FUNCTION(3)},
{TIM11, GPIO('F', 7), 1, GPIO_FUNCTION(3)},
{TIM12, GPIO('B', 14), 1, GPIO_FUNCTION(9)},
{TIM12, GPIO('B', 15), 2, GPIO_FUNCTION(9)},
{TIM13, GPIO('A', 6), 1, GPIO_FUNCTION(9)},
{TIM13, GPIO('F', 8), 1, GPIO_FUNCTION(9)},
{TIM14, GPIO('A', 7), 1, GPIO_FUNCTION(9)},
{TIM14, GPIO('F', 9), 1, GPIO_FUNCTION(9)},
#endif
#if CONFIG_MACH_STM32F4 // Pins that map to all klipper defined STM32F4 procs
{TIM1, GPIO('A', 8), 1, GPIO_FUNCTION(1)},
{TIM1, GPIO('E', 9), 1, GPIO_FUNCTION(1)},
{TIM1, GPIO('A', 9), 2, GPIO_FUNCTION(1)},
{TIM1, GPIO('E', 11), 2, GPIO_FUNCTION(1)},
{TIM1, GPIO('A', 10), 3, GPIO_FUNCTION(1)},
{TIM1, GPIO('E', 13), 3, GPIO_FUNCTION(1)},
{TIM1, GPIO('A', 11), 4, GPIO_FUNCTION(1)},
{TIM1, GPIO('E', 14), 4, GPIO_FUNCTION(1)},
{TIM2, GPIO('A', 5), 1, GPIO_FUNCTION(1)},
{TIM2, GPIO('A', 15), 1, GPIO_FUNCTION(1)},
{TIM2, GPIO('B', 3), 2, GPIO_FUNCTION(1)},
{TIM2, GPIO('B', 10), 3, GPIO_FUNCTION(1)},
{TIM2, GPIO('B', 11), 4, GPIO_FUNCTION(1)},
{TIM3, GPIO('B', 4), 1, GPIO_FUNCTION(2)},
{TIM3, GPIO('B', 5), 2, GPIO_FUNCTION(2)},
{TIM3, GPIO('B', 0), 3, GPIO_FUNCTION(2)},
{TIM3, GPIO('B', 1), 4, GPIO_FUNCTION(2)},
{TIM4, GPIO('B', 6), 1, GPIO_FUNCTION(2)},
{TIM4, GPIO('D', 12), 1, GPIO_FUNCTION(2)},
{TIM4, GPIO('B', 7), 2, GPIO_FUNCTION(2)},
{TIM4, GPIO('D', 13), 2, GPIO_FUNCTION(2)},
{TIM4, GPIO('D', 14), 3, GPIO_FUNCTION(2)},
{TIM4, GPIO('D', 15), 4, GPIO_FUNCTION(2)},
{TIM5, GPIO('A', 0), 1, GPIO_FUNCTION(2)},
{TIM5, GPIO('A', 1), 2, GPIO_FUNCTION(2)},
{TIM5, GPIO('A', 2), 3, GPIO_FUNCTION(2)},
{TIM5, GPIO('A', 3), 4, GPIO_FUNCTION(2)},
{TIM9, GPIO('E', 5), 1, GPIO_FUNCTION(3)},
{TIM9, GPIO('E', 6), 2, GPIO_FUNCTION(3)},
{TIM10, GPIO('B', 8), 1, GPIO_FUNCTION(3)},
{TIM11, GPIO('B', 9), 1, GPIO_FUNCTION(3)}
#endif
};
struct gpio_pwm