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

📄 mmc_drv.lst

📁 atmel at89c51snd1c mp3芯片方案源码
💻 LST
📖 第 1 页 / 共 2 页
字号:
 318   3                  gl_media_buffer[i++] = Mmc_rd_byte();
 319   3              gl_media_buffer[i++] = Mmc_rd_byte();
 320   3                  gl_media_buffer[i++] = Mmc_rd_byte();
 321   3              gl_media_buffer[i++] = Mmc_rd_byte();
 322   3                  gl_media_buffer[i++] = Mmc_rd_byte();
 323   3              gl_media_buffer[i++] = Mmc_rd_byte();
 324   3                  gl_media_buffer[i++] = Mmc_rd_byte();
 325   3              gl_media_buffer[i++] = Mmc_rd_byte();
 326   3                  gl_media_buffer[i++] = Mmc_rd_byte();
 327   3              gl_media_buffer[i++] = Mmc_rd_byte();
 328   3               }
 329   2               Mmc_disable_flow_ctrl(); 
 330   2           return TRUE;
 331   2        }
 332   1        else
 333   1        {
 334   2           return FALSE;
 335   2        }
 336   1      }
 337          
 338          
 339          //////////////////////////////////////////////////////////////////////////////
 340          bit mmc_read_close(void)
 341          {
 342   1         Mmc_disable_flow_ctrl();
 343   1         bMediaReadOpenFlag = 0;
 344   1         return OK;
 345   1      }
 346          
 347          
 348          //////////////////////////////////////////////////////////////////////////////
 349          INT8U mmc_read_byte(void)
 350          {  
 351   1         INT8U u8Data;
 352   1      
 353   1         if(u16MediaBytePointer >= 512)
 354   1         {
 355   2            u32MediaSector ++;               //sector number add
 356   2            mmc_read_close();
 357   2            mmc_read_open(u32MediaSector);
 358   2         }
 359   1      
 360   1         u8Data = gl_media_buffer[u16MediaBytePointer ++];
 361   1         return(u8Data);
 362   1      }
 363          
 364          
C51 COMPILER V7.50   MMC_DRV                                                               02/16/2009 09:59:52 PAGE 7   

 365          //////////////////////////////////////////////////////////////////////////////
 366          bit mmc_read_one_sector(INT32U u32MmcSector)
 367          {
 368   1        Byte i;
 369   1      
 370   1        if(mmc_read_open(u32MmcSector) == OK)
 371   1        {
 372   2           for (i = 0; i < 8; i++)
 373   2           {
 374   3              Usb_select_ep(EP_IN);
 375   3                            /* read 64 bytes from card */
 376   3              Usb_write_byte(mmc_read_byte());        
 377   3              Usb_write_byte(mmc_read_byte());
 378   3              Usb_write_byte(mmc_read_byte());        
 379   3              Usb_write_byte(mmc_read_byte());
 380   3              Usb_write_byte(mmc_read_byte());        
 381   3              Usb_write_byte(mmc_read_byte());
 382   3              Usb_write_byte(mmc_read_byte());        
 383   3              Usb_write_byte(mmc_read_byte());
 384   3              Usb_write_byte(mmc_read_byte());        
 385   3              Usb_write_byte(mmc_read_byte());
 386   3              Usb_write_byte(mmc_read_byte());        
 387   3              Usb_write_byte(mmc_read_byte());
 388   3              Usb_write_byte(mmc_read_byte());        
 389   3              Usb_write_byte(mmc_read_byte());
 390   3              Usb_write_byte(mmc_read_byte());        
 391   3              Usb_write_byte(mmc_read_byte());
 392   3              Usb_write_byte(mmc_read_byte());        
 393   3              Usb_write_byte(mmc_read_byte());
 394   3              Usb_write_byte(mmc_read_byte());        
 395   3              Usb_write_byte(mmc_read_byte());
 396   3              Usb_write_byte(mmc_read_byte());        
 397   3              Usb_write_byte(mmc_read_byte());
 398   3              Usb_write_byte(mmc_read_byte());        
 399   3              Usb_write_byte(mmc_read_byte());
 400   3              Usb_write_byte(mmc_read_byte());        
 401   3              Usb_write_byte(mmc_read_byte());
 402   3              Usb_write_byte(mmc_read_byte());        
 403   3              Usb_write_byte(mmc_read_byte());
 404   3              Usb_write_byte(mmc_read_byte());        
 405   3              Usb_write_byte(mmc_read_byte());
 406   3              Usb_write_byte(mmc_read_byte());        
 407   3              Usb_write_byte(mmc_read_byte());
 408   3              Usb_write_byte(mmc_read_byte());        
 409   3              Usb_write_byte(mmc_read_byte());
 410   3              Usb_write_byte(mmc_read_byte());        
 411   3              Usb_write_byte(mmc_read_byte());
 412   3              Usb_write_byte(mmc_read_byte());        
 413   3              Usb_write_byte(mmc_read_byte());
 414   3              Usb_write_byte(mmc_read_byte());        
 415   3              Usb_write_byte(mmc_read_byte());
 416   3              Usb_write_byte(mmc_read_byte());        
 417   3              Usb_write_byte(mmc_read_byte());
 418   3              Usb_write_byte(mmc_read_byte());        
 419   3              Usb_write_byte(mmc_read_byte());
 420   3              Usb_write_byte(mmc_read_byte());        
 421   3              Usb_write_byte(mmc_read_byte());
 422   3              Usb_write_byte(mmc_read_byte());        
 423   3              Usb_write_byte(mmc_read_byte());
 424   3              Usb_write_byte(mmc_read_byte());        
 425   3              Usb_write_byte(mmc_read_byte());
 426   3              Usb_write_byte(mmc_read_byte());        
C51 COMPILER V7.50   MMC_DRV                                                               02/16/2009 09:59:52 PAGE 8   

 427   3              Usb_write_byte(mmc_read_byte());
 428   3              Usb_write_byte(mmc_read_byte());        
 429   3              Usb_write_byte(mmc_read_byte());
 430   3              Usb_write_byte(mmc_read_byte());        
 431   3              Usb_write_byte(mmc_read_byte());
 432   3              Usb_write_byte(mmc_read_byte());        
 433   3              Usb_write_byte(mmc_read_byte());
 434   3              Usb_write_byte(mmc_read_byte());        
 435   3              Usb_write_byte(mmc_read_byte());
 436   3              Usb_write_byte(mmc_read_byte());        
 437   3              Usb_write_byte(mmc_read_byte());
 438   3              Usb_write_byte(mmc_read_byte());        
 439   3              Usb_write_byte(mmc_read_byte());
 440   3           
 441   3              Usb_set_TXRDY();
 442   3              Usb_select_ep(EP_IN);
 443   3              while (!Usb_tx_complete());
 444   3              Usb_clear_TXCMPL();  
 445   3           }   
 446   2           mmc_read_close();
 447   2           return OK;
 448   2         }
 449   1         return KO;
 450   1      }
 451          
 452          
 453          //////////////////////////////////////////////////////////////////////////////
 454          bit mmc_write_open(INT32U u32MmcSector)
 455          {  
 456   1         u32MediaSector = u32MmcSector;
 457   1         u16MediaBytePointer = 0;         //point to the first byte of the sector
 458   1         bMediaWriteOpenFlag = 1;
 459   1         Mmc_disable_flow_ctrl();
 460   1         return TRUE;
 461   1      }
 462          
 463          
 464          //////////////////////////////////////////////////////////////////////////////
 465          bit mmc_write_close(void)
 466          {    
 467   1        INT32U u32Address;   
 468   1        INT16U i;
 469   1      
 470   1        u32Address = u32MediaSector;
 471   1        u32Address <<= 9;
 472   1      
 473   1        Mmc_enable_flow_ctrl();    //enable control
 474   1        Mmc_set_write();                      //set write mode
 475   1      
 476   1        Mmc_write_block_cmd(u32Address);    //send write command
 477   1      
 478   1        if(OK == mmc_response_Try())
 479   1        {      
 480   2           i = 0;
 481   2      
 482   2               Mmc_wr_byte(gl_media_buffer[i++]); 
 483   2               Mmc_wr_byte(gl_media_buffer[i++]);
 484   2               Mmc_wr_byte(gl_media_buffer[i++]); 
 485   2               Mmc_wr_byte(gl_media_buffer[i++]);
 486   2               Mmc_wr_byte(gl_media_buffer[i++]); 
 487   2               Mmc_wr_byte(gl_media_buffer[i++]);
 488   2               Mmc_wr_byte(gl_media_buffer[i++]); 
C51 COMPILER V7.50   MMC_DRV                                                               02/16/2009 09:59:52 PAGE 9   

 489   2               Mmc_wr_byte(gl_media_buffer[i++]);
 490   2               Mmc_wr_byte(gl_media_buffer[i++]); 
 491   2               Mmc_wr_byte(gl_media_buffer[i++]);
 492   2               Mmc_wr_byte(gl_media_buffer[i++]); 
 493   2               Mmc_wr_byte(gl_media_buffer[i++]);
 494   2               Mmc_wr_byte(gl_media_buffer[i++]); 
 495   2               Mmc_wr_byte(gl_media_buffer[i++]);
 496   2               Mmc_wr_byte(gl_media_buffer[i++]); 
 497   2               Mmc_wr_byte(gl_media_buffer[i++]);
 498   2               
 499   2               Mmc_enable_send();   //enable sent
 500   2       //    while(Mmc_write_not_ready());
 501   2       //    lcd_print_string(0x40,"ready");
 502   2       //    Mmc_enable_send();
 503   2         //  while(!Mmc_empty_fifos());    //fifo isn't empty
 504   2         //  printch(0x40,"2");
 505   2      
 506   2               for(; i<512; )
 507   2               {      
 508   3               //       printch(0x40,"2");
 509   3                   //while(!Mmc_empty_fifos());    //fifo isn't empty
 510   3               //       printch(0x40,"3");
 511   3                       if(Mmc_empty_fifos())
 512   3                       {
 513   4                              Mmc_wr_byte(gl_media_buffer[i++]); 
 514   4                              Mmc_wr_byte(gl_media_buffer[i++]);
 515   4                              Mmc_wr_byte(gl_media_buffer[i++]); 
 516   4                              Mmc_wr_byte(gl_media_buffer[i++]);
 517   4                              Mmc_wr_byte(gl_media_buffer[i++]); 
 518   4                              Mmc_wr_byte(gl_media_buffer[i++]);
 519   4                              Mmc_wr_byte(gl_media_buffer[i++]); 
 520   4                              Mmc_wr_byte(gl_media_buffer[i++]); 
 521   4                       }
 522   3               }
 523   2      
 524   2           bMediaWriteOpenFlag = 0;
 525   2           Mmc_disable_flow_ctrl();
 526   2      
 527   2           lcd_print_string(0x40,"4");
 528   2           return TRUE;
 529   2         }
 530   1         else
 531   1         {
 532   2           return FALSE;
 533   2         }
 534   1      
 535   1      }
 536          
 537          //////////////////////////////////////////////////////////////////////////////
 538          bit mmc_write_byte(Byte mmc_data)
 539          {   
 540   1         gl_media_buffer[u16MediaBytePointer ++] = mmc_data;
 541   1         return TRUE;
 542   1      }
 543          
 544          
 545          //////////////////////////////////////////////////////////////////////////////
 546          bit mmc_write_one_sector(Uint32 mmc_sector)
 547          {
 548   1         INT8U j;
 549   1         mmc_write_open(mmc_sector);
 550   1      
C51 COMPILER V7.50   MMC_DRV                                                               02/16/2009 09:59:52 PAGE 10  

 551   1         Usb_select_ep(EP_OUT);   
 552   1      
 553   1         for (j=0; j<8; j++)
 554   1         {
 555   2            while(!Usb_rx_complete());          /* wait end of reception */
 556   2      
 557   2                mmc_write_byte(Usb_read_byte());
 558   2            mmc_write_byte(Usb_read_byte());
 559   2            mmc_write_byte(Usb_read_byte());
 560   2            mmc_write_byte(Usb_read_byte());
 561   2            mmc_write_byte(Usb_read_byte());
 562   2            mmc_write_byte(Usb_read_byte());
 563   2            mmc_write_byte(Usb_read_byte());
 564   2            mmc_write_byte(Usb_read_byte());
 565   2            mmc_write_byte(Usb_read_byte());
 566   2            mmc_write_byte(Usb_read_byte());
 567   2            mmc_write_byte(Usb_read_byte());
 568   2            mmc_write_byte(Usb_read_byte());
 569   2            mmc_write_byte(Usb_read_byte());
 570   2            mmc_write_byte(Usb_read_byte());
 571   2            mmc_write_byte(Usb_read_byte());
 572   2            mmc_write_byte(Usb_read_byte());
 573   2            mmc_write_byte(Usb_read_byte());
 574   2            mmc_write_byte(Usb_read_byte());
 575   2            mmc_write_byte(Usb_read_byte());
 576   2            mmc_write_byte(Usb_read_byte());
 577   2            mmc_write_byte(Usb_read_byte());
 578   2            mmc_write_byte(Usb_read_byte());
 579   2            mmc_write_byte(Usb_read_byte());
 580   2            mmc_write_byte(Usb_read_byte());
 581   2            mmc_write_byte(Usb_read_byte());
 582   2            mmc_write_byte(Usb_read_byte());
 583   2            mmc_write_byte(Usb_read_byte());
 584   2            mmc_write_byte(Usb_read_byte());
 585   2            mmc_write_byte(Usb_read_byte());
 586   2            mmc_write_byte(Usb_read_byte());
 587   2            mmc_write_byte(Usb_read_byte());
 588   2            mmc_write_byte(Usb_read_byte());
 589   2            mmc_write_byte(Usb_read_byte());
 590   2            mmc_write_byte(Usb_read_byte());
 591   2            mmc_write_byte(Usb_read_byte());
 592   2            mmc_write_byte(Usb_read_byte());
 593   2            mmc_write_byte(Usb_read_byte());
 594   2            mmc_write_byte(Usb_read_byte());
 595   2            mmc_write_byte(Usb_read_byte());
 596   2            mmc_write_byte(Usb_read_byte());
 597   2            mmc_write_byte(Usb_read_byte());
 598   2            mmc_write_byte(Usb_read_byte());
 599   2            mmc_write_byte(Usb_read_byte());
 600   2            mmc_write_byte(Usb_read_byte());
 601   2            mmc_write_byte(Usb_read_byte());
 602   2            mmc_write_byte(Usb_read_byte());
 603   2            mmc_write_byte(Usb_read_byte());
 604   2            mmc_write_byte(Usb_read_byte());
 605   2            mmc_write_byte(Usb_read_byte());
 606   2            mmc_write_byte(Usb_read_byte());
 607   2            mmc_write_byte(Usb_read_byte());
 608   2            mmc_write_byte(Usb_read_byte());
 609   2            mmc_write_byte(Usb_read_byte());
 610   2            mmc_write_byte(Usb_read_byte());
 611   2            mmc_write_byte(Usb_read_byte());
 612   2            mmc_write_byte(Usb_read_byte());
C51 COMPILER V7.50   MMC_DRV                                                               02/16/2009 09:59:52 PAGE 11  

 613   2            mmc_write_byte(Usb_read_byte());
 614   2            mmc_write_byte(Usb_read_byte());
 615   2            mmc_write_byte(Usb_read_byte());
 616   2            mmc_write_byte(Usb_read_byte());
 617   2            mmc_write_byte(Usb_read_byte());
 618   2            mmc_write_byte(Usb_read_byte());
 619   2            mmc_write_byte(Usb_read_byte());
 620   2            mmc_write_byte(Usb_read_byte());
 621   2      
 622   2            Usb_clear_RXOUT_PP();          
 623   2         }
 624   1        
 625   1         mmc_write_close();
 626   1         return OK;    
 627   1      }
 628          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   2395    ----
   CONSTANT SIZE    =      2    ----
   XDATA SIZE       =      2      39
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      1    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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