E_BOOL mg_RelayControl ( void   ) [static]

This function checks wether the motor relay can be enabled or must be disabled depending on safety conditions, motor load and pedelec settings. The function returns TRUE if the motor is enabled or FALSE if not.

Returns:
bRet (E_BOOL)
Return values:
TRUE,FALSE

Definition at line 301 of file ula_repl.c.

References COND_VOLT_ERR, current_GetValue(), FALSE, MAX_CURRENT, mg_bIsPedelec, mg_u16SpeedLimitMax, mg_u16SpeedLimitMin, pedal_GetTimeout(), PEDAL_TIMEOUT, relay_Enable(), safety_GetCondition(), SPEED_GET, and TRUE.

Referenced by main().

{
  E_BOOL bRet = TRUE;
  
  /* motor will be disabled if any error condition occours */
  if(safety_GetCondition() >= COND_VOLT_ERR)
  {
    bRet = FALSE;
  }
  /* motor will be disabled if momentary motor load is too high */
  else if(current_GetValue() >= MAX_CURRENT)
  {
    bRet = FALSE;
  }
  /* motor will be disabled if pedelec settings require it */
  else if (FALSE != mg_bIsPedelec)
  {
    if (SPEED_GET() < mg_u16SpeedLimitMin)
    {
      bRet = FALSE;
    }
    else
    {
      if(SPEED_GET() > mg_u16SpeedLimitMax)
      {
        bRet = FALSE;
      }
      else
      {
        if (pedal_GetTimeout() >= PEDAL_TIMEOUT)
        {
          bRet = FALSE;
        }
      }
    }
  }
  
  /* enable/disable motor relay */
  if(FALSE == bRet)
  {
    relay_Enable(FALSE);
  }
  else
  {
    relay_Enable(TRUE);
  }
  
  return (bRet);
} /* End: mg_RelayControl() */

Here is the call graph for this function:

Here is the caller graph for this function: