Interface to the timer module in the MIPS r4300 processor.
More...
|
#define | TF_ONE_SHOT 0 |
| Timer should fire only once.
|
|
#define | TF_CONTINUOUS 1 |
| Timer should fire at a regular interval.
|
|
#define | TF_DISABLED 2 |
| Timer is enabled or not. Can be used to get a new timer that's not started.
|
|
#define | TIMER_TICKS(us) ((int)TIMER_TICKS_LL(us)) |
| Calculate timer ticks based on microseconds.
|
|
#define | TIMER_MICROS(tk) ((int)TIMER_MICROS_LL(tk)) |
| Calculate microseconds based on timer ticks.
|
|
#define | TIMER_TICKS_LL(us) ((long long)(us) * TICKS_PER_SECOND / 1000000) |
| Calculate timer ticks based on microseconds.
|
|
#define | TIMER_MICROS_LL(tk) ((long long)(tk) * 1000000 / TICKS_PER_SECOND) |
| Calculate microseconds based on timer ticks.
|
|
|
typedef void(* | timer_callback1_t) (int ovfl) |
| Timer callback function without context.
|
|
typedef void(* | timer_callback2_t) (int ovfl, void *ctx) |
| Timer callback function with context.
|
|
Interface to the timer module in the MIPS r4300 processor.
The timer subsystem allows code to receive a callback after a specified number of ticks or microseconds. It interfaces with the MIPS coprocessor 0 to handle the timer interrupt and provide useful timing services.
Before attempting to use the timer subsystem, code should call timer_init. After the timer subsystem has been initialized, a new one-shot or continuous timer can be created with new_timer. To remove an expired one-shot timer or a recurring timer, use delete_timer. To temporarily stop a timer, use stop_timer. To restart a stopped timer or an expired one-shot timer, use start_timer. Once code no longer needs the timer subsystem, a call to timer_close will free all continuous timers and shut down the timer subsystem. Note that timers removed with stop_timer or expired one-short timers will not be removed automatically and are the responsibility of the calling code to be freed, regardless of a call to timer_close.
Because the MIPS internal counter wraps around after ~90 seconds (see TICKS_READ), it's not possible to schedule a timer more than 90 seconds in the future.
◆ timer_link_t
Data Fields |
uint32_t |
left |
Absolute ticks value at which the timer expires. |
uint32_t |
set |
Ticks to set if continuous. |
int |
ovfl |
To correct for drift. |
int |
flags |
Timer flags. See TF_ONE_SHOT, TF_CONTINUOUS, and TF_DISABLED. |
union timer_link_t.__unnamed42__ |
__unnamed__ |
Callback function to call when timer fires. |
void * |
ctx |
Callback context parameter. |
struct timer_link * |
next |
Link to next timer. |
◆ timer_link_t.__unnamed42__
union timer_link_t.__unnamed42__ |
Callback function to call when timer fires.
◆ TIMER_TICKS
Calculate timer ticks based on microseconds.
- Parameters
-
[in] | us | Microseconds to convert to ticks |
- Returns
- Timer ticks
◆ TIMER_MICROS
Calculate microseconds based on timer ticks.
- Parameters
-
[in] | tk | Ticks to convert to microseconds |
- Returns
- Microseconds
◆ TIMER_TICKS_LL
Calculate timer ticks based on microseconds.
- Parameters
-
[in] | us | Microseconds to convert to ticks |
- Returns
- Timer ticks as a long long
◆ TIMER_MICROS_LL
Calculate microseconds based on timer ticks.
- Parameters
-
[in] | tk | Ticks to convert to microseconds |
- Returns
- Microseconds as a long long