From b7fcd27d48dfcc9241fed620130f05c3d33603b0 Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 21 Feb 2012 23:23:18 +0000 Subject: [PATCH] Misc fixes to quadrature encoder debug output git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4411 42af7a65-404d-4744-a932-0658087f49c3 --- arch/arm/src/stm32/stm32_qencoder.c | 17 ++++++++++++----- configs/stm32f4discovery/src/up_qencoder.c | 4 ++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/arch/arm/src/stm32/stm32_qencoder.c b/arch/arm/src/stm32/stm32_qencoder.c index 97d7c4235b..67ba1eabb4 100644 --- a/arch/arm/src/stm32/stm32_qencoder.c +++ b/arch/arm/src/stm32/stm32_qencoder.c @@ -77,18 +77,18 @@ # ifdef CONFIG_DEBUG_VERBOSE # define qevdbg vdbg # define qellvdbg llvdbg -# define stm32_dumpgpio(p,m) stm32_dumpgpio(p,m) +# define qe_dumpgpio(p,m) stm32_dumpgpio(p,m) # else -# define qelldbg(x...) +# define qevdbg(x...) # define qellvdbg(x...) -# define stm32_dumpgpio(p,m) +# define qe_dumpgpio(p,m) # endif #else # define qedbg(x...) # define qelldbg(x...) # define qevdbg(x...) # define qellvdbg(x...) -# define stm32_dumpgpio(p,m) +# define qe_dumpgpio(p,m) #endif /************************************************************************************ @@ -604,6 +604,7 @@ static int stm32_setup(FAR struct qe_lowerhalf_s *lower) uint16_t ccmr1; uint16_t ccer; uint16_t cr1; + uint16_t regval; int ret; /* NOTE: Clocking should have been enabled in the low-level RCC logic at boot-up */ @@ -754,7 +755,12 @@ static int stm32_setup(FAR struct qe_lowerhalf_s *lower) cr1 &= ~GTIM_CR1_URS; stm32_putreg16(priv, STM32_GTIM_CR1_OFFSET, cr1); - /* Enable the update interrupt */ + /* Clear any pending update interrupts */ + + regval = stm32_getreg16(priv, STM32_GTIM_SR_OFFSET); + stm32_putreg16(priv, STM32_GTIM_SR_OFFSET, regval & ~GTIM_SR_UIF) + + /* Then enable the update interrupt */ dier = stm32_getreg16(priv, STM32_GTIM_DIER_OFFSET); dier |= GTIM_DIER_UIE; @@ -947,6 +953,7 @@ static int stm32_reset(FAR struct qe_lowerhalf_s *lower) FAR struct stm32_lowerhalf_s *priv = (FAR struct stm32_lowerhalf_s *)lower; irqstate_t flags; + qevdbg("Resetting position to zero\n"); DEBUGASSERT(lower && priv->inuse); /* Reset the timer and the counter. Interrupts are disabled to make this atomic diff --git a/configs/stm32f4discovery/src/up_qencoder.c b/configs/stm32f4discovery/src/up_qencoder.c index 5d91f4c367..60d4d760e2 100644 --- a/configs/stm32f4discovery/src/up_qencoder.c +++ b/configs/stm32f4discovery/src/up_qencoder.c @@ -89,7 +89,7 @@ # define qevdbg vdbg # define qellvdbg llvdbg # else -# define qelldbg(x...) +# define qevdbg(x...) # define qellvdbg(x...) # endif #else @@ -118,7 +118,7 @@ int qe_devinit(void) { - static initialized = false; + static bool initialized = false; int ret; /* Check if we are already initialized */