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

📄 lprtpos1.lst

📁 原创一个简单打小票POS机源代码
💻 LST
📖 第 1 页 / 共 5 页
字号:
C51 COMPILER V7.06   LPRTPOS1                                                              01/08/2007 10:43:11 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE LPRTPOS1
OBJECT MODULE PLACED IN Lprtpos1.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE Lprtpos1.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1             #include <stdio.h>
   2             #include <absacc.h>
   3             #include <reg52.h>
   4             #include <math.h>
   5             #include <intrins.h>
   6             #define UINT8  unsigned char
   7             #define UINT16 unsigned int
   8             #define UINT32 unsigned long
   9          void cleastc(void);
  10          /*        新增特殊功能寄存器定义        */  
  11          sfr      ISP_DATA       =   0xe2;
  12          sfr     ISP_ADDRH       =   0xe3;  
  13          sfr      ISP_ADDRL      =   0xe4;
  14          sfr      ISP_CMD        =   0xe5; 
  15          sfr      ISP_TRIG       =   0xe6;   
  16          sfr      ISP_CONTR    =   0xe7; 
  17          
  18          #define F_TM F0
  19          #define TIMER0_ENABLE  TL0=TH0; TR0=1;
  20          #define TIMER0_DISABLE TR0=0;
  21           sbit busy=P3^4;sbit BT_SND=P3^5;
  22           sbit BT_REC=P1^2;sbit p16=P1^6;
  23          
  24          
  25          sbit sda = P3^2;
  26          sbit scl = P3^3;
  27          sbit p37 = P3^7;
  28          sbit vp15=P1^5;
  29          sbit vp20=P2^0;
  30          sbit vp21=P2^1;
  31          sbit vp22=P2^2;
  32          sbit vp23=P2^3;
  33          sbit vp24=P2^4;
  34          idata UINT8 rom_snd[9];
  35          idata UINT8 time[7];  
  36          /*time[0]-sec time[1]--min time[2]-hour time[3]-day time[4]-week time[5]-month time[6]-year*/
  37            UINT8 code  led[27]={0xe7,0x84,0xd3,0xd6,0xb4,0x76,0x77,0xc4,0xf7,0xf4,0x08,
  38                                 0xf5,0x37,0x63,0x97,0x73,0x71,0xf6,0xb5,0x23,0xe5,0xd9,
  39                                 0x10,0x33,0x34,0x17,0xd9}; 
  40          
  41             UINT8 code keytab[4][12]=
  42          {
  43          {0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X0B,0XFF,0XFF,0XFF,0XFF,0XFF},
  44          {0XFF,0X01,0X04,0X07,0X00,0X0D,0XFF,0X11,0X14,0X17,0X1A,0X1D},
  45          {0XFF,0X02,0X05,0X08,0X0A,0X10,0XFF,0X12,0X15,0X18,0X1B,0X1E},
  46          {0XFF,0X03,0X06,0X09,0X0C,0X0E,0XFF,0X13,0X16,0X19,0X1C,0X1F}
  47          };
  48            bit flag=0,lcbj=0;
  49            UINT8 nmm=0,unit=0,pmbj,cred1=0,cred2=0,dday,curday;
  50            UINT8 data cyear=0x06,cmonth=0x08,cday=0x29,chour=15,cmin=30;
  51          // UINT8 idata dwmc[16],ypass[4];
  52           UINT8 idata  zdmoney[8],zmmoney[8],umoney1[8],umoney2[8],umoney3[8],umoney4[8],umoney5[8],umoney6[8];
  53          
  54          
  55          
C51 COMPILER V7.06   LPRTPOS1                                                              01/08/2007 10:43:11 PAGE 2   

  56          void prtinit(void) ;
  57          
  58          
  59          /*延时tms*/
  60          void delay(UINT8 t)
  61          {
  62   1      UINT8 i,j;
  63   1      for(i=0;i<t;i++){
  64   2      for(j=0;j<112;j++)
  65   2      {;}}
  66   1      }
  67          
  68          /*软件复位*/
  69          void stcrst(void)
  70          {
  71   1      ISP_CONTR=0x20;
  72   1      }
  73          /*发送I2C总线起始条件子程序 */
  74          
  75          char I_start()
  76          {
  77   1      scl=1; /* release SCL */
  78   1      sda=1; /* release SDA */
  79   1      _nop_();
  80   1      if( scl==0 || sda==0 ) return 0; /* IIC bus not available, Start false */
  81   1      else
  82   1      {
  83   2      scl=1; /* Send start operation */
  84   2      _nop_();
  85   2      _nop_();
  86   2      sda=0; /* SDA high-to-low when SCL high */
  87   2      _nop_();
  88   2      _nop_();
  89   2      _nop_(); /*one cycle delay function */
  90   2      _nop_(); /*declare in <intrins.h> */
  91   2      _nop_();
  92   2      scl=0; 
  93   2      _nop_();
  94   2      sda=1; /*release SDA */
  95   2      }
  96   1      } /*return with SDA high, SCL low */
  97          
  98          /*I2C总线停止条件子程序 */
  99          void I_stop()
 100          { 
 101   1      sda=0;
 102   1      _nop_();
 103   1      scl=1;
 104   1      _nop_();
 105   1      _nop_();
 106   1      _nop_();
 107   1      _nop_();
 108   1      _nop_();
 109   1      sda=1; /* SDA low-to-high when SCL high, return with SCL SDA high */
 110   1      }
 111          
 112          /*字节数据传送子程序*/
 113           
 114          
 115          bit  sendbyte_p(UINT8 c)          //if  ACK=1 the data of sended  is ok
 116          {                               //if  ACK=0 the data of sended  is not received
 117   1        UINT8 BitCnt;
C51 COMPILER V7.06   LPRTPOS1                                                              01/08/2007 10:43:11 PAGE 3   

 118   1       bit ACK;
 119   1      
 120   1       for(BitCnt=0;BitCnt<8;BitCnt++)     // data`length is eight
 121   1            {
 122   2              if((c<<BitCnt)&0x80)
 123   2          {
 124   3           sda=1;
 125   3             }
 126   2               else
 127   2          {
 128   3          sda=0;
 129   3                }
 130   2                _nop_();
 131   2      
 132   2            scl=1;                /*begin receive data*/
 133   2      //_nop_();_nop_(); _nop_();
 134   2      _nop_();_nop_();_nop_();
 135   2           scl=0;
 136   2                     }
 137   1      
 138   1                _nop_();
 139   1                _nop_();
 140   1           sda=1;                /*begin receive ACK*/
 141   1            _nop_();
 142   1            _nop_();
 143   1           scl=1;
 144   1      //_nop_();_nop_(); _nop_();
 145   1      _nop_();_nop_();_nop_();
 146   1      
 147   1           if(sda==1)
 148   1        {
 149   2         ACK=0;        /*Is receive ACK?*/
 150   2            }
 151   1             else
 152   1           {
 153   2            ACK=1;
 154   2              }
 155   1           scl=0;
 156   1            _nop_();
 157   1            _nop_();
 158   1           return(ACK);
 159   1      
 160   1      }
 161          
 162          
 163          UINT8  rcvbyte_p(void)
 164          {
 165   1         UINT8 retc;
 166   1         UINT8 BitCnt;
 167   1      
 168   1         retc=0;
 169   1         sda=1;              /*set receive`state*/
 170   1         for(BitCnt=0;BitCnt<8;BitCnt++)
 171   1              {
 172   2                _nop_();
 173   2      
 174   2                scl=0;          /*begin receive data*/
 175   2      
 176   2      //_nop_();_nop_(); _nop_();
 177   2      _nop_();_nop_();_nop_();
 178   2      
 179   2                scl=1;          /*make data valid*/
C51 COMPILER V7.06   LPRTPOS1                                                              01/08/2007 10:43:11 PAGE 4   

 180   2                _nop_();
 181   2                _nop_();
 182   2                retc=retc<<1;
 183   2                if(sda==1)retc=retc+1;
 184   2                _nop_();
 185   2                _nop_();
 186   2              }
 187   1         scl=0;
 188   1         _nop_();
 189   1         _nop_();
 190   1      
 191   1         return(retc);
 192   1      }
 193          
 194           
 195          
 196          void ack_i2c_p(bit a)
 197          {
 198   1      
 199   1         if(a==0)
 200   1        {
 201   2         sda=0;        /*is not last byte*/
 202   2          }
 203   1              else
 204   1        {
 205   2         sda=1;     /*is last byte*/
 206   2               }
 207   1      //_nop_();_nop_(); _nop_();
 208   1      _nop_();_nop_();_nop_();
 209   1      
 210   1         scl=1;
 211   1      //_nop_();_nop_(); _nop_();
 212   1      _nop_();_nop_();_nop_();
 213   1      
 214   1        scl=0;                 /*begin receive data  again*/
 215   1           _nop_();
 216   1           _nop_();
 217   1      
 218   1      }
 219          
 220          void get_time(UINT8 time[])
 221          {
 222   1           UINT8 i;
 223   1           bit a;
 224   1           a=0;
 225   1      
 226   1             I_start();
 227   1             while(~sendbyte_p(0xa2));               //send  slave  address
 228   1             while(~sendbyte_p(0x02));               //send word address
 229   1             I_start();
 230   1             while(~sendbyte_p(0xa3));
 231   1             for (i=0; i<7; i++)
 232   1                {
 233   2                   time[i]=rcvbyte_p();
 234   2                   if (i==6){
 235   3                   a=1;
 236   3                    }
 237   2                   ack_i2c_p(a);
 238   2                }
 239   1             I_stop();
 240   1      
 241   1             time[0] &= 0x7f;
C51 COMPILER V7.06   LPRTPOS1                                                              01/08/2007 10:43:11 PAGE 5   

 242   1             time[1] &= 0x7f;
 243   1             time[2] &= 0x3f;
 244   1             time[3] &= 0x3f;
 245   1             time[4] &= 0x07;
 246   1             time[5] &= 0x1f;
 247   1             time[6] &= 0xff;
 248   1      }
 249          
 250          void get_time1(UINT8 time[])
 251          {
 252   1           UINT8 i;
 253   1           bit a;
 254   1           a=0;
 255   1      
 256   1             I_start();
 257   1             while(~sendbyte_p(0xa2));               //send  slave  address
 258   1             while(~sendbyte_p(0x02));               //send word address
 259   1             I_start();
 260   1             while(~sendbyte_p(0xa3));
 261   1             for (i=0; i<4; i++)
 262   1                {
 263   2                   time[i]=rcvbyte_p();
 264   2                   if (i==2){
 265   3                   a=1;
 266   3                    }
 267   2                   ack_i2c_p(a);
 268   2                }
 269   1             I_stop();
 270   1      
 271   1             time[0] &= 0x7f;
 272   1             time[1] &= 0x7f;
 273   1             time[2] &= 0x3f;
 274   1             time[3] &= 0x3f;
 275   1            /* time[4] &= 0x07;
 276   1             time[5] &= 0x1f;
 277   1             time[6] &= 0xff;
 278   1             */
 279   1      }
 280          
 281          
 282          void set_time(UINT8 time[])
 283          {
 284   1           UINT8 i;
 285   1       I_start();
 286   1             while(~sendbyte_p(0xa2));
 287   1             while(~sendbyte_p(0x02));
 288   1           for(i=0;i<7;i++)
 289   1            {
 290   2               while(~sendbyte_p(time[i]));
 291   2            }
 292   1            I_stop();
 293   1      }
 294          
 295          
 296           
 297           
 298           
 299           
 300          /*时钟显示子程序 */
 301          void leddisplay(void)
 302          {
 303   1      
C51 COMPILER V7.06   LPRTPOS1                                                              01/08/2007 10:43:11 PAGE 6   

 304   1      p37=0;P2=P2&0xe0;vp15=0;P0=0;p37=1;vp15=1;P2=0xff;
 305   1      p37=0;
 306   1      P2=P2&0xe0;vp15=0;
 307   1      P0=led[time[2] / 16];
 308   1      p37=1;
 309   1      vp20=1;
 310   1      delay(1); 
 311   1      

⌨️ 快捷键说明

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