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


C++ TIM_TimeBaseStructInit函数代码示例

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


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

示例1: ENC1_Init

void ENC1_Init(void)
{
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2,ENABLE);
    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
  
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 ;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
    GPIO_Init(GPIOA, &GPIO_InitStructure);
  
    GPIO_PinAFConfig(GPIOA,GPIO_PinSource0,GPIO_AF_TIM2);
    
    /*NVIC_InitStructure.NVIC_IRQChannel = TIM4_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);*/
    
    /* Timer configuration in Encoder mode */ 
    TIM_DeInit(TIM2);
    TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
  
    TIM_TimeBaseStructure.TIM_Prescaler = 0x0; // No prescaling 
    TIM_TimeBaseStructure.TIM_Period = 40000-1; 
    TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
    TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;   
    TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
  
    TIM_EncoderInterfaceConfig(TIM2, TIM_EncoderMode_TI1,TIM_ICPolarity_Rising, TIM_ICPolarity_Rising);
    TIM_ICStructInit(&TIM_ICInitStructure);
    TIM_ICInitStructure.TIM_ICFilter = 0xe;
    TIM_ICInit(TIM2, &TIM_ICInitStructure);
  
    // Clear all pending interrupts
    TIM_ClearFlag(TIM2, TIM_FLAG_Update);
    TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE);
    TIM_SetCounter(TIM2,0);
    TIM2->CNT = 0;
    TIM_Cmd(TIM2, ENABLE);
}
开发者ID:lc641777437,项目名称:Wind-pendulum,代码行数:42,代码来源:encoder.c

示例2: DacInitDmaAndTimer

static void DacInitDmaAndTimer()
{
	uint32_t prescaler;
	uint32_t period;
	prescaler = 1;
	period = (3500)/2;

	DMA_InitTypeDef DMA_InitStructure;
	DMA_InitStructure.DMA_Channel = DMA_Channel_7;
	DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&DAC->DHR12R1;
	DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)&g_sinusBuffer;
	DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral;
	DMA_InitStructure.DMA_BufferSize = SinusBufferSize;
	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_High;
	DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;         
	DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull;
	DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
	DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;

	DMA_Init(DMA1_Stream5, &DMA_InitStructure);	
	DMA_Cmd(DMA1_Stream5, ENABLE);
	DAC_Cmd(DAC_Channel_1, ENABLE);
	DAC_DMACmd(DAC_Channel_1, ENABLE);

	//168 MHz / TIM_Prescaler / TIM_Period
	TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
	TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
	TIM_TimeBaseStructure.TIM_Period = period-1;
	TIM_TimeBaseStructure.TIM_Prescaler = prescaler-1;
	TIM_TimeBaseStructure.TIM_ClockDivision = 0;
	TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
	TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
	//TIM_SetCounter(TIM2, 0);
	TIM_SelectOutputTrigger(TIM2, TIM_TRGOSource_Update);

	g_dac_period = period * prescaler * SinusBufferSize;
}
开发者ID:alxsh,项目名称:balmer-usb-sdr,代码行数:42,代码来源:dac.c

示例3: TIM2_Config

void TIM2_Config(void)
{
  TIM_TimeBaseInitTypeDef    TIM_TimeBaseStructure;
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
  TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
  
  TIM_TimeBaseStructure.TIM_Period = 60000000/8000;
  TIM_TimeBaseStructure.TIM_Prescaler = 7;
  
  TIM_TimeBaseStructure.TIM_ClockDivision = 0;
  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
  TIM_TimeBaseStructure.TIM_RepetitionCounter = 0;
  TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
  TIM_SelectOutputTrigger(TIM2, TIM_TRGOSource_Update);
  TIM_ITConfig(TIM2,TIM2_IRQn, ENABLE);  
  NVIC_EnableIRQ(TIM2_IRQn);  
  
  TIM_Cmd(TIM2, ENABLE);
  
}
开发者ID:TSURKOVSERGEY,项目名称:sdi,代码行数:20,代码来源:config.c

示例4: TIM2_Configuration

// Set sample Time via recieve Command
// Set ADC Channel numbers via recieve Command
void TIM2_Configuration(void)
{ 
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
  
  TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
 
  /* Time base configuration */
  TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);               //500000
  TIM_TimeBaseStructure.TIM_Period = (84000000 / 200000) - 1; // 200 KHz, from 84 MHz TIM2CLK (ie APB1 = HCLK/4, TIM2CLK = HCLK/2)
  TIM_TimeBaseStructure.TIM_Prescaler = 0;
  TIM_TimeBaseStructure.TIM_ClockDivision = 0;
  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
  TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
 
  /* TIM2 TRGO selection */
  TIM_SelectOutputTrigger(TIM2, TIM_TRGOSource_Update); // ADC_ExternalTrigConv_T2_TRGO
 
  /* TIM2 enable counter */
  TIM_Cmd(TIM2, ENABLE);
}
开发者ID:yallawalla,项目名称:stm32,代码行数:22,代码来源:tripleadc.c

示例5: PIOS_DELAY_Init

int32_t PIOS_DELAY_Init(void)
{
	/* Enable timer clock */
	PIOS_DELAY_TIMER_RCC_FUNC;

	/* Time base configuration */
	TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
	TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
	TIM_TimeBaseStructure.TIM_Period = 65535; // maximum value
	TIM_TimeBaseStructure.TIM_Prescaler = 72-1; // for 1 uS accuracy fixed to 72Mhz
	TIM_TimeBaseStructure.TIM_ClockDivision = 0;
	TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
	TIM_TimeBaseInit(PIOS_DELAY_TIMER, &TIM_TimeBaseStructure);

	/* Enable counter */
	TIM_Cmd(PIOS_DELAY_TIMER, ENABLE);

	/* No error */
	return 0;
}
开发者ID:CorvusCorax,项目名称:my_OpenPilot_mods,代码行数:20,代码来源:pios_delay.c

示例6: TIM6_Config

/**
  * @brief  TIM6 Configuration
  * @note   TIM6 configuration is based on CPU @168MHz and APB1 @42MHz
  * @note   TIM6 Update event occurs each 37.5MHz/256 = 16.406 KHz    
  * @param  None
  * @retval None
  */
void TIM6_Config(void)
{
  TIM_TimeBaseInitTypeDef    TIM_TimeBaseStructure;
  /* TIM6 Periph clock enable */
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM6, ENABLE);

  /* Time base configuration */
  TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
  TIM_TimeBaseStructure.TIM_Period = 0xFF;
  TIM_TimeBaseStructure.TIM_Prescaler = 0;
  TIM_TimeBaseStructure.TIM_ClockDivision = 0;
  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; 
  TIM_TimeBaseInit(TIM6, &TIM_TimeBaseStructure);

  /* TIM6 TRGO selection */
  TIM_SelectOutputTrigger(TIM6, TIM_TRGOSource_Update);
  
  /* TIM6 enable counter */
  TIM_Cmd(TIM6, ENABLE);
}
开发者ID:0x00f,项目名称:STM32F4-Discovery-Firmware,代码行数:27,代码来源:main.c

示例7: adc_init_rcc

/* Configure and enable RCC for peripherals (ADC1, ADC2, Timer) */
static inline void adc_init_rcc( void )
{ // {{{
#if defined (USE_AD1) || defined (USE_AD2)
    TIM_TypeDef * timer;
    uint32_t rcc_apb;
#if defined(USE_AD_TIM4)
    timer   = TIM4;
    rcc_apb = RCC_APB1Periph_TIM4;
#elif defined(USE_AD_TIM1)
    timer   = TIM1;
    rcc_apb = RCC_APB2Periph_TIM1;
#else
    timer   = TIM2;
    rcc_apb = RCC_APB1Periph_TIM2;
#endif

    TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;

    RCC_ADCCLKConfig(RCC_PCLK2_Div2);
    RCC_APB1PeriphClockCmd(rcc_apb, ENABLE);
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB |
                   RCC_APB2Periph_GPIOC, ENABLE);
#ifdef USE_AD1
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
#endif
#ifdef USE_AD2
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC2, ENABLE);
#endif

    /* Time Base configuration */
    TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
    TIM_TimeBaseStructure.TIM_Period        = 0xFF;
    TIM_TimeBaseStructure.TIM_Prescaler     = 0x8;
    TIM_TimeBaseStructure.TIM_ClockDivision = 0x0;
    TIM_TimeBaseStructure.TIM_CounterMode   = TIM_CounterMode_Up;
    TIM_TimeBaseInit(timer, &TIM_TimeBaseStructure);
    TIM_SelectOutputTrigger(timer, TIM_TRGOSource_Update);
    TIM_Cmd(timer, ENABLE);

#endif // defined (USE_AD1) || defined (USE_AD2)
} // }}}
开发者ID:AntoineBlais,项目名称:paparazzi,代码行数:42,代码来源:adc_hw.c

示例8: TIM6_Config

/*
*********************************************************************************************************
*	函 数 名: TIM6_Config
*	功能说明: 配置定时器6,用于触发DAC。
*	形    参: 无
*	返 回 值: 无
*********************************************************************************************************
*/
void TIM6_Config(void)
{
    TIM_TimeBaseInitTypeDef    TIM_TimeBaseStructure;
    
     /* 使能TIM6时钟 */
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM6, ENABLE);
    
    /* --------------------------------------------------------
    system_stm32f4xx.c 文件中 void SetSysClock(void) 函数对时钟的配置如下:

    HCLK = SYSCLK / 1     (AHB1Periph)
    PCLK2 = HCLK / 2      (APB2Periph)
    PCLK1 = HCLK / 4      (APB1Periph)

    因为APB1 prescaler != 1, 所以 APB1上的TIMxCLK = PCLK1 x 2 = SystemCoreClock / 2;
    因为APB2 prescaler != 1, 所以 APB2上的TIMxCLK = PCLK2 x 2 = SystemCoreClock;

    APB1 定时器有 TIM2, TIM3 ,TIM4, TIM5, TIM6, TIM7, TIM12, TIM13, TIM14
    APB2 定时器有 TIM1, TIM8 ,TIM9, TIM10, TIM11
          
    TIM6 更新周期是 = TIM6CLK / (TIM_Period + 1)/(TIM_Prescaler + 1)
	根据如下的配置,更新周期是:
	TIM6CLK / (TIM_Period + 1)/(TIM_Prescaler + 1)
	= 84MHz /(55+1)/(0+1)
	= 1.5MHz
    ----------------------------------------------------------- */
    
    /* 配置TIM6 */
    TIM_TimeBaseStructInit(&TIM_TimeBaseStructure); 
    TIM_TimeBaseStructure.TIM_Period = 83;          
    TIM_TimeBaseStructure.TIM_Prescaler = 0;       
    TIM_TimeBaseStructure.TIM_ClockDivision = 0;    
    TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;  
    TIM_TimeBaseInit(TIM6, &TIM_TimeBaseStructure);

    /* TIM6 TRGO 选择 */
    TIM_SelectOutputTrigger(TIM6, TIM_TRGOSource_Update);

    /* 使能TIM6 */
    TIM_Cmd(TIM6, ENABLE);   
}
开发者ID:hyq19921011,项目名称:MyScop_GUI3.98,代码行数:49,代码来源:bsp_dac.c

示例9: BSP_Timer_Init

void BSP_Timer_Init()
{
	NVIC_InitTypeDef NVICInit;

	RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM5, ENABLE);

	NVICInit.NVIC_IRQChannel = TIM5_IRQn;
	NVICInit.NVIC_IRQChannelPreemptionPriority = 2;
	NVICInit.NVIC_IRQChannelSubPriority = 0;
	NVICInit.NVIC_IRQChannelCmd = ENABLE;
	NVIC_Init(&NVICInit);

	TIM_TimeBaseStructInit(&TIMInit);
	TIMInit.TIM_Prescaler = 0;
	TIMInit.TIM_CounterMode = TIM_CounterMode_Up;
	TIMInit.TIM_Period = 0;
	TIMInit.TIM_ClockDivision = TIM_CKD_DIV1;
	TIM_TimeBaseInit(TIM5, &TIMInit);

	TIM_InternalClockConfig(TIM5);
}
开发者ID:FarK,项目名称:CyclePOV-ASTR,代码行数:21,代码来源:bsp_timer.c

示例10: tim_init

//------------------------------------------------------------------------------
void tim_init(void)
{

	TIM_TimeBaseInitTypeDef timInit;
	NVIC_InitTypeDef        nvicInit;

	RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);

	TIM_TimeBaseStructInit(&timInit);
	timInit.TIM_Period = 10000;  // ms  = 10 sec
	timInit.TIM_Prescaler = (uint16_t) (SystemCoreClock / 1000) - 1;
	TIM_TimeBaseInit(TIM2, &timInit);

	nvicInit.NVIC_IRQChannel = TIM2_IRQn;
	nvicInit.NVIC_IRQChannelPriority = 3;
	nvicInit.NVIC_IRQChannelCmd = ENABLE;
	NVIC_Init(&nvicInit);
 
	TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE);
	TIM_Cmd(TIM2, ENABLE);
}
开发者ID:j-a-r-i,项目名称:stm32,代码行数:22,代码来源:main.c

示例11: TS_Init

void TS_Init()
{
	TS_SPIx = TS_HAL_Init();
	spi_init(TS_SPIx, 32);

	// timer for request touch coords time by time
	RCC_ClocksTypeDef clocks;
	RCC_GetClocksFreq(&clocks);
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM5, ENABLE);

	TIM_TimeBaseInitTypeDef timer_struct;
	TIM_TimeBaseStructInit(&timer_struct);
	timer_struct.TIM_Period = 999;
	timer_struct.TIM_Prescaler = (clocks.SYSCLK_Frequency/TOUCH_UPDATE_FREQUENCY/(timer_struct.TIM_Period+1)) - 1; // 10 Hz
	TIM_TimeBaseInit(TIM5, &timer_struct);
	TIM_ITConfig(TIM5, TIM_IT_Update, ENABLE);
	TIM_Cmd(TIM5, DISABLE);

	NVIC_EnableIRQ(TIM5_IRQn);
	NVIC_SetPriority(TIM5_IRQn, TS_IRQ_PRIORITY);
}
开发者ID:Nikolay-Kha,项目名称:GUILib,代码行数:21,代码来源:tsc2046.c

示例12: TIM_Config

/**
  * @brief  Configures the TIM2
  * @param  None
  * @retval None
  */
void TIM_Config(void)
{
  TIM_TimeBaseInitTypeDef    TIM_TimeBaseStructure;

  /* TIM2 Periph clock enable */
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);

  /* Time base configuration */
  TIM_TimeBaseStructInit(&TIM_TimeBaseStructure); 
  TIM_TimeBaseStructure.TIM_Period = 0x19;          
  TIM_TimeBaseStructure.TIM_Prescaler = 0x0;       
  TIM_TimeBaseStructure.TIM_ClockDivision = 0x0;    
  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;  
  TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);

  /* TIM2 TRGO selection: update event is selected as trigger for DAC */
  TIM_SelectOutputTrigger(TIM2, TIM_TRGOSource_Update);

  /* TIM2 enable counter */
  TIM_Cmd(TIM2, ENABLE);
}
开发者ID:RTOS-Developers,项目名称:TRTOS,代码行数:26,代码来源:main.c

示例13: Set_SampRate

/*
*********************************************************************************************************
*	函 数 名: SetSampRate
*	功能说明: 修改采样频率
*	形    参:freq : 采样频率 单位Hz
*	返 回 值: 无
*********************************************************************************************************
*/
static void Set_SampRate(T_DSO *g_DsoA)
{
	/* 第4步: 配置定时器2第2通道CC2, CC2作为ADC1的触发源 */
	TIM_TimeBaseInitTypeDef		TIM_TimeBaseStructure;
	TIM_OCInitTypeDef			TIM_OCInitStructure;
//	uint16_t Period;

	TIM_Cmd(TIM2, DISABLE);

	/*
	采样频率计算公式 :
		period = 72000000 / freq ;
		
		1200 == 60KHz 采样频率
	*/
//	Period = 72000 / freq -1;		

	/* 使能 TIM1 时钟 */
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);

	TIM_TimeBaseStructInit(&TIM_TimeBaseStructure); 
	TIM_TimeBaseStructure.TIM_Period = g_DsoA->SimplePeriod;          
	TIM_TimeBaseStructure.TIM_Prescaler = g_DsoA->SimplePrescal;   /* 计数频率 = 72000 000 / 18 = 4000 000	 */
	TIM_TimeBaseStructure.TIM_ClockDivision = 0x0;    
	TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;  
	TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);

	/* TIM1 通道1配置为PWM模式 */
	TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; 
	TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;                
	TIM_OCInitStructure.TIM_Pulse = TIM_TimeBaseStructure.TIM_Period / 2; 
	TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low;         
	TIM_OC2Init(TIM2, &TIM_OCInitStructure);

	/* TIM1 计数器使能 */
	TIM_Cmd(TIM2, DISABLE);

	/* TIM1 输出使能 */
	TIM_CtrlPWMOutputs(TIM2, ENABLE);  
}
开发者ID:cross-sky,项目名称:stm32-board,代码行数:48,代码来源:Tdso-v2.c

示例14: DAC_Init_StartUp

void DAC_Init_StartUp(void)
{


	DAC_InitStructure.DAC_Trigger = DAC_Trigger_T2_TRGO;
	DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable;
	DAC_Init(DAC_Channel_1, &DAC_InitStructure);
	DAC_Cmd(DAC_Channel_1, ENABLE);

	/* TIM2 外设时钟使能*/
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
	/* 定时器基础配置 */
	TIM_TimeBaseStructInit(&TIM_TimeBaseStructure); 
	TIM_TimeBaseStructure.TIM_Period = 0xffff;          
	TIM_TimeBaseStructure.TIM_Prescaler = 0x1a;       
	TIM_TimeBaseStructure.TIM_ClockDivision = 0x0;    
	TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;  
	TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
	/* TIM2触发输出模式选择  */
	TIM_SelectOutputTrigger(TIM2, TIM_TRGOSource_Update);
	/* TIM2使能 */
	TIM_Cmd(TIM2, ENABLE);
	
		DMA_DeInit(DMA1_Channel3); 

		DMA_InitStructure.DMA_PeripheralBaseAddr = DAC_DHR12R1_ADDRESS;
		DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&ctrlSoftStart;
		DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
  		DMA_InitStructure.DMA_BufferSize = 136;
  		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_Normal;
  		DMA_InitStructure.DMA_Priority = DMA_Priority_High;
  		DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
  		DMA_Init(DMA1_Channel3, &DMA_InitStructure);
		DMA_Cmd(DMA1_Channel3, ENABLE);
}
开发者ID:EMDCYY,项目名称:Laser-Power-TEC-Control,代码行数:39,代码来源:dac.c

示例15: cppmInit

void cppmInit(void)
{
  TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
  TIM_ICInitTypeDef  TIM_ICInitStructure;
  GPIO_InitTypeDef GPIO_InitStructure;
  NVIC_InitTypeDef NVIC_InitStructure;

  RCC_AHB1PeriphClockCmd(CPPM_GPIO_RCC, ENABLE);
  RCC_APB1PeriphClockCmd(CPPM_TIMER_RCC, ENABLE);

  // Configure the GPIO for the timer input
  GPIO_StructInit(&GPIO_InitStructure);
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  GPIO_InitStructure.GPIO_Pin = CPPM_GPIO_PIN;
  GPIO_Init(CPPM_GPIO_PORT, &GPIO_InitStructure);

  GPIO_PinAFConfig(CPPM_GPIO_PORT, CPPM_GPIO_SOURCE, CPPM_GPIO_AF);

  // Time base configuration. 1us tick.
  TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
  TIM_TimeBaseStructure.TIM_Prescaler = CPPM_TIM_PRESCALER;
  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
  TIM_TimeBaseInit(CPPM_TIMER, &TIM_TimeBaseStructure);

  // Setup input capture using default config.
  TIM_ICStructInit(&TIM_ICInitStructure);
  TIM_ICInit(CPPM_TIMER, &TIM_ICInitStructure);

  NVIC_InitStructure.NVIC_IRQChannel = TIM8_TRG_COM_TIM14_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = NVIC_CPPM_PRI;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);

  captureQueue = xQueueCreate(64, sizeof(uint16_t));

  TIM_ITConfig(CPPM_TIMER, TIM_IT_Update | TIM_IT_CC1, ENABLE);
  TIM_Cmd(CPPM_TIMER, ENABLE);
}
开发者ID:CarlosRDomin,项目名称:crazyflie-firmware,代码行数:39,代码来源:cppm.c


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