void speed_Init ( void   )

This function initiates the variables for timestamp, tacho RMP and trip distance and configures the tacho interrupt.

See also:
mg_u32TickTime
mg_u32Rpm
mg_u32Distance
Returns:
void

Definition at line 163 of file speed.c.

References INT0_BIT, INT0_DDR, memory_Get(), mg_u16WheelSize, mg_u32Distance, mg_u32Rpm, mg_u32TickTime, mg_u8NumMagnetsTacho, SPEED_INT_ENABLE, S_MEM_STRUCTRUE::u16WheelSize, and S_MEM_STRUCTRUE::u8NumMagnetsTacho.

Referenced by init_InitModules().

{
  mg_u8NumMagnetsTacho  = memory_Get()->u8NumMagnetsTacho;
  if(0U == mg_u8NumMagnetsTacho)
  {
    mg_u8NumMagnetsTacho = 1U;  // to avoid division by 0
  }
  
  INT0_DDR  &= ~(1U << INT0_BIT);   /* set ext. interrupt pin as input pin */
  
  /* the effective wheel size is the actual wheel size divided by the number of
     magnets */
  mg_u16WheelSize = ( memory_Get()->u16WheelSize / mg_u8NumMagnetsTacho );
  
  /* setup for falling edge */
  EICRA |=  (1<<ISC01);
  EICRA &= ~(1<<ISC00);
  
  mg_u32TickTime  = 0U;
  mg_u32Rpm       = 0U;
  mg_u32Distance  = 0U;
  
  /* enable interrupt */
  SPEED_INT_ENABLE();
}

Here is the call graph for this function:

Here is the caller graph for this function: