|
Modules | |
| AVR XMEGA Timer | |
Defines | |
| #define | timer_init(timer_id, timer, timer_callback) TIMER_SELECT(init, timer_id, timer, timer_callback) |
| Timer initialization. | |
| #define | timer_start(timer_id, timer) TIMER_SELECT(start, timer_id, timer) |
| Start the timer. | |
| #define | timer_stop(timer_id, timer) TIMER_SELECT(stop, timer_id, timer) |
| Stop the timer. | |
| #define | timer_set_alarm(timer_id, timer, delay) TIMER_SELECT(set_alarm, timer_id, timer, delay) |
| Set timer alarm. | |
| #define | timer_get_time(timer_id, timer) TIMER_SELECT(get_time, timer_id, timer) |
| Get current timer time stamp. | |
| #define | timer_write_resolution(timer_id, timer, timer_resolution) TIMER_SELECT(write_resolution, timer_id, timer, timer_resolution) |
| Set a timer resolution. | |
| #define | timer_set_resolution(timer_id, timer, resolution) TIMER_SELECT(set_resolution, timer_id, timer, resolution) |
| Generate a timer resolution configuration. | |
| #define | timer_read_resolution(timer_id, timer) TIMER_SELECT(read_resolution, timer_id, timer) |
| Read the current timer resolution configuration. | |
| #define | timer_get_resolution(timer_id, timer, timer_resolution) TIMER_SELECT(get_resolution, timer_id, timer, timer_resolution) |
| Convert the timer resolution configuration to ticks per second. | |
| #define | timer_maximum_delta(timer_id, timer) TIMER_SELECT(maximum_delta, timer_id, timer) |
| Get the maximum allowed timer delta. | |
A timer can be used to time events on the system. For example instead of active waiting, the CPU can go to sleep until the timer wakes the CPU up again. This is done by setting alarms on the timers. It is also possible to configure callback functions to be called once the alarms trigger.
Timers are based on various different hardware implementations and these are described in the sub-sections in this documentation. Depending on the chips hardware features, some of them may be available or not. A description which timer IDs correspond to which implementation is available in the sub-sections (added from <chip/timer.h>).
To enable the timer framework, an application must define the configuration symbol CONFIG_TIMER. Further configuration options are described in the specific implementations documentation.
The timers have a default resolution that can be changed by defining a CONFIG_TIMER_RESOLUTION symbol. The resolution must be expressed in ticks per second.
| #define timer_get_resolution | ( | timer_id, | |||
| timer, | |||||
| timer_resolution | ) | TIMER_SELECT(get_resolution, timer_id, timer, timer_resolution) |
Convert the timer resolution configuration to ticks per second.
| timer_id | Timer ID. | |
| timer | Pointer to timer struct. | |
| timer_resolution | Driver specific timer resolution representation. |
Definition at line 157 of file timer_xmega.h.
Referenced by app_memgame_launch(), app_tank_launch(), and slide_launch_helper().
Get current timer time stamp.
When the timer is stopped this function will always return 0 since the timer will start from 0 when started again.
| timer_id | Timer ID. | |
| timer | Pointer to timer struct. |
Definition at line 142 of file timer_xmega.h.
| #define timer_init | ( | timer_id, | |||
| timer, | |||||
| timer_callback | ) | TIMER_SELECT(init, timer_id, timer, timer_callback) |
Timer initialization.
An application can pass in a function pointer to a callback function which will be called each time the timer triggers.
| timer_id | Timer ID. | |
| timer | Pointer to timer struct. | |
| timer_callback | Function pointer to callback function. |
Definition at line 130 of file timer_xmega.h.
Referenced by app_memgame_launch(), app_tank_launch(), and slide_launch_helper().
Get the maximum allowed timer delta.
| timer_id | Timer ID. | |
| timer | Pointer to timer struct. |
Definition at line 160 of file timer_xmega.h.
Read the current timer resolution configuration.
| timer_id | Timer ID. | |
| timer | Pointer to timer struct. |
Definition at line 151 of file timer_xmega.h.
Set timer alarm.
The caller must ensure that the delay is within the allowed range of the timer. The maximum allowed value can be obtained by calling the function timer_maximum_delta. It is only possible to configure one alarm at once. If this function is called again while the current alarm has not triggered yet it will replace the current alarm settings.
| timer_id | Timer ID. | |
| timer | Pointer to timer struct. | |
| delay | Delay in timer ticks after which the alarm should trigger. |
Definition at line 139 of file timer_xmega.h.
Referenced by memgame_timer_callback(), memgame_update(), slide_show_file(), slide_timer_callback(), slide_worker(), tank_loader(), and tank_timer_callback().
| #define timer_set_resolution | ( | timer_id, | |||
| timer, | |||||
| resolution | ) | TIMER_SELECT(set_resolution, timer_id, timer, resolution) |
Generate a timer resolution configuration.
| timer_id | Timer ID. | |
| timer | Pointer to timer struct. | |
| resolution | Desired timer resolution in ticks per second. |
Definition at line 154 of file timer_xmega.h.
Referenced by app_memgame_launch(), app_tank_launch(), and slide_launch_helper().
Start the timer.
Calling this function will start the timer. The timer is reset before it starts thus it will start counting from 0.
| timer_id | Timer ID. | |
| timer | Pointer to timer struct. |
Definition at line 133 of file timer_xmega.h.
Referenced by memgame_update(), slide_show_file(), slide_worker(), and tank_loader().
Stop the timer.
| timer_id | Timer ID. | |
| timer | Pointer to timer struct. |
Definition at line 136 of file timer_xmega.h.
Referenced by memgame_timer_callback(), slide_window_handler(), and tank_frame_handler().
| #define timer_write_resolution | ( | timer_id, | |||
| timer, | |||||
| timer_resolution | ) | TIMER_SELECT(write_resolution, timer_id, timer, timer_resolution) |
Set a timer resolution.
| timer_id | Timer ID. | |
| timer | Pointer to timer struct. | |
| timer_resolution | This is a driver internal representation of the timer resolution. It can be generated by calling the timer_set_resolution function. |
Definition at line 148 of file timer_xmega.h.
Referenced by app_memgame_launch(), app_tank_launch(), and slide_launch_helper().
1.6.3