2 * This file is part of Cleanflight.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
21 #include "drivers/io.h"
23 #include "drivers/timer.h"
24 #include "drivers/timer_def.h"
25 #include "drivers/dma.h"
28 const timerHardware_t timerHardware
[USABLE_TIMER_CHANNEL_COUNT
] = {
29 { TIM9
, IO_TAG(PA3
), TIM_Channel_2
, TIM_USE_PPM
| TIM_USE_PWM
, 0, GPIO_AF_TIM9
, NULL
, 0, 0 }, // PPM / PWM1 / UART2 RX
30 { TIM9
, IO_TAG(PA2
), TIM_Channel_1
, TIM_USE_PWM
, 0, GPIO_AF_TIM9
, NULL
, 0, 0 }, // PPM / PWM2 / UART2 TX
32 { TIM8
, IO_TAG(PC6
), TIM_Channel_1
, TIM_USE_MOTOR
, 1, GPIO_AF_TIM8
, DMA2_Stream2
, DMA_Channel_7
, DMA2_ST2_HANDLER
}, // ESC 1
33 { TIM8
, IO_TAG(PC7
), TIM_Channel_2
, TIM_USE_MOTOR
, 1, GPIO_AF_TIM8
, DMA2_Stream3
, DMA_Channel_7
, DMA2_ST3_HANDLER
}, // ESC 2
34 { TIM8
, IO_TAG(PC9
), TIM_Channel_4
, TIM_USE_MOTOR
, 1, GPIO_AF_TIM8
, DMA2_Stream7
, DMA_Channel_7
, DMA2_ST7_HANDLER
}, // ESC 3
35 { TIM8
, IO_TAG(PC8
), TIM_Channel_3
, TIM_USE_MOTOR
, 1, GPIO_AF_TIM8
, DMA2_Stream4
, DMA_Channel_7
, DMA2_ST4_HANDLER
}, // ESC 4
37 #if (SPRACINGF4EVO_REV >= 2)
38 { 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
39 { 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
41 #ifdef USE_TIM10_TIM11_FOR_MOTORS
42 { TIM10
, IO_TAG(PB8
), TIM_Channel_1
, TIM_USE_MOTOR
, 1, GPIO_AF_TIM10
, NULL
, 0, 0 }, // ESC 5
43 { TIM11
, IO_TAG(PB9
), TIM_Channel_1
, TIM_USE_MOTOR
, 1, GPIO_AF_TIM11
, NULL
, 0, 0 }, // ESC 6
45 { TIM4
, IO_TAG(PB8
), TIM_Channel_3
, TIM_USE_MOTOR
, 1, GPIO_AF_TIM4
, DMA1_Stream7
, DMA_Channel_2
, DMA1_ST7_HANDLER
}, // ESC 5
46 { TIM4
, IO_TAG(PB9
), TIM_Channel_4
, TIM_USE_MOTOR
, 1, GPIO_AF_TIM4
, NULL
, 0, 0 }, // ESC 6
49 { TIM3
, IO_TAG(PB1
), TIM_Channel_4
, TIM_USE_MOTOR
, 1, GPIO_AF_TIM3
, DMA1_Stream2
, DMA_Channel_5
, DMA1_ST2_HANDLER
}, // ESC 7
50 { TIM3
, IO_TAG(PB0
), TIM_Channel_3
, TIM_USE_MOTOR
, 1, GPIO_AF_TIM3
, DMA1_Stream7
, DMA_Channel_5
, DMA1_ST7_HANDLER
}, // ESC 8
53 { TIM2
, IO_TAG(PA1
), TIM_Channel_2
, TIM_USE_LED
, 1, GPIO_AF_TIM2
, DMA1_Stream6
, DMA_Channel_3
, DMA1_ST6_HANDLER
}, // LED Strip
54 // Additional 2 PWM channels available on UART3 RX/TX pins
55 // However, when using led strip the timer cannot be used, but no code appears to prevent that right now
56 { 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)
57 { 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
59 { TIM1
, IO_TAG(PA8
), TIM_Channel_1
, TIM_USE_TRANSPONDER
, 1, GPIO_AF_TIM1
, DMA2_Stream6
, DMA_Channel_0
, DMA2_ST6_HANDLER
}, // Transponder
60 // Additional 2 PWM channels available on UART1 RX/TX pins
61 // However, when using transponder the timer cannot be used, but no code appears to prevent that right now
62 { 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
63 { 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