本文整理汇总了C++中ADC_RegularChannelConfig函数的典型用法代码示例。如果您正苦于以下问题:C++ ADC_RegularChannelConfig函数的具体用法?C++ ADC_RegularChannelConfig怎么用?C++ ADC_RegularChannelConfig使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ADC_RegularChannelConfig函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:CQUT-AC,项目名称:AC_Project_Flower,代码行数:10,代码来源:adc.c
示例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);
}
开发者ID:Laurenceb,项目名称:Dactyl,代码行数:10,代码来源:adc.c
示例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));
}
开发者ID:sunzhongmeng,项目名称:ufun-demo,代码行数:49,代码来源:ADC.c
示例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的校准程序,设置状态则等待
}
开发者ID:RTOS-Developers,项目名称:TRTOS,代码行数:25,代码来源:Touch_Driver.c
示例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);
}
开发者ID:MBARM,项目名称:MatchboxARM,代码行数:10,代码来源:main.c
示例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);
}
开发者ID:linilss,项目名称:Sound-system-DAT290,代码行数:10,代码来源:grundsystem.c
示例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;
}
开发者ID:Jeansfirm,项目名称:glexer_HDPLC_COAXIAL,代码行数:10,代码来源:main.c
示例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;
}
开发者ID:glockwork,项目名称:dfu,代码行数:10,代码来源:task_adc.c
示例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);
}
开发者ID:cquxutao,项目名称:Competition,代码行数:55,代码来源:adc.c
示例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);
}
开发者ID:YANGXINZHE,项目名称:1.5FLY,代码行数:55,代码来源:ADC.c
示例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?
}
开发者ID:li77leprince,项目名称:Laparoscopic,代码行数:11,代码来源:adc_dma.c
示例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规则组的转换结果
}
开发者ID:SxxSxx,项目名称:Slave_basketball_arm_controller,代码行数:11,代码来源:BSP.c
示例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);
}
}
}
开发者ID:TuniLame,项目名称:stm32-linux,代码行数:54,代码来源:main.c
示例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);
}
开发者ID:powenko,项目名称:STM32L152C-Discovery-SampleCode,代码行数:41,代码来源:main.c
示例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);
}
开发者ID:RTOS-Developers,项目名称:TRTOS,代码行数:41,代码来源:ADC_Driver.c
示例16: SENSOR_ADC_Init
void SENSOR_ADC_Init(void) {
ADC_InitTypeDef ADC_InitStructure;
ADC_CommonInitTypeDef ADC_CommonInitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1 | RCC_APB2Periph_ADC2, ENABLE);
/* ADC Common configuration *************************************************/
ADC_CommonInitStructure.ADC_Mode = ADC_DualMode_Interl;
ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_5Cycles;
ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_2;
ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2;
ADC_CommonInit(&ADC_CommonInitStructure);
/* ADC1 regular channel 12 configuration ************************************/
ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
ADC_InitStructure.ADC_ScanConvMode = DISABLE;
ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
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_Init(ADC2, &ADC_InitStructure);
ADC_RegularChannelConfig(ADC1, ADC_Channel_12, 1, ADC_SampleTime_3Cycles);
ADC_RegularChannelConfig(ADC2, ADC_Channel_13, 1, ADC_SampleTime_3Cycles);
/* Enable DMA request after last transfer (multi-ADC mode) ******************/
ADC_MultiModeDMARequestAfterLastTransferCmd(ENABLE);
/* Enable ADC **************************************************************/
ADC_Cmd(ADC1, ENABLE);
ADC_Cmd(ADC2, ENABLE);
/* Enable DMA2 Stream0 Transfer complete interrupt */
DMA_ITConfig(DMA2_Stream0, DMA_IT_TC, ENABLE);
/* Enable ADC1 DMA since ADC1 is the Master*/
ADC_DMACmd(ADC1, ENABLE);
}
开发者ID:everettqin,项目名称:mts,代码行数:41,代码来源:sensor.c
示例17: ds_therm_init
void ds_therm_init(void) {
//Initialization
RCC_ADCCLKConfig(RCC_ADC12PLLCLK_Div2);
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_ADC12, ENABLE);
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOF, ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOF, &GPIO_InitStructure);
//Enable the ADC’s voltage regulator and wait for it to stabilize
ADC_VoltageRegulatorCmd(ADC1, ENABLE);
ADC_TempSensorCmd(ADC1, ENABLE);
ds_delay_uS(10);
//Initialize the parameters that are common to all of the A2D Channels
ADC_CommonInitTypeDef ADC_CommonInitStructure;
ADC_CommonStructInit(&ADC_CommonInitStructure);
ADC_CommonInitStructure.ADC_Mode=ADC_Mode_Independent;
ADC_CommonInitStructure.ADC_Clock = ADC_Clock_AsynClkMode;
ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;
ADC_CommonInitStructure.ADC_DMAMode = ADC_DMAMode_OneShot;
ADC_CommonInitStructure.ADC_TwoSamplingDelay = 0;
ADC_CommonInit(ADC1, &ADC_CommonInitStructure);
//Initialize the parameters specific to channel 10
ADC_InitTypeDef ADC_InitStructure;
ADC_StructInit(&ADC_InitStructure);
ADC_InitStructure.ADC_ContinuousConvMode = ADC_ContinuousConvMode_Enable;
ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
ADC_InitStructure.ADC_ExternalTrigConvEvent = ADC_ExternalTrigConvEvent_0;
ADC_InitStructure.ADC_ExternalTrigEventEdge = ADC_ExternalTrigEventEdge_None;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_OverrunMode = ADC_OverrunMode_Disable;
ADC_InitStructure.ADC_AutoInjMode = ADC_AutoInjec_Disable;
ADC_InitStructure.ADC_NbrOfRegChannel = 1;
ADC_Init(ADC1, &ADC_InitStructure);
//Configure the specific ADC, channel, and timing
ADC_RegularChannelConfig(ADC1, ADC_Channel_16, 1, ADC_SampleTime_7Cycles5);
//Enable the ADC and wait for it to become ready.
ADC_Cmd(ADC1, ENABLE);
while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_RDY));
//Start the first conversion
ADC_StartConversion(ADC1);
}
开发者ID:fwgrange,项目名称:BotanicalBuddy,代码行数:53,代码来源:ds_therm.c
示例18: halInternalInitAdc
void halInternalInitAdc(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
ADC_InitTypeDef ADC_InitStructure;
//Configure TEMP_ENABLE GPIO as push-pull output, defaulting to active/on
GPIO_WriteBit(TEMP_ENABLE_PORT, TEMP_ENABLE_PIN, Bit_SET);
GPIO_InitStructure.GPIO_Pin = TEMP_ENABLE_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(TEMP_ENABLE_PORT, &GPIO_InitStructure);
//Configure TEMP_SENSE GPIO as analog input
GPIO_InitStructure.GPIO_Pin = TEMP_SENSOR_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(TEMP_SENSOR_PORT, &GPIO_InitStructure);
//Divide down the APB2 clock (72MHz) to get an ADC clock of 12MHz (<= 14MHz)
RCC_ADCCLKConfig(RCC_PCLK2_Div6);
//Configure ADC to be in independent, single conversion mode
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_InitStructure.ADC_ScanConvMode = DISABLE;
ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfChannel = 1;
ADC_Init(TEMP_SENSOR_ADC, &ADC_InitStructure);
//Configure sample times to longest (recommended for temp measure)
ADC_RegularChannelConfig(TEMP_SENSOR_ADC,
TEMP_SENSOR_ADC_CHAN,
1,
ADC_SampleTime_239Cycles5);
//Enable ADC
ADC_Cmd(TEMP_SENSOR_ADC, ENABLE);
//Reset ADC calibration registers
ADC_ResetCalibration(TEMP_SENSOR_ADC);
//Wait for cal reset to complete
while(ADC_GetResetCalibrationStatus(TEMP_SENSOR_ADC) == SET) {}
//Calibrate the ADC
ADC_StartCalibration(TEMP_SENSOR_ADC);
//Wait for cal to complete
while(ADC_GetCalibrationStatus(TEMP_SENSOR_ADC) == SET) {}
//This driver does not use interrupts; it's purely polling.
}
开发者ID:umangparekh,项目名称:thread_apps,代码行数:53,代码来源:adc.c
示例19: ADC1_GetValue
/*******************************************************************************
* 函 数 名:
* 功 能:
* 参 数:
* 返 回:
*******************************************************************************/
uint16_t ADC1_GetValue(uint8_t channel)
{
//设置指定ADC的规则组通道,设置它们的转化顺序和采样时间
//ADC1,ADC通道3,规则采样顺序值为1,采样时间为239.5周期
ADC_RegularChannelConfig(ADC1, channel, 1, ADC_SampleTime_239Cycles5 );
//使能指定的ADC1的软件转换启动功能
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
//等待转换结束
while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC ));
//返回最近一次ADC1规则组的转换结果
return ADC_GetConversionValue(ADC1);
}
开发者ID:tixlegeek,项目名称:STM32F103RBT6,代码行数:18,代码来源:adc.c
示例20: ADCManager_Structure
void ADCManager_Structure(ADCManagerTypeDef *ADCManager)
{
ADC_InitTypeDef ADC_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
u8 i;
defaultADCManager=ADCManager;
defaultADCManager->getData=ADCManager_getData;
defaultADCManager->startTransfer=ADCManager_startTransfer;
//defaultADCManager->ADC_Channels_num=sizeof(defaultADCManager->ADC_Channels);
RCC_APB2PeriphClockCmd(filterGPIO_RCC_ADC() | RCC_APB2Periph_ADC1 , ENABLE ); //使能ADC1通道时钟
RCC_ADCCLKConfig(RCC_PCLK2_Div6); //设置ADC分频因子6 72M/6=12,ADC最大时间不能超过14M
for(i=0;i<defaultADCManager->ADC_Channels_num;i++)
{
if(defaultADCManager->ADC_Channels[i]==ADC_Channel_16|defaultADCManager->ADC_Channels[i]==ADC_Channel_17)
continue;
GPIO_InitStructure.GPIO_Pin = filterPin_ADC(defaultADCManager->ADC_Channels[i]);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; //模拟输入引脚
GPIO_Init(filterGPIO_ADC(defaultADCManager->ADC_Channels[i]), &GPIO_InitStructure);
}
ADC_DeInit(ADC1); //复位ADC1,将外设 ADC1 的全部寄存器重设为缺省值
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent; //ADC工作模式:ADC1和ADC2工作在独立模式
ADC_InitStructure.ADC_ScanConvMode = ENABLE; //模数转换工作在单通道模式
ADC_InitStructure.ADC_ContinuousConvMode = (FunctionalState)defaultADCManager->isContinus; //模数转换工作在单次转换模式
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None; //转换由软件而不是外部触发启动
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; //ADC数据右对齐
ADC_InitStructure.ADC_NbrOfChannel = defaultADCManager->ADC_Channels_num; //顺序进行规则转换的ADC通道的数目
ADC_Init(ADC1, &ADC_InitStructure); //根据ADC_InitStruct中指定的参数初始化外设ADCx的寄存器
for(i=0;i<defaultADCManager->ADC_Channels_num;i++)
{
if(defaultADCManager->ADC_Channels[i]==ADC_Channel_16|defaultADCManager->ADC_Channels[i]==ADC_Channel_17)
ADC_TempSensorVrefintCmd(ENABLE);
ADC_RegularChannelConfig(ADC1, defaultADCManager->ADC_Channels[i], i+1, ADC_SampleTime_239Cycles5 ); //ADC1,ADC通道,采样时间为239.5周期
}
ADC_DMA_Config();
ADC_DMACmd(ADC1, ENABLE);
ADC_Cmd(ADC1, ENABLE); //使能指定的ADC1
ADC_ResetCalibration(ADC1); //使能复位校准
while(ADC_GetResetCalibrationStatus(ADC1)); //等待复位校准结束
ADC_StartCalibration(ADC1); //开启AD校准
while(ADC_GetCalibrationStatus(ADC1)); //等待校准结束
}
开发者ID:2cats,项目名称:STM32,代码行数:53,代码来源:ADCManager.c
注:本文中的ADC_RegularChannelConfig函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论