Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/rtthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ void rt_object_put_sethook(void (*hook)(struct rt_object *object));
* clock & timer interface
*/
rt_tick_t rt_tick_get(void);
rt_tick_t rt_delta_tick_get(rt_tick_t last_time);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的函数名风格和RT-Thread的函数名风格不一致

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你给个范例

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rt_tick_t rt_tick_get_delta(rt_tick_t base);

void rt_tick_set(rt_tick_t tick);
void rt_tick_increase(void);
void rt_tick_increase_tick(rt_tick_t tick);
Expand Down
19 changes: 19 additions & 0 deletions src/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,25 @@ rt_tick_t rt_tick_get(void)
}
RTM_EXPORT(rt_tick_get);

/**
* @brief This function will return delta tick from last_time.
*
* @param last_time to consider
*
* @return Return delta tick.
*/
rt_tick_t rt_delta_tick_get(rt_tick_t last_time)
{
rt_tick_t delta;
rt_tick_t tnow = rt_tick_get();
if (tnow >= last_time)
delta = tnow - last_time;
else
delta = RT_TICK_MAX - last_time + tnow + 1;
return delta;
}
RTM_EXPORT(rt_delta_tick_get);

/**
* @brief This function will set current tick.
*
Expand Down
Loading