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

C++ RCC_ADCCLKConfig函数代码示例

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

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



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

示例1: adcInit

void adcInit( void )
{
    // ADC Clock Div.
    RCC_ADCCLKConfig( RCC_PCLK2_Div8 );
    // Turn ADC and appropriate GPIO's clocks on.
    RCC_APB2PeriphClockCmd( ADC_CLK | GPIO_ADC_CLK, ENABLE );
    // Setup GPIO in type.
    GPIO_InitTypeDef init;
    init.GPIO_Pin  = ADC_PIN;
    init.GPIO_Mode = GPIO_Mode_AIN;
    GPIO_Init( GPIO_ADC, &init );
    // Setp ADC.
    ADC_DeInit( ADC1 );
    ADC_InitTypeDef adcInit;
    ADC_StructInit( &adcInit );
    adcInit.ADC_Mode               = ADC_Mode_Independent;
    adcInit.ADC_ContinuousConvMode = DISABLE;
    adcInit.ADC_ExternalTrigConv   = ADC_ExternalTrigConv_None;
    adcInit.ADC_DataAlign          = ADC_DataAlign_Right;
    adcInit.ADC_NbrOfChannel       = 1;
    
    // Now do the setup 
    ADC_Init( ADC1, &adcInit );
    // 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 ) )
        ;
}
开发者ID:glockwork,项目名称:dfu,代码行数:37,代码来源:task_adc.c


示例2: RCC_Config

void RCC_Config(void)
{
  
  RCC_DeInit(); 
  RCC_HSEConfig(RCC_HSE_ON); //Включим внешний генератор
  while (SUCCESS != RCC_WaitForHSEStartUp()); //Подождем запуска генератора
  RCC_PLLCmd(DISABLE); 
  RCC_PLLConfig(RCC_PLLSource_PREDIV1,RCC_PLLMul_12); //Вход ПЛЛ внешний генератор умножим на 12
  RCC_PLLCmd(ENABLE);  
  
  RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);   //Системное тактирование от ПЛЛ
  RCC_HCLKConfig(RCC_SYSCLK_Div1);      //Тактирование AHB с делением 1
  
  RCC_PCLKConfig(RCC_HCLK_Div8);        //Тактирование переферии с делением 8
  RCC_ADCCLKConfig(RCC_ADCCLK_PCLK_Div2);       //Тактирование АЦП
  RCC_I2CCLKConfig(RCC_I2C1CLK_SYSCLK);         //Тактируем шину I2C от системного тактирования
  RCC_USARTCLKConfig(RCC_USART1CLK_PCLK);       //Тактируем UART от шини  переферии
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA + RCC_AHBPeriph_GPIOB,ENABLE);
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1 + RCC_APB2Periph_USART1 + RCC_APB2Periph_TIM1 + RCC_APB2Periph_TIM15, ENABLE);
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);

  RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE);
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM14, ENABLE);
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
#ifdef MCO_ENABLE
  GPIOA_Struct_init.GPIO_Pin = GPIO_Pin_8;
  GPIOA_Struct_init.GPIO_Mode = GPIO_Mode_AF;
  GPIOA_Struct_init.GPIO_Speed = GPIO_Speed_Level_2;
  GPIOA_Struct_init.GPIO_OType = GPIO_OType_PP;
  GPIO_Init(GPIOA,&GPIOA_Struct_init);
  RCC_MCOConfig(RCC_MCOSource_SYSCLK);
  while (1);
#else
  RCC_MCOConfig(RCC_MCOSource_NoClock);
#endif /*MCO_ENABLE  */
};
开发者ID:avr-master,项目名称:M-02-15003,代码行数:37,代码来源:main.c


示例3: SysInitRCC

void SysInitRCC( void )
{
  // System clock is set by the SystemInit-function, called by the startup-file before main is called.
  // So, when correctly configured in system_stm32f10x.c, the system runs at HSE 8 MHz, using PLL to create 72 MHz SystemClock

  // ADCCLK = PCLK2/<divider>
  // PCLK2 runs @72 MHz, ADCCLK can be max. 14 MHz
  RCC_ADCCLKConfig(RCC_PCLK2_Div6);


  /* Enable AHB periphs */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE);

  /* Enable APB1 periphs */
  RCC_APB1PeriphClockCmd( RCC_APB1Periph_USART2, ENABLE );

  /* Enable APB2 periphs */
  RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA, ENABLE );
  RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB, ENABLE );
  RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOC, ENABLE );
  RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOD, ENABLE );

  RCC_APB2PeriphClockCmd( RCC_APB2Periph_AFIO, ENABLE ); // for remapping purposes
}
开发者ID:sorrowed,项目名称:STM32-FreeRTOS-LCD,代码行数:24,代码来源:SysInit.c


示例4: adc_init

/**
 * @brief Initialize an ADC peripheral.
 *
 * Initializes the RCC clock line for the given peripheral.  Resets
 * ADC device registers.
 *
 * @param dev ADC peripheral to initialize
 */
void adc_init(const adc_dev *dev) {

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

	dev->clkcmd(dev->clk, ENABLE);

	ADC_DeInit(dev->ADCx);

	RCC_ADCCLKConfig(RCC_PCLK2_Div6);

	/* ADCx Init ****************************************************************/
	ADC_InitTypeDef ADC_InitStructure;
	ADC_StructInit(&ADC_InitStructure);
	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(dev->ADCx, &ADC_InitStructure);
}
开发者ID:136048599,项目名称:vrgimbal,代码行数:32,代码来源:adc.c


示例5: thermcoupleIOinit

/*
 * =====================================================================================
 *
 *       Filename:  thermcouple.c
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  2013/3/23 20:10:37
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  RY (good lucky), [email protected]
 *   Organization:  
 *
 * =====================================================================================
 */
#include "thermcouple.h"

uint16_t oldTemparture;
void thermcoupleIOinit(void)/*{{{*/
{
	GPIO_InitTypeDef GPIO_InitStructure;
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);	   //GPIOB时钟
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;		   //口线翻转速度为50MHz
	
	GPIO_InitStructure.GPIO_Pin = ThermcoupleSck_Pin;
	GPIO_Init(ThermcoupleSck_Port, &GPIO_InitStructure);
	GPIO_InitStructure.GPIO_Pin = ThermcoupleCs_Pin;
	GPIO_Init(ThermcoupleCs_Port, &GPIO_InitStructure);

//	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
	GPIO_InitStructure.GPIO_Pin = ThermcoupleDo_Pin;
	GPIO_Init(ThermcoupleDo_Port, &GPIO_InitStructure);
	oldTemparture=25;
}/*}}}*/
uint16_t thermcoupleReadTemp(void)/*{{{*/
{
	uint16_t data=0;
	uint8_t i,result;
	bool badTemperature=false;
	bool haveData=false;
	GPIO_ResetBits(ThermcoupleSck_Port,ThermcoupleSck_Pin);
	GPIO_ResetBits(ThermcoupleCs_Port,ThermcoupleCs_Pin);
	delay_us(20);
	for(i=0;i<16;i++)
	{
		GPIO_SetBits(ThermcoupleSck_Port,ThermcoupleSck_Pin);
		delay_us(1);
		if(i>=1 && i<11)
		{
			data=data<<1;
			if(GPIO_ReadInputDataBit(ThermcoupleDo_Port,ThermcoupleDo_Pin))
			{
				data=data|0x01;
				haveData=true;
			}
		}
		if(i==13)
		{
			if(GPIO_ReadInputDataBit(ThermcoupleDo_Port,ThermcoupleDo_Pin))
				badTemperature=true;
		}
		delay_us(1);
		GPIO_ResetBits(ThermcoupleSck_Port,ThermcoupleSck_Pin);
		delay_us(2);
	}
	GPIO_SetBits(ThermcoupleCs_Port,ThermcoupleCs_Pin);
	delay_us(20);
	GPIO_ResetBits(ThermcoupleSck_Port,ThermcoupleSck_Pin);
	if(badTemperature)
	{
		data=oldTemparture;
	}
	else
	{
	}
	return data;
}/*}}}*/
void thermistorIOinit(void)/*{{{*/
{
	GPIO_InitTypeDef GPIO_InitStructure;
	ADC_InitTypeDef  ADC_InitStructure;

	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);	   //GPIOC时钟

	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;		   //口线翻转速度为50MHz
	
	GPIO_InitStructure.GPIO_Pin = HeaterBoardTherm_Pin;
	GPIO_Init(HeaterBoardTherm_Port,&GPIO_InitStructure);	


	RCC_ADCCLKConfig(RCC_CFGR_ADCPRE_DIV6);//ADC时钟PLCK2的6分频 12M。ADC最大时钟不能超过14M!
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
	ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;//工作在独立模式
	ADC_InitStructure.ADC_ScanConvMode = ENABLE; //使能扫描
	ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;//ADC转换工作在连续模式
//.........这里部分代码省略.........
开发者ID:madcc,项目名称:code_wlf,代码行数:101,代码来源:thermcouple.c


示例6: ADC_Configuration

void ADC_Configuration(void) 
{ 
    ADC_InitTypeDef ADC_InitStructure; 
    
    /* PCLK2 is the APB2 clock */ 
    /* ADCCLK = PCLK2/6 = 72/6 = 12MHz*/ 
    RCC_ADCCLKConfig(RCC_PCLK2_Div6); 
    
    /* Enable ADC1 clock so that we can talk to it */ 
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE); 
    
    /* Put everything back to power-on defaults */ 
    ADC_DeInit(ADC1); 
    
    /* ADC1 Configuration ------------------------------------------------------*/ 
    ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;                    /* ADC1 and ADC2 operate independently */
    ADC_InitStructure.ADC_ScanConvMode = DISABLE;                         /* Disable the scan conversion so we do one at a time */ 
    ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;                   /* Don't do contimuous conversions - do them on demand */
    ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;   /* Start conversin by software, not an external trigger */ 
    ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;                /* Conversions are 12 bit - put them in the lower 12 bits of the result */ 
    ADC_InitStructure.ADC_NbrOfChannel = 1;                               /* Say how many channels would be used by the sequencer */ 
    ADC_Init(ADC1, &ADC_InitStructure);                                   /* Now do the setup */ 
    ADC_Cmd(ADC1, ENABLE);                                                /* Enable ADC1 */ 
    
    /* 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)); 
}
开发者ID:MBARM,项目名称:MatchboxARM,代码行数:36,代码来源:main.c


示例7: BSP_Init

void  BSP_Init (void)
{
    BSP_IntInit();

    RCC_DeInit();
    RCC_HSEConfig(RCC_HSE_ON);
    RCC_WaitForHSEStartUp();


    RCC_HCLKConfig(RCC_SYSCLK_Div1);
    RCC_PCLK2Config(RCC_HCLK_Div1);
    RCC_PCLK1Config(RCC_HCLK_Div2);
    RCC_ADCCLKConfig(RCC_PCLK2_Div6);
    FLASH_SetLatency(FLASH_Latency_2);
    FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
    RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
    RCC_PLLCmd(ENABLE);

    while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) {
        ;
    }

    RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

    while (RCC_GetSYSCLKSource() != 0x08) {
        ;
    }

    BSP_ADC_Init();                                             /* Initialize the I/Os for the ADC      controls.       */
    BSP_LED_Init();                                             /* Initialize the I/Os for the LED      controls.       */
    BSP_PB_Init();                                              /* Initialize the I/Os for the PB       control.        */
    BSP_Joystick_Init();                                        /* Initialize the I/Os for the Joystick control.        */

    STM3210E_LCD_Init();
    LCD_Clear(0xFFFF);
}
开发者ID:CaryHWSZ,项目名称:Linux,代码行数:36,代码来源:bsp.c


示例8: adc1_mode_config

static void adc1_mode_config( void)
{
	DMA_InitTypeDef dma_init_structure;
	ADC_InitTypeDef adc_init_structure;

	/* 复位 ADC1,将与DMA有关的寄存器设我初始值; */ 
	DMA_DeInit( DMA1_Channel1);
	/*定义DMA外设基地址, 这里的ADC1_DR_Address 是用户自己定义的,即为存放转换结果的寄存器; 
	,他的作用就是告诉DMA取数就到ADC1_DR_Address 这里来取。;*/
	dma_init_structure.DMA_PeripheralBaseAddr = ADC1_DR_ADDRESS;
	/*定义内存基地址,即告诉DMA要将从AD中取来的数放到ADC_ConvertedValue中 ;*/
	dma_init_structure.DMA_MemoryBaseAddr = ( uint32_t)&s_adc1_converted_value;
	/*定义AD外设作为数据传输的来源,即告诉DMA是将AD中的数据取出放到内存中,不能反过来;*/
	dma_init_structure.DMA_DIR = DMA_DIR_PeripheralSRC;

	/*指定DMA通道的DMA缓存的大小,即告诉DMA开辟几个内存空间,由于我们只取通道10的AD数据所以只需开辟一个内存空间;*/
	dma_init_structure.DMA_BufferSize = 1;

	//dma_init_structure.DMA_BufferSize = 2;
	/*设定寄存器地址固定,即告诉DMA,只从固定的一个地方取数;*/ 
	dma_init_structure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
	/*设定内存地址固定,即每次DMA,,只将数搬到固定的内存中;*/ 
	dma_init_structure.DMA_MemoryInc = DMA_MemoryInc_Disable;
	/*设定内存地址递加,即每次DMA都是将该外设寄存器中的值传到两个内存空间中;*/ 
	//DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;


	/*设定外设数据宽度,即告诉DMA要取的数的大小,半字(16位);*/
	dma_init_structure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
	 /*设定内存的的宽度;*/
	dma_init_structure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
	/*设定DMA工作再循环缓存模式,即告诉DMA要不停的搬运,不能偷懒;*/ 
	dma_init_structure.DMA_Mode = DMA_Mode_Circular;
	 /*设定DMA选定的通道软件优先级;*/
	dma_init_structure.DMA_Priority = DMA_Priority_High;
	dma_init_structure.DMA_M2M = DMA_M2M_Disable;
	DMA_Init( DMA1_Channel1, &dma_init_structure);

	DMA_Cmd( DMA1_Channel1, ENABLE);

	/* ADC1 configuration */
	/*设置ADC工作在独立模式;*/
	adc_init_structure.ADC_Mode = ADC_Mode_Independent;
	/*规定AD转换工作在扫描模式,即对多个通道采样;*/ 
	//ADC_InitStructure.ADC_ScanConvMode = ENABLE

	/*规定AD转换工作在单次模式,即对一个通道采样;*/
	adc_init_structure.ADC_ScanConvMode = DISABLE;
	/*设定AD转化在连续模式;*/
	adc_init_structure.ADC_ContinuousConvMode = ENABLE;
	/*不使用外部促发转换;*/
	adc_init_structure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
	/*采集的数据在寄存器中以右对齐的方式存放;*/
	adc_init_structure.ADC_DataAlign = ADC_DataAlign_Right;
	/*设定要转换的AD通道数目;*/
	adc_init_structure.ADC_NbrOfChannel = 1;
	//adc_init_structure.ADC_NbrOfChannel = 2;

	ADC_Init( ADC1, &adc_init_structure);
	/*配置ADC时钟,为PCLK2的8分频,即9MHz;*/ 
	RCC_ADCCLKConfig( RCC_PCLK2_Div8);
	/*配置ADC1的通道11为55.5个采样周期; */
	ADC_RegularChannelConfig( ADC1,ADC_Channel_10,1,ADC_SampleTime_55Cycles5);
	//ADC_RegularChannelConfig( ADC1,ADC_Channel_11,1,ADC_SampleTime_55Cycles5);


	ADC_DMACmd( ADC1, ENABLE);
	ADC_Cmd( ADC1, ENABLE);

	ADC_ResetCalibration( ADC1);

	while( ADC_GetResetCalibrationStatus( ADC1) );

	ADC_StartCalibration( ADC1);
	while( ADC_GetCalibrationStatus( ADC1));
	/* 由于没有采用外部触发,所以使用软件触发ADC转换; */ 
	ADC_SoftwareStartConvCmd( ADC1, ENABLE);


}
开发者ID:cross-sky,项目名称:stm32,代码行数:80,代码来源:Tadc.c


示例9: RCC_Configuration

/**
  * @brief  Configures the different system clocks.
  * @param  None
  * @retval None
  */
void RCC_Configuration(void)
{
  /* RCC system reset(for debug purpose) */
  RCC_DeInit();

  /* Enable HSE */
  RCC_HSEConfig(RCC_HSE_ON);

  /* Wait till HSE is ready */
  HSEStartUpStatus = RCC_WaitForHSEStartUp();

  if(HSEStartUpStatus == SUCCESS)
  {
    /* Enable Prefetch Buffer */
    FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);

    /* Flash 2 wait state */
    FLASH_SetLatency(FLASH_Latency_2);
	
    /* HCLK = SYSCLK */
    RCC_HCLKConfig(RCC_SYSCLK_Div1); 
  
    /* PCLK2 = HCLK */
    RCC_PCLK2Config(RCC_HCLK_Div1); 

    /* PCLK1 = HCLK/2 */
    RCC_PCLK1Config(RCC_HCLK_Div2);

    /* ADCCLK = PCLK2/4 */
    RCC_ADCCLKConfig(RCC_PCLK2_Div4); 
  
#ifndef STM32F10X_CL  
    /* PLLCLK = 8MHz * 7 = 56 MHz */
    RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_7);

#else
    /* Configure PLLs *********************************************************/
    /* PLL2 configuration: PLL2CLK = (HSE / 5) * 8 = 40 MHz */
    RCC_PREDIV2Config(RCC_PREDIV2_Div5);
    RCC_PLL2Config(RCC_PLL2Mul_8);

    /* Enable PLL2 */
    RCC_PLL2Cmd(ENABLE);

    /* Wait till PLL2 is ready */
    while (RCC_GetFlagStatus(RCC_FLAG_PLL2RDY) == RESET)
    {}

    /* PLL configuration: PLLCLK = (PLL2 / 5) * 7 = 56 MHz */ 
    RCC_PREDIV1Config(RCC_PREDIV1_Source_PLL2, RCC_PREDIV1_Div5);
    RCC_PLLConfig(RCC_PLLSource_PREDIV1, RCC_PLLMul_7);
#endif

    /* Enable PLL */ 
    RCC_PLLCmd(ENABLE);

    /* Wait till PLL is ready */
    while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
    {
    }

    /* Select PLL as system clock source */
    RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

    /* Wait till PLL is used as system clock source */
    while(RCC_GetSYSCLKSource() != 0x08)
    {
    }
  }

/* Enable peripheral clocks --------------------------------------------------*/
  /* Enable ADC1 and GPIO_LED clock */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
}
开发者ID:phungyen,项目名称:stm32f10x_stdperiph_lib,代码行数:79,代码来源:main.c


示例10: RCC_Configuration

/**
  * @brief  Configures the different system clocks.
  * @param  None
  * @retval None
  */
void RCC_Configuration(void)
{
  /* RCC system reset(for debug purpose) */
  RCC_DeInit();

  /* Enable HSE */
  RCC_HSEConfig(RCC_HSE_ON);

  /* Wait till HSE is ready */
  HSEStartUpStatus = RCC_WaitForHSEStartUp();

  if(HSEStartUpStatus == SUCCESS)
  {
    /* Enable Prefetch Buffer */
    FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);

    /* Flash 2 wait state */
    FLASH_SetLatency(FLASH_Latency_2);
	
    /* HCLK = SYSCLK */
    RCC_HCLKConfig(RCC_SYSCLK_Div1); 
  
    /* PCLK2 = HCLK */
    RCC_PCLK2Config(RCC_HCLK_Div1); 

    /* PCLK1 = HCLK/2 */
    RCC_PCLK1Config(RCC_HCLK_Div2);

    /* ADCCLK = PCLK2/4 */
    RCC_ADCCLKConfig(RCC_PCLK2_Div4); 
  
#ifndef STM32F10X_CL  
    /* PLLCLK = 8MHz * 9 = 72 MHz */
    RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);

#else
    /* Configure PLLs *********************************************************/
    /* PLL2 configuration: PLL2CLK = (HSE / 5) * 8 = 40 MHz */
    RCC_PREDIV2Config(RCC_PREDIV2_Div5);
    RCC_PLL2Config(RCC_PLL2Mul_8);

    /* Enable PLL2 */
    RCC_PLL2Cmd(ENABLE);

    /* Wait till PLL2 is ready */
    while (RCC_GetFlagStatus(RCC_FLAG_PLL2RDY) == RESET)
    {}

    /* PLL configuration: PLLCLK = (PLL2 / 5) * 9 = 72 MHz */ 
    RCC_PREDIV1Config(RCC_PREDIV1_Source_PLL2, RCC_PREDIV1_Div5);
    RCC_PLLConfig(RCC_PLLSource_PREDIV1, RCC_PLLMul_9);

    /* PPL3 configuration: PLL3CLK = (HSE / 5) * 11 = PLL3_VCO = 110 MHz */
    RCC_PLL3Config(RCC_PLL3Mul_11);
    /* Enable PLL3 */
    RCC_PLL3Cmd(ENABLE);    
    /* Wait till PLL3 is ready */
    while (RCC_GetFlagStatus(RCC_FLAG_PLL3RDY) == RESET)
    {}

    /* Configure I2S clock source: On Connectivity-Line Devices, the I2S can be 
        clocked by PLL3 VCO instead of SYS_CLK in order to guarantee higher 
        precision */
    RCC_I2S3CLKConfig(RCC_I2S3CLKSource_PLL3_VCO);
    RCC_I2S2CLKConfig(RCC_I2S2CLKSource_PLL3_VCO);  
#endif

    /* Enable PLL */ 
    RCC_PLLCmd(ENABLE);

    /* Wait till PLL is ready */
    while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
    {
    }

    /* Select PLL as system clock source */
    RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

    /* Wait till PLL is used as system clock source */
    while(RCC_GetSYSCLKSource() != 0x08)
    {
    }
  }  
  
  /* Enable peripheral clocks --------------------------------------------------*/
  /* GPIOA, GPIOB and AFIO clocks enable */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |
                         RCC_APB2Periph_AFIO, ENABLE);

#ifdef USE_STM3210C_EVAL 
  /* GPIOC Clock enable (for the SPI3 remapped pins)  */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC , ENABLE);  
#endif /* USE_STM3210C_EVAL */  
  
  /* SPI2 and SPI3 clocks enable */
//.........这里部分代码省略.........
开发者ID:EvanLind,项目名称:WingProject,代码行数:101,代码来源:main.c


示例11: adcInit

void adcInit(drv_adc_config_t *init)
{
#if defined(CJMCU) || defined(CC3D)
    UNUSED(init);
#endif


    uint8_t i;
    uint8_t configuredAdcChannels = 0;

    memset(&adcConfig, 0, sizeof(adcConfig));

    GPIO_InitTypeDef GPIO_InitStructure;
    GPIO_StructInit(&GPIO_InitStructure);
    GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AIN;

#ifdef ADC1_GPIO
    if (init->channelMask & ADC_CHANNEL1_ENABLE) {
        GPIO_InitStructure.GPIO_Pin = ADC1_GPIO_PIN;
        GPIO_Init(ADC1_GPIO, &GPIO_InitStructure);
        adcConfig[ADC_CHANNEL_1].adcChannel = ADC1_CHANNEL;
        adcConfig[ADC_CHANNEL_1].dmaIndex = configuredAdcChannels++;
        adcConfig[ADC_CHANNEL_1].enabled = true;
        adcConfig[ADC_CHANNEL_1].sampleTime = ADC_SampleTime_239Cycles5;
    }
#endif

#ifdef ADC2_GPIO
    if (init->channelMask & ADC_CHANNEL2_ENABLE) {
        GPIO_InitStructure.GPIO_Pin = ADC2_GPIO_PIN;
        GPIO_Init(ADC2_GPIO, &GPIO_InitStructure);
        adcConfig[ADC_CHANNEL_2].adcChannel = ADC2_CHANNEL;
        adcConfig[ADC_CHANNEL_2].dmaIndex = configuredAdcChannels++;
        adcConfig[ADC_CHANNEL_2].enabled = true;
        adcConfig[ADC_CHANNEL_2].sampleTime = ADC_SampleTime_239Cycles5;
    }
#endif

#ifdef ADC3_GPIO
    if (init->channelMask & ADC_CHANNEL3_ENABLE) {
        GPIO_InitStructure.GPIO_Pin = ADC3_GPIO_PIN;
        GPIO_Init(ADC3_GPIO, &GPIO_InitStructure);
        adcConfig[ADC_CHANNEL_3].adcChannel = ADC3_CHANNEL;
        adcConfig[ADC_CHANNEL_3].dmaIndex = configuredAdcChannels++;
        adcConfig[ADC_CHANNEL_3].enabled = true;
        adcConfig[ADC_CHANNEL_3].sampleTime = ADC_SampleTime_239Cycles5;
    }
#endif

#ifdef ADC4_GPIO
    if (init->channelMask & ADC_CHANNEL4_ENABLE) {
        GPIO_InitStructure.GPIO_Pin   = ADC4_GPIO_PIN;
        GPIO_Init(ADC4_GPIO, &GPIO_InitStructure);
        adcConfig[ADC_CHANNEL_4].adcChannel = ADC4_CHANNEL;
        adcConfig[ADC_CHANNEL_4].dmaIndex = configuredAdcChannels++;
        adcConfig[ADC_CHANNEL_4].enabled = true;
        adcConfig[ADC_CHANNEL_4].sampleTime = ADC_SampleTime_239Cycles5;
    }
#endif

    RCC_ADCCLKConfig(RCC_PCLK2_Div8);  // 9MHz from 72MHz APB2 clock(HSE), 8MHz from 64MHz (HSI)
    RCC_AHBPeriphClockCmd(ADC_AHB_PERIPHERAL, ENABLE);
    RCC_APB2PeriphClockCmd(ADC_ABP2_PERIPHERAL, ENABLE);

    // FIXME ADC driver assumes all the GPIO was already placed in 'AIN' mode

    DMA_DeInit(ADC_DMA_CHANNEL);
    DMA_InitTypeDef DMA_InitStructure;
    DMA_StructInit(&DMA_InitStructure);
    DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&ADC_INSTANCE->DR;
    DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)adcValues;
    DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
    DMA_InitStructure.DMA_BufferSize = configuredAdcChannels;
    DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
    DMA_InitStructure.DMA_MemoryInc = configuredAdcChannels > 1 ? DMA_MemoryInc_Enable : 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(ADC_DMA_CHANNEL, &DMA_InitStructure);
    DMA_Cmd(ADC_DMA_CHANNEL, ENABLE);

    ADC_InitTypeDef ADC_InitStructure;
    ADC_StructInit(&ADC_InitStructure);
    ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
    ADC_InitStructure.ADC_ScanConvMode = configuredAdcChannels > 1 ? ENABLE : DISABLE;
    ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
    ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
    ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
    ADC_InitStructure.ADC_NbrOfChannel = configuredAdcChannels;
    ADC_Init(ADC_INSTANCE, &ADC_InitStructure);

    uint8_t rank = 1;
    for (i = 0; i < ADC_CHANNEL_COUNT; i++) {
        if (!adcConfig[i].enabled) {
            continue;
        }
        ADC_RegularChannelConfig(ADC_INSTANCE, adcConfig[i].adcChannel, rank++, adcConfig[i].sampleTime);
    }
//.........这里部分代码省略.........
开发者ID:180jacob,项目名称:cleanflight,代码行数:101,代码来源:adc_stm32f10x.c


示例12: BSP_Init

void  BSP_Init (void)
{
  USART_InitTypeDef USART_InitStructure;
  /* USARTx configuration ------------------------------------------------------*/
  /* USARTx configured as follow:
        - BaudRate = 115200 baud  
        - Word Length = 8 Bits
        - One Stop Bit
        - No parity
        - Hardware flow control disabled (RTS and CTS signals)
        - Receive and transmit enabled
  */
  USART_InitStructure.USART_BaudRate = 9600;
  USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  USART_InitStructure.USART_StopBits = USART_StopBits_1;
  USART_InitStructure.USART_Parity = USART_Parity_No ;
  USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
  USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;

    RCC_DeInit();
    RCC_HSEConfig(RCC_HSE_ON);
    RCC_WaitForHSEStartUp();

    RCC_HCLKConfig(RCC_SYSCLK_Div1);
    RCC_PCLK2Config(RCC_HCLK_Div1);
    RCC_PCLK1Config(RCC_HCLK_Div2);
    RCC_ADCCLKConfig(RCC_PCLK2_Div6);

	RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);

    FLASH_SetLatency(FLASH_Latency_2);
    FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);

    RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
    RCC_PLLCmd(ENABLE);

    while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) {
        ;
    }

    RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

    while (RCC_GetSYSCLKSource() != 0x08) {
        ;
    }


/*
SCU_AHBPeriphClockConfig(__VIC,ENABLE);

//VIC_DeInit();
VIC_Config(UART1_ITLine, VIC_IRQ, 15);
VIC_ITCmd(UART1_ITLine, ENABLE);
*/


    BSP_ADC_Init();                                             /* Initialize the I/Os for the ADC      controls.       */
    BSP_LED_Init();                                             /* Initialize the I/Os for the LED      controls.       */
	BSP_PB_Init();                                              		/* Initialize the I/Os for the PB       control.        */
   // BSP_Joystick_Init();                                        /* Initialize the I/Os for the Joystick control. 		 */
	GPIO_Configuration();
	USART_Init(USART1,&USART_InitStructure); 
	USART_Cmd(USART1, ENABLE);   
	UART2_int();
}
开发者ID:weekihowyee,项目名称:UCOSII,代码行数:66,代码来源:bsp.c


示例13: SampleChannel_Init

void SampleChannel_Init()
{
  NVIC_InitTypeDef NVIC_InitStructure;
  TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
  ADC_InitTypeDef ADC_InitStructure;
  DMA_InitTypeDef DMA_InitStructure;
  GPIO_InitTypeDef GPIO_InitStructure;

  NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel1_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA| RCC_APB2Periph_AFIO, ENABLE);
  GPIO_InitStructure.GPIO_Pin = ADC_CHANNEL10_PIN | ADC_CHANNEL11_PIN
      | ADC_CHANNEL12_PIN | ADC_CHANNEL14_PIN;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; //端口模式为模拟输入方式
  GPIO_Init(ADC_PORT, &GPIO_InitStructure);

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM8, ENABLE);
  TIM_DeInit(TIM8);
  TIM_TimeBaseStructure.TIM_Period = 1000000 / 1000 - 1;
  TIM_TimeBaseStructure.TIM_Prescaler = 71;
  TIM_TimeBaseStructure.TIM_ClockDivision = 0x0;
  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
  TIM_TimeBaseInit(TIM8, &TIM_TimeBaseStructure);
  TIM_SelectOutputTrigger(TIM8, TIM_TRGOSource_Update);

  RCC_ADCCLKConfig(RCC_PCLK2_Div6);
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
  GPIO_PinRemapConfig(GPIO_Remap_ADC1_ETRGREG, ENABLE);
  ADC_DeInit(ADC1);
  ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
  ADC_InitStructure.ADC_ScanConvMode = ENABLE;
  ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
  ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_Ext_IT11_TIM8_TRGO;
  ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
  ADC_InitStructure.ADC_NbrOfChannel = 4;
  ADC_Init(ADC1, &ADC_InitStructure);
  ADC_RegularChannelConfig(ADC1, ADC_Channel_14, 1, ADC_SampleTime_71Cycles5);
  ADC_RegularChannelConfig(ADC1, ADC_Channel_14, 2, ADC_SampleTime_71Cycles5);
  ADC_RegularChannelConfig(ADC1, ADC_Channel_14, 3, ADC_SampleTime_71Cycles5);
  ADC_RegularChannelConfig(ADC1, ADC_Channel_14, 4, ADC_SampleTime_71Cycles5);
  ADC_DiscModeChannelCountConfig(ADC1, 1);
  ADC_DiscModeCmd(ADC1, ENABLE);
  ADC_DMACmd(ADC1, ENABLE);
  ADC_Cmd(ADC1, ENABLE);
  ADC_ResetCalibration(ADC1);
  while (ADC_GetResetCalibrationStatus(ADC1))
    ;
  ADC_StartCalibration(ADC1);
  while (ADC_GetCalibrationStatus(ADC1))
    ;
  ADC_ExternalTrigConvCmd(ADC1, ENABLE);

  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
  DMA_DeInit(DMA1_Channel1);
  DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_ADDRESS;
  DMA_InitStructure.DMA_MemoryBaseAddr = (u32) (&ADCBuff);
  DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
  DMA_InitStructure.DMA_BufferSize = ADCNUM;
  DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
  DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
  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_Medium;
  DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
  DMA_Init(DMA1_Channel1, &DMA_InitStructure);
  DMA_ClearFlag(DMA1_IT_TC1 | DMA1_IT_HT1);
  DMA_ITConfig(DMA1_Channel1, DMA_IT_TC | DMA_IT_HT, ENABLE);
  DMA_Cmd(DMA1_Channel1, ENABLE);
}
开发者ID:Richard--Wang,项目名称:heartlab,代码行数:74,代码来源:sample.c


示例14: ADC_DMA_Init

/*
 * @brief Initialize the ADC peripheral.
 */
void ADC_DMA_Init()
{
	//Using "Dual Slow Interleaved ADC Mode" to achieve higher input impedance

	ADC_InitTypeDef ADC_InitStructure;
	DMA_InitTypeDef DMA_InitStructure;

	// ADCCLK = PCLK2/6 = 72/6 = 12MHz
	RCC_ADCCLKConfig(RCC_PCLK2_Div6);

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

	// Enable ADC1 and ADC2 clock
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1 | RCC_APB2Periph_ADC2, ENABLE);

	// DMA1 channel1 configuration
	DMA_DeInit(DMA1_Channel1);
	DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)ADC1_DR_ADDRESS;
	DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&ADC_DualConvertedValues;
	DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
	DMA_InitStructure.DMA_BufferSize = ADC_DMA_BUFFERSIZE;
	DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
	DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
	DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word;
	DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Word;
	DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
	DMA_InitStructure.DMA_Priority = DMA_Priority_High;
	DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
	DMA_Init(DMA1_Channel1, &DMA_InitStructure);

	// ADC1 configuration
	ADC_InitStructure.ADC_Mode = ADC_Mode_SlowInterl;
	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(ADC1, &ADC_InitStructure);

	// ADC2 configuration
	ADC_InitStructure.ADC_Mode = ADC_Mode_SlowInterl;
	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(ADC2, &ADC_InitStructure);

	// Enable ADC1
	ADC_Cmd(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));

	// Enable ADC2
	ADC_Cmd(ADC2, ENABLE);

	// Enable ADC2 reset calibration register
	ADC_ResetCalibration(ADC2);

	// Check the end of ADC2 reset calibration register
	while(ADC_GetResetCalibrationStatus(ADC2));

	// Start ADC2 calibration
	ADC_StartCalibration(ADC2);

	// Check the end of ADC2 calibration
	while(ADC_GetCalibrationStatus(ADC2));
}
开发者ID:BaSSraf,项目名称:core-firmware,代码行数:82,代码来源:spark_wiring.cpp


示例15: ADC1_Mode_Config

/* 函数名:ADC1_Mode_Config
 * 描述  :配置ADC1的工作模式为MDA模式
 * 输入  : 无
 * 输出  :无
 * 调用  :内部调用
 */
static void ADC1_Mode_Config(void)
{
	DMA_InitTypeDef DMA_InitStructure;
	ADC_InitTypeDef ADC_InitStructure;

	/* DMA channel1 configuration */
		   
  DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address;		        // 外设基地址
  DMA_InitStructure.DMA_MemoryBaseAddr = (u32)&ADC_ConvertedValue;	        // AD转换值所存放的内存基地址	(就是给个地址)
  DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;                        // 外设作为数据传输的来源	
  DMA_InitStructure.DMA_BufferSize = 1;                                     // 定义指定DMA通道 DMA缓存的大小
  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;         // 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);
  
  /* Enable DMA channel1 */
  DMA_Cmd(DMA1_Channel1, ENABLE);											//ENABLE她

  /* ADC1 configuration */
  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;					//Right
  ADC_InitStructure.ADC_NbrOfChannel = 1;				                    //仅一个通道转换
  ADC_Init(ADC1, &ADC_InitStructure);
	
  	/*配置ADC时钟,为PCLK2的8分频,即9Hz*/
	RCC_ADCCLKConfig(RCC_PCLK2_Div8); 

  /* ADC1 regular channel16 configuration */ 
  //设置采样通道IN16, 设置采样时间
  ADC_RegularChannelConfig(ADC1, ADC_Channel_16, 1, ADC_SampleTime_239Cycles5);	

  //使能温度传感器和内部参考电压   
  ADC_TempSensorVrefintCmd(ENABLE);                                    

   /* 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:daguoze,项目名称:Slave_Control_code1.19,代码行数:67,代码来源:tempad.c


示例16: RCC_Configuration

/********************************************************************************************************
* 函 数 名 : RCC_Configuration()
* 描    述 : 系统、外围设备时钟初始化
* 输入参数 : None.
* 输出参数 : None.
* 返   回  : None.
********************************************************************************************************/
void RCC_Configuration(void)
{   /* RCC system reset(for debug purpose) */
    ErrorStatus HSEStartUpStatus;
    
    RCC_DeInit();
    
    /* Enable HSE */
    RCC_HSEConfig(RCC_HSE_ON);
    RCC_LSEConfig(RCC_LSE_OFF); 

    /* Wait till HSE is ready */
    HSEStartUpStatus = RCC_WaitForHSEStartUp();
    
    if(HSEStartUpStatus == SUCCESS)
    {
        /* Enable Prefetch Buffer */
        FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
        /* Flash 2 wait state */
        FLASH_SetLatency(FLASH_Latency_2);
        
        /* HCLK = SYSCLK */
        RCC_HCLKConfig(RCC_SYSCLK_Div1);
        
        /* PCLK2 = HCLK */
        RCC_PCLK2Config(RCC_HCLK_Div1);
        
        /* PCLK1 = HCLK/4 */
        RCC_PCLK1Config(RCC_HCLK_Div2);
        
        /* PLLCLK = 8MHz * 9 = 72 MHz */
        RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
        
        /* ADCCLK = PCLK2/4 */
	RCC_ADCCLKConfig(RCC_PCLK2_Div8);

        
        /* Enable PLL */
        RCC_PLLCmd(ENABLE);
        
        /* Wait till PLL is ready */
        while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
        {
        }
        
        /* Select PLL as system clock source */
        RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
        
        /* Wait till PLL is used as system clock source */
        while(RCC_GetSYSCLKSource() != 0x08)
        {
        }
    }
    /* GPIO clock enable */
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB| RCC_APB2Periph_GPIOC 
                           | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE |RCC_APB2Periph_GPIOF|RCC_APB2Periph_GPIOG, ENABLE);
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4,ENABLE); 
    /* Enable AFIO clocks */
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
    
    /* TIM2 clock enable */
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);    
    /* TIM3 clock enable */
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
    /* TIM4 clock enable */
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);
    /* TIM5 clock enable */
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM5, ENABLE);
    /* TIM6 clock enable */
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM6, ENABLE);
    /* TIM7 clock enable */
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM7, ENABLE);
    
    /* USART1 clock enable */
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE);  
    /* USART2 clock enable */
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE);
    /* USART3 clock enable */
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3,ENABLE);
    
    /* Enable I2C1 clocks */
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE);
    
    /* Enable ADC2 clock */
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC2, ENABLE);
}
开发者ID:cquxutao,项目名称:Competition,代码行数:92,代码来源:BoardInit.c


示例17: Task_Led2

//----------------------------------------
static  void Task_Led2(void* p_arg)//负责采集电压
{
	GPIO_InitTypeDef GPIO_InitStructure;

	ADC_InitTypeDef ADC_InitStructure;
	DMA_InitTypeDef DMA_InitStructure;
  
	INT16U shu[4]={0}; 
	INT16U *s; 

	vu16 ADC_ConvertedValue;
	RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1 | RCC_APB2Periph_GPIOA, ENABLE);
	/* Configure PC.04 (ADC Channel14) as analog input -------------------------*/
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
	GPIO_Init(GPIOA, &GPIO_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 = 2;
	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);	
	/* Enable DMA channel1 */
	//DMA_Cmd(DMA1_Channel1, ENABLE);	
	/* ADC1 configuration ------------------------------------------------------*/
	ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;					//独立模式  CR1
	ADC_InitStructure.ADC_ScanConvMode = ENABLE;						    //扫描模式使能
	ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;					//连续转换模式使能
	ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;	//启动转换的外部事件--无  CR2
	ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;				//转换后的数据右对齐
	ADC_InitStructure.ADC_NbrOfChannel = 1;								//转换的通道数为1
	ADC_Init(ADC1, &ADC_InitStructure);

	/* ADCCLK = PCLK2/4 */
	RCC_ADCCLKConfig(RCC_PCLK2_Div6); 
	/* ADC1 regular channel14 configuration */ 
	ADC_RegularChannelConfig(ADC1, ADC_Channel_0, 1, ADC_SampleTime_55Cycles5);	  	//通道10采样时间														  
	//ADC_DMACmd(ADC1, ENABLE);		                          						  //允许ADC1进行DMA传送	
	/* Enable ADC1 */
	ADC_Cmd(ADC1, ENABLE);														  //使能ADC1	
	/* Enable ADC1 reset ca 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ RCC_AHB1PeriphClockCmd函数代码示例发布时间:2022-05-30
下一篇:
C++ RCBA32函数代码示例发布时间: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