xiaoxiang781216 edited a comment on pull request #1705:
URL: https://github.com/apache/incubator-nuttx/pull/1705#issuecomment-687655040
> > Is the oneshot supposed to keep counting after it fires? I understand
that oneshot fires once but at least stm32_oneshot.c stops counting. So
implementing up_timer_gettime() as arch_alarm.c does:
> > int up_timer_gettime(FAR struct timespec *ts)
> > {
> > int ret = -EAGAIN;
> > if (g_oneshot_lower != NULL)
> > {
> > ret = ONESHOT_CURRENT(g_oneshot_lower, ts);
> > }
> > return ret;
> > }
> > would only work if the timer continues to run AND it handles wrap-around
by adding one period on overflow and returns this monotonic value on
ONESHOT_CURRENT(). Neither of those two conditions are met in stm32_oneshot.c.
So is stm32_oneshot.c wrong or is that not how oneshot should work?
>
> Yes, resetting and stopping the timer is the correct behavior for a
oneshot timer. I expect that that all of the implementations do that.
>
But the driver document never mention wether the counting should stop or not:
```
/****************************************************************************
* Name: ONESHOT_CANCEL
*
* Description:
* Cancel the oneshot timer and return the time remaining on the timer.
*
* NOTE: This function may execute at a high rate with no timer running (as
* when pre-emption is enabled and disabled).
*
* Input Parameters:
* lower Caller allocated instance of the oneshot state structure. This
* structure must have been previously initialized via a call to
* oneshot_initialize();
* ts The location in which to return the time remaining on the
* oneshot timer. A time of zero is returned if the timer is
* not running.
*
* Returned Value:
* Zero (OK) is returned on success. A call to up_timer_cancel() when
* the timer is not active should also return success; a negated errno
* value is returned on any failure.
*
****************************************************************************/
#define ONESHOT_CANCEL(l,t) ((l)->ops->cancel(l,t))
```
So the implementer is free to just disable the interrupt but keep the
counting. This behaviour is very important to implement the tickless mode on
top of oneshot_lowerhalf_s without any drift.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]