SimAVR
AVR Simulator
sim_cycle_timers.h
Go to the documentation of this file.
1 /*
2  * sim_cycle_timers.h
3  *
4  * Copyright 2008-2012 Michel Pollet <buserror@gmail.com>
5  *
6  * This file is part of simavr.
7  *
8  * simavr is free software: you can redistribute it and/or modify it under the terms of the GNU
9  * General Public License as published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * simavr is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
13  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
14  * Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along with simavr. If not, see
17  * <http://www.gnu.org/licenses/>.
18  */
19 
33 #ifndef __SIM_CYCLE_TIMERS_H___
34 #define __SIM_CYCLE_TIMERS_H___
35 
36 #include "sim_avr_types.h"
37 
38 #ifdef __cplusplus
39 extern "C"
40 {
41 #endif
42 
43 #define MAX_CYCLE_TIMERS 64
44 
46 
57  typedef struct avr_cycle_timer_slot_t
58  {
62  void *param;
64 
70  typedef struct avr_cycle_timer_pool_t
71  {
73  avr_cycle_timer_slot_p timer_free;
74  avr_cycle_timer_slot_p timer;
76 
78  void avr_cycle_timer_register (struct avr_t *avr, avr_cycle_count_t when, avr_cycle_timer_t timer, void *param);
80  void avr_cycle_timer_register_usec (struct avr_t *avr, uint32_t when, avr_cycle_timer_t timer, void *param);
82  void avr_cycle_timer_cancel (struct avr_t *avr, avr_cycle_timer_t timer, void *param);
87  avr_cycle_count_t avr_cycle_timer_status (struct avr_t *avr, avr_cycle_timer_t timer, void *param);
88 
89  //
90  // Private, called from the core
91  //
93  void avr_cycle_timer_reset (struct avr_t *avr);
94 
95 #ifdef __cplusplus
96 };
97 #endif
98 
99 #endif /* __SIM_CYCLE_TIMERS_H___ */
100 
avr_cycle_timer_slot_p timer_free
Definition: sim_cycle_timers.h:73
avr_cycle_count_t when
Definition: sim_cycle_timers.h:60
void avr_cycle_timer_cancel(struct avr_t *avr, avr_cycle_timer_t timer, void *param)
cancel a previously set timer
Definition: sim_cycle_timers.c:155
#define MAX_CYCLE_TIMERS
Definition: sim_cycle_timers.h:43
avr_cycle_timer_slot_p timer
Definition: sim_cycle_timers.h:74
void * param
Definition: sim_avr.h:234
avr_cycle_count_t(* avr_cycle_timer_t)(struct avr_t *avr, avr_cycle_count_t when, void *param)
Definition: sim_cycle_timers.h:45
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
Definition: sim_cycle_timers.c:132
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
Definition: sim_cycle_timers.c:149
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...
void * param
Definition: sim_cycle_timers.h:62
Each timer instance contains the absolute cycle number they are hoping to run at, a function pointer ...
Definition: sim_cycle_timers.h:57
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 ...
avr_t * avr
Definition: run_avr.c:54
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...
Definition: sim_cycle_timers.c:180
Timer pool contains a pool of timer slots available, they all start queued into the 'free' qeueue...
Definition: sim_cycle_timers.h:70
struct avr_cycle_timer_slot_t * next
Definition: sim_cycle_timers.h:59
uint64_t avr_cycle_count_t
Definition: sim_avr_types.h:36
avr_cycle_timer_t timer
Definition: sim_cycle_timers.h:61
avr_cycle_count_t avr_cycle_timer_process(struct avr_t *avr)
Definition: sim_cycle_timers.c:200
avr_cycle_timer_slot_t timer_slots[MAX_CYCLE_TIMERS]
Definition: sim_cycle_timers.h:72
struct avr_cycle_timer_pool_t * avr_cycle_timer_pool_p
Main AVR instance.
Definition: sim_avr.h:142
struct avr_cycle_timer_slot_t * avr_cycle_timer_slot_p
void avr_cycle_timer_reset(struct avr_t *avr)
Definition: sim_cycle_timers.c:53