OpenCores
URL https://opencores.org/ocsvn/usb_fpga_1_2/usb_fpga_1_2/trunk

Subversion Repositories usb_fpga_1_2

[/] [usb_fpga_1_2/] [trunk/] [include/] [ztex-flash1.h] - Diff between revs 8 and 9

Show entire file | Details | Blame | View Log

Rev 8 Rev 9
Line 823... Line 823...
void flash_read_finish(WORD n) {
void flash_read_finish(WORD n) {
    while ( n > 32 ) {
    while ( n > 32 ) {
        mmc_clocks(0);                   // 256 clocks = 32 dummy bytes
        mmc_clocks(0);                   // 256 clocks = 32 dummy bytes
        n-=32;
        n-=32;
    }
    }
    mmc_clocks(n << 3);
    if ( n>0) mmc_clocks(n << 3);
    mmc_clocks(16);                     // 16 CRC clocks 
    mmc_clocks(16);                     // 16 CRC clocks 
    mmc_send_cmd(12, 0.0.0.0, 0);        // stop transmission command, errors are ignored
    mmc_send_cmd(12, 0.0.0.0, 0);        // stop transmission command, errors are ignored
//    mmc_wait_busy();                  // not required here
//    mmc_wait_busy();                  // not required here
    mmc_clocks(8);                      // 8 dummy clocks
    mmc_clocks(8);                      // 8 dummy clocks
   mmc_deselect();
   mmc_deselect();
Line 888... Line 888...
   but do not write the finalization procedure. This is done by flash_write_finish
   but do not write the finalization procedure. This is done by flash_write_finish
   or flash_write_next, i.e. these functions must be called after flash_write_finish_sector.
   or flash_write_next, i.e. these functions must be called after flash_write_finish_sector.
 
 
   Between flash_write_finish / flash_write_next and flash_write_finish_sector some code
   Between flash_write_finish / flash_write_next and flash_write_finish_sector some code
   may be executed because flash_write_finish / flash_write_next start with
   may be executed because flash_write_finish / flash_write_next start with
   mmc_wauit_busy().
   mmc_wait_busy().
 
 
   Returns an error code (FLASH_EC_*). 0 means no error.
   Returns an error code (FLASH_EC_*). 0 means no error.
*/
*/
BYTE flash_write_finish_sector (WORD n) {
BYTE flash_write_finish_sector (WORD n) {
    MMC_IO &= ~MMC_bmDI;                        // value of the dummy data is 0
    MMC_IO &= ~MMC_bmDI;                        // value of the dummy data is 0
    while ( n > 32 ) {
    while ( n > 32 ) {
        mmc_clocks(0);                           // 256 clocks = 32 dummy bytes
        mmc_clocks(0);                           // 256 clocks = 32 dummy bytes
        n-=32;
        n-=32;
    }
    }
    mmc_clocks(n << 3);
    if ( n>0) mmc_clocks(n << 3);
 
 
    MMC_IO |= MMC_bmDI;
    MMC_IO |= MMC_bmDI;
    mmc_clocks(16);                             // 16 CRC clocks
    mmc_clocks(16);                             // 16 CRC clocks
 
 
    if ( (flash_read_byte() & 0xf) != 5 ) {     // data response: last four bits must be 5
    if ( (flash_read_byte() & 0xf) != 5 ) {     // data response: last four bits must be 5
Line 944... Line 944...
   ********************************************************************* */
   ********************************************************************* */
// init the card
// init the card
void flash_init() {
void flash_init() {
    BYTE i, j, k;
    BYTE i, j, k;
 
 
 
#ifeq[UFM_1_15X_DETECTION_ENABLED][1]
 
    if ( is_ufm_1_15x ) {
 
        flash_enabled = 0;
 
        flash_ec = FLASH_EC_NOTSUPPORTED;
 
        return;
 
    }
 
#endif    
 
 
    flash_enabled = 1;
    flash_enabled = 1;
    flash_sector_size = 512;
    flash_sector_size = 512;
    mmc_version = 0;
    mmc_version = 0;
 
 
    OEMMC_PORT = OEMMC_PORT | ( MMC_bmCS | MMC_bmDI | MMC_bmCLK );
    OEMMC_PORT = OEMMC_PORT | ( MMC_bmCS | MMC_bmDI | MMC_bmCLK );

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.