红外发送代码分析

 if ((TIM1->IER & TIM1_IER_CC2IE) && (TIM1->SR1 & TIM1_SR1_CC2IF))
    {
        TIM1->SR1 &= (u8) (~TIM1_SR1_CC2IF);

        ret = get_nth_width(&_irwave, ir_eng._cur_send_bit, &width);//取得红外波的长度
        if ((0x00 == ret) || (ir_eng._cur_send_bit >= ir_eng._cur_wave_bit))
        {
            stop_compare();
            ir_eng.g_ir_state = IR_IDLE;
            return;
        }
        ir_eng._cur_send_bit++;//取波的个数


        if (width & 0x8000) 
        {
            pwm_stop();//如果是低电平,进入这个函数。
        }
        else
        {
            pwm_start();
        }
 next_lbl:
        cur = TIM1_GetCapture2();
        width &= 0x7FFF;//过滤负号,取得真实的脉宽值
        cur += width;
        TIM1_SetCompare2(cur);
    }

你可能感兴趣的:(代码分析)