📄 main.lst
字号:
725
726 WORD DiffTime_ms( WORD stime, WORD etime )
727 {
728 1 //#ifdef DEBUG
729 1 //dPrintf("\r\n(DiffTime) stime:%d, etime:%d", (WORD)stime, (WORD)etime );
730 1 //#endif
731 1 if( etime < stime ) { // resetted
732 2 return etime + (6000 - stime);
733 2 }
734 1 else {
735 2 return etime - stime;
736 2 }
C51 COMPILER V7.50 MAIN 08/20/2007 10:23:30 PAGE 13
737 1 }
738
739 #ifdef SUPPORT_CCD_VCHIP
void SetLastBlockedTime(void)
{
LastBlockedTime = SystemClock;
}
BYTE EnoughBlockedTime(void)
{
if( LastBlockedTime != 0xffffffff && ( SystemClock - LastBlockedTime ) >=5 )
return TRUE;
return FALSE;
}
#ifdef SUPPORT_TW88_CC_DECODER
void SetLastCCTime(void)
{
if( LastCCTime != SystemClock ) {
LastCCTime = SystemClock;
#ifdef DEBUG_CCEDS
// dPrintf("(LastCCTime:%ld)", LastCCTime );
#endif
}
}
BYTE WaitEnoughForCC(void)
{
// #ifdef DEBUG_CCEDS
// dPrintf("\r\n(WaitEnoughForCC) LastCCTime:%ld, SystemClock:%ld", LastCCTime, SystemClock );
// #endif
if( LastCCTime != 0xffffffff && ( SystemClock - LastCCTime ) >=5 ) { // 5 sec
#ifdef DEBUG_CCEDS
dPrintf("((WaitEngoughForCC!! SystemClock:%ld))", SystemClock );
#endif
return TRUE;
}
return FALSE;
}
#endif
#endif // SUPPORT_CCD_VCHIP
780
781 #if defined SUPPORT_TV
BYTE WantToStopTVScan(void)
{
BYTE AutoKey=0, ret=0, _RemoDataCode=0;
ret = GetKey(1);
if( ret == MENUKEY ) {
//Printf("\r\n(WantToStopTVScan) Pushed Menu Key!!");
return 1;
}
if( !ret )
ret = IsRemoDataReady(&_RemoDataCode, &AutoKey);
if( _RemoDataCode==REMO_MENU ) ret = 1;
else ret = 0;
C51 COMPILER V7.50 MAIN 08/20/2007 10:23:30 PAGE 14
#if defined DEBUG_KEYREMO || defined DEBUG_TV
dPrintf("\r\n(WantToStopTVScan) ret:0x%x, RemoDataCode:0x%x", (WORD)ret, (WORD)_RemoDataCode);
#endif
return ret;
}
#endif //SUPPORT_TV
806 //*****************************************************************************
807 // Serial Interrupt
808 //*****************************************************************************
809 #ifdef SERIAL
810
811 INTERRUPT(4, serial_int)
812 {
813 1 if( RI ) { //--- Receive interrupt ----
814 2 RI = 0;
815 2 RS_buf[RS_in++] = SBUF;
816 2 if( RS_in>=BUF_MAX ) RS_in = 0;
817 2 }
818 1
819 1 if( TI ) { //--- Transmit interrupt ----
820 2 TI = 0;
821 2 RS_Xbusy=0;
822 2 }
823 1 }
824 //=============================================================================
825 // Serial RX Check
826 //=============================================================================
827 BYTE RS_ready(void)
828 {
829 1 if( RS_in == RS_out ) return 0;
830 1 else return 1;
831 1 }
832 //=============================================================================
833 // Serial RX
834 //=============================================================================
835 BYTE RS_rx(void)
836 {
837 1 BYTE ret;
838 1
839 1 ES = 0;
840 1 ret = RS_buf[RS_out];
841 1 RS_out++;
842 1 if(RS_out >= BUF_MAX)
843 1 RS_out = 0;
844 1 ES = 1;
845 1
846 1 return ret;
847 1 }
848 //=============================================================================
849 // Serial TX
850 //=============================================================================
851 void RS_tx(BYTE tx_buf)
852 {
853 1 while(1) {
854 2 if(!RS_Xbusy) {
855 3 SBUF = tx_buf;
856 3 RS_Xbusy=1;
857 3 break;
858 3 }
859 2 }
860 1 }
C51 COMPILER V7.50 MAIN 08/20/2007 10:23:30 PAGE 15
861 //=============================================================================
862 // Serial Output string
863 //=============================================================================
864 void NewLine(void)
865 {
866 1 Puts("\r\n");
867 1 }
868
869 void PutsP(PDATA_P BYTE *ptr)
870 {
871 1 BYTE ch;
872 1 while(*ptr!='\0') {
873 2 ch = *ptr++;
874 2 RS_tx(ch);
875 2 }
876 1 }
877
878 #else
#define NewLine ;//
#define PutsP ;//
#endif // SERIAL
884 //=============================================================================
885 // Initialize CPU
886 //=============================================================================
887 void InitCPU(void)
888 {
889 1 CHPENR = 0x87; // Enable AUX RAM in Winbond(W78E516B)
890 1 CHPENR = 0x59; //
891 1 CHPCON = 0x10; //
892 1 CHPENR = 0x00; // Write Disable
893 1
894 1 SystemClock=0; //00:00
895 1 LastBlockedTime=0xffffffff; //00:00 //ljy010904...CC_FIX_CLEAR_ON_TIME..oops! previous vchip clear error
-
896 1 #ifdef SUPPORT_TW88_CC_DECODER
LastCCTime=0xffffffff; //ljy010904...CC_FIX_CLEAR_ON_TIME
#endif
899 1 //WakeupTime=0xffff;
900 1 //WakeupPR = 0;
901 1 OffTime=0xffff;
902 1 SleepTimer=0;
903 1 SleepTime=0xffff;
904 1
905 1 /*----- Initialize interrupt -------------*/
906 1
907 1 TH1 = 0xff; // SMOD = 0 SMOD =1
908 1 // 0ffh :57600 bps
909 1 // 0fdh : 9600 bps 0fdh :19200 bps
910 1 // 0fah : 4800 bps
911 1 // 0f4h : 2400 bps
912 1 // 0e8h : 1200 bps
913 1
914 1 SCON = 0x50; // 0100 0000 mode 1 - 8 bit UART
915 1 // Enable serial reception
916 1 TMOD = 0x22; // 0010 0010 timer 0 - 8 bit auto reload
917 1 // timer 1 - baud rate generator
918 1 TCON = 0x55; // 0101 0001 timer 0,1 run
919 1 // int 0, edge triggered
920 1 // int 1, edge triggered
921 1 // TF1 TR1 TF0 TR0 EI1 IT1 EI0 IT0
C51 COMPILER V7.50 MAIN 08/20/2007 10:23:30 PAGE 16
922 1 TH0 = TL0 = 64; // 64=4608 Hz at 11.0592MHz
923 1
924 1 PCON = 0x80; // 0000 0000 SMOD(double baud rate bit) = 1
925 1 IP = 0x02; // 0000 0000 interrupt priority
926 1 // - - PT2 PS PT1 PX1 PT0 PX0
927 1
928 1 #ifdef SERIAL
929 1 IE = 0x92; // 1001 0010 interrupt enable:Serial,TM0
930 1 // EA - ET2 ES ET1 EX1 ET0 EX0
931 1
932 1 TI = 1; // LJY000724 // For Starting Serial TX
933 1 ES = 1; // LJY000724
934 1 #else
IE = 0x82;
#endif // SERIAL
937 1
938 1 //------------ Timer 2 for Remocon --------------------------------
939 1 T2CON = 0x00; // Timer2 Clear
940 1 TR2 = 0;
941 1 ET2 = 1;
942 1 //-----------------------------------------------------------------
943 1
944 1 SEL_DVI= 1; // disable Digital VGA
945 1
946 1 ResetKey();
947 1
948 1 #ifdef SERIAL
949 1 RS_in = RS_out = 0;
950 1 commdptr = bptr = 0;
951 1 #endif // SERIAL
952 1
953 1 DebugLevel = 0;
954 1 RemoDataReady = 0;
955 1 I2CAddressDeb = DECODERADDRESS; //TW88I2CAddress;
956 1
957 1 }
958
959 #ifdef SERIAL
960 //=============================================================================
961 // I2C Edit Read
962 //=============================================================================
963 void MonWriteI2C(BYTE addr, BYTE index, BYTE val)
964 {
965 1 Printf("Write %02xh to [Adrs(%02xh)Index(%02xh)] ", (WORD)val, (WORD)addr, (WORD)index);
966 1 WriteI2C(addr, index, val);
967 1 }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -