src/timer.c
author frdupin
Wed, 13 Dec 2006 16:21:14 +0100
changeset 57 522ece4057d2
parent 48 adc6572caf5d
child 71 95cd3376cc9f
permissions -rwxr-xr-x
*** empty log message ***
38
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
     1
/*
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
     2
This file is part of CanFestival, a library implementing CanOpen Stack. 
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
     3
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
     4
Copyright (C): Edouard TISSERANT and Francis DUPIN
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
     5
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
     6
See COPYING file for copyrights details.
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
     7
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
     8
This library is free software; you can redistribute it and/or
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
     9
modify it under the terms of the GNU Lesser General Public
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    10
License as published by the Free Software Foundation; either
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    11
version 2.1 of the License, or (at your option) any later version.
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    12
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    13
This library is distributed in the hope that it will be useful,
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    14
but WITHOUT ANY WARRANTY; without even the implied warranty of
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    16
Lesser General Public License for more details.
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    17
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    18
You should have received a copy of the GNU Lesser General Public
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    19
License along with this library; if not, write to the Free Software
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    20
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    21
*/
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    22
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    23
//#define DEBUG_WAR_CONSOLE_ON
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    24
//#define DEBUG_ERR_CONSOLE_ON
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    25
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    26
#include <applicfg.h>
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    27
#include "timer.h"
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    28
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    29
// ---------  The timer table ---------
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    30
s_timer_entry timers[MAX_NB_TIMER] = {{TIMER_FREE, NULL, NULL, 0, 0, 0},};
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    31
//
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    32
TIMEVAL total_sleep_time = TIMEVAL_MAX;
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    33
TIMER_HANDLE last_timer_raw = -1;
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    34
48
adc6572caf5d minval/maxval macro operators precedence fix. Thanks Luis Jim?nez.
etisserant
parents: 38
diff changeset
    35
#define minval(a,b) ((a<b)?a:b)
38
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    36
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    37
// ---------  Use this to declare a new alarm ---------
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    38
TIMER_HANDLE SetAlarm(CO_Data* d, UNS32 id, TimerCallback_t callback, TIMEVAL value, TIMEVAL period)
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    39
{
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    40
	//printf("SetAlarm(UNS32 id=%d, TimerCallback_t callback=%x, TIMEVAL value=%d, TIMEVAL period=%d)\n", id, callback, value, period);
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    41
	TIMER_HANDLE i;
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    42
	TIMER_HANDLE row_number = TIMER_NONE;
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    43
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    44
	// in order to decide new timer setting we have to run over all timer rows
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    45
	for(i=0; i <= last_timer_raw + 1 && i < MAX_NB_TIMER; i++)
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    46
	{
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    47
		s_timer_entry *row = (timers+i);
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    48
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    49
		if (callback && 	// if something to store
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    50
		   row->state == TIMER_FREE) // and empty row
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    51
		{	// just store
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    52
			row->callback = callback;
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    53
			row->d = d;
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    54
			row->id = id;
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    55
			row->val = value;
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    56
			row->interval = period;
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    57
			row->state = TIMER_ARMED;
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    58
			row_number = i;
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    59
			break;
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    60
		}
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    61
	}
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    62
	
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    63
	if (row_number != TIMER_NONE) // if successfull
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    64
	{
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    65
		if (row_number == last_timer_raw + 1) last_timer_raw++;
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    66
		
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    67
		// set next wakeup alarm if new entry is sooner than others, or if it is alone
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    68
		TIMEVAL real_timer_value = minval(value, TIMEVAL_MAX);
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    69
		TIMEVAL elapsed_time = getElapsedTime();
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    70
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    71
		//printf("elapsed_time=%d real_timer_value=%d total_sleep_time=%d\n", elapsed_time, real_timer_value, total_sleep_time);
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    72
		if (total_sleep_time > elapsed_time && total_sleep_time - elapsed_time > real_timer_value)
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    73
		{
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    74
			total_sleep_time = elapsed_time + real_timer_value;
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    75
			setTimer(real_timer_value);
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    76
		}
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    77
		//printf("SetAlarm() return %d\n", row_number);
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    78
		return row_number;
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    79
	}
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    80
	return TIMER_NONE;
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    81
}
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    82
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    83
// ---------  Use this to remove an alarm ---------
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    84
TIMER_HANDLE DelAlarm(TIMER_HANDLE handle)
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    85
{
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    86
	// Quick and dirty. system timer will continue to be trigged, but no action will be preformed.
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    87
	MSG_WAR(0x3320, "DelAlarm. handle = ", handle);
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    88
	if(handle != TIMER_NONE)
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    89
	{
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    90
		if(handle == last_timer_raw) 
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    91
			last_timer_raw--;
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    92
		timers[handle].state = TIMER_FREE; 		
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    93
	}
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    94
	else {
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    95
	}
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    96
	return TIMER_NONE;
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    97
}
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    98
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
    99
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   100
// ---------  TimeDispatch is called on each timer expiration ---------
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   101
void TimeDispatch()
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   102
{
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   103
	TIMER_HANDLE i;
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   104
	TIMEVAL next_wakeup = TIMEVAL_MAX; // used to compute when should normaly occur next wakeup
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   105
	// First run : change timer state depending on time
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   106
	// Get time since timer signal
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   107
	TIMEVAL overrun = getElapsedTime();
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   108
	
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   109
	TIMEVAL real_total_sleep_time = total_sleep_time + overrun;
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   110
	//printf("total_sleep_time %d + overrun %d\n", total_sleep_time , overrun);
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   111
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   112
	for(i=0; i <= last_timer_raw; i++)
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   113
	{
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   114
		s_timer_entry *row = (timers+i);
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   115
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   116
		if (row->state & TIMER_ARMED) // if row is active
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   117
		{
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   118
			if (row->val <= real_total_sleep_time) // to be trigged
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   119
			{
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   120
				//printf("row->val(%d) <= (%d)real_total_sleep_time\n", row->val, real_total_sleep_time);
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   121
				if (!row->interval) // if simply outdated
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   122
				{
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   123
					row->state = TIMER_TRIG; // ask for trig
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   124
				}
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   125
				else // or period have expired
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   126
				{
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   127
					// set val as interval, with overrun correction
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   128
					row->val = row->interval - (overrun % row->interval);
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   129
					row->state = TIMER_TRIG_PERIOD; // ask for trig, periodic
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   130
					// Check if this new timer value is the soonest
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   131
					next_wakeup = minval(row->val,next_wakeup);
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   132
				}
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   133
			}
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   134
			else
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   135
			{
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   136
				// Each armed timer value in decremented.
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   137
				row->val -= real_total_sleep_time;
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   138
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   139
				// Check if this new timer value is the soonest
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   140
				next_wakeup = minval(row->val,next_wakeup);
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   141
			}
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   142
		}
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   143
	}
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   144
	
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   145
	// Remember how much time we should sleep.
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   146
	total_sleep_time = next_wakeup;
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   147
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   148
	// Set timer to soonest occurence
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   149
	setTimer(next_wakeup);
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   150
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   151
	// Then trig them or not.
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   152
	for(i=0; i<=last_timer_raw; i++)
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   153
	{
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   154
		s_timer_entry *row = (timers+i);
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   155
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   156
		if (row->state & TIMER_TRIG)
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   157
		{
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   158
			row->state &= ~TIMER_TRIG; // reset trig state (will be free if not periodic)
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   159
			(*row->callback)(row->d, row->id); // trig !
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   160
		}
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   161
	}
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   162
}
9b5bb1dcb4f5 Cygwin port. Still untested. Compiles and link.
etisserant
parents: 0
diff changeset
   163