/* Then reset channel registers: it also works if lock level is equal to 2 or 3 */
TIM2->CCER1 = (uint8_t)TIM2_CCER1_RESET_VALUE;
TIM2->CCER2 = (uint8_t)TIM2_CCER2_RESET_VALUE;
TIM2->CCMR1 = (uint8_t)TIM2_CCMR1_RESET_VALUE;
TIM2->CCMR2 = (uint8_t)TIM2_CCMR2_RESET_VALUE;
TIM2->CCMR3 = (uint8_t)TIM2_CCMR3_RESET_VALUE;
TIM2->CNTRH = (uint8_t)TIM2_CNTRH_RESET_VALUE;
TIM2->CNTRL = (uint8_t)TIM2_CNTRL_RESET_VALUE;
TIM2->PSCR = (uint8_t)TIM2_PSCR_RESET_VALUE;
TIM2->ARRH = (uint8_t)TIM2_ARRH_RESET_VALUE;
TIM2->ARRL = (uint8_t)TIM2_ARRL_RESET_VALUE;
TIM2->CCR1H = (uint8_t)TIM2_CCR1H_RESET_VALUE;
TIM2->CCR1L = (uint8_t)TIM2_CCR1L_RESET_VALUE;
TIM2->CCR2H = (uint8_t)TIM2_CCR2H_RESET_VALUE;
TIM2->CCR2L = (uint8_t)TIM2_CCR2L_RESET_VALUE;
TIM2->CCR3H = (uint8_t)TIM2_CCR3H_RESET_VALUE;
TIM2->CCR3L = (uint8_t)TIM2_CCR3L_RESET_VALUE;
TIM2->SR1 = (uint8_t)TIM2_SR1_RESET_VALUE;
// TIM2_TimeBaseInit(TIM2_PRESCALER_16, 60000); //定时器设置1M的计数频率,1US的分辨率
/* Set the Prescaler value */
TIM2->PSCR = (uint8_t)(TIM2_PRESCALER_16);
/* Set the Autoreload value */
TIM2->ARRH = (uint8_t)(60000 >> 8);
TIM2->ARRL = (uint8_t)(60000);
switch(key_val)
{
case Ir_Power:
Ir_Power_flag=1;
Ir_Repeat_Count=IR_REPEAT_NUM;
GPIO_WriteLow(PWN_CTL_GPIO, PWN_CTL_PIN);
//Power_step=10;
break;/*
case Ir_Home:
break;
case Ir_Up:
break;
case Ir_Left:
break;
case Ir_Ok:
break;
case Ir_Right:
break;
case Ir_Down:
break;
case Ir_Return:
break;
case Ir_NoVol:
break;
case Ir_Menu:
break;
case Ir_SubVol:
break;
case Ir_AddVol:
break;
case Ir_F1:
break;
case Ir_F2:
break;*/
default:
uart1_TX_buf[0]='#';
uart1_TX_buf[1]='K';
uart1_TX_buf[2]=':';
uart1_TX_buf[3]=hextoasc(key_val>>4);
uart1_TX_buf[4]=hextoasc(key_val&0x0f);
uart1_TX_buf[5]='$';
uart1_data(uart1_TX_buf,6);
break;
}
key_val=0;
}
}