From 0ed9d3d322d62226850ac6b3ca01431cc7520ae7 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Fri, 17 Jan 2020 08:57:32 +0000 Subject: [PATCH] Fixed bug #1067. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@13277 27425a3e-05d8-49a3-a47f-9c15f0e5edd8 --- os/hal/include/hal_gpt.h | 17 +++++++++++++++++ os/hal/ports/STM32/LLD/TIMv1/hal_gpt_lld.c | 22 +++++----------------- readme.txt | 2 ++ 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/os/hal/include/hal_gpt.h b/os/hal/include/hal_gpt.h index 91bd4484a..fd2b8fd74 100644 --- a/os/hal/include/hal_gpt.h +++ b/os/hal/include/hal_gpt.h @@ -111,6 +111,23 @@ typedef void (*gptcallback_t)(GPTDriver *gptp); */ #define gptGetCounterX(gptp) gpt_lld_get_counter(gptp) +/** + * @brief Common ISR code, GPT period event. + * + * @param[in] gptp pointer to the @p GPTDriver object + * + * @notapi + */ +#define _gpt_isr_invoke_cb(gptp) do { \ + if ((gptp)->state == GPT_ONESHOT) { \ + (gptp)->state = GPT_READY; \ + gpt_lld_stop_timer(gptp); \ + } \ + if ((gptp)->config->callback != NULL) { \ + (gptp)->config->callback(gptp); \ + } \ +} while (0) + /*===========================================================================*/ /* External declarations. */ /*===========================================================================*/ diff --git a/os/hal/ports/STM32/LLD/TIMv1/hal_gpt_lld.c b/os/hal/ports/STM32/LLD/TIMv1/hal_gpt_lld.c index 18e6bcaae..ace0c5e8d 100644 --- a/os/hal/ports/STM32/LLD/TIMv1/hal_gpt_lld.c +++ b/os/hal/ports/STM32/LLD/TIMv1/hal_gpt_lld.c @@ -822,18 +822,6 @@ void gpt_lld_start(GPTDriver *gptp) { } #endif -#if STM32_GPT_USE_TIM15 - if (&GPTD15 == gptp) { - rccEnableTIM15(true); - rccResetTIM15(); -#if defined(STM32_TIM15CLK) - gptp->clock = STM32_TIM15CLK; -#else - gptp->clock = STM32_TIMCLK2; -#endif - } -#endif - #if STM32_GPT_USE_TIM16 if (&GPTD16 == gptp) { rccEnableTIM16(true); @@ -1150,13 +1138,13 @@ void gpt_lld_polled_delay(GPTDriver *gptp, gptcnt_t interval) { * @notapi */ void gpt_lld_serve_interrupt(GPTDriver *gptp) { + uint32_t sr; - gptp->tim->SR = 0; - if (gptp->state == GPT_ONESHOT) { - gptp->state = GPT_READY; /* Back in GPT_READY state. */ - gpt_lld_stop_timer(gptp); /* Timer automatically stopped. */ + sr = gptp->tim->SR; + sr &= gptp->tim->DIER & STM32_TIM_DIER_IRQ_MASK; + if ((sr & STM32_TIM_SR_UIF) != 0) { + _gpt_isr_invoke_cb(gptp); } - gptp->config->callback(gptp); } #endif /* HAL_USE_GPT */ diff --git a/readme.txt b/readme.txt index 75d56f667..844ca7235 100644 --- a/readme.txt +++ b/readme.txt @@ -154,6 +154,8 @@ - HAL: Added a new interface for range-finder devices (used by EX). - HAL: Added mcuconf.h updater tool for STM32F407 (backported to 19.1.1). - NIL: Integrated NIL 4.0. +- FIX: Fixed Sharing issues with GPT TIMv1 driver (bug #1067) + (backported to 19.1.4)(backported to 18.2.3). - FIX: Fixed incorrect pointer type in lwipthread.c low_level_input causes panic on packet reception (bug #1009) (backported to 19.1.4)(backported to 18.2.3).