From 6cdf36877657bf2553f6b61783da9ae8eff45e61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Tue, 7 Jan 2020 18:55:52 +0100 Subject: [PATCH] stm32 io_timer: add support for 16 PWM outputs --- .../src/px4/stm/stm32_common/include/px4_arch/io_timer.h | 6 +++++- platforms/nuttx/src/px4/stm/stm32_common/io_pins/io_timer.c | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/platforms/nuttx/src/px4/stm/stm32_common/include/px4_arch/io_timer.h b/platforms/nuttx/src/px4/stm/stm32_common/include/px4_arch/io_timer.h index a2751dc53f..bda44530bb 100644 --- a/platforms/nuttx/src/px4/stm/stm32_common/include/px4_arch/io_timer.h +++ b/platforms/nuttx/src/px4/stm/stm32_common/include/px4_arch/io_timer.h @@ -49,7 +49,11 @@ __BEGIN_DECLS #else #define MAX_IO_TIMERS 2 #endif +#if DIRECT_PWM_OUTPUT_CHANNELS > 8 +#define MAX_TIMER_IO_CHANNELS DIRECT_PWM_OUTPUT_CHANNELS +#else #define MAX_TIMER_IO_CHANNELS 8 +#endif #define MAX_LED_TIMERS 2 #define MAX_TIMER_LED_CHANNELS 6 @@ -73,7 +77,7 @@ typedef enum io_timer_channel_mode_t { IOTimerChanModeSize } io_timer_channel_mode_t; -typedef uint8_t io_timer_channel_allocation_t; /* big enough to hold MAX_TIMER_IO_CHANNELS */ +typedef uint16_t io_timer_channel_allocation_t; /* big enough to hold MAX_TIMER_IO_CHANNELS */ /* array of timers dedicated to PWM in and out and capture use *** Note that the clock_freq is set to the source in the clock tree that 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 65ec0380c1..7cb2ec778a 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 @@ -150,7 +150,7 @@ static int io_timer_handler7(int irq, void *context, void *arg); #define TIM_DMABURSTLENGTH_4TRANSFERS 0x00000300U // NotUsed PWMOut PWMIn Capture OneShot Trigger Dshot -io_timer_channel_allocation_t channel_allocations[IOTimerChanModeSize] = { UINT8_MAX, 0, 0, 0, 0, 0, 0 }; +io_timer_channel_allocation_t channel_allocations[IOTimerChanModeSize] = { UINT16_MAX, 0, 0, 0, 0, 0, 0 }; typedef uint8_t io_timer_allocation_t; /* big enough to hold MAX_IO_TIMERS */