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

📄 sram.lst

📁 指纹识别源代码,用于智能门紧,还有配合MF800卡使用
💻 LST
📖 第 1 页 / 共 5 页
字号:
 277          void ram_write8(unsigned char ramitem8,unsigned char ramitem16)
 278          {
 279   1              SRAMA16=0;
 280   1              SRAMA17=0;
 281   1              SRAMA18=0;
 282   1      
 283   1              ramitem16=(ramitem16<<3)|(ramitem8>>5);
 284   1              ramitem8<<=3;
 285   1      
 286   1      
 287   1              DATAPORT=ramitem16;
 288   1              SEL573H=1;
 289   1              _nop_();
 290   1              SEL573H=0;
 291   1      
 292   1              //for(;(ramitem8&0x7)!=0x7;ramitem8++)
 293   1              do
 294   1              {
 295   2                      DATAPORT=ramitem8;
 296   2                      SEL573L=1;
 297   2                      _nop_();
 298   2                      SEL573L=0;
 299   2              
 300   2      
 301   2                      DATAPORT=tempbuff[ramitem8&0x7];
 302   2                      SELK6=0;
C51 COMPILER V7.01  SRAM                                                                   03/08/2007 12:09:36 PAGE 6   

 303   2                      WR=0;
 304   2                      _nop_();
 305   2                      WR=1;
 306   2                      SELK6=1;
 307   2                      ramitem8++;
 308   2              }while(ramitem8&0x7);
 309   1      }
 310          /////////////////////////////////////////////////////////////////////////
 311          void init_sram()
 312          {
 313   1              //unsigned char tempdata;
 314   1              
 315   1              //deletealluser();
 316   1              
 317   1              //sramtest();
 318   1              //ram_read16(128,0);
 319   1              //ram_read16(0,0);
 320   1              
 321   1              
 322   1      }
 323          /////////////////////////////////////////////////////////////////////////
 324          /////////////////////////////////////////////////////////////////////////
 325          unsigned short sramgetshort(unsigned char address)
 326          {
 327   1              unsigned short tempcount;
 328   1              //tempcount=(ram_readp0(address+1)<<8)|ram_readp0(address);
 329   1              tempcount=ram_readp0(address+1)<<8;
 330   1              tempcount|=ram_readp0(address);
 331   1              //tempcount=ram_readp0(address);
 332   1              //tempcount+=ram_readp0(address+1)<<8;
 333   1              return tempcount;
 334   1              
 335   1      }
 336          /////////////////////////////////////////////////////////////////////////
 337          unsigned char readsecumode()
 338          {
 339   1              unsigned char tempdata;
 340   1              tempdata=ram_readp0(SECUMODE);
 341   1              if(tempdata>=MAXSETMODESEL)
 342   1              {
 343   2                      ram_writep0(SECUMODE,0);
 344   2                      tempdata=0;
 345   2              }
 346   1              return tempdata;
 347   1      }
 348          /////////////////////////////////////////////////////////////////////////
 349          unsigned char readapbmode()
 350          {
 351   1              unsigned char tempdata;
 352   1              tempdata=ram_readp0(APBMODE);
 353   1              if(tempdata>=MAXSETAPBSEL)
 354   1              {
 355   2                      ram_writep0(APBMODE,0);
 356   2                      tempdata=0;
 357   2              }
 358   1              return tempdata;
 359   1      }
 360          /////////////////////////////////////////////////////////////////////////
 361          unsigned char readcommid()
 362          {
 363   1              unsigned char tempdata;
 364   1              tempdata=ram_readp0(COMMID);
C51 COMPILER V7.01  SRAM                                                                   03/08/2007 12:09:36 PAGE 7   

 365   1              if(tempdata>=MAXCOMMID)
 366   1              {
 367   2                      ram_writep0(COMMID,0);
 368   2                      tempdata=0;
 369   2              }
 370   1              return tempdata;
 371   1      }
 372          /////////////////////////////////////////////////////////////////////////
 373          unsigned char readduress()
 374          {
 375   1              unsigned char tempdata;
 376   1              tempdata=ram_readp0(DURESSMODE);
 377   1              if(tempdata>=MAXDURESSSEL)
 378   1              {
 379   2                      ram_writep0(DURESSMODE,0);
 380   2                      tempdata=0;
 381   2              }
 382   1              return tempdata;
 383   1      }
 384          /////////////////////////////////////////////////////////////////////////
 385          unsigned char readduresspw()
 386          {
 387   1              unsigned char tempdata;
 388   1              tempdata=ram_readp0(DURESSPW);
 389   1              if(tempdata>=100)
 390   1              {
 391   2                      ram_writep0(DURESSMODE,0);
 392   2                      tempdata=0;
 393   2              }
 394   1              return tempdata;
 395   1      }
 396          /////////////////////////////////////////////////////////////////////////
 397          unsigned char readbaudrate()
 398          {
 399   1              unsigned char tempdata;
 400   1              tempdata=ram_readp0(BAUDRATE);
 401   1              if(tempdata>=MAXBAUDRATESEL)
 402   1              {
 403   2                      ram_writep0(BAUDRATE,0);
 404   2                      tempdata=0;
 405   2              }
 406   1              return tempdata;
 407   1      }
 408          /////////////////////////////////////////////////////////////////////////
 409          unsigned char readpinkeyin()
 410          {
 411   1              unsigned char tempdata;
 412   1              tempdata=ram_readp0(PINKEYIN);
 413   1              if(tempdata>=MAXPINKEYINSEL)
 414   1              {
 415   2                      ram_writep0(PINKEYIN,1);
 416   2                      tempdata=1;
 417   2              }
 418   1              return tempdata;
 419   1      }
 420          /////////////////////////////////////////////////////////////////////////
 421          unsigned char readmodeindex()
 422          {
 423   1              unsigned char tempdata;
 424   1              tempdata=ram_readp0(MODEINDEX);
 425   1              if(tempdata>=MAXMODEINDEX)
 426   1              {
C51 COMPILER V7.01  SRAM                                                                   03/08/2007 12:09:36 PAGE 8   

 427   2                      ram_writep0(MODEINDEX,0);
 428   2                      tempdata=0;
 429   2              }
 430   1              return tempdata;
 431   1      }
 432          //////////////////////////////////////////////////////////////////////////////////////////////////////////
             -////////////////////////////////////////
 433          unsigned char readfpmode()
 434          {
 435   1              unsigned char tempdata;
 436   1              tempdata=ram_readp0(FPMODE);
 437   1              if(tempdata>=MAXFPMODESEL)
 438   1              {
 439   2                      ram_writep0(FPMODE,0);
 440   2                      tempdata=0;
 441   2              }
 442   1              return tempdata;
 443   1      }
 444          /////////////////////////////////////////////////////////////////////////
 445          /////////////////////////////////////////////////////////////////////////
 446          unsigned char readFunctions()
 447          {
 448   1              unsigned char tempdata;
 449   1              tempdata=ram_readp0(FUNCTIONS);
 450   1              if(tempdata>=MAXFUNCTIONS)
 451   1              {
 452   2                      ram_writep0(FUNCTIONS,0);
 453   2                      tempdata=0;
 454   2              }
 455   1              return tempdata;
 456   1      }
 457          /////////////////////////////////////////////////////////////////////////
 458          unsigned char readmasterchange()
 459          {
 460   1              unsigned char tempdata;
 461   1              tempdata=ram_readp0(MASTERCHANGED);
 462   1              if(tempdata>=MAXMASTERCHANGED)
 463   1              {
 464   2                      ram_writep0(MASTERCHANGED,0);
 465   2                      tempdata=0;
 466   2              }
 467   1              return tempdata;
 468   1      }
 469          /////////////////////////////////////////////////////////////////////////
 470          unsigned short readeventstart()
 471          {
 472   1              unsigned short eventstart;
 473   1      
 474   1              eventstart=ram_readp0(EVENTSTART);
 475   1              eventstart+=ram_readp0(EVENTSTART+1)<<8;
 476   1      
 477   1              if(eventstart>=MAXEVENTNUM)
 478   1              {
 479   2                      eventstart=0;
 480   2                      ram_writep0(EVENTSTART,0);
 481   2                      ram_writep0(EVENTSTART+1,0);
 482   2              }
 483   1              return eventstart;
 484   1      }
 485          /////////////////////////////////////////////////////////////////////////
 486          unsigned short readeventstop()
 487          {
C51 COMPILER V7.01  SRAM                                                                   03/08/2007 12:09:36 PAGE 9   

 488   1              unsigned short recordstop;
 489   1      
 490   1              recordstop=ram_readp0(EVENTSTOP+1)<<8;
 491   1              recordstop+=ram_readp0(EVENTSTOP);
 492   1      
 493   1              if(recordstop>=MAXEVENTNUM)
 494   1              {
 495   2                      recordstop=0;
 496   2                      ram_writep0(EVENTSTOP,0);
 497   2                      ram_writep0(EVENTSTOP+1,0);
 498   2              }
 499   1              return recordstop;
 500   1      }
 501          /////////////////////////////////////////////////////////////////////////
 502          unsigned char readholindex(unsigned char tsindex)
 503          {
 504   1              unsigned char tempdata;
 505   1              tempdata=ram_readp0(TSHOLINDEXSTART+tsindex);
 506   1              if(tempdata>=MAXTSHOLINDEX)
 507   1              {
 508   2                      ram_writep0(TSHOLINDEXSTART+tsindex,0);
 509   2                      tempdata=0;
 510   2              }
 511   1              return tempdata;
 512   1      }
 513          /////////////////////////////////////////////////////////////////////////
 514          /////////////////////////////////////////////////////////////////////////
 515          /*unsigned char readtype()
 516          {
 517                  unsigned char tempdata;
 518                  tempdata=ram_read(TYPE,0);
 519                  if(tempdata>=MAXSETTYPESEL)
 520                  {
 521                          ram_write(TYPE,0,0);
 522                          tempdata=0;
 523                  }
 524                  return tempdata;
 525          }*/
 526          /////////////////////////////////////////////////////////////////////////
 527          bit sramtest()
 528          {
 529   1              unsigned char testbank; //0~127
 530   1              unsigned char testgroup,i;
 531   1              
 532   1              for(testbank=0;testbank<128;testbank++)
 533   1              {
 534   2                      displaymessage(LMRAMTESTBANK,LINE1);
 535   2                      displayshort(testbank,3,9);
 536   2                      testgroup=0;
 537   2                      do
 538   2                      {
 539   3                              ram_read16(testgroup,testbank);
 540   3                              idata2idata(tempbuff,dispbuff[LINE1],16);
 541   3                              for(i=0;i<16;i++)tempbuff[i]=0x55;
 542   3                              ram_write16(testgroup,testbank);
 543   3                              ram_read16(testgroup,testbank);
 544   3                              for(i=0;i<16;i++)
 545   3                              {
 546   4                                      if(tempbuff[i]!=0x55)return FALSE;
 547   4                              }
 548   3                                              
 549   3                              for(i=0;i<16;i++)tempbuff[i]=0xaa;
C51 COMPILER V7.01  SRAM                                                                   03/08/2007 12:09:36 PAGE 10  

 550   3                              ram_write16(testgroup,testbank);
 551   3                              ram_read16(testgroup,testbank);
 552   3                              for(i=0;i<16;i++)
 553   3                              {
 554   4                                      if(tempbuff[i]!=0xaa)return FALSE;
 555   4                              }
 556   3                              
 557   3                              idata2idata(dispbuff[LINE1],tempbuff,16);
 558   3                              ram_write16(testgroup,testbank);
 559   3                              

⌨️ 快捷键说明

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