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


C++ ADC_GetFlagStatus函数代码示例

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


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


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