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 23... |
Line 23... |
#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 FPGA configuarion from Flash at startup
|
__xdata BYTE fpga_flash_result; // result of FPGA configuarion from Flash at startup
|
|
|
/* *********************************************************************
|
/* *********************************************************************
|
***** reset_fpga ****************************************************
|
***** reset_fpga ****************************************************
|
********************************************************************* */
|
********************************************************************* */
|
static void reset_fpga () { // reset FPGA
|
static void reset_fpga () { // reset FPGA
|
Line 145... |
Line 145... |
/* *********************************************************************
|
/* *********************************************************************
|
***** EP0 vendor command 0x32 ***************************************
|
***** EP0 vendor command 0x32 ***************************************
|
********************************************************************* */
|
********************************************************************* */
|
void fpga_send_ep0() {
|
void fpga_send_ep0() {
|
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 171... |
Line 171... |
mov dptr,#_fpga_checksum
|
mov dptr,#_fpga_checksum
|
mov a,r1
|
mov a,r1
|
movx @dptr,a
|
movx @dptr,a
|
|
|
010000$:
|
010000$:
|
_endasm;
|
__endasm;
|
if ( EP0BCL<64 ) {
|
if ( EP0BCL<64 ) {
|
finish_fpga_configuration();
|
finish_fpga_configuration();
|
}
|
}
|
}
|
}
|
|
|
Line 191... |
Line 191... |
/* *********************************************************************
|
/* *********************************************************************
|
***** 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
|
mov r5,dpl // = size
|
mov r5,dpl // = size
|
mov r6,dph
|
mov r6,dph
|
|
|
// fpga_bytes+=size
|
// fpga_bytes+=size
|
mov dptr,#_fpga_bytes
|
mov dptr,#_fpga_bytes
|
Line 249... |
Line 249... |
setb _IOD0
|
setb _IOD0
|
dec r5
|
dec r5
|
cjne r5,#0xff,010003$
|
cjne r5,#0xff,010003$
|
dec r6
|
dec r6
|
sjmp 010003$
|
sjmp 010003$
|
_endasm;
|
__endasm;
|
}
|
}
|
|
|
#include[ztex-fpga-flash.h]
|
#include[ztex-fpga-flash.h]
|
|
|
#else
|
#else
|