From 30dd0fdc1605baf4b81fce2b6fd9898de07f2ea1 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 29 Jun 2011 11:59:15 +0000 Subject: TIM8 support for STM32. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3098 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/platforms/STM32/gpt_lld.c | 59 ++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 12 deletions(-) (limited to 'os/hal/platforms/STM32/gpt_lld.c') diff --git a/os/hal/platforms/STM32/gpt_lld.c b/os/hal/platforms/STM32/gpt_lld.c index 8419cad68..f7a9226ad 100644 --- a/os/hal/platforms/STM32/gpt_lld.c +++ b/os/hal/platforms/STM32/gpt_lld.c @@ -31,18 +31,6 @@ #if HAL_USE_GPT || defined(__DOXYGEN__) -/* There are differences in vector names in the ST header for devices - including TIM15, TIM16, TIM17.*/ -#if STM32_HAS_TIM15 -#define TIM1_BRK_IRQn TIM1_BRK_TIM15_IRQn -#endif -#if STM32_HAS_TIM16 -#define TIM1_UP_IRQn TIM1_UP_TIM16_IRQn -#endif -#if STM32_HAS_TIM17 -#define TIM1_TRG_COM_IRQn TIM1_TRG_COM_TIM17_IRQn -#endif - /*===========================================================================*/ /* Driver exported variables. */ /*===========================================================================*/ @@ -87,6 +75,14 @@ GPTDriver GPTD4; GPTDriver GPTD5; #endif +/** + * @brief GPTD8 driver identifier. + * @note The driver GPTD8 allocates the timer TIM8 when enabled. + */ +#if STM32_GPT_USE_TIM8 || defined(__DOXYGEN__) +GPTDriver GPTD8; +#endif + /*===========================================================================*/ /* Driver local variables. */ /*===========================================================================*/ @@ -194,6 +190,22 @@ CH_IRQ_HANDLER(TIM5_IRQHandler) { } #endif /* STM32_GPT_USE_TIM5 */ +#if STM32_GPT_USE_TIM8 +/** + * @brief TIM5 interrupt handler. + * + * @isr + */ +CH_IRQ_HANDLER(TIM8_IRQHandler) { + + CH_IRQ_PROLOGUE(); + + gpt_lld_serve_interrupt(&GPTD8); + + CH_IRQ_EPILOGUE(); +} +#endif /* STM32_GPT_USE_TIM8 */ + /*===========================================================================*/ /* Driver exported functions. */ /*===========================================================================*/ @@ -234,6 +246,12 @@ void gpt_lld_init(void) { GPTD5.tim = TIM5; gptObjectInit(&GPTD5); #endif + +#if STM32_GPT_USE_TIM8 + /* Driver initialization.*/ + GPTD5.tim = TIM8; + gptObjectInit(&GPTD8); +#endif } /** @@ -299,6 +317,17 @@ void gpt_lld_start(GPTDriver *gptp) { gptp->clock = STM32_TIMCLK1; } #endif + +#if STM32_GPT_USE_TIM8 + if (&GPTD8 == gptp) { + RCC->APB2ENR |= RCC_APB2ENR_TIM8EN; + RCC->APB2RSTR = RCC_APB2RSTR_TIM8RST; + RCC->APB2RSTR = 0; + NVICEnableVector(TIM8_UP_IRQn, + CORTEX_PRIORITY_MASK(STM32_GPT_TIM8_IRQ_PRIORITY)); + gptp->clock = STM32_TIMCLK2; + } +#endif } /* Prescaler value calculation.*/ @@ -356,6 +385,12 @@ void gpt_lld_stop(GPTDriver *gptp) { NVICDisableVector(TIM5_IRQn); RCC->APB1ENR &= ~RCC_APB1ENR_TIM5EN; } +#endif +#if STM32_GPT_USE_TIM8 + if (&GPTD8 == gptp) { + NVICDisableVector(TIM8_UP_IRQn); + RCC->APB2ENR &= ~RCC_APB2ENR_TIM8EN; + } #endif } } -- cgit v1.2.3