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-fpga-flash.h] - Diff between revs 4 and 8

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 4 Rev 8
Line 1... Line 1...
/*!
/*!
   ZTEX Firmware Kit for EZ-USB Microcontrollers
   ZTEX Firmware Kit for EZ-USB FX2 Microcontrollers
   Copyright (C) 2009-2010 ZTEX e.K.
   Copyright (C) 2009-2011 ZTEX GmbH.
   http://www.ztex.de
   http://www.ztex.de
 
 
   This program is free software; you can redistribute it and/or modify
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License version 3 as
   it under the terms of the GNU General Public License version 3 as
   published by the Free Software Foundation.
   published by the Free Software Foundation.
Line 19... Line 19...
/*
/*
    Common functions for FPGA configuration from flash memory
    Common functions for FPGA configuration from flash memory
*/
*/
 
 
 
 
code BYTE fpga_flash_boot_id[] = {'Z','T','E', 'X', 'B', 'S', '\1', '\1'};
__code BYTE fpga_flash_boot_id[] = {'Z','T','E', 'X', 'B', 'S', '\1', '\1'};
 
 
/* *********************************************************************
/* *********************************************************************
   ***** fpga_configure_from_flash *************************************
   ***** fpga_configure_from_flash *************************************
   ********************************************************************* */
   ********************************************************************* */
/*
/*
    Configure the FPGA using a bitstream from flash.
    Configure the FPGA using a bitstream from flash.
    If force == 0 a already configured FPGA is not re-configured.
    If force == 0 a already configured FPGA is not re-configured.
    Return values:
    Return values:
        0 : configuration successfull
        0 : Configuration successful
        1 : fpga already configured
        1 : FPGA already configured
        2 : Flash error
        2 : Flash error
        3 : No bitstream found
        3 : No bitstream found
        4 : Configuration error
        4 : Configuration error
 
 
    The format of the boot sector (secor 0 of the flash memeory) is
    The format of the boot sector (secor 0 of the flash memeory) is
Line 73... Line 73...
    flash_read_finish(flash_sector_size - 12);          // dummy-read the rest of the sector + finish read opration
    flash_read_finish(flash_sector_size - 12);          // dummy-read the rest of the sector + finish read opration
    if ( i==0 )
    if ( i==0 )
        return 3;
        return 3;
 
 
    // read the bitstream
    // read the bitstream
    for ( k=1; k<i; k++ ) {
    if ( flash_read_init( 1 ) )                 // prepare reading sector k
        if ( flash_read_init( k ) )             // prepare reading sector k
 
            return 2;
            return 2;
 
    for ( k=1; k<i; k++ ) {
        fpga_send_bitstream_from_flash( flash_sector_size );
        fpga_send_bitstream_from_flash( flash_sector_size );
        flash_read_finish(0);                    // finish read opration
        if ( flash_read_next() )                // prepare reading next sector
    }
 
    if ( flash_read_init( i ) )                 // prepare reading sector i
 
        return 2;
        return 2;
 
    }
    fpga_send_bitstream_from_flash( j );
    fpga_send_bitstream_from_flash( j );
    flash_read_finish(flash_sector_size - j);   // finish read opration
    flash_read_finish(flash_sector_size - j);   // finish read opration
 
 
    finish_fpga_configuration();                // finish the FPGA configuration
    finish_fpga_configuration();                // finish the FPGA configuration
 
 

powered by: WebSVN 2.1.0

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