本文整理汇总了C++中ADC_RegularChannelConfig函数的典型用法代码示例。如果您正苦于以下问题:C++ ADC_RegularChannelConfig函数的具体用法?C++ ADC_RegularChannelConfig怎么用?C++ ADC_RegularChannelConfig使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ADC_RegularChannelConfig函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Get_Adc
u16 Get_Adc(u8 ch)
{
ADC_RegularChannelConfig(ADC1,ch,1,ADC_SampleTime_239Cycles5);
ADC_SoftwareStartConvCmd(ADC1,ENABLE);
while(!ADC_GetFlagStatus(ADC1,ADC_FLAG_EOC));
return ADC_GetConversionValue(ADC1);
}
示例2: readADC1
uint16_t readADC1(uint8_t channel)
{
ADC_RegularChannelConfig(ADC1, channel, 1, ADC_SampleTime_7Cycles5);
// Start the conversion
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
// Wait until conversion completion
while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET);
// Get the conversion value
return ADC_GetConversionValue(ADC1);
}
示例3: ADC_Config
/**************************************************************/
//程 序 名: ADC_Config()
//开 发 者: chenhonglin
//入口参数: 无
//功能说明: ADC配置
//**************************************************************/
void ADC_Config(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
ADC_InitTypeDef ADC_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1 | RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3 ; // PC2 -> AD_SIG1 PC3-> AD_SIG2
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
GPIO_Init(GPIOC, &GPIO_InitStructure);
//ADC1 configuration
//select continuous conversion mode
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
//We will convert multiple channels
ADC_InitStructure.ADC_ScanConvMode = ENABLE;
//we will convert one time
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;//
//select no external triggering
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
//right 12-bit data alignment in ADC data register
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
//2 channels conversion
ADC_InitStructure.ADC_NbrOfChannel = 2;
//load structure values to control and status registers
ADC_Init(ADC1, &ADC_InitStructure);
//configure each channel
ADC_RegularChannelConfig(ADC1, ADC_Channel_12, 1, ADC_SampleTime_41Cycles5);
ADC_RegularChannelConfig(ADC1, ADC_Channel_13, 2, ADC_SampleTime_41Cycles5);
//Enable ADC1
ADC_Cmd(ADC1, ENABLE);
//enable DMA for ADC
ADC_DMACmd(ADC1, ENABLE);
//Enable ADC1 reset calibration register
ADC_ResetCalibration(ADC1);
//Check the end of ADC1 reset calibration register
while (ADC_GetResetCalibrationStatus(ADC1));
//Start ADC1 calibration
ADC_StartCalibration(ADC1);
//Check the end of ADC1 calibration
while (ADC_GetCalibrationStatus(ADC1));
}
示例4: Touch_ADC1_Configuration
/**************************************************************************************
Func: 四线触摸端口配置
Time: 2014-6-18
Ver.: V1.0
Note;
**************************************************************************************/
void Touch_ADC1_Configuration(void)
{
ADC_InitTypeDef ADC_InitStructure;
ADC_DeInit(ADC1); //将外设 ADC1 的全部寄存器重设为缺省值
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent; //ADC工作模式:ADC1和ADC2工作在独立模式
ADC_InitStructure.ADC_ScanConvMode =ENABLE; //模数转换工作在扫描模式
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; //模数转换工作在连续转换模式
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None; //外部触发转换关闭
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; //ADC数据右对齐
ADC_InitStructure.ADC_NbrOfChannel =TOUCH_ADC_CHN; //顺序进行规则转换的ADC通道的数目
ADC_Init(ADC1, &ADC_InitStructure); //根据ADC_InitStruct中指定的参数初始化外设ADCx的寄存器
ADC_RegularChannelConfig(ADC1, ADC_Channel_14, 1, ADC_SampleTime_239Cycles5);
ADC_RegularChannelConfig(ADC1, ADC_Channel_15, 2, ADC_SampleTime_239Cycles5);
ADC_Cmd(ADC1, ENABLE); //使能指定的ADC1
ADC_ResetCalibration(ADC1); //复位指定的ADC1的校准寄存器
while(ADC_GetResetCalibrationStatus(ADC1)); //获取ADC1复位校准寄存器的状态,设置状态则等待
ADC_StartCalibration(ADC1); //开始指定ADC1的校准状态
while(ADC_GetCalibrationStatus(ADC1)); //获取指定ADC1的校准程序,设置状态则等待
}
示例5: readADC1
u16 readADC1(u8 channel)
{
/* Start the conversion */
ADC_RegularChannelConfig(ADC1, channel, 1, ADC_SampleTime_1Cycles5);
/* Wait until conversion completion */
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
/* Get the conversion value */
while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET);
return ADC_GetConversionValue(ADC1);
}
示例6: ad_init
void ad_init() {
RCC_PeriphClockCmd(RCC_ADC1, ENABLE);
RCC_PeriphClockCmd(RCC_GPIOC, ENABLE);
init_GPIO(GPIOC, GPIO_Pin_0, GPIO_Mode_AN, GPIO_Fast_Speed, GPIO_OType_PP, GPIO_PuPd_NOPULL);
initCommon_ADC(ADC_Mode_Independent, ADC_Prescaler_Div2, ADC_DMAAccessMode_Disabled, ADC_TwoSamplingDelay_5Cycles);
init_ADC(ADC_Resolution_12b, DISABLE, ENABLE, ADC_ExternalTrigConvEdge_None, ADC_ExternalTrigConv_T1_CC1, ADC_DataAlign_Right, 1);
ADC_Cmd(ADC1,ENABLE);
ADC_RegularChannelConfig(ADC1, ADC_Channel_10, 1, ADC_SampleTime_144Cycles);
}
示例7: Get_Adc
void Get_Adc(uint8_t ch)
{
//清空最近一次ADC转换的结果
ADC_RegularChannelConfig(ADC1, ch, 1, ADC_SampleTime_55Cycles5);
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC ));//等待转换结束
g_usAdcValue = ADC_GetConversionValue(ADC1);
sum_Adc=sum_Adc+g_usAdcValue;
g_usAdcValue=0;
}
示例8: adc
static uint16_t adc( void )
{
ADC_RegularChannelConfig( ADC1, ADC_CHANNEL, 1, ADC_SampleTime_239Cycles5 );
ADC_SoftwareStartConvCmd( ADC1, ENABLE );
while ( ADC_GetFlagStatus( ADC1, ADC_FLAG_EOC ) != SET )
;
uint16_t res;
res = ADC_GetConversionValue( ADC1 );
return res;
}
示例9: ADC1_MODE_Config
void ADC1_MODE_Config(void)
{
DMA_InitTypeDef DMA_InitStructure; //定义一个DMA结构体变量
ADC_InitTypeDef ADC_InitStructure; //定义一个ADC结构体变量
DMA_DeInit(DMA1_Channel1); //开启DMA1的第一通道
DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address;
DMA_InitStructure.DMA_MemoryBaseAddr=(uint32_t)&ADC_ConvertedValue;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; //DMA的转换模式为SRC模式,由外设搬移到内存
DMA_InitStructure.DMA_BufferSize = 1; //DMA缓存大小,1个
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; //接收一次数据后,设备地址禁止后移
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable; //关闭接收一次数据后,目标内存地址后移
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; //定义外设数据宽度为16位
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; //DMA搬移数据尺寸,HalfWord就是为16位
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; //转换模式,循环缓存模式。
DMA_InitStructure.DMA_Priority = DMA_Priority_High; //DMA优先级高
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; //M2M模式禁用
DMA_Init(DMA1_Channel1, &DMA_InitStructure);
/* Enable DMA1 channel1 */
DMA_Cmd(DMA1_Channel1, ENABLE);
ADC_TempSensorVrefintCmd(ENABLE);
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent; //独立的转换模式
ADC_InitStructure.ADC_ScanConvMode = ENABLE;
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfChannel = 1;
ADC_Init(ADC1, &ADC_InitStructure);
/* ADC1 regular channel14 configuration */
ADC_RegularChannelConfig(ADC1, ADC_Channel_16, 1, ADC_SampleTime_239Cycles5);
/* Enable ADC1 DMA */
ADC_DMACmd(ADC1, ENABLE);
/* Enable ADC1 */
ADC_Cmd(ADC1, ENABLE);
/* Enable ADC1 reset calibaration register */
ADC_ResetCalibration(ADC1);
/* Check the end of ADC1 reset calibration register */
while(ADC_GetResetCalibrationStatus(ADC1));
/* Start ADC1 calibaration */
ADC_StartCalibration(ADC1);
/* Check the end of ADC1 calibration */
while(ADC_GetCalibrationStatus(ADC1));
/* Start ADC1 Software Conversion */
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
}
示例10: ADC1_Mode_Config
static void ADC1_Mode_Config(void)
{
DMA_InitTypeDef DMA_InitStructure;
ADC_InitTypeDef ADC_InitStructure;
/* DMA channel1 configuration */
DMA_DeInit(DMA1_Channel1);
DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address;
DMA_InitStructure.DMA_MemoryBaseAddr = (u32)&ADC_ConvertedValue;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
DMA_InitStructure.DMA_BufferSize = 1;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA1_Channel1, &DMA_InitStructure);
DMA_ITConfig(DMA1_Channel1,DMA_IT_TC,ENABLE);
/* Enable DMA channel1 */
DMA_Cmd(DMA1_Channel1, DISABLE);
/* ADC1 configuration */
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent; //独立模式 每个ADC独立工作
ADC_InitStructure.ADC_ScanConvMode = ENABLE; //使用扫描模式 scan位设置
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; // cont位设置 连续转换模式
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None; ;//EXTSEL 选择启动规则通道组转换的外部事件 设置成有软件控制
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; //数据对齐 由软件置位和清楚 这里设置成右对齐
ADC_InitStructure.ADC_NbrOfChannel = 1; //规则通道序列长度 这些位由软件定义在规则通道转换序列中的通道数目 1个转换 指定由多少个通道被转换
ADC_Init(ADC1, &ADC_InitStructure);
/* ADC1 regular channel11 configuration */
ADC_RegularChannelConfig(ADC1, ADC_Channel_9, 1, ADC_SampleTime_55Cycles5); //转换时间是55.5个周期
/* Enable ADC1 DMA */
ADC_DMACmd(ADC1, ENABLE);
/* Enable ADC1 */
ADC_Cmd(ADC1, ENABLE);
/* Enable ADC1 reset calibaration register */
ADC_ResetCalibration(ADC1);
/* Check the end of ADC1 reset calibration register */
while(ADC_GetResetCalibrationStatus(ADC1));
/* Start ADC1 calibaration */
ADC_StartCalibration(ADC1);
/* Check the end of ADC1 calibration */
while(ADC_GetCalibrationStatus(ADC1));
/* Start ADC1 Software Conversion */
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
}
示例11: Get_Adc
u16 Get_Adc(u8 ch)
{
//éè?????¨ADCμ?1??ò×éí¨μà£?ò???DòáD£?2é?ùê±??
ADC_RegularChannelConfig(ADC1, ch, 1, ADC_SampleTime_239Cycles5 ); //ADC1,ADCí¨μà,2é?ùê±???a239.5?ü?ú
ADC_SoftwareStartConvCmd(ADC1, ENABLE); //ê1?ü???¨μ?ADC1μ?èí?t×a?????ˉ1|?ü
while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC ));//μè′y×a???áê?
return ADC_GetConversionValue(ADC1); //·μ??×??üò?′?ADC11??ò×éμ?×a???á1?
}
示例12: Get_Adc
u16 Get_Adc(u8 ch)
{
//设置指定ADC的规则组通道,一个序列,采样时间
ADC_RegularChannelConfig(ADC1, ch, 1, ADC_SampleTime_239Cycles5 ); //ADC1,ADC通道,采样时间为239.5周期
ADC_SoftwareStartConvCmd(ADC1, ENABLE); //使能指定的ADC1的软件转换启动功能
while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC ));//等待转换结束
return ADC_GetConversionValue(ADC1); //返回最近一次ADC1规则组的转换结果
}
示例13: main
int main(void)
{
static unsigned int led_state = 0;
RCC_ClocksTypeDef clockinfo;
RCC_GetClocksFreq(&clockinfo);
// regardless of clock speed this gives us 1000 ticks per second
SysTick_Config(clockinfo.SYSCLK_Frequency / 1000);
int blink_speed_ms = 400;
setup_gpios();
setup_adc();
setup_usart();
setup_button_irqs();
kkputs("hello karl...\n");
uint64_t lasttime = millis();
while (1) {
if (millis() - blink_speed_ms > lasttime) {
if (led_state & 1) {
switch_leds_on();
kkputs("O");
} else {
switch_leds_off();
kkputs("o");
}
led_state ^= 1;
GPIO_TOGGLE(GPIOC, GPIO_Pin_3);
lasttime = millis();
}
if (button_pressed) {
button_pressed = 0;
kkputs("button was pressed!\n");
blink_speed_ms >>= 1;
if (blink_speed_ms <= 50) {
blink_speed_ms = 1000;
}
}
// start and wait for adc to convert...
ADC_RegularChannelConfig(ADC1, ADC_Channel_5, 1, ADC_SampleTime_192Cycles);
ADC_SoftwareStartConv(ADC1);
while (ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == 0)
;
uint16_t pot_val = ADC_GetConversionValue(ADC1);
if (pot_val > 0x700) {
GPIO_HIGH(GPIOA, GPIO_Pin_4);
} else {
GPIO_LOW(GPIOA, GPIO_Pin_4);
}
}
}
示例14: configureADC_Temp
void configureADC_Temp(void)
{
uint32_t ch_index;
/* Enable ADC clock & SYSCFG */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
/* Enable the internal connection of Temperature sensor and with the ADC channels*/
ADC_TempSensorVrefintCmd(ENABLE);
/* Wait until ADC + Temp sensor start */
T_StartupTimeDelay = 1024;
while (T_StartupTimeDelay--);
/* Setup ADC common init struct */
ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div4;
ADC_CommonInit(&ADC_CommonInitStructure);
/* Initialise the ADC1 by using its init structure */
ADC_StructInit(&ADC_InitStructure);
ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b; // Set conversion resolution to 12bit
ADC_InitStructure.ADC_ScanConvMode = ENABLE; // Enable Scan mode (single conversion for each channel of the group)
ADC_InitStructure.ADC_ContinuousConvMode = DISABLE; // Disable Continuous conversion
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConvEdge_None; // Disable external conversion trigger
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; // Set conversion data alignement to right
ADC_InitStructure.ADC_NbrOfConversion = ADC_CONV_BUFF_SIZE; // Set conversion data alignement to ADC_CONV_BUFF_SIZE
ADC_Init(ADC1, &ADC_InitStructure);
/* ADC1 regular Temperature sensor channel16 and internal reference channel17 configuration */
for (ch_index = 1; ch_index <= MAX_TEMP_CHNL; ch_index++) {
ADC_RegularChannelConfig(ADC1, ADC_Channel_16, ch_index,
ADC_SampleTime_384Cycles);
}
ADC_RegularChannelConfig(ADC1, ADC_Channel_17, 17, ADC_SampleTime_384Cycles);
ADC_RegularChannelConfig(ADC1, ADC_Channel_17, 18, ADC_SampleTime_384Cycles);
ADC_RegularChannelConfig(ADC1, ADC_Channel_17, 19, ADC_SampleTime_384Cycles);
ADC_RegularChannelConfig(ADC1, ADC_Channel_17, 20, ADC_SampleTime_384Cycles);
}
示例15: ADC3_Mode_Config
static void ADC3_Mode_Config()
{
ADC_InitTypeDef ADC_InitStructure;
DMA_InitTypeDef DMA_InitStructure;
ADC_DeInit(ADC1); //将外设 ADC1 的全部寄存器重设为缺省值
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent; //ADC工作模式:ADC1和ADC2工作在独立模式
ADC_InitStructure.ADC_ScanConvMode =ENABLE; //模数转换工作在扫描模式
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; //模数转换工作在连续转换模式
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None; //外部触发转换关闭
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; //ADC数据右对齐
ADC_InitStructure.ADC_NbrOfChannel =ADC_CHN; //顺序进行规则转换的ADC通道的数目
ADC_Init(ADC1, &ADC_InitStructure); //根据ADC_InitStruct中指定的参数初始化外设ADCx的寄存器
ADC_RegularChannelConfig(ADC1, ADC_Channel_0, 1, ADC_SampleTime_239Cycles5);
ADC_RegularChannelConfig(ADC1, ADC_Channel_1, 2, ADC_SampleTime_239Cycles5);
ADC_RegularChannelConfig(ADC1, ADC_Channel_2, 3, ADC_SampleTime_239Cycles5);
ADC_Cmd(ADC1, ENABLE); //使能指定的ADC1
ADC_ResetCalibration(ADC1); //复位指定的ADC1的校准寄存器
while(ADC_GetResetCalibrationStatus(ADC1)); //获取ADC1复位校准寄存器的状态,设置状态则等待
ADC_StartCalibration(ADC1); //开始指定ADC1的校准状态
while(ADC_GetCalibrationStatus(ADC1)); //获取指定ADC1的校准程序,设置状态则等待
DMA_DeInit(DMA1_Channel1); //将DMA的通道1寄存器重设为缺省值
DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)&ADC1->DR; //DMA外设ADC基地址
DMA_InitStructure.DMA_MemoryBaseAddr = (u32)&ADCDMA_Value[0][0]; //DMA内存基地址
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; //内存作为数据传输的目的地
DMA_InitStructure.DMA_BufferSize = ADC_BUFSize*ADC_CHN; //DMA通道的DMA缓存的大小
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; //外设地址寄存器不变
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; //内存地址寄存器递增
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; //数据宽度为16位
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; //数据宽度为16位
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; //工作在循环缓存模式
DMA_InitStructure.DMA_Priority = DMA_Priority_High; //DMA通道 x拥有高优先级
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; //DMA通道x没有设置为内存到内存传输
DMA_Init(DMA1_Channel1, &DMA_InitStructure); //根据DMA_InitStruct中指定的参数初始化DMA的通道
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
DMA_Cmd(DMA1_Channel1, ENABLE);
DMA_ITConfig(DMA1_Channel1, DMA_IT_TC, ENABLE);
ADC_DMACmd(ADC1, ENABLE);
}