⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ir.c

📁 使用于克隆器
💻 C
字号:
/******************************************************************************
 Copyright (c) 2004 MStar Semiconductor, Inc.
 All rights reserved.

 [Module Name]: Ir.c
 [Date]:        04-Feb-2004
 [Comment]:
   Remote control subroutines.
 [Reversion History]:
*******************************************************************************/

#define _IR_C_

// System
#include <intrins.h>

// Common
#include "define.h"
#include "mcu.h"
#include "userdef.h"
// External
#include "i2c.h"
#include "uart.h"
#include "common.h"
#include "userpref.h"
#include "board.h"

#include "global.h"
#include "irfunc.h"

// Internal
#include "ir.h"


#if (IR_TYPE==IR_RC5)
#include "IR_RC5.c"
#elif (IR_TYPE==IR_NEC)
#include "IR_NEC.c"
#elif (IR_TYPE==IR_TOSHIBA)
#include "IR_TOSHIBA.c"
#endif

////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
void irDecodeRepeat(BYTE ucRepeatTime)
{
    if (g_bIrRepeat)
        g_ucIrRepeatCounter = ucRepeatTime;
}

void irPolling(void)
{
    if (g_ucIrRepeatCounter)
        g_ucIrRepeatCounter--;
    if (g_ucIrReleaseCounter)
    {
        if (--g_ucIrReleaseCounter == 0)
            g_bIrRepeat = FALSE;
    }
}

//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
void irDetectTimer0(void)
{
    if (++g_ucIrClocker > IR_OVERFLOW)
        g_ucIrClocker = 0;//IR_OVERFLOW;
}


#if (IR_CODE_DEBUG_EN)
void irDebugHandler(void)
{
   // if (g_ucIR_ErrTimeCount)
   //   return;
#if 1
    if (IR_DebugCustomerCode0_OKFlag)
    {
      Clr_IR_DebugCustomerCode0_OKFlag();
      printf("\r\n[IR0]: %x",g_ucIRDebugCode0);
	  g_ucIRDebugCode0=0;
    }
    if (IR_DebugCustomerCode1_OKFlag)
    {
      Clr_IR_DebugCustomerCode1_OKFlag();
      printf("\r\n[IR1]: %x",g_ucIRDebugCode1);
      //printf("\r\n[IR1]: %d",g_ucIRDebugCode1);
	  g_ucIRDebugCode0=0;
    }
#endif
    if (IR_DebugData_OKFlag)
    {
      Clr_IR_DebugData_OKFlag();
      printf("\r\n [Code]: %x",g_ucIRDebugData);
    }
}
#endif


#ifdef DVDENABLE
void irConvertIRTODVD(unsigned char Data)
{
    unsigned char i = 0;
    for (i = 0; i < 8; i++)
    {
        if (Data & 0x01)
        {
            Delay1ms(1);
            Delay10us(31);
            pinDVDIRSend = 0;
            Delay10us(40);
            pinDVDIRSend = 1;
        }
        else//0
        {
            Delay10us(22);
            pinDVDIRSend = 0;
            Delay10us(40);
            pinDVDIRSend = 1;
        }
        Data = Data >> 1;
    }
}

void irSendIRTODVD(void)
{
    unsigned char i = 0;
    unsigned char uc = 0x00;

    EA = 0;

    SetIRBYPassOFF();
    pinDVDIRSend = 1;
    Delay1ms(5);

    //IRstart
    pinDVDIRSend = 0;
    Delay1ms(9);
    pinDVDIRSend = 1;
    Delay1ms(4);
    Delay10us(25);
    pinDVDIRSend = 0;//13.5ms
    Delay10us(28);
    pinDVDIRSend = 1;
    //Delay1ms(1);
    irConvertIRTODVD(0x00);
    irConvertIRTODVD(0x00);
    irConvertIRTODVD(g_IrCodeParam[4]);
    irConvertIRTODVD(~g_IrCodeParam[4]);
    Delay1ms(20);
    pinDVDIRSend = 1;
    Delay1ms(5);

    //IRstart
    pinDVDIRSend = 0;
    Delay1ms(9);
    pinDVDIRSend = 1;
    Delay1ms(4);
    Delay10us(25);
    pinDVDIRSend = 0;//13.5ms
    Delay10us(28);
    pinDVDIRSend = 1;
    //Delay1ms(1);
    irConvertIRTODVD(0x00);
    irConvertIRTODVD(0x99);
    irConvertIRTODVD(g_IrCodeParam[4]);
    irConvertIRTODVD(~g_IrCodeParam[4]);

    EA = 1;
}
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -