diff --git a/src/main/drivers/timer.h b/src/main/drivers/timer.h index f05a33899..ead0649cd 100644 --- a/src/main/drivers/timer.h +++ b/src/main/drivers/timer.h @@ -56,6 +56,7 @@ typedef uint32_t timCNT_t; typedef enum { TIM_USE_ANY = 0x0, + TIM_USE_NONE = 0x0, TIM_USE_PPM = 0x1, TIM_USE_PWM = 0x2, TIM_USE_MOTOR = 0x4, diff --git a/src/main/drivers/timer_def.h b/src/main/drivers/timer_def.h index f5ba7d162..d32716b1a 100644 --- a/src/main/drivers/timer_def.h +++ b/src/main/drivers/timer_def.h @@ -20,7 +20,43 @@ #include #include "common/utils.h" -#if defined(STM32F3) +#if defined(STM32F1) + +#define DEF_TIM(tim, chan, pin, flags, out) {\ + tim,\ + IO_TAG(pin),\ + EXPAND(DEF_CHAN_ ## chan),\ + flags,\ + (DEF_CHAN_ ## chan ## _OUTPUT | out),\ + CONCAT(EXPAND(DEF_TIM_DMA__ ## tim ## _ ## chan), _CHANNEL),\ + CONCAT(EXPAND(DEF_TIM_DMA__ ## tim ## _ ## chan), _HANDLER)\ + } + +#define DEF_DMA_CHANNEL(tim, chan) CONCAT(EXPAND(DEF_TIM_DMA__ ## tim ## _ ## chan), _CHANNEL) +#define DEF_DMA_HANDLER(tim, chan) CONCAT(EXPAND(DEF_TIM_DMA__ ## tim ## _ ## chan), _HANDLER) + +/* add the DMA mappings here for F1 */ +#define DEF_TIM_DMA__TIM1_CH1 DMA1_CH2 +#define DEF_TIM_DMA__TIM1_CH2 DMA_NONE +#define DEF_TIM_DMA__TIM1_CH3 DMA1_CH6 +#define DEF_TIM_DMA__TIM1_CH4 DMA1_CH4 + +#define DEF_TIM_DMA__TIM2_CH1 DMA1_CH5 +#define DEF_TIM_DMA__TIM2_CH2 DMA1_CH7 +#define DEF_TIM_DMA__TIM2_CH3 DMA1_CH1 +#define DEF_TIM_DMA__TIM2_CH4 DMA1_CH7 + +#define DEF_TIM_DMA__TIM3_CH1 DMA1_CH6 +#define DEF_TIM_DMA__TIM3_CH2 DMA_NONE +#define DEF_TIM_DMA__TIM3_CH3 DMA1_CH2 +#define DEF_TIM_DMA__TIM3_CH4 DMA1_CH3 + +#define DEF_TIM_DMA__TIM4_CH1 DMA1_CH1 +#define DEF_TIM_DMA__TIM4_CH2 DMA1_CH4 +#define DEF_TIM_DMA__TIM4_CH3 DMA1_CH5 +#define DEF_TIM_DMA__TIM4_CH4 DMA_NONE + +#elif defined(STM32F3) #define DEF_TIM(tim, chan, pin, flags, out) {\ tim,\ @@ -100,27 +136,12 @@ #define DEF_TIM_DMA__TIM8_CH2N DMA2_CH5 -#define DMA1_CH1_CHANNEL DMA1_Channel1 -#define DMA1_CH2_CHANNEL DMA1_Channel2 -#define DMA1_CH3_CHANNEL DMA1_Channel3 -#define DMA1_CH4_CHANNEL DMA1_Channel4 -#define DMA1_CH5_CHANNEL DMA1_Channel5 -#define DMA1_CH6_CHANNEL DMA1_Channel6 -#define DMA1_CH7_CHANNEL DMA1_Channel7 -#define DMA2_CH1_CHANNEL DMA2_Channel1 -#define DMA2_CH2_CHANNEL DMA2_Channel2 -#define DMA2_CH3_CHANNEL DMA2_Channel3 -#define DMA2_CH4_CHANNEL DMA2_Channel4 -#define DMA2_CH5_CHANNEL DMA2_Channel5 -#define DMA2_CH6_CHANNEL DMA2_Channel6 -#define DMA2_CH7_CHANNEL DMA2_Channel7 - #define GPIO_AF(p, t) CONCAT(GPIO_AF__, p, _, t) #define GPIO_AF__PA0_TIM2_CH1 GPIO_AF_1 #define GPIO_AF__PA1_TIM2_CH2 GPIO_AF_1 #define GPIO_AF__PA2_TIM2_CH3 GPIO_AF_1 -#define GPIO_AF__PA3_TIM2_CH3 GPIO_AF_1 +#define GPIO_AF__PA3_TIM2_CH4 GPIO_AF_1 #define GPIO_AF__PA5_TIM2_CH1 GPIO_AF_1 #define GPIO_AF__PA6_TIM16_CH1 GPIO_AF_1 #define GPIO_AF__PA7_TIM17_CH1 GPIO_AF_1 @@ -221,6 +242,9 @@ #define GPIO_AF__PD1_TIM8_CH4 GPIO_AF_4 +#define GPIO_AF__PF9_TIM15_CH1 GPIO_AF_3 +#define GPIO_AF__PF10_TIM15_CH2 GPIO_AF_3 + #elif defined(STM32F4) #define DMA_OPT_FIRST 0 @@ -425,3 +449,18 @@ #define DEF_CHAN_CH2N_OUTPUT TIMER_OUTPUT_N_CHANNEL #define DEF_CHAN_CH3N_OUTPUT TIMER_OUTPUT_N_CHANNEL #define DEF_CHAN_CH4N_OUTPUT TIMER_OUTPUT_N_CHANNEL + +#define DMA1_CH1_CHANNEL DMA1_Channel1 +#define DMA1_CH2_CHANNEL DMA1_Channel2 +#define DMA1_CH3_CHANNEL DMA1_Channel3 +#define DMA1_CH4_CHANNEL DMA1_Channel4 +#define DMA1_CH5_CHANNEL DMA1_Channel5 +#define DMA1_CH6_CHANNEL DMA1_Channel6 +#define DMA1_CH7_CHANNEL DMA1_Channel7 +#define DMA2_CH1_CHANNEL DMA2_Channel1 +#define DMA2_CH2_CHANNEL DMA2_Channel2 +#define DMA2_CH3_CHANNEL DMA2_Channel3 +#define DMA2_CH4_CHANNEL DMA2_Channel4 +#define DMA2_CH5_CHANNEL DMA2_Channel5 +#define DMA2_CH6_CHANNEL DMA2_Channel6 +#define DMA2_CH7_CHANNEL DMA2_Channel7 \ No newline at end of file diff --git a/src/main/target/ALIENFLIGHTF3/target.c b/src/main/target/ALIENFLIGHTF3/target.c index 71849ec4d..65a745dd1 100644 --- a/src/main/target/ALIENFLIGHTF3/target.c +++ b/src/main/target/ALIENFLIGHTF3/target.c @@ -20,20 +20,22 @@ #include #include "drivers/io.h" +#include "drivers/dma.h" #include "drivers/timer.h" +#include "drivers/timer_def.h" const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { - // up to 10 Motor Outputs - { TIM15, IO_TAG(PB15), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_1 }, // PWM1 - PB15 - TIM1_CH3N, TIM15_CH1N, *TIM15_CH2 - { TIM15, IO_TAG(PB14), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_1 }, // PWM2 - PB14 - TIM1_CH2N, *TIM15_CH1 - { TIM1, IO_TAG(PA8), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_6 }, // PWM3 - PA8 - *TIM1_CH1, TIM4_ETR - { TIM3, IO_TAG(PB0), TIM_Channel_3, TIM_USE_PWM, 0, GPIO_AF_2 }, // PWM4 - PB0 - *TIM3_CH3, TIM1_CH2N, TIM8_CH2N - { TIM3, IO_TAG(PA6), TIM_Channel_1, TIM_USE_PWM, 0, GPIO_AF_2 }, // PWM5 - PA6 - *TIM3_CH1, TIM8_BKIN, TIM1_BKIN, TIM16_CH1 - { TIM2, IO_TAG(PA2), TIM_Channel_3, TIM_USE_PWM, 0, GPIO_AF_1 }, // PWM6 - PA2 - *TIM2_CH3, !TIM15_CH1 - { TIM3, IO_TAG(PB1), TIM_Channel_4, TIM_USE_PWM, 0, GPIO_AF_2 }, // PWM7 - PB1 - *TIM3_CH4, TIM1_CH3N, TIM8_CH3N - { TIM17, IO_TAG(PA7), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_1 }, // PWM8 - PA7 - !TIM3_CH2, *TIM17_CH1, TIM1_CH1N, TIM8_CH1 - { TIM3, IO_TAG(PA4), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_2 }, // PWM9 - PA4 - *TIM3_CH2 - { TIM2, IO_TAG(PA1), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_1 }, // PWM10 - PA1 - *TIM2_CH2, TIM15_CH1N - { TIM2, IO_TAG(PA3), TIM_Channel_4, TIM_USE_PWM | TIM_USE_PPM, 0, GPIO_AF_1 } // PPM - PA3 - TIM2_CH4, TIM15_CH2 - PWM13 + // up to 10 Motor Outputs + DEF_TIM(TIM15, CH2, PB15, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED), // PWM1 - PB15 - TIM1_CH3N, TIM15_CH1N, *TIM15_CH2 + DEF_TIM(TIM15, CH1, PB14, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED), // PWM2 - PB14 - TIM1_CH2N, *TIM15_CH1 + DEF_TIM(TIM1, CH1, PA8, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED), // PWM3 - PA8 - *TIM1_CH1, TIM4_ETR + DEF_TIM(TIM3, CH3, PB0, TIM_USE_PWM, TIMER_INPUT_ENABLED ), // PWM4 - PB0 - *TIM3_CH3, TIM1_CH2N, TIM8_CH2N + DEF_TIM(TIM3, CH1, PA6, TIM_USE_PWM, TIMER_INPUT_ENABLED ), // PWM5 - PA6 - *TIM3_CH1, TIM8_BKIN, TIM1_BKIN, TIM16_CH1 + DEF_TIM(TIM2, CH3, PA2, TIM_USE_PWM, TIMER_INPUT_ENABLED ), // PWM6 - PA2 - *TIM2_CH3, !TIM15_CH1 + DEF_TIM(TIM3, CH4, PB1, TIM_USE_PWM, TIMER_INPUT_ENABLED ), // PWM7 - PB1 - *TIM3_CH4, TIM1_CH3N, TIM8_CH3N + DEF_TIM(TIM17, CH1, PA7, TIM_USE_MOTOR, TIMER_OUTPUT_ENABLED), // PWM8 - PA7 - !TIM3_CH2, *TIM17_CH1, TIM1_CH1N, TIM8_CH1 + DEF_TIM(TIM3, CH2, PA4, TIM_USE_PWM, TIMER_INPUT_ENABLED ), // PWM9 - PA4 - *TIM3_CH2 + DEF_TIM(TIM2, CH2, PA1, TIM_USE_PWM, TIMER_INPUT_ENABLED ), // PWM10 - PA1 - *TIM2_CH2, TIM15_CH1N + DEF_TIM(TIM2, CH4, PA3, TIM_USE_PWM | TIM_USE_PPM, TIMER_INPUT_ENABLED ), // PPM - PA3 - TIM2_CH4, TIM15_CH2 - PWM13 }; diff --git a/src/main/target/ALIENFLIGHTF4/target.c b/src/main/target/ALIENFLIGHTF4/target.c index 9965a4e5c..a2d744fc6 100644 --- a/src/main/target/ALIENFLIGHTF4/target.c +++ b/src/main/target/ALIENFLIGHTF4/target.c @@ -20,21 +20,22 @@ #include #include "drivers/io.h" +#include "drivers/dma.h" #include "drivers/timer.h" +#include "drivers/timer_def.h" const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { - { TIM1, IO_TAG(PA8), TIM_Channel_1, TIM_USE_PWM | TIM_USE_PPM, 0, GPIO_AF_TIM1 }, // PWM1 - PA8 RC1 - { TIM1, IO_TAG(PB0), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_TIM1 }, // PWM2 - PB0 RC2 - { TIM1, IO_TAG(PB1), TIM_Channel_3, TIM_USE_PWM, 0, GPIO_AF_TIM1 }, // PWM3 - PB1 RC3 - { TIM8, IO_TAG(PB14),TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_TIM8 }, // PWM4 - PA14 RC4 - { TIM8, IO_TAG(PB15),TIM_Channel_3, TIM_USE_PWM, 0, GPIO_AF_TIM8 }, // PWM5 - PA15 RC5 - { TIM4, IO_TAG(PB8), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_TIM4 }, // PWM6 - PB8 OUT1 - { TIM4, IO_TAG(PB9), TIM_Channel_4, TIM_USE_MOTOR, 1, GPIO_AF_TIM4 }, // PWM7 - PB9 OUT2 - { TIM5, IO_TAG(PA0), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_TIM5 }, // PWM8 - PA0 OUT3 - { TIM5, IO_TAG(PA1), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_TIM5 }, // PWM9 - PA1 OUT4 - { TIM3, IO_TAG(PC6), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_TIM3 }, // PWM10 - PC6 OUT5 - { TIM3, IO_TAG(PC7), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_TIM3 }, // PWM11 - PC7 OUT6 - { TIM3, IO_TAG(PC8), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_TIM3 }, // PWM13 - PC8 OUT7 - { TIM3, IO_TAG(PC9), TIM_Channel_4, TIM_USE_MOTOR, 1, GPIO_AF_TIM3 }, // PWM13 - PC9 OUT8 + DEF_TIM(TIM1, CH1, PA8, TIM_USE_PWM | TIM_USE_PPM, 0, 0), // PWM1 - PA8 RC1 + DEF_TIM(TIM1, CH2, PB0, TIM_USE_PWM, 0, 0), // PWM2 - PB0 RC2 + DEF_TIM(TIM1, CH3, PB1, TIM_USE_PWM, 0, 0), // PWM3 - PB1 RC3 + DEF_TIM(TIM8, CH2, PB14, TIM_USE_PWM, 0, 0), // PWM4 - PA14 RC4 + DEF_TIM(TIM8, CH3, PB15, TIM_USE_PWM, 0, 0), // PWM5 - PA15 RC5 + DEF_TIM(TIM4, CH3, PB8, TIM_USE_MOTOR, 1, 0), // PWM6 - PB8 OUT1 + DEF_TIM(TIM4, CH4, PB9, TIM_USE_MOTOR, 1, 0), // PWM7 - PB9 OUT2 + DEF_TIM(TIM5, CH1, PA0, TIM_USE_MOTOR, 1, 0), // PWM8 - PA0 OUT3 + DEF_TIM(TIM5, CH2, PA1, TIM_USE_MOTOR, 1, 0), // PWM9 - PA1 OUT4 + DEF_TIM(TIM3, CH1, PC6, TIM_USE_MOTOR, 1, 0), // PWM10 - PC6 OUT5 + DEF_TIM(TIM3, CH2, PC7, TIM_USE_MOTOR, 1, 0), // PWM11 - PC7 OUT6 + DEF_TIM(TIM3, CH3, PC8, TIM_USE_MOTOR, 1, 0), // PWM13 - PC8 OUT7 + DEF_TIM(TIM3, CH4, PC9, TIM_USE_MOTOR, 1, 0), // PWM13 - PC9 OUT8 }; - diff --git a/src/main/target/BLUEJAYF4/target.c b/src/main/target/BLUEJAYF4/target.c index dd32a734c..491f7ff33 100644 --- a/src/main/target/BLUEJAYF4/target.c +++ b/src/main/target/BLUEJAYF4/target.c @@ -19,9 +19,9 @@ #include #include "drivers/io.h" -#include "drivers/timer.h" -#include "drivers/dma.h" +#include "drivers/dma.h" +#include "drivers/timer.h" #include "drivers/timer_def.h" /* diff --git a/src/main/target/CHEBUZZF3/target.c b/src/main/target/CHEBUZZF3/target.c index 6484ee4cc..8ae562de6 100644 --- a/src/main/target/CHEBUZZF3/target.c +++ b/src/main/target/CHEBUZZF3/target.c @@ -20,27 +20,29 @@ #include #include "drivers/io.h" +#include "drivers/dma.h" #include "drivers/timer.h" +#include "drivers/timer_def.h" const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { // INPUTS CH1-8 - { TIM1, IO_TAG(PA8), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_6 }, // PWM1 - PA8 - { TIM16, IO_TAG(PB8), TIM_Channel_1, TIM_USE_PWM, 0, GPIO_AF_1 }, // PWM2 - PB8 - { TIM17, IO_TAG(PB9), TIM_Channel_1, TIM_USE_PWM, 0, GPIO_AF_1 }, // PWM3 - PB9 - { TIM8, IO_TAG(PC6), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_4 }, // PWM4 - PC6 - { TIM8, IO_TAG(PC7), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_4 }, // PWM5 - PC7 - { TIM8, IO_TAG(PC8), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_4 }, // PWM6 - PC8 - { TIM15, IO_TAG(PF9), TIM_Channel_1, TIM_USE_PWM, 0, GPIO_AF_3 }, // PWM7 - PF9 - { TIM15, IO_TAG(PF10), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_3 }, // PWM8 - PF10 - { TIM4, IO_TAG(PD12), TIM_Channel_1, TIM_USE_PWM, 0, GPIO_AF_2 }, // PWM9 - PD12 - { TIM4, IO_TAG(PD13), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_2 }, // PWM10 - PD13 - { TIM4, IO_TAG(PD14), TIM_Channel_3, TIM_USE_PWM, 0, GPIO_AF_2 }, // PWM11 - PD14 - { TIM4, IO_TAG(PD15), TIM_Channel_4, TIM_USE_PWM, 0, GPIO_AF_2 }, // PWM12 - PD15 - { TIM2, IO_TAG(PA1), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_1 }, // PWM13 - PA1 - { TIM2, IO_TAG(PA2), TIM_Channel_3, TIM_USE_PWM, 0, GPIO_AF_1 }, // PWM14 - PA2 - { TIM2, IO_TAG(PA3), TIM_Channel_4, TIM_USE_PWM, 0, GPIO_AF_1 }, // PWM15 - PA3 - { TIM3, IO_TAG(PB0), TIM_Channel_3, TIM_USE_PWM, 0, GPIO_AF_2 }, // PWM16 - PB0 - { TIM3, IO_TAG(PB1), TIM_Channel_4, TIM_USE_PWM, 0, GPIO_AF_2 }, // PWM17 - PB1 - { TIM3, IO_TAG(PA4), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_2 } // PWM18 - PA4 + DEF_TIM(TIM1, CH1, PA8, TIM_USE_MOTOR, 1), // PWM1 - PA8 + DEF_TIM(TIM16, CH1, PB8, TIM_USE_PWM, 0), // PWM2 - PB8 + DEF_TIM(TIM17, CH1, PB9, TIM_USE_PWM, 0), // PWM3 - PB9 + DEF_TIM(TIM8, CH1, PC6, TIM_USE_MOTOR, 1), // PWM4 - PC6 + DEF_TIM(TIM8, CH2, PC7, TIM_USE_MOTOR, 1), // PWM5 - PC7 + DEF_TIM(TIM8, CH3, PC8, TIM_USE_MOTOR, 1), // PWM6 - PC8 + DEF_TIM(TIM15, CH1, PF9, TIM_USE_PWM, 0), // PWM7 - PF9 + DEF_TIM(TIM15, CH2, PF10, TIM_USE_PWM, 0), // PWM8 - PF10 + DEF_TIM(TIM4, CH1, PD12, TIM_USE_PWM, 0), // PWM9 - PD12 + DEF_TIM(TIM4, CH2, PD13, TIM_USE_PWM, 0), // PWM10 - PD13 + DEF_TIM(TIM4, CH3, PD14, TIM_USE_PWM, 0), // PWM11 - PD14 + DEF_TIM(TIM4, CH4, PD15, TIM_USE_PWM, 0), // PWM12 - PD15 + DEF_TIM(TIM2, CH2, PA1, TIM_USE_PWM, 0), // PWM13 - PA1 + DEF_TIM(TIM2, CH3, PA2, TIM_USE_PWM, 0), // PWM14 - PA2 + DEF_TIM(TIM2, CH4, PA3, TIM_USE_PWM, 0), // PWM15 - PA3 + DEF_TIM(TIM3, CH3, PB0, TIM_USE_PWM, 0), // PWM16 - PB0 + DEF_TIM(TIM3, CH4, PB1, TIM_USE_PWM, 0), // PWM17 - PB1 + DEF_TIM(TIM3, CH2, PA4, TIM_USE_PWM, 0) // PWM18 - PA4 }; diff --git a/src/main/target/COLIBRI/target.c b/src/main/target/COLIBRI/target.c index 0c273a64e..875669a8f 100644 --- a/src/main/target/COLIBRI/target.c +++ b/src/main/target/COLIBRI/target.c @@ -21,25 +21,27 @@ #include #include "drivers/io.h" -#include "drivers/timer.h" #include "drivers/dma.h" +#include "drivers/timer.h" +#include "drivers/timer_def.h" const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { - { TIM1, IO_TAG(PA10), TIM_Channel_3, TIM_USE_PWM | TIM_USE_PPM, 0, GPIO_AF_TIM1, NULL, 0, 0 }, // S1_IN - { TIM8, IO_TAG(PC6), TIM_Channel_1, TIM_USE_PWM, 0, GPIO_AF_TIM8 , NULL, 0, 0 }, // S2_IN - { TIM8, IO_TAG(PC7), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_TIM8 , NULL, 0, 0 }, // S3_IN - { TIM8, IO_TAG(PC8), TIM_Channel_3, TIM_USE_PWM, 0, GPIO_AF_TIM8 , NULL, 0, 0 }, // S4_IN - { TIM2, IO_TAG(PA15), TIM_Channel_1, TIM_USE_PWM, 0, GPIO_AF_TIM2 , NULL, 0, 0 }, // S5_IN - { TIM2, IO_TAG(PB3), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_TIM2 , NULL, 0, 0 }, // S6_IN - { TIM5, IO_TAG(PA0), TIM_Channel_1, TIM_USE_PWM, 0, GPIO_AF_TIM5 , NULL, 0, 0 }, // S7_IN - { TIM5, IO_TAG(PA1), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_TIM5 , NULL, 0, 0 }, // S8_IN - { TIM3, IO_TAG(PB0), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_TIM3 , NULL, 0, 0 }, // S1_OUT - { TIM3, IO_TAG(PB4), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_TIM3 , NULL, 0, 0 }, // S2_OUT - { TIM3, IO_TAG(PB1), TIM_Channel_4, TIM_USE_MOTOR, 1, GPIO_AF_TIM3 , NULL, 0, 0 }, // S3_OUT - { TIM12, IO_TAG(PB15), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_TIM12, NULL, 0, 0 }, // S4_OUT - { TIM3, IO_TAG(PB5), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_TIM3 , NULL, 0, 0 }, // S5_OUT - { TIM12, IO_TAG(PB14), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_TIM12, NULL, 0, 0 }, // S6_OUT - { TIM10, IO_TAG(PB8), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_TIM10, NULL, 0, 0 }, // S7_OUT - { TIM11, IO_TAG(PB9), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_TIM11, NULL, 0, 0 }, // S8_OUT - { TIM4, IO_TAG(PB7), TIM_Channel_2, TIM_USE_LED , 0, GPIO_AF_TIM11, DMA1_Stream3, DMA_Channel_2, DMA1_ST3_HANDLER }, // S8_OUT + DEF_TIM(TIM1, CH3, PA10, TIM_USE_PWM | TIM_USE_PPM, 0, 0), // S1_IN + DEF_TIM(TIM8, CH1, PC6, TIM_USE_PWM, 0, 0), // S2_IN + DEF_TIM(TIM8, CH2, PC7, TIM_USE_PWM, 0, 0), // S3_IN + DEF_TIM(TIM8, CH3, PC8, TIM_USE_PWM, 0, 0), // S4_IN + DEF_TIM(TIM2, CH1, PA15, TIM_USE_PWM, 0, 0), // S5_IN + DEF_TIM(TIM2, CH2, PB3, TIM_USE_PWM, 0, 0), // S6_IN + DEF_TIM(TIM5, CH1, PA0, TIM_USE_PWM, 0, 0), // S7_IN + DEF_TIM(TIM5, CH2, PA1, TIM_USE_PWM, 0, 0), // S8_IN + DEF_TIM(TIM3, CH3, PB0, TIM_USE_MOTOR, 1, 0), // S1_OUT + DEF_TIM(TIM3, CH1, PB4, TIM_USE_MOTOR, 1, 0), // S2_OUT + DEF_TIM(TIM3, CH4, PB1, TIM_USE_MOTOR, 1, 0), // S3_OUT + DEF_TIM(TIM12, CH2, PB15, TIM_USE_MOTOR, 1, 0), // S4_OUT + DEF_TIM(TIM3, CH2, PB5, TIM_USE_MOTOR, 1, 0), // S5_OUT + DEF_TIM(TIM12, CH1, PB14, TIM_USE_MOTOR, 1, 0), // S6_OUT + DEF_TIM(TIM10, CH1, PB8, TIM_USE_MOTOR, 1, 0), // S7_OUT + DEF_TIM(TIM11, CH1, PB9, TIM_USE_MOTOR, 1, 0), // S8_OUT + DEF_TIM(TIM4, CH2, PB7, TIM_USE_LED , 0, 0), // S8_OUT }; + \ No newline at end of file diff --git a/src/main/target/F4BY/target.c b/src/main/target/F4BY/target.c index 249e4dede..35c750cad 100644 --- a/src/main/target/F4BY/target.c +++ b/src/main/target/F4BY/target.c @@ -3,25 +3,27 @@ #include #include "drivers/io.h" +#include "drivers/dma.h" #include "drivers/timer.h" +#include "drivers/timer_def.h" const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { - { TIM3, IO_TAG(PC9), TIM_Channel_4, TIM_USE_PWM, 0, GPIO_AF_TIM3 }, // S1_IN - { TIM3, IO_TAG(PC8), TIM_Channel_3, TIM_USE_PWM, 0, GPIO_AF_TIM3 }, // S2_IN - { TIM3, IO_TAG(PC6), TIM_Channel_1, TIM_USE_PWM, 0, GPIO_AF_TIM3 }, // S3_IN - { TIM3, IO_TAG(PC7), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_TIM3 }, // S4_IN - { TIM4, IO_TAG(PD15), TIM_Channel_4, TIM_USE_PWM, 0, GPIO_AF_TIM4 }, // S5_IN - { TIM4, IO_TAG(PD14), TIM_Channel_3, TIM_USE_PWM, 0, GPIO_AF_TIM4 }, // S6_IN - { TIM4, IO_TAG(PD13), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_TIM4 }, // S7_IN - { TIM4, IO_TAG(PD12), TIM_Channel_1, TIM_USE_PWM, 0, GPIO_AF_TIM4 }, // S8_IN - { TIM2, IO_TAG(PA0), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_TIM2 }, // S1_OUT - { TIM2, IO_TAG(PA1), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_TIM2 }, // S2_OUT - { TIM5, IO_TAG(PA2), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_TIM5 }, // S3_OUT - { TIM5, IO_TAG(PA3), TIM_Channel_4, TIM_USE_MOTOR, 1, GPIO_AF_TIM5 }, // S4_OUT - { TIM1, IO_TAG(PE9), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_TIM1 }, // S5_OUT - { TIM1, IO_TAG(PE11), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_TIM1 }, // S6_OUT - { TIM1, IO_TAG(PE13), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_TIM1 }, // S7_OUT - { TIM1, IO_TAG(PE14), TIM_Channel_4, TIM_USE_MOTOR, 1, GPIO_AF_TIM1 }, // S8_OUT - { TIM9, IO_TAG(PE6), TIM_Channel_2, TIM_USE_MOTOR, 0, GPIO_AF_TIM9 }, // sonar echo if needed + DEF_TIM(TIM3, CH4, PC9, TIM_USE_PWM, 0, 0), // S1_IN + DEF_TIM(TIM3, CH3, PC8, TIM_USE_PWM, 0, 0), // S2_IN + DEF_TIM(TIM3, CH1, PC6, TIM_USE_PWM, 0, 0), // S3_IN + DEF_TIM(TIM3, CH2, PC7, TIM_USE_PWM, 0, 0), // S4_IN + DEF_TIM(TIM4, CH4, PD15, TIM_USE_PWM, 0, 0), // S5_IN + DEF_TIM(TIM4, CH3, PD14, TIM_USE_PWM, 0, 0), // S6_IN + DEF_TIM(TIM4, CH2, PD13, TIM_USE_PWM, 0, 0), // S7_IN + DEF_TIM(TIM4, CH1, PD12, TIM_USE_PWM, 0, 0), // S8_IN + DEF_TIM(TIM2, CH1, PA0, TIM_USE_MOTOR, 1, 0), // S1_OUT + DEF_TIM(TIM2, CH2, PA1, TIM_USE_MOTOR, 1, 0), // S2_OUT + DEF_TIM(TIM5, CH3, PA2, TIM_USE_MOTOR, 1, 0), // S3_OUT + DEF_TIM(TIM5, CH4, PA3, TIM_USE_MOTOR, 1, 0), // S4_OUT + DEF_TIM(TIM1, CH1, PE9, TIM_USE_MOTOR, 1, 0), // S5_OUT + DEF_TIM(TIM1, CH2, PE11, TIM_USE_MOTOR, 1, 0), // S6_OUT + DEF_TIM(TIM1, CH3, PE13, TIM_USE_MOTOR, 1, 0), // S7_OUT + DEF_TIM(TIM1, CH4, PE14, TIM_USE_MOTOR, 1, 0), // S8_OUT + DEF_TIM(TIM9, CH2, PE6, TIM_USE_MOTOR, 0, 0), // sonar echo if needed }; diff --git a/src/main/target/IRCFUSIONF3/target.c b/src/main/target/IRCFUSIONF3/target.c index b0eb9d70b..13e48d7d6 100644 --- a/src/main/target/IRCFUSIONF3/target.c +++ b/src/main/target/IRCFUSIONF3/target.c @@ -20,25 +20,27 @@ #include #include "drivers/io.h" +#include "drivers/dma.h" #include "drivers/timer.h" +#include "drivers/timer_def.h" const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { - { TIM2, IO_TAG(PA0), TIM_Channel_1, TIM_USE_PWM | TIM_USE_PPM, 0, GPIO_AF_1 }, // RC_CH1 - PA0 - *TIM2_CH1 - { TIM2, IO_TAG(PA1), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_1 }, // RC_CH2 - PA1 - *TIM2_CH2, TIM15_CH1N - { TIM2, IO_TAG(PB11), TIM_Channel_4, TIM_USE_PWM, 0, GPIO_AF_1 }, // RC_CH3 - PB11 - *TIM2_CH4, UART3_RX (AF7) - { TIM2, IO_TAG(PB10), TIM_Channel_3, TIM_USE_PWM, 0, GPIO_AF_1 }, // RC_CH4 - PB10 - *TIM2_CH3, UART3_TX (AF7) - { TIM3, IO_TAG(PB4), TIM_Channel_1, TIM_USE_PWM, 0, GPIO_AF_2 }, // RC_CH5 - PB4 - *TIM3_CH1 - { TIM3, IO_TAG(PB5), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_2 }, // RC_CH6 - PB5 - *TIM3_CH2 - { TIM3, IO_TAG(PB0), TIM_Channel_3, TIM_USE_PWM, 0, GPIO_AF_2 }, // RC_CH7 - PB0 - *TIM3_CH3, TIM1_CH2N, TIM8_CH2N - { TIM3, IO_TAG(PB1), TIM_Channel_4, TIM_USE_PWM, 0, GPIO_AF_2 }, // RC_CH8 - PB1 - *TIM3_CH4, TIM1_CH3N, TIM8_CH3N - { TIM16, IO_TAG(PA6), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_1 }, // PWM1 - PA6 - TIM3_CH1, TIM8_BKIN, TIM1_BKIN, *TIM16_CH1 - { TIM17, IO_TAG(PA7), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_1 }, // PWM2 - PA7 - TIM3_CH2, *TIM17_CH1, TIM1_CH1N, TIM8_CH1 - { TIM4, IO_TAG(PA11), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_10 },// PWM3 - PA11 - { TIM4, IO_TAG(PA12), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_10 },// PWM4 - PA12 - { TIM4, IO_TAG(PB8), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_2 }, // PWM5 - PB8 - { TIM4, IO_TAG(PB9), TIM_Channel_4, TIM_USE_MOTOR, 1, GPIO_AF_2 }, // PWM6 - PB9 - { TIM15, IO_TAG(PA2), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_9 }, // PWM7 - PA2 - { TIM15, IO_TAG(PA3), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_9 }, // PWM8 - PA3 - { TIM1, IO_TAG(PA8), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_6 }, // GPIO_TIMER / LED_STRIP + DEF_TIM(TIM2, CH1, PA0, TIM_USE_PWM | TIM_USE_PPM, 0), // RC_CH1 - PA0 - *TIM2_CH1 + DEF_TIM(TIM2, CH2, PA1, TIM_USE_PWM, 0), // RC_CH2 - PA1 - *TIM2_CH2, TIM15_CH1N + DEF_TIM(TIM2, CH4, PB11, TIM_USE_PWM, 0), // RC_CH3 - PB11 - *TIM2_CH4, UART3_RX (AF7) + DEF_TIM(TIM2, CH3, PB10, TIM_USE_PWM, 0), // RC_CH4 - PB10 - *TIM2_CH3, UART3_TX (AF7) + DEF_TIM(TIM3, CH1, PB4, TIM_USE_PWM, 0), // RC_CH5 - PB4 - *TIM3_CH1 + DEF_TIM(TIM3, CH2, PB5, TIM_USE_PWM, 0), // RC_CH6 - PB5 - *TIM3_CH2 + DEF_TIM(TIM3, CH3, PB0, TIM_USE_PWM, 0), // RC_CH7 - PB0 - *TIM3_CH3, TIM1_CH2N, TIM8_CH2N + DEF_TIM(TIM3, CH4, PB1, TIM_USE_PWM, 0), // RC_CH8 - PB1 - *TIM3_CH4, TIM1_CH3N, TIM8_CH3N + DEF_TIM(TIM16, CH1, PA6, TIM_USE_MOTOR, 1), // PWM1 - PA6 - TIM3_CH1, TIM8_BKIN, TIM1_BKIN, *TIM16_CH1 + DEF_TIM(TIM17, CH1, PA7, TIM_USE_MOTOR, 1), // PWM2 - PA7 - TIM3_CH2, *TIM17_CH1, TIM1_CH1N, TIM8_CH1 + DEF_TIM(TIM4, CH1, PA11, TIM_USE_MOTOR, 1), // PWM3 - PA11 + DEF_TIM(TIM4, CH2, PA12, TIM_USE_MOTOR, 1), // PWM4 - PA12 + DEF_TIM(TIM4, CH3, PB8, TIM_USE_MOTOR, 1), // PWM5 - PB8 + DEF_TIM(TIM4, CH4, PB9, TIM_USE_MOTOR, 1), // PWM6 - PB9 + DEF_TIM(TIM15, CH1, PA2, TIM_USE_MOTOR, 1), // PWM7 - PA2 + DEF_TIM(TIM15, CH2, PA3, TIM_USE_MOTOR, 1), // PWM8 - PA3 + DEF_TIM(TIM1, CH1, PA8, TIM_USE_MOTOR, 1), // GPIO_TIMER / LED_STRIP }; diff --git a/src/main/target/ISHAPEDF3/target.c b/src/main/target/ISHAPEDF3/target.c index 03015e22c..4fc274560 100644 --- a/src/main/target/ISHAPEDF3/target.c +++ b/src/main/target/ISHAPEDF3/target.c @@ -20,28 +20,28 @@ #include #include "drivers/io.h" -#include "drivers/timer.h" #include "drivers/dma.h" +#include "drivers/timer.h" +#include "drivers/timer_def.h" +// Production boards swapped RC_CH3/4 swapped to make it easier to use SerialRX using supplied cables - compared to first prototype. const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { - { TIM2, IO_TAG(PA0), TIM_Channel_1, TIM_USE_PWM |TIM_USE_PPM, 0, GPIO_AF_1, NULL, 0 }, // RC_CH1 - PA0 - *TIM2_CH1 - { TIM2, IO_TAG(PA1), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_1 , NULL, 0}, // RC_CH2 - PA1 - *TIM2_CH2, TIM15_CH1N - // Production boards swapped RC_CH3/4 swapped to make it easier to use SerialRX using supplied cables - compared to first prototype. - { TIM2, IO_TAG(PB11), TIM_Channel_4, TIM_USE_PWM, 0, GPIO_AF_1 , NULL, 0}, // RC_CH3 - PB11 - *TIM2_CH4, UART3_RX (AF7) - { TIM2, IO_TAG(PB10), TIM_Channel_3, TIM_USE_PWM, 0, GPIO_AF_1 , NULL, 0}, // RC_CH4 - PB10 - *TIM2_CH3, UART3_TX (AF7) - { TIM3, IO_TAG(PB4), TIM_Channel_1, TIM_USE_PWM, 0, GPIO_AF_2 , NULL, 0}, // RC_CH5 - PB4 - *TIM3_CH1 - { TIM3, IO_TAG(PB5), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_2 , NULL, 0}, // RC_CH6 - PB5 - *TIM3_CH2 - { TIM3, IO_TAG(PB0), TIM_Channel_3, TIM_USE_PWM, 0, GPIO_AF_2 , NULL, 0}, // RC_CH7 - PB0 - *TIM3_CH3, TIM1_CH2N, TIM8_CH2N - { TIM3, IO_TAG(PB1), TIM_Channel_4, TIM_USE_PWM, 0, GPIO_AF_2 , NULL, 0}, // RC_CH8 - PB1 - *TIM3_CH4, TIM1_CH3N, TIM8_CH3N - { TIM16, IO_TAG(PA6), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_1 , NULL, 0}, // PWM1 - PA6 - TIM3_CH1, TIM8_BKIN, TIM1_BKIN, *TIM16_CH1 - { TIM17, IO_TAG(PA7), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_1 , NULL, 0}, // PWM2 - PA7 - TIM3_CH2, *TIM17_CH1, TIM1_CH1N, TIM8_CH1 - { TIM4, IO_TAG(PA11), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_10, NULL, 0 },// PWM3 - PA11 - { TIM4, IO_TAG(PA12), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_10, NULL, 0 },// PWM4 - PA12 - { TIM4, IO_TAG(PB8), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_2 , NULL, 0}, // PWM5 - PB8 - { TIM4, IO_TAG(PB9), TIM_Channel_4, TIM_USE_MOTOR, 1, GPIO_AF_2 , NULL, 0}, // PWM6 - PB9 - { TIM15, IO_TAG(PA2), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_9 , NULL, 0}, // PWM7 - PA2 - { TIM15, IO_TAG(PA3), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_9 , NULL, 0}, // PWM8 - PA3 - - { TIM1, IO_TAG(PA8), TIM_Channel_1, TIM_USE_LED, 1, GPIO_AF_6 , DMA1_Channel2, DMA1_CH2_HANDLER}, // GPIO_TIMER / LED_STRIP + DEF_TIM(TIM2, CH1, PA0, TIM_USE_PWM |TIM_USE_PPM, 0), // RC_CH1 - PA0 - *TIM2_CH1 + DEF_TIM(TIM2, CH2, PA1, TIM_USE_PWM, 0), // RC_CH2 - PA1 - *TIM2_CH2, TIM15_CH1N + DEF_TIM(TIM2, CH4, PB11, TIM_USE_PWM, 0), // RC_CH3 - PB11 - *TIM2_CH4, UART3_RX (AF7) + DEF_TIM(TIM2, CH3, PB10, TIM_USE_PWM, 0), // RC_CH4 - PB10 - *TIM2_CH3, UART3_TX (AF7) + DEF_TIM(TIM3, CH1, PB4, TIM_USE_PWM, 0), // RC_CH5 - PB4 - *TIM3_CH1 + DEF_TIM(TIM3, CH2, PB5, TIM_USE_PWM, 0), // RC_CH6 - PB5 - *TIM3_CH2 + DEF_TIM(TIM3, CH3, PB0, TIM_USE_PWM, 0), // RC_CH7 - PB0 - *TIM3_CH3, TIM1_CH2N, TIM8_CH2N + DEF_TIM(TIM3, CH4, PB1, TIM_USE_PWM, 0), // RC_CH8 - PB1 - *TIM3_CH4, TIM1_CH3N, TIM8_CH3N + DEF_TIM(TIM16, CH1, PA6, TIM_USE_MOTOR, 1), // PWM1 - PA6 - TIM3_CH1, TIM8_BKIN, TIM1_BKIN, *TIM16_CH1 + DEF_TIM(TIM17, CH1, PA7, TIM_USE_MOTOR, 1), // PWM2 - PA7 - TIM3_CH2, *TIM17_CH1, TIM1_CH1N, TIM8_CH1 + DEF_TIM(TIM4, CH1, PA11, TIM_USE_MOTOR, 1), // PWM3 - PA11 + DEF_TIM(TIM4, CH2, PA12, TIM_USE_MOTOR, 1), // PWM4 - PA12 + DEF_TIM(TIM4, CH3, PB8, TIM_USE_MOTOR, 1), // PWM5 - PB8 + DEF_TIM(TIM4, CH4, PB9, TIM_USE_MOTOR, 1), // PWM6 - PB9 + DEF_TIM(TIM15, CH1, PA2, TIM_USE_MOTOR, 1), // PWM7 - PA2 + DEF_TIM(TIM15, CH2, PA3, TIM_USE_MOTOR, 1), // PWM8 - PA3 + DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 1), // GPIO_TIMER / LED_STRIP }; diff --git a/src/main/target/MULTIFLITEPICO/target.c b/src/main/target/MULTIFLITEPICO/target.c index b09058af7..7cf10492d 100755 --- a/src/main/target/MULTIFLITEPICO/target.c +++ b/src/main/target/MULTIFLITEPICO/target.c @@ -21,27 +21,26 @@ #include "drivers/io.h" #include "drivers/timer.h" +#include "drivers/timer_def.h" #include "drivers/dma.h" +// Production boards swapped RC_CH3/4 swapped to make it easierTIM_USE_MOTOR, to using supplied cables - compared to first prototype. const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { - { TIM2, IO_TAG(PA0), TIM_Channel_1, TIM_USE_PWM | TIM_USE_PPM, 0, GPIO_AF_1, NULL, 0 }, // RC_CH1 - PA0 - *TIM2_CH1 - { TIM2, IO_TAG(PA1), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_1, NULL, 0 }, // RC_CH2 - PA1 - *TIM2_CH2, TIM15_CH1N - // Production boards swapped RC_CH3/4 swapped to make it easierTIM_USE_MOTOR, to using supplied cables - compared to first prototype. - { TIM2, IO_TAG(PB11), TIM_Channel_4, TIM_USE_PWM, 0, GPIO_AF_1, NULL, 0 }, // RC_CH3 - PB11 - *TIM2_CH4, UART3_RX (AF7) - { TIM2, IO_TAG(PB10), TIM_Channel_3, TIM_USE_PWM, 0, GPIO_AF_1, NULL, 0 }, // RC_CH4 - PB10 - *TIM2_CH3, UART3_TX (AF7) - { TIM3, IO_TAG(PB4), TIM_Channel_1, TIM_USE_PWM, 0, GPIO_AF_2, NULL, 0 }, // RC_CH5 - PB4 - *TIM3_CH1 - { TIM3, IO_TAG(PB5), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_2, NULL, 0 }, // RC_CH6 - PB5 - *TIM3_CH2 - { TIM3, IO_TAG(PB0), TIM_Channel_3, TIM_USE_PWM, 0, GPIO_AF_2, NULL, 0 }, // RC_CH7 - PB0 - *TIM3_CH3, TIM1_CH2N, TIM8_CH2N - { TIM3, IO_TAG(PB1), TIM_Channel_4, TIM_USE_PWM, 0, GPIO_AF_2, NULL, 0 }, // RC_CH8 - PB1 - *TIM3_CH4, TIM1_CH3N, TIM8_CH3N - - { TIM16, IO_TAG(PA6), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_1, DMA1_Channel3, DMA1_CH3_HANDLER }, // PWM1 - PA6 - TIM3_CH1, TIM8_BKIN, TIM1_BKIN, *TIM16_CH1 - { TIM17, IO_TAG(PA7), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_1, DMA1_Channel7, DMA1_CH7_HANDLER }, // PWM2 - PA7 - TIM3_CH2, *TIM17_CH1, TIM1_CH1N, TIM8_CH1 - { TIM4, IO_TAG(PA11), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_10, DMA1_Channel1, DMA1_CH1_HANDLER },// PWM3 - PA11 - { TIM4, IO_TAG(PA12), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_10, DMA1_Channel4, DMA1_CH4_HANDLER },// PWM4 - PA12 - { TIM4, IO_TAG(PB8), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_2, NULL, 0 }, // PWM5 - PB8 - { TIM4, IO_TAG(PB9), TIM_Channel_4, TIM_USE_MOTOR, 1, GPIO_AF_2, NULL, 0 }, // PWM6 - PB9 - { TIM15, IO_TAG(PA2), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_9, NULL, 0 }, // PWM7 - PA2 - { TIM15, IO_TAG(PA3), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_9, NULL, 0 }, // PWM8 - PA3 - - { TIM1, IO_TAG(PA8), TIM_Channel_1, TIM_USE_LED, 1, GPIO_AF_6, DMA1_Channel2, DMA1_CH2_HANDLER }, // GPIO_TIMER / LED_STRIP + DEF_TIM(TIM2, CH1, PA0, TIM_USE_PWM | TIM_USE_PPM, 0), // RC_CH1 - PA0 - *TIM2_CH1 + DEF_TIM(TIM2, CH2, PA1, TIM_USE_PWM, 0), // RC_CH2 - PA1 - *TIM2_CH2, TIM15_CH1N + DEF_TIM(TIM2, CH4, PB11, TIM_USE_PWM, 0), // RC_CH3 - PB11 - *TIM2_CH4, UART3_RX (AF7) + DEF_TIM(TIM2, CH3, PB10, TIM_USE_PWM, 0), // RC_CH4 - PB10 - *TIM2_CH3, UART3_TX (AF7) + DEF_TIM(TIM3, CH1, PB4, TIM_USE_PWM, 0), // RC_CH5 - PB4 - *TIM3_CH1 + DEF_TIM(TIM3, CH2, PB5, TIM_USE_PWM, 0), // RC_CH6 - PB5 - *TIM3_CH2 + DEF_TIM(TIM3, CH3, PB0, TIM_USE_PWM, 0), // RC_CH7 - PB0 - *TIM3_CH3, TIM1_CH2N, TIM8_CH2N + DEF_TIM(TIM3, CH4, PB1, TIM_USE_PWM, 0), // RC_CH8 - PB1 - *TIM3_CH4, TIM1_CH3N, TIM8_CH3N + DEF_TIM(TIM16, CH1, PA6, TIM_USE_MOTOR, 1), // PWM1 - PA6 - TIM3_CH1, TIM8_BKIN, TIM1_BKIN, *TIM16_CH1 + DEF_TIM(TIM17, CH1, PA7, TIM_USE_MOTOR, 1), // PWM2 - PA7 - TIM3_CH2, *TIM17_CH1, TIM1_CH1N, TIM8_CH1 + DEF_TIM(TIM4, CH1, PA11, TIM_USE_MOTOR, 1), // PWM3 - PA11 + DEF_TIM(TIM4, CH2, PA12, TIM_USE_MOTOR, 1), // PWM4 - PA12 + DEF_TIM(TIM4, CH3, PB8, TIM_USE_MOTOR, 1), // PWM5 - PB8 + DEF_TIM(TIM4, CH4, PB9, TIM_USE_MOTOR, 1), // PWM6 - PB9 + DEF_TIM(TIM15, CH1, PA2, TIM_USE_MOTOR, 1), // PWM7 - PA2 + DEF_TIM(TIM15, CH2, PA3, TIM_USE_MOTOR, 1), // PWM8 - PA3 + DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 1), // GPIO_TIMER / LED_STRIP }; diff --git a/src/main/target/NAZE/target.c b/src/main/target/NAZE/target.c index 12ce8d40e..63697439c 100644 --- a/src/main/target/NAZE/target.c +++ b/src/main/target/NAZE/target.c @@ -21,21 +21,22 @@ #include "drivers/io.h" #include "drivers/timer.h" +#include "drivers/timer_def.h" #include "drivers/dma.h" const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { - { TIM2, IO_TAG(PA0), TIM_Channel_1, TIM_USE_PPM | TIM_USE_PWM, 0, NULL, 0 }, // PWM1 - RC1 - { TIM2, IO_TAG(PA1), TIM_Channel_2, TIM_USE_PWM, 0, NULL, 0 }, // PWM2 - RC2 - { TIM2, IO_TAG(PA2), TIM_Channel_3, TIM_USE_PWM, 0, NULL, 0 }, // PWM3 - RC3 - { TIM2, IO_TAG(PA3), TIM_Channel_4, TIM_USE_PWM, 0, NULL, 0 }, // PWM4 - RC4 - { TIM3, IO_TAG(PA6), TIM_Channel_1, TIM_USE_PWM | TIM_USE_LED, 0, DMA1_Channel6, DMA1_CH6_HANDLER }, // PWM5 - RC5 - { TIM3, IO_TAG(PA7), TIM_Channel_2, TIM_USE_PWM, 0, NULL, 0 }, // PWM6 - RC6 - { TIM3, IO_TAG(PB0), TIM_Channel_3, TIM_USE_PWM, 0, NULL, 0 }, // PWM7 - RC7 - { TIM3, IO_TAG(PB1), TIM_Channel_4, TIM_USE_PWM, 0, NULL, 0 }, // PWM8 - RC8 - { TIM1, IO_TAG(PA8), TIM_Channel_1, TIM_USE_MOTOR, 1, NULL, 0 }, // PWM9 - OUT1 - { TIM1, IO_TAG(PA11), TIM_Channel_4, TIM_USE_MOTOR, 1, NULL, 0 }, // PWM10 - OUT2 - { TIM4, IO_TAG(PB6), TIM_Channel_1, TIM_USE_MOTOR, 1, NULL, 0 }, // PWM11 - OUT3 - { TIM4, IO_TAG(PB7), TIM_Channel_2, TIM_USE_MOTOR, 1, NULL, 0 }, // PWM12 - OUT4 - { TIM4, IO_TAG(PB8), TIM_Channel_3, TIM_USE_MOTOR, 1, NULL, 0 }, // PWM13 - OUT5 - { TIM4, IO_TAG(PB9), TIM_Channel_4, TIM_USE_MOTOR, 1, NULL, 0 } // PWM14 - OUT6 + DEF_TIM(TIM2, CH1, PA0, TIM_USE_PPM | TIM_USE_PWM, 0), // PWM1 - RC1 + DEF_TIM(TIM2, CH2, PA1, TIM_USE_PWM, 0), // PWM2 - RC2 + DEF_TIM(TIM2, CH3, PA2, TIM_USE_PWM, 0), // PWM3 - RC3 + DEF_TIM(TIM2, CH4, PA3, TIM_USE_PWM, 0), // PWM4 - RC4 + DEF_TIM(TIM3, CH1, PA6, TIM_USE_PWM | TIM_USE_LED, 0), // PWM5 - RC5 + DEF_TIM(TIM3, CH2, PA7, TIM_USE_PWM, 0), // PWM6 - RC6 + DEF_TIM(TIM3, CH3, PB0, TIM_USE_PWM, 0), // PWM7 - RC7 + DEF_TIM(TIM3, CH4, PB1, TIM_USE_PWM, 0), // PWM8 - RC8 + DEF_TIM(TIM1, CH1, PA8, TIM_USE_MOTOR, 1), // PWM9 - OUT1 + DEF_TIM(TIM1, CH4, PA11, TIM_USE_MOTOR, 1), // PWM10 - OUT2 + DEF_TIM(TIM4, CH1, PB6, TIM_USE_MOTOR, 1), // PWM11 - OUT3 + DEF_TIM(TIM4, CH2, PB7, TIM_USE_MOTOR, 1), // PWM12 - OUT4 + DEF_TIM(TIM4, CH3, PB8, TIM_USE_MOTOR, 1), // PWM13 - OUT5 + DEF_TIM(TIM4, CH4, PB9, TIM_USE_MOTOR, 1) // PWM14 - OUT6 }; diff --git a/src/main/target/PIKOBLX/target.c b/src/main/target/PIKOBLX/target.c index 4a9603ede..d830ba78c 100644 --- a/src/main/target/PIKOBLX/target.c +++ b/src/main/target/PIKOBLX/target.c @@ -21,18 +21,19 @@ #include "drivers/io.h" #include "drivers/timer.h" +#include "drivers/timer_def.h" #include "drivers/dma.h" const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { - { TIM3, IO_TAG(PA4), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_2, NULL, 0 }, // PWM1 - PA4 - *TIM3_CH2 - { TIM3, IO_TAG(PA6), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_2, NULL, 0 }, // PWM2 - PA6 - *TIM3_CH1, TIM8_BKIN, TIM1_BKIN, TIM16_CH1 - { TIM3, IO_TAG(PB0), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_2, NULL, 0 }, // PWM3 - PB0 - *TIM3_CH3, TIM1_CH2N, TIM8_CH2N - { TIM3, IO_TAG(PB1), TIM_Channel_4, TIM_USE_MOTOR, 1, GPIO_AF_2, NULL, 0 }, // PWM4 - PB1 - *TIM3_CH4, TIM1_CH3N, TIM8_CH3N - { TIM2, IO_TAG(PA1), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_1, NULL, 0 }, // PWM5 - PA1 - *TIM2_CH2, TIM15_CH1N - { TIM2, IO_TAG(PA2), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_1, NULL, 0 }, // PWM6 - PA2 - *TIM2_CH3, !TIM15_CH1 - { TIM15, IO_TAG(PA3), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_9, NULL, 0 }, // PWM7 - PA3 - *TIM15_CH2, TIM2_CH4 - { TIM1, IO_TAG(PA8), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_6, NULL, 0 }, // PWM8 - PA8 - *TIM1_CH1, TIM4_ETR - { TIM17, IO_TAG(PA7), TIM_Channel_1, TIM_USE_PPM, 0, GPIO_AF_1, NULL, 0 }, // PPM - PA7 - *TIM17_CH1, TIM1_CH1N, TIM8_CH1 - { TIM16, IO_TAG(PB8), TIM_Channel_1, TIM_USE_LED, 0, GPIO_AF_1, DMA1_Channel3, DMA1_CH3_HANDLER }, // PPM - PA7 - *TIM17_CH1, TIM1_CH1N, TIM8_CH1 + DEF_TIM(TIM3, CH2, PA4, TIM_USE_MOTOR, 1), // PWM1 - PA4 - *TIM3_CH2 + DEF_TIM(TIM3, CH1, PA6, TIM_USE_MOTOR, 1), // PWM2 - PA6 - *TIM3_CH1, TIM8_BKIN, TIM1_BKIN, TIM16_CH1 + DEF_TIM(TIM3, CH3, PB0, TIM_USE_MOTOR, 1), // PWM3 - PB0 - *TIM3_CH3, TIM1_CH2N, TIM8_CH2N + DEF_TIM(TIM3, CH4, PB1, TIM_USE_MOTOR, 1), // PWM4 - PB1 - *TIM3_CH4, TIM1_CH3N, TIM8_CH3N + DEF_TIM(TIM2, CH2, PA1, TIM_USE_MOTOR, 1), // PWM5 - PA1 - *TIM2_CH2, TIM15_CH1N + DEF_TIM(TIM2, CH3, PA2, TIM_USE_MOTOR, 1), // PWM6 - PA2 - *TIM2_CH3, !TIM15_CH1 + DEF_TIM(TIM15, CH2, PA3, TIM_USE_MOTOR, 1), // PWM7 - PA3 - *TIM15_CH2, TIM2_CH4 + DEF_TIM(TIM1, CH1, PA8, TIM_USE_MOTOR, 1), // PWM8 - PA8 - *TIM1_CH1, TIM4_ETR + DEF_TIM(TIM17, CH1, PA7, TIM_USE_PPM, 0), // PPM - PA7 - *TIM17_CH1, TIM1_CH1N, TIM8_CH1 + DEF_TIM(TIM16, CH1, PB8, TIM_USE_LED, 0), // PPM - PA7 - *TIM17_CH1, TIM1_CH1N, TIM8_CH1 }; diff --git a/src/main/target/RACEBASE/target.c b/src/main/target/RACEBASE/target.c index ff5ec100c..009f6d63b 100755 --- a/src/main/target/RACEBASE/target.c +++ b/src/main/target/RACEBASE/target.c @@ -19,14 +19,16 @@ #include #include "drivers/io.h" + #include "drivers/timer.h" +#include "drivers/timer_def.h" #include "drivers/dma.h" const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { - { TIM2, IO_TAG(PA0), TIM_Channel_1, TIM_USE_PPM, 1, GPIO_AF_1, NULL, 0 }, - { TIM4, IO_TAG(PB6), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_2, NULL, 0 }, // PWM2 - PC6 - { TIM4, IO_TAG(PB7), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_2, NULL, 0 }, // PWM3 - PC7 - { TIM4, IO_TAG(PB8), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_2, NULL, 0 }, // PMW4 - PC8 - { TIM4, IO_TAG(PB9), TIM_Channel_4, TIM_USE_MOTOR, 1, GPIO_AF_2, NULL, 0 }, // PWM5 - PC9 - { TIM1, IO_TAG(PA8), TIM_Channel_1, TIM_USE_LED, 1, GPIO_AF_2, DMA1_Channel2, DMA1_CH2_HANDLER }, // PWM5 - PC9 + DEF_TIM(TIM2, CH1, PA0, TIM_USE_PPM, 1 ), + DEF_TIM(TIM4, CH1, PB6, TIM_USE_MOTOR, 1 ), // PWM2 - PC6 + DEF_TIM(TIM4, CH2, PB7, TIM_USE_MOTOR, 1 ), // PWM3 - PC7 + DEF_TIM(TIM4, CH3, PB8, TIM_USE_MOTOR, 1 ), // PMW4 - PC8 + DEF_TIM(TIM4, CH4, PB9, TIM_USE_MOTOR, 1 ), // PWM5 - PC9 + DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 1 ), // PWM5 - PC9 }; diff --git a/src/main/target/RCEXPLORERF3/target.c b/src/main/target/RCEXPLORERF3/target.c index 63ac464d5..4b84c6d00 100644 --- a/src/main/target/RCEXPLORERF3/target.c +++ b/src/main/target/RCEXPLORERF3/target.c @@ -22,14 +22,15 @@ #include "drivers/io.h" #include "drivers/timer.h" +#include "drivers/timer_def.h" #include "drivers/dma.h" const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { - { TIM3, IO_TAG(PA4), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_2, NULL, 0 }, // PWM1 - PA4 - { TIM17, IO_TAG(PA7), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_1, NULL, 0 }, // PWM2 - PA7 - { TIM1, IO_TAG(PA8), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_6, NULL, 0 }, // PWM3 - PA8 - { TIM3, IO_TAG(PB0), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_2, NULL, 0 }, // PWM4 - PB0 - { TIM3, IO_TAG(PB1), TIM_Channel_4, TIM_USE_MOTOR, 1, GPIO_AF_2, NULL, 0 }, // PWM5 - PB1 - { TIM2, IO_TAG(PA1), TIM_Channel_2, TIM_USE_PPM, 0, GPIO_AF_1, NULL, 0 }, // PWM6 - PPM - { TIM16, IO_TAG(PB8), TIM_Channel_1, TIM_USE_LED, 0, GPIO_AF_1, DMA1_Channel3, DMA1_CH3_HANDLER}, // PWM6 - PPM + DEF_TIM(TIM3, CH2, PA4, TIM_USE_MOTOR, 1), // PWM1 - PA4 + DEF_TIM(TIM17, CH1, PA7, TIM_USE_MOTOR, 1), // PWM2 - PA7 + DEF_TIM(TIM1, CH1, PA8, TIM_USE_MOTOR, 1), // PWM3 - PA8 + DEF_TIM(TIM3, CH3, PB0, TIM_USE_MOTOR, 1), // PWM4 - PB0 + DEF_TIM(TIM3, CH4, PB1, TIM_USE_MOTOR, 1), // PWM5 - PB1 + DEF_TIM(TIM2, CH2, PA1, TIM_USE_PPM, 0), // PWM6 - PPM + DEF_TIM(TIM16, CH1, PB8, TIM_USE_LED, 0), // PWM6 - PPM }; diff --git a/src/main/target/REVO/target.c b/src/main/target/REVO/target.c index b9164d7b8..31a059a1d 100644 --- a/src/main/target/REVO/target.c +++ b/src/main/target/REVO/target.c @@ -19,25 +19,26 @@ #include #include "drivers/io.h" -#include "drivers/dma.h" +#include "drivers/dma.h" #include "drivers/timer.h" +#include "drivers/timer_def.h" const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { - { TIM12, IO_TAG(PB14), TIM_Channel_1, TIM_USE_PWM | TIM_USE_PPM, 0, GPIO_AF_TIM12, NULL, 0, 0 }, // PPM (5th pin on FlexiIO port) - { TIM12, IO_TAG(PB15), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_TIM12, NULL, 0, 0 }, // S2_IN - { TIM8, IO_TAG(PC6), TIM_Channel_1, TIM_USE_PWM, 0, GPIO_AF_TIM8, NULL, 0, 0 }, // S3_IN - { TIM8, IO_TAG(PC7), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_TIM8, NULL, 0, 0 }, // S4_IN - { TIM8, IO_TAG(PC8), TIM_Channel_3, TIM_USE_PWM, 0, GPIO_AF_TIM8, NULL, 0, 0 }, // S5_IN - { TIM8, IO_TAG(PC9), TIM_Channel_4, TIM_USE_PWM, 0, GPIO_AF_TIM8, NULL, 0, 0 }, // S6_IN - { TIM3, IO_TAG(PB0), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_TIM3, DMA1_Stream7, DMA_Channel_5, DMA1_ST7_HANDLER }, // S1_OUT - { TIM3, IO_TAG(PB1), TIM_Channel_4, TIM_USE_MOTOR, 1, GPIO_AF_TIM3, DMA1_Stream2, DMA_Channel_5, DMA1_ST2_HANDLER }, // S2_OUT - { TIM2, IO_TAG(PA3), TIM_Channel_4, TIM_USE_MOTOR, 1, GPIO_AF_TIM2, DMA1_Stream6, DMA_Channel_3, DMA1_ST6_HANDLER }, // S3_OUT - { TIM2, IO_TAG(PA2), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_TIM2, DMA1_Stream1, DMA_Channel_3, DMA1_ST1_HANDLER }, // S4_OUT + DEF_TIM(TIM12, CH1, PB14, TIM_USE_PWM | TIM_USE_PPM, 0, 0), // PPM (5th pin on FlexiIO port) + DEF_TIM(TIM12, CH2, PB15, TIM_USE_PWM, 0, 0), // S2_IN + DEF_TIM(TIM8, CH1, PC6, TIM_USE_PWM, 0, 0), // S3_IN + DEF_TIM(TIM8, CH2, PC7, TIM_USE_PWM, 0, 0), // S4_IN + DEF_TIM(TIM8, CH3, PC8, TIM_USE_PWM, 0, 0), // S5_IN + DEF_TIM(TIM8, CH4, PC9, TIM_USE_PWM, 0, 0), // S6_IN + DEF_TIM(TIM3, CH3, PB0, TIM_USE_MOTOR, 1, 0), // S1_OUT D1_ST7 + DEF_TIM(TIM3, CH4, PB1, TIM_USE_MOTOR, 1, 0), // S2_OUT D1_ST2 + DEF_TIM(TIM2, CH4, PA3, TIM_USE_MOTOR, 1, 1), // S3_OUT D1_ST6 + DEF_TIM(TIM2, CH3, PA2, TIM_USE_MOTOR, 1, 0), // S4_OUT D1_ST1 #ifdef REVOLT - { TIM4, IO_TAG(PB6), TIM_Channel_1, TIM_USE_LED, 0, GPIO_AF_TIM4, DMA1_Stream0, DMA_Channel_2, DMA1_ST0_HANDLER }, // LED for REVOLT + DEF_TIM(TIM4, CH1, PB6, TIM_USE_LED, 0, 0), // LED for REVOLT D1_ST0 #else - { TIM5, IO_TAG(PA1), TIM_Channel_2, TIM_USE_MOTOR | TIM_USE_LED, 1, GPIO_AF_TIM5, DMA1_Stream4, DMA_Channel_6, DMA1_ST4_HANDLER }, // S5_OUT / LED for REVO - { TIM5, IO_TAG(PA0), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_TIM5, DMA1_Stream2, DMA_Channel_6, DMA1_ST2_HANDLER }, // S6_OUT + DEF_TIM(TIM5, CH2, PA1, TIM_USE_MOTOR | TIM_USE_LED, 1, 0), // S5_OUT / LED for REVO D1_ST4 + DEF_TIM(TIM5, CH1, PA0, TIM_USE_MOTOR, 1, 0), // S6_OUT D1_ST2 #endif }; diff --git a/src/main/target/REVONANO/target.c b/src/main/target/REVONANO/target.c index 44a60162f..46bc84c72 100644 --- a/src/main/target/REVONANO/target.c +++ b/src/main/target/REVONANO/target.c @@ -21,20 +21,20 @@ #include "drivers/io.h" #include "drivers/timer.h" +#include "drivers/timer_def.h" +#include "drivers/dma.h" const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { - { TIM2, IO_TAG(PB10), TIM_Channel_3, TIM_USE_PWM | TIM_USE_PPM, 0, GPIO_AF_TIM2 }, // PPM - { TIM3, IO_TAG(PB1), TIM_Channel_4, TIM_USE_PWM, 0, GPIO_AF_TIM3 }, // S2_IN - { TIM3, IO_TAG(PB0), TIM_Channel_3, TIM_USE_PWM, 0, GPIO_AF_TIM3 }, // S3_IN - { TIM3, IO_TAG(PA7), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_TIM3 }, // S4_IN - { TIM3, IO_TAG(PA6), TIM_Channel_1, TIM_USE_PWM, 0, GPIO_AF_TIM3 }, // S5_IN - { TIM2, IO_TAG(PA5), TIM_Channel_1, TIM_USE_PWM, 0, GPIO_AF_TIM2 }, // S6_IN - { TIM1, IO_TAG(PA10), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_TIM1 }, // S1_OUT - { TIM2, IO_TAG(PB3), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_TIM2 }, // S2_OUT - { TIM4, IO_TAG(PB8), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_TIM4 }, // S3_OUT - { TIM4, IO_TAG(PB9), TIM_Channel_4, TIM_USE_MOTOR, 1, GPIO_AF_TIM4 }, // S4_OUT - { TIM5, IO_TAG(PA0), TIM_Channel_1, TIM_USE_MOTOR | TIM_USE_LED, 1, GPIO_AF_TIM5 }, // S5_OUT - { TIM5, IO_TAG(PA1), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_TIM5 }, // S6_OUT + DEF_TIM(TIM2, CH3, PB10, TIM_USE_PWM | TIM_USE_PPM, 0, 0), // PPM + DEF_TIM(TIM3, CH4, PB1, TIM_USE_PWM, 0, 0), // S2_IN + DEF_TIM(TIM3, CH3, PB0, TIM_USE_PWM, 0, 0), // S3_IN + DEF_TIM(TIM3, CH2, PA7, TIM_USE_PWM, 0, 0), // S4_IN + DEF_TIM(TIM3, CH1, PA6, TIM_USE_PWM, 0, 0), // S5_IN + DEF_TIM(TIM2, CH1, PA5, TIM_USE_PWM, 0, 0), // S6_IN + DEF_TIM(TIM1, CH3, PA10, TIM_USE_MOTOR, 1, 0), // S1_OUT + DEF_TIM(TIM2, CH2, PB3, TIM_USE_MOTOR, 1, 0), // S2_OUT + DEF_TIM(TIM4, CH3, PB8, TIM_USE_MOTOR, 1, 0), // S3_OUT + DEF_TIM(TIM4, CH4, PB9, TIM_USE_MOTOR, 1, 0), // S4_OUT + DEF_TIM(TIM5, CH1, PA0, TIM_USE_MOTOR | TIM_USE_LED, 1, 0), // S5_OUT + DEF_TIM(TIM5, CH2, PA1, TIM_USE_MOTOR, 1, 0), // S6_OUT }; - - diff --git a/src/main/target/SINGULARITY/target.c b/src/main/target/SINGULARITY/target.c index 88b9213ab..f239b4d38 100644 --- a/src/main/target/SINGULARITY/target.c +++ b/src/main/target/SINGULARITY/target.c @@ -21,18 +21,19 @@ #include "drivers/io.h" #include "drivers/timer.h" +#include "drivers/timer_def.h" #include "drivers/dma.h" const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { - { TIM2, IO_TAG(PA15), TIM_Channel_1, TIM_USE_PWM | TIM_USE_PPM, 0, GPIO_AF_1, NULL, 0 }, // PPM/SERIAL RX - { TIM3, IO_TAG(PB4), TIM_Channel_1, TIM_USE_PWM, 0, GPIO_AF_2, NULL, 0 }, // PWM1 - { TIM3, IO_TAG(PB5), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_2, NULL, 0 }, // PWM2 - { TIM3, IO_TAG(PB0), TIM_Channel_3, TIM_USE_PWM, 0, GPIO_AF_2, NULL, 0 }, // PWM3 - { TIM3, IO_TAG(PB1), TIM_Channel_4, TIM_USE_PWM, 0, GPIO_AF_2, NULL, 0 }, // PWM4 - { TIM16, IO_TAG(PB8), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_1, NULL, 0 }, // PWM5 - { TIM17, IO_TAG(PB9), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_1, NULL, 0 }, // PWM6 - { TIM15, IO_TAG(PA2), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_9, NULL, 0 }, // SOFTSERIAL1 RX (NC) - { TIM15, IO_TAG(PA3), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_9, NULL, 0 }, // SOFTSERIAL1 TX - { TIM1, IO_TAG(PA8), TIM_Channel_1, TIM_USE_MOTOR | TIM_USE_LED, 1, GPIO_AF_6, DMA1_Channel2, DMA1_CH2_HANDLER }, // LED_STRIP + DEF_TIM(TIM2, CH1, PA15, TIM_USE_PWM | TIM_USE_PPM, 0), // PPM/SERIAL RX + DEF_TIM(TIM3, CH1, PB4, TIM_USE_PWM, 0), // PWM1 + DEF_TIM(TIM3, CH2, PB5, TIM_USE_PWM, 0), // PWM2 + DEF_TIM(TIM3, CH3, PB0, TIM_USE_PWM, 0), // PWM3 + DEF_TIM(TIM3, CH4, PB1, TIM_USE_PWM, 0), // PWM4 + DEF_TIM(TIM16, CH1, PB8, TIM_USE_MOTOR, 1), // PWM5 + DEF_TIM(TIM17, CH1, PB9, TIM_USE_MOTOR, 1), // PWM6 + DEF_TIM(TIM15, CH1, PA2, TIM_USE_MOTOR, 1), // SOFTSERIAL1 RX (NC) + DEF_TIM(TIM15, CH2, PA3, TIM_USE_MOTOR, 1), // SOFTSERIAL1 TX + DEF_TIM(TIM1, CH1, PA8, TIM_USE_MOTOR | TIM_USE_LED, 1), // LED_STRIP }; diff --git a/src/main/target/SIRINFPV/target.c b/src/main/target/SIRINFPV/target.c index 920ca000c..4064c10e6 100644 --- a/src/main/target/SIRINFPV/target.c +++ b/src/main/target/SIRINFPV/target.c @@ -21,16 +21,17 @@ #include "drivers/io.h" #include "drivers/timer.h" +#include "drivers/timer_def.h" +#include "drivers/dma.h" const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { - - { TIM4, IO_TAG(PB6), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_2 }, // PWM1 - PB6 - { TIM4, IO_TAG(PB7), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_2 }, // PWM2 - PB6 - { TIM4, IO_TAG(PB8), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_2 }, // PWM3 - PB8 - { TIM4, IO_TAG(PB9), TIM_Channel_4, TIM_USE_MOTOR, 1, GPIO_AF_2 }, // PWM4 - PB9 - { TIM3, IO_TAG(PB0), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_2 }, // PWM5 - PB0 - *TIM3_CH3 - { TIM3, IO_TAG(PB1), TIM_Channel_4, TIM_USE_MOTOR, 1, GPIO_AF_2 }, // PWM6 - PB1 - *TIM3_CH4 - { TIM2, IO_TAG(PB11), TIM_Channel_4, TIM_USE_PPM, 0, GPIO_AF_1 }, // RC_CH3 - PB11 - *TIM2_CH4, USART3_RX (AF7)y + DEF_TIM(TIM4, CH1, PB6, TIM_USE_MOTOR, 1), // PWM1 - PB6 + DEF_TIM(TIM4, CH2, PB7, TIM_USE_MOTOR, 1), // PWM2 - PB6 + DEF_TIM(TIM4, CH3, PB8, TIM_USE_MOTOR, 1), // PWM3 - PB8 + DEF_TIM(TIM4, CH4, PB9, TIM_USE_MOTOR, 1), // PWM4 - PB9 + DEF_TIM(TIM3, CH3, PB0, TIM_USE_MOTOR, 1), // PWM5 - PB0 - *TIM3_CH3 + DEF_TIM(TIM3, CH4, PB1, TIM_USE_MOTOR, 1), // PWM6 - PB1 - *TIM3_CH4 + DEF_TIM(TIM2, CH4, PB11, TIM_USE_PPM, 0), // RC_CH3 - PB11 - *TIM2_CH4, USART3_RX (AF7)y }; diff --git a/src/main/target/SPARKY/target.c b/src/main/target/SPARKY/target.c index cfd144128..dd1a54c45 100644 --- a/src/main/target/SPARKY/target.c +++ b/src/main/target/SPARKY/target.c @@ -21,22 +21,22 @@ #include "drivers/io.h" #include "drivers/timer.h" +#include "drivers/timer_def.h" #include "drivers/dma.h" -const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { // 6 3-pin headers - { TIM15, IO_TAG(PB15), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_1, NULL, 0 }, // PWM1 - PB15 - TIM1_CH3N, TIM15_CH1N, *TIM15_CH2 - { TIM15, IO_TAG(PB14), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_1, NULL, 0 }, // PWM2 - PB14 - TIM1_CH2N, *TIM15_CH1 - { TIM1, IO_TAG(PA8), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_6, NULL, 0 }, // PWM3 - PA8 - *TIM1_CH1, TIM4_ETR - { TIM3, IO_TAG(PB0), TIM_Channel_3, TIM_USE_MOTOR, 0, GPIO_AF_2, NULL, 0 }, // PWM4 - PB0 - *TIM3_CH3, TIM1_CH2N, TIM8_CH2N - { TIM16, IO_TAG(PA6), TIM_Channel_1, TIM_USE_MOTOR | TIM_USE_LED, 0, GPIO_AF_1, DMA1_Channel3, DMA1_CH3_HANDLER }, // PWM5 - PA6 - *TIM3_CH1, TIM8_BKIN, TIM1_BKIN, TIM16_CH1 - { TIM2, IO_TAG(PA2), TIM_Channel_3, TIM_USE_MOTOR, 0, GPIO_AF_1, NULL, 0 }, // PWM6 - PA2 - *TIM2_CH3, !TIM15_CH1 - // PWM7 - PMW10 - { TIM3, IO_TAG(PB1), TIM_Channel_4, TIM_USE_PWM, 0, GPIO_AF_2, NULL, 0 }, // PWM7 - PB1 - *TIM3_CH4, TIM1_CH3N, TIM8_CH3N - { TIM17, IO_TAG(PA7), TIM_Channel_1, TIM_USE_PWM, 1, GPIO_AF_1, NULL, 0 }, // PWM8 - PA7 - !TIM3_CH2, *TIM17_CH1, TIM1_CH1N, TIM8_CH1 - { TIM3, IO_TAG(PA4), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_2, NULL, 0 }, // PWM9 - PA4 - *TIM3_CH2 - { TIM2, IO_TAG(PA1), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_1, NULL, 0 }, // PWM10 - PA1 - *TIM2_CH2, TIM15_CH1N // PPM PORT - Also USART2 RX (AF5) - { TIM2, IO_TAG(PA3), TIM_Channel_4, TIM_USE_PPM, 0, GPIO_AF_1, NULL, 0 } // PPM - PA3 - TIM2_CH4, TIM15_CH2 - PWM13 +const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { + DEF_TIM(TIM15, CH2, PB15, TIM_USE_MOTOR, 1), // PWM1 - PB15 - TIM1_CH3N, TIM15_CH1N, *TIM15_CH2 + DEF_TIM(TIM15, CH1, PB14, TIM_USE_MOTOR, 1), // PWM2 - PB14 - TIM1_CH2N, *TIM15_CH1 + DEF_TIM(TIM1, CH1, PA8, TIM_USE_MOTOR, 1), // PWM3 - PA8 - *TIM1_CH1, TIM4_ETR + DEF_TIM(TIM3, CH3, PB0, TIM_USE_MOTOR, 0), // PWM4 - PB0 - *TIM3_CH3, TIM1_CH2N, TIM8_CH2N + DEF_TIM(TIM16, CH1, PA6, TIM_USE_MOTOR | TIM_USE_LED, 0), // PWM5 - PA6 - *TIM3_CH1, TIM8_BKIN, TIM1_BKIN, TIM16_CH1 + DEF_TIM(TIM2, CH3, PA2, TIM_USE_MOTOR, 0), // PWM6 - PA2 - *TIM2_CH3, !TIM15_CH1 + DEF_TIM(TIM3, CH4, PB1, TIM_USE_PWM, 0), // PWM7 - PB1 - *TIM3_CH4, TIM1_CH3N, TIM8_CH3N + DEF_TIM(TIM17, CH1, PA7, TIM_USE_PWM, 1), // PWM8 - PA7 - !TIM3_CH2, *TIM17_CH1, TIM1_CH1N, TIM8_CH1 + DEF_TIM(TIM3, CH2, PA4, TIM_USE_PWM, 0), // PWM9 - PA4 - *TIM3_CH2 + DEF_TIM(TIM2, CH2, PA1, TIM_USE_PWM, 0), // PWM10 - PA1 - *TIM2_CH2, TIM15_CH1N + DEF_TIM(TIM2, CH4, PA3, TIM_USE_PPM, 0) // PPM - PA3 - TIM2_CH4, TIM15_CH2 - PWM13 }; diff --git a/src/main/target/SPRACINGF3/target.c b/src/main/target/SPRACINGF3/target.c index b09058af7..d6ff3401b 100644 --- a/src/main/target/SPRACINGF3/target.c +++ b/src/main/target/SPRACINGF3/target.c @@ -20,28 +20,27 @@ #include #include "drivers/io.h" -#include "drivers/timer.h" #include "drivers/dma.h" +#include "drivers/timer.h" +#include "drivers/timer_def.h" -const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { - { TIM2, IO_TAG(PA0), TIM_Channel_1, TIM_USE_PWM | TIM_USE_PPM, 0, GPIO_AF_1, NULL, 0 }, // RC_CH1 - PA0 - *TIM2_CH1 - { TIM2, IO_TAG(PA1), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_1, NULL, 0 }, // RC_CH2 - PA1 - *TIM2_CH2, TIM15_CH1N // Production boards swapped RC_CH3/4 swapped to make it easierTIM_USE_MOTOR, to using supplied cables - compared to first prototype. - { TIM2, IO_TAG(PB11), TIM_Channel_4, TIM_USE_PWM, 0, GPIO_AF_1, NULL, 0 }, // RC_CH3 - PB11 - *TIM2_CH4, UART3_RX (AF7) - { TIM2, IO_TAG(PB10), TIM_Channel_3, TIM_USE_PWM, 0, GPIO_AF_1, NULL, 0 }, // RC_CH4 - PB10 - *TIM2_CH3, UART3_TX (AF7) - { TIM3, IO_TAG(PB4), TIM_Channel_1, TIM_USE_PWM, 0, GPIO_AF_2, NULL, 0 }, // RC_CH5 - PB4 - *TIM3_CH1 - { TIM3, IO_TAG(PB5), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_2, NULL, 0 }, // RC_CH6 - PB5 - *TIM3_CH2 - { TIM3, IO_TAG(PB0), TIM_Channel_3, TIM_USE_PWM, 0, GPIO_AF_2, NULL, 0 }, // RC_CH7 - PB0 - *TIM3_CH3, TIM1_CH2N, TIM8_CH2N - { TIM3, IO_TAG(PB1), TIM_Channel_4, TIM_USE_PWM, 0, GPIO_AF_2, NULL, 0 }, // RC_CH8 - PB1 - *TIM3_CH4, TIM1_CH3N, TIM8_CH3N - - { TIM16, IO_TAG(PA6), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_1, DMA1_Channel3, DMA1_CH3_HANDLER }, // PWM1 - PA6 - TIM3_CH1, TIM8_BKIN, TIM1_BKIN, *TIM16_CH1 - { TIM17, IO_TAG(PA7), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_1, DMA1_Channel7, DMA1_CH7_HANDLER }, // PWM2 - PA7 - TIM3_CH2, *TIM17_CH1, TIM1_CH1N, TIM8_CH1 - { TIM4, IO_TAG(PA11), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_10, DMA1_Channel1, DMA1_CH1_HANDLER },// PWM3 - PA11 - { TIM4, IO_TAG(PA12), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_10, DMA1_Channel4, DMA1_CH4_HANDLER },// PWM4 - PA12 - { TIM4, IO_TAG(PB8), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_2, NULL, 0 }, // PWM5 - PB8 - { TIM4, IO_TAG(PB9), TIM_Channel_4, TIM_USE_MOTOR, 1, GPIO_AF_2, NULL, 0 }, // PWM6 - PB9 - { TIM15, IO_TAG(PA2), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_9, NULL, 0 }, // PWM7 - PA2 - { TIM15, IO_TAG(PA3), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_9, NULL, 0 }, // PWM8 - PA3 - - { TIM1, IO_TAG(PA8), TIM_Channel_1, TIM_USE_LED, 1, GPIO_AF_6, DMA1_Channel2, DMA1_CH2_HANDLER }, // GPIO_TIMER / LED_STRIP +const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { + DEF_TIM(TIM2, CH1, PA0, TIM_USE_PWM | TIM_USE_PPM, 0), // RC_CH1 - PA0 - *TIM2_CH1 + DEF_TIM(TIM2, CH2, PA1, TIM_USE_PWM, 0), // RC_CH2 - PA1 - *TIM2_CH2, TIM15_CH1N + DEF_TIM(TIM2, CH4, PB11, TIM_USE_PWM, 0), // RC_CH3 - PB11 - *TIM2_CH4, UART3_RX (AF7) + DEF_TIM(TIM2, CH3, PB10, TIM_USE_PWM, 0), // RC_CH4 - PB10 - *TIM2_CH3, UART3_TX (AF7) + DEF_TIM(TIM3, CH1, PB4, TIM_USE_PWM, 0), // RC_CH5 - PB4 - *TIM3_CH1 + DEF_TIM(TIM3, CH2, PB5, TIM_USE_PWM, 0), // RC_CH6 - PB5 - *TIM3_CH2 + DEF_TIM(TIM3, CH3, PB0, TIM_USE_PWM, 0), // RC_CH7 - PB0 - *TIM3_CH3, TIM1_CH2N, TIM8_CH2N + DEF_TIM(TIM3, CH4, PB1, TIM_USE_PWM, 0), // RC_CH8 - PB1 - *TIM3_CH4, TIM1_CH3N, TIM8_CH3N + DEF_TIM(TIM16, CH1, PA6, TIM_USE_MOTOR, 1), // PWM1 - PA6 - TIM3_CH1, TIM8_BKIN, TIM1_BKIN, *TIM16_CH1 + DEF_TIM(TIM17, CH1, PA7, TIM_USE_MOTOR, 1), // PWM2 - PA7 - TIM3_CH2, *TIM17_CH1, TIM1_CH1N, TIM8_CH1 + DEF_TIM(TIM4, CH1, PA11, TIM_USE_MOTOR, 1), // PWM3 - PA11 + DEF_TIM(TIM4, CH2, PA12, TIM_USE_MOTOR, 1), // PWM4 - PA12 + DEF_TIM(TIM4, CH3, PB8, TIM_USE_MOTOR, 1), // PWM5 - PB8 + DEF_TIM(TIM4, CH4, PB9, TIM_USE_MOTOR, 1), // PWM6 - PB9 + DEF_TIM(TIM15, CH1, PA2, TIM_USE_MOTOR, 1), // PWM7 - PA2 + DEF_TIM(TIM15, CH2, PA3, TIM_USE_MOTOR, 1), // PWM8 - PA3 + DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 1), // GPIO_TIMER / LED_STRIP }; diff --git a/src/main/target/SPRACINGF3MINI/target.c b/src/main/target/SPRACINGF3MINI/target.c index 7147c4a1f..69399fb95 100644 --- a/src/main/target/SPRACINGF3MINI/target.c +++ b/src/main/target/SPRACINGF3MINI/target.c @@ -21,32 +21,29 @@ #include "drivers/io.h" #include "drivers/timer.h" +#include "drivers/timer_def.h" #include "drivers/dma.h" const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { // PPM Pad #ifdef SPRACINGF3MINI_MKII_REVA - { TIM3, IO_TAG(PB5), TIM_Channel_2, TIM_USE_PPM, 0, GPIO_AF_2, NULL, 0 }, // PPM - PB5 + DEF_TIM(TIM3, CH2, PB5, TIM_USE_PPM, 0), // PPM - PB5 // PB4 / TIM3 CH1 is connected to USBPresent #else - { TIM3, IO_TAG(PB4), TIM_Channel_1, TIM_USE_PPM, 0, GPIO_AF_2, NULL, 0 }, // PPM - PB4 + DEF_TIM(TIM3, CH1, PB4, TIM_USE_PPM, 0), // PPM - PB4 // PB5 / TIM3 CH2 is connected to USBPresent #endif - { TIM16, IO_TAG(PA6), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_1, NULL, 0 }, // PWM1 - PA6 - { TIM17, IO_TAG(PA7), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_1, NULL, 0 }, // PWM2 - PA7 - { TIM4, IO_TAG(PB8), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_2, NULL, 0 }, // PWM3 - PB8 - { TIM4, IO_TAG(PB9), TIM_Channel_4, TIM_USE_MOTOR, 1, GPIO_AF_2, NULL, 0 }, // PWM4 - PB9 - { TIM15, IO_TAG(PA2), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_9, NULL, 0 }, // PWM5 - PA2 - { TIM15, IO_TAG(PA3), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_9, NULL, 0 }, // PWM6 - PA3 - { TIM2, IO_TAG(PA0), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_1, NULL, 0 }, // PWM7 - PA0 - { TIM2, IO_TAG(PA1), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_1, NULL, 0 }, // PWM8 - PA1 - - // UART3 RX/TX - { TIM2, IO_TAG(PB10), TIM_Channel_3, 0, 1, GPIO_AF_1, NULL, 0 }, // PWM9 - PB10 - TIM2_CH3 / UART3_TX (AF7) - { TIM2, IO_TAG(PB11), TIM_Channel_4, 0, 1, GPIO_AF_1, NULL, 0 }, // PWM10 - PB11 - TIM2_CH4 / UART3_RX (AF7) - - // LED Strip Pad - { TIM1, IO_TAG(PA8), TIM_Channel_1, TIM_USE_LED, 1, GPIO_AF_6, DMA1_Channel2, DMA1_CH2_HANDLER }, // GPIO_TIMER / LED_STRIP + DEF_TIM(TIM16, CH1, PA6, TIM_USE_MOTOR, 1), // PWM1 - PA6 + DEF_TIM(TIM17, CH1, PA7, TIM_USE_MOTOR, 1), // PWM2 - PA7 + DEF_TIM(TIM4, CH3, PB8, TIM_USE_MOTOR, 1), // PWM3 - PB8 + DEF_TIM(TIM4, CH4, PB9, TIM_USE_MOTOR, 1), // PWM4 - PB9 + DEF_TIM(TIM15, CH1, PA2, TIM_USE_MOTOR, 1), // PWM5 - PA2 + DEF_TIM(TIM15, CH2, PA3, TIM_USE_MOTOR, 1), // PWM6 - PA3 + DEF_TIM(TIM2, CH1, PA0, TIM_USE_MOTOR, 1), // PWM7 - PA0 + DEF_TIM(TIM2, CH2, PA1, TIM_USE_MOTOR, 1), // PWM8 - PA1 + DEF_TIM(TIM2, CH3, PB10, TIM_USE_NONE, 1), // PWM9 - PB10 - TIM2_CH3 / UART3_TX (AF7) + DEF_TIM(TIM2, CH4, PB11, TIM_USE_NONE, 1), // PWM10 - PB11 - TIM2_CH4 / UART3_RX (AF7) + DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 1), // GPIO_TIMER / LED_STRIP }; diff --git a/src/main/target/VRRACE/target.c b/src/main/target/VRRACE/target.c index aff64adfb..88754414f 100644 --- a/src/main/target/VRRACE/target.c +++ b/src/main/target/VRRACE/target.c @@ -21,18 +21,20 @@ #include "drivers/io.h" #include "drivers/timer.h" +#include "drivers/timer_def.h" +#include "drivers/dma.h" const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { - { TIM1, IO_TAG(PE9), TIM_Channel_1, TIM_USE_PWM | TIM_USE_PPM, 0, GPIO_AF_TIM1 }, // PPM - { TIM1, IO_TAG(PE11), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_TIM1 }, // S2_IN - { TIM1, IO_TAG(PE13), TIM_Channel_3, TIM_USE_PWM, 0, GPIO_AF_TIM1 }, // S3_IN - { TIM1, IO_TAG(PE14), TIM_Channel_4, TIM_USE_PWM, 0, GPIO_AF_TIM1 }, // S4_IN - { TIM9, IO_TAG(PE6), TIM_Channel_1, TIM_USE_PWM, 0, GPIO_AF_TIM9 }, // S5_IN - { TIM9, IO_TAG(PE7), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_TIM9 }, // S6_IN - { TIM2, IO_TAG(PA1), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_TIM2 }, // S1_OUT - { TIM2, IO_TAG(PA2), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_TIM2 }, // S2_OUT - { TIM2, IO_TAG(PA3), TIM_Channel_4, TIM_USE_MOTOR, 1, GPIO_AF_TIM2 }, // S3_OUT - { TIM3, IO_TAG(PB5), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_TIM3 }, // S4_OUT - { TIM3, IO_TAG(PB0), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_TIM3 }, // S5_OUT - { TIM3, IO_TAG(PB1), TIM_Channel_4, TIM_USE_MOTOR, 1, GPIO_AF_TIM3 }, // S6_OUT -}; + DEF_TIM(TIM1, CH1, PE9, TIM_USE_PWM | TIM_USE_PPM, 0, 0), // PPM + DEF_TIM(TIM1, CH2, PE11, TIM_USE_PWM, 0, 0), // S2_IN + DEF_TIM(TIM1, CH3, PE13, TIM_USE_PWM, 0, 0), // S3_IN + DEF_TIM(TIM1, CH4, PE14, TIM_USE_PWM, 0, 0), // S4_IN + DEF_TIM(TIM9, CH1, PE6, TIM_USE_PWM, 0, 0), // S5_IN + DEF_TIM(TIM9, CH2, PE7, TIM_USE_PWM, 0, 0), // S6_IN + DEF_TIM(TIM2, CH2, PA1, TIM_USE_MOTOR, 1, 0), // S1_OUT + DEF_TIM(TIM2, CH3, PA2, TIM_USE_MOTOR, 1, 0), // S2_OUT + DEF_TIM(TIM2, CH4, PA3, TIM_USE_MOTOR, 1, 0), // S3_OUT + DEF_TIM(TIM3, CH2, PB5, TIM_USE_MOTOR, 1, 0), // S4_OUT + DEF_TIM(TIM3, CH3, PB0, TIM_USE_MOTOR, 1, 0), // S5_OUT + DEF_TIM(TIM3, CH4, PB1, TIM_USE_MOTOR, 1, 0), // S6_OUT +}; \ No newline at end of file diff --git a/src/main/target/X_RACERSPI/target.c b/src/main/target/X_RACERSPI/target.c index 045633276..82fec06d1 100644 --- a/src/main/target/X_RACERSPI/target.c +++ b/src/main/target/X_RACERSPI/target.c @@ -6,24 +6,23 @@ #include "drivers/io.h" #include "drivers/timer.h" +#include "drivers/timer_def.h" #include "drivers/dma.h" const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { - { TIM2, IO_TAG(PA0), TIM_Channel_1, TIM_USE_PWM | TIM_USE_PPM, 0, GPIO_AF_1, NULL, 0 }, // RC_CH1 - PA0 - *TIM2_CH1 - { TIM2, IO_TAG(PA1), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_1 , NULL, 0}, // RC_CH2 - PA1 - *TIM2_CH2, TIM15_CH1N - { TIM2, IO_TAG(PB11), TIM_Channel_4, TIM_USE_PWM, 0, GPIO_AF_1 , NULL, 0}, // RC_CH3 - PB11 - *TIM2_CH4, UART3_RX (AF7) - { TIM2, IO_TAG(PB10), TIM_Channel_3, TIM_USE_PWM, 0, GPIO_AF_1 , NULL, 0}, // RC_CH4 - PB10 - *TIM2_CH3, UART3_TX (AF7) - { TIM3, IO_TAG(PB0), TIM_Channel_3, TIM_USE_PWM, 0, GPIO_AF_2 , NULL, 0}, // RC_CH5 - PB0 - *TIM3_CH3, TIM1_CH2N, TIM8_CH2N - { TIM3, IO_TAG(PB1), TIM_Channel_4, TIM_USE_PWM, 0, GPIO_AF_2 , NULL, 0}, // RC_CH6 - PB1 - *TIM3_CH4, TIM1_CH3N, TIM8_CH3N - - { TIM16, IO_TAG(PA6), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_1, DMA1_Channel3, DMA1_CH3_HANDLER }, // PWM1 - PA6 - TIM3_CH1, TIM8_BKIN, TIM1_BKIN, *TIM16_CH1 - { TIM17, IO_TAG(PA7), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_1, DMA1_Channel7, DMA1_CH7_HANDLER }, // PWM2 - PA7 - TIM3_CH2, *TIM17_CH1, TIM1_CH1N, TIM8_CH1 - { TIM4, IO_TAG(PA11), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_10, DMA1_Channel1, DMA1_CH1_HANDLER },// PWM3 - PA11 - { TIM4, IO_TAG(PA12), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_10, DMA1_Channel4, DMA1_CH4_HANDLER },// PWM4 - PA12 - - { TIM4, IO_TAG(PB8), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_2 , NULL, 0}, // PWM5 - PB8 - { TIM4, IO_TAG(PB9), TIM_Channel_4, TIM_USE_MOTOR, 1, GPIO_AF_2 , NULL, 0}, // PWM6 - PB9 - { TIM15, IO_TAG(PA2), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_9 , NULL, 0}, // PWM7 - PA2 - { TIM15, IO_TAG(PA3), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_9 , NULL, 0}, // PWM8 - PA3 - { TIM1, IO_TAG(PA8), TIM_Channel_1, TIM_USE_MOTOR | TIM_USE_LED, 1, GPIO_AF_6 , DMA1_Channel2, DMA1_CH2_HANDLER}, // GPIO_TIMER / LED_STRIP + DEF_TIM(TIM2, CH1, PA0, TIM_USE_PWM | TIM_USE_PPM, 0), // RC_CH1 - PA0 - *TIM2_CH1 + DEF_TIM(TIM2, CH2, PA1, TIM_USE_PWM, 0), // RC_CH2 - PA1 - *TIM2_CH2, TIM15_CH1N + DEF_TIM(TIM2, CH4, PB11, TIM_USE_PWM, 0), // RC_CH3 - PB11 - *TIM2_CH4, UART3_RX (AF7) + DEF_TIM(TIM2, CH3, PB10, TIM_USE_PWM, 0), // RC_CH4 - PB10 - *TIM2_CH3, UART3_TX (AF7) + DEF_TIM(TIM3, CH3, PB0, TIM_USE_PWM, 0), // RC_CH5 - PB0 - *TIM3_CH3, TIM1_CH2N, TIM8_CH2N + DEF_TIM(TIM3, CH4, PB1, TIM_USE_PWM, 0), // RC_CH6 - PB1 - *TIM3_CH4, TIM1_CH3N, TIM8_CH3N + DEF_TIM(TIM16, CH1, PA6, TIM_USE_MOTOR, 1), // PWM1 - PA6 - TIM3_CH1, TIM8_BKIN, TIM1_BKIN, *TIM16_CH1 + DEF_TIM(TIM17, CH1, PA7, TIM_USE_MOTOR, 1), // PWM2 - PA7 - TIM3_CH2, *TIM17_CH1, TIM1_CH1N, TIM8_CH1 + DEF_TIM(TIM4, CH1, PA11, TIM_USE_MOTOR, 1), // PWM3 - PA11 + DEF_TIM(TIM4, CH2, PA12, TIM_USE_MOTOR, 1), // PWM4 - PA12 + DEF_TIM(TIM4, CH3, PB8, TIM_USE_MOTOR, 1), // PWM5 - PB8 + DEF_TIM(TIM4, CH4, PB9, TIM_USE_MOTOR, 1), // PWM6 - PB9 + DEF_TIM(TIM15, CH1, PA2, TIM_USE_MOTOR, 1), // PWM7 - PA2 + DEF_TIM(TIM15, CH2, PA3, TIM_USE_MOTOR, 1), // PWM8 - PA3 + DEF_TIM(TIM1, CH1, PA8, TIM_USE_MOTOR | TIM_USE_LED, 1), // GPIO_TIMER / LED_STRIP }; diff --git a/src/main/target/ZCOREF3/target.c b/src/main/target/ZCOREF3/target.c index 72d860c3f..f85061242 100644 --- a/src/main/target/ZCOREF3/target.c +++ b/src/main/target/ZCOREF3/target.c @@ -5,25 +5,27 @@ #include #include "drivers/io.h" +#include "drivers/dma.h" #include "drivers/timer.h" +#include "drivers/timer_def.h" const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { - { TIM2, IO_TAG(PA0), TIM_Channel_1, TIM_USE_PWM | TIM_USE_PPM, 0, GPIO_AF_1 }, // RC_CH1 - PA0 - *TIM2_CH1 - { TIM2, IO_TAG(PA1), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_1 }, // RC_CH2 - PA1 - *TIM2_CH2, TIM15_CH1N - { TIM2, IO_TAG(PB11), TIM_Channel_4, TIM_USE_PWM, 0, GPIO_AF_1 }, // RC_CH3 - PB11 - *TIM2_CH4, UART3_RX (AF7) - { TIM2, IO_TAG(PB10), TIM_Channel_3, TIM_USE_PWM, 0, GPIO_AF_1 }, // RC_CH4 - PB10 - *TIM2_CH3, UART3_TX (AF7) - { TIM3, IO_TAG(PB4), TIM_Channel_1, TIM_USE_PWM, 0, GPIO_AF_2 }, // RC_CH5 - PB4 - *TIM3_CH1 - { TIM3, IO_TAG(PB5), TIM_Channel_2, TIM_USE_PWM, 0, GPIO_AF_2 }, // RC_CH6 - PB5 - *TIM3_CH2 - { TIM3, IO_TAG(PB0), TIM_Channel_3, TIM_USE_PWM, 0, GPIO_AF_2 }, // RC_CH7 - PB0 - *TIM3_CH3, TIM1_CH2N, TIM8_CH2N - { TIM3, IO_TAG(PB1), TIM_Channel_4, TIM_USE_PWM, 0, GPIO_AF_2 }, // RC_CH8 - PB1 - *TIM3_CH4, TIM1_CH3N, TIM8_CH3N - { TIM16, IO_TAG(PA6), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_1 }, // PWM1 - PA6 - TIM3_CH1, TIM8_BKIN, TIM1_BKIN, *TIM16_CH1 - { TIM17, IO_TAG(PA7), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_1 }, // PWM2 - PA7 - TIM3_CH2, *TIM17_CH1, TIM1_CH1N, TIM8_CH1 - { TIM4, IO_TAG(PA11), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_10 }, // PWM3 - PA11 - { TIM4, IO_TAG(PA12), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_10 }, // PWM4 - PA12 - { TIM4, IO_TAG(PB8), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_2 }, // PWM5 - PB8 - { TIM4, IO_TAG(PB9), TIM_Channel_4, TIM_USE_MOTOR, 1, GPIO_AF_2 }, // PWM6 - PB9 - { TIM15, IO_TAG(PA2), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_9 }, // PWM7 - PA2 - { TIM15, IO_TAG(PA3), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_9 }, // PWM8 - PA3 - { TIM1, IO_TAG(PA8), TIM_Channel_1, TIM_USE_LED, 1, GPIO_AF_6 }, // GPIO_TIMER / LED_STRIP + DEF_TIM(TIM2, CH1, PA0, TIM_USE_PWM | TIM_USE_PPM, 0), // RC_CH1 - PA0 - *TIM2_CH1 + DEF_TIM(TIM2, CH2, PA1, TIM_USE_PWM, 0), // RC_CH2 - PA1 - *TIM2_CH2, TIM15_CH1N + DEF_TIM(TIM2, CH4, PB11, TIM_USE_PWM, 0), // RC_CH3 - PB11 - *TIM2_CH4, UART3_RX (AF7) + DEF_TIM(TIM2, CH3, PB10, TIM_USE_PWM, 0), // RC_CH4 - PB10 - *TIM2_CH3, UART3_TX (AF7) + DEF_TIM(TIM3, CH1, PB4, TIM_USE_PWM, 0), // RC_CH5 - PB4 - *TIM3_CH1 + DEF_TIM(TIM3, CH2, PB5, TIM_USE_PWM, 0), // RC_CH6 - PB5 - *TIM3_CH2 + DEF_TIM(TIM3, CH3, PB0, TIM_USE_PWM, 0), // RC_CH7 - PB0 - *TIM3_CH3, TIM1_CH2N, TIM8_CH2N + DEF_TIM(TIM3, CH4, PB1, TIM_USE_PWM, 0), // RC_CH8 - PB1 - *TIM3_CH4, TIM1_CH3N, TIM8_CH3N + DEF_TIM(TIM16, CH1, PA6, TIM_USE_MOTOR, 1), // PWM1 - PA6 - TIM3_CH1, TIM8_BKIN, TIM1_BKIN, *TIM16_CH1 + DEF_TIM(TIM17, CH1, PA7, TIM_USE_MOTOR, 1), // PWM2 - PA7 - TIM3_CH2, *TIM17_CH1, TIM1_CH1N, TIM8_CH1 + DEF_TIM(TIM4, CH1, PA11, TIM_USE_MOTOR, 1), // PWM3 - PA11 + DEF_TIM(TIM4, CH2, PA12, TIM_USE_MOTOR, 1), // PWM4 - PA12 + DEF_TIM(TIM4, CH3, PB8, TIM_USE_MOTOR, 1), // PWM5 - PB8 + DEF_TIM(TIM4, CH4, PB9, TIM_USE_MOTOR, 1), // PWM6 - PB9 + DEF_TIM(TIM15, CH1, PA2, TIM_USE_MOTOR, 1), // PWM7 - PA2 + DEF_TIM(TIM15, CH2, PA3, TIM_USE_MOTOR, 1), // PWM8 - PA3 + DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 1), // GPIO_TIMER / LED_STRIP }; diff --git a/src/main/target/common.h b/src/main/target/common.h index fa3af098b..fd0e869c1 100644 --- a/src/main/target/common.h +++ b/src/main/target/common.h @@ -20,28 +20,28 @@ #define I2C1_OVERCLOCK true #define I2C2_OVERCLOCK true +#ifdef STM32F7 +#define STM_FAST_TARGET +#endif -// STM32F4 specific settings that apply to all F4 targets +/**************************** + STM32 F4 specific settings. +****************************/ #ifdef STM32F4 +#define STM_FAST_TARGET +#define USE_DSHOT +#define I2C3_OVERCLOCK true +#endif -#define MAX_AUX_CHANNELS 99 -#define TASK_GYROPID_DESIRED_PERIOD 125 -#define SCHEDULER_DELAY_LIMIT 10 -#define I2C3_OVERCLOCK true - -#else // when not an F4 - -#define MAX_AUX_CHANNELS 6 -#define TASK_GYROPID_DESIRED_PERIOD 1000 -#define SCHEDULER_DELAY_LIMIT 100 - -#endif // STM32F4 +#ifdef STM32F3 +#define USE_DSHOT +#endif #ifdef STM32F1 // Using RX DMA disables the use of receive callbacks #define USE_UART1_RX_DMA #define USE_UART1_TX_DMA -#endif // STM32F1 +#endif #define SERIAL_RX #define USE_SERIALRX_SPEKTRUM // DSM2 and DSMX protocol @@ -52,6 +52,16 @@ #define USE_SERIALRX_XBUS // JR #define USE_CLI +#if defined(STM_FAST_TARGET) +#define MAX_AUX_CHANNELS 99 +#define TASK_GYROPID_DESIRED_PERIOD 125 +#define SCHEDULER_DELAY_LIMIT 10 +#else +#define MAX_AUX_CHANNELS 6 +#define TASK_GYROPID_DESIRED_PERIOD 1000 +#define SCHEDULER_DELAY_LIMIT 100 +#endif + #if (FLASH_SIZE > 64) #define BLACKBOX #define GPS