ChibiOS/RT
6.1.4
|
Time and Virtual Timers related APIs and services.
Functions | |
static void | vt_init (delta_list_t *dlhp) |
Delta list initialization. More... | |
static bool | vt_is_empty (delta_list_t *dlhp) |
List empty check. More... | |
static bool | vt_is_last (delta_list_t *dlhp, delta_list_t *dlp) |
Last timer in the list check. More... | |
static bool | vt_is_first (delta_list_t *dlhp, delta_list_t *dlp) |
Fist timer in the list check. More... | |
static bool | vt_is_timer (delta_list_t *dlhp, delta_list_t *dlp) |
Timer check. More... | |
static void | vt_insert_after (delta_list_t *dlhp, delta_list_t *dlp, sysinterval_t delta) |
Inserts an element after another header element. More... | |
static void | vt_insert_before (delta_list_t *dlhp, delta_list_t *dlp, sysinterval_t delta) |
Inserts an element before another header element. More... | |
static void | vt_insert (delta_list_t *dlhp, delta_list_t *dlep, sysinterval_t delta) |
Inserts an element in a delta list. More... | |
static delta_list_t * | vt_remove_first (delta_list_t *dlhp) |
Dequeues an element from the delta list. More... | |
static delta_list_t * | vt_dequeue (delta_list_t *dlp) |
Dequeues an element from the delta list. More... | |
static void | vt_set_alarm (systime_t now, sysinterval_t delay) |
Alarm time setup. More... | |
static void | vt_insert_first (virtual_timers_list_t *vtlp, virtual_timer_t *vtp, systime_t now, sysinterval_t delay) |
Inserts a timer as first element in a delta list. More... | |
static void | vt_enqueue (virtual_timers_list_t *vtlp, virtual_timer_t *vtp, sysinterval_t delay) |
Enqueues a virtual timer in a virtual timers list. More... | |
void | _vt_init (void) |
Virtual Timers initialization. More... | |
void | chVTDoSetI (virtual_timer_t *vtp, sysinterval_t delay, vtfunc_t vtfunc, void *par) |
Enables a one-shot virtual timer. More... | |
void | chVTDoResetI (virtual_timer_t *vtp) |
Disables a Virtual Timer. More... | |
sysinterval_t | chVTGetRemainingIntervalI (virtual_timer_t *vtp) |
Returns the remaining time interval before next timer trigger. More... | |
void | chVTDoTickI (void) |
Virtual timers ticker. More... | |
static void | chVTObjectInit (virtual_timer_t *vtp) |
Initializes a virtual_timer_t object. More... | |
static systime_t | chVTGetSystemTimeX (void) |
Current system time. More... | |
static systime_t | chVTGetSystemTime (void) |
Current system time. More... | |
static sysinterval_t | chVTTimeElapsedSinceX (systime_t start) |
Returns the elapsed time since the specified start time. More... | |
static bool | chVTIsSystemTimeWithinX (systime_t start, systime_t end) |
Checks if the current system time is within the specified time window. More... | |
static bool | chVTIsSystemTimeWithin (systime_t start, systime_t end) |
Checks if the current system time is within the specified time window. More... | |
static bool | chVTGetTimersStateI (sysinterval_t *timep) |
Returns the time interval until the next timer event. More... | |
static bool | chVTIsArmedI (const virtual_timer_t *vtp) |
Returns true if the specified timer is armed. More... | |
static bool | chVTIsArmed (const virtual_timer_t *vtp) |
Returns true if the specified timer is armed. More... | |
static void | chVTResetI (virtual_timer_t *vtp) |
Disables a Virtual Timer. More... | |
static void | chVTReset (virtual_timer_t *vtp) |
Disables a Virtual Timer. More... | |
static void | chVTSetI (virtual_timer_t *vtp, sysinterval_t delay, vtfunc_t vtfunc, void *par) |
Enables a virtual timer. More... | |
static void | chVTSet (virtual_timer_t *vtp, sysinterval_t delay, vtfunc_t vtfunc, void *par) |
Enables a virtual timer. More... | |
|
inlinestatic |
Delta list initialization.
[out] | dlhp | pointer to the delta list header |
Definition at line 58 of file chvt.c.
References ch_delta_list::delta, ch_delta_list::next, and ch_delta_list::prev.
Referenced by _vt_init().
|
inlinestatic |
List empty check.
[in] | dlhp | pointer to the delta list header |
Definition at line 72 of file chvt.c.
References ch_delta_list::next.
Referenced by chVTDoResetI(), chVTDoTickI(), and vt_enqueue().
|
inlinestatic |
Last timer in the list check.
[in] | dlhp | pointer to the delta list header |
[in] | dlp | pointer to the delta list element |
Definition at line 85 of file chvt.c.
References ch_delta_list::next.
|
inlinestatic |
Fist timer in the list check.
[in] | dlhp | pointer to the delta list header |
[in] | dlp | pointer to the delta list element |
Definition at line 98 of file chvt.c.
References ch_delta_list::next.
Referenced by chVTDoResetI().
|
inlinestatic |
|
inlinestatic |
Inserts an element after another header element.
[in] | dlhp | pointer to the delta list header element |
[in] | dlp | element to be inserted after the header element |
[in] | delta | delta of the element to be inserted |
Definition at line 125 of file chvt.c.
References ch_delta_list::delta, ch_delta_list::next, and ch_delta_list::prev.
Referenced by vt_insert_first().
|
inlinestatic |
Inserts an element before another header element.
[in] | dlhp | pointer to the delta list header element |
[in] | dlp | element to be inserted before the header element |
[in] | delta | delta of the element to be inserted |
Definition at line 145 of file chvt.c.
References ch_delta_list::delta, ch_delta_list::next, and ch_delta_list::prev.
Referenced by vt_insert().
|
inlinestatic |
Inserts an element in a delta list.
[in] | dlhp | pointer to the delta list header element |
[in] | dlep | element to be inserted before the header element |
[in] | delta | delta of the element to be inserted |
Definition at line 165 of file chvt.c.
References chDbgAssert, ch_delta_list::delta, ch_delta_list::next, and vt_insert_before().
Referenced by vt_enqueue().
|
inlinestatic |
Dequeues an element from the delta list.
[in] | dlhp | pointer to the delta list header |
Definition at line 200 of file chvt.c.
References ch_delta_list::next, and ch_delta_list::prev.
Referenced by chVTDoResetI().
|
inlinestatic |
Dequeues an element from the delta list.
[in] | dlp | pointer to the delta list element |
Definition at line 216 of file chvt.c.
References ch_delta_list::next, and ch_delta_list::prev.
Referenced by chVTDoResetI(), and chVTDoTickI().
|
static |
Alarm time setup.
(now + delay)
, the deadline is skipped forward in order to compensate for the event.[in] | now | last known system time |
[in] | delay | delay over now |
Definition at line 234 of file chvt.c.
References CH_CFG_ST_TIMEDELTA, chDbgAssert, chTimeAddX(), chTimeDiffX(), chVTGetSystemTimeX(), and TIME_MAX_SYSTIME.
Referenced by chVTDoResetI(), chVTDoTickI(), and vt_enqueue().
|
static |
Inserts a timer as first element in a delta list.
Definition at line 288 of file chvt.c.
References CH_CFG_ST_TIMEDELTA, chDbgAssert, chTimeAddX(), chTimeDiffX(), chVTGetSystemTimeX(), ch_virtual_timer::dlist, ch_virtual_timers_list::dlist, ch_virtual_timers_list::lasttime, TIME_MAX_SYSTIME, and vt_insert_after().
Referenced by vt_enqueue().
|
static |
Enqueues a virtual timer in a virtual timers list.
Definition at line 350 of file chvt.c.
References chTimeDiffX(), chVTGetSystemTimeX(), ch_virtual_timer::dlist, ch_virtual_timers_list::dlist, ch_virtual_timers_list::lasttime, vt_insert(), vt_insert_first(), vt_is_empty(), and vt_set_alarm().
Referenced by chVTDoSetI().
void _vt_init | ( | void | ) |
Virtual Timers initialization.
Definition at line 406 of file chvt.c.
References ch, ch_virtual_timers_list::dlist, ch_virtual_timers_list::lasttime, ch_virtual_timers_list::systime, vt_init(), and ch_system::vtlist.
Referenced by chSysInit().
void chVTDoSetI | ( | virtual_timer_t * | vtp, |
sysinterval_t | delay, | ||
vtfunc_t | vtfunc, | ||
void * | par | ||
) |
Enables a one-shot virtual timer.
The timer is enabled and programmed to trigger after the delay specified as parameter.
[out] | vtp | the virtual_timer_t structure pointer |
[in] | delay | the number of ticks before the operation timeouts, the special values are handled as follow:
|
[in] | vtfunc | the timer callback function. After invoking the callback the timer is disabled and the structure can be disposed or reused. |
[in] | par | a parameter that will be passed to the callback function |
Definition at line 438 of file chvt.c.
References ch, chDbgCheck, chDbgCheckClassI(), ch_virtual_timer::func, ch_virtual_timer::par, TIME_IMMEDIATE, vt_enqueue(), and ch_system::vtlist.
Referenced by chSchGoSleepTimeoutS(), and chVTSetI().
void chVTDoResetI | ( | virtual_timer_t * | vtp | ) |
Disables a Virtual Timer.
[in] | vtp | the virtual_timer_t structure pointer |
Definition at line 461 of file chvt.c.
References ch, chDbgAssert, chDbgCheck, chDbgCheckClassI(), chTimeDiffX(), chVTGetSystemTimeX(), chVTIsArmedI(), ch_delta_list::delta, ch_virtual_timer::dlist, ch_virtual_timers_list::dlist, ch_virtual_timer::func, ch_virtual_timers_list::lasttime, ch_delta_list::next, vt_dequeue(), vt_is_empty(), vt_is_first(), vt_remove_first(), vt_set_alarm(), and ch_system::vtlist.
Referenced by chVTResetI().
sysinterval_t chVTGetRemainingIntervalI | ( | virtual_timer_t * | vtp | ) |
Returns the remaining time interval before next timer trigger.
[in] | vtp | the virtual_timer_t structure pointer |
Definition at line 544 of file chvt.c.
References ch, chDbgAssert, chDbgCheckClassI(), chTimeDiffX(), chVTGetSystemTimeX(), ch_delta_list::delta, ch_virtual_timer::dlist, ch_virtual_timers_list::dlist, ch_virtual_timers_list::lasttime, ch_delta_list::next, and ch_system::vtlist.
void chVTDoTickI | ( | void | ) |
Virtual timers ticker.
Definition at line 584 of file chvt.c.
References ch, chDbgCheckClassI(), chSysLockFromISR(), chSysUnlockFromISR(), chTimeAddX(), chTimeDiffX(), chVTGetSystemTimeX(), ch_delta_list::delta, ch_virtual_timer::dlist, ch_virtual_timers_list::dlist, ch_virtual_timer::func, ch_virtual_timers_list::lasttime, ch_delta_list::next, ch_virtual_timer::par, ch_virtual_timers_list::systime, vt_dequeue(), vt_is_empty(), vt_set_alarm(), and ch_system::vtlist.
Referenced by chSysTimerHandlerI().
|
inlinestatic |
Initializes a virtual_timer_t
object.
chVTSetI()
initializes the object too. This function is only useful if you need to perform a chVTIsArmed()
check before calling chVTSetI()
.[out] | vtp | the virtual_timer_t structure pointer |
Definition at line 98 of file chvt.h.
References ch_virtual_timer::func.
|
inlinestatic |
Current system time.
Returns the number of system ticks since the chSysInit()
invocation.
systime_t
size.Definition at line 116 of file chvt.h.
References ch, ch_virtual_timers_list::systime, and ch_system::vtlist.
Referenced by chThdSleepUntil(), chThdSleepUntilWindowed(), chVTDoResetI(), chVTDoTickI(), chVTGetRemainingIntervalI(), chVTGetSystemTime(), chVTGetTimersStateI(), chVTIsSystemTimeWithinX(), chVTTimeElapsedSinceX(), trace_next(), vt_enqueue(), vt_insert_first(), and vt_set_alarm().
|
inlinestatic |
Current system time.
Returns the number of system ticks since the chSysInit()
invocation.
Definition at line 135 of file chvt.h.
References chSysLock(), chSysUnlock(), and chVTGetSystemTimeX().
Referenced by chVTIsSystemTimeWithin().
|
inlinestatic |
Returns the elapsed time since the specified start time.
[in] | start | start time |
Definition at line 153 of file chvt.h.
References chTimeDiffX(), and chVTGetSystemTimeX().
Checks if the current system time is within the specified time window.
[in] | start | the start of the time window (inclusive) |
[in] | end | the end of the time window (non inclusive) |
true | current time within the specified time window. |
false | current time not within the specified time window. |
Definition at line 171 of file chvt.h.
References chTimeIsInRangeX(), and chVTGetSystemTimeX().
Checks if the current system time is within the specified time window.
[in] | start | the start of the time window (inclusive) |
[in] | end | the end of the time window (non inclusive) |
true | current time within the specified time window. |
false | current time not within the specified time window. |
Definition at line 189 of file chvt.h.
References chTimeIsInRangeX(), and chVTGetSystemTime().
|
inlinestatic |
Returns the time interval until the next timer event.
CH_CFG_ST_TIMEDELTA
ticks. [out] | timep | pointer to a variable that will contain the time interval until the next timer elapses. This pointer can be NULL if the information is not required. |
false | if the timers list is empty. |
true | if the timers list contains at least one timer. |
Definition at line 210 of file chvt.h.
References ch, CH_CFG_ST_TIMEDELTA, chDbgCheckClassI(), chTimeDiffX(), chVTGetSystemTimeX(), ch_delta_list::delta, ch_virtual_timers_list::dlist, ch_virtual_timers_list::lasttime, ch_delta_list::next, and ch_system::vtlist.
|
inlinestatic |
Returns true
if the specified timer is armed.
chVTObjectInit()
or chVTDoSetI()
.[in] | vtp | the virtual_timer_t structure pointer |
Definition at line 242 of file chvt.h.
References chDbgCheckClassI(), and ch_virtual_timer::func.
Referenced by chVTDoResetI(), chVTIsArmed(), and chVTResetI().
|
inlinestatic |
Returns true
if the specified timer is armed.
chVTObjectInit()
or chVTDoSetI()
.[in] | vtp | the virtual_timer_t structure pointer |
Definition at line 259 of file chvt.h.
References chSysLock(), chSysUnlock(), and chVTIsArmedI().
|
inlinestatic |
Disables a Virtual Timer.
chVTObjectInit()
or chVTDoSetI()
.[in] | vtp | the virtual_timer_t structure pointer |
Definition at line 279 of file chvt.h.
References chVTDoResetI(), and chVTIsArmedI().
Referenced by chVTReset(), and chVTSetI().
|
inlinestatic |
Disables a Virtual Timer.
chVTObjectInit()
or chVTDoSetI()
.[in] | vtp | the virtual_timer_t structure pointer |
Definition at line 296 of file chvt.h.
References chSysLock(), chSysUnlock(), and chVTResetI().
|
inlinestatic |
Enables a virtual timer.
If the virtual timer was already enabled then it is re-enabled using the new parameters.
chVTObjectInit()
or chVTDoSetI()
.[in] | vtp | the virtual_timer_t structure pointer |
[in] | delay | the number of ticks before the operation timeouts, the special values are handled as follow:
|
[in] | vtfunc | the timer callback function. After invoking the callback the timer is disabled and the structure can be disposed or reused. |
[in] | par | a parameter that will be passed to the callback function |
Definition at line 325 of file chvt.h.
References chVTDoSetI(), and chVTResetI().
Referenced by chVTSet().
|
inlinestatic |
Enables a virtual timer.
If the virtual timer was already enabled then it is re-enabled using the new parameters.
chVTObjectInit()
or chVTDoSetI()
.[in] | vtp | the virtual_timer_t structure pointer |
[in] | delay | the number of ticks before the operation timeouts, the special values are handled as follow:
|
[in] | vtfunc | the timer callback function. After invoking the callback the timer is disabled and the structure can be disposed or reused. |
[in] | par | a parameter that will be passed to the callback function |
Definition at line 354 of file chvt.h.
References chSysLock(), chSysUnlock(), and chVTSetI().