This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 092a0c845333eac5ae88dcfcc43d834fcc0666cd Author: raiden00pl <[email protected]> AuthorDate: Sat Aug 7 14:26:46 2021 +0200 stm32/qenco: add an option to disable encoder timer extension from 16-bit to 32-bit Previous implementation has always expanded the width of the timer to 32-bit. This feature is not always needed and should be configurable from Kconfig. --- arch/arm/src/stm32/Kconfig | 4 ++++ arch/arm/src/stm32/stm32_qencoder.c | 16 ++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/arch/arm/src/stm32/Kconfig b/arch/arm/src/stm32/Kconfig index e8496f6..0316f41 100644 --- a/arch/arm/src/stm32/Kconfig +++ b/arch/arm/src/stm32/Kconfig @@ -11162,6 +11162,10 @@ menu "STM32 QEncoder Driver" depends on SENSORS_QENCODER depends on STM32_TIM1 || STM32_TIM2 || STM32_TIM3 || STM32_TIM4 || STM32_TIM5 || STM32_TIM8 +config STM32_QENCODER_DISABLE_EXTEND16BTIMERS + bool "Disable QEncoder timers extension from 16-bit to 32-bit" + default n + config STM32_TIM1_QE bool "TIM1 QE" default n diff --git a/arch/arm/src/stm32/stm32_qencoder.c b/arch/arm/src/stm32/stm32_qencoder.c index 92aee15..9dfc3bb 100644 --- a/arch/arm/src/stm32/stm32_qencoder.c +++ b/arch/arm/src/stm32/stm32_qencoder.c @@ -313,7 +313,7 @@ struct stm32_lowerhalf_s bool inuse; /* True: The lower-half driver is in-use */ -#ifdef HAVE_16BIT_TIMERS +#ifndef CONFIG_STM32_QENCODER_DISABLE_EXTEND16BTIMERS volatile int32_t position; /* The current position offset */ #endif }; @@ -344,7 +344,7 @@ static FAR struct stm32_lowerhalf_s *stm32_tim2lower(int tim); /* Interrupt handling */ -#ifdef HAVE_16BIT_TIMERS +#ifndef CONFIG_STM32_QENCODER_DISABLE_EXTEND16BTIMERS static int stm32_interrupt(int irq, FAR void *context, FAR void *arg); #endif @@ -724,7 +724,7 @@ static FAR struct stm32_lowerhalf_s *stm32_tim2lower(int tim) * ****************************************************************************/ -#ifdef HAVE_16BIT_TIMERS +#ifndef CONFIG_STM32_QENCODER_DISABLE_EXTEND16BTIMERS static int stm32_interrupt(int irq, FAR void *context, FAR void *arg) { FAR struct stm32_lowerhalf_s *priv = (FAR struct stm32_lowerhalf_s *)arg; @@ -777,7 +777,7 @@ static int stm32_setup(FAR struct qe_lowerhalf_s *lower) uint32_t ccmr1; uint16_t ccer; uint16_t cr1; -#ifdef HAVE_16BIT_TIMERS +#ifndef CONFIG_STM32_QENCODER_DISABLE_EXTEND16BTIMERS uint16_t regval; int ret; #endif @@ -941,7 +941,7 @@ static int stm32_setup(FAR struct qe_lowerhalf_s *lower) /* There is no need for interrupts with 32-bit timers */ -#ifdef HAVE_16BIT_TIMERS +#ifndef CONFIG_STM32_QENCODER_DISABLE_EXTEND16BTIMERS #ifdef HAVE_MIXEDWIDTH_TIMERS if (priv->config->width != 32) #endif @@ -974,7 +974,7 @@ static int stm32_setup(FAR struct qe_lowerhalf_s *lower) /* There is no need for interrupts with 32-bit timers */ -#ifdef HAVE_16BIT_TIMERS +#ifndef CONFIG_STM32_QENCODER_DISABLE_EXTEND16BTIMERS #ifdef HAVE_MIXEDWIDTH_TIMERS if (priv->config->width != 32) #endif @@ -1132,7 +1132,7 @@ static int stm32_shutdown(FAR struct qe_lowerhalf_s *lower) static int stm32_position(FAR struct qe_lowerhalf_s *lower, FAR int32_t *pos) { FAR struct stm32_lowerhalf_s *priv = (FAR struct stm32_lowerhalf_s *)lower; -#ifdef HAVE_16BIT_TIMERS +#ifndef CONFIG_STM32_QENCODER_DISABLE_EXTEND16BTIMERS int32_t position; int32_t verify; uint32_t count; @@ -1177,7 +1177,7 @@ static int stm32_position(FAR struct qe_lowerhalf_s *lower, FAR int32_t *pos) static int stm32_reset(FAR struct qe_lowerhalf_s *lower) { FAR struct stm32_lowerhalf_s *priv = (FAR struct stm32_lowerhalf_s *)lower; -#ifdef HAVE_16BIT_TIMERS +#ifndef CONFIG_STM32_QENCODER_DISABLE_EXTEND16BTIMERS irqstate_t flags; sninfo("Resetting position to zero\n");
