From 60cf02354f470daeef6587abd6933c02197fc7a8 Mon Sep 17 00:00:00 2001 From: Miguel Date: Fri, 31 Mar 2017 15:04:27 +0200 Subject: [PATCH] Change the timerHardware_t to use the DEF_TIM macro --- src/main/target/SPRACINGF4EVO/target.c | 43 +++++++++++++------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/main/target/SPRACINGF4EVO/target.c b/src/main/target/SPRACINGF4EVO/target.c index 94730870f..cead1a861 100644 --- a/src/main/target/SPRACINGF4EVO/target.c +++ b/src/main/target/SPRACINGF4EVO/target.c @@ -26,39 +26,40 @@ const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { - { TIM9, IO_TAG(PA3), TIM_Channel_2, TIM_USE_PPM | TIM_USE_PWM, 0, GPIO_AF_TIM9, NULL, 0, 0 }, // PPM / PWM1 / UART2 RX - { TIM9, IO_TAG(PA2), TIM_Channel_1, TIM_USE_PWM, 0, GPIO_AF_TIM9, NULL, 0, 0 }, // PPM / PWM2 / UART2 TX - { TIM8, IO_TAG(PC6), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_TIM8, DMA2_Stream2, DMA_Channel_7, DMA2_ST2_HANDLER }, // ESC 1 - { TIM8, IO_TAG(PC7), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_TIM8, DMA2_Stream3, DMA_Channel_7, DMA2_ST3_HANDLER }, // ESC 2 - { TIM8, IO_TAG(PC9), TIM_Channel_4, TIM_USE_MOTOR, 1, GPIO_AF_TIM8, DMA2_Stream7, DMA_Channel_7, DMA2_ST7_HANDLER }, // ESC 3 - { TIM8, IO_TAG(PC8), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_TIM8, DMA2_Stream4, DMA_Channel_7, DMA2_ST4_HANDLER }, // ESC 4 + DEF_TIM(TIM9, CH2, PA3, TIM_USE_PPM | TIM_USE_PWM, 0, 0), // PPM / PWM1 / UART2 RX + DEF_TIM(TIM9, CH1, PA2, TIM_USE_PWM, 0, 0), // PPM / PWM2 / UART2 TX + + DEF_TIM(TIM8, CH1, PC6, TIM_USE_MOTOR, 1, 1), // ESC 1 + DEF_TIM(TIM8, CH2, PC7, TIM_USE_MOTOR, 1, 1), // ESC 2 + DEF_TIM(TIM8, CH4, PC9, TIM_USE_MOTOR, 1, 0), // ESC 3 + DEF_TIM(TIM8, CH3, PC8, TIM_USE_MOTOR, 1, 1), // ESC 4 #if (SPRACINGF4EVO_REV >= 2) - { TIM4, IO_TAG(PB6), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_TIM4, DMA1_Stream0, DMA_Channel_2, DMA1_ST0_HANDLER }, // ESC 5 / Conflicts with USART5_RX / SPI3_RX - SPI3_RX can be mapped to DMA1_ST3_CH0 - { TIM4, IO_TAG(PB7), TIM_Channel_2, TIM_USE_MOTOR, 1, GPIO_AF_TIM4, DMA1_Stream3, DMA_Channel_2, DMA1_ST3_HANDLER }, // ESC 6 / Conflicts with USART3_RX + DEF_TIM(TIM4, CH1, PB6, TIM_USE_MOTOR, 1, 0), // ESC 5 / Conflicts with USART5_RX / SPI3_RX - SPI3_RX can be mapped to DMA1_ST3_CH0 + DEF_TIM(TIM4, CH2, PB7, TIM_USE_MOTOR, 1, 0), // ESC 6 / Conflicts with USART3_RX #else #ifdef USE_TIM10_TIM11_FOR_MOTORS - { TIM10, IO_TAG(PB8), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_TIM10, NULL, 0, 0 }, // ESC 5 - { TIM11, IO_TAG(PB9), TIM_Channel_1, TIM_USE_MOTOR, 1, GPIO_AF_TIM11, NULL, 0, 0 }, // ESC 6 + DEF_TIM(TIM10, CH1, PB8, TIM_USE_MOTOR, 1, 0), // ESC 5 + DEF_TIM(TIM11, CH1, PB9, TIM_USE_MOTOR, 1, 0), // ESC 6 #else - { TIM4, IO_TAG(PB8), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_TIM4, DMA1_Stream7, DMA_Channel_2, DMA1_ST7_HANDLER }, // ESC 5 - { TIM4, IO_TAG(PB9), TIM_Channel_4, TIM_USE_MOTOR, 1, GPIO_AF_TIM4, NULL, 0, 0 }, // ESC 6 + DEF_TIM(TIM4, CH3, PB8, TIM_USE_MOTOR, 1, 0), // ESC 5 + DEF_TIM(TIM4, CH4, PB9, TIM_USE_MOTOR, 1, 0), // ESC 6 #endif #endif - { TIM3, IO_TAG(PB1), TIM_Channel_4, TIM_USE_MOTOR, 1, GPIO_AF_TIM3, DMA1_Stream2, DMA_Channel_5, DMA1_ST2_HANDLER }, // ESC 7 - { TIM3, IO_TAG(PB0), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_TIM3, DMA1_Stream7, DMA_Channel_5, DMA1_ST7_HANDLER }, // ESC 8 + DEF_TIM(TIM3, CH4, PB1, TIM_USE_MOTOR, 1, 0), // ESC 7 + DEF_TIM(TIM3, CH3, PB0, TIM_USE_MOTOR, 1, 0), // ESC 8 - - { TIM2, IO_TAG(PA1), TIM_Channel_2, TIM_USE_LED, 1, GPIO_AF_TIM2, DMA1_Stream6, DMA_Channel_3, DMA1_ST6_HANDLER }, // LED Strip + DEF_TIM(TIM2, CH2, PA1, TIM_USE_LED, 1, 0), // LED Strip // Additional 2 PWM channels available on UART3 RX/TX pins // However, when using led strip the timer cannot be used, but no code appears to prevent that right now - { TIM2, IO_TAG(PB10), TIM_Channel_3, TIM_USE_MOTOR, 1, GPIO_AF_TIM2, DMA1_Stream1, DMA_Channel_3, DMA1_ST1_HANDLER }, // Shared with UART3 TX PIN and SPI3 TX (OSD) - { TIM2, IO_TAG(PB11), TIM_Channel_4, TIM_USE_MOTOR, 1, GPIO_AF_TIM2, DMA1_Stream6, DMA_Channel_3, DMA1_ST6_HANDLER }, // Shared with UART3 RX PIN + DEF_TIM(TIM2, CH3, PB10, TIM_USE_MOTOR, 1, 0), // Shared with UART3 TX PIN and SPI3 TX (OSD) + DEF_TIM(TIM2, CH4, PB11, TIM_USE_MOTOR, 1, 1), // Shared with UART3 RX PIN - { TIM1, IO_TAG(PA8), TIM_Channel_1, TIM_USE_TRANSPONDER, 1, GPIO_AF_TIM1, DMA2_Stream6, DMA_Channel_0, DMA2_ST6_HANDLER }, // Transponder + DEF_TIM(TIM1, CH1, PA8, TIM_USE_TRANSPONDER, 1, 0), // Transponder // Additional 2 PWM channels available on UART1 RX/TX pins // However, when using transponder the timer cannot be used, but no code appears to prevent that right now - { TIM1, IO_TAG(PA9), TIM_Channel_2, TIM_USE_SERVO | TIM_USE_PWM, 1, GPIO_AF_TIM1, DMA2_Stream2, DMA_Channel_6, DMA2_ST2_HANDLER }, // PWM 3 - { TIM1, IO_TAG(PA10), TIM_Channel_3, TIM_USE_SERVO | TIM_USE_PWM, 1, GPIO_AF_TIM1, DMA2_Stream6, DMA_Channel_6, DMA2_ST6_HANDLER }, // PWM 4 + DEF_TIM(TIM1, CH2, PA9, TIM_USE_SERVO | TIM_USE_PWM, 1, 1), // PWM 3 + DEF_TIM(TIM1, CH3, PA10, TIM_USE_SERVO | TIM_USE_PWM, 1, 1), // PWM 4 + };