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

📄 main.lst

📁 CS8955控制TV软件。用MCU做模拟电视的控制。
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V8.05a   MAIN                                                                 07/03/2008 18:27:37 PAGE 1   


C51 COMPILER V8.05a, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN .\OBJ\Main.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE main\Main.C LARGE BROWSE INCDIR(.\include) DEBUG OBJECTEXTEND PRINT(.\Main.
                    -lst) OBJECT(.\OBJ\Main.obj)

line level    source

   1          /******************************************************************************\
   2               Project Version:   MTKCARDVD()
   3          ********************************************************************************
   4               Filename:          MAIN.c
   5          
   6               Author:            Alan chan
   7          
   8               Company:           CoreTek/ACT Company
   9          
  10          ********************************************************************************
  11               File Version:      1.01
  12               File Created:      July 2007
  13          
  14               Compiled Using:    keil uVision2 Version 2.23 
  15          
  16          ********************************************************************************
  17               Files Required:
  18          
  19          ********************************************************************************
  20               File Description:
  21          
  22          ********************************************************************************
  23               File History:
  24          
  25          --------------------------------------------------------------------------------
  26            Date         Name           Description
  27          --------------------------------------------------------------------------------
  28            Mar. 2007    Alan Chan    File Created
  29            
  30          \******************************************************************************/
  31          #define _MAIN_
  32          #include "stdio.h"
  33          #include "string.h"
  34          
  35          #include "global.h"
  36          #include "irkey.h"
  37          #include "key.h"
  38          #include "task.h"
  39          #include "comdvd.h"
  40          #include "e2prom.h"
  41          
  42          #include "tv.h"
  43          
  44          #define MCU_CS_CLK_SWAP
  45          
  46          // Init variables
  47          void vInitVar(void)
  48          {
  49   1          BYTE  i;
  50   1              
  51   1          // timer 0 variables
  52   1          bTimer20ms = 0;
  53   1          wTimer0Count =100;
  54   1      
C51 COMPILER V8.05a   MAIN                                                                 07/03/2008 18:27:37 PAGE 2   

  55   1          // i2c variables
  56   1          vInitialI2C();
  57   1      
  58   1          // dvd com variables
  59   1          DvdRxIndex = DataOutValid = 0;
  60   1          for (i=0;i<(DVD_STATUS_BYTE-1);i++)
  61   1          {
  62   2              ShadowDvdInfo[i] = 0;   //otiose??? Invalid
  63   2          }
  64   1          for (i=0;i<CAR_INFO_BYTE;i++)
  65   1          {
  66   2              ShadowCarInfo[i] = 0; //otiose ?? ?Invalid
  67   2          }
  68   1      
  69   1      #ifdef ENABLE_UART
  70   1          // uart variables
  71   1          UartRxIndex = 0; 
  72   1      #endif
  73   1      
  74   1          // IR variables init        
  75   1          vInitIRVar();
  76   1      
  77   1          // mcu cmd
  78   1          CarMCUCmd = 0;
  79   1          CarMCUCmdPage = 0;
  80   1      }
  81          
  82          // Init IO
  83          void vInitIO()
  84          {
  85   1      #ifdef MARTIN_CS8955_IO_PORT  //martin 08May08 add
  86   1      CS8955_PADMOD0=0x00;
  87   1      CS8955_PADMOD1=0x00;
  88   1      CS8955_PADMOD2=0xa0; //0xE0; 
  89   1      #endif
  90   1      
  91   1      
  92   1          P0 = 0xff;         
  93   1          P1 = 0xff;  //0xfe;   martin 08May08        //set P1.0(tv_pwr)=0
  94   1          P2 = 0xff;         //set P2.0(dvd_do)=1, P2.1(dvd_di)=1, P2.2(dvd_clk)=1 
  95   1          P3 = 0xff; //0xcf; martin 08May08         //set P3.2(IR)=1,P3.3(dvd_cs)=1, P3.4(tv_sda)=0, P3.5(tv_scl
             -)=0;
  96   1      
  97   1              
  98   1      }
  99          
 100          #ifndef MARTIN_MCU_NO_IR
              // Init IR Interrupt
              void vInitIRInt(void)
              {
              // IR Remote Control
                 EX0 = 0;  //Disable INT 0 Interrupt
                 IT0 =1;  // INT 0  high  level control valid, //Enable edge trigger
              }
              #endif
 109          
 110          // Init Interrupt
 111          void vInitAllInt(BIT enable)
 112          {
 113   1         if (enable)
 114   1         {
 115   2       #ifndef MARTIN_DVD_COMM_NOT_SUPPORT_INT        
C51 COMPILER V8.05a   MAIN                                                                 07/03/2008 18:27:37 PAGE 3   

                 CS8955_EINT1PEN = 0x80;
                    // DVD com
                    EX1 =0x01; // Enable INT1 interrupt
                    IT1 =0x01; // / INT1  low / high control valid,
                    #endif
 121   2            #ifndef MARTIN_MCU_NO_IR
                     // IR Remote Contro Use the INT4 Pin and Function        
                     vInitIRInt();
                   #endif
 125   2         }
 126   1         else 
 127   1         {
 128   2            // DVD com
 129   2            #if 1 //#ifndef MARTIN_DVD_COMM_NOT_SUPPORT_INT   
 130   2            EX1 = 0x00; // Disable INT1 interrupt
 131   2            IT1 = 0x00; // INT 1  low  level control valid,
 132   2            #endif
 133   2            #ifndef MARTIN_MCU_NO_IR  //martin 08May08
                    // IR Remote Control      
                    EX0 = 0; // Disable INT0 interrupt
                    #endif
 137   2         }
 138   1      }
 139          
 140          // Init Timer0
 141          void vInitTimer()
 142          {
 143   1          TMOD|=0x01;   // set timer0 in mode1  16 bit timer
 144   1          TH0=0xEC;   
 145   1          TL0=0x78;   
 146   1      
 147   1         TF0 = 0;  //clear timer0 flag
 148   1          PT0= 0;   // priority Timer0 level
 149   1          ET0=1;   // enable timer0 interrupt
 150   1          TR0=0;   // start timer0
 151   1      }   
 152          
 153          #ifdef ENABLE_UART
 154          // Init Uart
 155          void vInitUart()
 156          {
 157   1         //SCON(98h): sm0/sm1/sm2/ren / tb8/rb8/ti/ri
 158   1         CS8955_OPTION |= 0x10;  //set master IIC==ISCL/ISDA(P3.4,P3.5);set master IIC frequency=100K(specificat
             -ion:PAGE 11)
 159   1         TMOD |= 0x20;   // timer1 in mode2
 160   1         TL1 = 0xfb; // 12M, 9600
 161   1         TH1 = 0xfb;
 162   1         PCON |= 0x80; //UART  baud rate double control(C51 book page 158)
 163   1         SCON = 0x50;        // mode1 & enable receive
 164   1      // TH1 = TL1 = 256-(62500/9600)-0;       // 12M, 9600_OK
 165   1      // TH1 = TL1 = 256-(74574/baudrate)-1;        // 14.3M
 166   1      // TH1 = TL1 = 256-(88200/baudrate)-0;        // 16.9M
 167   1      
 168   1         PT1= 0;   // priority Timer1 level
 169   1         ET1 = 0; // Disable timer1 interrupt
 170   1         TR1 = 1; // start timer1
 171   1       
 172   1         ES = 1;   // enable serial interrupt
 173   1         PS = 0;  // priority serial low
 174   1       
 175   1      CS8955_PADMOD2=0xa0; //0xE0; 
 176   1      CS8955_INTEN=0xe0;   //28May08
C51 COMPILER V8.05a   MAIN                                                                 07/03/2008 18:27:37 PAGE 4   

 177   1      CS8955_SLVBADR=0x80|(0x4c>>1);
 178   1      
 179   1      fgEnUART=0;  //03Jul08 test
 180   1      
 181   1      // printf("UART is ok\n"); 
 182   1         
 183   1      }
 184          #endif
 185          
 186          // Init CPU
 187          void vInitCPU(BIT OnOff)
 188          {
 189   1          vInitIO();  //P0-P3
 190   1      
 191   1          if (OnOff==0) 
 192   1          {
 193   2               PCON &= 0xFE;   // Disable PMM Mode
 194   2      
 195   2              vInitAllInt(OFF);
 196   2               #ifndef MARTIN_MCU_NO_IR  //martin 08May08
                      vInitIRInt();   
                       #endif
 199   2              vInitTimer();
 200   2      #ifdef ENABLE_UART
 201   2              vInitUart();   
 202   2      #endif        
 203   2               vInitVar();
 204   2      #ifndef MARTIN_SYSTEM_ONLY_TVMODE
                      SysMode = NextSysMode = PWR_DOWN_MODE;
              #endif
 207   2          }
 208   1          else
 209   1          {
 210   2               PCON &= 0xFE;   // Disable PMM Mode
 211   2              vInitAllInt(ON);
 212   2              vInitTimer();
 213   2      #ifdef ENABLE_UART
 214   2              vInitUart();   
 215   2      #endif
 216   2              vInitVar();
 217   2          }           
 218   1      }
 219          #ifdef MARTIN_SYSTEM_ONLY_TVMODE  //martin 08Mary08
 220          void vInitSys(void)   //martin 12May08
 221          {
 222   1              TR0=1;   // start timer0                                                
 223   1              //      EX0 = 1;  // IR         
 224   1       #ifndef MARTIN_DVD_COMM_NOT_SUPPORT_INT        
                      EX1 = 1;  // DVD com
                      #endif
 227   1         #ifdef ENABLE_UART
 228   1            ES = 1;   // enable serial interrupt
 229   1           TI = RI = 0;
 230   1         #endif
 231   1         vInitialE2prom();                    
 232   1        vInitTV();
 233   1        fgTvSearchState=0;
 234   1      }
 235          #else
              // Init sys pwr
              void vInitSysPwr(BIT PwrUp)
              {
C51 COMPILER V8.05a   MAIN                                                                 07/03/2008 18:27:37 PAGE 5   

                  mMuteEnable();
                  if (PwrUp)
                  {
                      mTVDisable();
                      Delay1ms(10);
                  }
                  else 
                  {
                      mTVDisable();
                  }
              }
              
              void vSysModeSwitch(BYTE mode)
              {
                      switch (mode)
                      {
                              case DVD_MODE:
                                      mTVDisable();
                                      break;
                              case TV_MODE:
                                      vInitTV();
                                      break;
                      }
              }
              #endif
 264          #ifndef MARTIN_MCU_NO_IR   //martin 08May08
              /////////////////// IR interrupt service routines////////////////////
              void ISR_EXINT0(void) interrupt 0 
              {
                  BYTE bKey;
              
                  EA = 0;
              
                  // Scan the remote control
                  bKey = bRemoteDetect();
              
                  // key is detected
                  if (bKey != IR_NONE)
                  {
                      if ((bKey == IR_LONGPUSH) && (_bIRLongPush == IR_NONE)
                              && (_bIRKey0!=IR_LONGPUSH) )
                      {
                              _bIRLongPush = _bIRKey0;
                      }
              
                      if (bKey != IR_LONGPUSH)
                      {
                              _bIRLongPush = IR_NONE;
                              _bIRKey0 = bKey;
                             _fgIRKeyValid = TRUE;
                      }
                     // long push
                      else     if (_bIRLongPush!=IR_NONE)
                      {
                              _bIRKey0 = Key2IR(TRUE,_bIRLongPush);
                              _bIRLongPush = IR_NONE;
                             _fgIRKeyValid = TRUE;
                        }
                  }   
              
                  EA = 1;     
              }
C51 COMPILER V8.05a   MAIN                                                                 07/03/2008 18:27:37 PAGE 6   

              #endif
 302          //System Clock  20ms
 303          void ISR_Timer0(void) interrupt 1  // 20ms task 
 304          {
 305   1           EA = 0;
 306   1           TH0=0xEC;   //timer 0 high byte
 307   1           TL0=0x78;    //timer 0 low byte
 308   1              
 309   1          if (!(--wTimer0Count))
 310   1          {
 311   2             bTimer20ms = 1;
 312   2             wTimer0Count = 5;
 313   2          }
 314   1      
 315   1          if (EEP_Wait>0)
 316   1              --EEP_Wait;
 317   1      
 318   1           TF0 = 0;
 319   1           EA = 1;
 320   1      }
 321          
 322          #ifdef ENABLE_UART
 323          void ISR_UART(void) interrupt 4 // Uart
 324          {
 325   1         EA = 0;
 326   1         if(RI)
 327   1         {
 328   2              if (SBUF!=0x0d && SBUF!=0x0a)
 329   2              {
 330   3                      UartRxBuf[UartRxIndex++] = SBUF;
 331   3                      if (UartRxIndex>=UART_BUF_SIZE)
 332   3                              UartRxIndex = 0;
 333   3              }               
 334   2              RI = 0;
 335   2         }

⌨️ 快捷键说明

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