mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 23:40:19 +08:00
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.
This commit is contained in:
committed by
Alan Carvalho de Assis
parent
b0c9a6133e
commit
092a0c8453
@@ -11162,6 +11162,10 @@ menu "STM32 QEncoder Driver"
|
|||||||
depends on SENSORS_QENCODER
|
depends on SENSORS_QENCODER
|
||||||
depends on STM32_TIM1 || STM32_TIM2 || STM32_TIM3 || STM32_TIM4 || STM32_TIM5 || STM32_TIM8
|
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
|
config STM32_TIM1_QE
|
||||||
bool "TIM1 QE"
|
bool "TIM1 QE"
|
||||||
default n
|
default n
|
||||||
|
|||||||
@@ -313,7 +313,7 @@ struct stm32_lowerhalf_s
|
|||||||
|
|
||||||
bool inuse; /* True: The lower-half driver is in-use */
|
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 */
|
volatile int32_t position; /* The current position offset */
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@@ -344,7 +344,7 @@ static FAR struct stm32_lowerhalf_s *stm32_tim2lower(int tim);
|
|||||||
|
|
||||||
/* Interrupt handling */
|
/* Interrupt handling */
|
||||||
|
|
||||||
#ifdef HAVE_16BIT_TIMERS
|
#ifndef CONFIG_STM32_QENCODER_DISABLE_EXTEND16BTIMERS
|
||||||
static int stm32_interrupt(int irq, FAR void *context, FAR void *arg);
|
static int stm32_interrupt(int irq, FAR void *context, FAR void *arg);
|
||||||
#endif
|
#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)
|
static int stm32_interrupt(int irq, FAR void *context, FAR void *arg)
|
||||||
{
|
{
|
||||||
FAR struct stm32_lowerhalf_s *priv = (FAR struct stm32_lowerhalf_s *)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;
|
uint32_t ccmr1;
|
||||||
uint16_t ccer;
|
uint16_t ccer;
|
||||||
uint16_t cr1;
|
uint16_t cr1;
|
||||||
#ifdef HAVE_16BIT_TIMERS
|
#ifndef CONFIG_STM32_QENCODER_DISABLE_EXTEND16BTIMERS
|
||||||
uint16_t regval;
|
uint16_t regval;
|
||||||
int ret;
|
int ret;
|
||||||
#endif
|
#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 */
|
/* There is no need for interrupts with 32-bit timers */
|
||||||
|
|
||||||
#ifdef HAVE_16BIT_TIMERS
|
#ifndef CONFIG_STM32_QENCODER_DISABLE_EXTEND16BTIMERS
|
||||||
#ifdef HAVE_MIXEDWIDTH_TIMERS
|
#ifdef HAVE_MIXEDWIDTH_TIMERS
|
||||||
if (priv->config->width != 32)
|
if (priv->config->width != 32)
|
||||||
#endif
|
#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 */
|
/* There is no need for interrupts with 32-bit timers */
|
||||||
|
|
||||||
#ifdef HAVE_16BIT_TIMERS
|
#ifndef CONFIG_STM32_QENCODER_DISABLE_EXTEND16BTIMERS
|
||||||
#ifdef HAVE_MIXEDWIDTH_TIMERS
|
#ifdef HAVE_MIXEDWIDTH_TIMERS
|
||||||
if (priv->config->width != 32)
|
if (priv->config->width != 32)
|
||||||
#endif
|
#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)
|
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;
|
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 position;
|
||||||
int32_t verify;
|
int32_t verify;
|
||||||
uint32_t count;
|
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)
|
static int stm32_reset(FAR struct qe_lowerhalf_s *lower)
|
||||||
{
|
{
|
||||||
FAR struct stm32_lowerhalf_s *priv = (FAR struct stm32_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;
|
irqstate_t flags;
|
||||||
|
|
||||||
sninfo("Resetting position to zero\n");
|
sninfo("Resetting position to zero\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user