/**
  * @brief  Enables or disables the ADC1 interrupts.
  * @param  ADC_IT: specifies the ADC interrupts sources to be enabled or disabled.
  *         This parameter can be any combination of the following values:
  *           @arg ADC1_IT_OUT_OF_RANGE:        the ADC1 measured value is out of range;
  *           @arg ADC1_IT_END_OF_CONVERSION:   the ADC1 conversion finished;
  * @param  NewState: new state of the ADC interrupts.
  *         This parameter can be: ENABLE or DISABLE.
  * @retval None
  */
void ADC_ITConfig(uint32_t ADC_IT, FunctionalState NewState)
{
  uint32_t tmpreg_ADC1_IE;
  uint32_t tmpreg_ADC_IT;

  /* Check the parameters */
  assert_param(IS_ADC_CONFIG_IT(ADC_IT));
  assert_param(IS_FUNCTIONAL_STATE(NewState));

  tmpreg_ADC1_IE = MDR_ADC->ADC1_STATUS;
  tmpreg_ADC_IT = ADC_IT << 2;

  /* Form new value */
  if (NewState != DISABLE)
  {
    /* Enable the ADC Interrupt requests by setting bits in the ADCx_STATUS registers */
    tmpreg_ADC1_IE |= tmpreg_ADC_IT & 0xFFFF;
  }
  else
  {
    /* Disable the ADC Interrupt requests by clearing bits in the ADCx_STATUS registers */
    tmpreg_ADC1_IE &= ~(tmpreg_ADC_IT & 0xFFFF);
  }

  /* Configure ADCx_STATUS registers with new value */
  MDR_ADC->ADC1_STATUS = tmpreg_ADC1_IE;

}
Example #2
0
/**
  * @brief  Enables or disables the specified ADC interrupts.
  * @param  ADCx: where x can be 1 to select the ADC peripheral.
  * @param  ADC_IT: specifies the ADC interrupt sources to be enabled or disabled.
  *   This parameter can be one of the following values:
  *     @arg ADC_IT_ADRDY: ADC ready interrupt
  *     @arg ADC_IT_EOSMP: End of sampling interrupt
  *     @arg ADC_IT_EOC: End of conversion interrupt
  *     @arg ADC_IT_EOSEQ: End of sequence of conversion interrupt
  *     @arg ADC_IT_OVR: overrun interrupt
  *     @arg ADC_IT_AWD: Analog watchdog interrupt
  * @param  NewState: new state of the specified ADC interrupts.
  *         This parameter can be: ENABLE or DISABLE.
  * @retval None
  */
void ADC_ITConfig(ADC_TypeDef* ADCx, uint32_t ADC_IT, FunctionalState NewState)
{
    /* Check the parameters */
    assert_param(IS_ADC_ALL_PERIPH(ADCx));
    assert_param(IS_FUNCTIONAL_STATE(NewState));
    assert_param(IS_ADC_CONFIG_IT(ADC_IT));

    if (NewState != DISABLE) {
        /* Enable the selected ADC interrupts */
        ADCx->IER |= ADC_IT;
    } else {
        /* Disable the selected ADC interrupts */
        ADCx->IER &= (~(uint32_t)ADC_IT);
    }
}
/**
  * @brief  Checks whether the ADC1 interrupt has occurred or not.
  * @param  ADC_IT: specifies the ADC interrupt source to check.
  *         This parameter can be one of the following values:
  *           @arg ADC1_IT_OUT_OF_RANGE:        the ADC1 measured value is out of range;
  *           @arg ADC1_IT_END_OF_CONVERSION:   the ADC1 conversion finished;
  * @retval The new state of the ADC_IT (SET or RESET).
  */
ITStatus ADC_GetITStatus(uint32_t ADC_IT)
{
  ITStatus bitstatus;
  uint32_t tmpreg;

  /* Check the parameters */
  assert_param(IS_ADC_CONFIG_IT(ADC_IT));

  tmpreg = ADC_GetStatus();
  tmpreg &= (tmpreg >> 2) & ADC_IT;

  if (tmpreg == 0)
  {
    bitstatus = RESET;
  }
  else
  {
    bitstatus = SET;
  }

  return bitstatus;
}