示例#1
0
文件: timer.c 项目: 136048599/vrbrain
void pwm_mode(timer_dev *dev, uint8_t channel) {
    timer_disable_irq(dev, channel);
   // timer_oc_set_mode(dev, channel, TIMER_OC_MODE_PWM_1, TIMER_OC_PE);
    switch (channel)
    {
		case 1:
			TIM_SelectOCxM(dev->regs, TIM_Channel_1, TIM_OCMode_PWM1);
			TIM_OC1PreloadConfig(dev->regs, TIM_OCPreload_Enable);		
			break;
		case 2:
			TIM_SelectOCxM(dev->regs, TIM_Channel_2, TIM_OCMode_PWM1);
			TIM_OC2PreloadConfig(dev->regs, TIM_OCPreload_Enable);					
			break;
		case 3:
			TIM_SelectOCxM(dev->regs, TIM_Channel_3, TIM_OCMode_PWM1);
			TIM_OC3PreloadConfig(dev->regs, TIM_OCPreload_Enable);					
			break;
		case 4:
			TIM_SelectOCxM(dev->regs, TIM_Channel_4, TIM_OCMode_PWM1);
			TIM_OC4PreloadConfig(dev->regs, TIM_OCPreload_Enable);					
			break;
    }
    
    timer_cc_enable(dev, channel);
}
示例#2
0
static void output_compare_mode(timer_dev *dev, uint8 channel) {
    timer_oc_set_mode(dev, channel, TIMER_OC_MODE_ACTIVE_ON_MATCH, 0);
    timer_cc_enable(dev, channel);
}
示例#3
0
static void pwm_mode(timer_dev *dev, uint8 channel) {
    timer_disable_irq(dev, channel);
    timer_oc_set_mode(dev, channel, TIMER_OC_MODE_PWM_1, TIMER_OC_PE);
    timer_cc_enable(dev, channel);
}