From ada48571d76a32f05d6679e0f818505585cc9ce7 Mon Sep 17 00:00:00 2001 From: Simone Guscetti Date: Fri, 19 May 2017 15:26:31 +0200 Subject: [PATCH] fmu-v5: fix timer config --- .../boards/px4fmu-v5/px4fmu_timer_config.c | 27 +++++++++---------- src/drivers/stm32/drv_io_timer.c | 6 +++++ src/drivers/stm32/drv_io_timer.h | 3 ++- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/drivers/boards/px4fmu-v5/px4fmu_timer_config.c b/src/drivers/boards/px4fmu-v5/px4fmu_timer_config.c index 0899f758f0..ef5eca0190 100644 --- a/src/drivers/boards/px4fmu-v5/px4fmu_timer_config.c +++ b/src/drivers/boards/px4fmu-v5/px4fmu_timer_config.c @@ -82,26 +82,25 @@ __EXPORT const io_timers_t io_timers[MAX_IO_TIMERS] = { .handler = io_timer_handler2, .vectorno = STM32_IRQ_TIM12, }, + { + .base = STM32_TIM2_BASE, + .clock_register = STM32_RCC_APB1ENR, + .clock_bit = RCC_APB1ENR_TIM2EN, + .clock_freq = STM32_APB1_TIM2_CLKIN, + .first_channel_index = 8, + .last_channel_index = 10, + .handler = io_timer_handler3, + .vectorno = STM32_IRQ_TIM2, + }, { .base = STM32_TIM9_BASE, .clock_register = STM32_RCC_APB2ENR, .clock_bit = RCC_APB2ENR_TIM9EN, .clock_freq = STM32_APB2_TIM9_CLKIN, - .first_channel_index = 8, - .last_channel_index = 8, - .handler = io_timer_handler3, - .vectorno = STM32_IRQ_TIM9, - - }, - { - .base = STM32_TIM2_BASE, - .clock_register = STM32_RCC_APB1ENR, - .clock_bit = RCC_APB2ENR_TIM2EN, - .clock_freq = STM32_APB2_TIM2_CLKIN, - .first_channel_index = 9, - .last_channel_index = 9, + .first_channel_index = 11, + .last_channel_index = 11, .handler = io_timer_handler4, - .vectorno = STM32_IRQ_TIM2, + .vectorno = STM32_IRQ_TIM9, } }; diff --git a/src/drivers/stm32/drv_io_timer.c b/src/drivers/stm32/drv_io_timer.c index 22cc3a2106..f078cf83fc 100644 --- a/src/drivers/stm32/drv_io_timer.c +++ b/src/drivers/stm32/drv_io_timer.c @@ -232,6 +232,12 @@ int io_timer_handler3(int irq, void *context) } +int io_timer_handler4(int irq, void *context) +{ + return io_timer_handler(4); + +} + static inline int validate_timer_index(unsigned timer) { return (timer < MAX_IO_TIMERS && io_timers[timer].base != 0) ? 0 : -EINVAL; diff --git a/src/drivers/stm32/drv_io_timer.h b/src/drivers/stm32/drv_io_timer.h index fc96aa29c6..75360d00fb 100644 --- a/src/drivers/stm32/drv_io_timer.h +++ b/src/drivers/stm32/drv_io_timer.h @@ -45,7 +45,7 @@ #pragma once __BEGIN_DECLS /* configuration limits */ -#define MAX_IO_TIMERS 4 +#define MAX_IO_TIMERS 5 #define MAX_TIMER_IO_CHANNELS 8 #define MAX_LED_TIMERS 2 @@ -112,6 +112,7 @@ __EXPORT int io_timer_handler0(int irq, void *context); __EXPORT int io_timer_handler1(int irq, void *context); __EXPORT int io_timer_handler2(int irq, void *context); __EXPORT int io_timer_handler3(int irq, void *context); +__EXPORT int io_timer_handler4(int irq, void *context); __EXPORT int io_timer_channel_init(unsigned channel, io_timer_channel_mode_t mode, channel_handler_t channel_handler, void *context);