diff --git a/boards/matek/h743-slim/src/board_config.h b/boards/matek/h743-slim/src/board_config.h index 13db68ab37..9653dbb43f 100644 --- a/boards/matek/h743-slim/src/board_config.h +++ b/boards/matek/h743-slim/src/board_config.h @@ -111,8 +111,8 @@ /* PWM */ -#define DIRECT_PWM_OUTPUT_CHANNELS 8 -#define DIRECT_INPUT_TIMER_CHANNELS 8 +#define DIRECT_PWM_OUTPUT_CHANNELS 10 +#define DIRECT_INPUT_TIMER_CHANNELS 10 #define BOARD_HAS_PWM DIRECT_PWM_OUTPUT_CHANNELS diff --git a/boards/matek/h743-slim/src/timer_config.cpp b/boards/matek/h743-slim/src/timer_config.cpp index bcdc7de7cf..3f1ac93e6f 100644 --- a/boards/matek/h743-slim/src/timer_config.cpp +++ b/boards/matek/h743-slim/src/timer_config.cpp @@ -37,7 +37,7 @@ constexpr io_timers_t io_timers[MAX_IO_TIMERS] = { initIOTimer(Timer::Timer3, DMA{DMA::Index1, DMA::Stream2, DMA::Channel5}), initIOTimer(Timer::Timer5, DMA{DMA::Index1, DMA::Stream0, DMA::Channel6}), initIOTimer(Timer::Timer4, DMA{DMA::Index1, DMA::Stream6, DMA::Channel2}), - // initIOTimer(Timer::Timer15), + initIOTimer(Timer::Timer15), }; constexpr timer_io_channels_t timer_io_channels[MAX_TIMER_IO_CHANNELS] = { @@ -49,10 +49,10 @@ constexpr timer_io_channels_t timer_io_channels[MAX_TIMER_IO_CHANNELS] = { initIOTimerChannel(io_timers, {Timer::Timer5, Timer::Channel4}, {GPIO::PortA, GPIO::Pin3}), initIOTimerChannel(io_timers, {Timer::Timer4, Timer::Channel1}, {GPIO::PortD, GPIO::Pin12}), initIOTimerChannel(io_timers, {Timer::Timer4, Timer::Channel2}, {GPIO::PortD, GPIO::Pin13}), + initIOTimerChannel(io_timers, {Timer::Timer15, Timer::Channel1}, {GPIO::PortE, GPIO::Pin5}), + initIOTimerChannel(io_timers, {Timer::Timer15, Timer::Channel2}, {GPIO::PortE, GPIO::Pin6}), // initIOTimerChannel(io_timers, {Timer::Timer4, Timer::Channel3}, {GPIO::PortD, GPIO::Pin14}), // initIOTimerChannel(io_timers, {Timer::Timer4, Timer::Channel4}, {GPIO::PortD, GPIO::Pin15}), - // initIOTimerChannel(io_timers, {Timer::Timer15, Timer::Channel1}, {GPIO::PortE, GPIO::Pin5}), - // initIOTimerChannel(io_timers, {Timer::Timer15, Timer::Channel2}, {GPIO::PortE, GPIO::Pin6}), }; constexpr io_timers_channel_mapping_t io_timers_channel_mapping = diff --git a/platforms/nuttx/src/px4/stm/stm32_common/include/px4_arch/hw_description.h b/platforms/nuttx/src/px4/stm/stm32_common/include/px4_arch/hw_description.h index 2fda992be2..ba2292b97e 100644 --- a/platforms/nuttx/src/px4/stm/stm32_common/include/px4_arch/hw_description.h +++ b/platforms/nuttx/src/px4/stm/stm32_common/include/px4_arch/hw_description.h @@ -91,6 +91,9 @@ enum Timer { Timer12, Timer13, Timer14, +#ifdef STM32_TIM15_BASE + Timer15 +#endif }; enum Channel { Channel1 = 1, @@ -153,6 +156,11 @@ static inline constexpr uint32_t timerBaseRegister(Timer::Timer timer) case Timer::Timer14: return STM32_TIM14_BASE; #endif +#ifdef STM32_TIM15_BASE + + case Timer::Timer15: return STM32_TIM15_BASE; +#endif + default: break; } diff --git a/platforms/nuttx/src/px4/stm/stm32_common/io_pins/io_timer.c b/platforms/nuttx/src/px4/stm/stm32_common/io_pins/io_timer.c index e27432f205..5a72cc9f5e 100644 --- a/platforms/nuttx/src/px4/stm/stm32_common/io_pins/io_timer.c +++ b/platforms/nuttx/src/px4/stm/stm32_common/io_pins/io_timer.c @@ -644,7 +644,12 @@ int io_timer_init_timer(unsigned timer, io_timer_channel_mode_t mode) rCCER(timer) = 0; rDCR(timer) = 0; - if ((io_timers[timer].base == STM32_TIM1_BASE) || (io_timers[timer].base == STM32_TIM8_BASE)) { + if ((io_timers[timer].base == STM32_TIM1_BASE) + || (io_timers[timer].base == STM32_TIM8_BASE) +#ifdef STM32_TIM15_BASE + || (io_timers[timer].base == STM32_TIM15_BASE) +#endif + ) { /* master output enable = on */ diff --git a/platforms/nuttx/src/px4/stm/stm32h7/include/px4_arch/hw_description.h b/platforms/nuttx/src/px4/stm/stm32h7/include/px4_arch/hw_description.h index c2ae6c9ce7..9627d9a4cd 100644 --- a/platforms/nuttx/src/px4/stm/stm32h7/include/px4_arch/hw_description.h +++ b/platforms/nuttx/src/px4/stm/stm32h7/include/px4_arch/hw_description.h @@ -85,6 +85,7 @@ static inline constexpr uint32_t getTimerUpdateDMAMap(Timer::Timer timer, const case Timer::Timer12: case Timer::Timer13: case Timer::Timer14: + case Timer::Timer15: break; } diff --git a/platforms/nuttx/src/px4/stm/stm32h7/include/px4_arch/io_timer_hw_description.h b/platforms/nuttx/src/px4/stm/stm32h7/include/px4_arch/io_timer_hw_description.h index 4d05111876..06e7db74ea 100644 --- a/platforms/nuttx/src/px4/stm/stm32h7/include/px4_arch/io_timer_hw_description.h +++ b/platforms/nuttx/src/px4/stm/stm32h7/include/px4_arch/io_timer_hw_description.h @@ -68,6 +68,10 @@ static inline constexpr timer_io_channels_t initIOTimerGPIOInOut(Timer::TimerCha gpio_af = GPIO_AF3; break; + case Timer::Timer15: + gpio_af = GPIO_AF4; + break; + case Timer::Timer13: case Timer::Timer14: gpio_af = GPIO_AF9; @@ -259,6 +263,17 @@ static inline constexpr io_timers_t initIOTimer(Timer::Timer timer, DMA dshot_dm ret.vectorno = STM32_IRQ_TIM14; #ifdef CONFIG_STM32_TIM14 nuttx_config_timer_enabled = true; +#endif + break; + + case Timer::Timer15: + ret.base = STM32_TIM15_BASE; + ret.clock_register = STM32_RCC_APB2ENR; + ret.clock_bit = RCC_APB2ENR_TIM15EN; + ret.clock_freq = STM32_APB2_TIM15_CLKIN; + ret.vectorno = STM32_IRQ_TIM15; +#ifdef CONFIG_STM32_TIM15 + nuttx_config_timer_enabled = true; #endif break; }