Commit f847c918 authored by Stefano Rivera's avatar Stefano Rivera

Import Upstream version 0.0.0+git20160908

parents
*.lst
*.asm
*.lib
*.sym
*.rel
*.mem
*.map
*.rst
*.lnk
*.hex
*.ihx
*.iic
*.lk
#-----------------------------------------------------------------------------
# Makefile for usb_jtag FX2 firmware
#-----------------------------------------------------------------------------
# Copyright 2007 Kolja Waschk, ixo.de
#-----------------------------------------------------------------------------
# This code is part of usbjtag. usbjtag is free software; you can redistribute
# it and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the License,
# or (at your option) any later version. usbjtag is distributed in the hope
# that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. You should have received a
# copy of the GNU General Public License along with this program in the file
# COPYING; if not, write to the Free Software Foundation, Inc., 51 Franklin
# St, Fifth Floor, Boston, MA 02110-1301 USA
#-----------------------------------------------------------------------------
LIBDIR=fx2
LIB=libfx2.lib
SHELL := /bin/bash
ifeq (${HARDWARE},)
HARDWARE=hw_basic
#HARDWARE=hw_saxo_l
#HARDWARE=hw_xpcu_i
#HARDWARE=hw_xpcu_x
#HARDWARE=hw_nexys
endif
CC=sdcc
CFLAGS+=-mmcs51 --no-xinit-opt -I${LIBDIR} -D${HARDWARE}
AS=sdas8051
ASFLAGS+=-plosgff
LDFLAGS=--code-loc 0x0000 --code-size 0x1800
LDFLAGS+=--xram-loc 0x1800 --xram-size 0x0800
LDFLAGS+=-Wl '-b USBDESCSEG = 0xE100'
LDFLAGS+=-L ${LIBDIR}
%.rel : %.a51
$(AS) $(ASFLAGS) $<
%.rel : %.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
default: usbjtag.hex
dscr.a51: dscr.a51.in
export H="${HARDWARE}~~~~~~~~~"; cat dscr.a51.in | \
sed \
-e"s/\$$H0/$${H:0:1}/" \
-e"s/\$$H1/$${H:1:1}/" \
-e"s/\$$H2/$${H:2:1}/" \
-e"s/\$$H3/$${H:3:1}/" \
-e"s/\$$H4/$${H:4:1}/" \
-e"s/\$$H5/$${H:5:1}/" \
-e"s/\$$H6/$${H:6:1}/" \
-e"s/\$$H7/$${H:7:1}/" \
-e"s/\$$H8/$${H:8:1}/" \
-e"s/\$$H9/$${H:9:1}/" | \
sed \
-e"s/ .db '~, 0//" \
> dscr.a51
#%.iic : %.hex
# ./hex2bix -ir -f 0xC2 -m 0xF000 -c 0x1 -o $@ $<
%.bix: %.hex
objcopy -I ihex -O binary $< $@
usbjtag.hex: vectors.rel usbjtag.rel dscr.rel eeprom.rel ${HARDWARE}.rel startup.rel ${LIBDIR}/${LIB}
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+
packihx $@ > .tmp.hex
rm $@
mv .tmp.hex $@
ls -al $@
${LIBDIR}/${LIB}:
make -C ${LIBDIR}
.PHONY: boot
boot: std.hex
-test -e /dev/usb_jtag && /sbin/fxload -D /dev/usb_jtag -I std.hex -t fx2
-test -e /dev/tracii_xl2 && /sbin/fxload -D /dev/tracii_xl2 -I std.hex -t fx2
-test -e /dev/xilinx_xpcu && /sbin/fxload -D /dev/xilinx_xpcu -I std.hex -t fx2
REF=/home/kawk/work/xilinx/xtern/xusbdfwu/xusbdfwu-1025.hex
.PHONY: ref
ref:
-test -e /dev/usb_jtag && /sbin/fxload -D /dev/usb_jtag -I ${REF} -t fx2
-test -e /dev/tracii_xl2 && /sbin/fxload -D /dev/tracii_xl2 -I ${REF} -t fx2
-test -e /dev/xilinx_xpcu && /sbin/fxload -D /dev/xilinx_xpcu -I ${REF} -t fx2
dscr.rel: dscr.a51
eeprom.rel: eeprom.c eeprom.h
usbjtag.rel: usbjtag.c hardware.h eeprom.h
${HARDWARE}.rel: ${HARDWARE}.c hardware.h
.PHONY: clean distclean
clean:
make -C ${LIBDIR} clean
rm -f *.lst *.asm *.lib *.sym *.rel *.mem *.map *.rst *.lnk *.lk *.hex dscr.a51
distclean: clean
usb_jtag using Cypress FX2 chip
===============================
== General information ==
The code in this directory is for Cypress FX2 (e.g. CY7C68013A) and can be
compiled with the SDCC compiler (I tried version 2.6 as shipped with Ubuntu
6.10). Once I had a version that could be compiled with Keil tools (until early
2007), but switched to SDCC because I usually develop on a Linux host.
No logic beside the FX2 itself and only a few external components are required
for a basic JTAG adapter. I don't have detailed schematics available; my test
setup consists of a FX2 on a custom board where it's directly connected to a
Cyclone FPGA.
____________
| |
| Cypress |
USB__| EZ-USB FX2 |__JTAG(TDI,TDO,TCK,TMS)
| CY7C68013A |
|____________|
__|__________
| |
| 24 MHz XTAL |
|_____________|
Similar boards are available from fpga4fun.com - the boards named "Saxo-L" and
"Xylo-EM" are pre-wired for use with an adapted version of my code, while
"Saxo" and "Xylo" can be used after soldering 4 extra wires:
http://www.fpga4fun.com/board_Xylo.html
There's a discussion thread in the fpga4fun forum about this firmware:
http://www.fpga4fun.com/forum/viewtopic.php?t=483
== Use with Nexys 1 / 2 Boards ==
Through a contribution by Sune Mai, this code can be used with the Digilent
Nexys / Nexys2 boards.
http://www.digilentinc.com/nexys/
http://www.digilentinc.com/nexys2/
The hardware-specific code file is hw_nexys.c, just change the line
"HARDWARE=hw_basic" to "HARDWARE=hw_nexys" in the file "Makefile" to use it.
Also, you may use the "nexys2prog" script by Andy Ross, available from the
same place this code is available from:
http://ixo-jtag.sourceforge.net/
== Adapting the code to your hardware ==
As is, the code assumes the following pin assignment:
Port C.0: TDI
Port C.1: TDO
Port C.2: TCK
Port C.3: TMS
Other assignments are possible. If you have your signals connected to
bit-addressable I/O pins (port A,B,C or D), I suggest you make a copy of
hw_basic.c and adapt the definitions and ProgIO_Init() in it to your needs.
The file hw_saxo_l is even simpler to adapt if you want only JTAG and no AS/PS
mode. If your signals are not on bit-addressable I/Os (that is, you're using
port E), you could base your adaptation on the slower hw_xpcu_i.c. You may
specify the name of your adapted hardware-specific file when "make"ing, e.g.:
make HARDWARE=hw_saxo_l
The USB identification data (vendor/product ID, strings, ...) can be modified
in dscr.a51. The firmware emulates the 128 byte EEPROM that usually holds
configuration data for the FT245 and which can be read from the host; its
content (including checksum) is computed from the data in dscr.a51 as well.
The WAKEUP pin should be high for the re-numeration to work reliably (thanks
Jean/fpga4fun!).
== Using it with Xilinx JTAG cable ==
There is code to support running in the "Xilinx Platform Cable USB". If you
select HARDWARE=hw_xpcu_i or hw_xpcu_x at the top of the Makefile, a firmware
for the XPCU will be built. I've tested this only with unmodified CPLD version
18 (0x12) on a Spartan-3E starter kit, as it was programmed by my WebPack 8.2i.
The code needs optimization; yet it is merely a proof of concept.
Compile for the XPCU with e.g. "make HARDWARE=hw_xpcu_x".
hw_xpcu_i: Access "internal" chain (the XPCU CPLD, IC3, itself)
hw_xpcu_x: Access "external" chain (the Spartan 3E, PROM, etc.)
== History ==
Changes since previous release 2008-07-05:
- Imported to SourceForge, please see the project page:
http://ixo-jtag.sourceforge.net/
Changes since previous release on 2007-02-15:
- Jean Nicolle contributed hw_saxo_l.c for the FX2 boards from fpga4fun.com
- fx2/Makefile fixed to build correct libfx2.lib even under Windows.
Changes since previous release on 2007-01-28:
- Initial suppport for running on Xilinx XPCU.
- New FX2 code, based on USRP2 from the GNU Radio Project;
- Firmware can now be compiled using SDCC 2.6. No more Keil support.
- EEPROM content is automatically computed from dscr.a51, including checksum.
Changes since initial release on 2006-04-23:
- added this readme.txt
- reorganized my project folder: diff now created from Subversion repository
- stripped *.dist extension from eeprom.c and dscr.a51
- added unique proper product and vendor ID (thanks to Antti Lukats!)
- fixed checksum in eeprom.c
- added comments about AS/PS mode pins in usbjtag.c
ixo-usb-jtag (0.0.0-90-g868e385-1) trusty; urgency=low
* Version bump.
-- Tim 'mithro' Ansell <mithro@mithis.com> Wed, 14 Oct 2015 17:25:00 +1100
ixo-usb-jtag (0.0.0-88-gd9e335b-1) trusty; urgency=low
* Version bump.
-- Tim 'mithro' Ansell <mithro@mithis.com> Sun, 11 Oct 2015 21:18:00 +1100
ixo-usb-jtag (0.0.0-85-g2df5d2f-1) trusty; urgency=low
* Version bump.
-- Tim 'mithro' Ansell <mithro@mithis.com> Fri, 9 Oct 2015 21:08:00 +1100
ixo-usb-jtag (0.0.0-83-g68bf25b-1) trusty; urgency=low
* Adding customisation.
-- Tim 'mithro' Ansell <mithro@mithis.com> Sun, 20 Sep 2015 19:28:00 +1000
ixo-usb-jtag (0.0.0-81-gc7d809d-1) trusty; urgency=low
* Initial attempt at packaging.
-- Tim 'mithro' Ansell <mithro@mithis.com> Thu, 20 Aug 2015 00:39:00 -0100
Source: ixo-usb-jtag
Maintainer: TimVideos Developers <timvideos@googlegroups.com>
Uploaders: Tim 'mithro' Ansell <mithro@mithis.com>
Section: misc
Priority: extra
Build-Depends: debhelper (>= 7), sdcc
Standards-Version: 3.9.3
Homepage: http://github.com/mithro/ixo-usb-jtag
Package: ixo-usb-jtag
Architecture: all
Depends: ${misc:Depends} fxload
Suggests: urjtag
Description: Firmware for USB JTAG programmers.
.
This firmware allows a USB-capable microcontroller - currently that's
primarily the Cypress FX2 EZ-USB family, or an FTDI FT245 in combination with
a CPLD - to act like an Altera USB-Blaster JTAG pod, which in turn may allow
you to use tools you'd normally use with the Altera USB-Blaster, including
available Linux tools such as UrJTAG.
This package was debianized by Tim 'mithro' Ansell <mithro@mithis.com> on
Thu, 20 Aug 2015 00:25:00 +0100.
#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.
# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1
UPSTREAM_VERSION=$(shell dpkg-parsechangelog | sed -e '/^Version/!d' -e 's/^Version: //g' -e's/-[^-]*$$//')
UPSTREAM_REVISION=$(shell echo v$(UPSTREAM_VERSION))
UPSTREAM_GIT=http://github.com/mithro/ixo-usb-jtag.git
UPSTREAM_CHECKOUT=ixo-usb-jtag-$(UPSTREAM_VERSION)
DEB_BUILD_ARCH_CPU ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH_CPU)
HARDWARE=hw_basic hw_saxo_l hw_xpcu_i hw_xpcu_x hw_nexys hw_opsis
get-orig-source:
git clone $(UPSTREAM_GIT) $(UPSTREAM_CHECKOUT)
cd $(UPSTREAM_CHECKOUT); git checkout $(UPSTREAM_REVISION)
tar -zcf ../ixo-usb-jtag_$(UPSTREAM_VERSION).orig.tar.gz $(UPSTREAM_CHECKOUT)
rm -rf $(UPSTREAM_CHECKOUT)
build: build-arch build-indep
build-arch:
# We have nothing to do by default.
build-indep: build-indep-stamp
build-indep-stamp:
dh_testdir
mkdir -p output
for HW in $(HARDWARE); do \
make clean || exit 1; \
HARDWARE=$$HW $(MAKE) || exit 1; \
cp usbjtag.hex ./output/$$HW.hex || exit 1; \
make clean || exit 1; \
done
touch build-indep-stamp
clean:
dh_testdir
dh_testroot
dh_clean
install: build-indep
dh_testdir
dh_testroot
dh_prep
dh_installdirs
mkdir -p $(CURDIR)/debian/ixo-usb-jtag/lib/firmware/ixo-usb-jtag
for HW in $(HARDWARE); do install -m644 ./output/$$HW.hex $(CURDIR)/debian/ixo-usb-jtag/lib/firmware/ixo-usb-jtag; done
mkdir -p $(CURDIR)/debian/ixo-usb-jtag/lib/udev/rules.d
install -m644 scripts/ixo-usb-jtag.rules $(CURDIR)/debian/ixo-usb-jtag/lib/udev/rules.d/85-ixo-usb-jtag.rules
# Build architecture-independent files here.
binary-indep: build-indep install
dh_testdir
dh_testroot
dh_installdocs
dh_lintian
dh_link
dh_strip
dh_compress
dh_fixperms
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb -- -Zxz
# Build architecture-dependent files here.
binary-arch: build-indep install
# We have nothing to do by default.
binary: binary-indep binary-arch
.PHONY: build build-arch build-indep clean binary-indep binary-arch binary install
compression = "xz"
This diff is collapsed.
/*-----------------------------------------------------------------------------
* FTDI EEPROM emulation
*-----------------------------------------------------------------------------
* Copyright (C) 2007 Kolja Waschk, ixo.de
*-----------------------------------------------------------------------------
* This code is part of usbjtag. usbjtag is free software; you can redistribute
* it and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version. usbjtag is distributed in the hope
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. You should have received a
* copy of the GNU General Public License along with this program in the file
* COPYING; if not, write to the Free Software Foundation, Inc., 51 Franklin
* St, Fifth Floor, Boston, MA 02110-1301 USA
*-----------------------------------------------------------------------------
*/
#include "eeprom.h"
#include "usb_descriptors.h"
xdata unsigned char eeprom[128];
extern xdata char dscr_vidpidver[6];
extern xdata char dscr_attrpow[2];
extern xdata char dscr_usbver[2];
extern xdata char dscr_strorder[4];
extern xdata char str1[];
extern xdata char str2[];
extern xdata char str3[];
static unsigned char ee_ptr;
static unsigned short ee_cksum;
void eeprom_append(unsigned char nb)
{
unsigned char pree_ptr = ee_ptr & ~1;
if(pree_ptr != ee_ptr)
{
ee_cksum = ee_cksum ^((unsigned short)nb << 8);
ee_cksum = ee_cksum ^ eeprom[pree_ptr];
ee_cksum = (ee_cksum << 1) | (ee_cksum >> 15);
};
eeprom[ee_ptr++] = nb;
}
void eeprom_init(void)
{
char j,sofs;
ee_ptr = 0;
ee_cksum = 0xAAAA;
eeprom_append(0x00);
eeprom_append(0x00);
for(j=0;j<6;j++) eeprom_append(dscr_vidpidver[j]);
for(j=0;j<2;j++) eeprom_append(dscr_attrpow[j]);
eeprom_append(0x1C);
eeprom_append(0x00);
for(j=0;j<2;j++) eeprom_append(dscr_usbver[j]);
sofs = 0x80 + ee_ptr + 6;
eeprom_append(sofs);
eeprom_append(str1[0]);
sofs += str1[0];
eeprom_append(sofs);
eeprom_append(str2[0]);
sofs += str2[0];
eeprom_append(sofs);
eeprom_append(str3[0]);
for(j=0;j<str1[0];j++) eeprom_append(str1[j]);
for(j=0;j<str2[0];j++) eeprom_append(str2[j]);
for(j=0;j<str3[0];j++) eeprom_append(str3[j]);
for(j=0;j<4;j++) eeprom_append(dscr_strorder[j]);
while(ee_ptr < 126) eeprom_append(0);
eeprom[126] = ee_cksum&0xFF;
eeprom[127] = (ee_cksum>>8)&0xFF;
}
/*-----------------------------------------------------------------------------
* FTDI EEPROM emulation
*-----------------------------------------------------------------------------
* Copyright (C) 2007 Kolja Waschk, ixo.de
*-----------------------------------------------------------------------------
* This code is part of usbjtag. usbjtag is free software; you can redistribute
* it and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version. usbjtag is distributed in the hope
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. You should have received a
* copy of the GNU General Public License along with this program in the file
* COPYING; if not, write to the Free Software Foundation, Inc., 51 Franklin
* St, Fifth Floor, Boston, MA 02110-1301 USA
*-----------------------------------------------------------------------------
*/
#ifndef _EEPROM_H
#define _EEPROM_H 1
extern __xdata unsigned char eeprom[128];
extern void eeprom_init(void);
#endif /* _EEPROM_H */
#-----------------------------------------------------------------------------
# Makefile for FX2 library code
#-----------------------------------------------------------------------------
# Copyright (C) 2007 Kolja Waschk, ixo.de
#-----------------------------------------------------------------------------
# This code is part of usbjtag. usbjtag is free software; you can redistribute
# it and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the License,
# or (at your option) any later version. usbjtag is distributed in the hope
# that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. You should have received a
# copy of the GNU General Public License along with this program in the file
# COPYING; if not, write to the Free Software Foundation, Inc., 51 Franklin
# St, Fifth Floor, Boston, MA 02110-1301 USA
#-----------------------------------------------------------------------------
CC=sdcc
CFLAGS+=-mmcs51 --no-xinit-opt -I.
CPPFLAGS+=
OBJS=delay.rel fx2utils.rel i2c.rel isr.rel timer.rel usb_common.rel
AR=sdcclib
(%.rel) : %.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $*.rel
$(AR) -a $@ $*.rel
rm $*.rel
libfx2.lib: libfx2.lib($(OBJS))
clean:
rm -f *.lst *.asm *.lib *.sym *.rel *.lib
/* -*- c++ -*- */
/*-----------------------------------------------------------------------------
* Delay routines
*-----------------------------------------------------------------------------
* Code taken from USRP2 firmware (GNU Radio Project), version 3.0.2,
* Copyright 2003 Free Software Foundation, Inc.
*-----------------------------------------------------------------------------
* This code is part of usbjtag. usbjtag is free software; you can redistribute
* it and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version. usbjtag is distributed in the hope
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. You should have received a
* copy of the GNU General Public License along with this program in the file
* COPYING; if not, write to the Free Software Foundation, Inc., 51 Franklin
* St, Fifth Floor, Boston, MA 02110-1301 USA
*-----------------------------------------------------------------------------
*/
#define _naked __naked
#define _asm __asm
#define _endasm __endasm
/*
* Delay approximately 1 microsecond (including overhead in udelay).
*/
static void
udelay1 (void) _naked
{
_asm ; lcall that got us here took 4 bus cycles
ret ; 4 bus cycles
_endasm;
}
/*
* delay for approximately usecs microseconds
*/
void
udelay (unsigned char usecs)
{
do {
udelay1 ();
} while (--usecs != 0);
}
/*
* Delay approximately 1 millisecond.
* We're running at 48 MHz, so we need 48,000 clock cycles.
*
* Note however, that each bus cycle takes 4 clock cycles (not obvious,
* but explains the factor of 4 problem below).
*/
static void
mdelay1 (void) _naked
{
_asm
mov dptr,#(-1200 & 0xffff)
002$:
inc dptr ; 3 bus cycles
mov a, dpl ; 2 bus cycles
orl a, dph ; 2 bus cycles
jnz 002$ ; 3 bus cycles
ret
_endasm;
}
void
mdelay (unsigned int msecs)
{
do {
mdelay1 ();
} while (--msecs != 0);
}
/* -*- c++ -*- */
/*-----------------------------------------------------------------------------
* Delay routines
*-----------------------------------------------------------------------------
* Code taken from USRP2 firmware (GNU Radio Project), version 3.0.2,
* Copyright 2003 Free Software Foundation, Inc.
*-----------------------------------------------------------------------------
* This code is part of usbjtag. usbjtag is free software; you can redistribute
* it and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version. usbjtag is distributed in the hope
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. You should have received a
* copy of the GNU General Public License along with this program in the file
* COPYING; if not, write to the Free Software Foundation, Inc., 51 Franklin
* St, Fifth Floor, Boston, MA 02110-1301 USA
*-----------------------------------------------------------------------------
*/
#ifndef _DELAY_H_
#define _DELAY_H_
/*
* delay for approximately usecs microseconds
* Note limit of 255 usecs.
*/
void udelay (unsigned char usecs);
/*
* delay for approximately msecs milliseconds
*/
void mdelay (unsigned short msecs);
#endif /* _DELAY_H_ */
This diff is collapsed.
/* -*- c++ -*- */
/*-----------------------------------------------------------------------------
* FX2 specific subroutines
*-----------------------------------------------------------------------------
* Code taken from USRP2 firmware (GNU Radio Project), version 3.0.2,
* Copyright 2003 Free Software Foundation, Inc.
*-----------------------------------------------------------------------------
* This code is part of usbjtag. usbjtag is free software; you can redistribute
* it and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version. usbjtag is distributed in the hope
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. You should have received a
* copy of the GNU General Public License along with this program in the file
* COPYING; if not, write to the Free Software Foundation, Inc., 51 Franklin
* St, Fifth Floor, Boston, MA 02110-1301 USA
*-----------------------------------------------------------------------------
*/
#include "fx2utils.h"
#include "fx2regs.h"
#include "delay.h"
void
fx2_stall_ep0 (void)
{
EP0CS |= bmEPSTALL;
}
void
fx2_reset_data_toggle (unsigned char ep)
{
TOGCTL = ((ep & 0x80) >> 3 | (ep & 0x0f));
TOGCTL |= bmRESETTOGGLE;
}
void
fx2_renumerate (void)
{
USBCS |= bmDISCON | bmRENUM;
// mdelay (1500); // FIXME why 1.5 seconds?
mdelay (250); // FIXME why 1.5 seconds?
USBIRQ = 0xff; // clear any pending USB irqs...
EPIRQ = 0xff; // they're from before the renumeration
EXIF &= ~bmEXIF_USBINT;
USBCS &= ~bmDISCON; // reconnect USB
}
/* -*- c++ -*- */
/*-----------------------------------------------------------------------------
* FX2 specific subroutines
*-----------------------------------------------------------------------------
* Code taken from USRP2 firmware (GNU Radio Project), version 3.0.2,
* Copyright 2003 Free Software Foundation, Inc.
*-----------------------------------------------------------------------------
* This code is part of usbjtag. usbjtag is free software; you can redistribute
* it and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version. usbjtag is distributed in the hope
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. You should have received a
* copy of the GNU General Public License along with this program in the file
* COPYING; if not, write to the Free Software Foundation, Inc., 51 Franklin
* St, Fifth Floor, Boston, MA 02110-1301 USA
*-----------------------------------------------------------------------------
*/
#ifndef _FX2UTILS_H_
#define _FX2UTILS_H_
void fx2_stall_ep0 (void);
void fx2_reset_data_toggle (unsigned char ep);
void fx2_renumerate (void);
#endif /* _FX2UTILS_H_ */
/* -*- c++ -*- */
/*-----------------------------------------------------------------------------
* I2C read/write functions for FX2
*-----------------------------------------------------------------------------
* Code taken from USRP2 firmware (GNU Radio Project), version 3.0.2,
* Copyright 2003 Free Software Foundation, Inc.
*-----------------------------------------------------------------------------
* This code is part of usbjtag. usbjtag is free software; you can redistribute
* it and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version. usbjtag is distributed in the hope
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. You should have received a
* copy of the GNU General Public License along with this program in the file
* COPYING; if not, write to the Free Software Foundation, Inc., 51 Franklin
* St, Fifth Floor, Boston, MA 02110-1301 USA
*-----------------------------------------------------------------------------
*/
#include "i2c.h"
#include "fx2regs.h"
#include <string.h>
// issue a stop bus cycle and wait for completion
// returns non-zero if successful, else 0
unsigned char
i2c_read (unsigned char addr, xdata unsigned char *buf, unsigned char len)
{
volatile unsigned char junk;