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

📄 busio.lst

📁 采用台湾MRT晶捷公司的MRT4方案的液晶电视的程序
💻 LST
📖 第 1 页 / 共 5 页
字号:
C51 COMPILER V6.23a  BUSIO                                                                 09/10/2004 16:09:03 PAGE 1   


C51 COMPILER V6.23a, COMPILATION OF MODULE BUSIO
OBJECT MODULE PLACED IN BUSIO.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE BUSIO.C OPTIMIZE(6,SIZE) ORDER DEFINE(DEBUGMSG=0,DEBUGTOOL=0) DEBUG OBJECTE
                    -XTEND CODE SYMBOLS

stmt level    source

   1          /************************************************
   2          *                                               *
   3          * BUSIO.C:  IO control routines.                *
   4          *                                               *
   5          *************************************************/
   6          #include "mascot.h"
   7          #include <reg51.h>
   8          #include "global.h"
   9          
  10          
  11          /**********************************************
  12          * Send Table data to Mascot regs              *
  13          ***********************************************/
  14          void RegDataTableOut(unsigned char *s)
  15          {
  16   1              unsigned char cnd, index;
  17   1      
  18   1              while ((cnd = *s++) != -1) {
  19   2                      index = *s++;
  20   2                      RegDataOut(index, s, cnd);
  21   2                      s += cnd;
  22   2              }
  23   1      }
  24          
  25          
  26          /**********************************************
  27          * Receive byte of data from Mascot regs       *
  28          ***********************************************/
  29          unsigned char RegByteIn(unsigned char index)
  30          {
  31   1              unsigned char data val;
  32   1      
  33   1      #if DISABLEINT0
  34   1              bit IntFlag;
  35   1      
  36   1              /* disable interrupt 0 */
  37   1              IntFlag = EX0;
  38   1              EX0 = 0;
  39   1      #endif
  40   1      
  41   1      
  42   1              /* I2C Start and send slave address */
  43   1              GoI2CMaster(SLAVEADDR_REGW);
  44   1              if (NoAck | BusFault) goto buserror;
  45   1      
  46   1              /* Send comm */
  47   1              SendI2CByte(READ_BYTE);
  48   1              if (NoAck) goto buserror;
  49   1      
  50   1              /* Send index */
  51   1              SendI2CByte(index);
  52   1              if (NoAck) goto buserror;
  53   1      
  54   1              SendI2CStop();
C51 COMPILER V6.23a  BUSIO                                                                 09/10/2004 16:09:03 PAGE 2   

  55   1      
  56   1              /* I2C Start and send slave address */
  57   1              GoI2CMaster(SLAVEADDR_REGR);
  58   1              if (NoAck | BusFault) goto buserror;
  59   1      
  60   1              /* data transmit */
  61   1              val = RcvI2CByte(1);
  62   1      
  63   1      endi2c:
  64   1              /* Finish transmition */
  65   1              SendI2CStop();
  66   1      
  67   1      
  68   1      
  69   1      
  70   1      #if DISABLEINT0
  71   1              /* restove interrupt 0 flag */
  72   1              EX0 =   IntFlag;
  73   1      #endif
  74   1      
  75   1              return(val);
  76   1      
  77   1      buserror:
  78   1      #if DEBUGMSG
                 printf("  BUS error (RegByteIn) !!!!\n");
              #endif
  81   1          goto endi2c;
  82   1      }
  83          
  84          /**********************************************
  85          * Receive bytes of data from Mascot regs      *
  86          ***********************************************/
  87          void RegDataIn(unsigned char index, unsigned char *s, int cnt)
  88          {
  89   1              int data byteCnt;
  90   1      
  91   1      #if DISABLEINT0
  92   1              bit IntFlag;
  93   1      
  94   1              /* disable interrupt 0 */
  95   1              IntFlag = EX0;
  96   1              EX0 = 0;
  97   1      #endif
  98   1      
  99   1      
 100   1              /* I2C Start and send slave address */
 101   1              GoI2CMaster(SLAVEADDR_REGW);
 102   1              if (NoAck | BusFault) goto buserror;
 103   1      
 104   1              /* Send comm */
 105   1              SendI2CByte(READ_AUTOINC);
 106   1              if (NoAck) goto buserror;
 107   1      
 108   1              /* Send index */
 109   1              SendI2CByte(index);
 110   1              if (NoAck) goto buserror;
 111   1      
 112   1              SendI2CStop();
 113   1      
 114   1              /* I2C Start and send slave address */
 115   1              GoI2CMaster(SLAVEADDR_REGR);
 116   1              if (NoAck | BusFault) goto buserror;
C51 COMPILER V6.23a  BUSIO                                                                 09/10/2004 16:09:03 PAGE 3   

 117   1      
 118   1              /* data transmit */
 119   1              for(byteCnt = cnt; byteCnt > 0; byteCnt--) {
 120   2                      *s++ = RcvI2CByte(byteCnt);
 121   2              }
 122   1              
 123   1      endi2c:
 124   1              /* Finish transmition */
 125   1              SendI2CStop();
 126   1      
 127   1      
 128   1      
 129   1      #if DISABLEINT0
 130   1              /* restove interrupt 0 flag */
 131   1              EX0 =   IntFlag;
 132   1      #endif
 133   1          return;
 134   1      
 135   1      buserror:
 136   1      #if DEBUGMSG
                 printf("    BUS error (RegDataIn) !!!!\n");
              #endif   
 139   1          goto endi2c;
 140   1      }
 141          
 142          /**********************************************
 143          * Write byte of data to Mascot regs           *
 144          ***********************************************/
 145          void RegByteOut(unsigned char index, unsigned char val)
 146          {
 147   1      #if DISABLEINT0
 148   1              bit IntFlag;
 149   1      
 150   1              /* disable interrupt 0 */
 151   1              IntFlag = EX0;
 152   1              EX0 = 0;
 153   1      #endif
 154   1      
 155   1      
 156   1              /* I2C Start and send slave address */
 157   1              GoI2CMaster(SLAVEADDR_REGW);
 158   1              if (NoAck | BusFault) goto buserror;
 159   1      
 160   1              /* Send comm */
 161   1              SendI2CByte(WRITE_BYTE);
 162   1              if (NoAck) goto buserror;
 163   1      
 164   1              /* Send index */
 165   1              SendI2CByte(index);
 166   1              if (NoAck) goto buserror;
 167   1      
 168   1              /* data transmit */
 169   1              SendI2CByte(val);
 170   1       
 171   1      endi2c:
 172   1              /* Finish transmition */
 173   1              SendI2CStop();
 174   1      
 175   1      
 176   1      
 177   1      
 178   1      #if DISABLEINT0
C51 COMPILER V6.23a  BUSIO                                                                 09/10/2004 16:09:03 PAGE 4   

 179   1              /* restove interrupt 0 flag */
 180   1              EX0 =   IntFlag;
 181   1      #endif
 182   1          return;
 183   1      
 184   1      buserror:
 185   1      #if DEBUGMSG
                 printf("    BUS error (RegByteOut) !!!!\n");
              #endif   
 188   1          goto endi2c;
 189   1      }
 190          
 191          
 192          /**********************************************
 193          * Write byte of data to Mascot regs           *
 194          ***********************************************/
 195          void RegWordOut(unsigned char index, unsigned int val)
 196          {
 197   1          unsigned char b[2];
 198   1      
 199   1          b[0] = val;
 200   1          b[1] = val>>8;
 201   1          RegDataOut(index, b, 2);
 202   1      }
 203          
 204          
 205          /**********************************************
 206          * Write bit(s) of data to Mascot reg          *
 207          ***********************************************/
 208          void RegBitOut(unsigned char index, unsigned char val, unsigned char mask)
 209          {
 210   1              unsigned char b;
 211   1              
 212   1          b = RegByteIn(index);
 213   1              b = (b & ~mask) | val;
 214   1              RegByteOut(index, b);
 215   1      }
 216          
 217          /**********************************************
 218          * Write bytes of data to Mascot regs          *
 219          ***********************************************/
 220          void RegDataOut(unsigned char index, unsigned char *s, int cnt)
 221          {
 222   1              int data byteCnt;
 223   1      
 224   1      #if DISABLEINT0
 225   1              bit IntFlag;
 226   1      
 227   1              /* disable interrupt 0 */
 228   1              IntFlag = EX0;
 229   1              EX0 = 0;
 230   1      #endif
 231   1      
 232   1              /* I2C Start and send slave address */
 233   1              GoI2CMaster(SLAVEADDR_REGW);
 234   1              if (NoAck | BusFault) goto buserror;
 235   1      
 236   1              /* Send comm */
 237   1              SendI2CByte(WRITE_AUTOINC);
 238   1              if (NoAck) goto buserror;
 239   1      
 240   1              /* Send index */
C51 COMPILER V6.23a  BUSIO                                                                 09/10/2004 16:09:03 PAGE 5   

 241   1              SendI2CByte(index);
 242   1              if (NoAck) goto buserror;
 243   1      
 244   1              /* data transmit */
 245   1              for(byteCnt = cnt; byteCnt > 0; byteCnt--) {
 246   2                      SendI2CByte(*s++);
 247   2                      if (NoAck) goto buserror;
 248   2              }
 249   1      
 250   1      endi2c:   
 251   1              /* Finish transmition */
 252   1              SendI2CStop();
 253   1      
 254   1      
 255   1      
 256   1      #if DISABLEINT0
 257   1              /* restove interrupt 0 flag */
 258   1              EX0 =   IntFlag;
 259   1      #endif
 260   1          return;
 261   1      
 262   1      buserror:
 263   1      #if DEBUGMSG
                  printf("    BUS error (RegDataOut) !!!!\n");
              #endif
 266   1              goto endi2c;
 267   1      }
 268          
 269          
 270          
 271          
 272           
 273          
 274          /**********************************************
 275          * Receive byte of data from Mascot regs       *
 276          ***********************************************/
 277          unsigned char OSDRegByteIn(unsigned char index)
 278          {
 279   1              unsigned char data val;
 280   1      
 281   1      #if DISABLEINT0
 282   1              bit IntFlag;
 283   1      
 284   1              /* disable interrupt 0 */
 285   1              IntFlag = EX0;
 286   1              EX0 = 0;
 287   1      #endif
 288   1      
 289   1      
 290   1              RegByteOut(0xC0, 0xBC); // Select OSD Registers
 291   1      
 292   1              /* I2C Start and send slave address */
 293   1              GoI2CMaster(SLAVEADDR_REGW);
 294   1              if (NoAck | BusFault) goto buserror;
 295   1      
 296   1              /* Send comm */
 297   1              SendI2CByte(READ_BYTE);
 298   1              if (NoAck) goto buserror;
 299   1      
 300   1              /* Send index */

⌨️ 快捷键说明

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