• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ ADC_GetFlagStatus函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: AdcMcuRead

uint16_t AdcMcuRead( Adc_t *obj, uint8_t channel )
{
    uint16_t adcData = 0;

    /* Enable The HSI (16Mhz) */
    RCC_HSICmd( ENABLE );

    /* Check that HSI oscillator is ready */
    while( RCC_GetFlagStatus( RCC_FLAG_HSIRDY ) == RESET );

    RCC_APB2PeriphClockCmd( RCC_APB2Periph_ADC1, ENABLE );

    // Temperature or Vref measurement
    if( ( channel == ADC_Channel_16 ) || ( channel == ADC_Channel_17 ) )
    {
        // Yes, enable temperature sensor and internal reference voltage
        ADC_TempSensorVrefintCmd( ENABLE );
    }

    // Configure selected channel
    ADC_RegularChannelConfig( ADC1, channel, 1, ADC_SampleTime_192Cycles );

    /* Define delay between ADC1 conversions */
    ADC_DelaySelectionConfig( ADC1, ADC_DelayLength_Freeze );

    /* Enable ADC1 Power Down during Delay */
    ADC_PowerDownCmd( ADC1, ADC_PowerDown_Idle_Delay, ENABLE );

    /* Enable ADC1 */
    ADC_Cmd( ADC1, ENABLE );

    /* Wait until ADC1 ON status */
    while( ADC_GetFlagStatus( ADC1, ADC_FLAG_ADONS ) == RESET )
    {
    }

    /* Start ADC1 Software Conversion */
    ADC_SoftwareStartConv( ADC1 );

    /* Wait until ADC Channel 5 or 1 end of conversion */
    while( ADC_GetFlagStatus( ADC1, ADC_FLAG_EOC ) == RESET )
    {
    }

    adcData = ADC_GetConversionValue( ADC1 );

    ADC_Cmd( ADC1, DISABLE );
    
    if( ( channel == ADC_Channel_16 ) || ( channel == ADC_Channel_17 ) )
    {
        // De-initialize ADC
        ADC_TempSensorVrefintCmd( DISABLE );    
    }

    RCC_APB2PeriphClockCmd( RCC_APB2Periph_ADC1, DISABLE );

    RCC_HSICmd( DISABLE );
   
    return adcData;
}
开发者ID:AlessandroLipari,项目名称:LoRaMac-node,代码行数:60,代码来源:adc-board.c


示例2: VoltageCal

/**
  * @brief  Calculate the actual Voltage
  * @note   
  * @retval The value of the VoltageCal data.
  //STM32F042Cx  为12 bit 精度ADC
  */
float VoltageCal(void)
{	
	//uint32_t Voltage;
	#define Vref_CAL_ADDR ((uint16_t*) ((uint32_t) 0x1FFFF7ba))
	float Voltage;
	float Voltage2;
	float Voltage3;
	//启动转换
	ADC_StartOfConversion(ADC1);
	//wait for conversion complete
	while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC)){;}
	//read ADC value
	Voltage = (float)ADC_GetConversionValue(ADC1);    
	#if  1
	//wait for conversion complete
	while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC)){;}
	//read ADC value
	Voltage2 = (float)ADC_GetConversionValue(ADC1);    
	Voltage3 =   ((*Vref_CAL_ADDR )* 3.3) /Voltage2;
	Voltage = ( Voltage * Voltage3) /0xFFF;
	#else
	Voltage = ( Voltage * 3.3) /0xFFF;
	#endif	
    return Voltage;
}
开发者ID:layeka,项目名称:sw_stm_can,代码行数:31,代码来源:Check_Qifa_Res_ADC.c


示例3: ADC_Config

/**
  * @brief  Configures the ADC1 channel5.
  * @param  None
  * @retval None
  */
void ADC_Config(void)
{
  /* Enable The HSI (16Mhz) */
  RCC_HSICmd(ENABLE);

  /* Enable the GPIOF or GPIOA Clock */
  RCC_AHBPeriphClockCmd(IDD_MEASUREMENT_GPIO_CLK, ENABLE);
  /* Configure PF.11 (ADC Channel11) or PA.05 (ADC Channe5) in analog mode */
  GPIO_InitStructure.GPIO_Pin =  IDD_MEASUREMENT_PIN;
  GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AN;
  GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_NOPULL;
  GPIO_Init(IDD_MEASUREMENT_GPIO, &GPIO_InitStructure);

  /* Check that HSI oscillator is ready */
  while(RCC_GetFlagStatus(RCC_FLAG_HSIRDY) == RESET);

  /* ADC1 Configuration ------------------------------------------------------*/
  
  /* Enable ADC1 clock */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
  
#ifdef USE_STM32L152D_EVAL
  /* Select ADC Bank channel */
  ADC_BankSelection(ADC1, ADC_Bank_B);
#endif
  
  ADC_StructInit(&ADC_InitStructure);
  ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
  ADC_InitStructure.ADC_ScanConvMode = DISABLE;
  ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
  ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
  ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
  ADC_InitStructure.ADC_NbrOfConversion = 1;
  ADC_Init(ADC1, &ADC_InitStructure);

  /* ADC1 regular channel5 or channel1 configuration */
  ADC_RegularChannelConfig(ADC1, IDD_MEASUREMENT_ADC_CHANNEL, 1, ADC_SampleTime_192Cycles);

  /* Define delay between ADC1 conversions */
  ADC_DelaySelectionConfig(ADC1, ADC_DelayLength_Freeze);
  
  /* Enable ADC1 Power Down during Delay */
  ADC_PowerDownCmd(ADC1, ADC_PowerDown_Idle_Delay, ENABLE);
  
  /* Enable ADC1 */
  ADC_Cmd(ADC1, ENABLE);

  /* Wait until ADC1 ON status */
  while (ADC_GetFlagStatus(ADC1, ADC_FLAG_ADONS) == RESET)
  {
  }

  /* Start ADC1 Software Conversion */
  ADC_SoftwareStartConv(ADC1);

  /* Wait until ADC Channel 5 or 1 end of conversion */
  while (ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET)
  {
  }
}
开发者ID:Amna2013,项目名称:stm32-test,代码行数:65,代码来源:main.c


示例4: temperature_MeasureValue

/**
  * @brief  Initializes the temperature sensor and its related ADC.
  * @param  None
  * @retval the float value of temperature measured in Celsius.
  */
float temperature_MeasureValue(void)
{	
	/* Raw value of temperature sensor voltage converted from ADC1_IN16 */
	uint16_t v_refint;
	/* Raw value of VREFINT converted from ADC1_INT17 */
	uint16_t v_sensor;
	
	/* select ADC1_IN16 to sample sensor voltage value*/
	ADC_RegularChannelConfig(ADC1, ADC_Channel_16, 1, ADC_SampleTime_28Cycles);
	/* start one ADC conversion */
	ADC_SoftwareStartConv(ADC1);
	/*  wait unitl ECO bit is set, sample finished */
	while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET);
	ADC_ClearFlag(ADC1, ADC_FLAG_EOC);
	/* Read the value from ADC_DR*/
	v_sensor = ADC_GetConversionValue(ADC1);

	/* select ADC1_IN16 to sample reference voltage value*/
	ADC_RegularChannelConfig(ADC1, ADC_Channel_17, 1, ADC_SampleTime_28Cycles);
	/* start one ADC conversion */
	ADC_SoftwareStartConv(ADC1);
	/*  wait unitl ECO bit is set, sample finished */
	while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET);
	ADC_ClearFlag(ADC1, ADC_FLAG_EOC);
	/* Read the value from ADC_DR*/
	v_refint = ADC_GetConversionValue(ADC1);

  /*
	 * measured_sensor_voltage = actual_reference_voltage * sampled_sensor_voltage / sampled_reference_voltage_value
	 * temperature = (measured_sensor_voltage - sensor_voltage_at_25) / AVG_SLOPE + 25
	 */
	return (VREFINT_VOLTAGE_V / v_refint * v_sensor - TEMPERATURE_V25) * 1000 / AVG_SLOPE + 25;
}
开发者ID:headyin,项目名称:Wireless-Board-Orientation-Control-System-ARM-Micro-Processor-Lab-,代码行数:38,代码来源:temperature.c


示例5: adc_setup

void adc_setup(){
    static int setup_complete = 0;
    ADC_InitTypeDef adc_init;
    GPIO_InitTypeDef gpio_init;
    
    if(setup_complete){
        return;
    }

    // Enable clock for ADC & GPIOC
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);

    // Initialize GPIOC
    GPIO_StructInit(&gpio_init);
    gpio_init.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | \
                         GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5; 
    gpio_init.GPIO_Mode = GPIO_Mode_AN;
    gpio_init.GPIO_Speed = GPIO_Speed_2MHz; 
    GPIO_Init(GPIOC, &gpio_init);
    
    // Initialize ADC1
    ADC_DeInit(ADC1);
    ADC_StructInit(&adc_init);
    ADC_Init(ADC1, &adc_init);

    //ADC_GetCalibrationFactor(ADC1);
    ADC_TempSensorVrefintCmd(ENABLE);
    ADC_Cmd(ADC1, ENABLE);
    while(ADC_GetFlagStatus(ADC1, ADC_FLAG_RCNR));
    while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_ADONS));

    setup_complete++;
}
开发者ID:zbanks,项目名称:hackboard,代码行数:34,代码来源:hal.c


示例6: ubasic_get_adc

/*---------------------------------------------------------------------------*/
int ubasic_get_adc(int ch)
{
	int var = 0xff;
	switch(ch){
		case 1:
			if (ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET) {
				var = 0xff;
			} else {
				var = ADC_GetConversionValue(ADC1) & 0x00ff;
				ADC_SoftwareStartConv(ADC1);
			}
			break;
		case 2:
			if (ADC_GetFlagStatus(ADC2, ADC_FLAG_EOC) == RESET) {
				var = 0xff;
			} else {
				var = ADC_GetConversionValue(ADC2) & 0x00ff;
				ADC_SoftwareStartConv(ADC2);
			}
			break;
		case 3:
			if (ADC_GetFlagStatus(ADC3, ADC_FLAG_EOC) == RESET) {
				var = 0xff;
			} else {
				var = ADC_GetConversionValue(ADC3) & 0x00ff;
				ADC_SoftwareStartConv(ADC3);
			}
			break;
		default:
			var = 0xff;
			break;
	}
	return var;
}
开发者ID:mizuki-tohru,项目名称:stm32f4-console,代码行数:35,代码来源:ubasic.c


示例7: adc_read

uint16_t adc_read(uint8_t channel){
  uint16_t vref;
  ADC_RegularChannelConfig(ADC1, ADC_Channel_Vrefint, 0, ADC_SampleTime_384Cycles);
  ADC_SoftwareStartConv(ADC1);
  while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET);
  vref=ADC_GetConversionValue(ADC1);

  ADC_RegularChannelConfig(ADC1, channel, 0, ADC_SampleTime_384Cycles);
  ADC_SoftwareStartConv(ADC1);
  while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET);
  return ADC_GetConversionValue(ADC1)*6840/vref; // magic number to get millivolts

}
开发者ID:zbanks,项目名称:hackboard,代码行数:13,代码来源:hal.c


示例8: rng_seed

static void
rng_seed()
{
    ADC_InitTypeDef ADC_InitStructure;
    ot_u16 ADCdata;
    int n;

    /* Enable The HSI (16Mhz) */
    RCC_HSICmd(ENABLE); // ADC can only use HSI?


    ADC_StructInit(&ADC_InitStructure);
    ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
    ADC_InitStructure.ADC_ScanConvMode = ENABLE;
    ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
    ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
    ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
    ADC_InitStructure.ADC_NbrOfConversion = 1;
    ADC_Init(ADC1, &ADC_InitStructure);

    ADC_RegularChannelConfig(ADC1, ADC_Channel_TempSensor, 1, ADC_SampleTime_4Cycles);

    /* Enable ADC1 */
    ADC_Cmd(ADC1, ENABLE);

    /* Wait until ADC1 ON status */
    while (ADC_GetFlagStatus(ADC1, ADC_FLAG_ADONS) == RESET)
    {
        asm("nop");
    }

    /* Start ADC1 Software Conversion */
    ADC_SoftwareStartConv(ADC1);

    r = 0;
    for (n = 0; n < 30; n++) {
        /* Wait until end of conversion */
        while (ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET)
            asm("nop");

        /* Read ADC conversion result */
        ADCdata = ADC_GetConversionValue(ADC1);
        r += ADCdata & 0x07;    // take lower noise bits
    }

    //debug_printf("r: %x\r\n", r);

    ADC_Cmd(ADC1, DISABLE);
    RCC_HSICmd(DISABLE); // assuming HSI not used
}
开发者ID:jpnorair,项目名称:OpenTag,代码行数:50,代码来源:platform_STM32L1xx.c


示例9: acquireTemperatureData

void acquireTemperatureData(void)
{
    /* Enable ADC clock */
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);

    /* Enable DMA1 clock */
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);

    /* Enable ADC1 */
    ADC_Cmd(ADC1, ENABLE);

    /* Wait until the ADC1 is ready */
    while(ADC_GetFlagStatus(ADC1, ADC_FLAG_ADONS) == RESET);

    /* re-initialize DMA -- is it needed ?*/
    DMA_DeInit(DMA1_Channel1);
    DMA_Init(DMA1_Channel1, &DMA_InitStructure);
    DMA_Cmd(DMA1_Channel1, ENABLE);

    /* Enable DMA channel 1 Transmit complete interrupt*/
    DMA_ITConfig(DMA1_Channel1, DMA_IT_TC, ENABLE);

    /* Disable DMA mode for ADC1 */
    ADC_DMACmd(ADC1, DISABLE);

    /* Enable DMA mode for ADC1 */
    ADC_DMACmd(ADC1, ENABLE);

    /* Clear global flag for DMA transfert complete */
    clearADCDMA_TransferComplete();

    /* Start ADC conversion */
    ADC_SoftwareStartConv(ADC1);
}
开发者ID:powenko,项目名称:STM32L152C-Discovery-SampleCode,代码行数:34,代码来源:main.c


示例10: ad_readval

float ad_readval() {
	ADC_SoftwareStartConv(ADC1);
	while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC));
	int ival = ADC_GetConversionValue(ADC1);
	float fval = (float) (ival - 2048) / 2048.0;
	return fval;
}
开发者ID:linilss,项目名称:Sound-system-DAT290,代码行数:7,代码来源:grundsystem.c


示例11: get_ADC_val

/**
 * @brief To get adc value of A0 ~ A3 from a WIZnet module.
 * @param index The sequence for A0 ~ A3 registration
 * @return adc value (uint16_t)
 */
uint16_t get_ADC_val(uint8_t index)
{
	uint16 adc_value = 0;

#if 0
	// for Test
	switch(index)
	{
		case A0: // WIZ550web BaseBoard: Potentiometer
			if(ADC_GetFlagStatus(ADC2, ADC_FLAG_EOC) == SET) adc_value = ADC_GetConversionValue(ADC2);
			break;
		case A1: // WIZ550web BaseBoard: Temperature Sensor
			adc_value = ADC1ConvertedValue; // TemperatureC = (((ADC_value * 3300) / 1023) - 500) / 10;
			break;
		case A2:
			adc_value = 1000;
			break;
		case A3:
			adc_value = 2000;
			break;
		default:
			adc_value = 0;
			break;
	}
#else
	adc_value = ADC_DualConvertedValueTab[index];
#endif

	return adc_value;
}
开发者ID:Index01,项目名称:WIZ550web,代码行数:35,代码来源:userHandler.c


示例12: readTemp

float readTemp(){
	float temperature;
	
	ADC_SoftwareStartConv(ADC1);				// Start the conversion
	while (ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET); // Wait for conversion to finish
	temperature = (float) ADC_GetConversionValue(ADC1); 			// Get ADC reading

	// Print ADC reading
	setbuf(stdout, NULL);
        printf("%f, " , temperature);
	
	// TODO: Convert ADC (digital) reading back to voltage value
        // Use the formula on page 20 of the lecture slides
        // Here, v_min = 0, v_max = 3.3, and n depends on the resolution
        // of the ADC (refer to the adc intialization in initTempSensor() function)
	// Assign the voltage value back to the temperature variable
        convADC(&temperature,12);

	setbuf(stdout, NULL);
        printf("%f, " , temperature);
	
	// TODO: Convert the digital value to a temperature and assign back
	// to the temperature value.
	// The formula for this conversion is given in the Technical Reference Manual
        // (v_sense is the voltage value we calculated in the previous step 
	// and assigned back to temp)
	// Temperature (in °C) = {(V_SENSE - V_25) / Avg_Slope} + 25
	convVolt(&temperature);


	setbuf(stdout, NULL);
        printf("%f\n" , temperature);
	
	return temperature;
}
开发者ID:JizhouZhang,项目名称:stm32f4-labs,代码行数:35,代码来源:main.c


示例13: ReadADC1

unsigned short ReadADC1 (unsigned int channel)
{
	uint32_t tmpreg = 0;
	//GPIOA_PIN4_ON;
	// Set channel and sample time
	//ADC_ChannelConfig(ADC1, channel, ADC_SampleTime_7_5Cycles);	//pifia la medicion 2800 o 3400 en ves de 4095
	//ADC_ChannelConfig(ADC1, channel, ADC_SampleTime_239_5Cycles);
	//ADC_ChannelConfig(ADC1, ADC_Channel_0, ADC_SampleTime_239_5Cycles);

	//ADC_ChannelConfig INTERNALS
	/* Configure the ADC Channel */
	ADC1->CHSELR = channel;

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

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

	/* Configure the ADC Sample time register */
	ADC1->SMPR = tmpreg ;


	// Start the conversion
	ADC_StartOfConversion(ADC1);
	// Wait until conversion completion
	while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET);
	// Get the conversion value
	//GPIOA_PIN4_OFF;	//tarda 20us en convertir
	return ADC_GetConversionValue(ADC1);
}
开发者ID:MarianoDel,项目名称:eclipse_dexel_rgb_4ch,代码行数:31,代码来源:adc.c


示例14: ADC_Supply

/**
  * @brief  To return the supply measurmeent
  * @caller several functions
  * @param None
  * @retval ADC value
  */ 
uint16_t ADC_Supply(void)
{
  uint8_t i;
  uint16_t res;

    /* Initializes ADC */
  ADC_Icc_Init();
 
  ADC_TempSensorVrefintCmd(ENABLE);

  /* ADC1 regular channel 17 for VREF configuration */
  ADC_RegularChannelConfig(ADC1, ADC_Channel_17, 1, ADC_SampleTime_192Cycles);
  
  /* initialize result */
  res = 0;
  for(i=4; i>0; i--)
  {
  /* start ADC convertion by software */
    ADC_SoftwareStartConv(ADC1);

    /* wait until end-of-covertion */
    while( ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == 0 );
  /* read ADC convertion result */
    res += ADC_GetConversionValue(ADC1);
  }
	
  /* de-initialize ADC */
  ADC_TempSensorVrefintCmd(DISABLE);
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, DISABLE);
  
  return (res>>2);
}
开发者ID:bzdegluk,项目名称:ACQ,代码行数:38,代码来源:icc_measure.c


示例15: ADC1_Read

uint16_t ADC1_Read(uint8_t Channel)                                     // convert and read given channel
{
  ADC_RegularChannelConfig(ADC1, Channel, 1, ADC_SampleTime_7Cycles5);
  ADC_SoftwareStartConvCmd(ADC1, ENABLE);                               // Start the conversion
  while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET);                // Wait until conversion complete
  return ADC_GetConversionValue(ADC1);                                  // Get the conversion value
}
开发者ID:pola14225,项目名称:diy-tracker,代码行数:7,代码来源:adc.cpp


示例16: getTemp_celcius

// fill this in
float getTemp_celcius() {
	ADC_SoftwareStartConv(ADC1);
	while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET);
	ADC_ClearFlag(ADC1, ADC_FLAG_EOC);

	return ((ADC1->DR * 3000.0/4096.0) - 760)/2.5 + 25;
}
开发者ID:cmtm,项目名称:microP,代码行数:8,代码来源:ADC.c


示例17: readADC

u16 readADC(ADC_TypeDef* ADCx, u8 channel, uint8_t sampleTime)
{
	ADC_RegularChannelConfig(ADCx, channel, 1, sampleTime);
	ADC_SoftwareStartConv(ADCx);
	while(ADC_GetFlagStatus(ADCx, ADC_FLAG_EOC) == RESET);
	return ADC_GetConversionValue(ADCx);
}
开发者ID:ktain,项目名称:Slither2.0,代码行数:7,代码来源:adc.c


示例18: read_channel

/*
 * NOTE: No protection, should only be called from ISR
 */
static uint16_t read_channel(oscilloscope_input_t ch)
{
  uint8_t real_ch;
  switch(ch)
  {
    case input_channel0:
      real_ch = ADC_Channel_7;
      break;

    case input_channel1:
      real_ch = ADC_Channel_8;
      break;

    default:
      ipc_watchdog_signal_error(0);
      return UINT16_MAX;
  }
  
  ADC_RegularChannelConfig(ADC1, real_ch, 1, ADC_SampleTime_239Cycles5);
  ADC_ClearFlag(ADC1, ADC_FLAG_EOC);
  ADC_SoftwareStartConvCmd(ADC1, ENABLE);

  /* spin until we have data */
  while (!ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC));			

  return ADC_GetConversionValue(ADC1);
}	
开发者ID:pabe,项目名称:pins-oscilloscope,代码行数:30,代码来源:task_measure.c


示例19: adc_read

static inline uint16_t adc_read(analogin_t *obj) {
  // Get ADC registers structure address
  ADC_TypeDef *adc = (ADC_TypeDef *)(obj->adc);
  
  // Configure ADC channel
  switch (obj->pin) {
      case PA_0:
          ADC_RegularChannelConfig(adc, ADC_Channel_0, 1, ADC_SampleTime_7Cycles5);
          break;
      case PA_1:
          ADC_RegularChannelConfig(adc, ADC_Channel_1, 1, ADC_SampleTime_7Cycles5);
          break;
      case PA_4:
          ADC_RegularChannelConfig(adc, ADC_Channel_4, 1, ADC_SampleTime_7Cycles5);
          break;
      case PB_0:
          ADC_RegularChannelConfig(adc, ADC_Channel_8, 1, ADC_SampleTime_7Cycles5);
          break;
      case PC_1:
          ADC_RegularChannelConfig(adc, ADC_Channel_11, 1, ADC_SampleTime_7Cycles5);
          break;
      case PC_0:
          ADC_RegularChannelConfig(adc, ADC_Channel_10, 1, ADC_SampleTime_7Cycles5);
          break;
      default:
          return 0;
  }

  ADC_SoftwareStartConvCmd(adc, ENABLE); // Start conversion
  
  while(ADC_GetFlagStatus(adc, ADC_FLAG_EOC) == RESET); // Wait end of conversion
  
  return(ADC_GetConversionValue(adc)); // Get conversion value
}
开发者ID:SibghatullahSheikh,项目名称:mbed,代码行数:34,代码来源:analogin_api.c


示例20: adc_convert

void adc_convert(void){
		uint16_t ADC1ConvertedValue;
	
	  /* Test EOC flag */
		while (ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET)
			;
 
	    /* Get ADC1 converted data */
		ADC1ConvertedValue = ADC_GetConversionValue(ADC1);
		//update_rawADC(USART2, ADC1ConvertedValue);		//ADC value 0-4096
		//update_degF(USART2, ADC1ConvertedValue/1.64);	//degF 0-2500F
		//update_degC(USART2, ADC1ConvertedValue/3);		//degC 0-1370C
		
		//USART_PUT_TEMPF(USART2, ADC1ConvertedValue/1.64);
		//USART_PUT_TEMPC(USART2, ADC1ConvertedValue/3);
		
		if (ADC1ConvertedValue > 4000)
		{
			GPIOC->BSRR = GPIO_Pin_8;
			GPIOC->BSRR = GPIO_Pin_9;
		}
		else if (ADC1ConvertedValue > 2000)
		{
			GPIOC->BSRR = GPIO_Pin_8;
			GPIOC->BRR = GPIO_Pin_9;
		}
		else
		{
			GPIOC->BRR = GPIO_Pin_8;
			GPIOC->BRR = GPIO_Pin_9;
		}
}
开发者ID:garthbjorn,项目名称:senior-design,代码行数:32,代码来源:f0_adc.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ADC_GetResetCalibrationStatus函数代码示例发布时间:2022-05-30
下一篇:
C++ ADC_GetConversionValue函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap