mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-02 20:28:37 +08:00
Overflow position offset not needed if we have only 32-bit counters
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4435 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
@@ -212,7 +212,10 @@ struct stm32_lowerhalf_s
|
|||||||
FAR const struct stm32_qeconfig_s *config; /* static onfiguration */
|
FAR const struct stm32_qeconfig_s *config; /* static onfiguration */
|
||||||
|
|
||||||
bool inuse; /* True: The lower-half driver is in-use */
|
bool inuse; /* True: The lower-half driver is in-use */
|
||||||
|
|
||||||
|
#ifdef HAVE_16BIT_TIMERS
|
||||||
volatile int32_t position; /* The current position offset */
|
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)
|
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;
|
FAR struct stm32_lowerhalf_s *priv = (FAR struct stm32_lowerhalf_s *)lower;
|
||||||
|
#ifdef HAVE_16BIT_TIMERS
|
||||||
int32_t position;
|
int32_t position;
|
||||||
int32_t verify;
|
int32_t verify;
|
||||||
uint32_t count;
|
uint32_t count;
|
||||||
@@ -1087,6 +1091,11 @@ static int stm32_position(FAR struct qe_lowerhalf_s *lower, int32_t *pos)
|
|||||||
/* Return the position measurement */
|
/* Return the position measurement */
|
||||||
|
|
||||||
*pos = position + (int32_t)count;
|
*pos = position + (int32_t)count;
|
||||||
|
#else
|
||||||
|
/* Return the counter value */
|
||||||
|
|
||||||
|
*pos = (int32_t)stm32_getreg32(priv, STM32_GTIM_CNT_OFFSET);;
|
||||||
|
#endif
|
||||||
return OK;
|
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)
|
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
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
|
|
||||||
qevdbg("Resetting position to zero\n");
|
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);
|
stm32_putreg32(priv, STM32_GTIM_CNT_OFFSET, 0);
|
||||||
priv->position = 0;
|
priv->position = 0;
|
||||||
irqrestore(flags);
|
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;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user