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


C++ ADC_GetConversionValue函数代码示例

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


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

示例1: 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

示例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: 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

示例4: DAC_SetChannel1Data

void CIO::interrupt()
{
  uint8_t control  = MARK_NONE;
  uint16_t sample  = DC_OFFSET;
  uint16_t rawRSSI = 0U;

  m_txBuffer.get(sample, control);

  // Send the value to the DAC
  DAC_SetChannel1Data(DAC_Align_12b_R, sample);

  // Read value from ADC1 and ADC2
  if ((ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET)) {
    // shouldn't be still in reset at this point so null the sample value?
    sample  = 0U;
  } else {
    sample  = ADC_GetConversionValue(ADC1);
#if defined(SEND_RSSI_DATA)
    rawRSSI = ADC_GetConversionValue(ADC2);
#endif
  }

  // trigger next ADC1
  ADC_ClearFlag(ADC1, ADC_FLAG_EOC);
  ADC_SoftwareStartConv(ADC1);

  m_rxBuffer.put(sample, control);
  m_rssiBuffer.put(rawRSSI);

  m_watchdog++;
}
开发者ID:g4klx,项目名称:MMDVM,代码行数:31,代码来源:IOSTM.cpp

示例5: main

/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
    /* Configure System clocks -----------------------------------------------*/
    RCC_Configuration();
    
    /* Configure GPIO ports --------------------------------------------------*/
    GPIO_Configuration();
    USART_Configuration();

    /* Output a message on Hyperterminal using printf function */
    printf("\n\rADC different test: \n\r");

    ADC_Configuration();
    while(ADC_GetBitState(ADC_FLAG_EOC) != SET);
    ADCConvertedValue = ADC_GetConversionValue();

    printf("\n\rThe original data  %d\n\r",ADCConvertedValue);
    ADC_DeInit(&ADC_InitStructure);

    ADC_OVERConfiguration();
    while(ADC_GetBitState(ADC_FLAG_EOC) != SET);
    ADCConvertedValue_OVER = ADC_GetConversionValue();

    printf("\n\rOversampling data  %d\n\r",ADCConvertedValue_OVER);

    while (1)
    {
    }
}
开发者ID:eeinz,项目名称:trochili,代码行数:34,代码来源:main.c

示例6: DMA2_Stream0_IRQHandler

void DMA2_Stream0_IRQHandler (void) {
    __IO uint16_t SENSOR_A_VoltValue = ADC_GetConversionValue(ADC1) * 3000/0xfff;
    __IO uint16_t SENSOR_B_VoltValue = ADC_GetConversionValue(ADC2) * 3000/0xfff;

    if(SENSOR_A_VoltValue > SENSOR_B_VoltValue) {
        sensor_header = 1;
    } else {
        sensor_header = -1;
    }

    DMA_ClearITPendingBit(DMA2_Stream0, DMA_IT_TCIF0);
}
开发者ID:everettqin,项目名称:mts,代码行数:12,代码来源:stm32f4xx_it.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: ADC_IRQHandler

void ADC_IRQHandler(void) {

    //ADC_ClearFlag(ADC1,ADC_FLAG_EOC);
    __IO uint16_t SENSOR_A_VoltValue = ADC_GetConversionValue(ADC1) * 3000/0xfff;
    __IO uint16_t SENSOR_B_VoltValue = ADC_GetConversionValue(ADC2) * 3000/0xfff;

    if(SENSOR_A_VoltValue > SENSOR_B_VoltValue) {
        sensor_header = 1;
    } else {
        sensor_header = -1;
    }

}
开发者ID:everettqin,项目名称:mts,代码行数:13,代码来源:stm32f4xx_it.c

示例9: Get_ADC_Voltage

int Get_ADC_Voltage(ADC_TypeDef* ADCx)
{
	AD_value=ADC_GetConversionValue(ADCx);		//读取ADC转换出的值
	Precent = (AD_value*100/4096);			    //算出百分比
	Voltage = Precent*33;						//3.3V的电平,计算等效电平
	return(Voltage);
}
开发者ID:Meekdai,项目名称:Air_mouse,代码行数:7,代码来源:adc.c

示例10: 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

示例11: main

/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f0xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f0xx.c file
     */ 

  /* ADC Configuration */
  ADC_Config();
  /* LCD Display init  */
  Display_Init();
    
  /* Infinite loop */
  while (1)
  {
    /* Test EOC flag */
    while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET);
    
    /* Get ADC1 converted data */
    ADC1ConvertedValue =ADC_GetConversionValue(ADC1);
    
    /* Compute the voltage */
    ADC1ConvertedVoltage = (ADC1ConvertedValue *3300)/0xFFF;
    
    /* Display converted data on the LCD */
    Display();
  }
}
开发者ID:Lee-Kevin,项目名称:MotorBridgeCapeFirmwareSourceCode,代码行数:35,代码来源:main.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: sampleADC

char sampleADC(void)
{
    char res = 0x0;

    CLK_PeripheralClockConfig(CLK_Peripheral_ADC1, ENABLE);
    ADC_DeInit(ADC1);

    ADC_VrefintCmd(ENABLE);
    delay_10us(3);

    ADC_Cmd(ADC1, ENABLE);
    ADC_Init(ADC1, ADC_ConversionMode_Single,
             ADC_Resolution_6Bit, ADC_Prescaler_1);

    ADC_SamplingTimeConfig(ADC1, ADC_Group_SlowChannels, ADC_SamplingTime_9Cycles);
    ADC_ChannelCmd(ADC1, ADC_Channel_0, ENABLE);
    delay_10us(3);

    ADC_SoftwareStartConv(ADC1);
    while( ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == 0);
    res = (char)ADC_GetConversionValue(ADC1);

    ADC_VrefintCmd(DISABLE);
    ADC_DeInit(ADC1);

    /* disable SchmittTrigger for ADC_Channel_24, to save power */
    //ADC_SchmittTriggerConfig(ADC1, ADC_Channel_24, DISABLE);

    CLK_PeripheralClockConfig(CLK_Peripheral_ADC1, DISABLE);
    ADC_ChannelCmd(ADC1, ADC_Channel_0, DISABLE);

    return res;
}
开发者ID:david1mdavis,项目名称:SnapOnControls,代码行数:33,代码来源:main.c

示例14: adc_lightsensor

uint16_t adc_lightsensor(void) {
  digitalWrite(ADC_LIGHTSENSOR_ENABLE, HIGH);
  ADC_SoftwareStartConv(ADC2);
  while(ADC_GetSoftwareStartConvStatus(ADC2));
  return ADC_GetConversionValue(ADC2);
  digitalWrite(ADC_LIGHTSENSOR_ENABLE, LOW);
}
开发者ID:stg,项目名称:SmartWatch_Toolchain,代码行数:7,代码来源:driver_adc.c

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