ChibiOS/RT Architecture - Reference Manual - Guides |
Time and Virtual Timers related APIs and services.
Data Structures | |
struct | VirtualTimer |
Virtual Timer descriptor structure. More... | |
struct | VTList |
Virtual timers list header. More... | |
Defines | |
#define | S2ST(sec) ((systime_t)((sec) * CH_FREQUENCY)) |
Time conversion utility. | |
#define | MS2ST(msec) ((systime_t)(((((msec) - 1L) * CH_FREQUENCY) / 1000L) + 1L)) |
Time conversion utility. | |
#define | US2ST(usec) ((systime_t)(((((usec) - 1L) * CH_FREQUENCY) / 1000000L) + 1L)) |
Time conversion utility. | |
#define | chVTDoTickI() |
Virtual timers ticker. | |
#define | chVTIsArmedI(vtp) ((vtp)->vt_func != NULL) |
Returns TRUE if the speciified timer is armed. | |
#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. | |
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. |
#define S2ST | ( | sec | ) | ((systime_t)((sec) * CH_FREQUENCY)) |
#define MS2ST | ( | msec | ) | ((systime_t)(((((msec) - 1L) * CH_FREQUENCY) / 1000L) + 1L)) |
Time conversion utility.
Converts from milliseconds to system ticks number.
Definition at line 50 of file chvt.h.
Referenced by mmcStart(), and tmrfunc().
#define US2ST | ( | usec | ) | ((systime_t)(((((usec) - 1L) * CH_FREQUENCY) / 1000000L) + 1L)) |
#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; \ fn(vtp->vt_par); \ } \ } \ }
Virtual timers ticker.
Definition at line 106 of file chvt.h.
Referenced by chSysTimerHandlerI().
#define chVTIsArmedI | ( | vtp | ) | ((vtp)->vt_func != NULL) |
Returns TRUE if the speciified timer is armed.
Definition at line 139 of file chvt.h.
Referenced by chSchGoSleepTimeoutS(), and chibios_rt::Timer::IsArmed().
#define chTimeNow | ( | ) | (vtlist.vt_systime) |
Current system time.
Returns the number of system ticks since the chSysInit()
invocation.
chThdSleepUntil()
.Definition at line 150 of file chvt.h.
Referenced by chDbgTrace(), chThdSleepUntil(), chTimeIsWithin(), chibios_rt::System::GetTime(), macWaitReceiveDescriptor(), and macWaitTransmitDescriptor().
typedef void(* vtfunc_t)(void *) |
typedef struct VirtualTimer VirtualTimer |
void vt_init | ( | void | ) |
Virtual Timers initialization.
Definition at line 47 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 time ticks, the value TIME_INFINITE is notallowed. The value TIME_IMMEDIATE is allowed but interpreted as a normal time specification not as an immediate timeout specification. |
[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 70 of file chvt.c.
References chDbgCheck, TIME_INFINITE, VirtualTimer::vt_func, VirtualTimer::vt_next, VTList::vt_next, VirtualTimer::vt_par, VirtualTimer::vt_prev, and VirtualTimer::vt_time.
Referenced by chSchGoSleepTimeoutS(), mmcStart(), chibios_rt::Timer::Set(), and tmrfunc().
void chVTResetI | ( | VirtualTimer * | vtp | ) |
Disables a Virtual Timer.
[in] | vtp | the VirtualTimer structure pointer |
Definition at line 97 of file chvt.c.
References chDbgAssert, chDbgCheck, VirtualTimer::vt_func, VirtualTimer::vt_next, VirtualTimer::vt_prev, and VirtualTimer::vt_time.
Referenced by chSchGoSleepTimeoutS(), mmcStop(), and chibios_rt::Timer::Reset().
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 122 of file chvt.c.
References chTimeNow.