From 13729f854e79dec6f827f83d27240d087a469ff9 Mon Sep 17 00:00:00 2001 From: James Cotton Date: Sat, 26 Nov 2011 22:41:41 -0600 Subject: [PATCH] PiOS F4: Fix PWM timer interrupts and enable PWM input --- flight/PiOS/STM32F4xx/pios_tim.c | 54 +++++++++++++-------------- flight/Revolution/System/pios_board.c | 8 ++-- 2 files changed, 29 insertions(+), 33 deletions(-) diff --git a/flight/PiOS/STM32F4xx/pios_tim.c b/flight/PiOS/STM32F4xx/pios_tim.c index b486bb54f..5bb8d25d7 100644 --- a/flight/PiOS/STM32F4xx/pios_tim.c +++ b/flight/PiOS/STM32F4xx/pios_tim.c @@ -376,18 +376,37 @@ static void PIOS_TIM_generic_irq_handler(TIM_TypeDef * timer) * Map all valid TIM IRQs to the common interrupt handler * and give it enough context to properly demux the various timers */ -void TIM1_UP_IRQHandler(void) __attribute__ ((alias ("PIOS_TIM_1_UP_irq_handler"))); -static void PIOS_TIM_1_UP_irq_handler (void) -{ - PIOS_TIM_generic_irq_handler (TIM1); -} - void TIM1_CC_IRQHandler(void) __attribute__ ((alias ("PIOS_TIM_1_CC_irq_handler"))); static void PIOS_TIM_1_CC_irq_handler (void) { PIOS_TIM_generic_irq_handler (TIM1); } +// The rest of TIM1 interrupts are overlapped +void TIM1_BRK_TIM9_IRQHandler(void) __attribute__ ((alias ("PIOS_TIM_9_CC_irq_handler"))); +static void PIOS_TIM_9_CC_irq_handler (void) +{ + // TODO: Check for TIM1_BRK + PIOS_TIM_generic_irq_handler (TIM9); +} + +void TIM1_UP_TIM10_IRQHandler(void) __attribute__ ((alias ("PIOS_TIM_10_CC_irq_handler"))); +static void PIOS_TIM_10_CC_irq_handler (void) +{ + if (TIM_GetITStatus(TIM1, TIM_IT_Update)) { + PIOS_TIM_generic_irq_handler(TIM1); + } else if (TIM_GetITStatus(TIM10, TIM_IT_CC1 | TIM_IT_CC2 | TIM_IT_CC3 | TIM_IT_CC4)) { + PIOS_TIM_generic_irq_handler (TIM10); + } +} + +void TIM1_TRG_COM_TIM11_IRQHandler(void) __attribute__ ((alias ("PIOS_TIM_11_CC_irq_handler"))); +static void PIOS_TIM_11_CC_irq_handler (void) +{ + // TODO: Check for TIM1_TRG + PIOS_TIM_generic_irq_handler (TIM11); +} + void TIM2_IRQHandler(void) __attribute__ ((alias ("PIOS_TIM_2_irq_handler"))); static void PIOS_TIM_2_irq_handler (void) { @@ -435,26 +454,3 @@ static void PIOS_TIM_8_CC_irq_handler (void) { PIOS_TIM_generic_irq_handler (TIM8); } - - -void TIM1_BRK_TIM9_IRQHandler(void) __attribute__ ((alias ("PIOS_TIM_9_CC_irq_handler"))); -static void PIOS_TIM_9_CC_irq_handler (void) -{ - // TODO: Check for TIM1_BRK - PIOS_TIM_generic_irq_handler (TIM9); -} - -void TIM1_UP_TIM10_IRQHandler(void) __attribute__ ((alias ("PIOS_TIM_10_CC_irq_handler"))); -static void PIOS_TIM_10_CC_irq_handler (void) -{ - // TODO: Check for TIM1_UP - PIOS_TIM_generic_irq_handler (TIM10); -} - -void TIM1_TRG_COM_TIM11_IRQHandler(void) __attribute__ ((alias ("PIOS_TIM_11_CC_irq_handler"))); -static void PIOS_TIM_11_CC_irq_handler (void) -{ - // TODO: Check for TIM1_TRG - PIOS_TIM_generic_irq_handler (TIM11); -} - diff --git a/flight/Revolution/System/pios_board.c b/flight/Revolution/System/pios_board.c index 127504df6..d06662732 100644 --- a/flight/Revolution/System/pios_board.c +++ b/flight/Revolution/System/pios_board.c @@ -1624,14 +1624,14 @@ void PIOS_Board_Init(void) { pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_DSMMAINPORT] = pios_dsm_rcvr_id; /* Set up the receiver port. Later this should be optional */ - //uint32_t pios_pwm_id; - //PIOS_PWM_Init(&pios_pwm_id, &pios_pwm_cfg); + uint32_t pios_pwm_id; + PIOS_PWM_Init(&pios_pwm_id, &pios_pwm_cfg); - /*uint32_t pios_pwm_rcvr_id; + uint32_t pios_pwm_rcvr_id; if (PIOS_RCVR_Init(&pios_pwm_rcvr_id, &pios_pwm_rcvr_driver, pios_pwm_id)) { PIOS_Assert(0); } - pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_PWM] = pios_pwm_rcvr_id;*/ + pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_PWM] = pios_pwm_rcvr_id; /* Set up the servo outputs */ PIOS_Servo_Init(&pios_servo_cfg);