Overflow position offset not needed if we have only 32-bit counters

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4435 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2012-02-28 01:58:23 +00:00
parent 951fe7ce47
commit 916c3733e2
1 changed files with 18 additions and 0 deletions

View File

@ -212,7 +212,10 @@ struct stm32_lowerhalf_s
FAR const struct stm32_qeconfig_s *config; /* static onfiguration */
bool inuse; /* True: The lower-half driver is in-use */
#ifdef HAVE_16BIT_TIMERS
volatile int32_t position; /* The current position offset */
#endif
};
/************************************************************************************
@ -1062,6 +1065,7 @@ static int stm32_shutdown(FAR struct qe_lowerhalf_s *lower)
static int stm32_position(FAR struct qe_lowerhalf_s *lower, int32_t *pos)
{
FAR struct stm32_lowerhalf_s *priv = (FAR struct stm32_lowerhalf_s *)lower;
#ifdef HAVE_16BIT_TIMERS
int32_t position;
int32_t verify;
uint32_t count;
@ -1087,6 +1091,11 @@ static int stm32_position(FAR struct qe_lowerhalf_s *lower, int32_t *pos)
/* Return the position measurement */
*pos = position + (int32_t)count;
#else
/* Return the counter value */
*pos = (int32_t)stm32_getreg32(priv, STM32_GTIM_CNT_OFFSET);;
#endif
return OK;
}
@ -1101,6 +1110,7 @@ static int stm32_position(FAR struct qe_lowerhalf_s *lower, 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
irqstate_t flags;
qevdbg("Resetting position to zero\n");
@ -1114,6 +1124,14 @@ static int stm32_reset(FAR struct qe_lowerhalf_s *lower)
stm32_putreg32(priv, STM32_GTIM_CNT_OFFSET, 0);
priv->position = 0;
irqrestore(flags);
#else
qevdbg("Resetting position to zero\n");
DEBUGASSERT(lower && priv->inuse);
/* Reset the counter to zero */
stm32_putreg32(priv, STM32_GTIM_CNT_OFFSET, 0);
#endif
return OK;
}