Moved PIT to common timer API.
This commit is contained in:
parent
f1e1cc0b25
commit
b0320ae16c
6 changed files with 87 additions and 59 deletions
38
src/timer.c
38
src/timer.c
|
|
@ -25,26 +25,35 @@ int timers_present = 0;
|
|||
int timer_one = 1;
|
||||
|
||||
int timer_count = 0, timer_latch = 0;
|
||||
int timer_start = 0;
|
||||
|
||||
void timer_process()
|
||||
{
|
||||
int c;
|
||||
|
||||
int retry;
|
||||
/*Get actual elapsed time*/
|
||||
timer_latch -= timer_count;
|
||||
int diff = timer_latch - timer_count;
|
||||
|
||||
for (c = 0; c < timers_present; c++)
|
||||
{
|
||||
// pclog("timer_process : %i enable %i %X\n", c, timers[c].enable, *timers[c].enable);
|
||||
if (*timers[c].enable)
|
||||
{
|
||||
*timers[c].count = *timers[c].count - (timer_latch << TIMER_SHIFT);
|
||||
if (*timers[c].count <= 0)
|
||||
{
|
||||
timers[c].callback(timers[c].priv);
|
||||
|
||||
timer_latch = 0;
|
||||
|
||||
do
|
||||
{
|
||||
retry = 0;
|
||||
for (c = 0; c < timers_present; c++)
|
||||
{
|
||||
if (*timers[c].enable)
|
||||
{
|
||||
*timers[c].count = *timers[c].count - (diff << TIMER_SHIFT);
|
||||
if (*timers[c].count <= 0)
|
||||
timers[c].callback(timers[c].priv);
|
||||
if (*timers[c].count <= 0)
|
||||
retry = 1;
|
||||
}
|
||||
}
|
||||
diff = 0;
|
||||
}
|
||||
while (retry);
|
||||
}
|
||||
|
||||
void timer_update_outstanding()
|
||||
|
|
@ -56,11 +65,6 @@ void timer_update_outstanding()
|
|||
if (*timers[c].enable && *timers[c].count < timer_latch)
|
||||
timer_latch = *timers[c].count;
|
||||
}
|
||||
if (spktime < timer_latch) timer_latch = spktime;
|
||||
//if (soundtime < timer_latch) timer_latch = soundtime;
|
||||
//if (gustime < timer_latch) timer_latch = gustime;
|
||||
//if (gustime2 < timer_latch) timer_latch = gustime2;
|
||||
//if (vidtime < timer_latch) timer_latch = vidtime;
|
||||
timer_count = timer_latch = (timer_latch + ((1 << TIMER_SHIFT) - 1)) >> TIMER_SHIFT;
|
||||
}
|
||||
|
||||
|
|
@ -76,7 +80,7 @@ int timer_add(void (*callback)(void *priv), int *count, int *enable, void *priv)
|
|||
{
|
||||
if (timers_present < TIMERS_MAX)
|
||||
{
|
||||
pclog("timer_add : adding timer %i\n", timers_present);
|
||||
// pclog("timer_add : adding timer %i\n", timers_present);
|
||||
timers[timers_present].present = 1;
|
||||
timers[timers_present].callback = callback;
|
||||
timers[timers_present].priv = priv;
|
||||
|
|
|
|||
Loading…
Reference in a new issue