Timer Timer: Timer driver now initializes without complaints. Need a test driver of some kind to make more testing progress.
This commit is contained in:
parent
9c3dce06e1
commit
3efd127e64
@ -1792,12 +1792,12 @@ TIMER_HANDLE tiva_gptm_configure(const struct tiva_gptmconfig_s *config)
|
||||
|
||||
/* Reset the timer to be certain that it is in the disabled state */
|
||||
|
||||
regval = tiva_getreg(priv, TIVA_SYSCON_SRTIMER);
|
||||
regval = getreg32(TIVA_SYSCON_SRTIMER);
|
||||
regval |= SYSCON_SRTIMER(config->gptm);
|
||||
tiva_putreg(priv, TIVA_SYSCON_SRTIMER, regval);
|
||||
putreg32(regval, TIVA_SYSCON_SRTIMER);
|
||||
|
||||
regval &= ~SYSCON_SRTIMER(config->gptm);
|
||||
tiva_putreg(priv, TIVA_SYSCON_SRTIMER, regval);
|
||||
putreg32(regval, TIVA_SYSCON_SRTIMER);
|
||||
|
||||
/* Wait for the reset to complete */
|
||||
|
||||
@ -1946,12 +1946,12 @@ void tiva_gptm_release(TIMER_HANDLE handle)
|
||||
|
||||
/* Reset the time to be certain that it is in the disabled state */
|
||||
|
||||
regval = tiva_getreg(priv, TIVA_SYSCON_SRTIMER);
|
||||
regval = getreg32(TIVA_SYSCON_SRTIMER);
|
||||
regval |= SYSCON_SRTIMER(config->gptm);
|
||||
tiva_putreg(priv, TIVA_SYSCON_SRTIMER, regval);
|
||||
putreg32(regval, TIVA_SYSCON_SRTIMER);
|
||||
|
||||
regval &= ~SYSCON_SRTIMER(config->gptm);
|
||||
tiva_putreg(priv, TIVA_SYSCON_SRTIMER, regval);
|
||||
putreg32(regval, TIVA_SYSCON_SRTIMER);
|
||||
|
||||
/* Wait for the reset to complete */
|
||||
|
||||
@ -2407,7 +2407,7 @@ void tiva_timer32_setinterval(TIMER_HANDLE handle, uint32_t interval)
|
||||
* generated as normal
|
||||
*/
|
||||
|
||||
modev1 = tiva_getreg(priv, moder);
|
||||
modev1 = getreg32(moder);
|
||||
modev2 = modev1 & ~TIMER_TnMR_TnCINTD;
|
||||
putreg32(modev2, moder);
|
||||
}
|
||||
@ -2415,7 +2415,7 @@ void tiva_timer32_setinterval(TIMER_HANDLE handle, uint32_t interval)
|
||||
{
|
||||
/* Setting the TACINTD bit prevents the time-out interrupt */
|
||||
|
||||
modev1 = tiva_getreg(priv, moder);
|
||||
modev1 = getreg32(moder);
|
||||
modev2 = modev1 | TIMER_TnMR_TnCINTD;
|
||||
putreg32(modev2, moder);
|
||||
|
||||
@ -2550,7 +2550,7 @@ void tiva_timer16_setinterval(TIMER_HANDLE handle, uint16_t interval, int tmndx)
|
||||
* generated as normal
|
||||
*/
|
||||
|
||||
modev1 = tiva_getreg(priv, moder);
|
||||
modev1 = getreg32(moder);
|
||||
modev2 = modev1 & ~TIMER_TnMR_TnCINTD;
|
||||
putreg32(modev2, moder);
|
||||
}
|
||||
@ -2558,7 +2558,7 @@ void tiva_timer16_setinterval(TIMER_HANDLE handle, uint16_t interval, int tmndx)
|
||||
{
|
||||
/* Setting the TACINTD bit prevents the time-out interrupt */
|
||||
|
||||
modev1 = tiva_getreg(priv, moder);
|
||||
modev1 = getreg32(moder);
|
||||
modev2 = modev1 | TIMER_TnMR_TnCINTD;
|
||||
putreg32(modev2, moder);
|
||||
|
||||
|
@ -87,6 +87,7 @@ struct tiva_lowerhalf_s
|
||||
|
||||
static uint32_t tiva_usec2ticks(struct tiva_lowerhalf_s *priv, uint32_t usecs);
|
||||
static uint32_t tiva_ticks2usec(struct tiva_lowerhalf_s *priv, uint32_t ticks);
|
||||
static int tiva_timeout(struct tiva_lowerhalf_s *priv, uint32_t timeout);
|
||||
|
||||
/* Interrupt handling *******************************************************/
|
||||
|
||||
@ -180,6 +181,44 @@ static uint32_t tiva_ticks2usec(struct tiva_lowerhalf_s *priv, uint32_t ticks)
|
||||
return (uint32_t)bigusec;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_timeout
|
||||
*
|
||||
* Description:
|
||||
* Calculate a new timeout value.
|
||||
*
|
||||
* Input Parameters:
|
||||
* priv - A pointer to a private timer driver lower half instance
|
||||
* timeout - The new timeout value in microseconds.
|
||||
*
|
||||
* Returned Values:
|
||||
* Zero on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int tiva_timeout(struct tiva_lowerhalf_s *priv, uint32_t timeout)
|
||||
{
|
||||
timvdbg("Entry: timeout=%d\n", timeout);
|
||||
|
||||
/* Save the desired timeout value */
|
||||
|
||||
priv->timeout = timeout;
|
||||
|
||||
/* Calculate the actual timeout value in clock ticks */
|
||||
|
||||
priv->clkticks = tiva_usec2ticks(priv, timeout);
|
||||
|
||||
/* Calculate an adjustment due to truncation in timer resolution */
|
||||
|
||||
timeout = tiva_ticks2usec(priv, priv->clkticks);
|
||||
priv->adjustment = priv->timeout - timeout;
|
||||
|
||||
timvdbg("clkin=%d clkticks=%d timeout=%d, adjustment=%d\n",
|
||||
priv->clkin, priv->clkticks, priv->timeout, priv->adjustment);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_handler
|
||||
*
|
||||
@ -380,10 +419,10 @@ static int tiva_getstatus(struct timer_lowerhalf_s *lower,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int tiva_settimeout(struct timer_lowerhalf_s *lower,
|
||||
uint32_t timeout)
|
||||
static int tiva_settimeout(struct timer_lowerhalf_s *lower, uint32_t timeout)
|
||||
{
|
||||
struct tiva_lowerhalf_s *priv = (struct tiva_lowerhalf_s *)lower;
|
||||
int ret;
|
||||
|
||||
DEBUGASSERT(priv);
|
||||
|
||||
@ -394,26 +433,17 @@ static int tiva_settimeout(struct timer_lowerhalf_s *lower,
|
||||
|
||||
timvdbg("Entry: timeout=%d\n", timeout);
|
||||
|
||||
/* Save the desired timeout value */
|
||||
/* Calculate the the new time settings */
|
||||
|
||||
priv->timeout = timeout;
|
||||
ret = tiva_timeout(priv, timeout);
|
||||
if (ret == OK)
|
||||
{
|
||||
/* Reset the timer interval */
|
||||
|
||||
/* Calculate the actual timeout value in clock ticks */
|
||||
tiva_timer32_setinterval(priv->handle, priv->clkticks);
|
||||
}
|
||||
|
||||
priv->clkticks = tiva_usec2ticks(priv, timeout);
|
||||
|
||||
/* Calculate an adjustment due to truncation in timer resolution */
|
||||
|
||||
timeout = tiva_ticks2usec(priv, priv->clkticks);
|
||||
priv->adjustment = priv->timeout - timeout;
|
||||
|
||||
timvdbg("clkin=%d clkticks=%d timout=%d, adjustment=%d\n",
|
||||
priv->clkin, priv->clkticks, priv->timeout, priv->adjustment);
|
||||
|
||||
/* Reset the timer interval */
|
||||
|
||||
tiva_timer32_setinterval(priv->handle, priv->clkticks);
|
||||
return OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -554,7 +584,7 @@ int tiva_timer_register(const char *devpath, int gptm, uint32_t timeout,
|
||||
|
||||
/* Set the initial timer interval */
|
||||
|
||||
ret = tiva_settimeout((struct timer_lowerhalf_s *)priv, timeout);
|
||||
ret = tiva_timeout(priv, timeout);
|
||||
if (ret < 0)
|
||||
{
|
||||
timdbg("ERROR: Failed to set initial timeout\n");
|
||||
|
@ -257,7 +257,7 @@ CONFIG_ARCH_HAVE_RAMVECTORS=y
|
||||
#
|
||||
# Board Settings
|
||||
#
|
||||
CONFIG_BOARD_LOOPSPERMSEC=4531
|
||||
CONFIG_BOARD_LOOPSPERMSEC=11401
|
||||
# CONFIG_ARCH_CALIBRATION is not set
|
||||
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user