mirror of
https://github.com/apache/nuttx.git
synced 2026-06-01 16:59:28 +08:00
timers/oneshot: Remove oneshot tick API.
This commit removed all oneshot tick API for new clkdev API. Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
This commit is contained in:
committed by
Alin Jerpelea
parent
fc28b93224
commit
7e7828b3f6
@@ -64,10 +64,6 @@ static int tricore_systimer_cancel(struct oneshot_lowerhalf_s *lower,
|
|||||||
struct timespec *ts);
|
struct timespec *ts);
|
||||||
static int tricore_systimer_current(struct oneshot_lowerhalf_s *lower,
|
static int tricore_systimer_current(struct oneshot_lowerhalf_s *lower,
|
||||||
struct timespec *ts);
|
struct timespec *ts);
|
||||||
static int
|
|
||||||
tricore_systimer_tick_start(struct oneshot_lowerhalf_s *lower,
|
|
||||||
oneshot_callback_t callback, void *arg,
|
|
||||||
clock_t ticks);
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
@@ -79,7 +75,6 @@ static const struct oneshot_operations_s g_tricore_systimer_ops =
|
|||||||
.start = tricore_systimer_start,
|
.start = tricore_systimer_start,
|
||||||
.cancel = tricore_systimer_cancel,
|
.cancel = tricore_systimer_cancel,
|
||||||
.current = tricore_systimer_current,
|
.current = tricore_systimer_current,
|
||||||
.tick_start = tricore_systimer_tick_start,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct tricore_systimer_lowerhalf_s g_systimer_lower =
|
static struct tricore_systimer_lowerhalf_s g_systimer_lower =
|
||||||
@@ -270,48 +265,6 @@ static int tricore_systimer_current(struct oneshot_lowerhalf_s *lower,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: tricore_systimer_tick_start
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Start the oneshot timer
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* lower An instance of the lower-half oneshot state structure. This
|
|
||||||
* structure must have been previously initialized via a call to
|
|
||||||
* oneshot_initialize();
|
|
||||||
* handler The function to call when when the oneshot timer expires.
|
|
||||||
* arg An opaque argument that will accompany the callback.
|
|
||||||
* ticks Provides the duration of the one shot timer.
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* Zero (OK) is returned on success; a negated errno value is returned
|
|
||||||
* on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static int
|
|
||||||
tricore_systimer_tick_start(struct oneshot_lowerhalf_s *lower,
|
|
||||||
oneshot_callback_t callback, void *arg,
|
|
||||||
clock_t ticks)
|
|
||||||
{
|
|
||||||
struct tricore_systimer_lowerhalf_s *priv =
|
|
||||||
(struct tricore_systimer_lowerhalf_s *)lower;
|
|
||||||
uint64_t mtime = tricore_systimer_get_time(priv);
|
|
||||||
|
|
||||||
priv->alarm = mtime + priv->freq * ticks / TICK_PER_SEC;
|
|
||||||
if (priv->alarm < mtime)
|
|
||||||
{
|
|
||||||
priv->alarm = UINT64_MAX;
|
|
||||||
}
|
|
||||||
|
|
||||||
priv->callback = callback;
|
|
||||||
priv->arg = arg;
|
|
||||||
|
|
||||||
tricore_systimer_set_timecmp(priv, priv->alarm);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: tricore_systimer_interrupt
|
* Name: tricore_systimer_interrupt
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -65,14 +65,6 @@ static int intel64_cancel(struct oneshot_lowerhalf_s *lower,
|
|||||||
struct timespec *ts);
|
struct timespec *ts);
|
||||||
static int intel64_current(struct oneshot_lowerhalf_s *lower,
|
static int intel64_current(struct oneshot_lowerhalf_s *lower,
|
||||||
struct timespec *ts);
|
struct timespec *ts);
|
||||||
static int intel64_tick_max_delay(struct oneshot_lowerhalf_s *lower,
|
|
||||||
clock_t *ticks);
|
|
||||||
static int intel64_tick_start(struct oneshot_lowerhalf_s *lower,
|
|
||||||
clock_t ticks);
|
|
||||||
static int intel64_tick_cancel(struct oneshot_lowerhalf_s *lower,
|
|
||||||
clock_t *ticks);
|
|
||||||
static int intel64_tick_current(struct oneshot_lowerhalf_s *lower,
|
|
||||||
clock_t *ticks);
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
@@ -85,11 +77,7 @@ static const struct oneshot_operations_s g_oneshot_ops =
|
|||||||
.max_delay = intel64_max_delay,
|
.max_delay = intel64_max_delay,
|
||||||
.start = intel64_start,
|
.start = intel64_start,
|
||||||
.cancel = intel64_cancel,
|
.cancel = intel64_cancel,
|
||||||
.current = intel64_current,
|
.current = intel64_current
|
||||||
.tick_max_delay = intel64_tick_max_delay,
|
|
||||||
.tick_start = intel64_tick_start,
|
|
||||||
.tick_cancel = intel64_tick_cancel,
|
|
||||||
.tick_current = intel64_tick_current,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static spinlock_t g_oneshotlow_spin;
|
static spinlock_t g_oneshotlow_spin;
|
||||||
@@ -295,142 +283,6 @@ static int intel64_current(struct oneshot_lowerhalf_s *lower,
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: intel64_tick_max_delay
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Determine the maximum delay of the one-shot timer (in microseconds)
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* lower An instance of the lower-half oneshot state structure. This
|
|
||||||
* structure must have been previously initialized via a call to
|
|
||||||
* oneshot_initialize();
|
|
||||||
* ticks The location in which to return the maximum delay.
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* Zero (OK) is returned on success; a negated errno value is returned
|
|
||||||
* on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static int intel64_tick_max_delay(struct oneshot_lowerhalf_s *lower,
|
|
||||||
clock_t *ticks)
|
|
||||||
{
|
|
||||||
struct timespec ts;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = intel64_max_delay(lower, &ts);
|
|
||||||
|
|
||||||
/* Convert time to ticks */
|
|
||||||
|
|
||||||
*ticks = clock_time2ticks(&ts);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: intel64_tick_start
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Start the oneshot timer
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* lower An instance of the lower-half oneshot state structure. This
|
|
||||||
* structure must have been previously initialized via a call to
|
|
||||||
* oneshot_initialize();
|
|
||||||
* handler The function to call when when the oneshot timer expires.
|
|
||||||
* arg An opaque argument that will accompany the callback.
|
|
||||||
* ticks Provides the duration of the one shot timer.
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* Zero (OK) is returned on success; a negated errno value is returned
|
|
||||||
* on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static int intel64_tick_start(struct oneshot_lowerhalf_s *lower,
|
|
||||||
clock_t ticks)
|
|
||||||
{
|
|
||||||
struct timespec ts;
|
|
||||||
|
|
||||||
/* Convert ticks to time */
|
|
||||||
|
|
||||||
clock_ticks2time(&ts, ticks);
|
|
||||||
|
|
||||||
return intel64_start(lower, &ts);
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: intel64_tick_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();
|
|
||||||
* ticks The location in which to return the time remaining on the
|
|
||||||
* oneshot timer.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static int intel64_tick_cancel(struct oneshot_lowerhalf_s *lower,
|
|
||||||
clock_t *ticks)
|
|
||||||
{
|
|
||||||
struct timespec ts;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = intel64_cancel(lower, &ts);
|
|
||||||
|
|
||||||
/* Convert time to ticks */
|
|
||||||
|
|
||||||
*ticks = clock_time2ticks(&ts);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: intel64_tick_current
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Get the current time.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* lower Caller allocated instance of the oneshot state structure. This
|
|
||||||
* structure must have been previously initialized via a call to
|
|
||||||
* oneshot_initialize();
|
|
||||||
* ticks The location in which to return the current time.
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* Zero (OK) is returned on success, a negated errno value is returned on
|
|
||||||
* any failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static int intel64_tick_current(struct oneshot_lowerhalf_s *lower,
|
|
||||||
clock_t *ticks)
|
|
||||||
{
|
|
||||||
struct timespec ts;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = intel64_current(lower, &ts);
|
|
||||||
|
|
||||||
/* Convert time to ticks */
|
|
||||||
|
|
||||||
*ticks = clock_time2ticks(&ts);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
@@ -95,10 +95,8 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#define ONESHOT_MAX_DELAY(l,t) \
|
#define ONESHOT_MAX_DELAY(l,t) (l)->ops->max_delay(l,t)
|
||||||
((l)->ops->max_delay ? (l)->ops->max_delay(l,t) : oneshot_max_delay(l,t))
|
#define ONESHOT_TICK_MAX_DELAY(l,t) oneshot_tick_max_delay(l,t)
|
||||||
#define ONESHOT_TICK_MAX_DELAY(l,t) \
|
|
||||||
((l)->ops->tick_max_delay ? (l)->ops->tick_max_delay(l,t) : oneshot_tick_max_delay(l,t))
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: ONESHOT_START
|
* Name: ONESHOT_START
|
||||||
@@ -120,10 +118,8 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#define ONESHOT_START(l,t) \
|
#define ONESHOT_START(l,t) (l)->ops->start(l,t)
|
||||||
((l)->ops->start ? (l)->ops->start(l,t) : oneshot_start(l,t))
|
#define ONESHOT_TICK_START(l,t) oneshot_tick_start(l,t)
|
||||||
#define ONESHOT_TICK_START(l,t) \
|
|
||||||
((l)->ops->tick_start ? (l)->ops->tick_start(l,t) : oneshot_tick_start(l,t))
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: ONESHOT_CANCEL
|
* Name: ONESHOT_CANCEL
|
||||||
@@ -149,10 +145,8 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#define ONESHOT_CANCEL(l,t) \
|
#define ONESHOT_CANCEL(l,t) (l)->ops->cancel(l,t)
|
||||||
((l)->ops->cancel ? (l)->ops->cancel(l,t) : oneshot_cancel(l,t))
|
#define ONESHOT_TICK_CANCEL(l,t) oneshot_tick_cancel(l,t)
|
||||||
#define ONESHOT_TICK_CANCEL(l,t) \
|
|
||||||
((l)->ops->tick_cancel ? (l)->ops->tick_cancel(l,t) : oneshot_tick_cancel(l,t))
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: ONESHOT_CURRENT
|
* Name: ONESHOT_CURRENT
|
||||||
@@ -173,10 +167,8 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#define ONESHOT_CURRENT(l,t) \
|
#define ONESHOT_CURRENT(l,t) (l)->ops->current(l,t)
|
||||||
((l)->ops->current ? (l)->ops->current(l,t) : oneshot_current(l,t))
|
#define ONESHOT_TICK_CURRENT(l,t) oneshot_tick_current(l,t)
|
||||||
#define ONESHOT_TICK_CURRENT(l,t) \
|
|
||||||
((l)->ops->tick_current ? (l)->ops->tick_current(l,t) : oneshot_tick_current(l,t))
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Types
|
* Public Types
|
||||||
@@ -207,14 +199,6 @@ struct oneshot_operations_s
|
|||||||
FAR struct timespec *ts);
|
FAR struct timespec *ts);
|
||||||
CODE int (*current)(FAR struct oneshot_lowerhalf_s *lower,
|
CODE int (*current)(FAR struct oneshot_lowerhalf_s *lower,
|
||||||
FAR struct timespec *ts);
|
FAR struct timespec *ts);
|
||||||
CODE int (*tick_max_delay)(FAR struct oneshot_lowerhalf_s *lower,
|
|
||||||
FAR clock_t *ticks);
|
|
||||||
CODE int (*tick_start)(FAR struct oneshot_lowerhalf_s *lower,
|
|
||||||
clock_t ticks);
|
|
||||||
CODE int (*tick_cancel)(FAR struct oneshot_lowerhalf_s *lower,
|
|
||||||
FAR clock_t *ticks);
|
|
||||||
CODE int (*tick_current)(FAR struct oneshot_lowerhalf_s *lower,
|
|
||||||
FAR clock_t *ticks);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* This structure describes the state of the oneshot timer lower-half
|
/* This structure describes the state of the oneshot timer lower-half
|
||||||
@@ -260,77 +244,9 @@ extern "C"
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Function Prototypes
|
* Inline Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static inline
|
|
||||||
int oneshot_max_delay(FAR struct oneshot_lowerhalf_s *lower,
|
|
||||||
FAR struct timespec *ts)
|
|
||||||
{
|
|
||||||
clock_t tick;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (lower->ops->tick_max_delay == NULL)
|
|
||||||
{
|
|
||||||
return -ENOTSUP;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = lower->ops->tick_max_delay(lower, &tick);
|
|
||||||
clock_ticks2time(ts, tick);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline
|
|
||||||
int oneshot_start(FAR struct oneshot_lowerhalf_s *lower,
|
|
||||||
FAR const struct timespec *ts)
|
|
||||||
{
|
|
||||||
clock_t tick;
|
|
||||||
|
|
||||||
if (lower->ops->tick_start == NULL)
|
|
||||||
{
|
|
||||||
return -ENOTSUP;
|
|
||||||
}
|
|
||||||
|
|
||||||
tick = clock_time2ticks(ts);
|
|
||||||
return lower->ops->tick_start(lower, tick);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline
|
|
||||||
int oneshot_cancel(FAR struct oneshot_lowerhalf_s *lower,
|
|
||||||
FAR struct timespec *ts)
|
|
||||||
{
|
|
||||||
clock_t tick;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (lower->ops->tick_cancel == NULL)
|
|
||||||
{
|
|
||||||
return -ENOTSUP;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = lower->ops->tick_cancel(lower, &tick);
|
|
||||||
clock_ticks2time(ts, tick);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline
|
|
||||||
int oneshot_current(FAR struct oneshot_lowerhalf_s *lower,
|
|
||||||
FAR struct timespec *ts)
|
|
||||||
{
|
|
||||||
clock_t tick;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (lower->ops->tick_current == NULL)
|
|
||||||
{
|
|
||||||
return -ENOTSUP;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = lower->ops->tick_current(lower, &tick);
|
|
||||||
clock_ticks2time(ts, tick);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline
|
static inline
|
||||||
int oneshot_tick_max_delay(FAR struct oneshot_lowerhalf_s *lower,
|
int oneshot_tick_max_delay(FAR struct oneshot_lowerhalf_s *lower,
|
||||||
FAR clock_t *ticks)
|
FAR clock_t *ticks)
|
||||||
@@ -408,6 +324,10 @@ void oneshot_process_callback(FAR struct oneshot_lowerhalf_s *lower)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: oneshot_initialize
|
* Name: oneshot_initialize
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user