当前位置: 首页>>代码示例>>C++>>正文


C++ IS_ADC_CHANNEL函数代码示例

本文整理汇总了C++中IS_ADC_CHANNEL函数的典型用法代码示例。如果您正苦于以下问题:C++ IS_ADC_CHANNEL函数的具体用法?C++ IS_ADC_CHANNEL怎么用?C++ IS_ADC_CHANNEL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了IS_ADC_CHANNEL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: is_adcx_channel

STATIC bool is_adcx_channel(int channel) {
#if defined(STM32F4) || defined(STM32F7)
    return IS_ADC_CHANNEL(channel);
#elif defined(STM32L4)
    ADC_HandleTypeDef handle;
    handle.Instance = ADCx;
    return IS_ADC_CHANNEL(&handle, channel);
#else
    #error Unsupported processor
#endif
}
开发者ID:c-goosen,项目名称:micropython,代码行数:11,代码来源:adc.c

示例2: is_adcx_channel

STATIC bool is_adcx_channel(int channel) {
#if defined(STM32F411xE)
    // The HAL has an incorrect IS_ADC_CHANNEL macro for the F411 so we check for temp
    return IS_ADC_CHANNEL(channel) || channel == ADC_CHANNEL_TEMPSENSOR;
#elif defined(STM32F0) || defined(STM32F4) || defined(STM32F7) || defined(STM32H7)
    return IS_ADC_CHANNEL(channel);
#elif defined(STM32L4)
    ADC_HandleTypeDef handle;
    handle.Instance = ADCx;
    return IS_ADC_CHANNEL(&handle, channel);
#else
    #error Unsupported processor
#endif
}
开发者ID:DanielO,项目名称:micropython,代码行数:14,代码来源:adc.c

示例3: adc_init_single

STATIC void adc_init_single(pyb_obj_adc_t *adc_obj) {
    if (!IS_ADC_CHANNEL(adc_obj->channel)) {
        return;
    }

    if (adc_obj->channel < ADC_NUM_GPIO_CHANNELS) {
      // Channels 0-16 correspond to real pins. Configure the GPIO pin in
      // ADC mode.
      const pin_obj_t *pin = pin_adc1[adc_obj->channel];
      GPIO_InitTypeDef GPIO_InitStructure;
      GPIO_InitStructure.Pin = pin->pin_mask;
      GPIO_InitStructure.Mode = GPIO_MODE_ANALOG;
      GPIO_InitStructure.Pull = GPIO_NOPULL;
      HAL_GPIO_Init(pin->gpio, &GPIO_InitStructure);
    }

    ADCx_CLK_ENABLE();

    ADC_HandleTypeDef *adcHandle = &adc_obj->handle;
    adcHandle->Instance                   = ADCx;
    adcHandle->Init.ClockPrescaler        = ADC_CLOCKPRESCALER_PCLK_DIV2;
    adcHandle->Init.Resolution            = ADC_RESOLUTION12b;
    adcHandle->Init.ScanConvMode          = DISABLE;
    adcHandle->Init.ContinuousConvMode    = DISABLE;
    adcHandle->Init.DiscontinuousConvMode = DISABLE;
    adcHandle->Init.NbrOfDiscConversion   = 0;
    adcHandle->Init.ExternalTrigConvEdge  = ADC_EXTERNALTRIGCONVEDGE_NONE;
    adcHandle->Init.ExternalTrigConv      = ADC_EXTERNALTRIGCONV_T1_CC1;
    adcHandle->Init.DataAlign             = ADC_DATAALIGN_RIGHT;
    adcHandle->Init.NbrOfConversion       = 1;
    adcHandle->Init.DMAContinuousRequests = DISABLE;
    adcHandle->Init.EOCSelection          = DISABLE;

    HAL_ADC_Init(adcHandle);
}
开发者ID:gan0ling,项目名称:micropython,代码行数:35,代码来源:adc.c

示例4: ADC_InjectedChannelConfig

/*******************************************************************************
* 函数名称: ADC_InjectedChannelConfig
* 功能描述: 配置选中的ADC注入信道相应的音序器(sequencer)等级和采样时间。
* 输入参数: (1)ADCx:其中x可以是1、2或3,用来选择ADC外围模块.
*           (2)ADC_Channel: 需要配置的ADC信道.
*                    ADC_Channel 可能的取值:
*                       - ADC_Channel_0: ADC信道0被选择
*                       - ADC_Channel_1: ADC信道1被选择
*                       - ADC_Channel_2: ADC信道2被选择
*                       - ADC_Channel_3: ADC信道3被选择
*                       - ADC_Channel_4: ADC信道4被选择
*                       - ADC_Channel_5: ADC信道5被选择
*                       - ADC_Channel_6: ADC信道6被选择
*                       - ADC_Channel_7: ADC信道7被选择
*                       - ADC_Channel_8: ADC信道8被选择
*                       - ADC_Channel_9: ADC信道9被选择
*                       - ADC_Channel_10: ADC信道10被选择
*                       - ADC_Channel_11: ADC信道11被选择
*                       - ADC_Channel_12: ADC信道12被选择
*                       - ADC_Channel_13: ADC信道13被选择
*                       - ADC_Channel_14: ADC信道14被选择
*                       - ADC_Channel_15: ADC信道15被选择
*                       - ADC_Channel_16: ADC信道16被选择
*                       - ADC_Channel_17: ADC信道17被选择
*           (3)Rank:注入组音序器(sequencer)的等级,选择范围必须在1-4之间
*           (4)ADC_SampleTime: ADC_SampleTime:将要为选中信道设置的采样时间值
*                    ADC_SampleTime.取值:
*                       - ADC_SampleTime_1Cycles5: 采样时间等于1.5个周期
*                       - ADC_SampleTime_7Cycles5: 采样时间等于7.5个周期
*                       - ADC_SampleTime_13Cycles5: 采样时间等于13.5个周期
*                       - ADC_SampleTime_28Cycles5: 采样时间等于28.5个周期
*                       - ADC_SampleTime_41Cycles5: 采样时间等于41.5个周期
*                       - ADC_SampleTime_55Cycles5: 采样时间等于55.5个周期
*                       - ADC_SampleTime_71Cycles5: 采样时间等于71.5个周期
*                       - ADC_SampleTime_239Cycles5: 采样时间等于239.5个周期
* 输出参数: 无
* 返回参数: 无
*******************************************************************************/
void ADC_InjectedChannelConfig(ADC_TypeDef* ADCx, u8 ADC_Channel, u8 Rank, u8 ADC_SampleTime)
{
  u32 tmpreg1 = 0, tmpreg2 = 0, tmpreg3 = 0;

  /* Check the parameters [检查参数] */
  assert_param(IS_ADC_ALL_PERIPH(ADCx));
  assert_param(IS_ADC_CHANNEL(ADC_Channel));
  assert_param(IS_ADC_INJECTED_RANK(Rank));
  assert_param(IS_ADC_SAMPLE_TIME(ADC_SampleTime));

  /* if ADC_Channel_10 ... ADC_Channel_17 is selected [如果ADC_Channel_10 ... ADC_Channel_17被选择]*/
  if (ADC_Channel > ADC_Channel_9)
  {
    /* Get the old register value [取得旧的寄存器值]*/
    tmpreg1 = ADCx->SMPR1;
    /* Calculate the mask to clear [计算需要清除的标志]*/
    tmpreg2 = SMPR1_SMP_Set << (3*(ADC_Channel - 10));
    /* Clear the old discontinuous mode channel count [清除过去的不间断模式通道计数器]*/
    tmpreg1 &= ~tmpreg2;
    /* Calculate the mask to set [计算需要置位的标志]*/
    tmpreg2 = (u32)ADC_SampleTime << (3*(ADC_Channel - 10));
    /* Set the discontinuous mode channel count [设置不间断模式通道计数器]*/
    tmpreg1 |= tmpreg2;
    /* Store the new register value [存储新的寄存器值]*/
    ADCx->SMPR1 = tmpreg1;
  }
  else /* ADC_Channel include in ADC_Channel_[0..9] [ADC_Channel 在 ADC_Channel_[0..9]之间]*/
  {
    /* Get the old register value [取得旧的寄存器值]*/
    tmpreg1 = ADCx->SMPR2;
    /* Calculate the mask to clear [计算需要清除的标志]*/
    tmpreg2 = SMPR2_SMP_Set << (3 * ADC_Channel);
    /* Clear the old discontinuous mode channel count [清除过去的不间断模式通道计数器]*/
    tmpreg1 &= ~tmpreg2;
    /* Calculate the mask to set [计算需要置位的标志]*/
    tmpreg2 = (u32)ADC_SampleTime << (3 * ADC_Channel);
    /* Set the discontinuous mode channel count [设置不间断模式通道计数器]*/
    tmpreg1 |= tmpreg2;
    /* Store the new register value [存储新的寄存器值]*/
    ADCx->SMPR2 = tmpreg1;
  }

  /* Rank configuration [序列配置]*/
  /* Get the old register value [取得旧的寄存器值]*/
  tmpreg1 = ADCx->JSQR;
  /* Get JL value[取得JL值]: Number = JL+1 */
  tmpreg3 =  (tmpreg1 & JSQR_JL_Set)>> 20;
  /* Calculate the mask to clear[计算需要清除的标志]: ((Rank-1)+(4-JL-1)) */
  tmpreg2 = JSQR_JSQ_Set << (5 * (u8)((Rank + 3) - (tmpreg3 + 1)));
  /* Clear the old JSQx bits for the selected rank [清除选中序列旧的JSQx位]*/
  tmpreg1 &= ~tmpreg2;
  /* Calculate the mask to set[计算需要置位的标志]: ((Rank-1)+(4-JL-1)) */
  tmpreg2 = (u32)ADC_Channel << (5 * (u8)((Rank + 3) - (tmpreg3 + 1)));
  /* Set the JSQx bits for the selected rank [置位选中序列旧的JSQx位]*/
  tmpreg1 |= tmpreg2;
  /* Store the new register value [存储新的寄存器值]*/
  ADCx->JSQR = tmpreg1;
}
开发者ID:WrongChao,项目名称:lammbo-fly,代码行数:96,代码来源:stm32f10x_adc.c

示例5: ADC_InjectedChannelConfig

/**
  * @brief  Configures for the selected ADC injected channel its corresponding
  *         rank in the sequencer and its sample time.
  * @param  ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
  * @param  ADC_Channel: the ADC channel to configure.
  *   This parameter can be one of the following values:
  *     @arg ADC_Channel_0: ADC Channel0 selected
  *     @arg ADC_Channel_1: ADC Channel1 selected
  *     @arg ADC_Channel_2: ADC Channel2 selected
  *     @arg ADC_Channel_3: ADC Channel3 selected
  *     @arg ADC_Channel_4: ADC Channel4 selected
  *     @arg ADC_Channel_5: ADC Channel5 selected
  *     @arg ADC_Channel_6: ADC Channel6 selected
  *     @arg ADC_Channel_7: ADC Channel7 selected
  *     @arg ADC_Channel_8: ADC Channel8 selected
  *     @arg ADC_Channel_9: ADC Channel9 selected
  *     @arg ADC_Channel_10: ADC Channel10 selected
  *     @arg ADC_Channel_11: ADC Channel11 selected
  *     @arg ADC_Channel_12: ADC Channel12 selected
  *     @arg ADC_Channel_13: ADC Channel13 selected
  *     @arg ADC_Channel_14: ADC Channel14 selected
  *     @arg ADC_Channel_15: ADC Channel15 selected
  *     @arg ADC_Channel_16: ADC Channel16 selected
  *     @arg ADC_Channel_17: ADC Channel17 selected
  * @param  Rank: The rank in the injected group sequencer. This parameter must be between 1 and 4.
  * @param  ADC_SampleTime: The sample time value to be set for the selected channel.
  *   This parameter can be one of the following values:
  *     @arg ADC_SampleTime_1Cycles5: Sample time equal to 1.5 cycles
  *     @arg ADC_SampleTime_7Cycles5: Sample time equal to 7.5 cycles
  *     @arg ADC_SampleTime_13Cycles5: Sample time equal to 13.5 cycles
  *     @arg ADC_SampleTime_28Cycles5: Sample time equal to 28.5 cycles
  *     @arg ADC_SampleTime_41Cycles5: Sample time equal to 41.5 cycles
  *     @arg ADC_SampleTime_55Cycles5: Sample time equal to 55.5 cycles
  *     @arg ADC_SampleTime_71Cycles5: Sample time equal to 71.5 cycles
  *     @arg ADC_SampleTime_239Cycles5: Sample time equal to 239.5 cycles
  * @retval None
  */
void ADC_InjectedChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel, uint8_t Rank, uint8_t ADC_SampleTime)
{
  uint32_t tmpreg1 = 0, tmpreg2 = 0, tmpreg3 = 0;
  /* Check the parameters */
  assert_param(IS_ADC_ALL_PERIPH(ADCx));
  assert_param(IS_ADC_CHANNEL(ADC_Channel));
  assert_param(IS_ADC_INJECTED_RANK(Rank));
  assert_param(IS_ADC_SAMPLE_TIME(ADC_SampleTime));
  /* if ADC_Channel_10 ... ADC_Channel_17 is selected */
  if (ADC_Channel > ADC_Channel_9)
  {
    /* Get the old register value */
    tmpreg1 = ADCx->SMPR1;
    /* Calculate the mask to clear */
    tmpreg2 = SMPR1_SMP_Set << (3*(ADC_Channel - 10));
    /* Clear the old channel sample time */
    tmpreg1 &= ~tmpreg2;
    /* Calculate the mask to set */
    tmpreg2 = (uint32_t)ADC_SampleTime << (3*(ADC_Channel - 10));
    /* Set the new channel sample time */
    tmpreg1 |= tmpreg2;
    /* Store the new register value */
    ADCx->SMPR1 = tmpreg1;
  }
  else /* ADC_Channel include in ADC_Channel_[0..9] */
  {
    /* Get the old register value */
    tmpreg1 = ADCx->SMPR2;
    /* Calculate the mask to clear */
    tmpreg2 = SMPR2_SMP_Set << (3 * ADC_Channel);
    /* Clear the old channel sample time */
    tmpreg1 &= ~tmpreg2;
    /* Calculate the mask to set */
    tmpreg2 = (uint32_t)ADC_SampleTime << (3 * ADC_Channel);
    /* Set the new channel sample time */
    tmpreg1 |= tmpreg2;
    /* Store the new register value */
    ADCx->SMPR2 = tmpreg1;
  }
  /* Rank configuration */
  /* Get the old register value */
  tmpreg1 = ADCx->JSQR;
  /* Get JL value: Number = JL+1 */
  tmpreg3 =  (tmpreg1 & JSQR_JL_Set)>> 20;
  /* Calculate the mask to clear: ((Rank-1)+(4-JL-1)) */
  tmpreg2 = JSQR_JSQ_Set << (5 * (uint8_t)((Rank + 3) - (tmpreg3 + 1)));
  /* Clear the old JSQx bits for the selected rank */
  tmpreg1 &= ~tmpreg2;
  /* Calculate the mask to set: ((Rank-1)+(4-JL-1)) */
  tmpreg2 = (uint32_t)ADC_Channel << (5 * (uint8_t)((Rank + 3) - (tmpreg3 + 1)));
  /* Set the JSQx bits for the selected rank */
  tmpreg1 |= tmpreg2;
  /* Store the new register value */
  ADCx->JSQR = tmpreg1;
}
开发者ID:alexd74,项目名称:stm32base,代码行数:92,代码来源:stm32f10x_adc.c

示例6: HAL_ADC_AnalogWDGConfig

/**
  * @brief Configures the analog watchdog.
  * @note Analog watchdog thresholds can be modified while ADC conversion is on going.
  * In this case, some constraints must be taken into account: the programmed threshold 
  * values are effective from the next ADC EOC (end of unitary conversion).
  * Considering that registers write delay may happen due to bus activity, this might cause
  * an uncertainty on the effective timing of the new programmed threshold values.
  * @param  hadc: pointer to a ADC_HandleTypeDef structure that contains
  *         the configuration information for the specified ADC.
  * @param  AnalogWDGConfig : pointer to an ADC_AnalogWDGConfTypeDef structure 
  *         that contains the configuration information of ADC analog watchdog.
  * @retval HAL status
  */
HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig(ADC_HandleTypeDef* hadc, ADC_AnalogWDGConfTypeDef* AnalogWDGConfig)
{
#ifdef USE_FULL_ASSERT  
  uint32_t tmp = 0;
#endif /* USE_FULL_ASSERT  */  
  
  /* Check the parameters */
  assert_param(IS_ADC_ANALOG_WATCHDOG(AnalogWDGConfig->WatchdogMode));
  assert_param(IS_ADC_CHANNEL(AnalogWDGConfig->Channel));
  assert_param(IS_FUNCTIONAL_STATE(AnalogWDGConfig->ITMode));

#ifdef USE_FULL_ASSERT  
  tmp = ADC_GET_RESOLUTION(hadc);
  assert_param(IS_ADC_RANGE(tmp, AnalogWDGConfig->HighThreshold));
  assert_param(IS_ADC_RANGE(tmp, AnalogWDGConfig->LowThreshold));
#endif /* USE_FULL_ASSERT  */
  
  /* Process locked */
  __HAL_LOCK(hadc);
  
  if(AnalogWDGConfig->ITMode == ENABLE)
  {
    /* Enable the ADC Analog watchdog interrupt */
    __HAL_ADC_ENABLE_IT(hadc, ADC_IT_AWD);
  }
  else
  {
    /* Disable the ADC Analog watchdog interrupt */
    __HAL_ADC_DISABLE_IT(hadc, ADC_IT_AWD);
  }
  
  /* Clear AWDEN, JAWDEN and AWDSGL bits */
  hadc->Instance->CR1 &=  ~(ADC_CR1_AWDSGL | ADC_CR1_JAWDEN | ADC_CR1_AWDEN);
  
  /* Set the analog watchdog enable mode */
  hadc->Instance->CR1 |= AnalogWDGConfig->WatchdogMode;
  
  /* Set the high threshold */
  hadc->Instance->HTR = AnalogWDGConfig->HighThreshold;
  
  /* Set the low threshold */
  hadc->Instance->LTR = AnalogWDGConfig->LowThreshold;
  
  /* Clear the Analog watchdog channel select bits */
  hadc->Instance->CR1 &= ~ADC_CR1_AWDCH;
  
  /* Set the Analog watchdog channel */
  hadc->Instance->CR1 |= (uint32_t)((uint16_t)(AnalogWDGConfig->Channel));
  
  /* Process unlocked */
  __HAL_UNLOCK(hadc);
  
  /* Return function status */
  return HAL_OK;
}
开发者ID:Cheong2K,项目名称:rt-thread,代码行数:68,代码来源:stm32f4xx_hal_adc.c

示例7: ADC_AnalogWatchdogSingleChannelConfig

/**
  * @brief  Configures the analog watchdog guarded single channel
  * @param  ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
  * @param  ADC_Channel: the ADC channel to configure for the analog watchdog.
  *   This parameter can be one of the following values:
  *     @arg ADC_Channel_0: ADC Channel0 selected
  *     @arg ADC_Channel_1: ADC Channel1 selected
  *     @arg ADC_Channel_2: ADC Channel2 selected
  *     @arg ADC_Channel_3: ADC Channel3 selected
  *     @arg ADC_Channel_4: ADC Channel4 selected
  *     @arg ADC_Channel_5: ADC Channel5 selected
  *     @arg ADC_Channel_6: ADC Channel6 selected
  *     @arg ADC_Channel_7: ADC Channel7 selected
  *     @arg ADC_Channel_8: ADC Channel8 selected
  *     @arg ADC_Channel_9: ADC Channel9 selected
  *     @arg ADC_Channel_10: ADC Channel10 selected
  *     @arg ADC_Channel_11: ADC Channel11 selected
  *     @arg ADC_Channel_12: ADC Channel12 selected
  *     @arg ADC_Channel_13: ADC Channel13 selected
  *     @arg ADC_Channel_14: ADC Channel14 selected
  *     @arg ADC_Channel_15: ADC Channel15 selected
  *     @arg ADC_Channel_16: ADC Channel16 selected
  *     @arg ADC_Channel_17: ADC Channel17 selected
  * @retval None
  */
void ADC_AnalogWatchdogSingleChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel)
{
  uint32_t tmpreg = 0;
  /* Check the parameters */
  assert_param(IS_ADC_ALL_PERIPH(ADCx));
  assert_param(IS_ADC_CHANNEL(ADC_Channel));
  /* Get the old register value */
  tmpreg = ADCx->CR1;
  /* Clear the Analog watchdog channel select bits */
  tmpreg &= CR1_AWDCH_Reset;
  /* Set the Analog watchdog channel */
  tmpreg |= ADC_Channel;
  /* Store the new register value */
  ADCx->CR1 = tmpreg;
}
开发者ID:alexd74,项目名称:stm32base,代码行数:40,代码来源:stm32f10x_adc.c

示例8: ADC_RegularChannelConfig

/**
* @brief  Configures for the selected ADC  channel its corresponding
*   rank in the sequencer and its sample time.
* @param ADCx: where x can be 1, 2 to select the ADC peripheral.
* @param ADC_Channel: the ADC channel to configure. 
*   This parameter can be one of the following values:
* @arg ADC_Channel_0: ADC Channel0 selected
* @arg ADC_Channel_1: ADC Channel1 selected
* @arg ADC_Channel_2: ADC Channel2 selected
* @arg ADC_Channel_3: ADC Channel3 selected
* @arg ADC_Channel_4: ADC Channel4 selected
* @arg ADC_Channel_5: ADC Channel5 selected
* @arg ADC_Channel_6: ADC Channel6 selected
* @arg ADC_Channel_7: ADC Channel7 selected
* @arg ADC_Channel_8: ADC Channel8 selected
* @retval : None
*/
void ADC_RegularChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel, uint8_t Rank, uint8_t ADC_SampleTime)
{
    uint32_t tmpreg = 0;
    /* Check the parameters */
    assert_param(IS_ADC_ALL_PERIPH(ADCx));
    assert_param(IS_ADC_CHANNEL(ADC_Channel));
    assert_param(IS_ADC_REGULAR_RANK(Rank));
    assert_param(IS_ADC_SAMPLE_TIME(ADC_SampleTime));
    tmpreg = ADCx->ADCFG;
    tmpreg &= ~(ADC_SMPR_SMP<<10);
    ADCx->ADCFG = tmpreg|((ADC_SampleTime&ADC_SMPR_SMP)<<10);
    switch(ADC_Channel)
    {
        /* set the CHEN0 bit for channel 0 enable*/
    case ADC_Channel_0: ADCx->ADCHS |= CHEN0_ENABLE;
    break;
    /* set the CHEN1 bit for channel 1 enable*/
    case ADC_Channel_1: ADCx->ADCHS |= CHEN1_ENABLE;
    break;
    /* set the CHEN2 bit for channel 2 enable*/
    case ADC_Channel_2: ADCx->ADCHS |= CHEN2_ENABLE;
    break;
    /* set the CHEN3 bit for channel 3 enable*/
    case ADC_Channel_3: ADCx->ADCHS |= CHEN3_ENABLE;
    break;
    /* set the CHEN4 bit for channel 4 enable*/
    case ADC_Channel_4: ADCx->ADCHS |= CHEN4_ENABLE;
    break;
    /* set the CHEN5 bit for channel 5 enable*/
    case ADC_Channel_5: ADCx->ADCHS |= CHEN5_ENABLE;
    break;
    /* set the CHEN6 bit for channel 6 enable*/
    case ADC_Channel_6: ADCx->ADCHS |= CHEN6_ENABLE;
    break;
    /* set the CHEN7 bit for channel 7 enable*/
    case ADC_Channel_7: ADCx->ADCHS |= CHEN7_ENABLE;
    break;
    /* set the SENSOREN bit for channel 8 enable*/
    case ADC_Channel_8: ADCx->ADCHS |= CHEN8_ENABLE;      //SENSOREN or VREFINT
    break;
    case ADC_Channel_All:ADCx->ADCHS |= CHALL_ENABLE;     //SENSOREN or VREFINT
    break;
    default:
        ADCx->ADCHS &= CHEN_DISABLE;  
        break;  
    }
}
开发者ID:heyuanjie87,项目名称:rt-thread,代码行数:64,代码来源:HAL_adc.c

示例9: ADC_AnalogWatchdogSingleChannelConfig

/*******************************************************************************
* 函数名称: ADC_AnalogWatchdogSingleChannelConfig
* 功能描述: 配置监视单信道的模拟看门狗
* 输入参数: (1)ADCx:其中x可以是1、2或3,用来选择ADC外围模块.
*           (2)ADC_Channel:将要为其配置模拟看门狗的信道.
*                    ADC_Channel 可能的取值:
*                       - ADC_Channel_0: ADC信道0被选择
*                       - ADC_Channel_1: ADC信道1被选择
*                       - ADC_Channel_2: ADC信道2被选择
*                       - ADC_Channel_3: ADC信道3被选择
*                       - ADC_Channel_4: ADC信道4被选择
*                       - ADC_Channel_5: ADC信道5被选择
*                       - ADC_Channel_6: ADC信道6被选择
*                       - ADC_Channel_7: ADC信道7被选择
*                       - ADC_Channel_8: ADC信道8被选择
*                       - ADC_Channel_9: ADC信道9被选择
*                       - ADC_Channel_10: ADC信道10被选择
*                       - ADC_Channel_11: ADC信道11被选择
*                       - ADC_Channel_12: ADC信道12被选择
*                       - ADC_Channel_13: ADC信道13被选择
*                       - ADC_Channel_14: ADC信道14被选择
*                       - ADC_Channel_15: ADC信道15被选择
*                       - ADC_Channel_16: ADC信道16被选择
*                       - ADC_Channel_17: ADC信道17被选择
* 输出参数: 无
* 返回参数: 无
*******************************************************************************/
void ADC_AnalogWatchdogSingleChannelConfig(ADC_TypeDef* ADCx, u8 ADC_Channel)
{
  u32 tmpreg = 0;

  /* Check the parameters 检查参数 */
  assert_param(IS_ADC_ALL_PERIPH(ADCx));
  assert_param(IS_ADC_CHANNEL(ADC_Channel));

  /* Get the old register value [取得旧的寄存器值]*/
  tmpreg = ADCx->CR1;
  /* Clear the Analog watchdog channel select bits [清除模拟看门狗通道选择位]*/
  tmpreg &= CR1_AWDCH_Reset;
  /* Set the Analog watchdog channel [置位模拟看门狗通道选择位]*/
  tmpreg |= ADC_Channel;
  /* Store the new register value [存储新的寄存器值]*/
  ADCx->CR1 = tmpreg;
}
开发者ID:WrongChao,项目名称:lammbo-fly,代码行数:44,代码来源:stm32f10x_adc.c

示例10: stm32f4_adc_configure_channel

/**
 * Configure an ADC channel on the STM32F4 ADC.
 *
 * @param dev The ADC device to configure
 * @param cnum The channel on the ADC device to configure
 * @param cfgdata An opaque pointer to channel config, expected to be
 *                a ADC_ChannelConfTypeDef
 *
 * @return 0 on success, non-zero on failure.
 */
static int
stm32f4_adc_configure_channel(struct adc_dev *dev, uint8_t cnum,
        void *cfgdata)
{
    int rc;
    ADC_HandleTypeDef *hadc;
    struct stm32f4_adc_dev_cfg *cfg;
    struct adc_chan_config *chan_cfg;
    GPIO_InitTypeDef gpio_td;

    rc = OS_EINVAL;

    if (dev == NULL && !IS_ADC_CHANNEL(cnum)) {
        goto err;
    }

    cfg  = (struct stm32f4_adc_dev_cfg *)dev->ad_dev.od_init_arg;
    hadc = cfg->sac_adc_handle;
    chan_cfg = &((struct adc_chan_config *)cfg->sac_chans)[cnum];

    cfgdata = (ADC_ChannelConfTypeDef *)cfgdata;

    if ((HAL_ADC_ConfigChannel(hadc, cfgdata)) != HAL_OK) {
        goto err;
    }

    dev->ad_chans[cnum].c_res = chan_cfg->c_res;
    dev->ad_chans[cnum].c_refmv = chan_cfg->c_refmv;
    dev->ad_chans[cnum].c_configured = 1;
    dev->ad_chans[cnum].c_cnum = cnum;

    if (stm32f4_resolve_adc_gpio(hadc, cnum, &gpio_td)) {
        goto err;
    }

    hal_gpio_init_stm(gpio_td.Pin, &gpio_td);

    return (OS_OK);
err:
    return (rc);
}
开发者ID:vrahane,项目名称:incubator-mynewt-core,代码行数:51,代码来源:adc_stm32f4.c

示例11: ADC_ChannelConfig

/**
  * @brief  Configures for the selected ADC and its sampling time.
  * @param  ADCx: where x can be 1 to select the ADC peripheral.
  * @param  ADC_Channel: the ADC channel to configure. 
  *          This parameter can be any combination of the following values:
  *            @arg ADC_Channel_0: ADC Channel0 selected
  *            @arg ADC_Channel_1: ADC Channel1 selected
  *            @arg ADC_Channel_2: ADC Channel2 selected
  *            @arg ADC_Channel_3: ADC Channel3 selected
  *            @arg ADC_Channel_4: ADC Channel4 selected
  *            @arg ADC_Channel_5: ADC Channel5 selected
  *            @arg ADC_Channel_6: ADC Channel6 selected
  *            @arg ADC_Channel_7: ADC Channel7 selected
  *            @arg ADC_Channel_8: ADC Channel8 selected
  *            @arg ADC_Channel_9: ADC Channel9 selected
  *            @arg ADC_Channel_10: ADC Channel10 selected, not available for STM32F031 devices
  *            @arg ADC_Channel_11: ADC Channel11 selected, not available for STM32F031 devices
  *            @arg ADC_Channel_12: ADC Channel12 selected, not available for STM32F031 devices
  *            @arg ADC_Channel_13: ADC Channel13 selected, not available for STM32F031 devices
  *            @arg ADC_Channel_14: ADC Channel14 selected, not available for STM32F031 devices
  *            @arg ADC_Channel_15: ADC Channel15 selected, not available for STM32F031 devices
  *            @arg ADC_Channel_16: ADC Channel16 selected
  *            @arg ADC_Channel_17: ADC Channel17 selected
  *            @arg ADC_Channel_18: ADC Channel18 selected, not available for STM32F030 devices
  * @param  ADC_SampleTime: The sample time value to be set for the selected channel. 
  *          This parameter can be one of the following values:
  *            @arg ADC_SampleTime_1_5Cycles: Sample time equal to 1.5 cycles  
  *            @arg ADC_SampleTime_7_5Cycles: Sample time equal to 7.5 cycles
  *            @arg ADC_SampleTime_13_5Cycles: Sample time equal to 13.5 cycles
  *            @arg ADC_SampleTime_28_5Cycles: Sample time equal to 28.5 cycles
  *            @arg ADC_SampleTime_41_5Cycles: Sample time equal to 41.5 cycles
  *            @arg ADC_SampleTime_55_5Cycles: Sample time equal to 55.5 cycles
  *            @arg ADC_SampleTime_71_5Cycles: Sample time equal to 71.5 cycles
  *            @arg ADC_SampleTime_239_5Cycles: Sample time equal to 239.5 cycles
  * @retval None
  */
void ADC_ChannelConfig(ADC_TypeDef* ADCx, uint32_t ADC_Channel, uint32_t ADC_SampleTime)
{
  uint32_t tmpreg = 0;

  /* Check the parameters */
  assert_param(IS_ADC_ALL_PERIPH(ADCx));
  assert_param(IS_ADC_CHANNEL(ADC_Channel));
  assert_param(IS_ADC_SAMPLE_TIME(ADC_SampleTime));

  /* Configure the ADC Channel */
  ADCx->CHSELR |= (uint32_t)ADC_Channel;

  /* Clear the Sampling time Selection bits */
  tmpreg &= ~ADC_SMPR1_SMPR;

  /* Set the ADC Sampling Time register */
  tmpreg |= (uint32_t)ADC_SampleTime;

  /* Configure the ADC Sample time register */
  ADCx->SMPR = tmpreg ;
}
开发者ID:Recontech,项目名称:STM32Fx_FreeRTOS_Base,代码行数:57,代码来源:stm32f0xx_adc.c

示例12: ADC_ChannelConfig

/**
  * @brief  Configures for the selected ADC and its sampling time.
  * @param  ADCx: where x can be 1 to select the ADC peripheral.
  * @param  ADC_Channel: the ADC channel to configure.
  *          This parameter can be any combination of the following values:
  *            @arg ADC_Channel_0: ADC Channel0 selected
  *            @arg ADC_Channel_1: ADC Channel1 selected
  *            @arg ADC_Channel_2: ADC Channel2 selected
  *            @arg ADC_Channel_3: ADC Channel3 selected
  *            @arg ADC_Channel_4: ADC Channel4 selected
  *            @arg ADC_Channel_5: ADC Channel5 selected
  *            @arg ADC_Channel_6: ADC Channel6 selected
  *            @arg ADC_Channel_7: ADC Channel7 selected
  *            @arg ADC_Channel_8: ADC Channel8 selected
  *            @arg ADC_Channel_9: ADC Channel9 selected
  *            @arg ADC_Channel_10: ADC Channel10 selected
  *            @arg ADC_Channel_11: ADC Channel11 selected
  *            @arg ADC_Channel_12: ADC Channel12 selected
  *            @arg ADC_Channel_13: ADC Channel13 selected
  *            @arg ADC_Channel_14: ADC Channel14 selected
  *            @arg ADC_Channel_15: ADC Channel15 selected
  *            @arg ADC_Channel_16: ADC Channel16 selected
  *            @arg ADC_Channel_17: ADC Channel17 selected
  *            @arg ADC_Channel_18: ADC Channel18 selected
  * @param  ADC_SampleTime: The sample time value to be set for the selected channel.
  *          This parameter can be one of the following values:
  *            @arg ADC_SampleTime_1_5Cycles: Sample time equal to 1.5 cycles
  *            @arg ADC_SampleTime_7_5Cycles: Sample time equal to 7.5 cycles
  *            @arg ADC_SampleTime_13_5Cycles: Sample time equal to 13.5 cycles
  *            @arg ADC_SampleTime_28_5Cycles: Sample time equal to 28.5 cycles
  *            @arg ADC_SampleTime_41_5Cycles: Sample time equal to 41.5 cycles
  *            @arg ADC_SampleTime_55_5Cycles: Sample time equal to 55.5 cycles
  *            @arg ADC_SampleTime_71_5Cycles: Sample time equal to 71.5 cycles
  *            @arg ADC_SampleTime_239_5Cycles: Sample time equal to 239.5 cycles
  * @retval None
  */
void ADC_ChannelConfig(ADC_TypeDef* ADCx, uint32_t ADC_Channel, uint32_t ADC_SampleTime)
{
    uint32_t tmpreg = 0;

    /* Check the parameters */
    assert_param(IS_ADC_ALL_PERIPH(ADCx));
    assert_param(IS_ADC_CHANNEL(ADC_Channel));
    assert_param(IS_ADC_SAMPLE_TIME(ADC_SampleTime));

    /* Configure the ADC Channel */
    //  ADCx->CHSELR |= (uint32_t)ADC_Channel;   PbP bug fix. The STM code logic ORs the Channel.  This will not clear any previous set channels
    ADCx->CHSELR = (uint32_t)ADC_Channel;       // Our fix will clear previous set channels

    /* Clear the Sampling time Selection bits */
    tmpreg &= ~ADC_SMPR1_SMPR;

    /* Set the ADC Sampling Time register */
    tmpreg |= (uint32_t)ADC_SampleTime;

    /* Configure the ADC Sample time register */
    ADCx->SMPR = tmpreg ;
}
开发者ID:TomTinkering,项目名称:bragmap_touch,代码行数:58,代码来源:stm32f0xx_adc.c

示例13: adc_make_new

/// \classmethod \constructor(pin)
/// Create an ADC object associated with the given pin.
/// This allows you to then read analog values on that pin.
STATIC mp_obj_t adc_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
    // check number of arguments
    mp_arg_check_num(n_args, n_kw, 1, 1, false);

    // 1st argument is the pin name
    mp_obj_t pin_obj = args[0];

    uint32_t channel;

    if (MP_OBJ_IS_INT(pin_obj)) {
        channel = mp_obj_get_int(pin_obj);
    } else {
        const pin_obj_t *pin = pin_find(pin_obj);
        if ((pin->adc_num & PIN_ADC1) == 0) {
            // No ADC1 function on that pin
            nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "pin %s does not have ADC capabilities", qstr_str(pin->name)));
        }
        channel = pin->adc_channel;
    }

    if (!IS_ADC_CHANNEL(channel)) {
        nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "not a valid ADC Channel: %d", channel));
    }
    if (pin_adc1[channel] == NULL) {
        nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "channel %d not available on this board", channel));
    }

    pyb_obj_adc_t *o = m_new_obj(pyb_obj_adc_t);
    memset(o, 0, sizeof(*o));
    o->base.type = &pyb_adc_type;
    o->pin_name = pin_obj;
    o->channel = channel;
    adc_init_single(o);

    return o;
}
开发者ID:gan0ling,项目名称:micropython,代码行数:39,代码来源:adc.c

示例14: ADC_RegularChannelConfig

/*******************************************************************************
* 函数名称: ADC_RegularChannelConfig
* 功能描述: 为选中的ADC常规组信道配置相关的音序器(sequencer)等级和采样时间。
* 输入参数: (1)ADCx:其中x可以是1、2或3,用来选择ADC外围模块.
*           (2)ADC_Channel:需要配置的ADC信道
*                    ADC_Channel 可能的取值:
*                       - ADC_Channel_0: ADC信道0被选择
*                       - ADC_Channel_1: ADC信道1被选择
*                       - ADC_Channel_2: ADC信道2被选择
*                       - ADC_Channel_3: ADC信道3被选择
*                       - ADC_Channel_4: ADC信道4被选择
*                       - ADC_Channel_5: ADC信道5被选择
*                       - ADC_Channel_6: ADC信道6被选择
*                       - ADC_Channel_7: ADC信道7被选择
*                       - ADC_Channel_8: ADC信道8被选择
*                       - ADC_Channel_9: ADC信道9被选择
*                       - ADC_Channel_10: ADC信道10被选择
*                       - ADC_Channel_11: ADC信道11被选择
*                       - ADC_Channel_12: ADC信道12被选择
*                       - ADC_Channel_13: ADC信道13被选择
*                       - ADC_Channel_14: ADC信道14被选择
*                       - ADC_Channel_15: ADC信道15被选择
*                       - ADC_Channel_16: ADC信道16被选择
*                       - ADC_Channel_17: ADC信道17被选择
*           (3)Rank:常规组音序器(sequencer)的等级。参数范围是1-16。
*           (4)ADC_SampleTime:将要为所选的信道设置的采样时间
*                    ADC_SampleTime.取值:
*                       - ADC_SampleTime_1Cycles5: 采样时间等于1.5个周期
*                       - ADC_SampleTime_7Cycles5: 采样时间等于7.5个周期
*                       - ADC_SampleTime_13Cycles5: 采样时间等于13.5个周期
*                       - ADC_SampleTime_28Cycles5: 采样时间等于28.5个周期
*                       - ADC_SampleTime_41Cycles5: 采样时间等于41.5个周期
*                       - ADC_SampleTime_55Cycles5: 采样时间等于55.5个周期
*                       - ADC_SampleTime_71Cycles5: 采样时间等于71.5个周期
*                       - ADC_SampleTime_239Cycles5: 采样时间等于239.5个周期
* 输出参数: 无
* 返回参数: 无
*******************************************************************************/
void ADC_RegularChannelConfig(ADC_TypeDef* ADCx, u8 ADC_Channel, u8 Rank, u8 ADC_SampleTime)
{
  u32 tmpreg1 = 0, tmpreg2 = 0;

  /* Check the parameters [检查参数] */
  assert_param(IS_ADC_ALL_PERIPH(ADCx));
  assert_param(IS_ADC_CHANNEL(ADC_Channel));
  assert_param(IS_ADC_REGULAR_RANK(Rank));
  assert_param(IS_ADC_SAMPLE_TIME(ADC_SampleTime));

  /* if ADC_Channel_10 ... ADC_Channel_17 is selected [如果ADC_Channel_10 ... ADC_Channel_17被选择]*/
  if (ADC_Channel > ADC_Channel_9)
  {
    /* Get the old register value [取得旧的寄存器值]*/
    tmpreg1 = ADCx->SMPR1;
    /* Calculate the mask to clear [计算需要清除的标志]*/
    tmpreg2 = SMPR1_SMP_Set << (3 * (ADC_Channel - 10));
    /* Clear the old discontinuous mode channel count [清除过去的不间断模式通道计数器]*/
    tmpreg1 &= ~tmpreg2;
    /* Calculate the mask to set [计算需要置位的标志]*/
    tmpreg2 = (u32)ADC_SampleTime << (3 * (ADC_Channel - 10));
    /* Set the discontinuous mode channel count [设置不间断模式通道计数器]*/
    tmpreg1 |= tmpreg2;
    /* Store the new register value [存储新的寄存器值]*/
    ADCx->SMPR1 = tmpreg1;
  }
  else /* ADC_Channel include in ADC_Channel_[0..9] [ADC_Channel 在 ADC_Channel_[0..9]之间]*/
  {
    /* Get the old register value [取得旧的寄存器值]*/
    tmpreg1 = ADCx->SMPR2;
    /* Calculate the mask to clear [计算需要清除的标志]*/
    tmpreg2 = SMPR2_SMP_Set << (3 * ADC_Channel);
    /* Clear the old discontinuous mode channel count [清除过去的不间断模式通道计数器]*/
    tmpreg1 &= ~tmpreg2;
    /* Calculate the mask to set [计算需要置位的标志]*/
    tmpreg2 = (u32)ADC_SampleTime << (3 * ADC_Channel);
    /* Set the discontinuous mode channel count [设置不间断模式通道计数器]*/
    tmpreg1 |= tmpreg2;
    /* Store the new register value [存储新的寄存器值]*/
    ADCx->SMPR2 = tmpreg1;
  }
  /* For Rank 1 to 6 [序列在1到6之间]*/
  if (Rank < 7)
  {
    /* Get the old register value [取得旧的寄存器值]*/
    tmpreg1 = ADCx->SQR3;
    /* Calculate the mask to clear [计算需要清除的标志]*/
    tmpreg2 = SQR3_SQ_Set << (5 * (Rank - 1));
    /* Clear the old SQx bits for the selected rank [根据选择的序列清除旧的SQx位]*/
    tmpreg1 &= ~tmpreg2;
    /* Calculate the mask to set [计算需要置位的标志]*/
    tmpreg2 = (u32)ADC_Channel << (5 * (Rank - 1));
    /* Set the SQx bits for the selected rank [根据选择的序列置位新的SQx位]*/
    tmpreg1 |= tmpreg2;
    /* Store the new register value [存储新的寄存器值]*/
    ADCx->SQR3 = tmpreg1;
  }
  /* For Rank 7 to 12 [序列在7到12之间]*/
  else if (Rank < 13)
  {
    /* Get the old register value [取得旧的寄存器值]*/
    tmpreg1 = ADCx->SQR2;
//.........这里部分代码省略.........
开发者ID:WrongChao,项目名称:lammbo-fly,代码行数:101,代码来源:stm32f10x_adc.c

示例15: adc_read_value

/**
  * @brief  This function will set the ADC to the required value
  * @param  pin : the pin to use
  * @retval the value of the adc
  */
uint16_t adc_read_value(PinName pin)
{
  ADC_HandleTypeDef AdcHandle = {};
  ADC_ChannelConfTypeDef  AdcChannelConf = {};
  __IO uint16_t uhADCxConvertedValue = 0;

  AdcHandle.Instance = pinmap_peripheral(pin, PinMap_ADC);

  if (AdcHandle.Instance == NP) return 0;

#ifndef STM32F1xx
  AdcHandle.Init.ClockPrescaler        = ADC_CLOCK_DIV;          /* Asynchronous clock mode, input ADC clock divided */
  AdcHandle.Init.Resolution            = ADC_RESOLUTION_12B;            /* 12-bit resolution for converted data */
  AdcHandle.Init.EOCSelection          = ADC_EOC_SINGLE_CONV;           /* EOC flag picked-up to indicate conversion end */
  AdcHandle.Init.ExternalTrigConvEdge  = ADC_EXTERNALTRIGCONVEDGE_NONE; /* Parameter discarded because software trigger chosen */
  AdcHandle.Init.DMAContinuousRequests = DISABLE;                       /* DMA one-shot mode selected (not applied to this example) */
#endif
  AdcHandle.Init.DataAlign             = ADC_DATAALIGN_RIGHT;           /* Right-alignment for converted data */
  AdcHandle.Init.ScanConvMode          = DISABLE;                       /* Sequencer disabled (ADC conversion on only 1 channel: channel set on rank 1) */
  AdcHandle.Init.ContinuousConvMode    = DISABLE;                       /* Continuous mode disabled to have only 1 conversion at each conversion trig */
  AdcHandle.Init.DiscontinuousConvMode = DISABLE;                       /* Parameter discarded because sequencer is disabled */
  AdcHandle.Init.ExternalTrigConv      = ADC_SOFTWARE_START;            /* Software start to trig the 1st conversion manually, without external event */
  AdcHandle.State = HAL_ADC_STATE_RESET;
#if defined (STM32F0xx) || defined (STM32L0xx)
  AdcHandle.Init.LowPowerAutoWait      = DISABLE;                       /* Auto-delayed conversion feature disabled */
  AdcHandle.Init.LowPowerAutoPowerOff  = DISABLE;                       /* ADC automatically powers-off after a conversion and automatically wakes-up when a new conversion is triggered */
  AdcHandle.Init.Overrun               = ADC_OVR_DATA_OVERWRITTEN;      /* DR register is overwritten with the last conversion result in case of overrun */
#ifdef STM32F0xx
  AdcHandle.Init.SamplingTimeCommon    = SAMPLINGTIME;
#else // STM32L0
  //LowPowerFrequencyMode to enable if clk freq < 2.8Mhz
  AdcHandle.Init.SamplingTime          = SAMPLINGTIME;
#endif
#else
#ifdef STM32F3xx
  AdcHandle.Init.LowPowerAutoWait      = DISABLE;                       /* Auto-delayed conversion feature disabled */
#endif
  AdcHandle.Init.NbrOfConversion       = 1;                             /* Specifies the number of ranks that will be converted within the regular group sequencer. */
  AdcHandle.Init.NbrOfDiscConversion   = 0;                             /* Parameter discarded because sequencer is disabled */
#endif

  g_current_pin = pin; /* Needed for HAL_ADC_MspInit*/

  if (HAL_ADC_Init(&AdcHandle) != HAL_OK) {
    return 0;
  }

  AdcChannelConf.Channel      = get_adc_channel(pin);             /* Specifies the channel to configure into ADC */
#ifdef STM32L4xx
  if (!IS_ADC_CHANNEL(&AdcHandle, AdcChannelConf.Channel)) return 0;
#else
  if (!IS_ADC_CHANNEL(AdcChannelConf.Channel)) return 0;
#endif
  AdcChannelConf.Rank         = ADC_REGULAR_RANK_1;               /* Specifies the rank in the regular group sequencer */
#ifndef STM32L0xx
  AdcChannelConf.SamplingTime = SAMPLINGTIME;                     /* Sampling time value to be set for the selected channel */
#endif
#if defined (STM32F3xx) || defined (STM32L4xx)
  AdcChannelConf.SingleDiff   = ADC_SINGLE_ENDED;                 /* Single-ended input channel */
  AdcChannelConf.OffsetNumber = ADC_OFFSET_NONE;                  /* No offset subtraction */
  AdcChannelConf.Offset = 0;                                      /* Parameter discarded because offset correction is disabled */
#endif
  /*##-2- Configure ADC regular channel ######################################*/
  if (HAL_ADC_ConfigChannel(&AdcHandle, &AdcChannelConf) != HAL_OK)
  {
    /* Channel Configuration Error */
    return 0;
  }

#if defined (STM32F0xx) || defined (STM32F1xx) || defined (STM32F3xx) || defined (STM32L0xx) || defined (STM32L4xx)
  /*##-2.1- Calibrate ADC then Start the conversion process ####################*/
#if defined (STM32F0xx) || defined (STM32F1xx)
  if (HAL_ADCEx_Calibration_Start(&AdcHandle) !=  HAL_OK)
#else
  if (HAL_ADCEx_Calibration_Start(&AdcHandle, ADC_SINGLE_ENDED) !=  HAL_OK)
#endif
  {
    /* ADC Calibration Error */
    return 0;
  }
#endif

  /*##-3- Start the conversion process ####################*/
  if (HAL_ADC_Start(&AdcHandle) != HAL_OK)
  {
    /* Start Conversation Error */
    return 0;
  }

  /*##-4- Wait for the end of conversion #####################################*/
  /*  For simplicity reasons, this example is just waiting till the end of the
      conversion, but application may perform other tasks while conversion
      operation is ongoing. */
  if (HAL_ADC_PollForConversion(&AdcHandle, 10) != HAL_OK)
  {
//.........这里部分代码省略.........
开发者ID:amassou2017,项目名称:Arduino_Core_STM32,代码行数:101,代码来源:analog.c


注:本文中的IS_ADC_CHANNEL函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。