# HG changeset patch # User greg # Date 1248080231 -7200 # Node ID b4bc22764a391cb683ed1ae9fb53c173240b257d # Parent 18db803e593f42a6362ec2477fffbd51a1e6be0b fix error in timer.c diff -r 18db803e593f -r b4bc22764a39 src/timer.c --- a/src/timer.c Mon Jul 20 10:56:08 2009 +0200 +++ b/src/timer.c Mon Jul 20 10:57:11 2009 +0200 @@ -1,5 +1,5 @@ /* -This file is part of CanFestival, a library implementing CanOpen Stack. +This file is part of CanFestival, a library implementing CanOpen Stack. Copyright (C): Edouard TISSERANT and Francis DUPIN @@ -43,17 +43,17 @@ #define min_val(a,b) ((a elapsed_time ? value - elapsed_time : 0; + real_timer_value = value; real_timer_value = min_val(real_timer_value, TIMEVAL_MAX); - + if (total_sleep_time > elapsed_time && total_sleep_time - elapsed_time > real_timer_value) { total_sleep_time = elapsed_time + real_timer_value; @@ -89,35 +89,35 @@ return row_number; } } - + return TIMER_NONE; } -/*! -** ----- Use this to remove an alarm ---- -** -** @param handle -** -** @return -**/ +/*! +** ----- Use this to remove an alarm ---- +** +** @param handle +** +** @return +**/ TIMER_HANDLE DelAlarm(TIMER_HANDLE handle) { /* Quick and dirty. system timer will continue to be trigged, but no action will be preformed. */ MSG_WAR(0x3320, "DelAlarm. handle = ", handle); if(handle != TIMER_NONE) { - if(handle == last_timer_raw) + if(handle == last_timer_raw) last_timer_raw--; - timers[handle].state = TIMER_FREE; + timers[handle].state = TIMER_FREE; } return TIMER_NONE; } -/*! -** ------ TimeDispatch is called on each timer expiration ---- -** +/*! +** ------ TimeDispatch is called on each timer expiration ---- +** **/ -int tdcount=0; +int tdcount=0; void TimeDispatch(void) { TIMER_HANDLE i; @@ -125,7 +125,7 @@ /* First run : change timer state depending on time */ /* Get time since timer signal */ TIMEVAL overrun = getElapsedTime(); - + TIMEVAL real_total_sleep_time = total_sleep_time + overrun; s_timer_entry *row; @@ -147,7 +147,7 @@ row->state = TIMER_TRIG_PERIOD; /* ask for trig, periodic */ /* Check if this new timer value is the soonest */ if(row->val < next_wakeup) - next_wakeup = row->val; + next_wakeup = row->val; } } else @@ -157,11 +157,11 @@ /* Check if this new timer value is the soonest */ if(row->val < next_wakeup) - next_wakeup = row->val; + next_wakeup = row->val; } } } - + /* Remember how much time we should sleep. */ total_sleep_time = next_wakeup;