UINT32 pedal_GetTimeout ( void   )

When no more pedal revolutions occur, the value mg_u32Rpm would stay as it is. To prevent from this behaviour, this function should be called at regular intervals. It will read the current system time (see timer_GetSystemTime()) and compare it with the last timestamp in mg_u32TickTime. If the difference between both values exeeds PEDAL_TIMEOUT, the value for mg_u32Rpm will be reset to 0.

The time difference between now and mg_u32TickTime will be returned.

See also:
timer_GetSystemTime
Returns:
Time difference between now and mg_u32TickTime (in ms)
Return values:
UINT32

Definition at line 170 of file pedal.c.

References mg_u32Rpm, mg_u32TickTime, PEDAL_TIMEOUT, and timer_GetSystemTime().

Referenced by main(), and mg_RelayControl().

{
  UINT32 u32SysTime;
  UINT32 u32TickTime;
  UINT32 u32Ret;
  
  u32SysTime = timer_GetSystemTime();
  asm("nop");
  cli();
  u32TickTime = mg_u32TickTime;
  sei();
  
  u32Ret = u32SysTime - u32TickTime;
  if(u32Ret > PEDAL_TIMEOUT)
  {
    mg_u32Rpm = 0UL;
    u32Ret = PEDAL_TIMEOUT;
  }
  
  return(u32Ret);
}

Here is the call graph for this function:

Here is the caller graph for this function: