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

Subversion Repositories usb_fpga_1_11

[/] [usb_fpga_1_11/] [trunk/] [include/] [ztex-fpga3.h] - Diff between revs 2 and 5

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

Rev 2 Rev 5
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 15... Line 15...
   You should have received a copy of the GNU General Public License
   You should have received a copy of the GNU General Public License
   along with this program; if not, see http://www.gnu.org/licenses/.
   along with this program; if not, see http://www.gnu.org/licenses/.
!*/
!*/
 
 
/*
/*
    FPGA support for ZTEX USB FPGA Modules 1.10
    FPGA support for ZTEX USB FPGA Modules 1.11
*/
*/
 
 
#ifndef[ZTEX_FPGA_H]
#ifndef[ZTEX_FPGA_H]
#define[ZTEX_FPGA_H]
#define[ZTEX_FPGA_H]
 
 
#define[@CAPABILITY_FPGA;]
#define[@CAPABILITY_FPGA;]
 
 
xdata BYTE fpga_checksum;         // checksum
__xdata BYTE fpga_checksum;         // checksum
xdata DWORD fpga_bytes;           // transfered bytes
__xdata DWORD fpga_bytes;           // transfered bytes
xdata BYTE fpga_init_b;           // init_b state (should be 222 after configuration)
__xdata BYTE fpga_init_b;           // init_b state (should be 222 after configuration)
xdata BYTE fpga_flash_result;     // result of automatic fpga configuarion from Flash
__xdata BYTE fpga_flash_result;     // result of automatic fpga configuarion from Flash
 
 
/* *********************************************************************
/* *********************************************************************
   ***** reset_fpga ****************************************************
   ***** reset_fpga ****************************************************
   ********************************************************************* */
   ********************************************************************* */
static void reset_fpga_int (BYTE mode) {                // reset FPGA
static void reset_fpga_int (BYTE mode) {                // reset FPGA
Line 38... Line 38...
    IFCONFIG = bmBIT7;
    IFCONFIG = bmBIT7;
    SYNCDELAY;
    SYNCDELAY;
    PORTACFG = 0;
    PORTACFG = 0;
    PORTCCFG = 0;
    PORTCCFG = 0;
 
 
    OEA = bmBIT1 | bmBIT3 | bmBIT4 | bmBIT5 | bmBIT6 | bmBIT7;
    OEA = (OEA & 5 ) | bmBIT1 | bmBIT3 | bmBIT4 | bmBIT5 | bmBIT6 | bmBIT7;
    IOA = bmBIT7 | mode;
    IOA = bmBIT7 | mode;
    wait(10);
    wait(10);
 
 
    OEC &= ~bmBIT3;
    OEC &= ~bmBIT3;
 
 
Line 86... Line 86...
   ********************************************************************* */
   ********************************************************************* */
static void finish_fpga_configuration () {
static void finish_fpga_configuration () {
    WORD w;
    WORD w;
    fpga_init_b += IOA0 ? 20 : 10;
    fpga_init_b += IOA0 ? 20 : 10;
 
 
    for ( w=0; w<65535; w++ ) {
    for ( w=0; w<64; w++ ) {
        IOA3 = 1; IOA3 = 0;
        IOA3 = 1; IOA3 = 0;
    }
    }
 
 
    IOA3 = 1; IOA3 = 0;
 
    IOA3 = 1; IOA3 = 0;
 
    IOA3 = 1; IOA3 = 0;
 
    IOA3 = 1; IOA3 = 0;
 
    IOA7 = 1;
    IOA7 = 1;
    IOA3 = 1; IOA3 = 0;
    IOA3 = 1; IOA3 = 0;
    IOA3 = 1; IOA3 = 0;
    IOA3 = 1; IOA3 = 0;
    IOA3 = 1; IOA3 = 0;
    IOA3 = 1; IOA3 = 0;
    IOA3 = 1; IOA3 = 0;
    IOA3 = 1; IOA3 = 0;
 
 
    OEA = 0;
    OEA = OEA & 5;
    fpga_init_b += IOA0 ? 2 : 1;
    fpga_init_b += IOA0 ? 2 : 1;
    if ( IOA1 )  {
    if ( IOA1 )  {
        IOA1 = 1;
        IOA1 = 1;
        post_fpga_config();
        post_fpga_config();
    }
    }
Line 148... Line 143...
void fpga_send_ep0() {
void fpga_send_ep0() {
    BYTE oOED;
    BYTE oOED;
    oOED = OED;
    oOED = OED;
    OED = 255;
    OED = 255;
    fpga_bytes += ep0_payload_transfer;
    fpga_bytes += ep0_payload_transfer;
    _asm
    __asm
        mov     dptr,#_EP0BCL
        mov     dptr,#_EP0BCL
        movx    a,@dptr
        movx    a,@dptr
        jz      010000$
        jz      010000$
        mov     r2,a
        mov     r2,a
        mov     _AUTOPTRL1,#(_EP0BUF)
        mov     _AUTOPTRL1,#(_EP0BUF)
Line 161... Line 156...
        mov     dptr,#_fpga_checksum
        mov     dptr,#_fpga_checksum
        movx    a,@dptr
        movx    a,@dptr
        mov     r1,a
        mov     r1,a
        mov     dptr,#_XAUTODAT1
        mov     dptr,#_XAUTODAT1
010001$:
010001$:
        movx    a,@dptr
        movx    a,@dptr                 // 2
        mov     _IOD,a
        mov     _IOD,a                  // 2
        setb    _IOA3
        setb    _IOA3                   // 2
        add     a,r1
        add     a,r1                    // 1
        mov     r1,a
        mov     r1,a                    // 1
        clr     _IOA3
        clr     _IOA3                   // 2
        djnz    r2, 010001$
        djnz    r2, 010001$             // 4
 
 
        mov     dptr,#_fpga_checksum
        mov     dptr,#_fpga_checksum
        mov     a,r1
        mov     a,r1
        movx    @dptr,a
        movx    @dptr,a
 
 
010000$:
010000$:
        _endasm;
        __endasm;
    OED = oOED;
    OED = oOED;
    if ( EP0BCL<64 ) {
    if ( EP0BCL<64 ) {
        finish_fpga_configuration();
        finish_fpga_configuration();
    }
    }
}
}
Line 195... Line 190...
/* *********************************************************************
/* *********************************************************************
   ***** fpga_send_bitstream_from_flash ********************************
   ***** fpga_send_bitstream_from_flash ********************************
   ********************************************************************* */
   ********************************************************************* */
void fpga_send_bitstream_from_flash (WORD size) {
void fpga_send_bitstream_from_flash (WORD size) {
        size;                   // this avoids stupid warnings
        size;                   // this avoids stupid warnings
_asm
__asm
        push    _OED
        push    _OED
        mov     _OED,#0
        mov     _OED,#0
 
 
        mov     r5,dpl          // = size
        mov     r5,dpl          // = size
        mov     r6,dph
        mov     r6,dph
Line 234... Line 229...
        addc    a,r4
        addc    a,r4
        inc     dptr
        inc     dptr
        movx    @dptr,a
        movx    @dptr,a
 
 
010003$:
010003$:
        cjne    r5,#0x00,010002$
        cjne    r5,#0x00,010002$        // 4
        cjne    r6,#0x00,010002$
        cjne    r6,#0x00,010002$
        pop     _OED
        pop     _OED
        ret
        ret
010002$:
010002$:                                // approx 73 cycles per byte
        setb    _IOA3
        setb    _IOA3  // 2
        setb    _IOC6
        setb    _IOC6  // 2
        clr     _IOA3
        clr     _IOA3  // 2
        clr     _IOC6
        clr     _IOC6  // 2
 
 
        setb    _IOA3
        setb    _IOA3
        setb    _IOC6
        setb    _IOC6
        clr     _IOA3
        clr     _IOA3
        clr     _IOC6
        clr     _IOC6
Line 279... Line 274...
        setb    _IOA3
        setb    _IOA3
        setb    _IOC6
        setb    _IOC6
        clr     _IOA3
        clr     _IOA3
        clr     _IOC6
        clr     _IOC6
 
 
        dec     r5
        dec     r5                      // 1
        cjne    r5,#0xff,010003$
        cjne    r5,#0xff,010003$        // 4
        dec     r6
        dec     r6
        sjmp    010003$
        sjmp    010003$
_endasm;
__endasm;
}
}
 
 
#include[ztex-fpga-flash.h]
#include[ztex-fpga-flash.h]
 
 
#else
#else

powered by: WebSVN 2.1.0

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