timer.h File Reference
Hardware independent timer driver (interface). More...
#include <cfg/os.h>
#include <cfg/macros.h>
#include <cpu/attr.h>
#include <cpu/irq.h>
#include <CPU_HEADER(timer)>
#include <mware/list.h>
#include <cfg/debug.h>
#include <cfg/compiler.h>
#include <appconfig.h>
#include <mware/event.h>
Go to the source code of this file.
Data Structures | |
| struct | Timer |
| The timer driver supports multiple synchronous timers that can trigger an event when they expire. More... | |
Defines | |
| #define | TIMER_MAGIC_ACTIVE 0xABBA |
| Timer is active when Timer.magic contains this value (for debugging purposes). | |
Functions | |
| ticks_t | timer_clock (void) |
| Return the system tick counter (expressed in ticks). | |
| ticks_t | timer_clock_unlocked (void) |
| Faster version of timer_clock(), to be called only when the timer interrupt is disabled (DISABLE_INTS) or overridden by a higher-priority or non-nesting interrupt. | |
| ticks_t | ms_to_ticks (mtime_t ms) |
| Convert ms [ms] to ticks. | |
| ticks_t | us_to_ticks (utime_t us) |
| Convert us [us] to ticks. | |
| mtime_t | ticks_to_ms (ticks_t ticks) |
| Convert ticks [ticks] to ms. | |
| utime_t | ticks_to_us (ticks_t ticks) |
| Convert ticks [ticks] to us. | |
| hptime_t | us_to_hptime (utime_t us) |
| Convert us [us] to hpticks. | |
| utime_t | hptime_to_us (hptime_t hpticks) |
| Convert hpticks [hptime] to usec. | |
| void | timer_delayTicks (ticks_t delay) |
| Wait for the specified amount of timer ticks. | |
| void | timer_delay (mtime_t delay) |
| Wait time ms using timer 0. | |
| void | timer_busyWait (hptime_t delay) |
| Busy wait until the specified amount of high-precision ticks have elapsed. | |
| void | timer_delayHp (hptime_t delay) |
| Wait for the specified amount of time (expressed in microseconds). | |
| void | timer_add (Timer *timer) |
| Add the specified timer to the software timer service queue. | |
| Timer * | timer_abort (Timer *timer) |
| Remove a timer from the timer queue before it has expired. | |
| void | timer_set_event_softint (Timer *timer, Hook func, iptr_t user_data) |
| Set the timer so that it calls an user hook when it expires. | |
| void | timer_setDelay (Timer *timer, ticks_t delay) |
| Set the timer delay (the time before the event will be triggered). | |
| void | timer_set_event_signal (Timer *timer, struct Process *proc, sigmask_t sigs) |
| Set the timer so that it sends a signal when it expires. | |
Variables | |
| volatile ticks_t | _clock |
| Master system clock (1 tick accuracy). | |
Detailed Description
Hardware independent timer driver (interface).
- Version:
- Id
- timer.h 932 2007-10-23 15:57:59Z batt
Definition in file timer.h.
Define Documentation
| #define TIMER_MAGIC_ACTIVE 0xABBA |
Timer is active when Timer.magic contains this value (for debugging purposes).
Function Documentation
| void timer_add | ( | Timer * | timer | ) |
| void timer_busyWait | ( | hptime_t | delay | ) |
| ticks_t timer_clock | ( | void | ) | [inline] |
Return the system tick counter (expressed in ticks).
The result is guaranteed to increment monotonically, but client code must be tolerant with respect to overflows.
The following code is safe:
ticks_t tea_start_time = timer_clock(); boil_water(); if (timer_clock() - tea_start_time > TEAPOT_DELAY) printf("Your tea, Sir.\n");
- Note:
- This function must disable interrupts on 8/16bit CPUs because the clock variable is larger than the processor word size and can't be copied atomically.
| ticks_t timer_clock_unlocked | ( | void | ) | [inline] |
Faster version of timer_clock(), to be called only when the timer interrupt is disabled (DISABLE_INTS) or overridden by a higher-priority or non-nesting interrupt.
- See also:
- timer_clock
| void timer_delayHp | ( | hptime_t | delay | ) |
