/************************************************* * Copyright (C) 1999-2004 by ZiLOG, Inc. * All Rights Reserved *************************************************/ #include #include "main.h" #include "timer.h" extern char subtmr; extern char t1; extern char t2; extern char t3; extern char t4; extern char t5; extern int lt1; extern unsigned char ircode; extern unsigned char oldir; ////////////////////////////////////////////////////////// //10 mS Interrupt routine #pragma interrupt void isr_timer0(void) { ircode=PCIN; // read ir input ircode &= 0xf0; // erase unused bits subtmr -=1; if(subtmr==0) { subtmr=10; if(t1>0) t1 -=1; if(t2>0) t2 -=1; if(t3>0) t3 -=1; if(t4>0) t4 -=1; if(t5>0) t5 -=1; lt1 +=1; // long sequence timer } } ////////////////////////////////////////////////////////// //Intialize Timer-0 void init_timer0(void) { SET_VECTOR(TIMER0, isr_timer0); T0H = 0x6; // Timer High T0L = 0xc0; // Timer Low T0RH = 0x06; // Reload Compare High T0RL = 0xc0; // Reload Compare Low 10mS interval T0CTL = 0xE9; // Continous/Prescale IRQ0ENH |= 0x20; // Set Interrupt Priority Nominal IRQ0ENL &= 0xDF; // Set Interrupt Priority Nominal } // Wait timer char wait(int wtime) { t1=wtime; // start timer while(t1>0) { if(ircode != oldir) // if ir input not sero { if(ircode >0) // and ircode is new { t1=0; // abort wait oldir=ircode; // copy new ir code to old return(1); // and indicate new ircode } } } return(0); // no new ir code }