/* Initializes the tim Channel4 according to the specified parameters in the init_struct.  */
void TIM_OC4Init(TIM_TypeDef *tim, TIM_OCInitTypeDef *init_struct)
/* Initializes the tim Channel4 according to the specified parameters in the init_struct.  */
void TIM_OC4Init(TIM_TypeDef *tim, TIM_OCInitTypeDef *init_struct)
{
    MODIFY_REG(tim->CCMR2, TIM_CCMR2_OC4M, (init_struct->TIM_OCMode) << 8);
    MODIFY_REG(tim->CCER, TIM_CCER_CC4EN | TIM_CCER_CC4P, \
               (init_struct->TIM_OCPolarity << 12) | (init_struct->TIM_OutputState << 12));
    WRITE_REG(tim->CCR4, init_struct->TIM_Pulse);
    if ((tim == TIM1) || (tim == TIM8))
        MODIFY_REG(tim->CR2, TIM_CR2_OIS4, init_struct->TIM_OCIdleState << 6);
}