Beispiel #1
0
/**
  * @brief  Configure COMP1 and COMP2 with interrupt
  * @param  None
  * @retval None
  */
static void COMP_Config(void)
{
 
  /*##-1- Configure the COMPx peripheral ###################################*/
  /* COMP1 Init: the higher threshold is set to VREFINT ~ 1.22V
     but can be changed to other available possibilities */
  Comp1Handle.Instance                = COMP1;

  Comp1Handle.Init.InvertingInput     = COMP_INVERTINGINPUT_VREFINT;
  Comp1Handle.Init.Output             = COMP_OUTPUT_NONE;
  Comp1Handle.Init.OutputPol          = COMP_OUTPUTPOL_NONINVERTED;
  Comp1Handle.Init.Hysteresis         = COMP_HYSTERESIS_HIGH;
  Comp1Handle.Init.Mode               = COMP_MODE_LOWPOWER;
  Comp1Handle.Init.WindowMode         = COMP_WINDOWMODE_DISABLE;
  Comp1Handle.Init.TriggerMode        = COMP_TRIGGERMODE_IT_RISING_FALLING;
  if(HAL_COMP_Init(&Comp1Handle) != HAL_OK)
  {
    /* Initialization Error */
    Error_Handler(); 
  }
  
  
  /* COMP2 Init: the lower threshold is set to VREFINT/4 ~ 1.22 / 4 ~ 0.305 V 
     but can be changed to other available possibilities */
  Comp2Handle.Instance                = COMP2;

  Comp2Handle.Init.InvertingInput     = COMP_INVERTINGINPUT_1_4VREFINT;
  Comp2Handle.Init.Output             = COMP_OUTPUT_NONE;
  Comp2Handle.Init.OutputPol          = COMP_OUTPUTPOL_NONINVERTED;
  Comp2Handle.Init.Hysteresis         = COMP_HYSTERESIS_HIGH;
  Comp2Handle.Init.Mode               = COMP_MODE_LOWPOWER;
  Comp2Handle.Init.WindowMode         = COMP_WINDOWMODE_ENABLE;
  Comp2Handle.Init.TriggerMode        = COMP_TRIGGERMODE_IT_RISING_FALLING;
  if(HAL_COMP_Init(&Comp2Handle) != HAL_OK)
  {
    /* Initialization Error */
    Error_Handler(); 
  }
  

  /* Start COMP1 */
  if(HAL_COMP_Start_IT(&Comp1Handle) != HAL_OK)
  {
    /* Initialization Error */
    Error_Handler(); 
  }
  
  /* Start COMP2 */
  if(HAL_COMP_Start_IT(&Comp2Handle) != HAL_OK)
  {
    /* Initialization Error */
    Error_Handler(); 
  } 
}
Beispiel #2
0
static void COMP_Config(void)
{
  /*##-1- Configure the COMP peripheral ######################################*/  
  hcomp1.Instance = COMP1;
  
  hcomp1.Init.InvertingInput  = COMP_INVERTINGINPUT_VREFINT;
  hcomp1.Init.Output          = COMP_OUTPUT_NONE;
  hcomp1.Init.OutputPol       = COMP_OUTPUTPOL_NONINVERTED;
  hcomp1.Init.Mode            = COMP_MODE_LOWPOWER;
  hcomp1.Init.Hysteresis      = COMP_HYSTERESIS_NONE;
  hcomp1.Init.WindowMode      = COMP_WINDOWMODE_DISABLED;
  hcomp1.Init.TriggerMode     = COMP_TRIGGERMODE_IT_RISING_FALLING;

  if(HAL_COMP_Init(&hcomp1) != HAL_OK)
  {
    /* Initialization Error */
    Error_Handler();
  }

  /*##-2- Start teh COMP1 and enable the interrupt ###########################*/  
  if(HAL_COMP_Start_IT(&hcomp1) != HAL_OK)
  {
    /* Initialization Error */
    Error_Handler();
  }
}
Beispiel #3
0
/**
  * @brief  Configures Comparator
  * @param  None
  * @retval None
  */
static void COMP_Config(void)
{
  /*##-1- Configure the COMP peripheral ######################################*/  
  hcomp1.Instance = COMP1;
  
  hcomp1.Init.InvertingInput    = COMP_INVERTINGINPUT_DAC1;
  hcomp1.Init.NonInvertingInput = COMP_NONINVERTINGINPUT_IO1;
  hcomp1.Init.OutputPol         = COMP_OUTPUTPOL_NONINVERTED;
  hcomp1.Init.Mode              = COMP_MODE_HIGHSPEED;
  hcomp1.Init.WindowMode        = COMP_WINDOWMODE_DISABLED;
  hcomp1.Init.TriggerMode       = COMP_TRIGGERMODE_IT_RISING_FALLING;

  if(HAL_COMP_Init(&hcomp1) != HAL_OK)
  {
    /* Error */
    ErrorHandler();
  }
  
  /*##-2- Start teh COMP1 and enable the interrupt ###########################*/  
  if(HAL_COMP_Start(&hcomp1) != HAL_OK)
  {
    /* Error */
    ErrorHandler();
  }
}
Beispiel #4
0
/* COMP1 init function */
void MX_COMP1_Init(void)
{

  hcomp1.Instance = COMP1;
  hcomp1.Init.InvertingInput = COMP_INVERTINGINPUT_1_4VREFINT;//DAC1;
  hcomp1.Init.NonInvertingInput = COMP_NONINVERTINGINPUT_IO1;
  hcomp1.Init.LPTIMConnection = COMP_LPTIMCONNECTION_DISABLED;
  hcomp1.Init.OutputPol = COMP_OUTPUTPOL_NONINVERTED;
  hcomp1.Init.Mode = COMP_MODE_LOWSPEED;
  hcomp1.Init.WindowMode = COMP_WINDOWMODE_DISABLED;
  hcomp1.Init.TriggerMode = COMP_TRIGGERMODE_IT_RISING_FALLING; //  IT_RISING;
  HAL_COMP_Init(&hcomp1);

}
Beispiel #5
0
/**
  * @brief  Configure COMPx
  * @param  None
  * @retval None
  */
static void COMPx_Config(void)
{
  /*##-1- Configure the COMPx peripheral ###################################*/
  /* COMPx Init: Inverted Pin is connected to DACx */
  /* Non-inverted pin is connected to Humidity Sensor */
  CompxHandle.Instance = COMPx;

  CompxHandle.Init.InvertingInput = COMP_INVERTINGINPUT_DACx;
  CompxHandle.Init.NonInvertingInput = COMP_NONINVERTINGINPUT_IO1;
  CompxHandle.Init.Output = COMP_OUTPUT_TIM4IC2;
  CompxHandle.Init.OutputPol = COMP_OUTPUTPOL_NONINVERTED;
  CompxHandle.Init.Hysteresis = COMP_HYSTERESIS_NONE;
  CompxHandle.Init.BlankingSrce = COMP_BLANKINGSRCE_NONE;
  CompxHandle.Init.WindowMode = COMP_WINDOWMODE_DISABLED;
  CompxHandle.Init.TriggerMode = COMP_TRIGGERMODE_NONE;
  HAL_COMP_Init(&CompxHandle);

  /*##-2- Start the comparator process #####################################*/ 
  /* Enable COMPx */
  HAL_COMP_Start(&CompxHandle);
}
Beispiel #6
0
/**
  * @brief  Configure COMPx
  * @param  None
  * @retval None
  */
static void COMPx_Config(void)
{
 
  /*##-1- Configure the COMPx peripheral ###################################*/
  /* COMPx init: COMPx Output is connected to GPIO only (not redirected     */
  /* to timers) and output blanking source is connected to                  */
  /* TIM1 OC5.                                              */
  CompxHandle.Instance = COMPx;

  CompxHandle.Init.InvertingInput    = COMP_INVERTINGINPUT_VREFINT;
  CompxHandle.Init.NonInvertingInput = COMP_NONINVERTINGINPUT_IO1;
  CompxHandle.Init.Output            = COMP_OUTPUT_NONE;
  CompxHandle.Init.OutputPol         = COMP_OUTPUTPOL_NONINVERTED;
  CompxHandle.Init.BlankingSrce      = COMP_BLANKINGSRCE_TIM1OC5;
  CompxHandle.Init.WindowMode        = COMP_WINDOWMODE_DISABLE;
  CompxHandle.Init.TriggerMode       = COMP_TRIGGERMODE_NONE;
  HAL_COMP_Init(&CompxHandle);

  /*##-2- Start the comparator process #####################################*/ 
  /* Enable COMPx: the higher threshold is set to VREFINT ~ 1.22 V */
  HAL_COMP_Start(&CompxHandle);
}