/**
  * @brief  Checks whether the specified ADC flag is set or not.
  * @param  ADCx: where x can be 1 to select the ADC1 peripheral.
  * @param  ADC_FLAG: specifies the flag to check.
  *          This parameter can be one of the following values:
  *            @arg ADC_FLAG_AWD: Analog watchdog flag
  *            @arg ADC_FLAG_OVR: Overrun flag
  *            @arg ADC_FLAG_EOSEQ: End of Sequence flag
  *            @arg ADC_FLAG_EOC: End of conversion flag
  *            @arg ADC_FLAG_EOSMP: End of sampling flag
  *            @arg ADC_FLAG_ADRDY: ADC Ready flag
  *            @arg ADC_FLAG_ADEN: ADC enable flag
  *            @arg ADC_FLAG_ADDIS: ADC disable flag
  *            @arg ADC_FLAG_ADSTART: ADC start flag
  *            @arg ADC_FLAG_ADSTP: ADC stop flag
  *            @arg ADC_FLAG_ADCAL: ADC Calibration flag
  * @retval The new state of ADC_FLAG (SET or RESET).
  */
FlagStatus ADC_GetFlagStatus(ADC_TypeDef* ADCx, uint32_t ADC_FLAG)
{
    FlagStatus bitstatus = RESET;
    uint32_t tmpreg = 0;

    /* Check the parameters */
    assert_param(IS_ADC_ALL_PERIPH(ADCx));
    assert_param(IS_ADC_GET_FLAG(ADC_FLAG));

    if((uint32_t)(ADC_FLAG & 0x01000000))
    {
        tmpreg = ADCx->CR & 0xFEFFFFFF;
    }
    else
    {
        tmpreg = ADCx->ISR;
    }

    /* Check the status of the specified ADC flag */
    if ((tmpreg & ADC_FLAG) != (uint32_t)RESET)
    {
        /* ADC_FLAG is set */
        bitstatus = SET;
    }
    else
    {
        /* ADC_FLAG is reset */
        bitstatus = RESET;
    }
    /* Return the ADC_FLAG status */
    return  bitstatus;
}
示例#2
0
/**
  * @brief  Checks whether the specified ADC flag is set or not.
  * @param  ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
  * @param  ADC_FLAG: specifies the flag to check.
  *   This parameter can be one of the following values:
  *     @arg ADC_FLAG_AWD: Analog watchdog flag
  *     @arg ADC_FLAG_EOC: End of conversion flag
  *     @arg ADC_FLAG_JEOC: End of injected group conversion flag
  *     @arg ADC_FLAG_JSTRT: Start of injected group conversion flag
  *     @arg ADC_FLAG_STRT: Start of regular group conversion flag
  * @retval The new state of ADC_FLAG (SET or RESET).
  */
FlagStatus ADC_GetFlagStatus(ADC_TypeDef* ADCx, uint8_t ADC_FLAG)
{
  FlagStatus bitstatus = RESET;
  /* Check the parameters */
  assert_param(IS_ADC_ALL_PERIPH(ADCx));
  assert_param(IS_ADC_GET_FLAG(ADC_FLAG));
  /* Check the status of the specified ADC flag */
  if ((ADCx->SR & ADC_FLAG) != (uint8_t)RESET)
  {
    /* ADC_FLAG is set */
    bitstatus = SET;
  }
  else
  {
    /* ADC_FLAG is reset */
    bitstatus = RESET;
  }
  /* Return the ADC_FLAG status */
  return  bitstatus;
}
示例#3
0
/*******************************************************************************
* 函数名称: ADC_GetFlagStatus
* 功能描述: 检查指定的ADC标志是否置位.
* 输入参数: (1)ADCx:其中x可以是1、2或3,用来选择ADC外围模块.
*           (2)ADC_FLAG:指定需要检查的标志。
*                    给出了ADC_FLAG 的取值:
*                       - ADC_FLAG_AWD: 模拟看门狗标志
*                       - ADC_FLAG_EOC: 转换结束标志
*                       - ADC_FLAG_JEOC: 注入组转换结束标志
*                       - ADC_FLAG_JSTRT: 注入组转换开始标志
*                       - ADC_FLAG_STRT: 常规组转换开始标志
* 输出参数: 无
* 返回参数: ADC_FLAG的新状态(SET或RESET).
*******************************************************************************/
FlagStatus ADC_GetFlagStatus(ADC_TypeDef* ADCx, u8 ADC_FLAG)
{
  FlagStatus bitstatus = RESET;

  /* Check the parameters [检查参数] */
  assert_param(IS_ADC_ALL_PERIPH(ADCx));
  assert_param(IS_ADC_GET_FLAG(ADC_FLAG));

  /* Check the status of the specified ADC flag [检查指定ADC状态位]*/
  if ((ADCx->SR & ADC_FLAG) != (u8)RESET)
  {
    /* ADC_FLAG is set [置位ADC_FLAG]*/
    bitstatus = SET;
  }
  else
  {
    /* ADC_FLAG is reset [复位ADC_FLAG]*/
    bitstatus = RESET;
  }

  /* Return the ADC_FLAG status [返回状态位ADC_FLAG]*/
  return  bitstatus;
}