From 39fa1818ffe52d04832d5f5d25ae01fb7b6d514f Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 18 Feb 2012 16:46:21 +0000 Subject: Improvements to the STM32 ICU driver. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3955 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/platforms/STM32/icu_lld.h | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'os/hal/platforms/STM32/icu_lld.h') diff --git a/os/hal/platforms/STM32/icu_lld.h b/os/hal/platforms/STM32/icu_lld.h index 5f53884cd..642de2a64 100644 --- a/os/hal/platforms/STM32/icu_lld.h +++ b/os/hal/platforms/STM32/icu_lld.h @@ -179,7 +179,7 @@ /*===========================================================================*/ /** - * @brief ICU driver mode. + * @brief ICU driver mode. */ typedef enum { ICU_INPUT_ACTIVE_HIGH = 0, /**< Trigger on rising edge. */ @@ -191,6 +191,14 @@ typedef enum { */ typedef uint32_t icufreq_t; +/** + * @brief ICU channel. + */ +typedef enum { + ICU_CHANNEL_1 = 0, /**< Use TIMxCH1. */ + ICU_CHANNEL_2 = 1, /**< Use TIMxCH2. */ +} icuchannel_t; + /** * @brief ICU counter type. */ @@ -220,6 +228,11 @@ typedef struct { */ icucallback_t period_cb; /* End of the mandatory fields.*/ + /** + * @brief Timer input channel to be used. + * @note Only inputs TIMx 1 and 2 are supported. + */ + icuchannel_t channel; } ICUConfig; /** @@ -246,6 +259,14 @@ struct ICUDriver { * @brief Pointer to the TIMx registers block. */ stm32_tim_t *tim; + /** + * @bried CCR register used for width capture. + */ + volatile uint32_t *wccrp; + /** + * @bried CCR register used for period capture. + */ + volatile uint32_t *pccrp; }; /*===========================================================================*/ @@ -262,7 +283,7 @@ struct ICUDriver { * * @notapi */ -#define icu_lld_get_width(icup) ((icup)->tim->CCR[1] + 1) +#define icu_lld_get_width(icup) (*((icup)->wccrp) + 1) /** * @brief Returns the width of the latest cycle. @@ -274,7 +295,7 @@ struct ICUDriver { * * @notapi */ -#define icu_lld_get_period(icup) ((icup)->tim->CCR[0] + 1) +#define icu_lld_get_period(icup) (*((icup)->pccrp) + 1) /*===========================================================================*/ /* External declarations. */ -- cgit v1.2.3