xiaoxiang781216 commented 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.
   
   > My suspicion from what you say is that the those arch drivers are not 
compatible with the existing MCU architectures. They are not used by any of the 
existing architectures in the repository; they are used only by Xiaomi 
hardware. They have probably implemented an incompatible version of the one 
shot driver for their purposes and those arch drivers may not be usable by 
other architectures.
   > 
   > I am completely unfamiliar with those drivers. I have never used them or 
even looked at them. You would have to discuss this with Xiaomi to see if they 
are using some non-standard oneshot driver. I don't know what we should do if 
they are. Certainly we do not want to corrupt the semantics of the oneshot 
driver.
   


----------------------------------------------------------------
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]


Reply via email to