|
ChibiOS/RT
2.6.0 |
|
Time and Virtual Timers related APIs and services.
Data Structures | |
| struct | VirtualTimer |
| Virtual Timer descriptor structure. More... | |
| struct | VTList |
| Virtual timers list header. More... | |
Functions | |
| void | _vt_init (void) |
| Virtual Timers initialization. | |
| void | chVTSetI (VirtualTimer *vtp, systime_t time, vtfunc_t vtfunc, void *par) |
| Enables a virtual timer. | |
| void | chVTResetI (VirtualTimer *vtp) |
| Disables a Virtual Timer. | |
| bool_t | chTimeIsWithin (systime_t start, systime_t end) |
| Checks if the current system time is within the specified time window. | |
Variables | |
| VTList | vtlist |
| Virtual timers delta list header. | |
| VTList | vtlist |
| Virtual timers delta list header. | |
Time conversion utilities | |
| #define | S2ST(sec) ((systime_t)((sec) * CH_FREQUENCY)) |
| Seconds to system ticks. | |
| #define | MS2ST(msec) |
| Milliseconds to system ticks. | |
| #define | US2ST(usec) |
| Microseconds to system ticks. | |
Macro Functions | |
| #define | chVTDoTickI() |
| Virtual timers ticker. | |
| #define | chVTIsArmedI(vtp) ((vtp)->vt_func != NULL) |
Returns TRUE if the specified timer is armed. | |
| #define | chVTSet(vtp, time, vtfunc, par) |
| Enables a virtual timer. | |
| #define | chVTReset(vtp) |
| Disables a Virtual Timer. | |
| #define | chTimeNow() (vtlist.vt_systime) |
| Current system time. | |
Typedefs | |
| typedef void(* | vtfunc_t )(void *) |
| Virtual Timer callback function. | |
| typedef struct VirtualTimer | VirtualTimer |
| Virtual Timer structure type. | |
| void _vt_init | ( | void | ) |
Virtual Timers initialization.
Definition at line 50 of file chvt.c.
References VTList::vt_next, VTList::vt_prev, VTList::vt_systime, and VTList::vt_time.
Referenced by chSysInit().
| void chVTSetI | ( | VirtualTimer * | vtp, |
| systime_t | time, | ||
| vtfunc_t | vtfunc, | ||
| void * | par | ||
| ) |
Enables a virtual timer.
| [out] | vtp | the VirtualTimer structure pointer |
| [in] | time | 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 76 of file chvt.c.
References chDbgCheck, chDbgCheckClassI(), TIME_IMMEDIATE, VirtualTimer::vt_func, VirtualTimer::vt_next, VTList::vt_next, VirtualTimer::vt_par, VirtualTimer::vt_prev, VirtualTimer::vt_time, and vtlist.
Referenced by chSchGoSleepTimeoutS(), evtStart(), and chibios_rt::Timer::setI().

| void chVTResetI | ( | VirtualTimer * | vtp | ) |
Disables a Virtual Timer.
| [in] | vtp | the VirtualTimer structure pointer |
Definition at line 106 of file chvt.c.
References chDbgAssert, chDbgCheck, chDbgCheckClassI(), VirtualTimer::vt_func, VirtualTimer::vt_next, VirtualTimer::vt_prev, and VirtualTimer::vt_time.
Referenced by chSchGoSleepTimeoutS(), and chibios_rt::Timer::resetI().

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 134 of file chvt.c.
References chTimeNow.
Referenced by chibios_rt::System::isTimeWithin().
| #define S2ST | ( | sec | ) | ((systime_t)((sec) * CH_FREQUENCY)) |
Seconds to system ticks.
Converts from seconds to system ticks number.
| [in] | sec | number of seconds |
| #define MS2ST | ( | msec | ) |
((systime_t)(((((msec) - 1L) * CH_FREQUENCY) / \ 1000L) + 1L))
Milliseconds to system ticks.
Converts from milliseconds to system ticks number.
| [in] | msec | number of milliseconds |
Definition at line 65 of file chvt.h.
Referenced by test_start_timer().
| #define US2ST | ( | usec | ) |
((systime_t)(((((usec) - 1L) * CH_FREQUENCY) / \ 1000000L) + 1L))
Microseconds to system ticks.
Converts from microseconds to system ticks number.
| [in] | usec | number of microseconds |
| #define chVTDoTickI | ( | ) |
{ \
vtlist.vt_systime++; \
if (&vtlist != (VTList *)vtlist.vt_next) { \
VirtualTimer *vtp; \
\
--vtlist.vt_next->vt_time; \
while (!(vtp = vtlist.vt_next)->vt_time) { \
vtfunc_t fn = vtp->vt_func; \
vtp->vt_func = (vtfunc_t)NULL; \
vtp->vt_next->vt_prev = (void *)&vtlist; \
(&vtlist)->vt_next = vtp->vt_next; \
chSysUnlockFromIsr(); \
fn(vtp->vt_par); \
chSysLockFromIsr(); \
} \
} \
}
Virtual timers ticker.
Definition at line 137 of file chvt.h.
Referenced by chSysTimerHandlerI().
| #define chVTIsArmedI | ( | vtp | ) | ((vtp)->vt_func != NULL) |
Returns TRUE if the specified timer is armed.
Definition at line 160 of file chvt.h.
Referenced by chSchGoSleepTimeoutS(), evtStart(), chibios_rt::Timer::isArmedI(), and chibios_rt::Timer::resetI().
| #define chVTSet | ( | vtp, | |
| time, | |||
| vtfunc, | |||
| par | |||
| ) |
{ \
chSysLock(); \
chVTSetI(vtp, time, vtfunc, par); \
chSysUnlock(); \
}
Enables a virtual timer.
| [out] | vtp | the VirtualTimer structure pointer |
| [in] | time | 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 181 of file chvt.h.
Referenced by test_start_timer().
| #define chVTReset | ( | vtp | ) |
{ \
chSysLock(); \
if (chVTIsArmedI(vtp)) \
chVTResetI(vtp); \
chSysUnlock(); \
}
Disables a Virtual Timer.
| [in] | vtp | the VirtualTimer structure pointer |
Definition at line 195 of file chvt.h.
Referenced by evtStop().
| #define chTimeNow | ( | ) | (vtlist.vt_systime) |
Current system time.
Returns the number of system ticks since the chSysInit() invocation.
chThdSleepUntil().Definition at line 213 of file chvt.h.
Referenced by chThdSleepUntil(), chTimeIsWithin(), dbg_trace(), chibios_rt::System::getTime(), macWaitReceiveDescriptor(), macWaitTransmitDescriptor(), and test_wait_tick().
| typedef void(* vtfunc_t)(void *) |
| typedef struct VirtualTimer VirtualTimer |