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

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

Rev 5 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 32... Line 32...
 
 
/* *********************************************************************
/* *********************************************************************
   ***** EEPROM support and some I2C helper functions ******************
   ***** EEPROM support and some I2C helper functions ******************
   ********************************************************************* */
   ********************************************************************* */
#ifneq[EEPROM_DISABLED][1]
#ifneq[EEPROM_DISABLED][1]
 
 
 
#ifneq[EEPROM_MAC_DISABLED][1]
 
#ifeq[PRODUCT_IS][UFM-1_15]
 
#define[MAC_EEPROM_ENABLED]
 
#endif // PRODUCT_IS=UFM-1_15
 
#endif // EEPROM_MAC_DISABLED
 
 
#include[ztex-eeprom.h]
#include[ztex-eeprom.h]
#endif
 
 
#endif // EEPROM_DISABLED
 
 
 
 
/* *********************************************************************
/* *********************************************************************
   ***** Flash memory support ******************************************
   ***** Flash memory support ******************************************
   ********************************************************************* */
   ********************************************************************* */
#ifeq[FLASH_ENABLED][1]
#ifeq[FLASH_ENABLED][1]
Line 90... Line 99...
#define[MMC_BIT_CS][5]
#define[MMC_BIT_CS][5]
#define[MMC_BIT_DI][7]
#define[MMC_BIT_DI][7]
#define[MMC_BIT_CLK][6]
#define[MMC_BIT_CLK][6]
#include[ztex-flash1.h]
#include[ztex-flash1.h]
 
 
 
#elifeq[PRODUCT_IS][UFM-1_15]
 
#define[MMC_PORT][C]
 
#define[MMC_BIT_DO][4]
 
#define[MMC_BIT_CS][5]
 
#define[MMC_BIT_DI][7]
 
#define[MMC_BIT_CLK][6]
 
#include[ztex-flash1.h]
 
 
#elifeq[PRODUCT_IS][UXM-1_0]
#elifeq[PRODUCT_IS][UXM-1_0]
#define[MMC_PORT][C]
#define[MMC_PORT][C]
#define[MMC_BIT_CS][7]
#define[MMC_BIT_CS][7]
#define[MMC_BIT_DI][6]
#define[MMC_BIT_DI][6]
#define[MMC_BIT_DO][4]
#define[MMC_BIT_DO][4]
Line 117... Line 134...
#include[ztex-fpga1.h]
#include[ztex-fpga1.h]
#elifeq[PRODUCT_IS][UFM-1_10]
#elifeq[PRODUCT_IS][UFM-1_10]
#include[ztex-fpga2.h]
#include[ztex-fpga2.h]
#elifeq[PRODUCT_IS][UFM-1_11]
#elifeq[PRODUCT_IS][UFM-1_11]
#include[ztex-fpga3.h]
#include[ztex-fpga3.h]
 
#elifeq[PRODUCT_IS][UFM-1_15]
 
#include[ztex-fpga4.h]
#endif
#endif
 
 
 
 
/* *********************************************************************
/* *********************************************************************
   ***** DEBUG helper functions ****************************************
   ***** DEBUG helper functions ****************************************
Line 132... Line 151...
 
 
/* *********************************************************************
/* *********************************************************************
   ***** XMEGA support *************************************************
   ***** XMEGA support *************************************************
   ********************************************************************* */
   ********************************************************************* */
#ifneq[XMEGA_DISABLED][1]
#ifneq[XMEGA_DISABLED][1]
 
 
#ifeq[PRODUCT_IS][UXM-1_0]
#ifeq[PRODUCT_IS][UXM-1_0]
 
#define[PDI_PORT][A]
 
#define[PDI_BIT_CLK][0]
 
#define[PDI_BIT_DATA][1]
#include[ztex-xmega.h]
#include[ztex-xmega.h]
#endif
#endif
 
 
 
#ifeq[EXP_1_10_ENABLED][1]
 
#ifneq[PRODUCT_IS][UFM-1_0]
 
#elifneq[PRODUCT_IS][UFM-1_1]
 
#elifneq[PRODUCT_IS][UFM-1_2]
 
#elifneq[PRODUCT_IS][UFM-1_10]
 
#elifneq[PRODUCT_IS][UFM-1_11]
 
#elifneq[PRODUCT_IS][UFM-1_15]
 
#warning[ZTEX Experimental Board 1.10 is not supported by this product.]
 
#endif
 
#define[PDI_PORT][E]
 
#define[PDI_BIT_CLK][5]
 
#define[PDI_BIT_DATA][4]
 
#include[ztex-xmega.h]
#endif
#endif
 
 
 
#endif
 
 
/* *********************************************************************
/* *********************************************************************
   ***** define the descriptors and the interrupt routines *************
   ***** define the descriptors and the interrupt routines *************
   ********************************************************************* */
   ********************************************************************* */
#include[ztex-descriptors.h]
#include[ztex-descriptors.h]
#include[ztex-isr.h]
#include[ztex-isr.h]
 
 
 
 
 
#ifdef[@CAPABILITY_MAC_EEPROM;]
 
/* *********************************************************************
 
   ***** mac_eeprom_init ***********************************************
 
   ********************************************************************* */
 
void mac_eeprom_init ( ) {
 
    BYTE b,c,d;
 
    xdata BYTE buf[5];
 
    __code char hexdigits[] = "0123456789ABCDEF";
 
 
 
    for (b=0; b<10; b++) {       // abort if SN != "0000000000"
 
        if ( SN_STRING[b] != '0' )
 
            return;
 
    }
 
 
 
    mac_eeprom_read ( buf, 0xfb, 5 );   // read the last 5 MAC digits
 
 
 
    c=0;
 
    for (b=0; b<5; b++) {        // convert to MAC to SN string
 
        d = buf[b];
 
        SN_STRING[c] = hexdigits[d>>4];
 
        c++;
 
        SN_STRING[c] = hexdigits[d & 15];
 
        c++;
 
    }
 
}
 
#endif
 
 
 
 
/* *********************************************************************
/* *********************************************************************
   ***** init_USB ******************************************************
   ***** init_USB ******************************************************
   ********************************************************************* */
   ********************************************************************* */
#define[EPXCFG(][);][    EP$0CFG = 
#define[EPXCFG(][);][    EP$0CFG = 
#ifeq[EP$0_DIR][IN]
#ifeq[EP$0_DIR][IN]
Line 192... Line 258...
void init_USB ()
void init_USB ()
{
{
    USBCS |= 0x08;
    USBCS |= 0x08;
 
 
    CPUCS = bmBIT4 | bmBIT1;
    CPUCS = bmBIT4 | bmBIT1;
 
    wait(2);
    CKCON &= ~7;
    CKCON &= ~7;
 
 
#ifeq[PRODUCT_IS][UFM-1_0]
#ifeq[PRODUCT_IS][UFM-1_0]
    IOA1 = 1;
    IOA1 = 1;
    OEA |= bmBIT1;
    OEA |= bmBIT1;
Line 209... Line 276...
    IOA1 = 1;
    IOA1 = 1;
    OEA |= bmBIT1;
    OEA |= bmBIT1;
#elifeq[PRODUCT_IS][UFM-1_11]
#elifeq[PRODUCT_IS][UFM-1_11]
    IOA1 = 1;
    IOA1 = 1;
    OEA |= bmBIT1;
    OEA |= bmBIT1;
 
#elifeq[PRODUCT_IS][UFM-1_15]
 
    IOA1 = 1;
 
    OEA |= bmBIT1;
#endif
#endif
 
 
    INIT_CMDS;
    INIT_CMDS;
 
 
    EA = 0;
    EA = 0;
Line 261... Line 331...
#endif
#endif
#ifeq[DEBUG_ENABLED][1]
#ifeq[DEBUG_ENABLED][1]
    debug_init();
    debug_init();
#endif
#endif
#ifeq[XMEGA_ENABLED][1]
#ifeq[XMEGA_ENABLED][1]
//    xmega_init();
    xmega_init();
 
#endif
 
#ifdef[@CAPABILITY_MAC_EEPROM;]
 
    mac_eeprom_init();
#endif
#endif
 
 
 
 
    USBCS |= bmBIT7 | bmBIT1;
    USBCS |= bmBIT7 | bmBIT1;
    wait(250);
    wait(10);
 
//    wait(250);
    USBCS &= ~0x08;
    USBCS &= ~0x08;
}
}
 
 
 
 
#endif   /* ZTEX_H */
#endif   /* ZTEX_H */

powered by: WebSVN 2.1.0

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