SimAVR
AVR Simulator
Cycle Timers

Cycle timers are callbacks that will be called when "when" cycle is reached these timers are one shots, then get cleared if the timer function returns zero, they get reset if the callback function returns a new cycle number. More...

Data Structures

struct  avr_cycle_timer_slot_t
 Each timer instance contains the absolute cycle number they are hoping to run at, a function pointer to call and a parameter. More...
 
struct  avr_cycle_timer_pool_t
 Timer pool contains a pool of timer slots available, they all start queued into the 'free' qeueue, are migrated to the 'active' queue when needed and are re-queued to the free one when done. More...
 

Macros

#define MAX_CYCLE_TIMERS   64
 

Typedefs

typedef avr_cycle_count_t(* avr_cycle_timer_t) (struct avr_t *avr, avr_cycle_count_t when, void *param)
 
typedef struct avr_cycle_timer_slot_t avr_cycle_timer_slot_t
 Each timer instance contains the absolute cycle number they are hoping to run at, a function pointer to call and a parameter. More...
 
typedef struct avr_cycle_timer_slot_tavr_cycle_timer_slot_p
 
typedef struct avr_cycle_timer_pool_t avr_cycle_timer_pool_t
 Timer pool contains a pool of timer slots available, they all start queued into the 'free' qeueue, are migrated to the 'active' queue when needed and are re-queued to the free one when done. More...
 
typedef struct avr_cycle_timer_pool_tavr_cycle_timer_pool_p
 

Functions

void avr_cycle_timer_register (struct avr_t *avr, avr_cycle_count_t when, avr_cycle_timer_t timer, void *param)
 register for calling 'timer' in 'when' cycles More...
 
void avr_cycle_timer_register_usec (struct avr_t *avr, uint32_t when, avr_cycle_timer_t timer, void *param)
 register a timer to call in 'when' usec More...
 
void avr_cycle_timer_cancel (struct avr_t *avr, avr_cycle_timer_t timer, void *param)
 cancel a previously set timer More...
 
avr_cycle_count_t avr_cycle_timer_status (struct avr_t *avr, avr_cycle_timer_t timer, void *param)
 Check to see if a timer is present, if so, return the number (+1) of cycles left for it to fire, and if not present, return zero. More...
 
avr_cycle_count_t avr_cycle_timer_process (struct avr_t *avr)
 
void avr_cycle_timer_reset (struct avr_t *avr)
 

Detailed Description

Cycle timers are callbacks that will be called when "when" cycle is reached these timers are one shots, then get cleared if the timer function returns zero, they get reset if the callback function returns a new cycle number.

The implementation maintains a list of 'pending' timers, sorted by when they should run, it allows very quick comparison with the next timer to run, and quick removal of then from the pile once dispatched.

Macro Definition Documentation

#define MAX_CYCLE_TIMERS   64

Typedef Documentation

Timer pool contains a pool of timer slots available, they all start queued into the 'free' qeueue, are migrated to the 'active' queue when needed and are re-queued to the free one when done.

Each timer instance contains the absolute cycle number they are hoping to run at, a function pointer to call and a parameter.

it will NEVER be the exact cycle specified, as each instruction is not divisible and might take 2 or more cycles anyway.

However if there was a LOT of cycle lag, the timer migth be called repeteadly until it 'caches up'.

typedef avr_cycle_count_t(* avr_cycle_timer_t) (struct avr_t *avr, avr_cycle_count_t when, void *param)

Function Documentation

void avr_cycle_timer_cancel ( struct avr_t avr,
avr_cycle_timer_t  timer,
void *  param 
)

cancel a previously set timer

Here is the call graph for this function:

Here is the caller graph for this function:

avr_cycle_count_t avr_cycle_timer_process ( struct avr_t avr)

Here is the call graph for this function:

Here is the caller graph for this function:

void avr_cycle_timer_register ( struct avr_t avr,
avr_cycle_count_t  when,
avr_cycle_timer_t  timer,
void *  param 
)

register for calling 'timer' in 'when' cycles

Here is the call graph for this function:

Here is the caller graph for this function:

void avr_cycle_timer_register_usec ( struct avr_t avr,
uint32_t  when,
avr_cycle_timer_t  timer,
void *  param 
)

register a timer to call in 'when' usec

Here is the call graph for this function:

Here is the caller graph for this function:

void avr_cycle_timer_reset ( struct avr_t avr)

Here is the caller graph for this function:

avr_cycle_count_t avr_cycle_timer_status ( struct avr_t avr,
avr_cycle_timer_t  timer,
void *  param 
)

Check to see if a timer is present, if so, return the number (+1) of cycles left for it to fire, and if not present, return zero.

Here is the caller graph for this function: