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

Subversion Repositories usb_fpga_1_2

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /usb_fpga_1_2
    from Rev 2 to Rev 3
    Reverse comparison

Rev 2 → Rev 3

/trunk/java/FWLoader.java
41,7 → 41,7
" -d <number> Device Number (default: 0)\n"+
" -f Force uploads\n"+
" -p Print bus info\n"+
" -w Enable certain workaraounds which may be required for vmware + windows\n"+
" -w Enable certain workaraounds\n"+
" -h This help \n\n"+
"Ordered parameters:\n"+
" -i Info\n"+
51,7 → 51,9
" -rf Reset FPGA\n"+
" -uf <bitstream> Upload <bitstream>\n"+
" -re Reset EEPROM Firmware\n"+
" -ue <ihx file> Upload Firmware to EEPROM" );
" -ue <ihx file> Upload Firmware to EEPROM\n"+
" -rm Reset FLASH bitstream\n"+
" -um <bitstream> Upload Firmware to FLASH");
// process global parameters
123,9 → 125,9
System.err.println(helpMsg);
System.exit(0);
}
else if ( args[i].equals("-i") || args[i].equals("-ii") || args[i].equals("-ru") || args[i].equals("-rf") || args[i].equals("-re")) {
else if ( args[i].equals("-i") || args[i].equals("-ii") || args[i].equals("-ru") || args[i].equals("-rf") || args[i].equals("-re") || args[i].equals("-rm") ) {
}
else if ( args[i].equals("-uu") || args[i].equals("-uf") || args[i].equals("-ue") ) {
else if ( args[i].equals("-uu") || args[i].equals("-uf") || args[i].equals("-ue") || args[i].equals("-um") ) {
i+=1;
}
else {
153,12 → 155,12
}
if ( args[i].equals("-ii") ) {
System.out.println( ztex );
String str = ztex.capabilityInfo(" ");
String str = ztex.capabilityInfo("\n ");
if ( str.equals("") ) {
System.out.println( " No capabilities");
}
else {
System.out.println( " Capabilities:\n"+str);
System.out.println( " Capabilities:\n "+str);
}
}
else if ( args[i].equals("-ru") ) {
197,6 → 199,22
}
System.out.println("FPGA configuration time: " + ztex.configureFpga( args[i], forceUpload ) + " ms");
}
else if ( args[i].equals("-rm") ) {
System.out.println("First free sector: " + ztex.flashFirstFreeSector() );
ztex.flashResetBitstream();
System.out.println("First free sector: " + ztex.flashFirstFreeSector() );
}
else if ( args[i].equals("-um") ) {
i++;
if ( i >= args.length ) {
System.err.println("Error: Filename expected after -uf");
System.err.println(helpMsg);
System.exit(1);
}
System.out.println("First free sector: " + ztex.flashFirstFreeSector() );
System.out.println("FPGA configuration time: " + ztex.flashUploadBitstream( args[i] ) + " ms");
System.out.println("First free sector: " + ztex.flashFirstFreeSector() );
}
}
}
catch (Exception e) {
/trunk/java/ztex/CapabilityException.java
18,7 → 18,13
 
package ztex;
 
/** * Thrown is a required capability is not available. */
public class CapabilityException extends Exception {
/**
* Constructs an instance from a givig device and capability string.
* @param ztex The device.
* @param cap Capability name.
*/
public CapabilityException ( Ztex1 ztex, String cap) {
super( "bus=" + ztex.dev().dev().getBus().getDirname() + " device=" + ztex.dev().dev().getFilename() + ": " + cap + " not supported" );
}
/trunk/java/ztex/FirmwareUploadException.java
17,12 → 17,17
!*/
 
package ztex;
 
/** * Signals that an error occured while attempting to upload the firmware. */
public class FirmwareUploadException extends Exception {
/**
* Constructs an instance from the given error message.
* @param msg The error message.
*/
public FirmwareUploadException (String msg) {
super( "Error uploading firmware: "+msg );
}
 
/** * Constructs an instance using a standard message. */
public FirmwareUploadException () {
super( "Error uploading firmware" );
}
/trunk/java/ztex/IhxParseException.java
18,8 → 18,13
 
package ztex;
 
/** * Signals that an error occurred while attempting to decode the ihx file. */
public class IhxParseException extends Exception {
public IhxParseException( String msg ) {
/**
* Constructs an instance from the given error message.
* @param msg The error message.
*/
public IhxParseException( String msg ) {
super( msg );
}
}
/trunk/java/ztex/InvalidFirmwareException.java
18,12 → 18,59
 
package ztex;
 
import ch.ntb.usb.*;
 
/**
* Thrown if a device runs with no or the wrong firmware, i.e. if the ZTEX descriptor is not found or damaged. */
public class InvalidFirmwareException extends Exception {
/**
* Constructs an instance from the given device and error message.
* @param ztex The device.
* @param msg The error message.
*/
public InvalidFirmwareException ( Ztex1 ztex, String msg) {
super( "bus=" + ztex.dev().dev().getBus().getDirname() + " device=" + ztex.dev().dev().getFilename() + ": Invalid Firmware: "+ msg );
this( ztex.dev().dev(), msg );
}
 
/**
* Constructs an instance from the given device and error message.
* @param dev The device.
* @param msg The error message.
*/
public InvalidFirmwareException ( ZtexDevice1 dev, String msg) {
this( dev.dev(), msg );
}
 
/**
* Constructs an instance from the given device and error message.
* @param dev The device.
* @param msg The error message.
*/
public InvalidFirmwareException (Usb_Device dev, String msg) {
super( "bus=" + dev.getBus().getDirname() + " device=" + dev.getFilename() + ": Invalid Firmware: "+ msg );
}
 
/**
* Constructs an instance from the given device and error message.
* @param ztex The device.
*/
public InvalidFirmwareException ( Ztex1 ztex ) {
super( "bus=" + ztex.dev().dev().getBus().getDirname() + " device=" + ztex.dev().dev().getFilename() + ": Invalid Firmware" );
this( ztex.dev().dev() );
}
 
/**
* Constructs an instance from the given device and error message.
* @param dev The device.
*/
public InvalidFirmwareException ( ZtexDevice1 dev ) {
this( dev.dev() );
}
 
/**
* Constructs an instance from the given device and error message.
* @param dev The device.
*/
public InvalidFirmwareException (Usb_Device dev ) {
super( "bus=" + dev.getBus().getDirname() + " device=" + dev.getFilename() + ": Invalid Firmware" );
}
}
/trunk/java/ztex/BitstreamReadException.java
19,12 → 19,17
package ztex;
 
import java.io.*;
 
/** * Signals that an error occurred while attempting to read a bitstream. */
public class BitstreamReadException extends IOException {
/**
* Constructs an instance from the given error message.
* @param msg The error message.
*/
public BitstreamReadException(String msg) {
super( "Cannot read bitstream: "+msg );
}
 
/** * Constructs an instance using a standard message. */
public BitstreamReadException() {
super( "Cannot read bitstream" );
}
/trunk/java/ztex/AlreadyConfiguredException.java
18,11 → 18,17
 
package ztex;
 
/** * Thrown if the FPGA is already configured. */
public class AlreadyConfiguredException extends Exception {
/**
* Constructs an instance from the given input string.
* @param msg A message.
*/
public AlreadyConfiguredException (String msg) {
super( "FPGA already configured: "+msg );
}
 
/** * Constructs an instance using a standard message. */
public AlreadyConfiguredException() {
super( "FPGA already configured" );
}
/trunk/java/ztex/UsbException.java
19,12 → 19,21
package ztex;
 
import ch.ntb.usb.*;
 
/** * Signals an USB error. */
public class UsbException extends Exception {
public UsbException(String msg) {
/**
* Constructs an instance from the given error message.
* @param msg The error message.
*/
public UsbException(String msg) {
super( msg );
}
 
/**
* Constructs an instance from the given device and error message.
* @param dev The device.
* @param msg The error message.
*/
public UsbException(Usb_Device dev, String msg) {
super( "bus=" + dev.getBus().getDirname() + " device=" + dev.getFilename() + ": " + msg );
}
/trunk/java/ztex/IhxFileDamagedException.java
17,8 → 17,14
!*/
 
package ztex;
 
/** * Signals that an ihx file is corrupt. */
public class IhxFileDamagedException extends Exception {
/**
* Constructs an instance from a given file name, line number and error message.
* @param filename The file name.
* @param line The line number.
* @param msg An error message.
*/
public IhxFileDamagedException ( String filename, int line, String msg ) {
super( "ihx file " + filename + "(" + line + ") damaged: "+msg );
}
/trunk/java/ztex/Ztex1.java
16,7 → 16,7
along with this program; if not, see http://www.gnu.org/licenses/.
!*/
 
/*
/*
Functions for USB devices with ZTEX descriptor 1
*/
package ztex;
26,13 → 26,36
 
import ch.ntb.usb.*;
 
/**
* This class implements the interface-independent part of the communication protocol for the interaction with the ZTEX firmware.<p>
* All firmware implementations that provide the ZTEX descriptor 1 are supported.
* A description of this descriptor can be found in {@link ZtexDevice1}.
* <p>
* The most important features of this class are the functions for uploading the firmware
* and the renumeration management.
* <p>
* The interface dependent part of the communication protocol (currently only one is supported)
* can be found in {@link Ztex1v1}.
* @see ZtexDevice1
* @see Ztex1v1
*/
public class Ztex1 {
protected int handle;
protected ZtexDevice1 dev = null;
private int handle;
private ZtexDevice1 dev = null;
private boolean oldDevices[] = new boolean[128];
private String usbBusName = null;
/** * Setting to true will enable certain workarounds, e.g. to deal with bad driver/OS implementations. */
public boolean certainWorkarounds = false;
/** * The timeout for control messages in ms. */
public int controlMsgTimeout = 1000; // in ms
private long lastVendorCommandT = 0;
 
// ******* Ztex1 ***************************************************************
/**
* Constructs an instance from a given device.
* @param pDev The given device.
* @throws UsbException if an communication error occurred.
*/
public Ztex1 ( ZtexDevice1 pDev ) throws UsbException {
dev = pDev;
 
42,11 → 65,13
}
 
// ******* finalize ************************************************************
/** * The destructor closes the USB file handle. */
protected void finalize () {
LibusbJava.usb_close(handle);
}
 
// ******* handle **************************************************************
/** * Returns the USB file handle. */
public final int handle()
{
return handle;
53,6 → 78,10
}
 
// ******* dev *****************************************************************
/**
* Returns the corresponding {@link ZtexDevice1}.
* @return the corresponding {@link ZtexDevice1}.
*/
public final ZtexDevice1 dev()
{
return dev;
59,11 → 88,19
}
 
// ******* valid ***************************************************************
/**
* Returns true if ZTEX descriptor 1 is available.
* @return true if ZTEX descriptor 1 is available.
*/
public boolean valid ( ) {
return dev.valid();
}
 
// ******* checkValid **********************************************************
/**
* Checks whether ZTEX descriptor 1 is available.
* @throws InvalidFirmwareException if ZTEX descriptor 1 is not available.
*/
public void checkValid () throws InvalidFirmwareException {
if ( ! dev.valid() )
throw new InvalidFirmwareException(this, "Can't read ZTEX descriptor 1");
70,23 → 107,72
}
 
// ******* vendorCommand *******************************************************
public int vendorCommand (int cmd, String func, int value, int index, byte[] buf, int length) throws UsbException {
int i;
if ( (i=LibusbJava.usb_control_msg(handle, 0x40, cmd, value, index, buf, length, 1000)) < 0 )
throw new UsbException( dev.dev(), (func != null ? func + ": " : "" ) + LibusbJava.usb_strerror());
try {
Thread.sleep(1); // avoid package loss (due to interrupts ?)
}
catch ( InterruptedException e ) {
/**
* Sends a vendor command to Endpoint 0 of the EZ-USB device.
* The command may be send multiple times until the {@link #controlMsgTimeout} is reached.
* @param cmd The command number (0..255).
* @param func The name of the command. This string is used for the generation of error messages.
* @param value The value (0..65535), i.e bytes 2 and 3 of the setup data.
* @param index The index (0..65535), i.e. bytes 4 and 5 of the setup data.
* @param length The size of the payload data (0..65535), i.e. bytes 6 and 7 of the setup data.
* @param buf The payload data buffer.
* @return the number of bytes sent.
* @throws UsbException if a communication error occurs.
*/
public synchronized int vendorCommand (int cmd, String func, int value, int index, byte[] buf, int length) throws UsbException {
long t0 = new Date().getTime()-100;
int trynum = 0;
int i = -1;
if ( controlMsgTimeout < 200 )
controlMsgTimeout = 200;
while ( i<=0 && new Date().getTime()-t0<controlMsgTimeout ) { // we repeat the message until the timeout has reached
i = LibusbJava.usb_control_msg(handle, 0x40, cmd, value, index, buf, length, controlMsgTimeout);
if ( certainWorkarounds ) {
try {
Thread.sleep(2);
}
catch ( InterruptedException e ) {
}
}
lastVendorCommandT = new Date().getTime();
if ( i < 0 ) {
System.err.println("Warning (try " + (trynum+1) + "): " + LibusbJava.usb_strerror() );
try {
Thread.sleep( 1 << trynum ); // we don't want to bother the USB device to often
}
catch ( InterruptedException e ) {
}
trynum++;
}
}
if ( i < 0 )
throw new UsbException( dev.dev(), (func != null ? func + ": " : "" )+ LibusbJava.usb_strerror());
return i;
}
 
/**
* Sends a vendor command with no payload data to Endpoint 0 of the EZ-USB device.
* The command may be send multiple times until the {@link #controlMsgTimeout} is reached.
* @param cmd The command number (0..255).
* @param func The name of the command. This string is used for the generation of error messages.
* @param value The value (0..65535), i.e bytes 2 and 3 of the setup data.
* @param index The index (0..65535), i.e. bytes 4 and 5 of the setup data.
* @return the number of bytes sent.
* @throws UsbException if a communication error occurs.
*/
public int vendorCommand (int cmd, String func, int value, int index) throws UsbException {
byte[] buf = { 0 };
return vendorCommand (cmd, func, value, index, buf, 0);
}
 
/**
* Sends a vendor command with no payload data and no setup data to Endpoint 0 of the EZ-USB device.
* The command may be send multiple times until the {@link #controlMsgTimeout} is reached.
* @param cmd The command number (0..255).
* @param func The name of the command. This string is used for the generation of error messages.
* @return the number of bytes sent.
* @throws UsbException if a communication error occurs.
*/
public int vendorCommand (int cmd, String func) throws UsbException {
byte[] buf = { 0 };
return vendorCommand (cmd, func, 0, 0, buf, 0);
93,40 → 179,106
}
 
// ******* vendorRequest *******************************************************
public int vendorRequest (int cmd, String func, int value, int index, byte[] buf, int maxlen) throws UsbException {
int i = LibusbJava.usb_control_msg(handle, 0xc0, cmd, value, index, buf, maxlen, 1000);
/**
* Sends a vendor request to Endpoint 0 of the EZ-USB device.
* The request may be send multiple times until the {@link #controlMsgTimeout} is reached.
* @param cmd The request number (0..255).
* @param func The name of the request. This string is used for the generation of error messages.
* @param value The value (0..65535), i.e bytes 2 and 3 of the setup data.
* @param index The index (0..65535), i.e. bytes 4 and 5 of the setup data.
* @param maxlen The size of the requested payload data (0..65535), i.e. bytes 6 and 7 of the setup data.
* @param buf The payload data buffer.
* @return the number of bytes received.
* @throws UsbException if a communication error occurs.
*/
public synchronized int vendorRequest (int cmd, String func, int value, int index, byte[] buf, int maxlen) throws UsbException {
long t0 = new Date().getTime()-100;
int trynum = 0;
int i = -1;
if ( controlMsgTimeout < 200 )
controlMsgTimeout = 200;
while ( i<=0 && new Date().getTime()-t0<controlMsgTimeout ) { // we repeat the message until the timeout has reached
/*
The HSNAK mechanism of EP0 usually avoids that a request is sent before a command has been completed.
Unfortunately this mechanism is only 99.99% reliable. Therefore we wait at least 1ms after the last
command has been send before we transmit a new request.
*/
long ms = new Date().getTime() - lastVendorCommandT;
if ( ms < 2 ) { //
try {
Thread.sleep(1);
}
catch ( InterruptedException e ) {
}
}
i = LibusbJava.usb_control_msg(handle, 0xc0, cmd, value, index, buf, maxlen, controlMsgTimeout);
if ( certainWorkarounds ) {
try {
Thread.sleep(2);
}
catch ( InterruptedException e ) {
}
}
if ( i < 0 ) {
System.err.println("Warning (try " + (trynum+1) + "): " + LibusbJava.usb_strerror() );
try {
Thread.sleep( 1 << trynum ); // we don't want to bother the USB device to often
}
catch ( InterruptedException e ) {
}
trynum++;
}
}
if ( i < 0 )
throw new UsbException( dev.dev(), (func != null ? func + ": " : "" ) + LibusbJava.usb_strerror());
try {
Thread.sleep(1); // avoid package loss (due to interrupts ?)
}
catch ( InterruptedException e ) {
}
return i;
}
 
/**
* Sends a vendor request to Endpoint 0 of the EZ-USB device.
* The request may be send multiple times until the {@link #controlMsgTimeout} is reached.
* @param cmd The request number (0..255).
* @param func The name of the request. This string is used for the generation of error messages.
* @param maxlen The size of the requested payload data (0..65535), i.e. bytes 6 and 7 of the setup data.
* @param buf The payload data buffer.
* @return the number of bytes sent.
* @throws UsbException if a communication error occurs.
*/
public int vendorRequest (int cmd, String func, byte[] buf, int maxlen) throws UsbException {
return vendorRequest (cmd, func, 0, 0, buf, maxlen);
}
 
// ******* vendorCommand2 ******************************************************
public void vendorCommand2 (int cmd, String func, int value, int index, byte[] buf, int length) throws UsbException {
/**
* Sends a vendor command to Endpoint 0 of the EZ-USB device and throws an {@link UsbException} if not all of the payload has been sent.
* The command may be send multiple times until the {@link #controlMsgTimeout} is reached.
* @param cmd The command number (0..255).
* @param func The name of the command. This string is used for the generation of error messages.
* @param value The value (0..65535), i.e bytes 2 and 3 of the setup data.
* @param index The index (0..65535), i.e. bytes 4 and 5 of the setup data.
* @param length The size of the payload data (0..65535), i.e. bytes 6 and 7 of the setup data.
* @param buf The payload data buffer.
* @throws UsbException if a communication error occurs or if not all of the payload has been sent.
*/
public synchronized void vendorCommand2 (int cmd, String func, int value, int index, byte[] buf, int length) throws UsbException {
int i = vendorCommand (cmd, func, value, index, buf, length);
if ( i != length )
throw new UsbException( dev.dev(), (func != null ? func + ": " : "" ) + "Send " + i + " byte of data instead of " + length + " bytes");
}
 
public void vendorCommand2 (int cmd, String func, int value, int index) throws UsbException {
byte[] buf = { 0 };
vendorCommand2 (cmd, func, value, index, buf, 0);
}
 
public void vendorCommand2 (int cmd, String func) throws UsbException {
byte[] buf = { 0 };
vendorCommand2 (cmd, func, 0, 0, buf, 0);
}
 
// ******* vendorRequest2 ******************************************************
/**
* Sends a vendor request to Endpoint 0 of the EZ-USB device and throws an {@link UsbException} if not all of the payload has been received.
* The request may be send multiple times until the {@link #controlMsgTimeout} is reached.
* @param cmd The request number (0..255).
* @param func The name of the request. This string is used for the generation of error messages.
* @param value The value (0..65535), i.e bytes 2 and 3 of the setup data.
* @param index The index (0..65535), i.e. bytes 4 and 5 of the setup data.
* @param maxlen The size of the requested payload data (0..65535), i.e. bytes 6 and 7 of the setup data.
* @param buf The payload data buffer.
* @throws UsbException if a communication error occurs or not all of the payload has been received.
*/
public void vendorRequest2 (int cmd, String func, int value, int index, byte[] buf, int maxlen) throws UsbException {
int i = vendorRequest(cmd, func, value, index, buf, maxlen);
if ( i != maxlen )
133,12 → 285,21
throw new UsbException( dev.dev(), (func != null ? func + ": " : "" ) + "Received " + i + " byte of data, expected "+maxlen+" bytes");
}
 
/**
* Sends a vendor request to Endpoint 0 of the EZ-USB device and throws an {@link UsbException} if not all of the payload has been received.
* The request may be send multiple times until the {@link #controlMsgTimeout} is reached.
* @param cmd The request number (0..255).
* @param func The name of the request. This string is used for the generation of error messages.
* @param maxlen The size of the requested payload data (0..65535), i.e. bytes 6 and 7 of the setup data.
* @param buf The payload data buffer.
* @throws UsbException if a communication error occurs or not all of the payload has been received.
*/
public void vendorRequest2 (int cmd, String func, byte[] buf, int maxlen) throws UsbException {
vendorRequest2(cmd, func, 0, 0, buf, maxlen);
}
 
// ******* findOldDevices ******************************************************
private void findOldDevices () {
private synchronized void findOldDevices () {
Usb_Bus bus = dev.dev().getBus();
usbBusName = bus.getDirname();
 
156,7 → 317,7
}
 
// ******* findNewDevice *******************************************************
private Usb_Device findNewDevice ( String errMsg ) throws DeviceLostException {
private synchronized Usb_Device findNewDevice ( String errMsg ) throws DeviceLostException {
Usb_Device newDev = null;
LibusbJava.usb_find_busses();
LibusbJava.usb_find_devices();
180,12 → 341,12
}
 
// ******* initNewDevice *******************************************************
private void initNewDevice ( String errBase ) throws DeviceLostException, UsbException, ZtexDescriptorException {
// scan the bus for up to 5 s for a new device
private void initNewDevice ( String errBase ) throws DeviceLostException, UsbException, InvalidFirmwareException {
// scan the bus for up to 60 s for a new device. Boot sequence may take a while.
Usb_Device newDev = null;
for ( int i=0; i<20 && newDev==null; i++ ) {
for ( int i=0; i<300 && newDev==null; i++ ) {
try {
Thread.sleep( 250 );
Thread.sleep( 200 );
}
catch ( InterruptedException e ) {
}
201,7 → 362,7
try {
dev = new ZtexDevice1( newDev, vid, pid );
}
catch ( ZtexDescriptorException e ) {
catch ( InvalidFirmwareException e ) {
if ( vid == ZtexDevice1.cypressVendorId && pid == ZtexDevice1.cypressProductId ) {
dev = new ZtexDevice1( newDev, -1, -1 );
}
213,8 → 374,23
}
 
// ******* uploadFirmware ******************************************************
/**
* Uploads the firmware to the EZ-USB and manages the renumeration process.
* <p>
* Before the firmware is uploaded the device is set into a reset state.
* After the upload the firmware is booted and the renumeration starts.
* During this process the device disappears from the bus and a new one
* occurs which will be assigned to this class automatically (instead of the disappeared one).
* @param ihxFileName The file name of the firmware image in ihx format. The file can be a regular file or a system resource (e.g. a file from the current jar archive).
* @param force The compatibility check is skipped if true.
* @throws IncompatibleFirmwareException if the given firmware is not compatible to the installed one, see {@link ZtexDevice1#compatible(int,int,int,int)} (Upload can be enforced using the <tt>force</tt> parameter)
* @throws FirmwareUploadException If an error occurred while attempting to upload the firmware.
* @throws UsbException if a communication error occurs.
* @throws InvalidFirmwareException if ZTEX descriptor 1 is not available.
* @throws DeviceLostException if a device went lost after renumeration.
*/
// returns upload time in ms
public long uploadFirmware ( String ihxFileName, boolean force ) throws IncompatibleFirmwareException, FirmwareUploadException, UsbException, ZtexDescriptorException, DeviceLostException {
public long uploadFirmware ( String ihxFileName, boolean force ) throws IncompatibleFirmwareException, FirmwareUploadException, UsbException, InvalidFirmwareException, DeviceLostException {
// load the ihx file
ZtexIhxFile1 ihxFile;
try {
252,7 → 428,18
}
 
// ******* resetEzUsb **********************************************************
public void resetEzUsb () throws IncompatibleFirmwareException, FirmwareUploadException, UsbException, ZtexDescriptorException, DeviceLostException {
/**
* Resets the EZ-USB and manages the renumeration process.
* <p>
* After the reset the renumeration starts.
* During this process the device disappears from the bus and a new one
* occurs which will be assigned to this class automatically (instead of the disappeared one).
* @throws FirmwareUploadException If an error occurred while attempting to upload the firmware.
* @throws UsbException if a communication error occurs.
* @throws InvalidFirmwareException if ZTEX descriptor 1 is not available.
* @throws DeviceLostException if a device went lost after renumeration.
*/
public void resetEzUsb () throws FirmwareUploadException, UsbException, InvalidFirmwareException, DeviceLostException {
// scan the bus for comparison
findOldDevices();
259,7 → 446,7
// reset the EZ-USB
EzUsb.reset(handle,true);
try {
EzUsb.reset(handle,false); // error (may caused re-numeration) can be ignored
EzUsb.reset(handle,false); // error (may caused by re-numeration) can be ignored
}
catch ( FirmwareUploadException e ) {
}
269,6 → 456,10
}
 
// ******* toString ************************************************************
/**
* Returns a lot of useful information about the corresponding device.
* @return a lot of useful information about the corresponding device.
*/
public String toString () {
return dev.toString();
}
/trunk/java/ztex/package.html
0,0 → 1,77
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head></head>
<body bgcolor="white">
The Java API of the <a href="http://www.ztex.de/firmware-kit/index.e.html">ZTEX EZ-USB SDK</a>.
<p>
This API is the host-side counterpart of the Firmware-Kit and allows user software to interact with
EZ-USB devices running with such firmware. It uses <a href="../ch/ntb/usb/package-summary.html">libusbJava</a>, a Java wrapper
for the libusb 0.1 and the libusb-win32 USB libraries. This API is known to run on Linux and Windows, but should work on every operating
system which supports libusb and Java.
<p>
<h2>Features</h2>
The main features are:
<ul>
<li> Platform independent host software. It is possible to pack all necessary files (libusb libraries, firmware, bitstream) into
one single jar archive which runs on both, Linux and Windows (and other OS's that support libusb and Java) </li>
<li> Licensed as Open Source under GPLv3 </li>
<li> Firmware upload directly into the EZ-USB Microcontroller</li>
<li> Access to EEPROM memory</li>
<li> Firmware upload to EEPROM</li>
<li> Support of Flash memory </li>
<li> Bitstream upload directly to the FPGA (for <a href="http://www.ztex.de/usb-fpga-1/usb-fpga-1.2.e.html">ZTEX USB-FPGA-Modules</a>)</li>
<li> Bitstream upload to Flash memory (for <a href="http://www.ztex.de/usb-fpga-1/usb-fpga-1.2.e.html">ZTEX USB-FPGA-Modules</a>)</li>
</ul>
 
<p>
<h2>Interaction with the firmware</h2>
Firmware built using the <a href="http://www.ztex.de/firmware-kit/index.e.html">Firmware Development Kit</a> supports an additional descriptor, the ZTEX descriptor 1. This descriptor
identifies the device and firmware, provides compatibility information (e.g. to avoid that a device is loaded with the wrong firmware)
and specifies the communication protocol. A description of the descriptor is given in {@link ztex.ZtexDevice1}.
<p>
The communication protocol defines how the functions provided by the firmware (see main features above)
can be accessed. Currently there is only one protocol implemented, the so called interface 1.
A description of the interface is given in {@link ztex.Ztex1v1}.
<p>
The most importand classes for the interaction with the EZ-USB device / firmware are
<p>
<table bgcolor="#404040" cellspacing=1 cellpadding=4>
<tr>
<td bgcolor="#ffffff" valign="top">{@link ztex.ZtexDevice1}</td>
<td bgcolor="#ffffff" valign="top">Represents an EZ-USB device that supports ZTEX descriptor 1. These devices can be found using {@link ztex.ZtexScanBus1}. </td>
</tr>
<tr>
<td bgcolor="#ffffff" valign="top">{@link ztex.Ztex1}</td>
<td bgcolor="#ffffff" valign="top">Implementation of interface-independent part of the communication protocol, e.g. uploading the firmware to the EZ-USB and renumeration management.</td>
</tr>
<tr>
<td bgcolor="#ffffff" valign="top">{@link ztex.Ztex1v1}</td>
<td bgcolor="#ffffff" valign="top">Implemenetaion of the Interface 1, i.e. the interface dependent part of the communication protocol.</td>
</tr>
</table>
 
<p>
<h2>System overview</h2>
The following diagram gives an overview about the usage of the different parts of the <a href="http://www.ztex.de/firmware-kit/index.e.html">ZTEX EZ-USB SDK</a>.
<p>
<img src="../../imgs/ztex_firmware_kit-diagram.png" width="660" height="600" alt="ZTEX EZ-USB SDK overview for Linux and Windows">
<p>
The host software usually consists of a single jar archive which contains
<ul>
<li> all necessary Java bytecode; </li>
<li> the libusb Java wrapper libraries for Linux (libusbJava.so) and Windows (libusbJava.dll), which are statically linked against libusb (no libusb installation required); </li>
<li> the firmware for the EZ-USB device (unless not installed in EEPROM); </li>
<li> Bitstream for the FPGA (if required). </li>
</ul>
This single jar archive runs on both, Linux and Windows (or other OS's that support libusb and Java).
<p>
On Linux this jar archive has no additional software requirements. The libusb(Java) library communicates directly with the EZ-USB device using kernel routines.
<p>
On Windows a libusb driver is required. (This driver is a part of the ZTEX SDK package). The libusb(Java) library communicates with the EZ-USB device using that driver.
 
<h2>Related Resources</h2>
For more information about this project visit the
<a href="http://www.ztex.de/firmware-kit/index.e.html">ZTEX EZ-USB SDK</a> page.
 
</body>
</html>
/trunk/java/ztex/BitstreamUploadException.java
17,12 → 17,17
!*/
 
package ztex;
 
/** * Signals that an error occurred while attempting to upload the bitstream. */
public class BitstreamUploadException extends Exception {
public BitstreamUploadException (String msg) {
/**
* Constructs an instance from the given error message.
* @param msg The error message.
*/
public BitstreamUploadException (String msg) {
super( "Error uploading bitstream: "+msg );
}
 
/** * Constructs an instance using a standard message. */
public BitstreamUploadException () {
super( "Error uploading bitstream" );
}
/trunk/java/ztex/DeviceLostException.java
18,11 → 18,17
 
package ztex;
 
/** * Thrown if a device went lost after renumeration. */
public class DeviceLostException extends Exception {
/**
* Constructs an instance from the given input string.
* @param msg A message.
*/
public DeviceLostException (String msg) {
super( msg );
}
 
/** * Constructs an instance using a standard message. */
public DeviceLostException () {
super( "Device lost");
}
/trunk/java/ztex/IncompatibleFirmwareException.java
18,11 → 18,17
 
package ztex;
 
/** *Thrown while attempting to overwrite an existing firmware with an incompatible one.*/
public class IncompatibleFirmwareException extends Exception {
/**
* Constructs an instance from the given error message.
* @param msg The error message.
*/
public IncompatibleFirmwareException (String msg) {
super( "Incompatible firmware: "+msg );
}
 
/** * Constructs an instance using a standard message. */
public IncompatibleFirmwareException () {
super( "Incompatible firmware" );
}
/trunk/java/ztex/Ztex1v1.java
20,15 → 20,38
Functions for USB devices with ZTEX descriptor 1, Interface 1
Interface capabilities and vendor requests (VR) / commands (VC):
0.0 : EEPROM support
VR 0x38 : read from EEPROM
Returns:
EEPROM data
VC 0x39 : write to EEPROM
VR 0x3a : EEPROM state
Returns:
Offs Description
0-1 bytes written
2 checksum
3 0:idle, 1:busy or error
0.1 : FPGA Configuration
VR 0x31 : FPGA state
VR 0x30 : get FPGA state
Returns:
Offs Description
0 1: unconfigured, 0:configured
1 checksum
2-5 transfered bytes
6 INIT_B state
Offs Description
0 1: unconfigured, 0:configured
1 checksum
2-5 transferred bytes
6 INIT_B state
VC 0x31 : reset FPGA
VC 0x32 : send FPGA configuration data (Bitstream)
 
0.2 : Flash memory support
VR 0x40 : Flash state
Returns:
Offs Description
0 1:enabled, 0:disabled
1-2 Sector size
3-6 Number of sectors
7 Error code
VR 0x41 : read from Flash
VR 0x42 : write to Flash
*/
package ztex;
 
37,55 → 60,268
 
import ch.ntb.usb.*;
 
/**
* This class implements the communication protocol of the interface version 1 for the interaction with the ZTEX firmware.
* <p>
* The features supported by this interface can be accessed via vendor commands and vendor requests via Endpoint 0.
* Each feature can be enabled or disabled by the firmware and also depends from the hardware.
* The presence of a feature is indicated by a 1 in the corresponding feature bit of the ZTEX descriptor 1, see {@link ZtexDevice1}.
* The following table gives an overview about the features
* <table bgcolor="#404040" cellspacing=1 cellpadding=10>
* <tr>
* <td bgcolor="#d0d0d0" valign="bottom"><b>Capability bit</b></td>
* <td bgcolor="#d0d0d0" valign="bottom"><b>Description</b></td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">0.0</td>
* <td bgcolor="#ffffff" valign="top" colspan=2>
* EEPROM support<p>
* <table bgcolor="#404040" cellspacing=1 cellpadding=6>
* <tr>
* <td bgcolor="#d0d0d0" valign="bottom"><b>Vendor request (VR)<br> or command (VC)</b></td>
* <td bgcolor="#d0d0d0" valign="bottom"><b>Description</b></td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">VR 0x38</td>
* <td bgcolor="#ffffff" valign="top">Read from EEPROM</td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">VC 0x39</td>
* <td bgcolor="#ffffff" valign="top">Write to EEPROM</td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">VR 0x3a</td>
* <td bgcolor="#ffffff" valign="top">Get EEPROM state. Returns:
* <table bgcolor="#404040" cellspacing=1 cellpadding=4>
* <tr>
* <td bgcolor="#d0d0d0" valign="bottom"><b>Bytes</b></td>
* <td bgcolor="#d0d0d0" valign="bottom"><b>Description</b></td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">0-1</td>
* <td bgcolor="#ffffff" valign="top">Number of bytes written.</td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">2</td>
* <td bgcolor="#ffffff" valign="top">Checksum</td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">3</td>
* <td bgcolor="#ffffff" valign="top">0:idle, 1:busy or error</td>
* </tr>
* </table>
* </td>
* </tr>
* </table>
* </td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">0.1</td>
* <td bgcolor="#ffffff" valign="top" colspan=2>
* FPGA Configuration<p>
* <table bgcolor="#404040" cellspacing=1 cellpadding=6>
* <tr>
* <td bgcolor="#d0d0d0" valign="bottom"><b>Vendor request (VR)<br> or command (VC)</b></td>
* <td bgcolor="#d0d0d0" valign="bottom"><b>Description</b></td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">VR 0x30</td>
* <td bgcolor="#ffffff" valign="top">Get FPGA state. Returns:
* <table bgcolor="#404040" cellspacing=1 cellpadding=4>
* <tr>
* <td bgcolor="#d0d0d0" valign="bottom"><b>Bytes</b></td>
* <td bgcolor="#d0d0d0" valign="bottom"><b>Description</b></td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">0</td>
* <td bgcolor="#ffffff" valign="top">1: unconfigured, 0:configured</td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">1</td>
* <td bgcolor="#ffffff" valign="top">Checksum</td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">2-5</td>
* <td bgcolor="#ffffff" valign="top">Number of bytes transferred.</td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">6</td>
* <td bgcolor="#ffffff" valign="top">INIT_B states (Must be 222).</td>
* </tr>
* </table>
* </td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">VC 0x31</td>
* <td bgcolor="#ffffff" valign="top">Reset FPGA</td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">VR 0x32</td>
* <td bgcolor="#ffffff" valign="top">Send Bitstream</td>
* </tr>
* </table>
* </td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">0.2</td>
* <td bgcolor="#ffffff" valign="top" colspan=2>
* Flash memory support<p>
* <table bgcolor="#404040" cellspacing=1 cellpadding=6>
* <tr>
* <td bgcolor="#d0d0d0" valign="bottom"><b>Vendor request (VR)<br> or command (VC)</b></td>
* <td bgcolor="#d0d0d0" valign="bottom"><b>Description</b></td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">VR 0x40</td>
* <td bgcolor="#ffffff" valign="top">Get Flash state. Returns:
* <table bgcolor="#404040" cellspacing=1 cellpadding=4>
* <tr>
* <td bgcolor="#d0d0d0" valign="bottom"><b>Bytes</b></td>
* <td bgcolor="#d0d0d0" valign="bottom"><b>Description</b></td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">0</td>
* <td bgcolor="#ffffff" valign="top">1:enabled, 0:disabled</td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">1-2</td>
* <td bgcolor="#ffffff" valign="top">Sector size</td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">3-6</td>
* <td bgcolor="#ffffff" valign="top">Number of sectors</td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">7</td>
* <td bgcolor="#ffffff" valign="top">Error code</td>
* </tr>
* </table>
* </td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">VR 0x41</td>
* <td bgcolor="#ffffff" valign="top">Read one sector from Flash</td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">VC 0x42</td>
* <td bgcolor="#ffffff" valign="top">Write one sector to Flash</td>
* </tr>
* </table>
* </td>
* </tr>
* </table>
* @see ZtexDevice1
* @see Ztex1
*/
 
public class Ztex1v1 extends Ztex1 {
/** * The names of the capabilities */
public static final String capabilityStrings[] = {
"EEPROM read/write" ,
"FPGA configuration"
"FPGA configuration" ,
"Flash memory support"
};
public boolean certainWorkarounds = false; // setting to true will enable certain workarounds which may be required for vmware + windows
 
private boolean fpgaConfigured = false;
private int fpgaChecksum = 0;
private int fpgaBytes = 0;
private int fpgaInitB = 0;
/** * Number of bytes written to EEPROM. (Obtained by {@link #eepromState()}.) */
public int eepromBytes = 0;
/** * Checksum of the last EEPROM transfer. (Obtained by {@link #eepromState()}.) */
public int eepromChecksum = 0;
public boolean eepromReady = true;
 
private int flashEnabled = -1;
private int flashSectorSize = -1;
private int flashSectors = -1;
 
/** * Last Flash error code obtained by {@link #flashState()}. See FLASH_EC_* for possible error codes. */
public int flashEC = 0;
/** * Means no error. */
public static final int FLASH_EC_NO_ERROR = 0;
/** * Signals an error while attempting to execute a command. */
public static final int FLASH_EC_CMD_ERROR = 1;
/** * Signals that a timeout occurred. */
public static final int FLASH_EC_TIMEOUT = 2;
/** * Signals that Flash memory it busy. */
public static final int FLASH_EC_BUSY = 3;
/** * Signals that another Flash operation is pending. */
public static final int FLASH_EC_PENDING = 4;
/** * Signals an error while attempting to read from Flash. */
public static final int FLASH_EC_READ_ERROR = 5;
/** * Signals an error while attempting to write to Flash. */
public static final int FLASH_EC_WRITE_ERROR = 6;
 
// ******* Ztex1v1 *************************************************************
public Ztex1v1 ( ZtexDevice1 pDev ) throws UsbException, ZtexDescriptorException {
/**
* Constructs an instance from a given device.
* @param pDev The given device.
* @throws UsbException if an communication error occurred.
*/
public Ztex1v1 ( ZtexDevice1 pDev ) throws UsbException {
super ( pDev );
certainWorkarounds = false;
}
 
// ******* valid ***************************************************************
/**
* Returns true if ZTEX interface 1 is available.
* @return true if ZTEX interface 1 is available.
*/
public boolean valid ( ) {
return dev.valid() && dev.interfaceVersion()==1;
return dev().valid() && dev().interfaceVersion()==1;
}
 
/**
* Returns true if ZTEX interface 1 and capability i.j are available.
* @param i byte index of the capability
* @param j bit index of the capability
* @return true if ZTEX interface 1 and capability i.j are available.
*/
public boolean valid ( int i, int j) {
return dev.valid() && dev.interfaceVersion()==1 && dev.interfaceCapabilities(i,j);
return dev().valid() && dev().interfaceVersion()==1 && dev().interfaceCapabilities(i,j);
}
 
// ******* compatible **********************************************************
/**
* Checks whether the given product ID is compatible to the device corresponding to this class and whether interface 1 is supported.<br>
* The given product ID is compatible
* <pre>if ( this.productId(0)==0 || productId0<=0 || this.productId(0)==productId0 ) &&
( this.productId(0)==0 || productId1<=0 || this.productId(1)==productId1 ) &&
( this.productId(2)==0 || productId2<=0 || this.productId(2)==productId2 ) &&
( this.productId(3)==0 || productId3<=0 || this.productId(3)==productId3 ) </pre>
* @param productId0 Byte 0 of the given product ID
* @param productId1 Byte 1 of the given product ID
* @param productId2 Byte 2 of the given product ID
* @param productId3 Byte 3 of the given product ID
* @return true if the given product ID is compatible and interface 1 is supported.
*/
public boolean compatible ( int productId0, int productId1, int productId2, int productId3 ) {
return dev.valid() && dev.compatible ( productId0, productId1, productId2, productId3 ) && dev.interfaceVersion()==1;
return dev().valid() && dev().compatible ( productId0, productId1, productId2, productId3 ) && dev().interfaceVersion()==1;
}
 
// ******* checkValid **********************************************************
/**
* Checks whether ZTEX descriptor 1 is available and interface 1 is supported.
* @throws InvalidFirmwareException if ZTEX descriptor 1 is not available or interface 1 is not supported.
*/
public void checkValid () throws InvalidFirmwareException {
super.checkValid();
if ( dev.interfaceVersion() != 1 )
throw new InvalidFirmwareException(this, "Wrong interface: " + dev.interfaceVersion() + ", expected: 1" );
if ( dev().interfaceVersion() != 1 )
throw new InvalidFirmwareException(this, "Wrong interface: " + dev().interfaceVersion() + ", expected: 1" );
}
 
// ******* checkCapability *****************************************************
/**
* Checks whether ZTEX descriptor 1 is available and interface 1 and a given capability are supported.
* @param i byte index of the capability
* @param j bit index of the capability
* @throws InvalidFirmwareException if ZTEX descriptor 1 is not available or interface 1 is not supported.
* @throws CapabilityException if the given capability is not supported.
*/
public void checkCapability ( int i, int j ) throws InvalidFirmwareException, CapabilityException {
checkValid();
if ( ! dev.interfaceCapabilities(i,j) ) {
if ( ! dev().interfaceCapabilities(i,j) ) {
int k = i*8 + j;
if ( k>=0 && k<capabilityStrings.length )
throw new CapabilityException( this, ( k>=0 && k<=capabilityStrings.length ) ? capabilityStrings[k] : ("Capabilty " + i + "," + j) );
93,9 → 329,18
}
 
// ******* checkCompatible *****************************************************
/**
* Checks whether the given product ID is compatible to the device corresponding to this class and whether interface 1 is supported.
* See {@link #compatible(int,int,int,int)}.
* @param productId0 Byte 0 of the given product ID
* @param productId1 Byte 1 of the given product ID
* @param productId2 Byte 2 of the given product ID
* @param productId3 Byte 3 of the given product ID
* @throws InvalidFirmwareException if the given product ID is not compatible or interface 1 is not supported.
*/
public void checkCompatible ( int productId0, int productId1, int productId2, int productId3 ) throws InvalidFirmwareException {
checkValid();
if ( ! dev.compatible ( productId0, productId1, productId2, productId3 ) )
if ( ! dev().compatible ( productId0, productId1, productId2, productId3 ) )
throw new InvalidFirmwareException(this, "Incompatible Product ID");
}
 
110,7 → 355,26
fpgaInitB = buffer[6] & 0xff;
}
 
// ******* getFpgaState ********************************************************
/**
* Prints out the FPGA state.
* @throws InvalidFirmwareException if interface 1 is not supported.
* @throws UsbException if a communication error occurs.
* @throws CapabilityException if FPGA configuration is not supported by the firmware.
*/
public void printFpgaState () throws UsbException, InvalidFirmwareException, CapabilityException {
getFpgaState();
System.out.println( "size=" + fpgaBytes + " ; checksum=" + fpgaChecksum + "; INIT_B_HIST=" + fpgaInitB +" (should be 222)" );
}
 
// ******* getFpgaConfiguration ************************************************
/**
* Returns true if the FPGA is configured.
* @return true if the FPGA is configured.
* @throws InvalidFirmwareException if interface 1 is not supported.
* @throws UsbException if a communication error occurs.
* @throws CapabilityException if FPGA configuration is not supported by the firmware.
*/
public boolean getFpgaConfiguration () throws UsbException, InvalidFirmwareException, CapabilityException {
getFpgaState ();
return fpgaConfigured;
117,6 → 381,13
}
 
// ******* getFpgaConfigurationStr *********************************************
/**
* Returns a string that indicates the FPGA configuration status.
* @return a string that indicates the FPGA configuration status.
* @throws InvalidFirmwareException if interface 1 is not supported.
* @throws UsbException if a communication error occurs.
* @throws CapabilityException if FPGA configuration is not supported by the firmware.
*/
public String getFpgaConfigurationStr () throws UsbException, InvalidFirmwareException, CapabilityException {
getFpgaState ();
return fpgaConfigured ? "FPGA configured" : "FPGA unconfigured";
123,6 → 394,12
}
 
// ******* resetFGPA ***********************************************************
/**
* Resets the FPGA.
* @throws InvalidFirmwareException if interface 1 is not supported.
* @throws UsbException if a communication error occurs.
* @throws CapabilityException if FPGA configuration is not supported by the firmware.
*/
public void resetFpga () throws UsbException, InvalidFirmwareException, CapabilityException {
checkCapability(0,1);
vendorCommand(0x31, "resetFpga" );
130,6 → 407,17
 
// ******* configureFpga *******************************************************
// returns configuration time in ms
/**
* Upload a Bitstream to the FPGA.
* @param fwFileName The file name of the Bitstream. The file can be a regular file or a system resource (e.g. a file from the current jar archive).
* @param force If set to true existing configurations will be overwritten. (By default an {@link AlreadyConfiguredException} is thrown).
* @throws BitstreamReadException if an error occurred while attempting to read the Bitstream.
* @throws BitstreamUploadException if an error occurred while attempting to upload the Bitstream.
* @throws AlreadyConfiguredException if the FPGA is already configured.
* @throws InvalidFirmwareException if interface 1 is not supported.
* @throws UsbException if a communication error occurs.
* @throws CapabilityException if FPGA configuration is not supported by the firmware.
*/
public long configureFpga ( String fwFileName, boolean force ) throws BitstreamReadException, UsbException, BitstreamUploadException, AlreadyConfiguredException, InvalidFirmwareException, CapabilityException {
final int transactionBytes = certainWorkarounds ? 256 : 2048;
long t0 = 0;
139,7 → 427,7
if ( !force && getFpgaConfiguration() )
throw new AlreadyConfiguredException();
 
// read the bitstream file
// read the Bitstream file
byte[][] buffer = new byte[4*1024*1024/transactionBytes][];
int size = 0;
try {
168,7 → 456,7
if ( size < 64 || size % 64 == 0 )
throw new BitstreamReadException("Invalid file size: " + size );
// upload the bitstream file
// upload the Bitstream file
for ( int tries=10; tries>0; tries-- ) {
resetFpga();
189,12 → 477,13
cs = ( cs + (buffer[i][k] & 0xff) ) & 0xff;
}
 
getFpgaState();
getFpgaState();
// System.err.println("fpgaConfigred=" + fpgaConfigured + " fpgaBytes="+fpgaBytes + " ("+bs+") fpgaChecksum="+fpgaChecksum + " ("+cs+") fpgaInitB="+fpgaInitB );
if ( ! fpgaConfigured ) {
throw new BitstreamUploadException( "FPGA configuration failed: DONE pin does not go high (size=" + fpgaBytes + " , " + (bs - fpgaBytes) + " bytes went lost; checksum="
+ fpgaChecksum + " , should be " + cs + "; INIT_B_HIST=" + fpgaInitB +", should be 222)" );
}
// System.out.println( "FPGA configuration: size=" + fpgaBytes + " , " + (bs - fpgaBytes) + " bytes went lost; checksum=" + fpgaChecksum + " , should be " + cs + "; INIT_B_HIST=" + fpgaInitB +", should be 222" );
if ( fpgaInitB != 222 )
System.err.println ( "Warning: FPGA configuration may have failed: DONE pin has gone high but INIT_B states are wrong: " + fpgaInitB +", should be 222");
221,6 → 510,14
 
// ******* eepromState *********************************************************
// returns true if EEPROM is ready
/**
* Reads the current EEPROM status.
* This method also sets the varibles {@link #eepromBytes} and {@link #eepromChecksum}.
* @throws InvalidFirmwareException if interface 1 is not supported.
* @throws UsbException if a communication error occurs.
* @throws CapabilityException if EEPROM access is not supported by the firmware.
* @return true if EEPROM is ready.
*/
public boolean eepromState ( ) throws UsbException, InvalidFirmwareException, CapabilityException {
byte[] buf = new byte[4];
checkCapability(0,0);
227,32 → 524,61
vendorRequest2(0x3A, "EEPROM State", 0, 0, buf, 4);
eepromBytes = (buf[0] & 255) | (buf[1] & 255)<<8;
eepromChecksum = buf[2] & 255;
eepromReady = buf[3] == 0;
return eepromReady;
return buf[3] == 0;
}
 
// ******* eepromWrite *********************************************************
/**
* Writes data to the EEPROM.
* @param addr The destination address of the EEPROM.
* @param buf The data.
* @param length The amount of bytes to be sent.
* @throws InvalidFirmwareException if interface 1 is not supported.
* @throws UsbException if a communication error occurs.
* @throws CapabilityException if EEPROM access is not supported by the firmware.
*/
public void eepromWrite ( int addr, byte[] buf, int length ) throws UsbException, InvalidFirmwareException, CapabilityException {
checkCapability(0,0);
vendorCommand2( 0x39, "EEPROM Write", addr, 0, buf, length );
try {
Thread.sleep( 10 );
}
catch ( InterruptedException e) {
}
}
 
// ******* eepromRead **********************************************************
/**
* Reads data from the EEPROM.
* @param addr The source address of the EEPROM.
* @param buf A buffer for the storage of the data.
* @param length The amount of bytes to be read.
* @throws InvalidFirmwareException if interface 1 is not supported.
* @throws UsbException if a communication error occurs.
* @throws CapabilityException if EEPROM access is not supported by the firmware.
*/
public void eepromRead ( int addr, byte[] buf, int length ) throws UsbException, InvalidFirmwareException, CapabilityException {
checkCapability(0,0);
for ( int tries=4; tries>0; tries-- ) {
try {
vendorRequest2( 0x38, "EEPROM Read", addr, 0, buf, length ); // sometimes a little bit slow
tries = 0;
}
catch ( UsbException e ) {
if ( tries<=1 ) throw e;
}
}
vendorRequest2( 0x38, "EEPROM Read", addr, 0, buf, length ); // sometimes a little bit slow
try {
Thread.sleep( 10 );
}
catch ( InterruptedException e) {
}
}
 
// ******* eepromUpload ********************************************************
// returns upload time in ms
/**
* Upload the firmware to the EEPROM.
* In order to start the uploaded firmware the device must be reset.
* @param ihxFileName The file name of the firmware image in ihx format. The file can be a regular file or a system resource (e.g. a file from the current jar archive).
* @param force Skips the compatibility check if true.
* @throws IncompatibleFirmwareException if the given firmware is not compatible to the installed one, see {@link #compatible(int,int,int,int)} (Upload can be enforced using the <tt>force</tt> parameter.)
* @throws InvalidFirmwareException if interface 1 is not supported.
* @throws CapabilityException if EEPROM access is not supported by the firmware.
* @throws FirmwareUploadException if an error occurred while attempting to upload the firmware.
*/
public long eepromUpload ( String ihxFileName, boolean force ) throws IncompatibleFirmwareException, FirmwareUploadException, InvalidFirmwareException, CapabilityException {
final int pagesMax = 256;
final int pageSize = 256;
276,16 → 602,16
// System.out.println(ihxFile);
 
// check for compatibility
if ( ! force && dev.valid() ) {
if ( ! force && dev().valid() ) {
if ( ihxFile.interfaceVersion() != 1 )
throw new IncompatibleFirmwareException("Wrong interface version: Expected 1, got " + ihxFile.interfaceVersion() );
if ( ! dev.compatible ( ihxFile.productId(0), ihxFile.productId(1), ihxFile.productId(2), ihxFile.productId(3) ) )
throw new IncompatibleFirmwareException("Incompatible productId's: Current firmware: " + ZtexDevice1.byteArrayString(dev.productId())
if ( ! dev().compatible ( ihxFile.productId(0), ihxFile.productId(1), ihxFile.productId(2), ihxFile.productId(3) ) )
throw new IncompatibleFirmwareException("Incompatible productId's: Current firmware: " + ZtexDevice1.byteArrayString(dev().productId())
+ " Ihx File: " + ZtexDevice1.byteArrayString(ihxFile.productId()) );
}
 
Usb_Device_Descriptor dd = dev.dev().getDescriptor();
Usb_Device_Descriptor dd = dev().dev().getDescriptor();
int vid = dd.getIdVendor() & 65535;
int pid = dd.getIdProduct() & 65535;
 
344,7 → 670,7
cs = ( cs + (buffer[i][j] & 255) ) & 255;
}
 
for ( int tries=4; tries>0; tries-- ) {
for ( int tries=3; tries>0; tries-- ) {
try {
eepromWrite(i*pageSize, buffer[i], k);
eepromState();
376,10 → 702,17
 
// ******* eepromDisable ********************************************************
/**
* Disables the firmware stored in the EEPROM.
* This is achived by writing a "0" to the address 0 of the EEPROM.
* @throws InvalidFirmwareException if interface 1 is not supported.
* @throws CapabilityException if EEPROM access is not supported by the firmware.
* @throws FirmwareUploadException if an error occurred while attempting to disable the firmware.
*/
public void eepromDisable ( ) throws FirmwareUploadException, InvalidFirmwareException, CapabilityException {
byte[] buf = { 0 };
 
for ( int tries=4; tries>0; tries-- ) {
for ( int tries=3; tries>0; tries-- ) {
try {
eepromWrite(0, buf, 1);
 
399,10 → 732,386
}
}
}
 
// ******* flashStrError *******************************************************
/**
* Converts a given error code into a String.
* @param errNum The error code.
* @return an error message.
*/
public static String flashStrError ( int errNum ) {
switch ( errNum ) {
case FLASH_EC_NO_ERROR:
return "USB error: " + LibusbJava.usb_strerror();
case FLASH_EC_CMD_ERROR:
return "Command error";
case FLASH_EC_TIMEOUT:
return "Timeout error";
case FLASH_EC_BUSY:
return "Busy";
case FLASH_EC_PENDING:
return "Another operation is pending";
case FLASH_EC_READ_ERROR:
return "Read error";
case FLASH_EC_WRITE_ERROR:
return "Write error";
}
return "Error " + errNum;
}
 
/**
* Gets the last Flash error from the device.
* @return an error message.
*/
public String flashStrError ( ) {
try {
return flashStrError( getFlashEC() );
}
catch ( Exception e ) {
return "Unknown error (Error receiving errorcode: "+e.getLocalizedMessage() +")";
}
}
 
// ******* flashState **********************************************************
/**
* Reads the the Flash memory status and information.
* This method also sets the variables {@link #flashEnabled}, {@link #flashSectorSize} and {@link #flashSectors}.
* @return true if Flash memory is installed.
* @throws InvalidFirmwareException if interface 1 is not supported.
* @throws UsbException if a communication error occurs.
* @throws CapabilityException if Flash memory access is not supported by the firmware.
*/
public boolean flashState () throws UsbException, InvalidFirmwareException, CapabilityException {
byte[] buf = new byte[8];
checkCapability(0,2);
 
// device may be busy due to initialization, we try it up to up to 4s
vendorRequest2(0x40, "Flash State", 0, 0, buf, 8);
flashEC = buf[7] & 255;
int tries=20;
while ( flashEC==FLASH_EC_BUSY && tries>0 )
{
try {
Thread.sleep( 200 );
}
catch ( InterruptedException e) {
}
tries-=1;
vendorRequest2(0x40, "Flash State", 0, 0, buf, 8);
flashEC = buf[7] & 255;
}
flashEnabled = buf[0] & 255;
flashSectorSize = flashEnabled == 1 ? ((buf[2] & 255) << 8) | (buf[1] & 255) : 0;
flashSectors = flashEnabled == 1 ? ((buf[6] & 255) << 24) | ((buf[5] & 255) << 16) | ((buf[4] & 255) << 8) | (buf[3] & 255) : 0;
return flashEnabled == 1;
}
 
// ******* getFlashEC **********************************************************
// reads the current error code
/**
* Gets the last Flash error from the device.
* @throws InvalidFirmwareException if interface 1 is not supported.
* @throws UsbException if a communication error occurs.
* @throws CapabilityException if Flash memory access is not supported by the firmware.
*/
public int getFlashEC () throws UsbException, InvalidFirmwareException, CapabilityException {
byte[] buf = new byte[8];
checkCapability(0,2);
vendorRequest2(0x40, "Flash State", 0, 0, buf, 8);
flashEC = buf[7] & 255;
return flashEC;
}
 
// ******* flashReadSector ****************************************************
// read exactly one sector
/**
* Reads one sector from the Flash.
* @param sector The sector number to be read.
* @param buf A buffer for the storage of the data.
* @throws InvalidFirmwareException if interface 1 is not supported.
* @throws UsbException if a communication error occurs.
* @throws CapabilityException if Flash memory access is not possible.
*/
public void flashReadSector ( int sector, byte[] buf ) throws UsbException, InvalidFirmwareException, CapabilityException {
checkCapability(0,2);
if ( ! flashEnabled() )
throw new CapabilityException(this, "No Flash memory installed or");
 
try {
vendorRequest2( 0x41, "Flash Read", sector, 0, buf, flashSectorSize );
}
catch ( UsbException e ) {
throw new UsbException( dev().dev(), "Flash Read: " + flashStrError() );
}
}
 
// ******* flashWriteSector ***************************************************
// write exactly one sector
/**
* Writes one sector to the Flash.
* @param sector The sector number to be written.
* @param buf The data.
* @throws InvalidFirmwareException if interface 1 is not supported.
* @throws UsbException if a communication error occurs.
* @throws CapabilityException if Flash memory access is not possible.
*/
public void flashWriteSector ( int sector, byte[] buf ) throws UsbException, InvalidFirmwareException, CapabilityException {
checkCapability(0,2);
if ( ! flashEnabled() )
throw new CapabilityException(this, "No Flash memory installed or");
 
try {
vendorCommand2( 0x42, "Flash Write", sector, 0, buf, flashSectorSize );
}
catch ( UsbException e ) {
throw new UsbException( dev().dev(), "Flash Write: " + flashStrError() );
}
}
 
// ******* flashEnabled ********************************************************
// returns enabled / disabled state
/**
* Returns true if Flash memory is installed.
* @return true if Flash memory is installed.
* @throws InvalidFirmwareException if interface 1 is not supported.
* @throws UsbException if a communication error occurs.
* @throws CapabilityException if Flash memory access is not supported by the firmware.
*/
public boolean flashEnabled () throws UsbException, InvalidFirmwareException, CapabilityException {
if ( flashEnabled < 0 ) // init variable
flashState();
return flashEnabled == 1;
}
 
// ******* flashSectorSize *****************************************************
// returns sector size of Flash memory, if available
/**
* Returns the sector size of the Flash memory or 0, if no flash memory is installed.
* If required, the sector size is determined form the device first.
* @return the sector size of the Flash memory.
* @throws InvalidFirmwareException if interface 1 is not supported.
* @throws UsbException if a communication error occurs.
* @throws CapabilityException if Flash memory access is not supported by the firmware.
*/
public int flashSectorSize () throws UsbException, InvalidFirmwareException, CapabilityException {
if ( flashSectorSize < 0 ) // init variable
flashState();
return flashSectorSize;
}
 
// ******* flashSectors ********************************************************
// returns number of sectors of Flash memory, if available
/**
* Returns the number of sectors of the Flash memory or 0, if no Flash memory is installed.
* If required, the number of sectors is determined form the device first.
* @return the number of sectors of the Flash memory.
* @throws InvalidFirmwareException if interface 1 is not supported.
* @throws UsbException if a communication error occurs.
* @throws CapabilityException if Flash memory access is not supported by the firmware.
*/
public int flashSectors () throws UsbException, InvalidFirmwareException, CapabilityException {
if ( flashSectors < 0 ) // init variable
flashState();
return flashSectors;
}
 
// ******* flashSize ***********************************************************
// returns size of Flash memory, if available
/**
* Returns the size of Flash memory or 0, if no Flash memory is installed.
* If required, the Flash size is determined form the device first.
* @return the size of Flash memory.
* @throws InvalidFirmwareException if interface 1 is not supported.
* @throws UsbException if a communication error occurs.
* @throws CapabilityException if Flash memory access is not supported by the firmware.
*/
public long flashSize () throws UsbException, InvalidFirmwareException, CapabilityException {
return flashSectorSize() * flashSectors();
}
 
// ******* printMmcState *******************************************************
// returns true if Flash is available
/**
* Prints out some debug information about *SD/MMC Flash cards in SPI mode.<br>
* <b>Only use this method if such kind of Flash is installed.</b>
* @throws InvalidFirmwareException if interface 1 is not supported.
* @throws UsbException if a communication error occurs.
* @throws CapabilityException if Flash memory access is not supported by the firmware.
*/
public boolean printMmcState ( ) throws UsbException, InvalidFirmwareException, CapabilityException {
byte[] buf = new byte[22];
checkCapability(0,2);
vendorRequest2(0x43, "MMC State", 0, 0, buf, 22);
System.out.println("status=" + Integer.toBinaryString(256+(buf[0] & 255)).substring(1) + "." + Integer.toBinaryString(256+(buf[1] & 255)).substring(1) +
" lastCmd=" + buf[3] +
" lastCmdResponse=" + Integer.toBinaryString(256+(buf[4] & 255)).substring(1) +
" ec=" + buf[2] +
" BUSY=" + buf[21] +
" buf=" + (buf[5] & 255)+" "+(buf[6] & 255)+" "+(buf[7] & 255)+" "+(buf[8] & 255)+" "+(buf[9] & 255)+" "+(buf[10] & 255)+" "+(buf[11] & 255)); // +" "+(buf[12] & 255)+" "+(buf[13] & 255)+" "+(buf[14] & 255)+" "+(buf[15] & 255)+" "+(buf[16] & 255));
 
return flashEnabled == 1;
}
 
// ******* flashUploadBitstream ************************************************
/*
Returns configuration time in ms.
The format of the boot sector (sector 0 of the Flash memory) is
0..7
8..9 Number of sectors, or 0 is disabled
10..11 Number of bytes in the last sector, i.e. th total size of Bitstream is ((bs[8] | (bs[9]<<8) - 1) * flash_sector_size + ((bs[10] | (bs[11]<<8))
*/
/**
* Uploads a Bitstream to the Flash.
* This allows the firmware to load the Bitstream from Flash. Together with installation of the firmware in EEPROM
* it is possible to construct fully autonomous devices.
* <p>
* Information about the bitstream is stored in sector 0.
* This so called boot sector has the following format:
* <table bgcolor="#404040" cellspacing=1 cellpadding=4>
* <tr>
* <td bgcolor="#d0d0d0" valign="bottom"><b>Bytes</b></td>
* <td bgcolor="#d0d0d0" valign="bottom"><b>Description</b></td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">0..7</td>
* <td bgcolor="#ffffff" valign="top">ID, must be "ZTEXBS",1,1</td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">8..9</td>
* <td bgcolor="#ffffff" valign="top">The number of sectors used to store the Bitstream. 0 means no Bitstream.</td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">10..11</td>
* <td bgcolor="#ffffff" valign="top">The number of bytes in the last sector.</td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">12..sectorSize-1</td>
* <td bgcolor="#ffffff" valign="top">This data is reserved for future use and preserved by this method.</td>
* </tr>
* </table>
* <p>
* The total size of the Bitstream is computed as ((bs[8] | (bs[9]<<8) - 1) * flash_sector_size + ((bs[10] | (bs[11]<<8))
* where bs[i] denotes byte i of the boot sector.
* <p>
* The first sector of the Bitstream is sector 1.
* @param fwFileName The file name of the Bitstream. The file can be a regular file or a system resource (e.g. a file from the current jar archive).
* @throws InvalidFirmwareException if interface 1 is not supported.
* @throws UsbException if a communication error occurs.
* @throws CapabilityException if Flash memory access is not possible.
* @throws BitstreamReadException if an error occurred while attempting to read the Bitstream.
*/
public long flashUploadBitstream ( String fwFileName ) throws BitstreamReadException, UsbException, InvalidFirmwareException, CapabilityException {
checkCapability(0,2);
if ( ! flashEnabled() )
throw new CapabilityException(this, "No Flash memory installed or");
// read the Bitstream file
byte[][] buffer = new byte[2048][];
int i,j;
try {
InputStream inputStream = JInputStream.getInputStream( fwFileName );
j = flashSectorSize;
for ( i=0; i<buffer.length && j==flashSectorSize; i++ ) {
buffer[i] = new byte[flashSectorSize];
j = inputStream.read( buffer[i] );
if ( j < 0 )
j = 0;
}
try {
inputStream.close();
}
catch ( Exception e ) {
System.err.println( "Warning: Error closing file " + fwFileName + ": " + e.getLocalizedMessage() );
}
}
catch (IOException e) {
throw new BitstreamReadException(e.getLocalizedMessage());
}
 
// upload the Bitstream file
byte[] sector = new byte[flashSectorSize];
byte[] ID = new String("ZTEXBS").getBytes();
 
flashReadSector(0,sector); // read the boot sector (only the first 16 bytes are overwritten)
for (int k=0; k<6; k++)
sector[k]=ID[k];
sector[6] = 1;
sector[7] = 1;
sector[8] = (byte) (i & 255);
sector[9] = (byte) ((i>>8) & 255);
sector[10] = (byte) (j & 255);
sector[11] = (byte) ((j>>8) & 255);
long t0 = new Date().getTime();
flashWriteSector(0,sector); // write the boot sector
for (int k=0; k<i; k++)
flashWriteSector(k+1,buffer[k]); // write the Bitstream sectors
 
return new Date().getTime() - t0;
}
 
// ******* flashResetBitstream *************************************************
// Clears a Bitstream from the Flash.
/**
* Clears a Bitstream from the Flash.
* This is achieved by writing 0 to bytes 8..9 of the boot sector, see {@link #flashUploadBitstream(String)}.
* If no boot sector is installed the method returns without any write action.
* @throws InvalidFirmwareException if interface 1 is not supported.
* @throws UsbException if a communication error occurs.
* @throws CapabilityException if Flash memory access is not possible.
*/
public void flashResetBitstream ( ) throws UsbException, InvalidFirmwareException, CapabilityException {
checkCapability(0,2);
if ( ! flashEnabled() )
throw new CapabilityException(this, "No Flash memory installed or");
byte[] sector = new byte[flashSectorSize];
byte[] ID = new String("ZTEXBS").getBytes();
 
flashReadSector(0,sector); // read the boot sector
for (int k=0; k<6; k++)
if ( sector[k] != ID[k] )
return;
if (sector[6]!=1 || sector[7]!=1 )
return;
sector[8] = 0;
sector[9] = 0;
flashWriteSector(0,sector); // write the boot sector
}
 
// ******* flashFirstFreeSector ************************************************
// Returns the first free sector of the Flash memory, i.e. the first sector behind the Bitstream
/**
* Returns the first free sector of the Flash memory.
* This is the first sector behind the Bitstream, or 0 if no boot sector is installed (or 1 if a boot sector but no Bitstream is installed).
* @return the first free sector of the Flash memory.
* @throws InvalidFirmwareException if interface 1 is not supported.
* @throws UsbException if a communication error occurs.
* @throws CapabilityException if Flash memory access is not possible.
*/
public int flashFirstFreeSector ( ) throws UsbException, InvalidFirmwareException, CapabilityException {
checkCapability(0,2);
if ( ! flashEnabled() )
throw new CapabilityException(this, "No Flash memory installed or");
 
byte[] sector = new byte[flashSectorSize];
byte[] ID = new String("ZTEXBS").getBytes();
 
flashReadSector(0,sector); // read the boot sector
for (int k=0; k<6; k++)
if ( sector[k] != ID[k] )
return 0;
if (sector[6]!=1 || sector[7]!=1 )
return 0;
return (sector[8] & 255) + ((sector[9] & 255) << 8) + 1;
}
// ******* toString ************************************************************
/**
* Returns a lot of useful information about the corresponding device.
* @return a lot of useful information about the corresponding device.
*/
public String toString () {
String str = dev.toString();
String str = dev().toString();
try {
str += "\n " + getFpgaConfigurationStr();
}
412,17 → 1121,22
}
 
// ******* capabilityInfo ******************************************************
/**
* Creates a String with capability information.
* @param pf A separator between the single capabilities, e.g. ", "
* @return a string of the supported capabilities.
*/
public String capabilityInfo ( String pf ) {
String str = "";
for ( int i=0; i<6; i++ )
for (int j=0; j<8; j++ )
if ( dev.interfaceCapabilities(i,j) ) {
if ( dev().interfaceCapabilities(i,j) ) {
if ( ! str.equals("") )
str+="\n";
str+=pf;
if (i*8+j < capabilityStrings.length)
str+=pf+capabilityStrings[i*8+j];
str+=capabilityStrings[i*8+j];
else
str+=pf+i+"."+j;
str+=i+"."+j;
}
return str;
}
/trunk/java/ztex/ZtexIhxFile1.java
24,12 → 24,19
import java.io.*;
import java.util.*;
 
/**
* Represents a firmware image with ZTEX descriptor 1 loaded from an ihx (Intel Hex format) file. <br>
* The ZTEX descriptor is usually located at the position 0x6x of the firmware image. <br>
* A description of the ZTEX descriptor 1 can be found in {@link ZtexDevice1}.
* @see ZtexDevice1
* @see Ztex1
*/
public class ZtexIhxFile1 extends IhxFile {
private static final int defaultZtexDescriptorOffs = 0x6c;
 
private int ztexDescriptorOffs = defaultZtexDescriptorOffs;
 
private byte productId[] = { 0,0,0,0 }; // product ID from the ZTEX descpriptor, not the USB product ID
private byte productId[] = { 0,0,0,0 }; // product ID from the ZTEX descriptor, not the USB product ID
private byte fwVersion = 0;
private byte interfaceVersion = 0;
private byte interfaceCapabilities[] = { 0,0,0,0, 0,0 };
37,6 → 44,15
private char snString[] = new char[10];
 
// ******* ZtexIhxFile1 ********************************************************
/**
* Constructs an instance from a given file name and descriptor position.<br>
* This method can also read system resources, e.g. files from the current jar archive.
* @param fileName The file name.
* @param pZtexDescriptorOffs The position of the descriptor in bytes. The default position is 0x6c.
* @throws IOException If an read error occurred.
* @throws IhxFileDamagedException If the ihx file is damaged.
* @throws IncompatibleFirmwareException If the firmware image contains no valid ZTEX descriptor 1 at the specified position.
*/
public ZtexIhxFile1( String fileName, int pZtexDescriptorOffs ) throws IOException, IhxFileDamagedException, IncompatibleFirmwareException {
super( fileName );
 
80,58 → 96,111
}
}
 
// ensure word bounded upload data
// ensure word aligned upload data
for ( int i=0; i+1<ihxData.length; i+=2 )
if ( ihxData[i]<0 && ihxData[i+1]>=0 )
ihxData[i] = 0;
}
 
/**
* Constructs an instance from a given file name.
* The ZTEX descriptor 1 is expected to be at the position 0x6c of the firmware image.<br>
* This method can also read system resources, e.g. files from the current jar archive.
* @param fileName The file name.
* @throws IOException If an read error occurred.
* @throws IhxFileDamagedException If the ihx file is damaged.
* @throws IncompatibleFirmwareException If the firmware image contains no valid ZTEX descriptor 1 at the specified position.
*/
public ZtexIhxFile1( String fileName ) throws IOException, IhxFileDamagedException, IncompatibleFirmwareException {
this( fileName, defaultZtexDescriptorOffs );
}
 
// ******* productId ***********************************************************
/**
* Returns the product ID (all 4 bytes).
* @return PRODUCT_ID, see {@link ZtexDevice1}.
*/
public final byte[] productId() {
return productId;
}
 
/**
* Returns byte i of the product ID.
* @return PRODUCT_ID[i], see {@link ZtexDevice1}.
* @param i index
*/
public int productId( int i ) {
return productId[i] & 255;
}
 
// ******* fwVersion ***********************************************************
/**
* Returns the firmware version.
* @return FW_VERSION, see {@link ZtexDevice1}.
*/
public final int fwVersion() {
return fwVersion & 255;
}
 
// ******* interfaceVersion *****************************************************
/**
* Returns the interface version.
* @return INTERFACE_VERSION, see {@link ZtexDevice1}.
*/
public final int interfaceVersion() {
return interfaceVersion & 255;
}
 
// ******* interfaceCapabilities ************************************************
/**
* Returns the interface capabilities (all 6 bytes).
* @return INTERFACE_CAPABILITIES, see {@link ZtexDevice1}.
*/
public final byte[] interfaceCapabilities() {
return interfaceCapabilities;
}
 
/**
* Returns byte i of the interface capabilities.
* @return INTERFACE_CAPABILITIES[i], see {@link ZtexDevice1}.
* @param i index
*/
public final int interfaceCapabilities( int i ) {
return interfaceCapabilities[i] & 255;
}
 
// ******* moduleReserved ******************************************************
/**
* Returns the application specific information (all 12 bytes).
* @return MODULE_RESERVED, see {@link ZtexDevice1}.
*/
public final byte[] moduleReserved() {
return moduleReserved;
}
 
/**
* Returns byte i of the application specific information.
* @return MODULE_RESERVED[i], see {@link ZtexDevice1}.
* @param i index
*/
public final int moduleReserved( int i ) {
return moduleReserved[i] & 255;
}
 
// ******* snString ************************************************************
/**
* Returns the serial number string.
* @return SN_STRING, see {@link ZtexDevice1}.
*/
public final String snString() {
return new String( snString );
}
 
// ******* setSnString **********************************************************
/**
* Modifies the serial number string.
* @param s The new serial number string which must not be longer then 10 characters.
*/
public final void setSnString( String s ) throws IncompatibleFirmwareException {
if ( s.length()>10 )
throw new IncompatibleFirmwareException( "Serial number too long (max. 10 characters)" );
146,6 → 215,10
}
 
// ******* toString ************************************************************
/**
* Returns a string representation if the instance.
* @return a string representation if the instance.
*/
public String toString () {
return "productID=" + ZtexDevice1.byteArrayString(productId) + " fwVer="+(fwVersion & 255) + " ifVer="+(interfaceVersion & 255)+ " snString=\"" + snString() + "\"";
}
/trunk/java/ztex/JInputStream.java
16,9 → 16,6
along with this program; if not, see http://www.gnu.org/licenses/.
!*/
 
/*
creates an input stream from a file as system resource (i.e. from the current .jar file)
*/
package ztex;
 
import java.io.*;
25,8 → 22,15
import java.util.*;
import java.net.*;
 
/** * Creates an input stream from a regular file or a system resource file (i.e. a file from the current jar file). */
public class JInputStream {
 
/**
* Constructs an instance from a giving file name.
* @param fileName The file name.
* @throws SecurityException Signals a security violation.
* @throws FileNotFoundException Thrown if the file was not found.
*/
static public InputStream getInputStream ( String fileName ) throws SecurityException, FileNotFoundException {
InputStream is = null;
try {
/trunk/java/ztex/IhxFile.java
24,8 → 24,15
import java.io.*;
import java.util.*;
import java.net.*;
/**
* A class representing a firmware image loaded from an ihx (Intel Hex format) file.
*/
public class IhxFile {
 
public class IhxFile {
/**
* This array stores the firmware image.
* Values &lt;0 and &gt;255 mean that the data is undefined.
*/
public short ihxData[] = new short[65536];
// ******* readHexDigit ********************************************************
48,6 → 55,13
}
// ******* IhxFile *************************************************************
/**
* Constructs an instance from a given file name.
* This method can also read system resources, e.g. files from the current jar archive.
* @param fileName The file name.
* @throws IOException If an read error occurred.
* @throws IhxFileDamagedException If the ihx file is damaged.
*/
public IhxFile ( String fileName ) throws IOException, IhxFileDamagedException {
InputStream in = JInputStream.getInputStream( fileName );
int b, len, cs, addr;
118,7 → 132,11
}
 
// ******* dataInfo ************************************************************
public void dataInfo( PrintStream out ) {
/**
* Print out some information about the memory usage.
* @param out Where the data is printed out.
*/
public void dataInfo( PrintStream out ) {
int addr=-1;
for ( int i=0; i<=65536; i++ ) { // data
if ( (i==65536 || ihxData[i]<0) && addr>=0 ) {
/trunk/java/ztex/EzUsb.java
16,9 → 16,6
along with this program; if not, see http://www.gnu.org/licenses/.
!*/
 
/*
Upload firmware to Cypress EZ-USB device
*/
package ztex;
 
import java.io.*;
26,8 → 23,17
 
import ch.ntb.usb.*;
 
/**
* Provides methods for uploading firmware to Cypress EZ-USB devices.
*/
public class EzUsb {
// ******* reset **************************************************************
/**
* Controls the reset state of a Cypress EZ-USB device.
* @param handle The handle of the device.
* @param r The reset state (true means reset).
* @throws FirmwareUploadException if an error occurred while attempting to control the reset state.
*/
public static void reset ( int handle, boolean r ) throws FirmwareUploadException {
byte buffer[] = { (byte) (r ? 1 : 0) };
int k = LibusbJava.usb_control_msg(handle, 0x40, 0xA0, 0xE600, 0, buffer, 1, 1000); // upload j bytes
36,7 → 42,7
else if ( k!=1 )
throw new FirmwareUploadException( "Unable to set reset="+buffer[0] );
try {
Thread.sleep( 50 );
Thread.sleep( r ? 50 : 400 ); // give the firmware some time for initialization
}
catch ( InterruptedException e ) {
}
43,14 → 49,20
}
// ******* uploadFirmware ******************************************************
// returns upload time in ms
/**
* Uploads the Firmware to a Cypress EZ-USB device.
* @param handle The handle of the device.
* @param ihxFile The firmware image.
* @return The upload time in ms.
* @throws FirmwareUploadException if an error occurred while attempting to upload the firmware.
*/
public static long uploadFirmware (int handle, IhxFile ihxFile ) throws FirmwareUploadException {
final int transactionBytes = 256;
byte[] buffer = new byte[transactionBytes];
long t0 = new Date().getTime();
 
reset( handle, true ); // reset = 1
long t0 = new Date().getTime();
int j = 0;
for ( int i=0; i<=ihxFile.ihxData.length; i++ ) {
if ( i >= ihxFile.ihxData.length || ihxFile.ihxData[i] < 0 || j >=transactionBytes ) {
74,6 → 86,7
j+=1;
}
}
long t1 = new Date().getTime();
 
try {
EzUsb.reset(handle,false); // error (may caused re-numeration) can be ignored
80,7 → 93,7
}
catch ( FirmwareUploadException e ) {
}
return new Date().getTime() - t0;
return t1 - t0;
}
}
 
/trunk/java/ztex/ZtexScanBus1.java
26,10 → 26,35
 
import ch.ntb.usb.*;
 
/**
* A class used for finding the EZ-USB devices on the USB.
* The devices found are stored as a list of {@link ZtexDevice1} instances.
* @see ZtexDevice1
*/
 
public class ZtexScanBus1 {
private Vector<ZtexDevice1> devices = new Vector<ZtexDevice1>();
 
// ******* ZtexScanBus1 ********************************************************
/**
* Scans the USB for suitable devices and constructs a list of them.
* Four kinds of search filters can be applied
* <ol>
* <li> usbVendorId and usbProductId can be used to search for devices with a given vendor and product ID. These devices must provide a ZTEX descriptor 1.</li>
* <li> If a certain interface version is required, it can be specified using interfaceVersion. </li>
* <li> Incompatible devices can be excluded by the specification of the ZTEX product ID's, see {@link ZtexDevice1#compatible(int,int,int,int)}. </li>
* <li> If scanCypress is true, all devices (even unconfigured ones) with Cypress EZ-USB vendor and product ID's are considered. </li>
* </ol>
* @param usbVendorId USB vendor ID of the device to be searched for
* @param usbProductId USB product ID of the device to be searched for
* @param scanCypress Include devices with Cypress EZ-USB vendor and product ID's (even unconfigured ones)
* @param quiet if true, don't print any warnings
* @param interfaceVersion The required interface version (&lt;0 if no interface version is required)
* @param productId0 Byte 0 of a given ZTEX product ID (&le;0 if not to be considered)
* @param productId1 Byte 1 of a given ZTEX product ID (&le;0 if not to be considered)
* @param productId2 Byte 2 of a given ZTEX product ID (&le;0 if not to be considered)
* @param productId3 Byte 3 of a given ZTEX product ID (&le;0 if not to be considered)
*/
public ZtexScanBus1 (int usbVendorId, int usbProductId, boolean scanCypress, boolean quiet, int interfaceVersion, int productId0, int productId1, int productId2, int productId3 ) {
LibusbJava.usb_find_busses();
LibusbJava.usb_find_devices();
47,13 → 72,13
devices.add( zdev );
}
}
catch ( ZtexDescriptorException e ) {
catch ( InvalidFirmwareException e ) {
if ( scanCypress && usbVendorId == ZtexDevice1.cypressVendorId && usbProductId == ZtexDevice1.cypressProductId ) {
try {
ZtexDevice1 zdev = new ZtexDevice1( dev, -1, -1 );
if ( zdev.isCypress() ) devices.add( zdev );
}
catch ( ZtexDescriptorException e2 ) {
catch ( InvalidFirmwareException e2 ) {
if ( ! quiet )
System.err.println( e2.getLocalizedMessage() ); // should never occur
}
74,15 → 99,45
}
}
 
/**
* Scans the USB for suitable devices and constructs a list of them.
* Three kinds of search filters can be applied
* <ol>
* <li> usbVendorId and usbProductId can be used to search for devices with a given vendor and product ID. These devices must provide a ZTEX descriptor 1.</li>
* <li> If a certain interface version is required, it can be specified using interfaceVersion. </li>
* <li> If scanCypress is true, all devices (even unconfigured ones) with Cypress EZ-USB vendor and product ID's are considered. </li>
* </ol>
* @param usbVendorId USB vendor ID of the device to be searched for
* @param usbProductId USB product ID of the device to be searched for
* @param scanCypress Include devices with Cypress EZ-USB vendor and product ID's (even unconfigured ones)
* @param quiet if true, don't print any warnings
* @param interfaceVersion The required interface version (<0 if no interface version is required)
*/
public ZtexScanBus1 (int usbVendorId, int usbProductId, boolean scanCypress, boolean quiet, int interfaceVersion ) {
this(usbVendorId, usbProductId, scanCypress, quiet, interfaceVersion, -1,-1,-1,-1 );
}
 
/**
* Scans the USB for suitable devices and constructs a list of them.
* Two kinds of search filters can be applied
* <ol>
* <li> usbVendorId and usbProductId can be used to search for devices with a given vendor and product ID. These devices must provide a ZTEX descriptor 1.</li>
* <li> If scanCypress is true, all devices (even unconfigured ones) with Cypress EZ-USB vendor and product ID's are considered. </li>
* </ol>
* @param usbVendorId USB vendor ID of the device to be searched for
* @param usbProductId USB product ID of the device to be searched for
* @param scanCypress Include devices with Cypress EZ-USB vendor and product ID's (even unconfigured ones)
* @param quiet if true, don't print any warnings
*/
public ZtexScanBus1 (int usbVendorId, int usbProductId, boolean scanCypress, boolean quiet ) {
this(usbVendorId, usbProductId, scanCypress, quiet, -1, -1,-1,-1,-1 );
}
 
// ******* printBus ************************************************************
/**
* Prints out a list of devices found.
* @param out Where the output is to be printed to.
*/
public void printBus( PrintStream out ) {
for (int i=0; i<devices.size(); i++ ) {
out.println( i + ": " + devices.elementAt(i).toString() );
90,11 → 145,21
}
// ******* numberOfDevices *****************************************************
/**
* Returns the number of devices found.
* @return the number of devices found.
*/
public final int numberOfDevices () {
return devices.size();
}
 
// ******* device **************************************************************
/**
* Returns a device from the list of devices.
* @param i The device index.
* @return a device from the list of devices.
* @throws IndexOutOfBoundsException if i&lt;0 or i&ge;{@link #numberOfDevices()}
*/
public final ZtexDevice1 device (int i) throws IndexOutOfBoundsException {
if ( i<0 || i>=devices.size() )
throw new IndexOutOfBoundsException( "Device number out of range. Valid numbers are 0.." + (devices.size()-1) );
/trunk/java/ztex/ZtexDevice1.java
26,8 → 26,97
 
import ch.ntb.usb.*;
 
/**
* A class representing an EZ-USB device that supports the ZTEX descriptor 1 or an unconfigured EZ-USB device.<br>
* Instances of this class are usually created by {@link ZtexScanBus1}.
* The following table describes the ZTEX descriptor 1.
* <table bgcolor="#404040" cellspacing=1 cellpadding=4>
* <tr>
* <td bgcolor="#d0d0d0" valign="top"><b>Field name</b></td>
* <td bgcolor="#d0d0d0" valign="top"><b>Offset</b></td>
* <td bgcolor="#d0d0d0" valign="top"><b>Size</b></td>
* <td bgcolor="#d0d0d0" valign="top"><b>Description</b></td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">ZTEX_DESCRIPTOR_SIZE</td>
* <td bgcolor="#ffffff" valign="top">0</td>
* <td bgcolor="#ffffff" valign="top">1</td>
* <td bgcolor="#ffffff" valign="top">Size of the descriptor in bytes; must be 40 for descriptor version 1</td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">ZTEX_DESCRIPTOR_VERSION</td>
* <td bgcolor="#ffffff" valign="top">1</td>
* <td bgcolor="#ffffff" valign="top">1</td>
* <td bgcolor="#ffffff" valign="top">Descriptor version; 1 for version 1</td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">ZTEXID</td>
* <td bgcolor="#ffffff" valign="top">2</td>
* <td bgcolor="#ffffff" valign="top">4</td>
* <td bgcolor="#ffffff" valign="top">ID; must be "ZTEX"</td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">PRODUCT_ID</td>
* <td bgcolor="#ffffff" valign="top">6</td>
* <td bgcolor="#ffffff" valign="top">4</td>
* <td bgcolor="#ffffff" valign="top">Four numbers (0..255) representing the product ID and firmware compatibility information.<br>
* A firmware can overwrite an installed one<br>
* <pre>if ( INSTALLED.PRODUCTID[0]==0 || PRODUCTID[0]==0 || INSTALLED.PRODUCTID[0]==PRODUCTID[0] ) &&
( INSTALLED.PRODUCTID[1]==0 || PRODUCTID[1]==0 || INSTALLED.PRODUCTID[1]==PRODUCTID[1] ) &&
( INSTALLED.PRODUCTID[2]==0 || PRODUCTID[2]==0 || INSTALLED.PRODUCTID[2]==PRODUCTID[2] ) &&
( INSTALLED.PRODUCTID[3]==0 || PRODUCTID[3]==0 || INSTALLED.PRODUCTID[3]==PRODUCTID[3] ) </pre>
* Here is a list of the preserved product ID's:
* <table><tr><td>&nbsp</td><td>
* <table>
* <tr><td>0.0.0.0</td> <td>default Product ID (no product specified)</td></tr>
* <tr><td>1.*.*.*</td> <td>may be used for experimental purposes</td></tr>
* <tr><td>10.*.*.*</td> <td>used for ZTEX products</td></tr>
* <tr><td>10.11.*.*</td> <td><a href="http://www.ztex.de/usb-fpga-1/usb-fpga-1.2.e.html">ZTEX USB-FPGA-Module 1.2</a></td></tr>
* <tr><td>10.20.*.*</td> <td><a href="http://www.ztex.de/usb-1/usb-1.0.e.html">ZTEX USB-Module 1.0</a></td></tr>
* </table></td></tr></table>
* Please contact me (<a href="http://www.ztex.de/contact.e.html">http://www.ztex.de/contact.e.html</a>) if you want to register or reserve a Product ID (range).
* </td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">FW_VERSION</td>
* <td bgcolor="#ffffff" valign="top">10</td>
* <td bgcolor="#ffffff" valign="top">1</td>
* <td bgcolor="#ffffff" valign="top">May be used to specify the firmware version.</td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">INTERFACE_VERSION</td>
* <td bgcolor="#ffffff" valign="top">11</td>
* <td bgcolor="#ffffff" valign="top">1</td>
* <td bgcolor="#ffffff" valign="top">The interface version. This number specifies the protocol that is used for interfacing the host software. A description of interface version 1 can be found in {@link Ztex1v1} </td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">INTERFACE_CAPABILITIES</td>
* <td bgcolor="#ffffff" valign="top">12</td>
* <td bgcolor="#ffffff" valign="top">6</td>
* <td bgcolor="#ffffff" valign="top">6 bytes, each bit represents a capability. If set, the capability is supported. A description of the capabilities of interface version 1 can be found in {@link Ztex1v1} </td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">MODULE_RESERVED</td>
* <td bgcolor="#ffffff" valign="top">18</td>
* <td bgcolor="#ffffff" valign="top">12</td>
* <td bgcolor="#ffffff" valign="top">12 bytes for application specific use, i.e. they depend from the PRODUCT_ID </td>
* </tr>
* <tr>
* <td bgcolor="#ffffff" valign="top">SN_STRING</td>
* <td bgcolor="#ffffff" valign="top">30</td>
* <td bgcolor="#ffffff" valign="top">10</td>
* <td bgcolor="#ffffff" valign="top">A serial number string of 10 characters. The default SN is "0000000000"</td> </td>
* </tr>
* </table>
* @see Ztex1
* @see Ztex1v1
* @see ZtexScanBus1
*/
 
public class ZtexDevice1 {
/** * The Cypress vendor ID 0x4b4. */
public static final int cypressVendorId = 0x4b4;
/** * The EZ-USB product ID 0x8613. */
public static final int cypressProductId = 0x8613;
 
private Usb_Device dev = null;
38,7 → 127,7
private String manufacturerString = null;
private String productString = null;
private String snString = null;
private byte productId[] = { 0,0,0,0 }; // product ID from the ZTEX descpriptor, not the USB product ID
private byte productId[] = { 0,0,0,0 }; // product ID from the ZTEX descriptor, not the USB product ID
private byte fwVersion = 0;
private byte interfaceVersion = 0;
private byte interfaceCapabilities[] = { 0,0,0,0, 0,0 };
45,6 → 134,11
private byte moduleReserved[] = { 0,0,0,0, 0,0,0,0, 0,0,0,0 };
 
// ******* byteArrayString *****************************************************
/**
* Produces a nice string representation of an array of bytes.
* @param buf A byte array.
* @return a nice string
*/
public static String byteArrayString ( byte buf[] ) {
String s = new String( "" );
for ( int i = 0; i<buf.length; i++ ) {
56,11 → 150,22
}
// ******* ZtexDevice1 *********************************************************
// Read the ZTEX descriptor if usbVendorId=pUsbVendorId and usbProductId=pUsbProductId
public ZtexDevice1 (Usb_Device p_dev, int pUsbVendorId, int pUsbProductId) throws UsbException, ZtexDescriptorException {
/**
* Constructs an instance from a given USB device.<br>
* If the given vendor and product id's match to the vendor and product id's of the given USB device,
* the ZTEX descriptor 1 is attempted to read. If this fails, an {@link InvalidFirmwareException} is thrown.
* To suppress this behavior (e.g. if the EZ-USB device is known to be unconfigured) the vendor and product id's
* can be set to -1.
* @param p_dev The USB device.
* @param pUsbVendorId The given vendor ID.
* @param pUsbProductId The given product ID.
* @throws UsbException if an USB communication error occurs.
* @throws InvalidFirmwareException if no valid ZTEX descriptor 1 is found.
*/
public ZtexDevice1 (Usb_Device p_dev, int pUsbVendorId, int pUsbProductId) throws UsbException, InvalidFirmwareException {
dev = p_dev;
 
Usb_Device_Descriptor dd = dev.getDescriptor();
Usb_Device_Descriptor dd = dev().getDescriptor();
usbVendorId = dd.getIdVendor() & 65535;
usbProductId = dd.getIdProduct() & 65535;
81,7 → 186,7
if ( usbVendorId == pUsbVendorId && usbProductId == pUsbProductId ) {
if ( snString == null ) {
LibusbJava.usb_close(handle);
throw new ZtexDescriptorException( dev, "Not a ZTEX device" ); // ZTEX devices always have a SN. See also the next comment a few lines below
throw new InvalidFirmwareException( dev, "Not a ZTEX device" ); // ZTEX devices always have a SN. See also the next comment a few lines below
}
byte[] buf = new byte[42];
88,15 → 193,15
int i = LibusbJava.usb_control_msg(handle, 0xc0, 0x22, 0, 0, buf, 40, 500); // Failing of this may cause problems under windows. Therefore we check for the SN above.
if ( i < 0 ) {
LibusbJava.usb_close(handle);
throw new ZtexDescriptorException( dev, "Error reading ZTEX descriptor: " + LibusbJava.usb_strerror() );
throw new InvalidFirmwareException( dev, "Error reading ZTEX descriptor: " + LibusbJava.usb_strerror() );
}
else if ( i != 40 ) {
LibusbJava.usb_close(handle);
throw new ZtexDescriptorException( dev, "Error reading ZTEX descriptor: Invalid size: " + i );
throw new InvalidFirmwareException( dev, "Error reading ZTEX descriptor: Invalid size: " + i );
}
if ( buf[0]!=40 || buf[1]!=1 || buf[2]!='Z' || buf[3]!='T' || buf[4]!='E' || buf[5]!='X' ) {
LibusbJava.usb_close(handle);
throw new ZtexDescriptorException( dev, "Invalid ZTEX descriptor" );
throw new InvalidFirmwareException( dev, "Invalid ZTEX descriptor" );
}
productId[0] = buf[6];
productId[1] = buf[7];
134,8 → 239,12
}
 
// ******* toString ************************************************************
/**
* Returns a string representation if the device with a lot of useful information.
* @return a string representation if the device with a lot of useful information.
*/
public String toString () {
return "bus=" + dev.getBus().getDirname() + " device=" + dev.getFilename() +
return "bus=" + dev().getBus().getDirname() + " device=" + dev().getFilename() +
"\n " + ( isCypress ? "Cypress" : "" ) +
( manufacturerString == null ? "" : (" Manufacturer=\"" + manufacturerString + "\"") ) +
( productString == null ? "" : (" Product=\"" + productString + "\"") ) +
144,6 → 253,19
}
 
// ******* compatible **********************************************************
/**
* Checks whether the given product ID is compatible to the device.<br>
* The given product ID is compatible
* <pre>if ( this.productId(0)==0 || productId0<=0 || this.productId(0)==productId0 ) &&
( this.productId(0)==0 || productId1<=0 || this.productId(1)==productId1 ) &&
( this.productId(2)==0 || productId2<=0 || this.productId(2)==productId2 ) &&
( this.productId(3)==0 || productId3<=0 || this.productId(3)==productId3 ) </pre>
* @param productId0 Byte 0 of the given product ID
* @param productId1 Byte 1 of the given product ID
* @param productId2 Byte 2 of the given product ID
* @param productId3 Byte 3 of the given product ID
* @return true if the given product ID is compatible
*/
public final boolean compatible( int productId0, int productId1, int productId2, int productId3 ) {
return ( productId[0]==0 || productId0<=0 || (productId[0] & 255) == productId0 ) &&
( productId[1]==0 || productId1<=0 || (productId[1] & 255) == productId1 ) &&
152,73 → 274,137
}
// ******* dev *****************************************************************
/**
* Returns the USB device.
* @return the USB device.
*/
public final Usb_Device dev() {
return dev;
}
 
// ******* isCypress ***********************************************************
/**
* Returns true if the device has Cypress EZ-USB vendor and product ID's (0x4b4 and 0x8613).
* @return true if the device has Cypress EZ-USB vendor and product ID's (0x4b4 and 0x8613).
*/
public final boolean isCypress() {
return isCypress;
}
// ******* valid ***************************************************************
/**
* Returns true if ZTEX descriptor 1 is available.
* @return true if ZTEX descriptor 1 is available.
*/
public final boolean valid() {
return valid;
}
 
// ******* usbVendorId *********************************************************
/**
* Returns the USB vendor ID of the device.
* @return the USB vendor ID of the device.
*/
public final int usbVendorId() {
return usbVendorId;
}
 
// ******* usbProductId *********************************************************
/**
* Returns the USB product ID of the device.
* @return the USB product ID of the device.
*/
public final int usbProductId() {
return usbProductId;
}
 
// ******* manufacturerString **************************************************
/**
* Returns the manufacturer string of the device.
* @return the manufacturer string of the device.
*/
public final String manufacturerString() {
return manufacturerString;
}
 
// ******* productString *******************************************************
/**
* Returns the product string of the device.
* @return the product string of the device.
*/
public final String productString() {
return productString;
}
 
// ******* snString ************************************************************
/**
* Returns the serial number string of the device.
* @return the serial number string of the device.
*/
public final String snString() {
return snString;
}
 
// ******* productId ***********************************************************
/**
* Returns the product ID (all 4 bytes).
* @return PRODUCT_ID, see above.
*/
public final byte[] productId() {
return productId;
}
 
/**
* Returns byte i of the product ID.
* @return PRODUCT_ID[i], see above.
* @param i index
*/
public int productId( int i ) {
return productId[i] & 255;
}
 
// ******* fwVersion ***********************************************************
/**
* Returns the firmware version.
* @return FW_VERSION, see above.
*/
public final int fwVersion() {
return fwVersion & 255;
}
 
// ******* interfaceVersion *****************************************************
/**
* Returns the interface version.
* @return INTERFACE_VERSION, see above.
*/
public final int interfaceVersion() {
return interfaceVersion & 255;
}
 
// ******* interfaceCapabilities ************************************************
/**
* Returns the interface capabilities (all 6 bytes).
* @return INTERFACE_CAPABILITIES, see above.
*/
public final byte[] interfaceCapabilities() {
return interfaceCapabilities;
}
 
/**
* Returns byte i of the interface capabilities.
* @return INTERFACE_CAPABILITIES[i], see above.
* @param i index
*/
public final int interfaceCapabilities( int i ) {
return interfaceCapabilities[i] & 255;
}
 
/**
* Returns byte i, bit j of the interface capabilities.
* @return INTERFACE_CAPABILITIES[i].j, see above.
* @param i byte index
* @param j bit index
*/
public final boolean interfaceCapabilities( int i, int j ) {
return (i>=0) && (i<=5) && (j>=0) && (j<8) &&
(((interfaceCapabilities[i] & 255) & (1 << j)) != 0);
225,10 → 411,19
}
 
// ******* moduleReserved ******************************************************
/**
* Returns the application specific information (all 12 bytes).
* @return MODULE_RESERVED, see above.
*/
public final byte[] moduleReserved() {
return moduleReserved;
}
 
/**
* Returns byte i of the application specific information.
* @return MODULE_RESERVED[i], see above.
* @param i index
*/
public final int moduleReserved( int i ) {
return moduleReserved[i] & 255;
}
/trunk/include/ztex-descriptors.h
48,6 → 48,8
0.0.0.0 // default Product ID (no product specified)
1.*.*.* // may be used for experimental purposes
10.*.*.* // used for ZTEX products
10.11.*.* // ZTEX USB-FPGA-Module 1.2
10.20.*.* // ZTEX USB-Module 1.0
Please contact me (http://www.ztex.de --> Impressum/Kontakt) if you want to register/reserve a Product ID (range).
*/
63,6 → 65,7
Standard interface capabilities:
0.0 : EEPROM read/write, see ztex-eeprom.h
0.1 : FPGA configuration, see ztex-fpga.h
0.2 : Flash memeory suport, see ztex-flash1.h
*/
xdata at ZTEX_DESCRIPTOR_OFFS+12 BYTE INTERFACE_CAPABILITIES[6];
 
144,6 → 147,10
#nolf
+ 2
#endif
#ifdef[@CAPABILITY_FLASH;]
#nolf
+ 4
#endif
.db 0
.db 0
.db 0
/trunk/include/ztex.h
17,7 → 17,7
!*/
 
/*
Puts everything in the right order together.
Puts everything together.
*/
 
#ifndef[ZTEX_H]
30,13 → 30,49
 
 
/* *********************************************************************
***** EEPROM support and some I2c helper functions ******************
********************************************************************* */
#ifneq[EEPROM_DISABLED][1]
#include[ztex-eeprom.h]
#endif
 
/* *********************************************************************
***** Flash memory support ******************************************
********************************************************************* */
#ifeq[FLASH_ENABLED][1]
 
#ifeq[PRODUCT_IS][UFM-1_1]
#define[MMC_PORT][E]
#define[MMC_BIT_CS][7]
#define[MMC_BIT_DI][6]
#define[MMC_BIT_DO][4]
#define[MMC_BIT_CLK][5]
#include[ztex-flash1.h]
 
#elifeq[PRODUCT_IS][UFM-1_2]
#define[MMC_PORT][E]
#define[MMC_BIT_CS][7]
#define[MMC_BIT_DI][6]
#define[MMC_BIT_DO][4]
#define[MMC_BIT_CLK][5]
#include[ztex-flash1.h]
 
#elifeq[PRODUCT_IS][UM-1_0]
#define[MMC_PORT][C]
#define[MMC_BIT_CS][7]
#define[MMC_BIT_DI][6]
#define[MMC_BIT_DO][4]
#define[MMC_BIT_CLK][5]
#include[ztex-flash1.h]
 
#elifeq[PRODUCT_IS][UM-1_10]
#define[MMC_PORT][C]
#define[MMC_BIT_CS][4]
#define[MMC_BIT_DI][5]
#define[MMC_BIT_DO][7]
#define[MMC_BIT_CLK][6]
#include[ztex-flash1.h]
 
#else
#warning[FLASH option is not supported by this product]
#define[FLASH_ENABLED][0]
43,15 → 79,7
#endif
#endif
 
 
/* *********************************************************************
***** EEPROM support and some I2c helper functions ******************
********************************************************************* */
#ifneq[EEPROM_DISABLED][1]
#include[ztex-eeprom.h]
#endif
 
/* *********************************************************************
***** FPGA configuration support ************************************
********************************************************************* */
#ifeq[PRODUCT_IS][UFM-1_0]
113,14 → 141,24
 
void init_USB ()
{
 
USBCS |= 0x08;
CPUCS = bmBIT4 | bmBIT1;
CKCON &= ~7;
#ifeq[PRODUCT_IS][UFM-1_0]
IOA1 = 1;
OEA |= bmBIT1;
#elifeq[PRODUCT_IS][UFM-1_1]
IOA1 = 1;
OEA |= bmBIT1;
#elifeq[PRODUCT_IS][UFM-1_2]
IOA1 = 1;
OEA |= bmBIT1;
#endif
EA = 0;
EUSB = 0;
 
ENABLE_AVUSB;
150,12 → 188,6
EUSB = 1;
EA = 1;
 
USBCS |= 0x08;
USBCS |= bmBIT7 | bmBIT1;
wait(500);
USBCS &= ~0x08;
wait(500);
EP1XCFG(1IN);
EP1XCFG(1OUT);
EPXCFG(2);
162,6 → 194,18
EPXCFG(4);
EPXCFG(6);
EPXCFG(8);
#ifeq[FLASH_ENABLED][1]
flash_init();
#endif
#ifeq[FLASH_BITSTREAM_ENABLED][1]
fpga_configure_from_flash_init();
#endif
 
USBCS |= bmBIT7 | bmBIT1;
wait(250);
USBCS &= ~0x08;
}
 
 
#endif /* ZTEX_H */
/trunk/include/ztex-conf.h
64,6 → 64,7
#define[POST_FPGA_CONFIG][]
 
 
 
/*
Add a vedor request for endpoint 0,
 
109,7 → 110,16
break;
]]
 
/*
This macro generates a EP0 stall and aborts the current loop. Stalls are usually used to indicate errors.
*/
#define[EP0_STALL;][{
EP0CS |= 0x01; // set stall
ep0_payload_remaining = 0;
break;
}]
 
 
/*
Endoint 2,4,5,8 configuration:
 
310,4 → 320,10
*/
#define[ENABLE_FLASH;][#define[FLASH_ENABLED][1]]
 
/*
This macro enables the FPGA configuration using a bitstream from the Flash memory
Usage: ENABLE_FLASH_BITSTREAM;
*/
#define[ENABLE_FLASH_BITSTREAM;][#define[FLASH_BITSTREAM_ENABLED][1]]
 
#endif
/trunk/include/ztex-eeprom.h
30,10 → 30,10
***** global variables **********************************************
********************************************************************* */
xdata WORD eeprom_addr;
xdata WORD eeprom_length;
xdata WORD eeprom_write_bytes;
xdata BYTE eeprom_write_checksum;
 
 
/* *********************************************************************
***** i2c_waitWrite *************************************************
********************************************************************* */
202,16 → 202,14
********************************************************************* */
BYTE eeprom_read_ep0 () {
BYTE i, b;
b = ( eeprom_length > 64 ) ? 64 : eeprom_length;
b = ep0_payload_transfer;
i = eeprom_read(EP0BUF, eeprom_addr, b);
eeprom_addr += b;
eeprom_length -= b;
return i;
}
 
ADD_EP0_VENDOR_REQUEST((0x38,, // read from EEPROM
eeprom_addr = (SETUPDAT[3] << 8) | SETUPDAT[2]; // Address
eeprom_length = (SETUPDAT[7] << 8) | SETUPDAT[6]; // size
EP0BCH = 0;
EP0BCL = eeprom_read_ep0();
,,
232,7 → 230,6
eeprom_write_checksum = 0;
eeprom_write_bytes = 0;
eeprom_addr = ( SETUPDAT[3] << 8) | SETUPDAT[2]; // Address
EP0BCL = 1;
,,
eeprom_write_ep0(EP0BCL);
));;
/trunk/include/ztex-fpga.h
25,14 → 25,14
 
#define[@CAPABILITY_FPGA;]
 
xdata BYTE fpga_checksum = 0; // checksum
xdata DWORD fpga_bytes = 0; // transfered bytes
xdata BYTE fpga_init_b = 0; // init_b state (should be 222 after configuration)
xdata BYTE fpga_checksum; // checksum
xdata DWORD fpga_bytes; // transfered bytes
xdata BYTE fpga_init_b; // init_b state (should be 222 after configuration)
 
/* *********************************************************************
***** resetFPGA *****************************************************
***** reset_fpga ****************************************************
********************************************************************* */
static void resetFPGA () { // reset FPGA
static void reset_fpga () { // reset FPGA
unsigned short k;
IFCONFIG = bmBIT7;
SYNCDELAY;
65,19 → 65,26
}
 
/* *********************************************************************
***** initFPGAConfiguration *****************************************
***** init_fpga_configuration ***************************************
********************************************************************* */
static void initFPGAConfiguration () {
static void init_fpga_configuration () {
{
PRE_FPGA_RESET
}
resetFPGA(); // reset FPGA
reset_fpga(); // reset FPGA
}
 
/* *********************************************************************
***** finishFPGAConfiguration ***************************************
***** post_fpga_confog **********************************************
********************************************************************* */
static void finishFPGAConfiguration () {
static void post_fpga_config () {
POST_FPGA_CONFIG
}
 
/* *********************************************************************
***** finish_fpga_configuration *************************************
********************************************************************* */
static void finish_fpga_configuration () {
fpga_init_b += IOC0 ? 20 : 10;
IOD0 = 0; IOB = 0; IOD0 = 1;
IOD0 = 0; IOD0 = 1;
91,12 → 98,12
IOD0 = 0; IOD0 = 1;
IOD0 = 0; IOD0 = 1;
OEB = 0;
// OEC = 0;
OEC = 0;
OED = 0;
OEA = 0;
fpga_init_b += IOC0 ? 2 : 1;
if ( IOA1 ) {
POST_FPGA_CONFIG
post_fpga_config();
}
 
IOA1 = 1;
117,7 → 124,7
}
else {
EP0BUF[0] = 1; // FPGA unconfigured
resetFPGA(); // prepare FPGA for configuration
reset_fpga(); // prepare FPGA for configuration
}
EP0BCH = 0;
128,24 → 135,22
/* *********************************************************************
***** EP0 vendor command 0x31 ***************************************
********************************************************************* */
ADD_EP0_VENDOR_COMMAND((0x31,,initFPGAConfiguration();,,));; // reset FPGA
ADD_EP0_VENDOR_COMMAND((0x31,,init_fpga_configuration();,,));; // reset FPGA
 
 
/* *********************************************************************
***** EP0 vendor command 0x32 ***************************************
********************************************************************* */
ADD_EP0_VENDOR_COMMAND((0x32,, // send FPGA configuration data
EP0BCL=1;
,,
fpga_bytes += EP0BCL;
void fpga_send_ep0() {
fpga_bytes += ep0_payload_transfer;
_asm
mov _AUTOPTRL1,#(_EP0BUF)
mov _AUTOPTRH1,#(_EP0BUF >> 8)
mov _AUTOPTRSETUP,#0x07
mov dptr,#_EP0BCL
movx a,@dptr
jz 010000$
mov r2,a
mov _AUTOPTRL1,#(_EP0BUF)
mov _AUTOPTRH1,#(_EP0BUF >> 8)
mov _AUTOPTRSETUP,#0x07
mov dptr,#_fpga_checksum
movx a,@dptr
mov r1,a
165,11 → 170,199
010000$:
_endasm;
 
if ( EP0BCL<64 ) {
finishFPGAConfiguration();
finish_fpga_configuration();
}
}
 
ADD_EP0_VENDOR_COMMAND((0x32,, // send FPGA configuration data
,,
fpga_send_ep0();
));;
 
 
#ifeq[FLASH_BITSTREAM_ENABLED][1]
#ifeq[FLASH_ENABLED][1]
 
code BYTE fpga_flash_boot_id[] = {'Z','T','E', 'X', 'B', 'S', '\1', '\1'};
 
/* *********************************************************************
***** fpga_configure_from_flash *************************************
********************************************************************* */
/*
Configure the FPGA using a bitstream from flash.
If force == 0 a already configured FPGA is not re-configured.
Return values:
0 : configuration successfull
1 : fpga already configured
2 : Flash error
3 : No bitstream found
4 : Configuration error
 
The format of the boot sector (secor 0 of the flash memeory) is
0..7 ID, must be "ZTEXBS",1,1
8..9 Number of used sectors, or 0 is disabled
10..11 Number of bytes in the last sector, i.e. th total size of bitstream is ((bs[8] | (bs[9]<<8) - 1) * flash_sector_size + ((bs[10] | (bs[11]<<8)
the rest of the sector is reserved for future use and preserved by the host software
*/
void fpga_send_bitstream_from_flash (WORD size) {
size; // this avoids stupid warnings
_asm
mov r5,dpl // = size
mov r6,dph
 
// fpga_bytes+=size
mov dptr,#_fpga_bytes
movx a,@dptr
mov r1,a
inc dptr
movx a,@dptr
mov r2,a
inc dptr
movx a,@dptr
mov r3,a
inc dptr
movx a,@dptr
mov r4,a
 
mov dptr,#_fpga_bytes
mov a,r5
add a,r1
movx @dptr,a
mov a,r6
addc a,r2
inc dptr
movx @dptr,a
mov a,#0
addc a,r3
inc dptr
movx @dptr,a
mov a,#0
addc a,r4
inc dptr
movx @dptr,a
 
mov dptr,#_fpga_checksum
movx a,@dptr
mov r7,a
 
010003$:
cjne r5,#0x00,010002$
cjne r6,#0x00,010002$
mov dptr,#_fpga_checksum
mov a,r7
movx @dptr,a
ret
010002$:
clr _IOD0
lcall _flash_read_byte
mov a,dpl
mov _IOB,a
add a,r7
mov r7,a
setb _IOD0
dec r5
cjne r5,#0xff,010003$
dec r6
sjmp 010003$
_endasm;
}
 
BYTE fpga_configure_from_flash( BYTE force) {
WORD i,j,k;
if ( force == 0 ) {
OEA &= ~bmBIT1;
if ( IOA1 ) { // FPGA already configured
IOA1 = 1;
OEA |= bmBIT1;
return 1;
}
}
init_fpga_configuration(); // prepare FPGA for configuration
 
// read the boot sector
if ( flash_read_init( 0 ) ) // prepare reading sector 0
return 2;
for ( i=0; i<8 && flash_read_byte()==fpga_flash_boot_id[i]; i++ );
if ( i != 8 ) {
flash_read_finish(flash_sector_size - i); // dummy-read the rest of the sector + finish read opration
return 3;
}
i = flash_read_byte();
i |= flash_read_byte() << 8; // two c operations to ensure correct order
j = flash_read_byte();
j |= flash_read_byte() << 8; // two c operations to ensure correct order
flash_read_finish(flash_sector_size - 12); // dummy-read the rest of the sector + finish read opration
if ( i==0 )
return 3;
 
// read the bitstream
for ( k=1; k<i; k++ ) {
if ( flash_read_init( k ) ) // prepare reading sector k
return 2;
fpga_send_bitstream_from_flash( flash_sector_size );
flash_read_finish(0); // finish read opration
}
if ( flash_read_init( i ) ) // prepare reading sector i
return 2;
fpga_send_bitstream_from_flash( j );
flash_read_finish(flash_sector_size - j); // finish read opration
finish_fpga_configuration(); // finish the FPGA configuration
 
OEA &= ~bmBIT1;
if ( IOA1 ) { // FPGA configured
IOA1 = 1;
OEA |= bmBIT1;
return 0;
}
IOA1 = 1;
OEA |= bmBIT1;
return 4; // FPGA not configured correctly
}
 
/* *********************************************************************
***** fpga_first_free_sector ****************************************
********************************************************************* */
// First free sector. Returns 0 if no boot sector exeists.
// Use the macro FLASH_FIRST_FREE_SECTOR instead of this function.
#define[FLASH_FIRST_FREE_SECTOR][fpga_first_free_sector()];
WORD fpga_first_free_sector() {
BYTE i,j;
flash_read_init( 0 ); // prepare reading sector 0
for ( i=0; i<8 && flash_read_byte()==fpga_flash_boot_id[i]; i++ );
if ( i != 8 ) {
flash_read_finish(flash_sector_size - i); // dummy-read the rest of the sector + finish read opration
return 0;
}
i=flash_read_byte();
j=flash_read_byte();
flash_read_finish(flash_sector_size - 10); // dummy-read the rest of the sector + finish read opration
return (i | (j<<8))+1;
}
 
 
/* *********************************************************************
***** fpga_configure_from_flash_init ********************************
********************************************************************* */
// this function is colled by init_USB;
void fpga_configure_from_flash_init() {
BYTE b;
b = fpga_configure_from_flash(0);
if ( b == 1 ) {
post_fpga_config();
}
else if ( b == 4 ) {
fpga_configure_from_flash(0); // up to two tries
}
}
 
#else
#warning[Flash interface is not enabled but required for FPGA configuration using a bitstream from Flash meomory]
#define[FLASH_BITSTREAM_ENABLED][0]
#endif
#endif
 
#endif /*ZTEX_FPGA_H*/
/trunk/include/ztex-isr.h
23,7 → 23,8
#ifndef[ZTEX_ISR_H]
#define[ZTEX_ISR_H]
 
xdata BYTE prevSetupRequest = 0xff;
xdata BYTE ep0_prev_setup_request = 0xff;
xdata BYTE ep0_vendor_cmd_setup = 0;
 
xdata WORD ISOFRAME_COUNTER[4] = {0, 0, 0, 0}; // counters for iso frames automatically reset by sync frame request
 
86,15 → 87,35
EP0BCL = i;
}
 
/* *********************************************************************
***** ep0_payload_update ********************************************
********************************************************************* */
static void ep0_payload_update() {
ep0_payload_transfer = ( ep0_payload_remaining > 64 ) ? 64 : ep0_payload_remaining;
ep0_payload_remaining -= ep0_payload_transfer;
}
 
 
/* *********************************************************************
***** ep0_vendor_cmd_su **********************************************
********************************************************************* */
static void ep0_vendor_cmd_su() {
switch ( ep0_prev_setup_request ) {
EP0_VENDOR_COMMANDS_SU;
default:
EP0CS |= 0x01; // set stall, unknown request
}
}
 
/* *********************************************************************
***** SUDAV_ISR *****************************************************
********************************************************************* */
static void SUDAV_ISR () interrupt
{
BYTE a;
prevSetupRequest = bRequest;
ep0_prev_setup_request = bRequest;
SUDPTRCTL = 1;
// standard USB requests
switch ( bRequest ) {
case 0x00: // get status
261,6 → 282,9
// vendor request and commands
switch ( bmRequestType ) {
case 0xc0: // vendor request
ep0_payload_remaining = (SETUPDAT[7] << 8) | SETUPDAT[6];
ep0_payload_update();
switch ( bRequest ) {
case 0x22: // get ZTEX descriptor
SUDPTRCTL = 0;
275,17 → 299,24
}
break;
case 0x40: // vendor command
switch ( bRequest ) {
EP0_VENDOR_COMMANDS_SU;
default:
EP0CS |= 0x01; // set stall, unknown request
/* vendor commands may overlap if they are send without pause. To avoid
synchronization problems the setup sequences are executed in EP0OUT_ISR, i.e.
after the first packet of payload date received. */
if ( SETUPDAT[7]!=0 || SETUPDAT[6]!=0 ) {
ep0_vendor_cmd_setup = 1;
EP0BCL = 0;
EXIF &= ~bmBIT4; // clear main USB interrupt flag
USBIRQ = bmBIT0; // clear SUADV IRQ
return; // don't clear HSNAK bit. This is done after the command has completed
}
ep0_vendor_cmd_su(); // setup sequences of vendor command with no payload ara executed immediately
EP0BCL = 0;
break;
}
 
EP0CS |= 0x80;
EXIF &= ~bmBIT4;
USBIRQ = bmBIT0;
EXIF &= ~bmBIT4; // clear main USB interrupt flag
USBIRQ = bmBIT0; // clear SUADV IRQ
EP0CS |= 0x80; // clear the HSNAK bit
}
 
/* *********************************************************************
334,12 → 365,12
}
 
/* *********************************************************************
***** AP0ACK_ISR ****************************************************
***** EP0ACK_ISR ****************************************************
********************************************************************* */
void EP0ACK_ISR() interrupt
{
EXIF &= ~bmBIT4;
USBIRQ = bmBIT6;
EXIF &= ~bmBIT4; // clear USB interrupt flag
USBIRQ = bmBIT6; // clear EP0ACK IRQ
}
 
/* *********************************************************************
347,15 → 378,17
********************************************************************* */
static void EP0IN_ISR () interrupt
{
switch ( prevSetupRequest ) {
EUSB = 0; // block all USB interrupts
ep0_payload_update();
switch ( ep0_prev_setup_request ) {
EP0_VENDOR_REQUESTS_DAT;
default:
EP0BCH = 0;
EP0BCL = 0;
}
EP0CS |= 0x80;
EXIF &= ~bmBIT4;
EPIRQ = bmBIT0;
EXIF &= ~bmBIT4; // clear USB interrupt flag
EPIRQ = bmBIT0; // clear EP0IN IRQ
EUSB = 1;
}
 
/* *********************************************************************
363,14 → 396,27
********************************************************************* */
static void EP0OUT_ISR () interrupt
{
switch ( prevSetupRequest ) {
EUSB = 0; // block all USB interrupts
if ( ep0_vendor_cmd_setup ) {
ep0_vendor_cmd_setup = 0;
ep0_payload_remaining = (SETUPDAT[7] << 8) | SETUPDAT[6];
ep0_vendor_cmd_su();
}
ep0_payload_update();
switch ( ep0_prev_setup_request ) {
EP0_VENDOR_COMMANDS_DAT;
}
}
 
EP0BCL = 1;
EP0BCL = 0;
 
EXIF &= ~bmBIT4;
EPIRQ = bmBIT1;
EXIF &= ~bmBIT4; // clear main USB interrupt flag
EPIRQ = bmBIT1; // clear EP0OUT IRQ
if ( ep0_payload_remaining == 0 ) {
EP0CS |= 0x80; // clear the HSNAK bit
}
EUSB = 1;
}
 
 
/trunk/include/ztex-HSFPGAConf.h
19,8 → 19,8
#ifndef[ZTEX_HS_FPGA_CONF1_H]
#define[ZTEX_HS_FPGA_CONF1_H]
 
ADD_EP0_VENDOR_COMMAND((0x33,,initHSFPGAConfiguration();,,));;
ADD_EP0_VENDOR_COMMAND((0x34,,finishHSFPGAConfiguration();,,));;
ADD_EP0_VENDOR_COMMAND((0x33,,init_hs_fpga_configuration();,,));;
ADD_EP0_VENDOR_COMMAND((0x34,,finish_hs_fpga_configuration();,,));;
 
#ifndef[HS_FPGA_CONF_EP]
#error[Macro `HS_FPGA_CONF_EP' is not defined]
34,18 → 34,18
#endif
 
 
static void initHSFPGAConfiguration();
static void finishHSFPGAConfiguration();
static void init_hs_fpga_configuration();
static void finish_hs_fpga_configuration();
 
#elifndef[ZTEX_HS_FPGA_CONF2_H] /*ZTEX_HS_FPGA_CONF1_H*/
#define[ZTEX_HS_FPGA_CONF2_H]
 
static void finishHSFPGAConfiguration() {
static void finish_hs_fpga_configuration() {
GPIFABORT = 0xFF;
SYNCDELAY;
IFCONFIG = bmBIT7 | bmBIT6;
SYNCDELAY;
finishFPGAConfiguration();
finish_fpga_configuration();
}
 
// FIFO write wave form
58,8 → 58,8
};
 
static void initHSFPGAConfiguration() {
initFPGAConfiguration();
static void init_hs_fpga_configuration() {
init_fpga_configuration();
 
EPHS_FPGA_CONF_EPCS &= ~bmBIT0; // clear stall bit
 
/trunk/include/ztex-flash1.h
17,90 → 17,897
!*/
 
/*
supports AT45D* Flash on Port E
SPI mode of MMC / *SD Cards
*/
 
#ifndef[ZTEX_FLASH_H]
#define[ZTEX_FLASH_H]
#ifeq[MMC_PORT][E]
#define[MMC_bmMODE]
#elifeq[MMC_PORT][A]
#elifeq[MMC_PORT][B]
#elifeq[MMC_PORT][C]
#elifneq[MMC_PORT][D]
#error[Macro `MMC_PORT' is not defined correctly. Valid values are: `A', `B', `C', `D' and `E'.]
#endif
 
#define[FLASH_SI_BIT][6]
#define[FLASH_SO_BIT][4]
#define[FLASH_CLK_BIT][5]
#ifeq[PRODUCT_IS][UFM-1_1]
#define[FLASH_CS_BIT][3]
//#warning[FLASH_CS_BIT=3]
#else
#define[FLASH_CS_BIT][7]
//#warning[FLASH_CS_BIT=7]
#ifndef[ZTEX_FLASH1_H]
#define[ZTEX_FLASH1_H]
 
#define[@CAPABILITY_FLASH;]
 
#ifndef[MMC_PORT]
#error[MMC_PORT not defined]
#endif
 
xdata BYTE flash_buffer = 1; // current buffer 1
xdata BYTE flash_bufferModified = 0; // 1 indicates that the current flash page needs to be reprogrammeded
xdata WORD flash_page = 0xffff; // current flash page
xdata WORD flash_nextPage = 0xffff; // next flash page (usually flashPage+1)
xdata WORD flash_maxPage = 0; // next flash page (usually flashPage+1)
xdata WORD flash_pageSize = 528; // page size (512 or 528)
xdata BYTE flash_register[4]; // used to store register content
#ifndef[MMC_BIT_CS]
#error[MMC_BIT_CS not defined]
#endif
 
#ifndef[MMC_BIT_DI]
#error[MMC_BIT_DI not defined]
#endif
 
#ifndef[MMC_BIT_DO]
#error[MMC_BIT_DO not defined]
#endif
 
#ifndef[MMC_BIT_CLK]
#error[MMC_BIT_CLK not defined]
#endif
 
#define[MMC_bmCS][bmBITMMC_BIT_CS]
#define[MMC_bmDI][bmBITMMC_BIT_DI]
#define[MMC_bmDO][bmBITMMC_BIT_DO]
#define[MMC_bmCLK][bmBITMMC_BIT_CLK]
 
#define[MMC_IO][IOMMC_PORT]
 
#ifndef[MMC_bmMODE]
#define[MMC_CS][IOMMC_PORTMMC_BIT_CS]
#define[MMC_CLK][IOMMC_PORTMMC_BIT_CLK]
#define[MMC_DI][IOMMC_PORTMMC_BIT_DI]
#define[MMC_DO][IOMMC_PORTMMC_BIT_DO]
#endif
 
// may be redefined if the first sectors are reserved (e.g. for a FPGA bitstream)
#define[FLASH_FIRST_FREE_SECTOR][0]
 
xdata BYTE flash_enabled; // 0 1: enabled, 0:disabled
xdata WORD flash_sector_size; // 1 sector size
xdata DWORD flash_sectors; // 3 number of sectors
xdata BYTE flash_ec; // 7 error code
 
xdata BYTE mmc_last_cmd; // 0
xdata BYTE mmc_response; // 1
xdata BYTE mmc_buffer[16]; // 2
 
#define[FLASH_EC_CMD_ERROR][1]
#define[FLASH_EC_TIMEOUT][2]
#define[FLASH_EC_BUSY][3]
#define[FLASH_EC_PENDING][4]
#define[FLASH_EC_READ_ERROR][5]
#define[FLASH_EC_WRITE_ERROR][6]
 
/* *********************************************************************
***** flash_setPage *************************************************
***** mmc_clocks ****************************************************
********************************************************************* */
/* set the current page, i.e. executes the following steps
1. wait if busy
2. read the desired page from the falsh array into the new buffer
3. write the old buffer to the flash array (if modified)
*/
static void flash_setPage(WORD page)
{
flash_nextPage = page + 1;
// perform c (256 if c=0) clocks
void mmc_clocks (BYTE c) {
c; // this avoids stupid warnings
_asm
mov r2,dpl
#ifdef[MMC_bmMODE]
mov a,_MMC_IO
anl a, #(~MMC_bmCLK)
mov r3, a
orl a, #(MMC_bmCLK)
mov r4, a
010014$:
mov _MMC_IO,r4
nop
mov _MMC_IO,r3
#else
010014$:
setb _MMC_CLK
nop
clr _MMC_CLK
#endif
djnz r2,010014$
_endasm;
}
 
 
/* *********************************************************************
***** flash_read_byte ***********************************************
********************************************************************* */
// read a single byte from the flash
BYTE flash_read_byte() { // uses r2,r3,r4
_asm
#ifdef[MMC_bmMODE]
// 8 - 1 + 8*13 + 1 + 6 = 118 clocks
mov a,_MMC_IO
anl a, #(~MMC_bmCLK)
mov r2, a
orl a, #(MMC_bmCLK)
mov r3, a
mov a,_MMC_IO // 7
anl a,#(MMC_bmDO)
mov _MMC_IO, r3
subb a,#1
rlc a
mov r4,a
mov _MMC_IO, r2
 
mov a,_MMC_IO // 6
anl a,#(MMC_bmDO)
mov _MMC_IO, r3
subb a,#1
mov a,r4
rlc a
mov r4,a
mov _MMC_IO, r2
 
mov a,_MMC_IO // 5
anl a,#(MMC_bmDO)
mov _MMC_IO, r3
subb a,#1
mov a,r4
rlc a
mov r4,a
mov _MMC_IO, r2
 
mov a,_MMC_IO // 4
anl a,#(MMC_bmDO)
mov _MMC_IO, r3
subb a,#1
mov a,r4
rlc a
mov r4,a
mov _MMC_IO, r2
mov a,_MMC_IO // 3
anl a,#(MMC_bmDO)
mov _MMC_IO, r3
subb a,#1
mov a,r4
rlc a
mov r4,a
mov _MMC_IO, r2
mov a,_MMC_IO // 2
anl a,#(MMC_bmDO)
mov _MMC_IO, r3
subb a,#1
mov a,r4
rlc a
mov r4,a
mov _MMC_IO, r2
 
mov a,_MMC_IO // 1
anl a,#(MMC_bmDO)
mov _MMC_IO, r3
subb a,#1
mov a,r4
rlc a
mov r4,a
mov _MMC_IO, r2
mov a,_MMC_IO // 0
anl a,#(MMC_bmDO)
mov _MMC_IO, r3
subb a,#1
mov a,r4
rlc a
xrl a,#255
mov _MMC_IO, r2
#else
// 8*7 + 6 = 62 clocks
mov c,_MMC_DO // 7
setb _MMC_CLK
rlc a
clr _MMC_CLK
 
mov c,_MMC_DO // 6
setb _MMC_CLK
rlc a
clr _MMC_CLK
 
mov c,_MMC_DO // 5
setb _MMC_CLK
rlc a
clr _MMC_CLK
 
mov c,_MMC_DO // 4
setb _MMC_CLK
rlc a
clr _MMC_CLK
 
mov c,_MMC_DO // 3
setb _MMC_CLK
rlc a
clr _MMC_CLK
 
mov c,_MMC_DO // 2
setb _MMC_CLK
rlc a
clr _MMC_CLK
 
mov c,_MMC_DO // 1
setb _MMC_CLK
rlc a
clr _MMC_CLK
 
mov c,_MMC_DO // 0
setb _MMC_CLK
rlc a
clr _MMC_CLK
#endif
mov dpl,a
ret
_endasm;
return 0; // never ever called (just to avoid warnings)
}
 
/* *********************************************************************
***** flash_read ****************************************************
********************************************************************* */
// read len (256 if len=0) bytes from the flash to the buffer
void flash_read(__xdata BYTE *buf, BYTE len) {
*buf; // this avoids stupid warnings
len; // this too
_asm // *buf is in dptr, len is in _flash_read_PARM_2
mov r2,_flash_read_PARM_2
#ifdef[MMC_bmMODE]
mov a,_MMC_IO
anl a, #(~MMC_bmCLK)
mov r5, a
orl a, #(MMC_bmCLK)
mov r3, a
010012$:
// 8 + len*(-1 + 8*13 - 1 + 2 + 9) + 4 = 12 + len*113 clocks
mov a,_MMC_IO // 7
anl a,#(MMC_bmDO)
mov _MMC_IO, r3
subb a,#1
rlc a
mov r4,a
mov _MMC_IO, r5
 
mov a,_MMC_IO // 6
anl a,#(MMC_bmDO)
mov _MMC_IO, r3
subb a,#1
mov a,r4
rlc a
mov r4,a
mov _MMC_IO, r5
 
mov a,_MMC_IO // 5
anl a,#(MMC_bmDO)
mov _MMC_IO, r3
subb a,#1
mov a,r4
rlc a
mov r4,a
mov _MMC_IO, r5
 
mov a,_MMC_IO // 4
anl a,#(MMC_bmDO)
mov _MMC_IO, r3
subb a,#1
mov a,r4
rlc a
mov r4,a
mov _MMC_IO, r5
mov a,_MMC_IO // 3
anl a,#(MMC_bmDO)
mov _MMC_IO, r3
subb a,#1
mov a,r4
rlc a
mov r4,a
mov _MMC_IO, r5
mov a,_MMC_IO // 2
anl a,#(MMC_bmDO)
mov _MMC_IO, r3
subb a,#1
mov a,r4
rlc a
mov r4,a
mov _MMC_IO, r5
 
mov a,_MMC_IO // 1
anl a,#(MMC_bmDO)
mov _MMC_IO, r3
subb a,#1
mov a,r4
rlc a
mov r4,a
mov _MMC_IO, r5
mov a,_MMC_IO // 0
anl a,#(MMC_bmDO)
mov _MMC_IO, r3
subb a,#1
mov a,r4
rlc a
xrl a,#255
mov _MMC_IO, r5
#else
010012$:
// 2 + len*(8*7 + 9) + 4 = 6 + len*65 clocks
mov c,_MMC_DO // 7
setb _MMC_CLK
rlc a
clr _MMC_CLK
 
mov c,_MMC_DO // 6
setb _MMC_CLK
rlc a
clr _MMC_CLK
 
mov c,_MMC_DO // 5
setb _MMC_CLK
rlc a
clr _MMC_CLK
 
mov c,_MMC_DO // 4
setb _MMC_CLK
rlc a
clr _MMC_CLK
 
mov c,_MMC_DO // 3
setb _MMC_CLK
rlc a
clr _MMC_CLK
 
mov c,_MMC_DO // 2
setb _MMC_CLK
rlc a
clr _MMC_CLK
 
mov c,_MMC_DO // 1
setb _MMC_CLK
rlc a
clr _MMC_CLK
 
mov c,_MMC_DO // 0
setb _MMC_CLK
rlc a
clr _MMC_CLK
#endif
movx @dptr,a
inc dptr
djnz r2,010012$
_endasm;
}
 
/* *********************************************************************
***** flash_write_byte **********************************************
********************************************************************* */
// send one bytes from buffer buf to the card
void flash_write_byte (BYTE b) { // b is in dpl
b; // this avoids stupid warnings
_asm
#ifdef[MMC_bmMODE]
// up to 7 + 8*12 + 6 = 109 clocks
mov a,_MMC_IO
anl a, #(255 - MMC_bmCLK - MMC_bmDI )
mov r3, a
mov a,dpl
rlc a // 7
mov _MMC_IO,r3
jnc 0100157$
orl _MMC_IO, #(MMC_bmDI)
0100157$:
orl _MMC_IO, #(MMC_bmCLK)
rlc a // 6
mov _MMC_IO,r3
jnc 0100156$
orl _MMC_IO, #(MMC_bmDI)
0100156$:
orl _MMC_IO, #(MMC_bmCLK)
rlc a // 5
mov _MMC_IO,r3
jnc 0100155$
orl _MMC_IO, #(MMC_bmDI)
0100155$:
orl _MMC_IO, #(MMC_bmCLK)
 
rlc a // 4
mov _MMC_IO,r3
jnc 0100154$
orl _MMC_IO, #(MMC_bmDI)
0100154$:
orl _MMC_IO, #(MMC_bmCLK)
rlc a // 3
mov _MMC_IO,r3
jnc 0100153$
orl _MMC_IO, #(MMC_bmDI)
0100153$:
orl _MMC_IO, #(MMC_bmCLK)
 
rlc a // 2
mov _MMC_IO,r3
jnc 0100152$
orl _MMC_IO, #(MMC_bmDI)
0100152$:
orl _MMC_IO, #(MMC_bmCLK)
rlc a // 1
mov _MMC_IO,r3
jnc 0100151$
orl _MMC_IO, #(MMC_bmDI)
0100151$:
orl _MMC_IO, #(MMC_bmCLK)
 
rlc a // 0
mov _MMC_IO,r3
jnc 0100150$
orl _MMC_IO, #(MMC_bmDI)
0100150$:
orl _MMC_IO, #(MMC_bmCLK)
mov _MMC_IO,r3
#else
// 3 + 8*7 + 4 = 63 clocks
mov a,dpl
rlc a // 7
 
mov _MMC_DI,c
setb _MMC_CLK
rlc a // 6
clr _MMC_CLK
 
mov _MMC_DI,c
setb _MMC_CLK
rlc a // 5
clr _MMC_CLK
 
mov _MMC_DI,c
setb _MMC_CLK
rlc a // 4
clr _MMC_CLK
 
mov _MMC_DI,c
setb _MMC_CLK
rlc a // 3
clr _MMC_CLK
 
mov _MMC_DI,c
setb _MMC_CLK
rlc a // 2
clr _MMC_CLK
 
mov _MMC_DI,c
setb _MMC_CLK
rlc a // 1
clr _MMC_CLK
 
mov _MMC_DI,c
setb _MMC_CLK
rlc a // 0
clr _MMC_CLK
 
mov _MMC_DI,c
setb _MMC_CLK
nop
clr _MMC_CLK
#endif
_endasm;
}
 
/* *********************************************************************
***** flash_write ***************************************************
********************************************************************* */
/* writes <bytes> bytes at address <addr> to the current buffer starting at <offs>.
If <setNextPage> = 1 the next page (defined by <flash_nextPage> is set automatically
// write len (256 id len=0) bytes from the buffer to the flash
void flash_write(__xdata BYTE *buf, BYTE len) {
*buf; // this avoids stupid warnings
len; // this too
_asm // *buf is in dptr, len is in _flash_read_PARM_2
mov r2,_flash_read_PARM_2
#ifdef[MMC_bmMODE]
// 7 + len*(2 + 8*12 + 7 ) + 6 = 13 + len*105 clocks
mov a,_MMC_IO
anl a, #(255 - MMC_bmCLK - MMC_bmDI )
mov r3, a
010013$:
movx a,@dptr
rlc a // 7
mov _MMC_IO,r3
jnc 0100167$
orl _MMC_IO, #(MMC_bmDI)
0100167$:
orl _MMC_IO, #(MMC_bmCLK)
rlc a // 6
mov _MMC_IO,r3
jnc 0100166$
orl _MMC_IO, #(MMC_bmDI)
0100166$:
orl _MMC_IO, #(MMC_bmCLK)
rlc a // 5
mov _MMC_IO,r3
jnc 0100165$
orl _MMC_IO, #(MMC_bmDI)
0100165$:
orl _MMC_IO, #(MMC_bmCLK)
 
rlc a // 4
mov _MMC_IO,r3
jnc 0100164$
orl _MMC_IO, #(MMC_bmDI)
0100164$:
orl _MMC_IO, #(MMC_bmCLK)
rlc a // 3
mov _MMC_IO,r3
jnc 0100163$
orl _MMC_IO, #(MMC_bmDI)
0100163$:
orl _MMC_IO, #(MMC_bmCLK)
 
rlc a // 2
mov _MMC_IO,r3
jnc 0100162$
orl _MMC_IO, #(MMC_bmDI)
0100162$:
orl _MMC_IO, #(MMC_bmCLK)
rlc a // 1
mov _MMC_IO,r3
jnc 0100161$
orl _MMC_IO, #(MMC_bmDI)
0100161$:
orl _MMC_IO, #(MMC_bmCLK)
 
rlc a // 0
mov _MMC_IO,r3
jnc 0100160$
orl _MMC_IO, #(MMC_bmDI)
0100160$:
orl _MMC_IO, #(MMC_bmCLK)
 
inc dptr
djnz r2,010013$
mov _MMC_IO,r3
#else
010013$:
// 2 + len*(3 + 8*7 - 1 + 7 ) + 4 = 6 + len*65 clocks
movx a,@dptr
rlc a // 7
 
mov _MMC_DI,c
setb _MMC_CLK
rlc a // 6
clr _MMC_CLK
 
mov _MMC_DI,c
setb _MMC_CLK
rlc a // 5
clr _MMC_CLK
 
mov _MMC_DI,c
setb _MMC_CLK
rlc a // 4
clr _MMC_CLK
 
mov _MMC_DI,c
setb _MMC_CLK
rlc a // 3
clr _MMC_CLK
 
mov _MMC_DI,c
setb _MMC_CLK
rlc a // 2
clr _MMC_CLK
 
mov _MMC_DI,c
setb _MMC_CLK
rlc a // 1
clr _MMC_CLK
 
mov _MMC_DI,c
setb _MMC_CLK
rlc a // 0
clr _MMC_CLK
 
mov _MMC_DI,c
setb _MMC_CLK
inc dptr
clr _MMC_CLK
 
djnz r2,010013$
#endif
_endasm;
}
 
/* *********************************************************************
***** mmc_wait_busy *************************************************
********************************************************************* */
BYTE mmc_wait_busy () {
WORD i;
flash_ec = FLASH_EC_BUSY;
MMC_IO |= MMC_bmDI; // avoids that in-data is interpreted as command
for (i=0; (flash_read_byte()!=255) && i<65535; i++ ) ;
if ( MMC_IO & MMC_bmDO ) {
flash_ec = 0;
return 0;
}
return 1;
}
 
/* *********************************************************************
***** mmc_select ****************************************************
********************************************************************* */
/*
select the card (CS) and waits if busy
returns 1 if busy
*/
static void flash_write(WORD addr, WORD bytes, WORD offs, BYTE setNextPage)
{
addr = 0;
bytes = 0;
offs = 0;
setNextPage = 0;
BYTE mmc_select() {
MMC_IO |= MMC_bmCS; // CS = 1
mmc_clocks(8); // 8 dummy clocks to finish a previous command
MMC_IO &= ~MMC_bmCS; // CS = 0
 
return mmc_wait_busy();
}
 
/* *********************************************************************
***** flash_write ***************************************************
***** mmc_deselect **************************************************
********************************************************************* */
static void flash_readRegister(BYTE cmd)
{
BYTE oe,b,i,j;
b = OEE & ( ~( (1 << FLASH_SO_BIT) | (1 << FLASH_SI_BIT) | (1 << FLASH_CLK_BIT) | (1 << FLASH_CS_BIT) ) );
oe = IOE & b;
IOE = oe | (1 << FLASH_CS_BIT); // CS = 1
OEE = b | (1 << FLASH_SI_BIT) | (1 << FLASH_CLK_BIT) | (1 << FLASH_CS_BIT);
IOE = oe; // CS = 0
// de-select the card (CS) and waits if busy
void mmc_deselect() {
MMC_IO |= MMC_bmDI; // CS = 1
mmc_clocks(8); // 8 dummy clocks to finish a previous command
MMC_IO |= MMC_bmCS; // CS = 1
mmc_clocks(8); // 8 more dummy clocks
}
/* *********************************************************************
***** mmc_read_response *********************************************
********************************************************************* */
// read the first response byte
BYTE mmc_read_response() {
MMC_IO |= MMC_bmDI; // avoids that in-data is interpreted as command
_asm
mov r2,#0x255
010010$:
lcall _flash_read_byte
mov a,dpl
jnb acc.7,010011$
djnz r2, 010010$
 
// CLK=0
for ( i=0; i<8; i++ ) {
IOE = b = oe | ((cmd & 128) >> (7-FLASH_SI_BIT)); // CLK = 0, SI=x
IOE = b | (1 << FLASH_CLK_BIT); // CLK = 1, SI=x
cmd <<= 1;
010011$:
mov dptr,#_mmc_response
movx @dptr,a
mov dpl,a
ret
_endasm;
return 0; // never ever called, just to avoid stupid warnings
}
 
/* *********************************************************************
***** mmc_wait_start ************************************************
********************************************************************* */
/*
wait for the start byte
returns 1 on error
*/
BYTE mmc_wait_start() {
WORD to;
to=0;
MMC_IO |= MMC_bmDI; // avoids that in-data is interpreted as command
while ( flash_read_byte() != 0xfe ) { // wait for the start byte
if ( ++to == 0 ) // 65536 * 8 clocks
return 1;
}
return 0;
}
 
/* *********************************************************************
***** flash_read_init ***********************************************
********************************************************************* */
/*
Start the initialization sequence for reading sector s-
The whole sector must be read.
returns an error code (FLASH_EC_*). 0 means no error.
*/
BYTE flash_read_init(DWORD s) {
if ( (MMC_IO & MMC_bmCS) == 0 ) {
return FLASH_EC_PENDING; // we interrupted a pending Flash operation
}
if ( mmc_select() ) { // select the card
mmc_deselect();
return FLASH_EC_BUSY;
}
mmc_last_cmd = 17;
mmc_buffer[0] = 17 | 64;
s = s << 1;
mmc_buffer[1] = s >> 16;
mmc_buffer[2] = s >> 8;
mmc_buffer[3] = s;
mmc_buffer[4] = 0;
mmc_buffer[5] = 1;
flash_write(mmc_buffer,6);
mmc_read_response();
if ( mmc_response != 0 ) {
mmc_deselect();
return FLASH_EC_CMD_ERROR;
}
 
if ( mmc_wait_start() ) { // wait for the start byte
mmc_deselect();
return FLASH_EC_TIMEOUT;
}
return 0;
}
 
/* *********************************************************************
***** flash_read_finish *********************************************
********************************************************************* */
/*
Reads n dummy bytes (the whole sector has to be read out)
and runs the finalization sequence for a sector read.
*/
void flash_read_finish(WORD n) {
while ( n > 32 ) {
mmc_clocks(0); // 256 clocks = 32 dummy bytes
n-=32;
}
mmc_clocks(n << 3);
mmc_clocks(24); // 16 CRC + 8 dummy clocks
mmc_deselect();
}
 
 
/* *********************************************************************
***** flash_write_init **********************************************
********************************************************************* */
/*
Start the initialization sequence for writing sector s
The whole sectir must be written.
returns an error code (FLASH_EC_*). 0 means no error.
*/
BYTE flash_write_init(DWORD s) {
if ( (MMC_IO & MMC_bmCS) == 0 ) {
return FLASH_EC_PENDING; // we interrupted a pending Flash operation
}
if ( mmc_select() ) { // select the card
mmc_deselect();
return FLASH_EC_BUSY;
}
mmc_clocks(8);
mmc_last_cmd = 24;
mmc_buffer[0] = 24 | 64;
s = s << 1;
mmc_buffer[1] = s >> 16;
mmc_buffer[2] = s >> 8;
mmc_buffer[3] = s;
mmc_buffer[4] = 0;
mmc_buffer[5] = 1;
flash_write(mmc_buffer,6);
mmc_read_response();
if ( mmc_response != 0 ) {
mmc_deselect();
return FLASH_EC_CMD_ERROR;
}
 
MMC_IO |= MMC_bmDI; // send one dummy byte plus the start byte 0xfe
mmc_clocks(15);
MMC_IO &= ~MMC_bmDI;
MMC_IO |= MMC_bmCLK;
MMC_IO &= ~MMC_bmCLK;
return 0;
}
 
/* *********************************************************************
***** flash_write_finish ********************************************
********************************************************************* */
/*
Writes n dummy bytes (the whole sector has to be written)
and runs the finalization sequence for a sector write
returns an error code (FLASH_EC_*). 0 means no error.
*/
BYTE flash_write_finish(WORD n) {
BYTE b;
MMC_IO &= ~MMC_bmDI; // value of the dummy data is 0
while ( n > 32 ) {
mmc_clocks(0); // 256 clocks = 32 dummy bytes
n-=32;
}
mmc_clocks(n << 3);
 
MMC_IO |= MMC_bmDI;
mmc_clocks(16); // 16 CRC clocks
b = flash_read_byte() & 7;
// mmc_wait_busy(); // not required here, programming continues if card is deslected
mmc_deselect();
if ( b != 5 ) { // data response, last three bits must be 5
return FLASH_EC_WRITE_ERROR;
}
return 0;
}
/* *********************************************************************
***** mmc_send_cmd **************************************************
********************************************************************* */
// send a command
#define[mmc_send_cmd(][,$1);][{ // send a command, argument=0
mmc_last_cmd = $0;
mmc_buffer[0] = 64 | ($0 & 127);
mmc_buffer[1] = 0;
mmc_buffer[2] = 0;
mmc_buffer[3] = 0;
mmc_buffer[4] = 0;
mmc_buffer[5] = $1 | 1;
flash_write(mmc_buffer,6);
mmc_read_response();
}]
 
/* *********************************************************************
***** flash_init ****************************************************
********************************************************************* */
// init the card
void flash_init() {
BYTE i;
 
flash_enabled = 1;
flash_sector_size = 512;
for ( j=0; j<4; j++ ) {
// CLK = 1
b = 0;
for ( i=0; i<8; i++ ) {
IOE = oe; // CLK = 0, SO=x
b = (b << 1) | ((IOE >> FLASH_SO_BIT) & 1);
IOE = oe | (1 << FLASH_CLK_BIT); // CLK = 1
}
flash_register[j]=b;
OEMMC_PORT = (OEMMC_PORT & ~MMC_bmDO) | ( MMC_bmCS | MMC_bmDI | MMC_bmCLK );
MMC_IO |= MMC_bmDI;
MMC_IO |= MMC_bmCS;
mmc_clocks(0); // 256 clocks
mmc_select(); // select te card
flash_ec = FLASH_EC_BUSY;
mmc_send_cmd(0, 0x95); // send reset command
if ( mmc_response & ~1 ) { // check for errors
goto mmc_init_cmd_err;
}
 
IOE = oe | (1 << FLASH_CS_BIT); // CS = 1
for ( i=0; mmc_response != 0 && i<255; i++ ) { // send the init command and wait wait (up to 1s) until ready
wait(4);
mmc_send_cmd(1, 0xff);
}
if ( mmc_response != 0 ) { // check for errors
goto mmc_init_cmd_err;
}
 
mmc_send_cmd(9, 0); // read the CSD
if ( mmc_wait_start() ) {
flash_ec = FLASH_EC_TIMEOUT;
goto mmc_init_err;
}
flash_read(mmc_buffer,16);
mmc_clocks(16); // CRC is clocked out to nirvana
 
i = (mmc_buffer[5] & 15) + ((mmc_buffer[10] >> 7) | ((mmc_buffer[9] & 3) << 1)) - 7;
flash_sectors = ((mmc_buffer[8] >> 6) | (mmc_buffer[7] << 2) | ((mmc_buffer[6] & 3) << 10)) + 1;
flash_sectors = flash_sectors << i;
 
flash_ec = 0;
mmc_deselect();
return;
 
mmc_init_cmd_err:
flash_ec = FLASH_EC_CMD_ERROR;
mmc_init_err:
flash_enabled = 0;
mmc_deselect();
}
 
 
107,14 → 914,170
/* *********************************************************************
***** EP0 vendor request 0x40 ***************************************
********************************************************************* */
// send mmc information structure (card size, error status, ...) to the host
ADD_EP0_VENDOR_REQUEST((0x40,,
flash_readRegister(SETUPDAT[2]);
EP0BUF[0] = flash_register[0];
EP0BUF[1] = flash_register[1];
EP0BUF[2] = flash_register[2];
EP0BUF[3] = flash_register[3];
MEM_COPY1(flash_enabled,EP0BUF,8);
EP0BCH = 0;
EP0BCL = 4;
,,));;
EP0BCL = 8;
,,
));;
 
#endif /*ZTEX_DESCRIPTORS_H*/
/* *********************************************************************
***** EP0 vendor request 0x41 ***************************************
********************************************************************* */
void mmc_read_ep0 () {
flash_read(EP0BUF, ep0_payload_transfer);
if ( ep0_payload_remaining == 0 ) {
mmc_clocks(24); // 16 CRC + 8 dummy clocks
mmc_deselect();
}
}
 
ADD_EP0_VENDOR_REQUEST((0x41,, // read (exactly) one sector
if ( (MMC_IO & MMC_bmCS) == 0 ) {
flash_ec = FLASH_EC_PENDING; // we interrupted a pending Flash operation
EP0_STALL;
}
if ( mmc_select() ) { // select the card
mmc_deselect();
EP0_STALL;
}
mmc_last_cmd = 17;
mmc_buffer[0] = 17 | 64;
_asm
clr c
mov dptr,#(_SETUPDAT + 2)
movx a,@dptr
mov dptr,#(_mmc_buffer + 3)
rlc a
movx @dptr,a
 
mov dptr,#(_SETUPDAT + 3)
movx a,@dptr
mov dptr,#(_mmc_buffer + 2)
rlc a
movx @dptr,a
 
mov dptr,#(_SETUPDAT + 4)
movx a,@dptr
mov dptr,#(_mmc_buffer + 1)
rlc a
movx @dptr,a
_endasm;
mmc_buffer[4] = 0;
mmc_buffer[5] = 1;
flash_write(mmc_buffer,6);
mmc_read_response();
if ( mmc_response != 0 ) {
flash_ec = FLASH_EC_CMD_ERROR;
mmc_deselect();
EP0_STALL;
}
 
if ( mmc_wait_start() ) { // wait for the start byte
flash_ec = FLASH_EC_TIMEOUT;
mmc_deselect();
EP0_STALL;
}
 
mmc_read_ep0();
EP0BCH = 0;
EP0BCL = ep0_payload_transfer;
,,
if ( ep0_payload_transfer != 0 ) {
mmc_read_ep0();
}
EP0BCH = 0;
EP0BCL = ep0_payload_transfer;
));;
 
/* *********************************************************************
***** EP0 vendor command 0x42 ***************************************
********************************************************************* */
void mmc_send_ep0 () {
flash_write(EP0BUF, ep0_payload_transfer);
if ( ep0_payload_remaining == 0 ) {
MMC_IO |= MMC_bmDI;
mmc_clocks(16); // 16 CRC clocks
if ( (flash_read_byte() & 7) != 5 ) { // data response, last three bits must be 5
flash_ec = FLASH_EC_WRITE_ERROR;
}
// mmc_wait_busy(); // not required here, programming continues if card is deselected
mmc_deselect();
}
}
 
ADD_EP0_VENDOR_COMMAND((0x42,, // write (exactly!) one sector
if ( (MMC_IO & MMC_bmCS) == 0 ) {
flash_ec = FLASH_EC_PENDING; // we interrupted a pending Flash operation
EP0_STALL;
}
if ( mmc_select() ) { // select the card
mmc_deselect();
EP0_STALL;
}
mmc_last_cmd = 24;
mmc_buffer[0] = 24 | 64;
_asm
clr c
mov dptr,#(_SETUPDAT + 2)
movx a,@dptr
mov dptr,#(_mmc_buffer + 3)
rlc a
movx @dptr,a
 
mov dptr,#(_SETUPDAT + 3)
movx a,@dptr
mov dptr,#(_mmc_buffer + 2)
rlc a
movx @dptr,a
 
mov dptr,#(_SETUPDAT + 4)
movx a,@dptr
mov dptr,#(_mmc_buffer + 1)
rlc a
movx @dptr,a
_endasm;
mmc_buffer[4] = 0;
mmc_buffer[5] = 1;
flash_write(mmc_buffer,6);
mmc_read_response();
if ( mmc_response != 0 ) {
flash_ec = FLASH_EC_CMD_ERROR;
mmc_deselect();
EP0_STALL;
}
 
MMC_IO |= MMC_bmDI; // send one dummy byte plus the start byte 0xfe
mmc_clocks(15);
MMC_IO &= ~MMC_bmDI;
MMC_IO |= MMC_bmCLK;
MMC_IO &= ~MMC_bmCLK;
,,
if ( ep0_payload_transfer != 0 ) {
flash_ec = 0;
mmc_send_ep0();
if ( flash_ec != 0 ) {
EP0_STALL;
}
}
));;
 
/* *********************************************************************
***** EP0 vendor request 0x43 ***************************************
********************************************************************* */
// send detailed MMC status plus debug information
ADD_EP0_VENDOR_REQUEST((0x43,, // this may interrupt a pending operation
MEM_COPY1(flash_ec,EP0BUF+2,19);
EP0BUF[21] = (MMC_IO & MMC_bmDO) == 0;
mmc_select();
mmc_send_cmd(13, 0);
EP0BUF[0] = mmc_response;
EP0BUF[1] = flash_read_byte();
mmc_deselect();
EP0BCH = 0;
EP0BCL = 22;
,,
));;
 
#endif /*ZTEX_FLASH1_H*/
/trunk/include/ztex-flash2.h
0,0 → 1,122
/*!
ZTEX Firmware Kit for EZ-USB Microcontrollers
Copyright (C) 2008-2009 ZTEX e.K.
http://www.ztex.de
 
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
published by the Free Software Foundation.
 
This program 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; if not, see http://www.gnu.org/licenses/.
!*/
 
/*
supports AT45D* Flash on Port E
*/
 
#ifndef[ZTEX_FLASH2_H]
#define[ZTEX_FLASH2_H]
 
#define[@CAPABILITY_FLASH;]
 
#define[FLASH_SI_BIT][6]
#define[FLASH_SO_BIT][4]
#define[FLASH_CLK_BIT][5]
#ifeq[PRODUCT_IS][UFM-1_1]
#define[FLASH_CS_BIT][3]
//#warning[FLASH_CS_BIT=3]
#else
#define[FLASH_CS_BIT][7]
//#warning[FLASH_CS_BIT=7]
#endif
 
xdata BYTE flash_buffer = 1; // current buffer 1
xdata BYTE flash_bufferModified = 0; // 1 indicates that the current flash page needs to be reprogrammeded
xdata WORD flash_page = 0xffff; // current flash page
xdata WORD flash_nextPage = 0xffff; // next flash page (usually flashPage+1)
xdata WORD flash_maxPage = 0; // next flash page (usually flashPage+1)
xdata WORD flash_pageSize = 528; // page size (512 or 528)
xdata BYTE flash_register[4]; // used to store register content
 
/* *********************************************************************
***** flash_setPage *************************************************
********************************************************************* */
/* set the current page, i.e. executes the following steps
1. wait if busy
2. read the desired page from the flash array into the new buffer
3. write the old buffer to the flash array (if modified)
*/
static void flash_setPage(WORD page)
{
flash_nextPage = page + 1;
}
 
/* *********************************************************************
***** flash_write ***************************************************
********************************************************************* */
/* writes <bytes> bytes at address <addr> to the current buffer starting at <offs>.
If <setNextPage> = 1 the next page (defined by <flash_nextPage> is set automatically
*/
static void flash_write(WORD addr, WORD bytes, WORD offs, BYTE setNextPage)
{
addr = 0;
bytes = 0;
offs = 0;
setNextPage = 0;
}
 
/* *********************************************************************
***** flash_write ***************************************************
********************************************************************* */
static void flash_readRegister(BYTE cmd)
{
BYTE oe,b,i,j;
b = OEE & ( ~( (1 << FLASH_SO_BIT) | (1 << FLASH_SI_BIT) | (1 << FLASH_CLK_BIT) | (1 << FLASH_CS_BIT) ) );
oe = IOE & b;
IOE = oe | (1 << FLASH_CS_BIT); // CS = 1
OEE = b | (1 << FLASH_SI_BIT) | (1 << FLASH_CLK_BIT) | (1 << FLASH_CS_BIT);
IOE = oe; // CS = 0
 
// CLK=0
for ( i=0; i<8; i++ ) {
IOE = b = oe | ((cmd & 128) >> (7-FLASH_SI_BIT)); // CLK = 0, SI=x
IOE = b | (1 << FLASH_CLK_BIT); // CLK = 1, SI=x
cmd <<= 1;
}
for ( j=0; j<4; j++ ) {
// CLK = 1
b = 0;
for ( i=0; i<8; i++ ) {
IOE = oe; // CLK = 0, SO=x
b = (b << 1) | ((IOE >> FLASH_SO_BIT) & 1);
IOE = oe | (1 << FLASH_CLK_BIT); // CLK = 1
}
flash_register[j]=b;
}
 
IOE = oe | (1 << FLASH_CS_BIT); // CS = 1
}
 
 
/* *********************************************************************
***** EP0 vendor request 0x40 ***************************************
********************************************************************* */
ADD_EP0_VENDOR_REQUEST((0x40,,
flash_readRegister(SETUPDAT[2]);
EP0BUF[0] = flash_register[0];
EP0BUF[1] = flash_register[1];
EP0BUF[2] = flash_register[2];
EP0BUF[3] = flash_register[3];
EP0BCH = 0;
EP0BCL = 4;
,,));;
 
#endif /*ZTEX_FLASH2_H*/
/trunk/include/ztex-utils.h
46,13 → 46,33
typedef unsigned short WORD;
typedef unsigned long DWORD;
 
#include[ezregs.h]
#include[ezintavecs.h]
/* *********************************************************************
***** include the basic functions ***********************************
***** global variables **********************************************
********************************************************************* */
#include[ezregs.h]
#include[ezintavecs.h]
/*
The following two variables are used to control HSNAK bit.
ep0_payload_remaining is set to the length field of of the Setup Data
structure (in SUDAV_ISR). At the begin of each payload data transfer (in
SUDAV_ISR, EP0IN_ISR and EP0OUT_ISR) the amount of payload of the current
transfer s calculated (<=64 bytes) and subtracted from
ep0_payload_remaining. For Vendor Commands HSNAK bit is cleared
automatically (at the end of EP0OUT_ISR) ifep0_payload_remaining == 0.
For Vendor Requests HSNAK bit is always cleared at the end of SUDAV_ISR.
*/
 
xdata WORD ep0_payload_remaining = 0; // remaining amount of ep0 payload data (excluding the data of the current transfer)
xdata BYTE ep0_payload_transfer = 0; // transfer
 
/* *********************************************************************
*********************************************************************
***** basic functions ***********************************************
*********************************************************************
********************************************************************* */
 
/* *********************************************************************
***** wait **********************************************************
********************************************************************* */
void wait(WORD short ms) { // wait in ms
68,7 → 88,7
 
WORD i,j;
for (j=0; j<us; j++)
for (i=0; i<120; i++);
for (i=0; i<10; i++);
}
 
 
98,12 → 118,14
 
#define[MEM_COPY1(][,$1,$2);][{
_asm
push ar2
mov _AUTOPTRL1,#(_$0)
mov _AUTOPTRH1,#((_$0) >> 8)
mov _AUTOPTRL2,#(_$1)
mov _AUTOPTRH2,#((_$1) >> 8)
mov r2,#($2);
lcall _MEM_COPY1_int
lcall _MEM_COPY1_int
pop ar2
_endasm;
}]
 
/trunk/libusbJava-src/ch/ntb/usb/package.html
2,25 → 2,27
<html>
<head></head>
<body bgcolor="white">
A Java wrapper for the libusb 0.1 and libusb-win32 USB library.
<p>
The Java libusb wrapper is known to work on Linux, Windows and Mac, but should work on every operating system which supports libusb and Java.
<p>
This software has originally been developed by members of the <a href="http://inf.ntb.ch" title="Computer Science Laboratory" target="_blank">Computer Science Laboratory</a>
at the <a href="http://www.ntb.ch" title="NTB" target="_blank">University of Applied Sciences of Technology NTB</a>, Buchs, Switzerland.
<p>
The main project page is <a href="http://libusbjava.sourceforge.net">http://libusbjava.sourceforge.net</a>.
<p>
This version is distributed together with the Java API of the <a href="http://www.ztex.de/firmware-kit/index.e.html">ZTEX EZ-USB SDK</a> and bases
on the SVN version of Apr. 6, 2009. It is extended by the ability to load the (OS dependent) libraries form system ressource (e.g. in the current .jar file),
see the <i><a href="LibLoader.html">LibLoader</a></i> Class.
<p>
<i>LibusbJava.java</i> is the JNI class to the <i>libusbJava.so</i> and <i>LibusbJava.dll</i>, respectively.
Every class starting with <i>Usb_</i> represents a descriptor of the bus structure which is retrieved by
calling <i>LibusbJava.usb_get_busses()</i>.
 
Includes the main classes for the Java libusb wrapper.
<br>
<i>LibusbJava.java</i>
is the JNI class to the
<i>LibusbJava.dll</i>
. Every class starting with
<i>Usb_</i>
represents a descriptor of the bus structure which is retrieved by
calling
<i>LibusbJava.usb_get_busses()</i>
.
 
<p>
<h2>Related Resources</h2>
 
For more information about this project visit
<a
href="http://libusbjava.sourceforge.net">http://libusbjava.sourceforge.net</a>
.
<a href="http://libusbjava.sourceforge.net">http://libusbjava.sourceforge.net</a>.
 
</body>
</html>
/trunk/libusbJava-src/ch/ntb/usb/LibLoader.java
11,7 → 11,7
import java.io.*;
 
/**
* This class allows to load libraries in the normal way or as a system resource.
* This class allows to load libraries in the normal way or as a system resource (e.g. form the current .jar file).
* See below for a further description. <br>
*
* @author Stefan Ziegenbalg
21,11 → 21,11
 
/**
* Loads a library. This is done in three steps.<br>
* 1. The library is tried to be load from the path list specified by the java.library.path proterty. <br>
* 2. The library is tried to be load from the currrent directory. <br>
* 3. The library is searched as a system ressource (e.g. in the current .jar file),
* copied to te temporary directory and loaded from there. Afterwards the temporary library is deleted.
* The copying is necessary because libraries cant be loeaded directly from .jar files.<br>
* 1. The library is tried to be load from the path list specified by the java.library.path property. <br>
* 2. The library is tried to be load from the current directory. <br>
* 3. The library is searched as a system resource (e.g. in the current .jar file),
* copied to to temporary directory and loaded from there. Afterwards the temporary library is deleted.
* The copying is necessary because libraries can't be loaded directly from .jar files.<br>
*
* @param libName Library name (e.g. usbJava)
*
/trunk/libusbJava-src/Makefile
48,6 → 48,9
$(JAVAC) $(JAVASRCS)
echo > classes.made
 
doc:
javadoc ch.ntb.usb -d ../docs/libusbJava
install2: all
$(INSTALLDIR) ../libusbJava/ch/ntb/usb/logger
$(INSTALLFILE) $(LIBTARGET) ../libusbJava
/trunk/docs/imgs/ztex_firmware_kit-diagram.png Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream
trunk/docs/imgs/ztex_firmware_kit-diagram.png Property changes : Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: trunk/docs/java/stylesheet.css =================================================================== --- trunk/docs/java/stylesheet.css (nonexistent) +++ trunk/docs/java/stylesheet.css (revision 3) @@ -0,0 +1,29 @@ +/* Javadoc style sheet */ + +/* Define colors, fonts and other style attributes here to override the defaults */ + +/* Page background color */ +body { background-color: #FFFFFF; color:#000000 } + +/* Headings */ +h1 { font-size: 145% } + +/* Table colors */ +.TableHeadingColor { background: #CCCCFF; color:#000000 } /* Dark mauve */ +.TableSubHeadingColor { background: #EEEEFF; color:#000000 } /* Light mauve */ +.TableRowColor { background: #FFFFFF; color:#000000 } /* White */ + +/* Font used in left-hand frame lists */ +.FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#000000 } +.FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } +.FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } + +/* Navigation bar fonts and colors */ +.NavBarCell1 { background-color:#EEEEFF; color:#000000} /* Light mauve */ +.NavBarCell1Rev { background-color:#00008B; color:#FFFFFF} /* Dark Blue */ +.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;color:#000000;} +.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;color:#FFFFFF;} + +.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} +.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} + Index: trunk/docs/java/index-all.html =================================================================== --- trunk/docs/java/index-all.html (nonexistent) +++ trunk/docs/java/index-all.html (revision 3) @@ -0,0 +1,1282 @@ + + + + + + +Index + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +A B C D E F G H I J L M N O P R S T U V W Z
+

+A

+
+
AlreadyConfiguredException - Exception in ztex
Thrown if the FPGA is already configured.
AlreadyConfiguredException(String) - +Constructor for exception ztex.AlreadyConfiguredException +
Constructs an instance from the given input string. +
AlreadyConfiguredException() - +Constructor for exception ztex.AlreadyConfiguredException +
Constructs an instance using a standard message. +
+
+

+B

+
+
BitstreamReadException - Exception in ztex
Signals that an error occurred while attempting to read a bitstream.
BitstreamReadException(String) - +Constructor for exception ztex.BitstreamReadException +
Constructs an instance from the given error message. +
BitstreamReadException() - +Constructor for exception ztex.BitstreamReadException +
Constructs an instance using a standard message. +
BitstreamUploadException - Exception in ztex
Signals that an error occurred while attempting to upload the bitstream.
BitstreamUploadException(String) - +Constructor for exception ztex.BitstreamUploadException +
Constructs an instance from the given error message. +
BitstreamUploadException() - +Constructor for exception ztex.BitstreamUploadException +
Constructs an instance using a standard message. +
byteArrayString(byte[]) - +Static method in class ztex.ZtexDevice1 +
Produces a nice string representation of an array of bytes. +
+
+

+C

+
+
CapabilityException - Exception in ztex
Thrown is a required capability is not available.
CapabilityException(Ztex1, String) - +Constructor for exception ztex.CapabilityException +
Constructs an instance from a givig device and capability string. +
capabilityInfo(String) - +Method in class ztex.Ztex1v1 +
Creates a String with capability information. +
capabilityStrings - +Static variable in class ztex.Ztex1v1 +
The names of the capabilities +
certainWorkarounds - +Variable in class ztex.Ztex1 +
Setting to true will enable certain workarounds, e.g. to deal with bad driver/OS implementations. +
ch.ntb.usb - package ch.ntb.usb
A Java wrapper for the libusb 0.1 and libusb-win32 USB library.
checkCapability(int, int) - +Method in class ztex.Ztex1v1 +
Checks whether ZTEX descriptor 1 is available and interface 1 and a given capability are supported. +
checkCompatible(int, int, int, int) - +Method in class ztex.Ztex1v1 +
Checks whether the given product ID is compatible to the device corresponding to this class and whether interface 1 is supported. +
checkValid() - +Method in class ztex.Ztex1 +
Checks whether ZTEX descriptor 1 is available. +
checkValid() - +Method in class ztex.Ztex1v1 +
Checks whether ZTEX descriptor 1 is available and interface 1 is supported. +
close() - +Method in class ch.ntb.usb.Device +
Release the claimed interface and close the opened device. +
compatible(int, int, int, int) - +Method in class ztex.Ztex1v1 +
Checks whether the given product ID is compatible to the device corresponding to this class and whether interface 1 is supported. +
compatible(int, int, int, int) - +Method in class ztex.ZtexDevice1 +
Checks whether the given product ID is compatible to the device. +
configureFpga(String, boolean) - +Method in class ztex.Ztex1v1 +
Upload a Bitstream to the FPGA. +
controlMsg(int, int, int, int, byte[], int, int, boolean) - +Method in class ch.ntb.usb.Device +
Performs a control request to the default control pipe on a device. +
controlMsgTimeout - +Variable in class ztex.Ztex1 +
The timeout for control messages in ms. +
cypressProductId - +Static variable in class ztex.ZtexDevice1 +
The EZ-USB product ID 0x8613. +
cypressVendorId - +Static variable in class ztex.ZtexDevice1 +
The Cypress vendor ID 0x4b4. +
+
+

+D

+
+
dataInfo(PrintStream) - +Method in class ztex.IhxFile +
Print out some information about the memory usage. +
dev() - +Method in class ztex.Ztex1 +
Returns the corresponding ZtexDevice1. +
dev() - +Method in class ztex.ZtexDevice1 +
Returns the USB device. +
Device - Class in ch.ntb.usb
This class represents an USB device.
Device(short, short) - +Constructor for class ch.ntb.usb.Device +
  +
Device(short, short, String) - +Constructor for class ch.ntb.usb.Device +
  +
device(int) - +Method in class ztex.ZtexScanBus1 +
Returns a device from the list of devices. +
DeviceLostException - Exception in ztex
Thrown if a device went lost after renumeration.
DeviceLostException(String) - +Constructor for exception ztex.DeviceLostException +
Constructs an instance from the given input string. +
DeviceLostException() - +Constructor for exception ztex.DeviceLostException +
Constructs an instance using a standard message. +
+
+

+E

+
+
eepromBytes - +Variable in class ztex.Ztex1v1 +
Number of bytes written to EEPROM. +
eepromChecksum - +Variable in class ztex.Ztex1v1 +
Checksum of the last EEPROM transfer. +
eepromDisable() - +Method in class ztex.Ztex1v1 +
Disables the firmware stored in the EEPROM. +
eepromRead(int, byte[], int) - +Method in class ztex.Ztex1v1 +
Reads data from the EEPROM. +
eepromState() - +Method in class ztex.Ztex1v1 +
Reads the current EEPROM status. +
eepromUpload(String, boolean) - +Method in class ztex.Ztex1v1 +
Upload the firmware to the EEPROM. +
eepromWrite(int, byte[], int) - +Method in class ztex.Ztex1v1 +
Writes data to the EEPROM. +
ERROR_BAD_FILE_DESCRIPTOR - +Static variable in class ch.ntb.usb.LibusbJava +
System error codes. +
ERROR_BUSY - +Static variable in class ch.ntb.usb.LibusbJava +
System error codes. +
ERROR_INVALID_PARAMETER - +Static variable in class ch.ntb.usb.LibusbJava +
System error codes. +
ERROR_IO_ERROR - +Static variable in class ch.ntb.usb.LibusbJava +
System error codes. +
ERROR_NO_SUCH_DEVICE_OR_ADDRESS - +Static variable in class ch.ntb.usb.LibusbJava +
System error codes. +
ERROR_NOT_ENOUGH_MEMORY - +Static variable in class ch.ntb.usb.LibusbJava +
System error codes. +
ERROR_SUCCESS - +Static variable in class ch.ntb.usb.LibusbJava +
System error codes. +
ERROR_TIMEDOUT - +Static variable in class ch.ntb.usb.LibusbJava +
System error codes. +
EzUsb - Class in ztex
Provides methods for uploading firmware to Cypress EZ-USB devices.
EzUsb() - +Constructor for class ztex.EzUsb +
  +
+
+

+F

+
+
finalize() - +Method in class ztex.Ztex1 +
The destructor closes the USB file handle. +
FirmwareUploadException - Exception in ztex
Signals that an error occured while attempting to upload the firmware.
FirmwareUploadException(String) - +Constructor for exception ztex.FirmwareUploadException +
Constructs an instance from the given error message. +
FirmwareUploadException() - +Constructor for exception ztex.FirmwareUploadException +
Constructs an instance using a standard message. +
FLASH_EC_BUSY - +Static variable in class ztex.Ztex1v1 +
Signals that Flash memory it busy. +
FLASH_EC_CMD_ERROR - +Static variable in class ztex.Ztex1v1 +
Signals an error while attempting to execute a command. +
FLASH_EC_NO_ERROR - +Static variable in class ztex.Ztex1v1 +
Means no error. +
FLASH_EC_PENDING - +Static variable in class ztex.Ztex1v1 +
Signals that another Flash operation is pending. +
FLASH_EC_READ_ERROR - +Static variable in class ztex.Ztex1v1 +
Signals an error while attempting to read from Flash. +
FLASH_EC_TIMEOUT - +Static variable in class ztex.Ztex1v1 +
Signals that a timeout occurred. +
FLASH_EC_WRITE_ERROR - +Static variable in class ztex.Ztex1v1 +
Signals an error while attempting to write to Flash. +
flashEC - +Variable in class ztex.Ztex1v1 +
Last Flash error code obtained by Ztex1v1.flashState(). +
flashEnabled() - +Method in class ztex.Ztex1v1 +
Returns true if Flash memory is installed. +
flashFirstFreeSector() - +Method in class ztex.Ztex1v1 +
Returns the first free sector of the Flash memory. +
flashReadSector(int, byte[]) - +Method in class ztex.Ztex1v1 +
Reads one sector from the Flash. +
flashResetBitstream() - +Method in class ztex.Ztex1v1 +
Clears a Bitstream from the Flash. +
flashSectors() - +Method in class ztex.Ztex1v1 +
Returns the number of sectors of the Flash memory or 0, if no Flash memory is installed. +
flashSectorSize() - +Method in class ztex.Ztex1v1 +
Returns the sector size of the Flash memory or 0, if no flash memory is installed. +
flashSize() - +Method in class ztex.Ztex1v1 +
Returns the size of Flash memory or 0, if no Flash memory is installed. +
flashState() - +Method in class ztex.Ztex1v1 +
Reads the the Flash memory status and information. +
flashStrError(int) - +Static method in class ztex.Ztex1v1 +
Converts a given error code into a String. +
flashStrError() - +Method in class ztex.Ztex1v1 +
Gets the last Flash error from the device. +
flashUploadBitstream(String) - +Method in class ztex.Ztex1v1 +
Uploads a Bitstream to the Flash. +
flashWriteSector(int, byte[]) - +Method in class ztex.Ztex1v1 +
Writes one sector to the Flash. +
FULLSPEED_MAX_BULK_PACKET_SIZE - +Static variable in class ch.ntb.usb.USB +
The maximum packet size of a bulk transfer when operating in fullspeed + (12 MB/s) mode. +
fwVersion() - +Method in class ztex.ZtexDevice1 +
Returns the firmware version. +
fwVersion() - +Method in class ztex.ZtexIhxFile1 +
Returns the firmware version. +
+
+

+G

+
+
getAltinterface() - +Method in class ch.ntb.usb.Device +
Returns the alternative interface. +
getAltsetting() - +Method in class ch.ntb.usb.Usb_Interface +
Retuns an array of interface descriptors. +
getBAlternateSetting() - +Method in class ch.ntb.usb.Usb_Interface_Descriptor +
Returns the value used to select the alternate setting (LibusbJava.usb_set_altinterface(int, int)). +
getBcdDevice() - +Method in class ch.ntb.usb.Usb_Device_Descriptor +
Returns the device release number. +
getBcdUSB() - +Method in class ch.ntb.usb.Usb_Device_Descriptor +
Returns the USB specification number to which the device complies to. +
getBConfigurationValue() - +Method in class ch.ntb.usb.Usb_Config_Descriptor +
Returns the value to use as an argument to select this configuration (LibusbJava.usb_set_configuration(int, int)). +
getBDescriptorType() - +Method in class ch.ntb.usb.Usb_Descriptor +
Get the type of this descriptor. +
getBDeviceClass() - +Method in class ch.ntb.usb.Usb_Device_Descriptor +
Returns the class code (Assigned by www.usb.org)
+ If equal to zero, each interface specifies it's own class code. +
getBDeviceProtocol() - +Method in class ch.ntb.usb.Usb_Device_Descriptor +
Returns the protocol code (Assigned by www.usb.org)
+
getBDeviceSubClass() - +Method in class ch.ntb.usb.Usb_Device_Descriptor +
Returns the subclass code (Assigned by www.usb.org)
+
getBEndpointAddress() - +Method in class ch.ntb.usb.Usb_Endpoint_Descriptor +
Returns the endpoint address. +
getBInterfaceClass() - +Method in class ch.ntb.usb.Usb_Interface_Descriptor +
Returns the class code (Assigned by www.usb.org). +
getBInterfaceNumber() - +Method in class ch.ntb.usb.Usb_Interface_Descriptor +
Returns the number (identifier) of this interface. +
getBInterfaceProtocol() - +Method in class ch.ntb.usb.Usb_Interface_Descriptor +
Returns the protocol code (Assigned by www.usb.org). +
getBInterfaceSubClass() - +Method in class ch.ntb.usb.Usb_Interface_Descriptor +
Returns the subclass code (Assigned by www.usb.org). +
getBInterval() - +Method in class ch.ntb.usb.Usb_Endpoint_Descriptor +
Returns the intervall for polling endpoint data transfers. +
getBLength() - +Method in class ch.ntb.usb.Usb_Descriptor +
Get the size of this descriptor in bytes. +
getBmAttributes() - +Method in class ch.ntb.usb.Usb_Config_Descriptor +
Returns the power parameters for this configuration. +
getBmAttributes() - +Method in class ch.ntb.usb.Usb_Endpoint_Descriptor +
Returns the attributes of this endpoint. +
getBMaxPacketSize0() - +Method in class ch.ntb.usb.Usb_Device_Descriptor +
Returns the maximum packet size for endpoint zero. +
getBNumConfigurations() - +Method in class ch.ntb.usb.Usb_Device_Descriptor +
Returns the number of possible configurations supported at its current + speed. +
getBNumEndpoints() - +Method in class ch.ntb.usb.Usb_Interface_Descriptor +
Returns the number of endpoints used for this interface. +
getBNumInterfaces() - +Method in class ch.ntb.usb.Usb_Config_Descriptor +
Returns the number of interfaces. +
getBRefresh() - +Method in class ch.ntb.usb.Usb_Endpoint_Descriptor +
  +
getBSynchAddress() - +Method in class ch.ntb.usb.Usb_Endpoint_Descriptor +
  +
getBus() - +Static method in class ch.ntb.usb.USB +
Returns the root Usb_Bus element. +
getBus() - +Method in class ch.ntb.usb.Usb_Device +
Returns the reference to the bus to which this device is connected. +
getChildren() - +Method in class ch.ntb.usb.Usb_Device +
Returns a reference to the first child. +
getConfig() - +Method in class ch.ntb.usb.Usb_Device +
Returns the USB config descriptors. +
getConfigDescriptors() - +Method in class ch.ntb.usb.Device +
Returns the configuration descriptors associated with this device. +
getConfiguration() - +Method in class ch.ntb.usb.Device +
Returns the current configuration used. +
getDescriptor() - +Method in class ch.ntb.usb.Usb_Device +
Returns the USB device descriptor. +
getDevice() - +Method in class ch.ntb.usb.Device +
Returns the Usb_Device instance associated with this device. +
getDevice(short, short, String) - +Static method in class ch.ntb.usb.USB +
Create a new device an register it in a device queue. +
getDevice(short, short) - +Static method in class ch.ntb.usb.USB +
See USB.getDevice(short, short, String). +
getDeviceDescriptor() - +Method in class ch.ntb.usb.Device +
Returns the device descriptor associated with this device. +
getDevices() - +Method in class ch.ntb.usb.Usb_Bus +
Get the first device ojects of the devices linked list. +
getDevnum() - +Method in class ch.ntb.usb.Usb_Device +
Returns the number assigned to this device. +
getDirname() - +Method in class ch.ntb.usb.Usb_Bus +
Returns the systems String representation of the bus. +
getEndpoint() - +Method in class ch.ntb.usb.Usb_Interface_Descriptor +
Returns an array of endpoint descriptors. +
getExtra() - +Method in class ch.ntb.usb.Usb_Config_Descriptor +
Returns the data of extra descriptor(s) if available. +
getExtra() - +Method in class ch.ntb.usb.Usb_Endpoint_Descriptor +
Returns the data of extra descriptor(s) if available. +
getExtra() - +Method in class ch.ntb.usb.Usb_Interface_Descriptor +
Returns the data of extra descriptor(s) if available. +
getExtralen() - +Method in class ch.ntb.usb.Usb_Config_Descriptor +
Returns the number of bytes of the extra descriptor. +
getExtralen() - +Method in class ch.ntb.usb.Usb_Endpoint_Descriptor +
Returns the number of bytes of the extra descriptor. +
getExtralen() - +Method in class ch.ntb.usb.Usb_Interface_Descriptor +
Returns the number of bytes of the extra descriptor. +
getFilename() - +Method in class ch.ntb.usb.Device +
Returns the optional filename which is set when there are multiple + devices with the same vendor and product id. +
getFilename() - +Method in class ch.ntb.usb.Usb_Device +
Returns the systems String representation. +
getFlashEC() - +Method in class ztex.Ztex1v1 +
Gets the last Flash error from the device. +
getFpgaConfiguration() - +Method in class ztex.Ztex1v1 +
Returns true if the FPGA is configured. +
getFpgaConfigurationStr() - +Method in class ztex.Ztex1v1 +
Returns a string that indicates the FPGA configuration status. +
getIConfiguration() - +Method in class ch.ntb.usb.Usb_Config_Descriptor +
Returns the index of the String descriptor describing this configuration. +
getIdProduct() - +Method in class ch.ntb.usb.Device +
Returns the product ID of the device. +
getIdProduct() - +Method in class ch.ntb.usb.Usb_Device_Descriptor +
Returns the product ID (Assigned by www.usb.org)
+
getIdVendor() - +Method in class ch.ntb.usb.Device +
Returns the vendor ID of the device. +
getIdVendor() - +Method in class ch.ntb.usb.Usb_Device_Descriptor +
Returns the Vendor ID (Assigned by www.usb.org)
+
getIInterface() - +Method in class ch.ntb.usb.Usb_Interface_Descriptor +
Returns the index of the String descriptor describing this interface. +
getIManufacturer() - +Method in class ch.ntb.usb.Usb_Device_Descriptor +
Returns the index of the manufacturer string descriptor. +
getInputStream(String) - +Static method in class ztex.JInputStream +
Constructs an instance from a giving file name. +
getInterface() - +Method in class ch.ntb.usb.Device +
Returns the current interface. +
getInterface() - +Method in class ch.ntb.usb.Usb_Config_Descriptor +
Returns the USB interface descriptors. +
getIProduct() - +Method in class ch.ntb.usb.Usb_Device_Descriptor +
Returns the index of the product string descriptor. +
getISerialNumber() - +Method in class ch.ntb.usb.Usb_Device_Descriptor +
Returns the index of serial number string descriptor. +
getLocation() - +Method in class ch.ntb.usb.Usb_Bus +
Returns the location in the USB bus linked list. +
getMaxPacketSize() - +Method in class ch.ntb.usb.Device +
Returns the maximum packet size in bytes which is allowed to be + transmitted at once. +
getMaxPower() - +Method in class ch.ntb.usb.Usb_Config_Descriptor +
Returns the maximum power consumption in 2mA units. +
getNext() - +Method in class ch.ntb.usb.Usb_Bus +
Returns the next bus object. +
getNext() - +Method in class ch.ntb.usb.Usb_Device +
Returns the pointer to the next device. +
getNumAltsetting() - +Method in class ch.ntb.usb.Usb_Interface +
Returns the number of alternate settings. +
getNumChildren() - +Method in class ch.ntb.usb.Usb_Device +
Returns the number of children of this device. +
getPrev() - +Method in class ch.ntb.usb.Usb_Bus +
Returns the previous bus object. +
getPrev() - +Method in class ch.ntb.usb.Usb_Device +
Returns the pointer to the previous device. +
getRootDev() - +Method in class ch.ntb.usb.Usb_Bus +
Get the root device of this bus. +
getWMaxPacketSize() - +Method in class ch.ntb.usb.Usb_Endpoint_Descriptor +
Returns the maximum packet size of this endpoint is capable of sending or + receiving. +
getWTotalLength() - +Method in class ch.ntb.usb.Usb_Config_Descriptor +
Returns the total length in bytes of all descriptors. +
+
+

+H

+
+
handle() - +Method in class ztex.Ztex1 +
Returns the USB file handle. +
HIGHSPEED_MAX_BULK_PACKET_SIZE - +Static variable in class ch.ntb.usb.USB +
The maximum packet size of a bulk transfer when operating in highspeed + (480 MB/s) mode. +
+
+

+I

+
+
ihxData - +Variable in class ztex.IhxFile +
This array stores the firmware image. +
IhxFile - Class in ztex
A class representing a firmware image loaded from an ihx (Intel Hex format) file.
IhxFile(String) - +Constructor for class ztex.IhxFile +
Constructs an instance from a given file name. +
IhxFileDamagedException - Exception in ztex
Signals that an ihx file is corrupt.
IhxFileDamagedException(String, int, String) - +Constructor for exception ztex.IhxFileDamagedException +
Constructs an instance from a given file name, line number and error message. +
IhxParseException - Exception in ztex
Signals that an error occurred while attempting to decode the ihx file.
IhxParseException(String) - +Constructor for exception ztex.IhxParseException +
Constructs an instance from the given error message. +
IncompatibleFirmwareException - Exception in ztex
Thrown while attempting to overwrite an existing firmware with an incompatible one.
IncompatibleFirmwareException(String) - +Constructor for exception ztex.IncompatibleFirmwareException +
Constructs an instance from the given error message. +
IncompatibleFirmwareException() - +Constructor for exception ztex.IncompatibleFirmwareException +
Constructs an instance using a standard message. +
init() - +Static method in class ch.ntb.usb.USB +
Explicitly calls LibusbJava.usb_init(). +
interfaceCapabilities() - +Method in class ztex.ZtexDevice1 +
Returns the interface capabilities (all 6 bytes). +
interfaceCapabilities(int) - +Method in class ztex.ZtexDevice1 +
Returns byte i of the interface capabilities. +
interfaceCapabilities(int, int) - +Method in class ztex.ZtexDevice1 +
Returns byte i, bit j of the interface capabilities. +
interfaceCapabilities() - +Method in class ztex.ZtexIhxFile1 +
Returns the interface capabilities (all 6 bytes). +
interfaceCapabilities(int) - +Method in class ztex.ZtexIhxFile1 +
Returns byte i of the interface capabilities. +
interfaceVersion() - +Method in class ztex.ZtexDevice1 +
Returns the interface version. +
interfaceVersion() - +Method in class ztex.ZtexIhxFile1 +
Returns the interface version. +
InvalidFirmwareException - Exception in ztex
Thrown if a device runs with no or the wrong firmware, i.e. if the ZTEX descriptor is not found or damaged.
InvalidFirmwareException(Ztex1, String) - +Constructor for exception ztex.InvalidFirmwareException +
Constructs an instance from the given device and error message. +
InvalidFirmwareException(ZtexDevice1, String) - +Constructor for exception ztex.InvalidFirmwareException +
Constructs an instance from the given device and error message. +
InvalidFirmwareException(Usb_Device, String) - +Constructor for exception ztex.InvalidFirmwareException +
Constructs an instance from the given device and error message. +
InvalidFirmwareException(Ztex1) - +Constructor for exception ztex.InvalidFirmwareException +
Constructs an instance from the given device and error message. +
InvalidFirmwareException(ZtexDevice1) - +Constructor for exception ztex.InvalidFirmwareException +
Constructs an instance from the given device and error message. +
InvalidFirmwareException(Usb_Device) - +Constructor for exception ztex.InvalidFirmwareException +
Constructs an instance from the given device and error message. +
isCypress() - +Method in class ztex.ZtexDevice1 +
Returns true if the device has Cypress EZ-USB vendor and product ID's (0x4b4 and 0x8613). +
isOpen() - +Method in class ch.ntb.usb.Device +
Check if the device is open. +
+
+

+J

+
+
JInputStream - Class in ztex
Creates an input stream from a regular file or a system resource file (i.e. a file from the current jar file).
JInputStream() - +Constructor for class ztex.JInputStream +
  +
+
+

+L

+
+
LibLoader - Class in ch.ntb.usb
This class allows to load libraries in the normal way or as a system resource (e.g. form the current .jar file).
LibLoader() - +Constructor for class ch.ntb.usb.LibLoader +
  +
LibusbJava - Class in ch.ntb.usb
This class represents the Java Native Interface to the shared library which + is (with some exceptions) a one-to-one representation of the libusb API.
LibusbJava() - +Constructor for class ch.ntb.usb.LibusbJava +
  +
load(String) - +Static method in class ch.ntb.usb.LibLoader +
Loads a library. +
logBus(Usb_Bus) - +Static method in class ch.ntb.usb.Utils +
  +
logBus(Usb_Bus, PrintStream) - +Static method in class ch.ntb.usb.Utils +
  +
+
+

+M

+
+
manufacturerString() - +Method in class ztex.ZtexDevice1 +
Returns the manufacturer string of the device. +
moduleReserved() - +Method in class ztex.ZtexDevice1 +
Returns the application specific information (all 12 bytes). +
moduleReserved(int) - +Method in class ztex.ZtexDevice1 +
Returns byte i of the application specific information. +
moduleReserved() - +Method in class ztex.ZtexIhxFile1 +
Returns the application specific information (all 12 bytes). +
moduleReserved(int) - +Method in class ztex.ZtexIhxFile1 +
Returns byte i of the application specific information. +
+
+

+N

+
+
numberOfDevices() - +Method in class ztex.ZtexScanBus1 +
Returns the number of devices found. +
+
+

+O

+
+
open(int, int, int) - +Method in class ch.ntb.usb.Device +
Opens the device and claims the specified configuration, interface and + altinterface. +
+
+

+P

+
+
printBus(PrintStream) - +Method in class ztex.ZtexScanBus1 +
Prints out a list of devices found. +
printFpgaState() - +Method in class ztex.Ztex1v1 +
Prints out the FPGA state. +
printMmcState() - +Method in class ztex.Ztex1v1 +
Prints out some debug information about *SD/MMC Flash cards in SPI mode. +
productId() - +Method in class ztex.ZtexDevice1 +
Returns the product ID (all 4 bytes). +
productId(int) - +Method in class ztex.ZtexDevice1 +
Returns byte i of the product ID. +
productId() - +Method in class ztex.ZtexIhxFile1 +
Returns the product ID (all 4 bytes). +
productId(int) - +Method in class ztex.ZtexIhxFile1 +
Returns byte i of the product ID. +
productString() - +Method in class ztex.ZtexDevice1 +
Returns the product string of the device. +
+
+

+R

+
+
readBulk(int, byte[], int, int, boolean) - +Method in class ch.ntb.usb.Device +
Read data from the device using a bulk transfer. +
readInterrupt(int, byte[], int, int, boolean) - +Method in class ch.ntb.usb.Device +
Read data from the device using a interrupt transfer. +
REQ_CLEAR_FEATURE - +Static variable in class ch.ntb.usb.USB +
This request is used to clear or disable a specific feature (USB spec + 9.4.1). +
REQ_GET_CONFIGURATION - +Static variable in class ch.ntb.usb.USB +
This request returns the current device configuration value (USB spec + 9.4.2). +
REQ_GET_DESCRIPTOR - +Static variable in class ch.ntb.usb.USB +
This request returns the specified descriptor if the descriptor exists + (USB spec 9.4.3). +
REQ_GET_INTERFACE - +Static variable in class ch.ntb.usb.USB +
This request returns the selected alternate setting for the specified + interface (USB spec 9.4.4). +
REQ_GET_STATUS - +Static variable in class ch.ntb.usb.USB +
This request returns status for the specified recipient (USB spec 9.4.5). +
REQ_SET_ADDRESS - +Static variable in class ch.ntb.usb.USB +
This request sets the device address for all future device accesses (USB + spec 9.4.6). +
REQ_SET_CONFIGURATION - +Static variable in class ch.ntb.usb.USB +
This request sets the device configuration (USB spec 9.4.7). +
REQ_SET_DESCRIPTOR - +Static variable in class ch.ntb.usb.USB +
This request is optional and may be used to update existing descriptors + or new descriptors may be added (USB spec 9.4.8). +
REQ_SET_FEATURE - +Static variable in class ch.ntb.usb.USB +
This request is used to set or enable a specific feature (USB spec + 9.4.9). +
REQ_SET_INTERFACE - +Static variable in class ch.ntb.usb.USB +
This request allows the host to select an alternate setting for the + specified interface (USB spec 9.4.10). +
REQ_SYNCH_FRAME - +Static variable in class ch.ntb.usb.USB +
This request is used to set and then report an endpoint’s synchronization + frame (USB spec 9.4.11). +
REQ_TYPE_DIR_DEVICE_TO_HOST - +Static variable in class ch.ntb.usb.USB +
Identifies the direction of data transfer in the second phase of the + control transfer. +
REQ_TYPE_DIR_HOST_TO_DEVICE - +Static variable in class ch.ntb.usb.USB +
Identifies the direction of data transfer in the second phase of the + control transfer. +
REQ_TYPE_RECIP_DEVICE - +Static variable in class ch.ntb.usb.USB +
Specifies the intended recipient of the request. +
REQ_TYPE_RECIP_ENDPOINT - +Static variable in class ch.ntb.usb.USB +
Specifies the intended recipient of the request. +
REQ_TYPE_RECIP_INTERFACE - +Static variable in class ch.ntb.usb.USB +
Specifies the intended recipient of the request. +
REQ_TYPE_RECIP_OTHER - +Static variable in class ch.ntb.usb.USB +
Specifies the intended recipient of the request. +
REQ_TYPE_TYPE_CLASS - +Static variable in class ch.ntb.usb.USB +
Specifies the type of the request. +
REQ_TYPE_TYPE_RESERVED - +Static variable in class ch.ntb.usb.USB +
Specifies the type of the request. +
REQ_TYPE_TYPE_STANDARD - +Static variable in class ch.ntb.usb.USB +
Specifies the type of the request. +
REQ_TYPE_TYPE_VENDOR - +Static variable in class ch.ntb.usb.USB +
Specifies the type of the request. +
reset() - +Method in class ch.ntb.usb.Device +
Sends an USB reset to the device. +
reset(int, boolean) - +Static method in class ztex.EzUsb +
Controls the reset state of a Cypress EZ-USB device. +
resetEzUsb() - +Method in class ztex.Ztex1 +
Resets the EZ-USB and manages the renumeration process. +
resetFpga() - +Method in class ztex.Ztex1v1 +
Resets the FPGA. +
+
+

+S

+
+
setResetOnFirstOpen(boolean, int) - +Method in class ch.ntb.usb.Device +
If enabled, the device is reset when first opened. +
setSnString(String) - +Method in class ztex.ZtexIhxFile1 +
Modifies the serial number string. +
snString() - +Method in class ztex.ZtexDevice1 +
Returns the serial number string of the device. +
snString() - +Method in class ztex.ZtexIhxFile1 +
Returns the serial number string. +
+
+

+T

+
+
toString() - +Method in class ch.ntb.usb.Usb_Bus +
  +
toString() - +Method in class ch.ntb.usb.Usb_Config_Descriptor +
  +
toString() - +Method in class ch.ntb.usb.Usb_Device +
  +
toString() - +Method in class ch.ntb.usb.Usb_Device_Descriptor +
  +
toString() - +Method in class ch.ntb.usb.Usb_Endpoint_Descriptor +
  +
toString() - +Method in class ch.ntb.usb.Usb_Interface +
  +
toString() - +Method in class ch.ntb.usb.Usb_Interface_Descriptor +
  +
toString() - +Method in class ztex.Ztex1 +
Returns a lot of useful information about the corresponding device. +
toString() - +Method in class ztex.Ztex1v1 +
Returns a lot of useful information about the corresponding device. +
toString() - +Method in class ztex.ZtexDevice1 +
Returns a string representation if the device with a lot of useful information. +
toString() - +Method in class ztex.ZtexIhxFile1 +
Returns a string representation if the instance. +
+
+

+U

+
+
updateDescriptors() - +Method in class ch.ntb.usb.Device +
Updates the device and descriptor information from the bus. +
uploadFirmware(int, IhxFile) - +Static method in class ztex.EzUsb +
Uploads the Firmware to a Cypress EZ-USB device. +
uploadFirmware(String, boolean) - +Method in class ztex.Ztex1 +
Uploads the firmware to the EZ-USB and manages the renumeration process. +
USB - Class in ch.ntb.usb
This class manages all USB devices and defines some USB specific constants.
USB() - +Constructor for class ch.ntb.usb.USB +
  +
usb_bulk_read(int, int, byte[], int, int) - +Static method in class ch.ntb.usb.LibusbJava +
Performs a bulk read request to the endpoint specified by ep. +
usb_bulk_write(int, int, byte[], int, int) - +Static method in class ch.ntb.usb.LibusbJava +
Performs a bulk write request to the endpoint specified by ep. +
Usb_Bus - Class in ch.ntb.usb
Represents an USB bus.
Usb_Bus() - +Constructor for class ch.ntb.usb.Usb_Bus +
  +
usb_claim_interface(int, int) - +Static method in class ch.ntb.usb.LibusbJava +
Claim an interface of a device. +
USB_CLASS_AUDIO - +Static variable in class ch.ntb.usb.Usb_Device_Descriptor +
Device and/or interface class codes. +
USB_CLASS_COMM - +Static variable in class ch.ntb.usb.Usb_Device_Descriptor +
Device and/or interface class codes. +
USB_CLASS_DATA - +Static variable in class ch.ntb.usb.Usb_Device_Descriptor +
Device and/or interface class codes. +
USB_CLASS_HID - +Static variable in class ch.ntb.usb.Usb_Device_Descriptor +
Device and/or interface class codes. +
USB_CLASS_HUB - +Static variable in class ch.ntb.usb.Usb_Device_Descriptor +
Device and/or interface class codes. +
USB_CLASS_MASS_STORAGE - +Static variable in class ch.ntb.usb.Usb_Device_Descriptor +
Device and/or interface class codes. +
USB_CLASS_PER_INTERFACE - +Static variable in class ch.ntb.usb.Usb_Device_Descriptor +
Device and/or interface class codes. +
USB_CLASS_PRINTER - +Static variable in class ch.ntb.usb.Usb_Device_Descriptor +
Device and/or interface class codes. +
USB_CLASS_VENDOR_SPEC - +Static variable in class ch.ntb.usb.Usb_Device_Descriptor +
Device and/or interface class codes. +
usb_clear_halt(int, int) - +Static method in class ch.ntb.usb.LibusbJava +
Clears any halt status on an endpoint. +
usb_close(int) - +Static method in class ch.ntb.usb.LibusbJava +
usb_close closes a device opened with + usb_open. +
Usb_Config_Descriptor - Class in ch.ntb.usb
Represents the descriptor of a USB configuration.
Usb_Config_Descriptor() - +Constructor for class ch.ntb.usb.Usb_Config_Descriptor +
  +
usb_control_msg(int, int, int, int, int, byte[], int, int) - +Static method in class ch.ntb.usb.LibusbJava +
Performs a control request to the default control pipe on a device. +
Usb_Descriptor - Class in ch.ntb.usb
Common USB descriptor values.
Usb_Descriptor() - +Constructor for class ch.ntb.usb.Usb_Descriptor +
  +
Usb_Device - Class in ch.ntb.usb
Represents an USB device.
Usb_Device() - +Constructor for class ch.ntb.usb.Usb_Device +
  +
Usb_Device_Descriptor - Class in ch.ntb.usb
Represents the descriptor of a USB device.
Usb_Device_Descriptor() - +Constructor for class ch.ntb.usb.Usb_Device_Descriptor +
  +
USB_DT_CONFIG - +Static variable in class ch.ntb.usb.Usb_Descriptor +
Descriptor types (Usb_Descriptor.bDescriptorType). +
USB_DT_CONFIG_SIZE - +Static variable in class ch.ntb.usb.Usb_Descriptor +
Descriptor sizes per descriptor type (Usb_Descriptor.bLength). +
USB_DT_DEVICE - +Static variable in class ch.ntb.usb.Usb_Descriptor +
Descriptor types (Usb_Descriptor.bDescriptorType). +
USB_DT_DEVICE_SIZE - +Static variable in class ch.ntb.usb.Usb_Descriptor +
Descriptor sizes per descriptor type (Usb_Descriptor.bLength). +
USB_DT_ENDPOINT - +Static variable in class ch.ntb.usb.Usb_Descriptor +
Descriptor types (Usb_Descriptor.bDescriptorType). +
USB_DT_ENDPOINT_AUDIO_SIZE - +Static variable in class ch.ntb.usb.Usb_Descriptor +
Descriptor sizes per descriptor type (Usb_Descriptor.bLength). +
USB_DT_ENDPOINT_SIZE - +Static variable in class ch.ntb.usb.Usb_Descriptor +
Descriptor sizes per descriptor type (Usb_Descriptor.bLength). +
USB_DT_HID - +Static variable in class ch.ntb.usb.Usb_Descriptor +
Descriptor types (Usb_Descriptor.bDescriptorType). +
USB_DT_HUB - +Static variable in class ch.ntb.usb.Usb_Descriptor +
Descriptor types (Usb_Descriptor.bDescriptorType). +
USB_DT_HUB_NONVAR_SIZE - +Static variable in class ch.ntb.usb.Usb_Descriptor +
Descriptor sizes per descriptor type (Usb_Descriptor.bLength). +
USB_DT_INTERFACE - +Static variable in class ch.ntb.usb.Usb_Descriptor +
Descriptor types (Usb_Descriptor.bDescriptorType). +
USB_DT_INTERFACE_SIZE - +Static variable in class ch.ntb.usb.Usb_Descriptor +
Descriptor sizes per descriptor type (Usb_Descriptor.bLength). +
USB_DT_PHYSICAL - +Static variable in class ch.ntb.usb.Usb_Descriptor +
Descriptor types (Usb_Descriptor.bDescriptorType). +
USB_DT_REPORT - +Static variable in class ch.ntb.usb.Usb_Descriptor +
Descriptor types (Usb_Descriptor.bDescriptorType). +
USB_DT_STRING - +Static variable in class ch.ntb.usb.Usb_Descriptor +
Descriptor types (Usb_Descriptor.bDescriptorType). +
USB_ENDPOINT_ADDRESS_MASK - +Static variable in class ch.ntb.usb.Usb_Endpoint_Descriptor +
Endpoint address mask (in bEndpointAddress). +
Usb_Endpoint_Descriptor - Class in ch.ntb.usb
Represents the descriptor of an USB endpoint.
Usb_Endpoint_Descriptor() - +Constructor for class ch.ntb.usb.Usb_Endpoint_Descriptor +
  +
USB_ENDPOINT_DIR_MASK - +Static variable in class ch.ntb.usb.Usb_Endpoint_Descriptor +
Endpoint address mask (in bEndpointAddress). +
USB_ENDPOINT_TYPE_BULK - +Static variable in class ch.ntb.usb.Usb_Endpoint_Descriptor +
Possible endpoint types (in bmAttributes). +
USB_ENDPOINT_TYPE_CONTROL - +Static variable in class ch.ntb.usb.Usb_Endpoint_Descriptor +
Possible endpoint types (in bmAttributes). +
USB_ENDPOINT_TYPE_INTERRUPT - +Static variable in class ch.ntb.usb.Usb_Endpoint_Descriptor +
Possible endpoint types (in bmAttributes). +
USB_ENDPOINT_TYPE_ISOCHRONOUS - +Static variable in class ch.ntb.usb.Usb_Endpoint_Descriptor +
Possible endpoint types (in bmAttributes). +
USB_ENDPOINT_TYPE_MASK - +Static variable in class ch.ntb.usb.Usb_Endpoint_Descriptor +
Endpoint type mask (in bmAttributes). +
usb_find_busses() - +Static method in class ch.ntb.usb.LibusbJava +
usb_find_busses will find all of the busses on the system. +
usb_find_devices() - +Static method in class ch.ntb.usb.LibusbJava +
usb_find_devices will find all of the devices on each bus. +
usb_get_busses() - +Static method in class ch.ntb.usb.LibusbJava +
usb_get_busses returns a tree of descriptor objects. +
usb_get_descriptor(int, byte, byte, int) - +Static method in class ch.ntb.usb.LibusbJava +
Retrieves a descriptor from the device identified by the type and index + of the descriptor from the default control pipe. +
usb_get_descriptor_by_endpoint(int, int, byte, byte, int) - +Static method in class ch.ntb.usb.LibusbJava +
Retrieves a descriptor from the device identified by the type and index + of the descriptor from the control pipe identified by ep. +
usb_get_string(int, int, int) - +Static method in class ch.ntb.usb.LibusbJava +
Retrieves the string descriptor specified by index and langid from a + device. +
usb_get_string_simple(int, int) - +Static method in class ch.ntb.usb.LibusbJava +
usb_get_string_simple is a wrapper around + usb_get_string that retrieves the string description + specified by index in the first language for the descriptor. +
usb_init() - +Static method in class ch.ntb.usb.LibusbJava +
Just like the name implies, usb_init sets up some internal + structures. +
Usb_Interface - Class in ch.ntb.usb
Represents an USB interface.
Usb_Interface() - +Constructor for class ch.ntb.usb.Usb_Interface +
  +
Usb_Interface_Descriptor - Class in ch.ntb.usb
Represents the descriptor of a USB interface.
Usb_Interface_Descriptor() - +Constructor for class ch.ntb.usb.Usb_Interface_Descriptor +
  +
usb_interrupt_read(int, int, byte[], int, int) - +Static method in class ch.ntb.usb.LibusbJava +
Performs a interrupt read request to the endpoint specified by ep. +
usb_interrupt_write(int, int, byte[], int, int) - +Static method in class ch.ntb.usb.LibusbJava +
Performs an interrupt write request to the endpoint specified by ep. +
USB_MAXALTSETTING - +Static variable in class ch.ntb.usb.Usb_Interface +
Maximal number of alternate settings +
USB_MAXCONFIG - +Static variable in class ch.ntb.usb.Usb_Config_Descriptor +
Maximum number of configurations per device +
USB_MAXENDPOINTS - +Static variable in class ch.ntb.usb.Usb_Endpoint_Descriptor +
Maximum number of endpoints +
USB_MAXINTERFACES - +Static variable in class ch.ntb.usb.Usb_Interface_Descriptor +
Maximum number of interfaces +
usb_open(Usb_Device) - +Static method in class ch.ntb.usb.LibusbJava +
usb_open is to be used to open up a device for use. +
usb_release_interface(int, int) - +Static method in class ch.ntb.usb.LibusbJava +
Releases a previously claimed interface +
usb_reset(int) - +Static method in class ch.ntb.usb.LibusbJava +
Resets a device by sending a RESET down the port it is connected to. +
usb_set_altinterface(int, int) - +Static method in class ch.ntb.usb.LibusbJava +
Sets the active alternate setting of the current interface +
usb_set_configuration(int, int) - +Static method in class ch.ntb.usb.LibusbJava +
Sets the active configuration of a device +
usb_set_debug(int) - +Static method in class ch.ntb.usb.LibusbJava +
Sets the debugging level of libusb. +
usb_strerror() - +Static method in class ch.ntb.usb.LibusbJava +
Returns the error string after an error occured. +
USBException - Exception in ch.ntb.usb
 
USBException(String) - +Constructor for exception ch.ntb.usb.USBException +
  +
UsbException - Exception in ztex
Signals an USB error.
UsbException(String) - +Constructor for exception ztex.UsbException +
Constructs an instance from the given error message. +
UsbException(Usb_Device, String) - +Constructor for exception ztex.UsbException +
Constructs an instance from the given device and error message. +
usbProductId() - +Method in class ztex.ZtexDevice1 +
Returns the USB product ID of the device. +
USBTimeoutException - Exception in ch.ntb.usb
 
USBTimeoutException(String) - +Constructor for exception ch.ntb.usb.USBTimeoutException +
  +
usbVendorId() - +Method in class ztex.ZtexDevice1 +
Returns the USB vendor ID of the device. +
Utils - Class in ch.ntb.usb
 
Utils() - +Constructor for class ch.ntb.usb.Utils +
  +
+
+

+V

+
+
valid() - +Method in class ztex.Ztex1 +
Returns true if ZTEX descriptor 1 is available. +
valid() - +Method in class ztex.Ztex1v1 +
Returns true if ZTEX interface 1 is available. +
valid(int, int) - +Method in class ztex.Ztex1v1 +
Returns true if ZTEX interface 1 and capability i.j are available. +
valid() - +Method in class ztex.ZtexDevice1 +
Returns true if ZTEX descriptor 1 is available. +
vendorCommand(int, String, int, int, byte[], int) - +Method in class ztex.Ztex1 +
Sends a vendor command to Endpoint 0 of the EZ-USB device. +
vendorCommand(int, String, int, int) - +Method in class ztex.Ztex1 +
Sends a vendor command with no payload data to Endpoint 0 of the EZ-USB device. +
vendorCommand(int, String) - +Method in class ztex.Ztex1 +
Sends a vendor command with no payload data and no setup data to Endpoint 0 of the EZ-USB device. +
vendorCommand2(int, String, int, int, byte[], int) - +Method in class ztex.Ztex1 +
Sends a vendor command to Endpoint 0 of the EZ-USB device and throws an UsbException if not all of the payload has been sent. +
vendorRequest(int, String, int, int, byte[], int) - +Method in class ztex.Ztex1 +
Sends a vendor request to Endpoint 0 of the EZ-USB device. +
vendorRequest(int, String, byte[], int) - +Method in class ztex.Ztex1 +
Sends a vendor request to Endpoint 0 of the EZ-USB device. +
vendorRequest2(int, String, int, int, byte[], int) - +Method in class ztex.Ztex1 +
Sends a vendor request to Endpoint 0 of the EZ-USB device and throws an UsbException if not all of the payload has been received. +
vendorRequest2(int, String, byte[], int) - +Method in class ztex.Ztex1 +
Sends a vendor request to Endpoint 0 of the EZ-USB device and throws an UsbException if not all of the payload has been received. +
+
+

+W

+
+
writeBulk(int, byte[], int, int, boolean) - +Method in class ch.ntb.usb.Device +
Write data to the device using a bulk transfer. +
writeInterrupt(int, byte[], int, int, boolean) - +Method in class ch.ntb.usb.Device +
Write data to the device using a interrupt transfer. +
+
+

+Z

+
+
ztex - package ztex
The Java API of the ZTEX EZ-USB SDK.
Ztex1 - Class in ztex
This class implements the interface-independent part of the communication protocol for the interaction with the ZTEX firmware.
Ztex1(ZtexDevice1) - +Constructor for class ztex.Ztex1 +
Constructs an instance from a given device. +
Ztex1v1 - Class in ztex
This class implements the communication protocol of the interface version 1 for the interaction with the ZTEX firmware.
Ztex1v1(ZtexDevice1) - +Constructor for class ztex.Ztex1v1 +
Constructs an instance from a given device. +
ZtexDevice1 - Class in ztex
A class representing an EZ-USB device that supports the ZTEX descriptor 1 or an unconfigured EZ-USB device.
ZtexDevice1(Usb_Device, int, int) - +Constructor for class ztex.ZtexDevice1 +
Constructs an instance from a given USB device. +
ZtexIhxFile1 - Class in ztex
Represents a firmware image with ZTEX descriptor 1 loaded from an ihx (Intel Hex format) file.
ZtexIhxFile1(String, int) - +Constructor for class ztex.ZtexIhxFile1 +
Constructs an instance from a given file name and descriptor position. +
ZtexIhxFile1(String) - +Constructor for class ztex.ZtexIhxFile1 +
Constructs an instance from a given file name. +
ZtexScanBus1 - Class in ztex
A class used for finding the EZ-USB devices on the USB.
ZtexScanBus1(int, int, boolean, boolean, int, int, int, int, int) - +Constructor for class ztex.ZtexScanBus1 +
Scans the USB for suitable devices and constructs a list of them. +
ZtexScanBus1(int, int, boolean, boolean, int) - +Constructor for class ztex.ZtexScanBus1 +
Scans the USB for suitable devices and constructs a list of them. +
ZtexScanBus1(int, int, boolean, boolean) - +Constructor for class ztex.ZtexScanBus1 +
Scans the USB for suitable devices and constructs a list of them. +
+
+A B C D E F G H I J L M N O P R S T U V W Z + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/allclasses-frame.html =================================================================== --- trunk/docs/java/allclasses-frame.html (nonexistent) +++ trunk/docs/java/allclasses-frame.html (revision 3) @@ -0,0 +1,97 @@ + + + + + + +All Classes + + + + + + + + + + + +All Classes +
+ + + + + +
AlreadyConfiguredException +
+BitstreamReadException +
+BitstreamUploadException +
+CapabilityException +
+Device +
+DeviceLostException +
+EzUsb +
+FirmwareUploadException +
+IhxFile +
+IhxFileDamagedException +
+IhxParseException +
+IncompatibleFirmwareException +
+InvalidFirmwareException +
+JInputStream +
+LibLoader +
+LibusbJava +
+USB +
+Usb_Bus +
+Usb_Config_Descriptor +
+Usb_Descriptor +
+Usb_Device +
+Usb_Device_Descriptor +
+Usb_Endpoint_Descriptor +
+Usb_Interface +
+Usb_Interface_Descriptor +
+USBException +
+UsbException +
+USBTimeoutException +
+Utils +
+Ztex1 +
+Ztex1v1 +
+ZtexDevice1 +
+ZtexIhxFile1 +
+ZtexScanBus1 +
+
+ + + Index: trunk/docs/java/constant-values.html =================================================================== --- trunk/docs/java/constant-values.html (nonexistent) +++ trunk/docs/java/constant-values.html (revision 3) @@ -0,0 +1,662 @@ + + + + + + +Constant Field Values + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Constant Field Values

+
+
+Contents + + + + + + +
+ch.ntb.*
+ +

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ch.ntb.usb.USB
+public static final intREQ_CLEAR_FEATURE1
+public static final intREQ_GET_CONFIGURATION8
+public static final intREQ_GET_DESCRIPTOR6
+public static final intREQ_GET_INTERFACE10
+public static final intREQ_GET_STATUS0
+public static final intREQ_SET_ADDRESS5
+public static final intREQ_SET_CONFIGURATION9
+public static final intREQ_SET_DESCRIPTOR7
+public static final intREQ_SET_FEATURE3
+public static final intREQ_SET_INTERFACE11
+public static final intREQ_SYNCH_FRAME12
+public static final intREQ_TYPE_DIR_DEVICE_TO_HOST128
+public static final intREQ_TYPE_DIR_HOST_TO_DEVICE0
+public static final intREQ_TYPE_RECIP_DEVICE0
+public static final intREQ_TYPE_RECIP_ENDPOINT2
+public static final intREQ_TYPE_RECIP_INTERFACE1
+public static final intREQ_TYPE_RECIP_OTHER3
+public static final intREQ_TYPE_TYPE_CLASS32
+public static final intREQ_TYPE_TYPE_RESERVED96
+public static final intREQ_TYPE_TYPE_STANDARD0
+public static final intREQ_TYPE_TYPE_VENDOR64
+ +

+ +

+ +

+ + + + + + + + + + +
ch.ntb.usb.Usb_Config_Descriptor
+public static final intUSB_MAXCONFIG8
+ +

+ +

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ch.ntb.usb.Usb_Descriptor
+public static final intUSB_DT_CONFIG2
+public static final intUSB_DT_CONFIG_SIZE9
+public static final intUSB_DT_DEVICE1
+public static final intUSB_DT_DEVICE_SIZE18
+public static final intUSB_DT_ENDPOINT5
+public static final intUSB_DT_ENDPOINT_AUDIO_SIZE9
+public static final intUSB_DT_ENDPOINT_SIZE7
+public static final intUSB_DT_HID33
+public static final intUSB_DT_HUB41
+public static final intUSB_DT_HUB_NONVAR_SIZE7
+public static final intUSB_DT_INTERFACE4
+public static final intUSB_DT_INTERFACE_SIZE9
+public static final intUSB_DT_PHYSICAL35
+public static final intUSB_DT_REPORT34
+public static final intUSB_DT_STRING3
+ +

+ +

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ch.ntb.usb.Usb_Device_Descriptor
+public static final intUSB_CLASS_AUDIO1
+public static final intUSB_CLASS_COMM2
+public static final intUSB_CLASS_DATA10
+public static final intUSB_CLASS_HID3
+public static final intUSB_CLASS_HUB9
+public static final intUSB_CLASS_MASS_STORAGE8
+public static final intUSB_CLASS_PER_INTERFACE0
+public static final intUSB_CLASS_PRINTER7
+public static final intUSB_CLASS_VENDOR_SPEC255
+ +

+ +

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ch.ntb.usb.Usb_Endpoint_Descriptor
+public static final intUSB_ENDPOINT_ADDRESS_MASK15
+public static final intUSB_ENDPOINT_DIR_MASK128
+public static final intUSB_ENDPOINT_TYPE_BULK2
+public static final intUSB_ENDPOINT_TYPE_CONTROL0
+public static final intUSB_ENDPOINT_TYPE_INTERRUPT3
+public static final intUSB_ENDPOINT_TYPE_ISOCHRONOUS1
+public static final intUSB_ENDPOINT_TYPE_MASK3
+public static final intUSB_MAXENDPOINTS32
+ +

+ +

+ +

+ + + + + + + + + + +
ch.ntb.usb.Usb_Interface
+public static final intUSB_MAXALTSETTING128
+ +

+ +

+ +

+ + + + + + + + + + +
ch.ntb.usb.Usb_Interface_Descriptor
+public static final intUSB_MAXINTERFACES32
+ +

+ +

+ +

+ + + +
+ztex.*
+ +

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ztex.Ztex1v1
+public static final intFLASH_EC_BUSY3
+public static final intFLASH_EC_CMD_ERROR1
+public static final intFLASH_EC_NO_ERROR0
+public static final intFLASH_EC_PENDING4
+public static final intFLASH_EC_READ_ERROR5
+public static final intFLASH_EC_TIMEOUT2
+public static final intFLASH_EC_WRITE_ERROR6
+ +

+ +

+ +

+ + + + + + + + + + + + + + + +
ztex.ZtexDevice1
+public static final intcypressProductId34323
+public static final intcypressVendorId1204
+ +

+ +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ch/ntb/usb/Usb_Config_Descriptor.html =================================================================== --- trunk/docs/java/ch/ntb/usb/Usb_Config_Descriptor.html (nonexistent) +++ trunk/docs/java/ch/ntb/usb/Usb_Config_Descriptor.html (revision 3) @@ -0,0 +1,526 @@ + + + + + + +Usb_Config_Descriptor + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ch.ntb.usb +
+Class Usb_Config_Descriptor

+








    +java.lang.Object








    +  extended by ch.ntb.usb.Usb_Descriptor








    +      extended by ch.ntb.usb.Usb_Config_Descriptor








    +
+
+
+
public class Usb_Config_Descriptor
extends Usb_Descriptor
+ + +

+Represents the descriptor of a USB configuration.
+ A USB device can have several different configuration.
+
+ The length of the configuration descriptor is + Usb_Descriptor.USB_DT_CONFIG_SIZE and the type is + Usb_Descriptor.USB_DT_CONFIG. +

+ +

+


+ +

+ + + +

+ + + + + + + +
+Field Summary
+static intUSB_MAXCONFIG + +
+          Maximum number of configurations per device
+ + + + + + + +
Fields inherited from class ch.ntb.usb.Usb_Descriptor
USB_DT_CONFIG, USB_DT_CONFIG_SIZE, USB_DT_DEVICE, USB_DT_DEVICE_SIZE, USB_DT_ENDPOINT, USB_DT_ENDPOINT_AUDIO_SIZE, USB_DT_ENDPOINT_SIZE, USB_DT_HID, USB_DT_HUB, USB_DT_HUB_NONVAR_SIZE, USB_DT_INTERFACE, USB_DT_INTERFACE_SIZE, USB_DT_PHYSICAL, USB_DT_REPORT, USB_DT_STRING
+  + + + + + + + + + + +
+Constructor Summary
Usb_Config_Descriptor() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ bytegetBConfigurationValue() + +
+          Returns the value to use as an argument to select this configuration (LibusbJava.usb_set_configuration(int, int)).
+ bytegetBmAttributes() + +
+          Returns the power parameters for this configuration.
+ bytegetBNumInterfaces() + +
+          Returns the number of interfaces.
+ byte[]getExtra() + +
+          Returns the data of extra descriptor(s) if available.
+ intgetExtralen() + +
+          Returns the number of bytes of the extra descriptor.
+ bytegetIConfiguration() + +
+          Returns the index of the String descriptor describing this configuration.
+ Usb_Interface[]getInterface() + +
+          Returns the USB interface descriptors.
+ bytegetMaxPower() + +
+          Returns the maximum power consumption in 2mA units.
+ shortgetWTotalLength() + +
+          Returns the total length in bytes of all descriptors.
+ java.lang.StringtoString() + +
+           
+ + + + + + + +
Methods inherited from class ch.ntb.usb.Usb_Descriptor
getBDescriptorType, getBLength
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + +

+ + + +
+Field Detail
+ +

+USB_MAXCONFIG

+








    +public static final int USB_MAXCONFIG
+
+
Maximum number of configurations per device +

+

+
See Also:
Constant Field Values
+
+ + + + + + + + +
+Constructor Detail
+ +

+Usb_Config_Descriptor

+








    +public Usb_Config_Descriptor()
+
+
+ + + + + + + + +
+Method Detail
+ +

+getBConfigurationValue

+








    +public byte getBConfigurationValue()
+
+
Returns the value to use as an argument to select this configuration (LibusbJava.usb_set_configuration(int, int)). +

+

+ +
Returns:
the value to use as an argument to select this configuration
+
+
+
+ +

+getBmAttributes

+








    +public byte getBmAttributes()
+
+
Returns the power parameters for this configuration.
+
+ Bit 7: Reserved, set to 1 (USB 1.0 Bus Powered)
+ Bit 6: Self Powered
+ Bit 5: Remote Wakeup
+ Bit 4..0: Reserved, set to 0 +

+

+ +
Returns:
the power parameters for this configuration
+
+
+
+ +

+getBNumInterfaces

+








    +public byte getBNumInterfaces()
+
+
Returns the number of interfaces.
+

+

+ +
Returns:
the number of interfaces
+
+
+
+ +

+getExtra

+








    +public byte[] getExtra()
+
+
Returns the data of extra descriptor(s) if available.
+

+

+ +
Returns:
null or a byte array with the extra descriptor data
+
+
+
+ +

+getExtralen

+








    +public int getExtralen()
+
+
Returns the number of bytes of the extra descriptor.
+

+

+ +
Returns:
the number of bytes of the extra descriptor
+
+
+
+ +

+getIConfiguration

+








    +public byte getIConfiguration()
+
+
Returns the index of the String descriptor describing this configuration.
+

+

+ +
Returns:
the index of the String descriptor
+
+
+
+ +

+getInterface

+








    +public Usb_Interface[] getInterface()
+
+
Returns the USB interface descriptors.
+

+

+ +
Returns:
the USB interface descriptors
+
+
+
+ +

+getMaxPower

+








    +public byte getMaxPower()
+
+
Returns the maximum power consumption in 2mA units.
+

+

+ +
Returns:
the maximum power consumption in 2mA units
+
+
+
+ +

+getWTotalLength

+








    +public short getWTotalLength()
+
+
Returns the total length in bytes of all descriptors.
+ When the configuration descriptor is read, it returns the entire + configuration hierarchy which includes all related interface and endpoint + descriptors. The wTotalLength field reflects the number of + bytes in the hierarchy. +

+

+ +
Returns:
the total length in bytes of all descriptors
+
+
+
+ +

+toString

+








    +public java.lang.String toString()
+
+
+
Overrides:
toString in class java.lang.Object
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ch/ntb/usb/USBTimeoutException.html =================================================================== --- trunk/docs/java/ch/ntb/usb/USBTimeoutException.html (nonexistent) +++ trunk/docs/java/ch/ntb/usb/USBTimeoutException.html (revision 3) @@ -0,0 +1,240 @@ + + + + + + +USBTimeoutException + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ch.ntb.usb +
+Class USBTimeoutException

+








    +java.lang.Object








    +  extended by java.lang.Throwable








    +      extended by java.lang.Exception








    +          extended by java.io.IOException








    +              extended by ch.ntb.usb.USBException








    +                  extended by ch.ntb.usb.USBTimeoutException








    +
+
+
All Implemented Interfaces:
java.io.Serializable
+
+
+
+
public class USBTimeoutException
extends USBException
+ + +

+

+
See Also:
Serialized Form
+
+ +

+ + + + +

+ + + + + + +
+Constructor Summary
USBTimeoutException(java.lang.String string) + +
+           
+  + + + + + + + +
+Method Summary
+ + + + + + + +
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + +

+ + + +
+Constructor Detail
+ +

+USBTimeoutException

+








    +public USBTimeoutException(java.lang.String string)
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ch/ntb/usb/LibusbJava.html =================================================================== --- trunk/docs/java/ch/ntb/usb/LibusbJava.html (nonexistent) +++ trunk/docs/java/ch/ntb/usb/LibusbJava.html (revision 3) @@ -0,0 +1,1075 @@ + + + + + + +LibusbJava + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ch.ntb.usb +
+Class LibusbJava

+








    +java.lang.Object








    +  extended by ch.ntb.usb.LibusbJava








    +
+
+
+
public class LibusbJava
extends java.lang.Object
+ + +

+This class represents the Java Native Interface to the shared library which + is (with some exceptions) a one-to-one representation of the libusb API.
+
+

Project Description

+ Java libusb is a Java wrapper for the libusb and libusb-win32 USB library. + + libusb aim is to create a + library for use by user level applications to access USB devices regardless + of OS.
+ Libusb-win32 is a port of + the USB library libusb to the + Windows operating systems. The library allows user space applications to + access any USB device on Windows in a generic way without writing any line of + kernel driver code.
+
+ The API description of this class has been copied from the libusb documentation + and adapted where neccessary.
+

+ +

+


+ +

+ + + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Field Summary
+static intERROR_BAD_FILE_DESCRIPTOR + +
+          System error codes.
+static intERROR_BUSY + +
+          System error codes.
+static intERROR_INVALID_PARAMETER + +
+          System error codes.
+static intERROR_IO_ERROR + +
+          System error codes.
+static intERROR_NO_SUCH_DEVICE_OR_ADDRESS + +
+          System error codes.
+static intERROR_NOT_ENOUGH_MEMORY + +
+          System error codes.
+static intERROR_SUCCESS + +
+          System error codes.
+static intERROR_TIMEDOUT + +
+          System error codes.
+  + + + + + + + + + + +
+Constructor Summary
LibusbJava() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static intusb_bulk_read(int dev_handle, + int ep, + byte[] bytes, + int size, + int timeout) + +
+          Performs a bulk read request to the endpoint specified by ep.
+static intusb_bulk_write(int dev_handle, + int ep, + byte[] bytes, + int size, + int timeout) + +
+          Performs a bulk write request to the endpoint specified by ep.
+static intusb_claim_interface(int dev_handle, + int interface_) + +
+          Claim an interface of a device.
+static intusb_clear_halt(int dev_handle, + int ep) + +
+          Clears any halt status on an endpoint.
+static intusb_close(int dev_handle) + +
+          usb_close closes a device opened with + usb_open.
+static intusb_control_msg(int dev_handle, + int requesttype, + int request, + int value, + int index, + byte[] bytes, + int size, + int timeout) + +
+          Performs a control request to the default control pipe on a device.
+static intusb_find_busses() + +
+          usb_find_busses will find all of the busses on the system.
+static intusb_find_devices() + +
+          usb_find_devices will find all of the devices on each bus.
+static Usb_Bususb_get_busses() + +
+          usb_get_busses returns a tree of descriptor objects.
+static java.lang.Stringusb_get_descriptor_by_endpoint(int dev_handle, + int ep, + byte type, + byte index, + int size) + +
+          Retrieves a descriptor from the device identified by the type and index + of the descriptor from the control pipe identified by ep.
+static java.lang.Stringusb_get_descriptor(int dev_handle, + byte type, + byte index, + int size) + +
+          Retrieves a descriptor from the device identified by the type and index + of the descriptor from the default control pipe.
+static java.lang.Stringusb_get_string_simple(int dev_handle, + int index) + +
+          usb_get_string_simple is a wrapper around + usb_get_string that retrieves the string description + specified by index in the first language for the descriptor.
+static java.lang.Stringusb_get_string(int dev_handle, + int index, + int langid) + +
+          Retrieves the string descriptor specified by index and langid from a + device.
+static voidusb_init() + +
+          Just like the name implies, usb_init sets up some internal + structures.
+static intusb_interrupt_read(int dev_handle, + int ep, + byte[] bytes, + int size, + int timeout) + +
+          Performs a interrupt read request to the endpoint specified by ep.
+static intusb_interrupt_write(int dev_handle, + int ep, + byte[] bytes, + int size, + int timeout) + +
+          Performs an interrupt write request to the endpoint specified by ep.
+static intusb_open(Usb_Device dev) + +
+          usb_open is to be used to open up a device for use.
+static intusb_release_interface(int dev_handle, + int interface_) + +
+          Releases a previously claimed interface
+static intusb_reset(int dev_handle) + +
+          Resets a device by sending a RESET down the port it is connected to.
+static intusb_set_altinterface(int dev_handle, + int alternate) + +
+          Sets the active alternate setting of the current interface
+static intusb_set_configuration(int dev_handle, + int configuration) + +
+          Sets the active configuration of a device
+static voidusb_set_debug(int level) + +
+          Sets the debugging level of libusb.
+static java.lang.Stringusb_strerror() + +
+          Returns the error string after an error occured.
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + +

+ + + +
+Field Detail
+ +

+ERROR_SUCCESS

+








    +public static int ERROR_SUCCESS
+
+
System error codes.
+ This list is not complete! For more error codes see the file 'errorno.h' + on your system. +

+

+
+
+
+ +

+ERROR_BAD_FILE_DESCRIPTOR

+








    +public static int ERROR_BAD_FILE_DESCRIPTOR
+
+
System error codes.
+ This list is not complete! For more error codes see the file 'errorno.h' + on your system. +

+

+
+
+
+ +

+ERROR_NO_SUCH_DEVICE_OR_ADDRESS

+








    +public static int ERROR_NO_SUCH_DEVICE_OR_ADDRESS
+
+
System error codes.
+ This list is not complete! For more error codes see the file 'errorno.h' + on your system. +

+

+
+
+
+ +

+ERROR_BUSY

+








    +public static int ERROR_BUSY
+
+
System error codes.
+ This list is not complete! For more error codes see the file 'errorno.h' + on your system. +

+

+
+
+
+ +

+ERROR_INVALID_PARAMETER

+








    +public static int ERROR_INVALID_PARAMETER
+
+
System error codes.
+ This list is not complete! For more error codes see the file 'errorno.h' + on your system. +

+

+
+
+
+ +

+ERROR_TIMEDOUT

+








    +public static int ERROR_TIMEDOUT
+
+
System error codes.
+ This list is not complete! For more error codes see the file 'errorno.h' + on your system. +

+

+
+
+
+ +

+ERROR_IO_ERROR

+








    +public static int ERROR_IO_ERROR
+
+
System error codes.
+ This list is not complete! For more error codes see the file 'errorno.h' + on your system. +

+

+
+
+
+ +

+ERROR_NOT_ENOUGH_MEMORY

+








    +public static int ERROR_NOT_ENOUGH_MEMORY
+
+
System error codes.
+ This list is not complete! For more error codes see the file 'errorno.h' + on your system. +

+

+
+
+ + + + + + + + +
+Constructor Detail
+ +

+LibusbJava

+








    +public LibusbJava()
+
+
+ + + + + + + + +
+Method Detail
+ +

+usb_set_debug

+








    +public static void usb_set_debug(int level)
+
+
Sets the debugging level of libusb.
+ + The range is from 0 to 255, where 0 disables debug output and 255 enables + all output. On application start, debugging is disabled (0). +

+

+
Parameters:
level - 0 to 255
+
+
+
+ +

+usb_init

+








    +public static void usb_init()
+
+
Just like the name implies, usb_init sets up some internal + structures. usb_init must be called before any other + libusb functions. +

+

+
+
+
+
+ +

+usb_find_busses

+








    +public static int usb_find_busses()
+
+
usb_find_busses will find all of the busses on the system. +

+

+ +
Returns:
the number of changes since previous call to this function (total + of new busses and busses removed).
+
+
+
+ +

+usb_find_devices

+








    +public static int usb_find_devices()
+
+
usb_find_devices will find all of the devices on each bus. + This should be called after usb_find_busses. +

+

+ +
Returns:
the number of changes since the previous call to this function + (total of new device and devices removed).
+
+
+
+ +

+usb_get_busses

+








    +public static Usb_Bus usb_get_busses()
+
+
usb_get_busses returns a tree of descriptor objects.
+ The tree represents the bus structure with devices, configurations, + interfaces and endpoints. Note that this is only a copy. To refresh the + information, usb_get_busses() must be called again.
+ The name of the objects contained in the tree is starting with + Usb_. +

+

+ +
Returns:
the structure of all busses and devices. Note: The + java objects are copies of the C structs.
+
+
+
+ +

+usb_open

+








    +public static int usb_open(Usb_Device dev)
+
+
usb_open is to be used to open up a device for use. + usb_open must be called before attempting to perform any + operations to the device. +

+

+
Parameters:
dev - The device to open. +
Returns:
a handle used in future communication with the device. 0 if an + error has occurred.
+
+
+
+ +

+usb_close

+








    +public static int usb_close(int dev_handle)
+
+
usb_close closes a device opened with + usb_open. +

+

+
Parameters:
dev_handle - The handle to the device. +
Returns:
0 on success or < 0 on error.
+
+
+
+ +

+usb_set_configuration

+








    +public static int usb_set_configuration(int dev_handle,








    +                                        int configuration)
+
+
Sets the active configuration of a device +

+

+
Parameters:
dev_handle - The handle to the device.
configuration - The value as specified in the descriptor field + bConfigurationValue. +
Returns:
0 on success or < 0 on error.
+
+
+
+ +

+usb_set_altinterface

+








    +public static int usb_set_altinterface(int dev_handle,








    +                                       int alternate)
+
+
Sets the active alternate setting of the current interface +

+

+
Parameters:
dev_handle - The handle to the device.
alternate - The value as specified in the descriptor field + bAlternateSetting. +
Returns:
0 on success or < 0 on error.
+
+
+
+ +

+usb_clear_halt

+








    +public static int usb_clear_halt(int dev_handle,








    +                                 int ep)
+
+
Clears any halt status on an endpoint. +

+

+
Parameters:
dev_handle - The handle to the device.
ep - The value specified in the descriptor field bEndpointAddress. +
Returns:
0 on success or < 0 on error.
+
+
+
+ +

+usb_reset

+








    +public static int usb_reset(int dev_handle)
+
+
Resets a device by sending a RESET down the port it is connected to.
+
+ Causes re-enumeration: After calling usb_reset, + the device will need to re-enumerate and thusly, requires you to find the + new device and open a new handle. The handle used to call + usb_reset will no longer work. +

+

+
Parameters:
dev_handle - The handle to the device. +
Returns:
0 on success or < 0 on error.
+
+
+
+ +

+usb_claim_interface

+








    +public static int usb_claim_interface(int dev_handle,








    +                                      int interface_)
+
+
Claim an interface of a device.
+
+ Must be called!: usb_claim_interface must be + called before you perform any operations related to this interface (like + usb_set_altinterface, usb_bulk_write, etc). +

+

+
Parameters:
dev_handle - The handle to the device.
interface_ - The value as specified in the descriptor field + bInterfaceNumber. +
Returns:
0 on success or < 0 on error.
+
+
+
+ +

+usb_release_interface

+








    +public static int usb_release_interface(int dev_handle,








    +                                        int interface_)
+
+
Releases a previously claimed interface +

+

+
Parameters:
dev_handle - The handle to the device.
interface_ - The value as specified in the descriptor field + bInterfaceNumber. +
Returns:
0 on success or < 0 on error.
+
+
+
+ +

+usb_control_msg

+








    +public static int usb_control_msg(int dev_handle,








    +                                  int requesttype,








    +                                  int request,








    +                                  int value,








    +                                  int index,








    +                                  byte[] bytes,








    +                                  int size,








    +                                  int timeout)
+
+
Performs a control request to the default control pipe on a device. The + parameters mirror the types of the same name in the USB specification. +

+

+
Parameters:
dev_handle - The handle to the device.
requesttype -
request -
value -
index -
bytes -
size -
timeout - +
Returns:
the number of bytes written/read or < 0 on error.
+
+
+
+ +

+usb_get_string

+








    +public static java.lang.String usb_get_string(int dev_handle,








    +                                              int index,








    +                                              int langid)
+
+
Retrieves the string descriptor specified by index and langid from a + device. +

+

+
Parameters:
dev_handle - The handle to the device.
index -
langid - +
Returns:
the descriptor String or null
+
+
+
+ +

+usb_get_string_simple

+








    +public static java.lang.String usb_get_string_simple(int dev_handle,








    +                                                     int index)
+
+
usb_get_string_simple is a wrapper around + usb_get_string that retrieves the string description + specified by index in the first language for the descriptor. +

+

+
Parameters:
dev_handle - The handle to the device.
index - +
Returns:
the descriptor String or null
+
+
+
+ +

+usb_get_descriptor

+








    +public static java.lang.String usb_get_descriptor(int dev_handle,








    +                                                  byte type,








    +                                                  byte index,








    +                                                  int size)
+
+
Retrieves a descriptor from the device identified by the type and index + of the descriptor from the default control pipe.
+
+ See usb_get_descriptor_by_endpoint(int, int, byte, byte, int) + for a function that allows the control endpoint to be specified. +

+

+
Parameters:
dev_handle - The handle to the device.
type -
index -
size - number of charactes which will be retrieved (the length of the + resulting String) +
Returns:
the descriptor String or null
+
+
+
+ +

+usb_get_descriptor_by_endpoint

+








    +public static java.lang.String usb_get_descriptor_by_endpoint(int dev_handle,








    +                                                              int ep,








    +                                                              byte type,








    +                                                              byte index,








    +                                                              int size)
+
+
Retrieves a descriptor from the device identified by the type and index + of the descriptor from the control pipe identified by ep. +

+

+
Parameters:
dev_handle - The handle to the device.
ep -
type -
index -
size - number of charactes which will be retrieved (the length of the + resulting String) +
Returns:
the descriptor String or null
+
+
+
+ +

+usb_bulk_write

+








    +public static int usb_bulk_write(int dev_handle,








    +                                 int ep,








    +                                 byte[] bytes,








    +                                 int size,








    +                                 int timeout)
+
+
Performs a bulk write request to the endpoint specified by ep. +

+

+
Parameters:
dev_handle - The handle to the device.
ep -
bytes -
size -
timeout - +
Returns:
the number of bytes written on success or < 0 on error.
+
+
+
+ +

+usb_bulk_read

+








    +public static int usb_bulk_read(int dev_handle,








    +                                int ep,








    +                                byte[] bytes,








    +                                int size,








    +                                int timeout)
+
+
Performs a bulk read request to the endpoint specified by ep. +

+

+
Parameters:
dev_handle - The handle to the device.
ep -
bytes -
size -
timeout - +
Returns:
the number of bytes read on success or < 0 on error.
+
+
+
+ +

+usb_interrupt_write

+








    +public static int usb_interrupt_write(int dev_handle,








    +                                      int ep,








    +                                      byte[] bytes,








    +                                      int size,








    +                                      int timeout)
+
+
Performs an interrupt write request to the endpoint specified by ep. +

+

+
Parameters:
dev_handle - The handle to the device.
ep -
bytes -
size -
timeout - +
Returns:
the number of bytes written on success or < 0 on error.
+
+
+
+ +

+usb_interrupt_read

+








    +public static int usb_interrupt_read(int dev_handle,








    +                                     int ep,








    +                                     byte[] bytes,








    +                                     int size,








    +                                     int timeout)
+
+
Performs a interrupt read request to the endpoint specified by ep. +

+

+
Parameters:
dev_handle - The handle to the device.
ep -
bytes -
size -
timeout - +
Returns:
the number of bytes read on success or < 0 on error.
+
+
+
+ +

+usb_strerror

+








    +public static java.lang.String usb_strerror()
+
+
Returns the error string after an error occured. +

+

+ +
Returns:
the last error sring.
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ch/ntb/usb/package-frame.html =================================================================== --- trunk/docs/java/ch/ntb/usb/package-frame.html (nonexistent) +++ trunk/docs/java/ch/ntb/usb/package-frame.html (revision 3) @@ -0,0 +1,69 @@ + + + + + + +ch.ntb.usb + + + + + + + + + + + +ch.ntb.usb + + + + +
+Classes  + +
+Device +
+LibLoader +
+LibusbJava +
+USB +
+Usb_Bus +
+Usb_Config_Descriptor +
+Usb_Descriptor +
+Usb_Device +
+Usb_Device_Descriptor +
+Usb_Endpoint_Descriptor +
+Usb_Interface +
+Usb_Interface_Descriptor +
+Utils
+ + + + + + +
+Exceptions  + +
+USBException +
+USBTimeoutException
+ + + + Index: trunk/docs/java/ch/ntb/usb/package-summary.html =================================================================== --- trunk/docs/java/ch/ntb/usb/package-summary.html (nonexistent) +++ trunk/docs/java/ch/ntb/usb/package-summary.html (revision 3) @@ -0,0 +1,257 @@ + + + + + + +ch.ntb.usb + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+

+Package ch.ntb.usb +

+A Java wrapper for the libusb 0.1 and libusb-win32 USB library. +

+See: +
+          Description +

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class Summary
DeviceThis class represents an USB device.
LibLoaderThis class allows to load libraries in the normal way or as a system resource (e.g. form the current .jar file).
LibusbJavaThis class represents the Java Native Interface to the shared library which + is (with some exceptions) a one-to-one representation of the libusb API.
USBThis class manages all USB devices and defines some USB specific constants.
Usb_BusRepresents an USB bus.
Usb_Config_DescriptorRepresents the descriptor of a USB configuration.
Usb_DescriptorCommon USB descriptor values.
Usb_DeviceRepresents an USB device.
Usb_Device_DescriptorRepresents the descriptor of a USB device.
Usb_Endpoint_DescriptorRepresents the descriptor of an USB endpoint.
Usb_InterfaceRepresents an USB interface.
Usb_Interface_DescriptorRepresents the descriptor of a USB interface.
Utils 
+  + +

+ +

+ + + + + + + + + + + +
+Exception Summary
USBException 
USBTimeoutException 
+  + +

+

+Package ch.ntb.usb Description +

+ +

+A Java wrapper for the libusb 0.1 and libusb-win32 USB library. +

+The Java libusb wrapper is known to work on Linux, Windows and Mac, but should work on every operating system which supports libusb and Java. +

+This software has originally been developed by members of the Computer Science Laboratory +at the University of Applied Sciences of Technology NTB, Buchs, Switzerland. +

+The main project page is http://libusbjava.sourceforge.net. +

+This version is distributed together with the Java API of the ZTEX EZ-USB SDK and bases +on the SVN version of Apr. 6, 2009. It is extended by the ability to load the (OS dependent) libraries form system ressource (e.g. in the current .jar file), +see the LibLoader Class. +

+LibusbJava.java is the JNI class to the libusbJava.so and LibusbJava.dll, respectively. +Every class starting with Usb_ represents a descriptor of the bus structure which is retrieved by +calling LibusbJava.usb_get_busses(). + +

+

Related Resources

+For more information about this project visit +http://libusbjava.sourceforge.net. +

+ +

+

+
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ch/ntb/usb/Usb_Endpoint_Descriptor.html =================================================================== --- trunk/docs/java/ch/ntb/usb/Usb_Endpoint_Descriptor.html (nonexistent) +++ trunk/docs/java/ch/ntb/usb/Usb_Endpoint_Descriptor.html (revision 3) @@ -0,0 +1,659 @@ + + + + + + +Usb_Endpoint_Descriptor + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ch.ntb.usb +
+Class Usb_Endpoint_Descriptor

+








    +java.lang.Object








    +  extended by ch.ntb.usb.Usb_Descriptor








    +      extended by ch.ntb.usb.Usb_Endpoint_Descriptor








    +
+
+
+
public class Usb_Endpoint_Descriptor
extends Usb_Descriptor
+ + +

+Represents the descriptor of an USB endpoint.
+ Endpoint descriptors are used to describe endpoints other than endpoint zero. + Endpoint zero is always assumed to be a control endpoint and is configured + before any descriptors are even requested. The host will use the information + returned from these descriptors to determine the bandwidth requirements of + the bus.
+
+ The length of the configuration descriptor is + Usb_Descriptor.USB_DT_ENDPOINT_SIZE and the type is + Usb_Descriptor.USB_DT_ENDPOINT. +

+ +

+


+ +

+ + + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Field Summary
+static intUSB_ENDPOINT_ADDRESS_MASK + +
+          Endpoint address mask (in bEndpointAddress).
+static intUSB_ENDPOINT_DIR_MASK + +
+          Endpoint address mask (in bEndpointAddress).
+static intUSB_ENDPOINT_TYPE_BULK + +
+          Possible endpoint types (in bmAttributes).
+static intUSB_ENDPOINT_TYPE_CONTROL + +
+          Possible endpoint types (in bmAttributes).
+static intUSB_ENDPOINT_TYPE_INTERRUPT + +
+          Possible endpoint types (in bmAttributes).
+static intUSB_ENDPOINT_TYPE_ISOCHRONOUS + +
+          Possible endpoint types (in bmAttributes).
+static intUSB_ENDPOINT_TYPE_MASK + +
+          Endpoint type mask (in bmAttributes).
+static intUSB_MAXENDPOINTS + +
+          Maximum number of endpoints
+ + + + + + + +
Fields inherited from class ch.ntb.usb.Usb_Descriptor
USB_DT_CONFIG, USB_DT_CONFIG_SIZE, USB_DT_DEVICE, USB_DT_DEVICE_SIZE, USB_DT_ENDPOINT, USB_DT_ENDPOINT_AUDIO_SIZE, USB_DT_ENDPOINT_SIZE, USB_DT_HID, USB_DT_HUB, USB_DT_HUB_NONVAR_SIZE, USB_DT_INTERFACE, USB_DT_INTERFACE_SIZE, USB_DT_PHYSICAL, USB_DT_REPORT, USB_DT_STRING
+  + + + + + + + + + + +
+Constructor Summary
Usb_Endpoint_Descriptor() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ bytegetBEndpointAddress() + +
+          Returns the endpoint address.
+ bytegetBInterval() + +
+          Returns the intervall for polling endpoint data transfers.
+ bytegetBmAttributes() + +
+          Returns the attributes of this endpoint.
+ bytegetBRefresh() + +
+           
+ bytegetBSynchAddress() + +
+           
+ byte[]getExtra() + +
+          Returns the data of extra descriptor(s) if available.
+ intgetExtralen() + +
+          Returns the number of bytes of the extra descriptor.
+ shortgetWMaxPacketSize() + +
+          Returns the maximum packet size of this endpoint is capable of sending or + receiving.
+ java.lang.StringtoString() + +
+           
+ + + + + + + +
Methods inherited from class ch.ntb.usb.Usb_Descriptor
getBDescriptorType, getBLength
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + +

+ + + +
+Field Detail
+ +

+USB_MAXENDPOINTS

+








    +public static final int USB_MAXENDPOINTS
+
+
Maximum number of endpoints +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_ENDPOINT_ADDRESS_MASK

+








    +public static final int USB_ENDPOINT_ADDRESS_MASK
+
+
Endpoint address mask (in bEndpointAddress). +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_ENDPOINT_DIR_MASK

+








    +public static final int USB_ENDPOINT_DIR_MASK
+
+
Endpoint address mask (in bEndpointAddress). +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_ENDPOINT_TYPE_MASK

+








    +public static final int USB_ENDPOINT_TYPE_MASK
+
+
Endpoint type mask (in bmAttributes). +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_ENDPOINT_TYPE_CONTROL

+








    +public static final int USB_ENDPOINT_TYPE_CONTROL
+
+
Possible endpoint types (in bmAttributes). +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_ENDPOINT_TYPE_ISOCHRONOUS

+








    +public static final int USB_ENDPOINT_TYPE_ISOCHRONOUS
+
+
Possible endpoint types (in bmAttributes). +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_ENDPOINT_TYPE_BULK

+








    +public static final int USB_ENDPOINT_TYPE_BULK
+
+
Possible endpoint types (in bmAttributes). +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_ENDPOINT_TYPE_INTERRUPT

+








    +public static final int USB_ENDPOINT_TYPE_INTERRUPT
+
+
Possible endpoint types (in bmAttributes). +

+

+
See Also:
Constant Field Values
+
+ + + + + + + + +
+Constructor Detail
+ +

+Usb_Endpoint_Descriptor

+








    +public Usb_Endpoint_Descriptor()
+
+
+ + + + + + + + +
+Method Detail
+ +

+getBEndpointAddress

+








    +public byte getBEndpointAddress()
+
+
Returns the endpoint address.
+
+ Bits 3..0: Endpoint number
+ Bits 6..4: Reserved. Set to zero
+ Bit 7: Direction. 0 = Out, 1 = In (ignored for control endpoints)
+

+

+ +
Returns:
the endpoint address
+
+
+
+ +

+getBInterval

+








    +public byte getBInterval()
+
+
Returns the intervall for polling endpoint data transfers.
+ Value in frame counts. Ignored for Bulk & Control eEndpoints. Isochronous + endpoints must equal 1 and field may range from 1 to 255 for interrupt + endpoints. +

+

+ +
Returns:
the intervall for polling endpoint data transfers
+
+
+
+ +

+getBmAttributes

+








    +public byte getBmAttributes()
+
+
Returns the attributes of this endpoint.
+ + Bits 1..0: Transfer Type (see USB_ENDPOINT_TYPE_XXX).
+ Bits 7..2: Reserved.
+ +








    +        If isochronous endpoint:








    +                Bits 3..2: Synchronisation type








    +                00 = No synchronisation








    +                        01 = Asynchronous








    +          10 = Adaptive








    +          11 = Synchronous








    +        Bits 5..4: Usage Type








    +        00 = Data endpoint








    +        01 = Feedback endpoint








    +        10 = Explicit feedback data endpoint








    +        11 = Reserved








    + 
+

+

+ +
Returns:
the attributes of this endpoint
+
+
+
+ +

+getBRefresh

+








    +public byte getBRefresh()
+
+
+
+
+
+
+ +

+getBSynchAddress

+








    +public byte getBSynchAddress()
+
+
+
+
+
+
+ +

+getExtra

+








    +public byte[] getExtra()
+
+
Returns the data of extra descriptor(s) if available.
+

+

+ +
Returns:
null or a byte array with the extra descriptor data
+
+
+
+ +

+getExtralen

+








    +public int getExtralen()
+
+
Returns the number of bytes of the extra descriptor.
+

+

+ +
Returns:
the number of bytes of the extra descriptor
+
+
+
+ +

+getWMaxPacketSize

+








    +public short getWMaxPacketSize()
+
+
Returns the maximum packet size of this endpoint is capable of sending or + receiving.
+

+

+ +
Returns:
the maximum packet size
+
+
+
+ +

+toString

+








    +public java.lang.String toString()
+
+
+
Overrides:
toString in class java.lang.Object
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ch/ntb/usb/Usb_Descriptor.html =================================================================== --- trunk/docs/java/ch/ntb/usb/Usb_Descriptor.html (nonexistent) +++ trunk/docs/java/ch/ntb/usb/Usb_Descriptor.html (revision 3) @@ -0,0 +1,600 @@ + + + + + + +Usb_Descriptor + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ch.ntb.usb +
+Class Usb_Descriptor

+








    +java.lang.Object








    +  extended by ch.ntb.usb.Usb_Descriptor








    +
+
+
Direct Known Subclasses:
Usb_Config_Descriptor, Usb_Device_Descriptor, Usb_Endpoint_Descriptor, Usb_Interface_Descriptor
+
+
+
+
public class Usb_Descriptor
extends java.lang.Object
+ + +

+Common USB descriptor values.
+

+ +

+


+ +

+ + + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Field Summary
+static intUSB_DT_CONFIG + +
+          Descriptor types (bDescriptorType).
+static intUSB_DT_CONFIG_SIZE + +
+          Descriptor sizes per descriptor type (bLength).
+static intUSB_DT_DEVICE + +
+          Descriptor types (bDescriptorType).
+static intUSB_DT_DEVICE_SIZE + +
+          Descriptor sizes per descriptor type (bLength).
+static intUSB_DT_ENDPOINT + +
+          Descriptor types (bDescriptorType).
+static intUSB_DT_ENDPOINT_AUDIO_SIZE + +
+          Descriptor sizes per descriptor type (bLength).
+static intUSB_DT_ENDPOINT_SIZE + +
+          Descriptor sizes per descriptor type (bLength).
+static intUSB_DT_HID + +
+          Descriptor types (bDescriptorType).
+static intUSB_DT_HUB + +
+          Descriptor types (bDescriptorType).
+static intUSB_DT_HUB_NONVAR_SIZE + +
+          Descriptor sizes per descriptor type (bLength).
+static intUSB_DT_INTERFACE + +
+          Descriptor types (bDescriptorType).
+static intUSB_DT_INTERFACE_SIZE + +
+          Descriptor sizes per descriptor type (bLength).
+static intUSB_DT_PHYSICAL + +
+          Descriptor types (bDescriptorType).
+static intUSB_DT_REPORT + +
+          Descriptor types (bDescriptorType).
+static intUSB_DT_STRING + +
+          Descriptor types (bDescriptorType).
+  + + + + + + + + + + +
+Constructor Summary
Usb_Descriptor() + +
+           
+  + + + + + + + + + + + + + + + +
+Method Summary
+ bytegetBDescriptorType() + +
+          Get the type of this descriptor.
+ bytegetBLength() + +
+          Get the size of this descriptor in bytes.
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + +

+ + + +
+Field Detail
+ +

+USB_DT_DEVICE

+








    +public static final int USB_DT_DEVICE
+
+
Descriptor types (bDescriptorType). +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_DT_CONFIG

+








    +public static final int USB_DT_CONFIG
+
+
Descriptor types (bDescriptorType). +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_DT_STRING

+








    +public static final int USB_DT_STRING
+
+
Descriptor types (bDescriptorType). +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_DT_INTERFACE

+








    +public static final int USB_DT_INTERFACE
+
+
Descriptor types (bDescriptorType). +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_DT_ENDPOINT

+








    +public static final int USB_DT_ENDPOINT
+
+
Descriptor types (bDescriptorType). +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_DT_HID

+








    +public static final int USB_DT_HID
+
+
Descriptor types (bDescriptorType). +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_DT_REPORT

+








    +public static final int USB_DT_REPORT
+
+
Descriptor types (bDescriptorType). +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_DT_PHYSICAL

+








    +public static final int USB_DT_PHYSICAL
+
+
Descriptor types (bDescriptorType). +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_DT_HUB

+








    +public static final int USB_DT_HUB
+
+
Descriptor types (bDescriptorType). +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_DT_DEVICE_SIZE

+








    +public static final int USB_DT_DEVICE_SIZE
+
+
Descriptor sizes per descriptor type (bLength). +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_DT_CONFIG_SIZE

+








    +public static final int USB_DT_CONFIG_SIZE
+
+
Descriptor sizes per descriptor type (bLength). +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_DT_INTERFACE_SIZE

+








    +public static final int USB_DT_INTERFACE_SIZE
+
+
Descriptor sizes per descriptor type (bLength). +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_DT_ENDPOINT_SIZE

+








    +public static final int USB_DT_ENDPOINT_SIZE
+
+
Descriptor sizes per descriptor type (bLength). +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_DT_ENDPOINT_AUDIO_SIZE

+








    +public static final int USB_DT_ENDPOINT_AUDIO_SIZE
+
+
Descriptor sizes per descriptor type (bLength). +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_DT_HUB_NONVAR_SIZE

+








    +public static final int USB_DT_HUB_NONVAR_SIZE
+
+
Descriptor sizes per descriptor type (bLength). +

+

+
See Also:
Constant Field Values
+
+ + + + + + + + +
+Constructor Detail
+ +

+Usb_Descriptor

+








    +public Usb_Descriptor()
+
+
+ + + + + + + + +
+Method Detail
+ +

+getBDescriptorType

+








    +public byte getBDescriptorType()
+
+
Get the type of this descriptor.
+

+

+ +
Returns:
the type of this descriptor
+
+
+
+ +

+getBLength

+








    +public byte getBLength()
+
+
Get the size of this descriptor in bytes.
+

+

+ +
Returns:
the size of this descriptor in bytes
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ch/ntb/usb/package-tree.html =================================================================== --- trunk/docs/java/ch/ntb/usb/package-tree.html (nonexistent) +++ trunk/docs/java/ch/ntb/usb/package-tree.html (revision 3) @@ -0,0 +1,162 @@ + + + + + + +ch.ntb.usb Class Hierarchy + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For Package ch.ntb.usb +

+
+
+
Package Hierarchies:
All Packages
+
+

+Class Hierarchy +

+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ch/ntb/usb/USB.html =================================================================== --- trunk/docs/java/ch/ntb/usb/USB.html (nonexistent) +++ trunk/docs/java/ch/ntb/usb/USB.html (revision 3) @@ -0,0 +1,908 @@ + + + + + + +USB + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ch.ntb.usb +
+Class USB

+








    +java.lang.Object








    +  extended by ch.ntb.usb.USB








    +
+
+
+
public class USB
extends java.lang.Object
+ + +

+This class manages all USB devices and defines some USB specific constants.
+

+ +

+


+ +

+ + + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Field Summary
+static intFULLSPEED_MAX_BULK_PACKET_SIZE + +
+          The maximum packet size of a bulk transfer when operating in fullspeed + (12 MB/s) mode.
+static intHIGHSPEED_MAX_BULK_PACKET_SIZE + +
+          The maximum packet size of a bulk transfer when operating in highspeed + (480 MB/s) mode.
+static intREQ_CLEAR_FEATURE + +
+          This request is used to clear or disable a specific feature (USB spec + 9.4.1).
+static intREQ_GET_CONFIGURATION + +
+          This request returns the current device configuration value (USB spec + 9.4.2).
+static intREQ_GET_DESCRIPTOR + +
+          This request returns the specified descriptor if the descriptor exists + (USB spec 9.4.3).
+static intREQ_GET_INTERFACE + +
+          This request returns the selected alternate setting for the specified + interface (USB spec 9.4.4).
+static intREQ_GET_STATUS + +
+          This request returns status for the specified recipient (USB spec 9.4.5).
+static intREQ_SET_ADDRESS + +
+          This request sets the device address for all future device accesses (USB + spec 9.4.6).
+static intREQ_SET_CONFIGURATION + +
+          This request sets the device configuration (USB spec 9.4.7).
+static intREQ_SET_DESCRIPTOR + +
+          This request is optional and may be used to update existing descriptors + or new descriptors may be added (USB spec 9.4.8).
+static intREQ_SET_FEATURE + +
+          This request is used to set or enable a specific feature (USB spec + 9.4.9).
+static intREQ_SET_INTERFACE + +
+          This request allows the host to select an alternate setting for the + specified interface (USB spec 9.4.10).
+static intREQ_SYNCH_FRAME + +
+          This request is used to set and then report an endpoint’s synchronization + frame (USB spec 9.4.11).
+static intREQ_TYPE_DIR_DEVICE_TO_HOST + +
+          Identifies the direction of data transfer in the second phase of the + control transfer.
+static intREQ_TYPE_DIR_HOST_TO_DEVICE + +
+          Identifies the direction of data transfer in the second phase of the + control transfer.
+static intREQ_TYPE_RECIP_DEVICE + +
+          Specifies the intended recipient of the request.
+static intREQ_TYPE_RECIP_ENDPOINT + +
+          Specifies the intended recipient of the request.
+static intREQ_TYPE_RECIP_INTERFACE + +
+          Specifies the intended recipient of the request.
+static intREQ_TYPE_RECIP_OTHER + +
+          Specifies the intended recipient of the request.
+static intREQ_TYPE_TYPE_CLASS + +
+          Specifies the type of the request.
+static intREQ_TYPE_TYPE_RESERVED + +
+          Specifies the type of the request.
+static intREQ_TYPE_TYPE_STANDARD + +
+          Specifies the type of the request.
+static intREQ_TYPE_TYPE_VENDOR + +
+          Specifies the type of the request.
+  + + + + + + + + + + +
+Constructor Summary
USB() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static Usb_BusgetBus() + +
+          Returns the root Usb_Bus element.
+static DevicegetDevice(short idVendor, + short idProduct) + +
+          See getDevice(short, short, String).
+static DevicegetDevice(short idVendor, + short idProduct, + java.lang.String filename) + +
+          Create a new device an register it in a device queue.
+static voidinit() + +
+          Explicitly calls LibusbJava.usb_init().
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + +

+ + + +
+Field Detail
+ +

+REQ_GET_STATUS

+








    +public static final int REQ_GET_STATUS
+
+
This request returns status for the specified recipient (USB spec 9.4.5). +

+

+
See Also:
Device.controlMsg(int, int, int, int, byte[], int, int, + boolean), +Constant Field Values
+
+
+ +

+REQ_CLEAR_FEATURE

+








    +public static final int REQ_CLEAR_FEATURE
+
+
This request is used to clear or disable a specific feature (USB spec + 9.4.1). +

+

+
See Also:
Device.controlMsg(int, int, int, int, byte[], int, int, + boolean), +Constant Field Values
+
+
+ +

+REQ_SET_FEATURE

+








    +public static final int REQ_SET_FEATURE
+
+
This request is used to set or enable a specific feature (USB spec + 9.4.9). +

+

+
See Also:
Device.controlMsg(int, int, int, int, byte[], int, int, + boolean), +Constant Field Values
+
+
+ +

+REQ_SET_ADDRESS

+








    +public static final int REQ_SET_ADDRESS
+
+
This request sets the device address for all future device accesses (USB + spec 9.4.6). +

+

+
See Also:
Device.controlMsg(int, int, int, int, byte[], int, int, + boolean), +Constant Field Values
+
+
+ +

+REQ_GET_DESCRIPTOR

+








    +public static final int REQ_GET_DESCRIPTOR
+
+
This request returns the specified descriptor if the descriptor exists + (USB spec 9.4.3). +

+

+
See Also:
Device.controlMsg(int, int, int, int, byte[], int, int, + boolean), +Constant Field Values
+
+
+ +

+REQ_SET_DESCRIPTOR

+








    +public static final int REQ_SET_DESCRIPTOR
+
+
This request is optional and may be used to update existing descriptors + or new descriptors may be added (USB spec 9.4.8). +

+

+
See Also:
Device.controlMsg(int, int, int, int, byte[], int, int, + boolean), +Constant Field Values
+
+
+ +

+REQ_GET_CONFIGURATION

+








    +public static final int REQ_GET_CONFIGURATION
+
+
This request returns the current device configuration value (USB spec + 9.4.2). +

+

+
See Also:
Device.controlMsg(int, int, int, int, byte[], int, int, + boolean), +Constant Field Values
+
+
+ +

+REQ_SET_CONFIGURATION

+








    +public static final int REQ_SET_CONFIGURATION
+
+
This request sets the device configuration (USB spec 9.4.7). +

+

+
See Also:
Device.controlMsg(int, int, int, int, byte[], int, int, + boolean), +Constant Field Values
+
+
+ +

+REQ_GET_INTERFACE

+








    +public static final int REQ_GET_INTERFACE
+
+
This request returns the selected alternate setting for the specified + interface (USB spec 9.4.4). +

+

+
See Also:
Device.controlMsg(int, int, int, int, byte[], int, int, + boolean), +Constant Field Values
+
+
+ +

+REQ_SET_INTERFACE

+








    +public static final int REQ_SET_INTERFACE
+
+
This request allows the host to select an alternate setting for the + specified interface (USB spec 9.4.10). +

+

+
See Also:
Device.controlMsg(int, int, int, int, byte[], int, int, + boolean), +Constant Field Values
+
+
+ +

+REQ_SYNCH_FRAME

+








    +public static final int REQ_SYNCH_FRAME
+
+
This request is used to set and then report an endpoint’s synchronization + frame (USB spec 9.4.11). +

+

+
See Also:
Device.controlMsg(int, int, int, int, byte[], int, int, + boolean), +Constant Field Values
+
+
+ +

+REQ_TYPE_DIR_HOST_TO_DEVICE

+








    +public static final int REQ_TYPE_DIR_HOST_TO_DEVICE
+
+
Identifies the direction of data transfer in the second phase of the + control transfer.
+ The state of the Direction bit is ignored if the wLength field is zero, + signifying there is no Data stage.
+ Specifies bit 7 of bmRequestType. +

+

+
See Also:
Device.controlMsg(int, int, int, int, byte[], int, int, + boolean), +Constant Field Values
+
+
+ +

+REQ_TYPE_DIR_DEVICE_TO_HOST

+








    +public static final int REQ_TYPE_DIR_DEVICE_TO_HOST
+
+
Identifies the direction of data transfer in the second phase of the + control transfer.
+ The state of the Direction bit is ignored if the wLength field is zero, + signifying there is no Data stage.
+ Specifies bit 7 of bmRequestType. +

+

+
See Also:
Device.controlMsg(int, int, int, int, byte[], int, int, + boolean), +Constant Field Values
+
+
+ +

+REQ_TYPE_TYPE_STANDARD

+








    +public static final int REQ_TYPE_TYPE_STANDARD
+
+
Specifies the type of the request.
+ Specifies bits 6..5 of bmRequestType. +

+

+
See Also:
Device.controlMsg(int, int, int, int, byte[], int, int, + boolean), +Constant Field Values
+
+
+ +

+REQ_TYPE_TYPE_CLASS

+








    +public static final int REQ_TYPE_TYPE_CLASS
+
+
Specifies the type of the request.
+ Specifies bits 6..5 of bmRequestType. +

+

+
See Also:
Device.controlMsg(int, int, int, int, byte[], int, int, + boolean), +Constant Field Values
+
+
+ +

+REQ_TYPE_TYPE_VENDOR

+








    +public static final int REQ_TYPE_TYPE_VENDOR
+
+
Specifies the type of the request.
+ Specifies bits 6..5 of bmRequestType. +

+

+
See Also:
Device.controlMsg(int, int, int, int, byte[], int, int, + boolean), +Constant Field Values
+
+
+ +

+REQ_TYPE_TYPE_RESERVED

+








    +public static final int REQ_TYPE_TYPE_RESERVED
+
+
Specifies the type of the request.
+ Specifies bits 6..5 of bmRequestType. +

+

+
See Also:
Device.controlMsg(int, int, int, int, byte[], int, int, + boolean), +Constant Field Values
+
+
+ +

+REQ_TYPE_RECIP_DEVICE

+








    +public static final int REQ_TYPE_RECIP_DEVICE
+
+
Specifies the intended recipient of the request.
+ Requests may be directed to the device, an interface on the device, or a + specific endpoint on a device. When an interface or endpoint is + specified, the wIndex field identifies the interface or endpoint.
+ Specifies bits 4..0 of bmRequestType. +

+

+
See Also:
Device.controlMsg(int, int, int, int, byte[], int, int, + boolean), +Constant Field Values
+
+
+ +

+REQ_TYPE_RECIP_INTERFACE

+








    +public static final int REQ_TYPE_RECIP_INTERFACE
+
+
Specifies the intended recipient of the request.
+ Requests may be directed to the device, an interface on the device, or a + specific endpoint on a device. When an interface or endpoint is + specified, the wIndex field identifies the interface or endpoint.
+ Specifies bits 4..0 of bmRequestType. +

+

+
See Also:
Device.controlMsg(int, int, int, int, byte[], int, int, + boolean), +Constant Field Values
+
+
+ +

+REQ_TYPE_RECIP_ENDPOINT

+








    +public static final int REQ_TYPE_RECIP_ENDPOINT
+
+
Specifies the intended recipient of the request.
+ Requests may be directed to the device, an interface on the device, or a + specific endpoint on a device. When an interface or endpoint is + specified, the wIndex field identifies the interface or endpoint.
+ Specifies bits 4..0 of bmRequestType. +

+

+
See Also:
Device.controlMsg(int, int, int, int, byte[], int, int, + boolean), +Constant Field Values
+
+
+ +

+REQ_TYPE_RECIP_OTHER

+








    +public static final int REQ_TYPE_RECIP_OTHER
+
+
Specifies the intended recipient of the request.
+ Requests may be directed to the device, an interface on the device, or a + specific endpoint on a device. When an interface or endpoint is + specified, the wIndex field identifies the interface or endpoint.
+ Specifies bits 4..0 of bmRequestType. +

+

+
See Also:
Device.controlMsg(int, int, int, int, byte[], int, int, + boolean), +Constant Field Values
+
+
+ +

+HIGHSPEED_MAX_BULK_PACKET_SIZE

+








    +public static int HIGHSPEED_MAX_BULK_PACKET_SIZE
+
+
The maximum packet size of a bulk transfer when operating in highspeed + (480 MB/s) mode. +

+

+
+
+
+ +

+FULLSPEED_MAX_BULK_PACKET_SIZE

+








    +public static int FULLSPEED_MAX_BULK_PACKET_SIZE
+
+
The maximum packet size of a bulk transfer when operating in fullspeed + (12 MB/s) mode. +

+

+
+
+ + + + + + + + +
+Constructor Detail
+ +

+USB

+








    +public USB()
+
+
+ + + + + + + + +
+Method Detail
+ +

+getDevice

+








    +public static Device getDevice(short idVendor,








    +                               short idProduct,








    +                               java.lang.String filename)
+
+
Create a new device an register it in a device queue. If the device is + already registered, a reference to it will be returned.
+

+

+
Parameters:
idVendor - the vendor id of the USB device
idProduct - the product id of the USB device
filename - an optional filename which can be used to distinguish multiple + devices with the same vendor and product id. +
Returns:
a newly created device or an already registered device
+
+
+
+ +

+getDevice

+








    +public static Device getDevice(short idVendor,








    +                               short idProduct)
+
+
See getDevice(short, short, String). The parameter + filename is set to null. +

+

+
Parameters:
idVendor -
idProduct - +
Returns:
a newly created device or an already registered device
+
+
+
+ +

+getBus

+








    +public static Usb_Bus getBus()








    +                      throws USBException
+
+
Returns the root Usb_Bus element. +

+

+ +
Returns:
the root Usb_Bus element +
Throws: +
USBException
+
+
+
+ +

+init

+








    +public static void init()
+
+
Explicitly calls LibusbJava.usb_init(). Note that you don't need + to call this procedure as it is called implicitly when creating a new + device with getDevice(short, short, String). +

+

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ch/ntb/usb/LibLoader.html =================================================================== --- trunk/docs/java/ch/ntb/usb/LibLoader.html (nonexistent) +++ trunk/docs/java/ch/ntb/usb/LibLoader.html (revision 3) @@ -0,0 +1,264 @@ + + + + + + +LibLoader + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ch.ntb.usb +
+Class LibLoader

+








    +java.lang.Object








    +  extended by ch.ntb.usb.LibLoader








    +
+
+
+
public class LibLoader
extends java.lang.Object
+ + +

+This class allows to load libraries in the normal way or as a system resource (e.g. form the current .jar file). + See below for a further description.
+

+ +

+


+ +

+ + + + +

+ + + + + + +
+Constructor Summary
LibLoader() + +
+           
+  + + + + + + + + + + + +
+Method Summary
+static voidload(java.lang.String libName) + +
+          Loads a library.
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + +

+ + + +
+Constructor Detail
+ +

+LibLoader

+








    +public LibLoader()
+
+
+ + + + + + + + +
+Method Detail
+ +

+load

+








    +public static void load(java.lang.String libName)
+
+
Loads a library. This is done in three steps.
+ 1. The library is tried to be load from the path list specified by the java.library.path property.
+ 2. The library is tried to be load from the current directory.
+ 3. The library is searched as a system resource (e.g. in the current .jar file), + copied to to temporary directory and loaded from there. Afterwards the temporary library is deleted. + The copying is necessary because libraries can't be loaded directly from .jar files.
+

+

+
Parameters:
libName - Library name (e.g. usbJava) +
Throws: +
java.lang.UnsatisfiedLinkError
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ch/ntb/usb/Device.html =================================================================== --- trunk/docs/java/ch/ntb/usb/Device.html (nonexistent) +++ trunk/docs/java/ch/ntb/usb/Device.html (revision 3) @@ -0,0 +1,859 @@ + + + + + + +Device + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ch.ntb.usb +
+Class Device

+








    +java.lang.Object








    +  extended by ch.ntb.usb.Device








    +
+
+
+
public class Device
extends java.lang.Object
+ + +

+This class represents an USB device.
+ To get an instance of an USB device use USB.getDevice(...). +

+ +

+


+ +

+ + + + +

+ + + + + + + + + + + +
+Constructor Summary
+protected Device(short idVendor, + short idProduct) + +
+           
+protected Device(short idVendor, + short idProduct, + java.lang.String filename) + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voidclose() + +
+          Release the claimed interface and close the opened device.
+ intcontrolMsg(int requestType, + int request, + int value, + int index, + byte[] data, + int size, + int timeout, + boolean reopenOnTimeout) + +
+          Performs a control request to the default control pipe on a device.
+ intgetAltinterface() + +
+          Returns the alternative interface.
+ Usb_Config_Descriptor[]getConfigDescriptors() + +
+          Returns the configuration descriptors associated with this device.
+ intgetConfiguration() + +
+          Returns the current configuration used.
+ Usb_DevicegetDevice() + +
+          Returns the Usb_Device instance associated with this device.
+ Usb_Device_DescriptorgetDeviceDescriptor() + +
+          Returns the device descriptor associated with this device.
+protected  java.lang.StringgetFilename() + +
+          Returns the optional filename which is set when there are multiple + devices with the same vendor and product id.
+ intgetIdProduct() + +
+          Returns the product ID of the device.
+ intgetIdVendor() + +
+          Returns the vendor ID of the device.
+ intgetInterface() + +
+          Returns the current interface.
+ intgetMaxPacketSize() + +
+          Returns the maximum packet size in bytes which is allowed to be + transmitted at once.
+ booleanisOpen() + +
+          Check if the device is open.
+ voidopen(int configuration, + int interface_, + int altinterface) + +
+          Opens the device and claims the specified configuration, interface and + altinterface.
+ intreadBulk(int in_ep_address, + byte[] data, + int size, + int timeout, + boolean reopenOnTimeout) + +
+          Read data from the device using a bulk transfer.
+ intreadInterrupt(int in_ep_address, + byte[] data, + int size, + int timeout, + boolean reopenOnTimeout) + +
+          Read data from the device using a interrupt transfer.
+ voidreset() + +
+          Sends an USB reset to the device.
+ voidsetResetOnFirstOpen(boolean enable, + int timeout) + +
+          If enabled, the device is reset when first opened.
+ voidupdateDescriptors() + +
+          Updates the device and descriptor information from the bus.
+ intwriteBulk(int out_ep_address, + byte[] data, + int size, + int timeout, + boolean reopenOnTimeout) + +
+          Write data to the device using a bulk transfer.
+ intwriteInterrupt(int out_ep_address, + byte[] data, + int size, + int timeout, + boolean reopenOnTimeout) + +
+          Write data to the device using a interrupt transfer.
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + +

+ + + +
+Constructor Detail
+ +

+Device

+








    +protected Device(short idVendor,








    +                 short idProduct)
+
+
+
+ +

+Device

+








    +protected Device(short idVendor,








    +                 short idProduct,








    +                 java.lang.String filename)
+
+
+ + + + + + + + +
+Method Detail
+ +

+updateDescriptors

+








    +public void updateDescriptors()








    +                       throws USBException
+
+
Updates the device and descriptor information from the bus.
+ The descriptors can be read with getDeviceDescriptor() and + getConfigDescriptors(). +

+

+ +
Throws: +
USBException
+
+
+
+ +

+getDeviceDescriptor

+








    +public Usb_Device_Descriptor getDeviceDescriptor()
+
+
Returns the device descriptor associated with this device.
+ The descriptor is updated by calling updateDescriptors() or + open(int, int, int). +

+

+ +
Returns:
the device descriptor associated with this device or + null
+
+
+
+ +

+getConfigDescriptors

+








    +public Usb_Config_Descriptor[] getConfigDescriptors()
+
+
Returns the configuration descriptors associated with this device.
+ The descriptors are updated by calling updateDescriptors() or + open(int, int, int). +

+

+ +
Returns:
the configuration descriptors associated with this device or + null
+
+
+
+ +

+open

+








    +public void open(int configuration,








    +                 int interface_,








    +                 int altinterface)








    +          throws USBException
+
+
Opens the device and claims the specified configuration, interface and + altinterface.
+ First the bus is enumerated. If the device is found its descriptors are + read and the maxPacketSize value is updated. If no + endpoints are found in the descriptors an exception is thrown. +

+

+
Parameters:
configuration - the configuration, see + Usb_Config_Descriptor.getBConfigurationValue()
interface_ - the interface, see + Usb_Interface_Descriptor.getBInterfaceNumber()
altinterface - the alternate interface, see + Usb_Interface_Descriptor.getBAlternateSetting(). If + no alternate interface must be set -1 can be used. +
Throws: +
USBException
+
+
+
+ +

+close

+








    +public void close()








    +           throws USBException
+
+
Release the claimed interface and close the opened device.
+

+

+ +
Throws: +
USBException
+
+
+
+ +

+reset

+








    +public void reset()








    +           throws USBException
+
+
Sends an USB reset to the device. The device handle will no longer be + valid. To use the device again, open(int, int, int) must be + called. +

+

+ +
Throws: +
USBException
+
+
+
+ +

+writeBulk

+








    +public int writeBulk(int out_ep_address,








    +                     byte[] data,








    +                     int size,








    +                     int timeout,








    +                     boolean reopenOnTimeout)








    +              throws USBException
+
+
Write data to the device using a bulk transfer.
+

+

+
Parameters:
out_ep_address - endpoint address to write to
data - data to write to this endpoint
size - size of the data
timeout - amount of time in ms the device will try to send the data + until a timeout exception is thrown
reopenOnTimeout - if set to true, the device will try to open the connection and + send the data again before a timeout exception is thrown +
Returns:
the actual number of bytes written +
Throws: +
USBException
+
+
+
+ +

+readBulk

+








    +public int readBulk(int in_ep_address,








    +                    byte[] data,








    +                    int size,








    +                    int timeout,








    +                    boolean reopenOnTimeout)








    +             throws USBException
+
+
Read data from the device using a bulk transfer.
+

+

+
Parameters:
in_ep_address - endpoint address to read from
data - data buffer for the data to be read
size - the maximum requested data size
timeout - amount of time in ms the device will try to receive data until + a timeout exception is thrown
reopenOnTimeout - if set to true, the device will try to open the connection and + receive the data again before a timeout exception is thrown +
Returns:
the actual number of bytes read +
Throws: +
USBException
+
+
+
+ +

+writeInterrupt

+








    +public int writeInterrupt(int out_ep_address,








    +                          byte[] data,








    +                          int size,








    +                          int timeout,








    +                          boolean reopenOnTimeout)








    +                   throws USBException
+
+
Write data to the device using a interrupt transfer.
+

+

+
Parameters:
out_ep_address - endpoint address to write to
data - data to write to this endpoint
size - size of the data
timeout - amount of time in ms the device will try to send the data + until a timeout exception is thrown
reopenOnTimeout - if set to true, the device will try to open the connection and + send the data again before a timeout exception is thrown +
Returns:
the actual number of bytes written +
Throws: +
USBException
+
+
+
+ +

+readInterrupt

+








    +public int readInterrupt(int in_ep_address,








    +                         byte[] data,








    +                         int size,








    +                         int timeout,








    +                         boolean reopenOnTimeout)








    +                  throws USBException
+
+
Read data from the device using a interrupt transfer.
+

+

+
Parameters:
in_ep_address - endpoint address to read from
data - data buffer for the data to be read
size - the maximum requested data size
timeout - amount of time in ms the device will try to receive data until + a timeout exception is thrown
reopenOnTimeout - if set to true, the device will try to open the connection and + receive the data again before a timeout exception is thrown +
Returns:
the actual number of bytes read +
Throws: +
USBException
+
+
+
+ +

+controlMsg

+








    +public int controlMsg(int requestType,








    +                      int request,








    +                      int value,








    +                      int index,








    +                      byte[] data,








    +                      int size,








    +                      int timeout,








    +                      boolean reopenOnTimeout)








    +               throws USBException
+
+
Performs a control request to the default control pipe on a device.
+ The parameters mirror the types of the same name in the USB + specification. +

+

+
Parameters:
requestType - USB device request type (USB specification 9.3, + bmRequestType). Use constants from USB + (REQ_TYPE_xxx).
request - specific request (USB specification 9.4, bRequest). Use + constants from USB (REQ_xxx).
value - field that varies according to request (USB specification 9.4, + wValue)
index - field that varies according to request (USB specification 9.4, + wIndex)
data - the send/receive buffer
size - the buffer size. 0 is a valid value, but there must still be a + dummy data buffer provided.
timeout - amount of time in ms the device will try to send/receive data + until a timeout exception is thrown
reopenOnTimeout - if set to true, the device will try to open the connection and + send/receive the data again before a timeout exception is + thrown +
Returns:
the number of bytes written/read +
Throws: +
USBException
+
+
+
+ +

+getIdProduct

+








    +public int getIdProduct()
+
+
Returns the product ID of the device.
+

+

+ +
Returns:
the product ID of the device.
+
+
+
+ +

+getIdVendor

+








    +public int getIdVendor()
+
+
Returns the vendor ID of the device.
+

+

+ +
Returns:
the vendor ID of the device.
+
+
+
+ +

+getAltinterface

+








    +public int getAltinterface()
+
+
Returns the alternative interface.
+ This value is only valid after opening the device. +

+

+ +
Returns:
the alternative interface. This value is only valid after opening + the device.
+
+
+
+ +

+getConfiguration

+








    +public int getConfiguration()
+
+
Returns the current configuration used.
+ This value is only valid after opening the device. +

+

+ +
Returns:
the current configuration used. This value is only valid after + opening the device.
+
+
+
+ +

+getInterface

+








    +public int getInterface()
+
+
Returns the current interface.
+ This value is only valid after opening the device. +

+

+ +
Returns:
the current interface. This value is only valid after opening the + device.
+
+
+
+ +

+getMaxPacketSize

+








    +public int getMaxPacketSize()
+
+
Returns the maximum packet size in bytes which is allowed to be + transmitted at once.
+ The value is determined by reading the endpoint descriptor(s) when + opening the device. It is invalid before the device is opened! Note that + if some endpoints use different packet sizes the maximum packet size is + return. This value may be used to determine if a device is opened in + fullspeed or highspeed mode. +

+

+ +
Returns:
the maximum packet size
+
+
+
+ +

+isOpen

+








    +public boolean isOpen()
+
+
Check if the device is open.
+ This checks only for a valid device handle. It doesn't check if the + device is still attached or working. +

+

+ +
Returns:
true if the device is open
+
+
+
+ +

+setResetOnFirstOpen

+








    +public void setResetOnFirstOpen(boolean enable,








    +                                int timeout)
+
+
If enabled, the device is reset when first opened.
+ This will only happen once. When the application is started, the device + state is unknown. If the device is not reset, read or write may result in + a USBTimeoutException.
+
+ This feature is disabled by default. +

+

+
Parameters:
enable - true if the device should be reset when first opened
timeout - the timeout between the reset and the reopening
+
+
+
+ +

+getFilename

+








    +protected java.lang.String getFilename()
+
+
Returns the optional filename which is set when there are multiple + devices with the same vendor and product id. See + USB.getDevice(short, short, String). Use + Usb_Device.getFilename() to read the filename of a device. +

+

+ +
Returns:
the filename if set or null
+
+
+
+ +

+getDevice

+








    +public Usb_Device getDevice()
+
+
Returns the Usb_Device instance associated with this device. This value + is only valid after opening the device. +

+

+ +
Returns:
the Usb_Device instance associated with this device.
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ch/ntb/usb/Utils.html =================================================================== --- trunk/docs/java/ch/ntb/usb/Utils.html (nonexistent) +++ trunk/docs/java/ch/ntb/usb/Utils.html (revision 3) @@ -0,0 +1,271 @@ + + + + + + +Utils + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ch.ntb.usb +
+Class Utils

+








    +java.lang.Object








    +  extended by ch.ntb.usb.Utils








    +
+
+
+
public class Utils
extends java.lang.Object
+ + +

+


+ +

+ + + + +

+ + + + + + +
+Constructor Summary
Utils() + +
+           
+  + + + + + + + + + + + + + + + +
+Method Summary
+static voidlogBus(Usb_Bus bus) + +
+           
+static voidlogBus(Usb_Bus bus, + java.io.PrintStream out) + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + +

+ + + +
+Constructor Detail
+ +

+Utils

+








    +public Utils()
+
+
+ + + + + + + + +
+Method Detail
+ +

+logBus

+








    +public static void logBus(Usb_Bus bus)
+
+
+
+
+
+
+ +

+logBus

+








    +public static void logBus(Usb_Bus bus,








    +                          java.io.PrintStream out)
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ch/ntb/usb/Usb_Bus.html =================================================================== --- trunk/docs/java/ch/ntb/usb/Usb_Bus.html (nonexistent) +++ trunk/docs/java/ch/ntb/usb/Usb_Bus.html (revision 3) @@ -0,0 +1,391 @@ + + + + + + +Usb_Bus + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ch.ntb.usb +
+Class Usb_Bus

+








    +java.lang.Object








    +  extended by ch.ntb.usb.Usb_Bus








    +
+
+
+
public class Usb_Bus
extends java.lang.Object
+ + +

+Represents an USB bus.
+ This is the root class for the representation of the libusb USB structure. + Zero or more devices may be connected to an USB bus. +

+ +

+


+ +

+ + + + +

+ + + + + + +
+Constructor Summary
Usb_Bus() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ Usb_DevicegetDevices() + +
+          Get the first device ojects of the devices linked list.
+ java.lang.StringgetDirname() + +
+          Returns the systems String representation of the bus.
+ longgetLocation() + +
+          Returns the location in the USB bus linked list.
+ Usb_BusgetNext() + +
+          Returns the next bus object.
+ Usb_BusgetPrev() + +
+          Returns the previous bus object.
+ Usb_DevicegetRootDev() + +
+          Get the root device of this bus.
+ java.lang.StringtoString() + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + +

+ + + +
+Constructor Detail
+ +

+Usb_Bus

+








    +public Usb_Bus()
+
+
+ + + + + + + + +
+Method Detail
+ +

+getDevices

+








    +public Usb_Device getDevices()
+
+
Get the first device ojects of the devices linked list.
+

+

+ +
Returns:
the first device ojects of the devices linked list or null
+
+
+
+ +

+getDirname

+








    +public java.lang.String getDirname()
+
+
Returns the systems String representation of the bus.
+

+

+ +
Returns:
the systems String representation of the bus
+
+
+
+ +

+getNext

+








    +public Usb_Bus getNext()
+
+
Returns the next bus object.
+

+

+ +
Returns:
Returns the next bus object or null
+
+
+
+ +

+getPrev

+








    +public Usb_Bus getPrev()
+
+
Returns the previous bus object.
+

+

+ +
Returns:
Returns the previous bus object or null
+
+
+
+ +

+getRootDev

+








    +public Usb_Device getRootDev()
+
+
Get the root device of this bus.
+

+

+ +
Returns:
the root device oject or null
+
+
+
+ +

+getLocation

+








    +public long getLocation()
+
+
Returns the location in the USB bus linked list.
+

+

+ +
Returns:
the location in the USB bus linked list
+
+
+
+ +

+toString

+








    +public java.lang.String toString()
+
+
+
Overrides:
toString in class java.lang.Object
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ch/ntb/usb/Usb_Device_Descriptor.html =================================================================== --- trunk/docs/java/ch/ntb/usb/Usb_Device_Descriptor.html (nonexistent) +++ trunk/docs/java/ch/ntb/usb/Usb_Device_Descriptor.html (revision 3) @@ -0,0 +1,772 @@ + + + + + + +Usb_Device_Descriptor + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ch.ntb.usb +
+Class Usb_Device_Descriptor

+








    +java.lang.Object








    +  extended by ch.ntb.usb.Usb_Descriptor








    +      extended by ch.ntb.usb.Usb_Device_Descriptor








    +
+
+
+
public class Usb_Device_Descriptor
extends Usb_Descriptor
+ + +

+Represents the descriptor of a USB device.
+ A USB device can only have one device descriptor. It specifies some basic, + yet important information about the device.
+
+ The length of the device descriptor is + Usb_Descriptor.USB_DT_DEVICE_SIZE and the type is + Usb_Descriptor.USB_DT_DEVICE. +

+ +

+


+ +

+ + + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Field Summary
+static intUSB_CLASS_AUDIO + +
+          Device and/or interface class codes.
+static intUSB_CLASS_COMM + +
+          Device and/or interface class codes.
+static intUSB_CLASS_DATA + +
+          Device and/or interface class codes.
+static intUSB_CLASS_HID + +
+          Device and/or interface class codes.
+static intUSB_CLASS_HUB + +
+          Device and/or interface class codes.
+static intUSB_CLASS_MASS_STORAGE + +
+          Device and/or interface class codes.
+static intUSB_CLASS_PER_INTERFACE + +
+          Device and/or interface class codes.
+static intUSB_CLASS_PRINTER + +
+          Device and/or interface class codes.
+static intUSB_CLASS_VENDOR_SPEC + +
+          Device and/or interface class codes.
+ + + + + + + +
Fields inherited from class ch.ntb.usb.Usb_Descriptor
USB_DT_CONFIG, USB_DT_CONFIG_SIZE, USB_DT_DEVICE, USB_DT_DEVICE_SIZE, USB_DT_ENDPOINT, USB_DT_ENDPOINT_AUDIO_SIZE, USB_DT_ENDPOINT_SIZE, USB_DT_HID, USB_DT_HUB, USB_DT_HUB_NONVAR_SIZE, USB_DT_INTERFACE, USB_DT_INTERFACE_SIZE, USB_DT_PHYSICAL, USB_DT_REPORT, USB_DT_STRING
+  + + + + + + + + + + +
+Constructor Summary
Usb_Device_Descriptor() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ shortgetBcdDevice() + +
+          Returns the device release number.
+ shortgetBcdUSB() + +
+          Returns the USB specification number to which the device complies to.
+ bytegetBDeviceClass() + +
+          Returns the class code (Assigned by www.usb.org)
+ If equal to zero, each interface specifies it's own class code.
+ bytegetBDeviceProtocol() + +
+          Returns the protocol code (Assigned by www.usb.org)
+ bytegetBDeviceSubClass() + +
+          Returns the subclass code (Assigned by www.usb.org)
+ bytegetBMaxPacketSize0() + +
+          Returns the maximum packet size for endpoint zero.
+ bytegetBNumConfigurations() + +
+          Returns the number of possible configurations supported at its current + speed.
+ shortgetIdProduct() + +
+          Returns the product ID (Assigned by www.usb.org)
+ shortgetIdVendor() + +
+          Returns the Vendor ID (Assigned by www.usb.org)
+ bytegetIManufacturer() + +
+          Returns the index of the manufacturer string descriptor.
+ bytegetIProduct() + +
+          Returns the index of the product string descriptor.
+ bytegetISerialNumber() + +
+          Returns the index of serial number string descriptor.
+ java.lang.StringtoString() + +
+           
+ + + + + + + +
Methods inherited from class ch.ntb.usb.Usb_Descriptor
getBDescriptorType, getBLength
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + +

+ + + +
+Field Detail
+ +

+USB_CLASS_PER_INTERFACE

+








    +public static final int USB_CLASS_PER_INTERFACE
+
+
Device and/or interface class codes. +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_CLASS_AUDIO

+








    +public static final int USB_CLASS_AUDIO
+
+
Device and/or interface class codes. +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_CLASS_COMM

+








    +public static final int USB_CLASS_COMM
+
+
Device and/or interface class codes. +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_CLASS_HID

+








    +public static final int USB_CLASS_HID
+
+
Device and/or interface class codes. +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_CLASS_PRINTER

+








    +public static final int USB_CLASS_PRINTER
+
+
Device and/or interface class codes. +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_CLASS_MASS_STORAGE

+








    +public static final int USB_CLASS_MASS_STORAGE
+
+
Device and/or interface class codes. +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_CLASS_HUB

+








    +public static final int USB_CLASS_HUB
+
+
Device and/or interface class codes. +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_CLASS_DATA

+








    +public static final int USB_CLASS_DATA
+
+
Device and/or interface class codes. +

+

+
See Also:
Constant Field Values
+
+
+ +

+USB_CLASS_VENDOR_SPEC

+








    +public static final int USB_CLASS_VENDOR_SPEC
+
+
Device and/or interface class codes. +

+

+
See Also:
Constant Field Values
+
+ + + + + + + + +
+Constructor Detail
+ +

+Usb_Device_Descriptor

+








    +public Usb_Device_Descriptor()
+
+
+ + + + + + + + +
+Method Detail
+ +

+getBcdDevice

+








    +public short getBcdDevice()
+
+
Returns the device release number.
+ Assigned by the manufacturer of the device. +

+

+ +
Returns:
the device release number
+
+
+
+ +

+getBcdUSB

+








    +public short getBcdUSB()
+
+
Returns the USB specification number to which the device complies to.
+ This field reports the highest version of USB the device supports. The + value is in binary coded decimal with a format of 0xJJMN where JJ is the + major version number, M is the minor version number and N is the sub + minor version number.
+ Examples: USB 2.0 is reported as 0x0200, USB 1.1 as 0x0110 and USB 1.0 as + 0x100 +

+

+ +
Returns:
the USB specification number to which the device complies to
+
+
+
+ +

+getBDeviceClass

+








    +public byte getBDeviceClass()
+
+
Returns the class code (Assigned by www.usb.org)
+ If equal to zero, each interface specifies it's own class code. If equal + to 0xFF, the class code is vendor specified. Otherwise the field is a + valid class code. +

+

+ +
Returns:
the class code
+
+
+
+ +

+getBDeviceProtocol

+








    +public byte getBDeviceProtocol()
+
+
Returns the protocol code (Assigned by www.usb.org)
+

+

+ +
Returns:
the protocol code
+
+
+
+ +

+getBDeviceSubClass

+








    +public byte getBDeviceSubClass()
+
+
Returns the subclass code (Assigned by www.usb.org)
+

+

+ +
Returns:
the subclass code
+
+
+
+ +

+getBMaxPacketSize0

+








    +public byte getBMaxPacketSize0()
+
+
Returns the maximum packet size for endpoint zero.
+ Valid sizes are 8, 16, 32, 64. +

+

+ +
Returns:
the maximum packet size for endpoint zero
+
+
+
+ +

+getBNumConfigurations

+








    +public byte getBNumConfigurations()
+
+
Returns the number of possible configurations supported at its current + speed.
+

+

+ +
Returns:
the number of possible configurations supported at its current + speed
+
+
+
+ +

+getIdProduct

+








    +public short getIdProduct()
+
+
Returns the product ID (Assigned by www.usb.org)
+

+

+ +
Returns:
the product ID
+
+
+
+ +

+getIdVendor

+








    +public short getIdVendor()
+
+
Returns the Vendor ID (Assigned by www.usb.org)
+

+

+ +
Returns:
the Vendor ID
+
+
+
+ +

+getIManufacturer

+








    +public byte getIManufacturer()
+
+
Returns the index of the manufacturer string descriptor.
+ If this value is 0, no string descriptor is used. +

+

+ +
Returns:
the index of the manufacturer string descriptor
+
+
+
+ +

+getIProduct

+








    +public byte getIProduct()
+
+
Returns the index of the product string descriptor.
+ If this value is 0, no string descriptor is used. +

+

+ +
Returns:
the index of the product string descriptor
+
+
+
+ +

+getISerialNumber

+








    +public byte getISerialNumber()
+
+
Returns the index of serial number string descriptor.
+ If this value is 0, no string descriptor is used. +

+

+ +
Returns:
the index of serial number string descriptor
+
+
+
+ +

+toString

+








    +public java.lang.String toString()
+
+
+
Overrides:
toString in class java.lang.Object
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ch/ntb/usb/Usb_Interface_Descriptor.html =================================================================== --- trunk/docs/java/ch/ntb/usb/Usb_Interface_Descriptor.html (nonexistent) +++ trunk/docs/java/ch/ntb/usb/Usb_Interface_Descriptor.html (revision 3) @@ -0,0 +1,546 @@ + + + + + + +Usb_Interface_Descriptor + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ch.ntb.usb +
+Class Usb_Interface_Descriptor

+








    +java.lang.Object








    +  extended by ch.ntb.usb.Usb_Descriptor








    +      extended by ch.ntb.usb.Usb_Interface_Descriptor








    +
+
+
+
public class Usb_Interface_Descriptor
extends Usb_Descriptor
+ + +

+Represents the descriptor of a USB interface.
+ The interface descriptor could be seen as a header or grouping of the + endpoints into a functional group performing a single feature of the device.
+
+ The length of the interface descriptor is + Usb_Descriptor.USB_DT_INTERFACE_SIZE and the type is + Usb_Descriptor.USB_DT_INTERFACE. +

+ +

+


+ +

+ + + +

+ + + + + + + +
+Field Summary
+static intUSB_MAXINTERFACES + +
+          Maximum number of interfaces
+ + + + + + + +
Fields inherited from class ch.ntb.usb.Usb_Descriptor
USB_DT_CONFIG, USB_DT_CONFIG_SIZE, USB_DT_DEVICE, USB_DT_DEVICE_SIZE, USB_DT_ENDPOINT, USB_DT_ENDPOINT_AUDIO_SIZE, USB_DT_ENDPOINT_SIZE, USB_DT_HID, USB_DT_HUB, USB_DT_HUB_NONVAR_SIZE, USB_DT_INTERFACE, USB_DT_INTERFACE_SIZE, USB_DT_PHYSICAL, USB_DT_REPORT, USB_DT_STRING
+  + + + + + + + + + + +
+Constructor Summary
Usb_Interface_Descriptor() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ bytegetBAlternateSetting() + +
+          Returns the value used to select the alternate setting (LibusbJava.usb_set_altinterface(int, int)).
+ bytegetBInterfaceClass() + +
+          Returns the class code (Assigned by www.usb.org).
+ bytegetBInterfaceNumber() + +
+          Returns the number (identifier) of this interface.
+ bytegetBInterfaceProtocol() + +
+          Returns the protocol code (Assigned by www.usb.org).
+ bytegetBInterfaceSubClass() + +
+          Returns the subclass code (Assigned by www.usb.org).
+ bytegetBNumEndpoints() + +
+          Returns the number of endpoints used for this interface.
+ Usb_Endpoint_Descriptor[]getEndpoint() + +
+          Returns an array of endpoint descriptors.
+ byte[]getExtra() + +
+          Returns the data of extra descriptor(s) if available.
+ intgetExtralen() + +
+          Returns the number of bytes of the extra descriptor.
+ bytegetIInterface() + +
+          Returns the index of the String descriptor describing this interface.
+ java.lang.StringtoString() + +
+           
+ + + + + + + +
Methods inherited from class ch.ntb.usb.Usb_Descriptor
getBDescriptorType, getBLength
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + +

+ + + +
+Field Detail
+ +

+USB_MAXINTERFACES

+








    +public static final int USB_MAXINTERFACES
+
+
Maximum number of interfaces +

+

+
See Also:
Constant Field Values
+
+ + + + + + + + +
+Constructor Detail
+ +

+Usb_Interface_Descriptor

+








    +public Usb_Interface_Descriptor()
+
+
+ + + + + + + + +
+Method Detail
+ +

+toString

+








    +public java.lang.String toString()
+
+
+
Overrides:
toString in class java.lang.Object
+
+
+
+
+
+
+ +

+getBAlternateSetting

+








    +public byte getBAlternateSetting()
+
+
Returns the value used to select the alternate setting (LibusbJava.usb_set_altinterface(int, int)).
+

+

+ +
Returns:
the alternate setting
+
+
+
+ +

+getBInterfaceClass

+








    +public byte getBInterfaceClass()
+
+
Returns the class code (Assigned by www.usb.org).
+

+

+ +
Returns:
the class code
+
+
+
+ +

+getBInterfaceNumber

+








    +public byte getBInterfaceNumber()
+
+
Returns the number (identifier) of this interface.
+

+

+ +
Returns:
the number (identifier) of this interface
+
+
+
+ +

+getBInterfaceProtocol

+








    +public byte getBInterfaceProtocol()
+
+
Returns the protocol code (Assigned by www.usb.org).
+

+

+ +
Returns:
the protocol code
+
+
+
+ +

+getBInterfaceSubClass

+








    +public byte getBInterfaceSubClass()
+
+
Returns the subclass code (Assigned by www.usb.org).
+

+

+ +
Returns:
the subclass code
+
+
+
+ +

+getBNumEndpoints

+








    +public byte getBNumEndpoints()
+
+
Returns the number of endpoints used for this interface.
+

+

+ +
Returns:
the number of endpoints used for this interface
+
+
+
+ +

+getEndpoint

+








    +public Usb_Endpoint_Descriptor[] getEndpoint()
+
+
Returns an array of endpoint descriptors.
+

+

+ +
Returns:
an array of endpoint descriptors
+
+
+
+ +

+getExtra

+








    +public byte[] getExtra()
+
+
Returns the data of extra descriptor(s) if available.
+

+

+ +
Returns:
null or a byte array with the extra descriptor data
+
+
+
+ +

+getExtralen

+








    +public int getExtralen()
+
+
Returns the number of bytes of the extra descriptor.
+

+

+ +
Returns:
the number of bytes of the extra descriptor
+
+
+
+ +

+getIInterface

+








    +public byte getIInterface()
+
+
Returns the index of the String descriptor describing this interface.
+

+

+ +
Returns:
the index of the String descriptor
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ch/ntb/usb/Usb_Device.html =================================================================== --- trunk/docs/java/ch/ntb/usb/Usb_Device.html (nonexistent) +++ trunk/docs/java/ch/ntb/usb/Usb_Device.html (revision 3) @@ -0,0 +1,457 @@ + + + + + + +Usb_Device + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ch.ntb.usb +
+Class Usb_Device

+








    +java.lang.Object








    +  extended by ch.ntb.usb.Usb_Device








    +
+
+
+
public class Usb_Device
extends java.lang.Object
+ + +

+Represents an USB device.
+ An USB device has one device descriptor and it may have multiple + configuration descriptors. +

+ +

+


+ +

+ + + + +

+ + + + + + +
+Constructor Summary
Usb_Device() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ Usb_BusgetBus() + +
+          Returns the reference to the bus to which this device is connected.
+ Usb_DevicegetChildren() + +
+          Returns a reference to the first child.
+ Usb_Config_Descriptor[]getConfig() + +
+          Returns the USB config descriptors.
+ Usb_Device_DescriptorgetDescriptor() + +
+          Returns the USB device descriptor.
+ bytegetDevnum() + +
+          Returns the number assigned to this device.
+ java.lang.StringgetFilename() + +
+          Returns the systems String representation.
+ Usb_DevicegetNext() + +
+          Returns the pointer to the next device.
+ bytegetNumChildren() + +
+          Returns the number of children of this device.
+ Usb_DevicegetPrev() + +
+          Returns the pointer to the previous device.
+ java.lang.StringtoString() + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + +

+ + + +
+Constructor Detail
+ +

+Usb_Device

+








    +public Usb_Device()
+
+
+ + + + + + + + +
+Method Detail
+ +

+getBus

+








    +public Usb_Bus getBus()
+
+
Returns the reference to the bus to which this device is connected.
+

+

+ +
Returns:
the reference to the bus to which this device is connected
+
+
+
+ +

+getChildren

+








    +public Usb_Device getChildren()
+
+
Returns a reference to the first child.
+

+

+ +
Returns:
a reference to the first child
+
+
+
+ +

+getConfig

+








    +public Usb_Config_Descriptor[] getConfig()
+
+
Returns the USB config descriptors.
+

+

+ +
Returns:
the USB config descriptors
+
+
+
+ +

+getDescriptor

+








    +public Usb_Device_Descriptor getDescriptor()
+
+
Returns the USB device descriptor.
+

+

+ +
Returns:
the USB device descriptor
+
+
+
+ +

+getDevnum

+








    +public byte getDevnum()
+
+
Returns the number assigned to this device.
+

+

+ +
Returns:
the number assigned to this device
+
+
+
+ +

+getFilename

+








    +public java.lang.String getFilename()
+
+
Returns the systems String representation.
+

+

+ +
Returns:
the systems String representation
+
+
+
+ +

+getNext

+








    +public Usb_Device getNext()
+
+
Returns the pointer to the next device.
+

+

+ +
Returns:
the pointer to the next device or null
+
+
+
+ +

+getNumChildren

+








    +public byte getNumChildren()
+
+
Returns the number of children of this device.
+

+

+ +
Returns:
the number of children of this device
+
+
+
+ +

+getPrev

+








    +public Usb_Device getPrev()
+
+
Returns the pointer to the previous device.
+

+

+ +
Returns:
the pointer to the previous device or null
+
+
+
+ +

+toString

+








    +public java.lang.String toString()
+
+
+
Overrides:
toString in class java.lang.Object
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ch/ntb/usb/USBException.html =================================================================== --- trunk/docs/java/ch/ntb/usb/USBException.html (nonexistent) +++ trunk/docs/java/ch/ntb/usb/USBException.html (revision 3) @@ -0,0 +1,242 @@ + + + + + + +USBException + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ch.ntb.usb +
+Class USBException

+








    +java.lang.Object








    +  extended by java.lang.Throwable








    +      extended by java.lang.Exception








    +          extended by java.io.IOException








    +              extended by ch.ntb.usb.USBException








    +
+
+
All Implemented Interfaces:
java.io.Serializable
+
+
+
Direct Known Subclasses:
USBTimeoutException
+
+
+
+
public class USBException
extends java.io.IOException
+ + +

+

+
See Also:
Serialized Form
+
+ +

+ + + + +

+ + + + + + +
+Constructor Summary
USBException(java.lang.String string) + +
+           
+  + + + + + + + +
+Method Summary
+ + + + + + + +
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + +

+ + + +
+Constructor Detail
+ +

+USBException

+








    +public USBException(java.lang.String string)
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ch/ntb/usb/Usb_Interface.html =================================================================== --- trunk/docs/java/ch/ntb/usb/Usb_Interface.html (nonexistent) +++ trunk/docs/java/ch/ntb/usb/Usb_Interface.html (revision 3) @@ -0,0 +1,340 @@ + + + + + + +Usb_Interface + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ch.ntb.usb +
+Class Usb_Interface

+








    +java.lang.Object








    +  extended by ch.ntb.usb.Usb_Interface








    +
+
+
+
public class Usb_Interface
extends java.lang.Object
+ + +

+Represents an USB interface.
+ An interface is a group of alternate settings of a configuration.
+

+ +

+


+ +

+ + + +

+ + + + + + + +
+Field Summary
+static intUSB_MAXALTSETTING + +
+          Maximal number of alternate settings
+  + + + + + + + + + + +
+Constructor Summary
Usb_Interface() + +
+           
+  + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ Usb_Interface_Descriptor[]getAltsetting() + +
+          Retuns an array of interface descriptors.
+ intgetNumAltsetting() + +
+          Returns the number of alternate settings.
+ java.lang.StringtoString() + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + +

+ + + +
+Field Detail
+ +

+USB_MAXALTSETTING

+








    +public static final int USB_MAXALTSETTING
+
+
Maximal number of alternate settings +

+

+
See Also:
Constant Field Values
+
+ + + + + + + + +
+Constructor Detail
+ +

+Usb_Interface

+








    +public Usb_Interface()
+
+
+ + + + + + + + +
+Method Detail
+ +

+toString

+








    +public java.lang.String toString()
+
+
+
Overrides:
toString in class java.lang.Object
+
+
+
+
+
+
+ +

+getAltsetting

+








    +public Usb_Interface_Descriptor[] getAltsetting()
+
+
Retuns an array of interface descriptors.
+

+

+ +
Returns:
an array of interface descriptors
+
+
+
+ +

+getNumAltsetting

+








    +public int getNumAltsetting()
+
+
Returns the number of alternate settings.
+

+

+ +
Returns:
the number of alternate settings
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ztex/BitstreamUploadException.html =================================================================== --- trunk/docs/java/ztex/BitstreamUploadException.html (nonexistent) +++ trunk/docs/java/ztex/BitstreamUploadException.html (revision 3) @@ -0,0 +1,262 @@ + + + + + + +BitstreamUploadException + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ztex +
+Class BitstreamUploadException

+








    +java.lang.Object








    +  extended by java.lang.Throwable








    +      extended by java.lang.Exception








    +          extended by ztex.BitstreamUploadException








    +
+
+
All Implemented Interfaces:
java.io.Serializable
+
+
+
+
public class BitstreamUploadException
extends java.lang.Exception
+ + +

+Signals that an error occurred while attempting to upload the bitstream. +

+ +

+

+
See Also:
Serialized Form
+
+ +

+ + + + +

+ + + + + + + + + +
+Constructor Summary
BitstreamUploadException() + +
+          Constructs an instance using a standard message.
BitstreamUploadException(java.lang.String msg) + +
+          Constructs an instance from the given error message.
+  + + + + + + + +
+Method Summary
+ + + + + + + +
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + +

+ + + +
+Constructor Detail
+ +

+BitstreamUploadException

+








    +public BitstreamUploadException(java.lang.String msg)
+
+
Constructs an instance from the given error message. +

+

+
Parameters:
msg - The error message.
+
+
+ +

+BitstreamUploadException

+








    +public BitstreamUploadException()
+
+
Constructs an instance using a standard message. +

+

+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ztex/DeviceLostException.html =================================================================== --- trunk/docs/java/ztex/DeviceLostException.html (nonexistent) +++ trunk/docs/java/ztex/DeviceLostException.html (revision 3) @@ -0,0 +1,262 @@ + + + + + + +DeviceLostException + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ztex +
+Class DeviceLostException

+








    +java.lang.Object








    +  extended by java.lang.Throwable








    +      extended by java.lang.Exception








    +          extended by ztex.DeviceLostException








    +
+
+
All Implemented Interfaces:
java.io.Serializable
+
+
+
+
public class DeviceLostException
extends java.lang.Exception
+ + +

+Thrown if a device went lost after renumeration. +

+ +

+

+
See Also:
Serialized Form
+
+ +

+ + + + +

+ + + + + + + + + +
+Constructor Summary
DeviceLostException() + +
+          Constructs an instance using a standard message.
DeviceLostException(java.lang.String msg) + +
+          Constructs an instance from the given input string.
+  + + + + + + + +
+Method Summary
+ + + + + + + +
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + +

+ + + +
+Constructor Detail
+ +

+DeviceLostException

+








    +public DeviceLostException(java.lang.String msg)
+
+
Constructs an instance from the given input string. +

+

+
Parameters:
msg - A message.
+
+
+ +

+DeviceLostException

+








    +public DeviceLostException()
+
+
Constructs an instance using a standard message. +

+

+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ztex/Ztex1v1.html =================================================================== --- trunk/docs/java/ztex/Ztex1v1.html (nonexistent) +++ trunk/docs/java/ztex/Ztex1v1.html (revision 3) @@ -0,0 +1,1603 @@ + + + + + + +Ztex1v1 + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ztex +
+Class Ztex1v1

+








    +java.lang.Object








    +  extended by ztex.Ztex1








    +      extended by ztex.Ztex1v1








    +
+
+
+
public class Ztex1v1
extends Ztex1
+ + +

+This class implements the communication protocol of the interface version 1 for the interaction with the ZTEX firmware. +

+ The features supported by this interface can be accessed via vendor commands and vendor requests via Endpoint 0. + Each feature can be enabled or disabled by the firmware and also depends from the hardware. + The presence of a feature is indicated by a 1 in the corresponding feature bit of the ZTEX descriptor 1, see ZtexDevice1. + The following table gives an overview about the features +

+ + + + + + + + + + + + + + + + +
Capability bitDescription
0.0 + EEPROM support

+

+ + + + + + + + + + + + + + + + +
Vendor request (VR)
or command (VC)
Description
VR 0x38Read from EEPROM
VC 0x39Write to EEPROM
VR 0x3aGet EEPROM state. Returns: + + + + + + + + + + + + + + + + + +
BytesDescription
0-1Number of bytes written.
2Checksum
30:idle, 1:busy or error
+
+
0.1 + FPGA Configuration

+

+ + + + + + + + + + + + + + + + +
Vendor request (VR)
or command (VC)
Description
VR 0x30Get FPGA state. Returns: + + + + + + + + + + + + + + + + + + + + + +
BytesDescription
01: unconfigured, 0:configured
1Checksum
2-5Number of bytes transferred.
6INIT_B states (Must be 222).
+
VC 0x31Reset FPGA
VR 0x32Send Bitstream
+
0.2 + Flash memory support

+

+ + + + + + + + + + + + + + + + +
Vendor request (VR)
or command (VC)
Description
VR 0x40Get Flash state. Returns: + + + + + + + + + + + + + + + + + + + + + +
BytesDescription
01:enabled, 0:disabled
1-2Sector size
3-6Number of sectors
7Error code
+
VR 0x41Read one sector from Flash
VC 0x42Write one sector to Flash
+
+

+ +

+

+
See Also:
ZtexDevice1, +Ztex1
+
+ +

+ + + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Field Summary
+static java.lang.String[]capabilityStrings + +
+          The names of the capabilities
+ inteepromBytes + +
+          Number of bytes written to EEPROM.
+ inteepromChecksum + +
+          Checksum of the last EEPROM transfer.
+static intFLASH_EC_BUSY + +
+          Signals that Flash memory it busy.
+static intFLASH_EC_CMD_ERROR + +
+          Signals an error while attempting to execute a command.
+static intFLASH_EC_NO_ERROR + +
+          Means no error.
+static intFLASH_EC_PENDING + +
+          Signals that another Flash operation is pending.
+static intFLASH_EC_READ_ERROR + +
+          Signals an error while attempting to read from Flash.
+static intFLASH_EC_TIMEOUT + +
+          Signals that a timeout occurred.
+static intFLASH_EC_WRITE_ERROR + +
+          Signals an error while attempting to write to Flash.
+ intflashEC + +
+          Last Flash error code obtained by flashState().
+ + + + + + + +
Fields inherited from class ztex.Ztex1
certainWorkarounds, controlMsgTimeout
+  + + + + + + + + + + +
+Constructor Summary
Ztex1v1(ZtexDevice1 pDev) + +
+          Constructs an instance from a given device.
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ java.lang.StringcapabilityInfo(java.lang.String pf) + +
+          Creates a String with capability information.
+ voidcheckCapability(int i, + int j) + +
+          Checks whether ZTEX descriptor 1 is available and interface 1 and a given capability are supported.
+ voidcheckCompatible(int productId0, + int productId1, + int productId2, + int productId3) + +
+          Checks whether the given product ID is compatible to the device corresponding to this class and whether interface 1 is supported.
+ voidcheckValid() + +
+          Checks whether ZTEX descriptor 1 is available and interface 1 is supported.
+ booleancompatible(int productId0, + int productId1, + int productId2, + int productId3) + +
+          Checks whether the given product ID is compatible to the device corresponding to this class and whether interface 1 is supported.
+ longconfigureFpga(java.lang.String fwFileName, + boolean force) + +
+          Upload a Bitstream to the FPGA.
+ voideepromDisable() + +
+          Disables the firmware stored in the EEPROM.
+ voideepromRead(int addr, + byte[] buf, + int length) + +
+          Reads data from the EEPROM.
+ booleaneepromState() + +
+          Reads the current EEPROM status.
+ longeepromUpload(java.lang.String ihxFileName, + boolean force) + +
+          Upload the firmware to the EEPROM.
+ voideepromWrite(int addr, + byte[] buf, + int length) + +
+          Writes data to the EEPROM.
+ booleanflashEnabled() + +
+          Returns true if Flash memory is installed.
+ intflashFirstFreeSector() + +
+          Returns the first free sector of the Flash memory.
+ voidflashReadSector(int sector, + byte[] buf) + +
+          Reads one sector from the Flash.
+ voidflashResetBitstream() + +
+          Clears a Bitstream from the Flash.
+ intflashSectors() + +
+          Returns the number of sectors of the Flash memory or 0, if no Flash memory is installed.
+ intflashSectorSize() + +
+          Returns the sector size of the Flash memory or 0, if no flash memory is installed.
+ longflashSize() + +
+          Returns the size of Flash memory or 0, if no Flash memory is installed.
+ booleanflashState() + +
+          Reads the the Flash memory status and information.
+ java.lang.StringflashStrError() + +
+          Gets the last Flash error from the device.
+static java.lang.StringflashStrError(int errNum) + +
+          Converts a given error code into a String.
+ longflashUploadBitstream(java.lang.String fwFileName) + +
+          Uploads a Bitstream to the Flash.
+ voidflashWriteSector(int sector, + byte[] buf) + +
+          Writes one sector to the Flash.
+ intgetFlashEC() + +
+          Gets the last Flash error from the device.
+ booleangetFpgaConfiguration() + +
+          Returns true if the FPGA is configured.
+ java.lang.StringgetFpgaConfigurationStr() + +
+          Returns a string that indicates the FPGA configuration status.
+ voidprintFpgaState() + +
+          Prints out the FPGA state.
+ booleanprintMmcState() + +
+          Prints out some debug information about *SD/MMC Flash cards in SPI mode.
+ voidresetFpga() + +
+          Resets the FPGA.
+ java.lang.StringtoString() + +
+          Returns a lot of useful information about the corresponding device.
+ booleanvalid() + +
+          Returns true if ZTEX interface 1 is available.
+ booleanvalid(int i, + int j) + +
+          Returns true if ZTEX interface 1 and capability i.j are available.
+ + + + + + + +
Methods inherited from class ztex.Ztex1
dev, finalize, handle, resetEzUsb, uploadFirmware, vendorCommand, vendorCommand, vendorCommand, vendorCommand2, vendorRequest, vendorRequest, vendorRequest2, vendorRequest2
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + +

+ + + +
+Field Detail
+ +

+capabilityStrings

+








    +public static final java.lang.String[] capabilityStrings
+
+
The names of the capabilities +

+

+
+
+
+ +

+eepromBytes

+








    +public int eepromBytes
+
+
Number of bytes written to EEPROM. (Obtained by eepromState().) +

+

+
+
+
+ +

+eepromChecksum

+








    +public int eepromChecksum
+
+
Checksum of the last EEPROM transfer. (Obtained by eepromState().) +

+

+
+
+
+ +

+flashEC

+








    +public int flashEC
+
+
Last Flash error code obtained by flashState(). See FLASH_EC_* for possible error codes. +

+

+
+
+
+ +

+FLASH_EC_NO_ERROR

+








    +public static final int FLASH_EC_NO_ERROR
+
+
Means no error. +

+

+
See Also:
Constant Field Values
+
+
+ +

+FLASH_EC_CMD_ERROR

+








    +public static final int FLASH_EC_CMD_ERROR
+
+
Signals an error while attempting to execute a command. +

+

+
See Also:
Constant Field Values
+
+
+ +

+FLASH_EC_TIMEOUT

+








    +public static final int FLASH_EC_TIMEOUT
+
+
Signals that a timeout occurred. +

+

+
See Also:
Constant Field Values
+
+
+ +

+FLASH_EC_BUSY

+








    +public static final int FLASH_EC_BUSY
+
+
Signals that Flash memory it busy. +

+

+
See Also:
Constant Field Values
+
+
+ +

+FLASH_EC_PENDING

+








    +public static final int FLASH_EC_PENDING
+
+
Signals that another Flash operation is pending. +

+

+
See Also:
Constant Field Values
+
+
+ +

+FLASH_EC_READ_ERROR

+








    +public static final int FLASH_EC_READ_ERROR
+
+
Signals an error while attempting to read from Flash. +

+

+
See Also:
Constant Field Values
+
+
+ +

+FLASH_EC_WRITE_ERROR

+








    +public static final int FLASH_EC_WRITE_ERROR
+
+
Signals an error while attempting to write to Flash. +

+

+
See Also:
Constant Field Values
+
+ + + + + + + + +
+Constructor Detail
+ +

+Ztex1v1

+








    +public Ztex1v1(ZtexDevice1 pDev)








    +        throws UsbException
+
+
Constructs an instance from a given device. +

+

+
Parameters:
pDev - The given device. +
Throws: +
UsbException - if an communication error occurred.
+
+ + + + + + + + +
+Method Detail
+ +

+valid

+








    +public boolean valid()
+
+
Returns true if ZTEX interface 1 is available. +

+

+
Overrides:
valid in class Ztex1
+
+
+ +
Returns:
true if ZTEX interface 1 is available.
+
+
+
+ +

+valid

+








    +public boolean valid(int i,








    +                     int j)
+
+
Returns true if ZTEX interface 1 and capability i.j are available. +

+

+
Parameters:
i - byte index of the capability
j - bit index of the capability +
Returns:
true if ZTEX interface 1 and capability i.j are available.
+
+
+
+ +

+compatible

+








    +public boolean compatible(int productId0,








    +                          int productId1,








    +                          int productId2,








    +                          int productId3)
+
+
Checks whether the given product ID is compatible to the device corresponding to this class and whether interface 1 is supported.
+ The given product ID is compatible +
if ( this.productId(0)==0 || productId0<=0 || this.productId(0)==productId0 ) &&








    +   ( this.productId(0)==0 || productId1<=0 || this.productId(1)==productId1 ) &&








    +   ( this.productId(2)==0 || productId2<=0 || this.productId(2)==productId2 ) &&








    +   ( this.productId(3)==0 || productId3<=0 || this.productId(3)==productId3 ) 
+

+

+
Parameters:
productId0 - Byte 0 of the given product ID
productId1 - Byte 1 of the given product ID
productId2 - Byte 2 of the given product ID
productId3 - Byte 3 of the given product ID +
Returns:
true if the given product ID is compatible and interface 1 is supported.
+
+
+
+ +

+checkValid

+








    +public void checkValid()








    +                throws InvalidFirmwareException
+
+
Checks whether ZTEX descriptor 1 is available and interface 1 is supported. +

+

+
Overrides:
checkValid in class Ztex1
+
+
+ +
Throws: +
InvalidFirmwareException - if ZTEX descriptor 1 is not available or interface 1 is not supported.
+
+
+
+ +

+checkCapability

+








    +public void checkCapability(int i,








    +                            int j)








    +                     throws InvalidFirmwareException,








    +                            CapabilityException
+
+
Checks whether ZTEX descriptor 1 is available and interface 1 and a given capability are supported. +

+

+
Parameters:
i - byte index of the capability
j - bit index of the capability +
Throws: +
InvalidFirmwareException - if ZTEX descriptor 1 is not available or interface 1 is not supported. +
CapabilityException - if the given capability is not supported.
+
+
+
+ +

+checkCompatible

+








    +public void checkCompatible(int productId0,








    +                            int productId1,








    +                            int productId2,








    +                            int productId3)








    +                     throws InvalidFirmwareException
+
+
Checks whether the given product ID is compatible to the device corresponding to this class and whether interface 1 is supported. + See compatible(int,int,int,int). +

+

+
Parameters:
productId0 - Byte 0 of the given product ID
productId1 - Byte 1 of the given product ID
productId2 - Byte 2 of the given product ID
productId3 - Byte 3 of the given product ID +
Throws: +
InvalidFirmwareException - if the given product ID is not compatible or interface 1 is not supported.
+
+
+
+ +

+printFpgaState

+








    +public void printFpgaState()








    +                    throws UsbException,








    +                           InvalidFirmwareException,








    +                           CapabilityException
+
+
Prints out the FPGA state. +

+

+ +
Throws: +
InvalidFirmwareException - if interface 1 is not supported. +
UsbException - if a communication error occurs. +
CapabilityException - if FPGA configuration is not supported by the firmware.
+
+
+
+ +

+getFpgaConfiguration

+








    +public boolean getFpgaConfiguration()








    +                             throws UsbException,








    +                                    InvalidFirmwareException,








    +                                    CapabilityException
+
+
Returns true if the FPGA is configured. +

+

+ +
Returns:
true if the FPGA is configured. +
Throws: +
InvalidFirmwareException - if interface 1 is not supported. +
UsbException - if a communication error occurs. +
CapabilityException - if FPGA configuration is not supported by the firmware.
+
+
+
+ +

+getFpgaConfigurationStr

+








    +public java.lang.String getFpgaConfigurationStr()








    +                                         throws UsbException,








    +                                                InvalidFirmwareException,








    +                                                CapabilityException
+
+
Returns a string that indicates the FPGA configuration status. +

+

+ +
Returns:
a string that indicates the FPGA configuration status. +
Throws: +
InvalidFirmwareException - if interface 1 is not supported. +
UsbException - if a communication error occurs. +
CapabilityException - if FPGA configuration is not supported by the firmware.
+
+
+
+ +

+resetFpga

+








    +public void resetFpga()








    +               throws UsbException,








    +                      InvalidFirmwareException,








    +                      CapabilityException
+
+
Resets the FPGA. +

+

+ +
Throws: +
InvalidFirmwareException - if interface 1 is not supported. +
UsbException - if a communication error occurs. +
CapabilityException - if FPGA configuration is not supported by the firmware.
+
+
+
+ +

+configureFpga

+








    +public long configureFpga(java.lang.String fwFileName,








    +                          boolean force)








    +                   throws BitstreamReadException,








    +                          UsbException,








    +                          BitstreamUploadException,








    +                          AlreadyConfiguredException,








    +                          InvalidFirmwareException,








    +                          CapabilityException
+
+
Upload a Bitstream to the FPGA. +

+

+
Parameters:
fwFileName - The file name of the Bitstream. The file can be a regular file or a system resource (e.g. a file from the current jar archive).
force - If set to true existing configurations will be overwritten. (By default an AlreadyConfiguredException is thrown). +
Throws: +
BitstreamReadException - if an error occurred while attempting to read the Bitstream. +
BitstreamUploadException - if an error occurred while attempting to upload the Bitstream. +
AlreadyConfiguredException - if the FPGA is already configured. +
InvalidFirmwareException - if interface 1 is not supported. +
UsbException - if a communication error occurs. +
CapabilityException - if FPGA configuration is not supported by the firmware.
+
+
+
+ +

+eepromState

+








    +public boolean eepromState()








    +                    throws UsbException,








    +                           InvalidFirmwareException,








    +                           CapabilityException
+
+
Reads the current EEPROM status. + This method also sets the varibles eepromBytes and eepromChecksum. +

+

+ +
Returns:
true if EEPROM is ready. +
Throws: +
InvalidFirmwareException - if interface 1 is not supported. +
UsbException - if a communication error occurs. +
CapabilityException - if EEPROM access is not supported by the firmware.
+
+
+
+ +

+eepromWrite

+








    +public void eepromWrite(int addr,








    +                        byte[] buf,








    +                        int length)








    +                 throws UsbException,








    +                        InvalidFirmwareException,








    +                        CapabilityException
+
+
Writes data to the EEPROM. +

+

+
Parameters:
addr - The destination address of the EEPROM.
buf - The data.
length - The amount of bytes to be sent. +
Throws: +
InvalidFirmwareException - if interface 1 is not supported. +
UsbException - if a communication error occurs. +
CapabilityException - if EEPROM access is not supported by the firmware.
+
+
+
+ +

+eepromRead

+








    +public void eepromRead(int addr,








    +                       byte[] buf,








    +                       int length)








    +                throws UsbException,








    +                       InvalidFirmwareException,








    +                       CapabilityException
+
+
Reads data from the EEPROM. +

+

+
Parameters:
addr - The source address of the EEPROM.
buf - A buffer for the storage of the data.
length - The amount of bytes to be read. +
Throws: +
InvalidFirmwareException - if interface 1 is not supported. +
UsbException - if a communication error occurs. +
CapabilityException - if EEPROM access is not supported by the firmware.
+
+
+
+ +

+eepromUpload

+








    +public long eepromUpload(java.lang.String ihxFileName,








    +                         boolean force)








    +                  throws IncompatibleFirmwareException,








    +                         FirmwareUploadException,








    +                         InvalidFirmwareException,








    +                         CapabilityException
+
+
Upload the firmware to the EEPROM. + In order to start the uploaded firmware the device must be reset. +

+

+
Parameters:
ihxFileName - The file name of the firmware image in ihx format. The file can be a regular file or a system resource (e.g. a file from the current jar archive).
force - Skips the compatibility check if true. +
Throws: +
IncompatibleFirmwareException - if the given firmware is not compatible to the installed one, see compatible(int,int,int,int) (Upload can be enforced using the force parameter.) +
InvalidFirmwareException - if interface 1 is not supported. +
CapabilityException - if EEPROM access is not supported by the firmware. +
FirmwareUploadException - if an error occurred while attempting to upload the firmware.
+
+
+
+ +

+eepromDisable

+








    +public void eepromDisable()








    +                   throws FirmwareUploadException,








    +                          InvalidFirmwareException,








    +                          CapabilityException
+
+
Disables the firmware stored in the EEPROM. + This is achived by writing a "0" to the address 0 of the EEPROM. +

+

+ +
Throws: +
InvalidFirmwareException - if interface 1 is not supported. +
CapabilityException - if EEPROM access is not supported by the firmware. +
FirmwareUploadException - if an error occurred while attempting to disable the firmware.
+
+
+
+ +

+flashStrError

+








    +public static java.lang.String flashStrError(int errNum)
+
+
Converts a given error code into a String. +

+

+
Parameters:
errNum - The error code. +
Returns:
an error message.
+
+
+
+ +

+flashStrError

+








    +public java.lang.String flashStrError()
+
+
Gets the last Flash error from the device. +

+

+ +
Returns:
an error message.
+
+
+
+ +

+flashState

+








    +public boolean flashState()








    +                   throws UsbException,








    +                          InvalidFirmwareException,








    +                          CapabilityException
+
+
Reads the the Flash memory status and information. + This method also sets the variables flashEnabled, flashSectorSize and flashSectors. +

+

+ +
Returns:
true if Flash memory is installed. +
Throws: +
InvalidFirmwareException - if interface 1 is not supported. +
UsbException - if a communication error occurs. +
CapabilityException - if Flash memory access is not supported by the firmware.
+
+
+
+ +

+getFlashEC

+








    +public int getFlashEC()








    +               throws UsbException,








    +                      InvalidFirmwareException,








    +                      CapabilityException
+
+
Gets the last Flash error from the device. +

+

+ +
Throws: +
InvalidFirmwareException - if interface 1 is not supported. +
UsbException - if a communication error occurs. +
CapabilityException - if Flash memory access is not supported by the firmware.
+
+
+
+ +

+flashReadSector

+








    +public void flashReadSector(int sector,








    +                            byte[] buf)








    +                     throws UsbException,








    +                            InvalidFirmwareException,








    +                            CapabilityException
+
+
Reads one sector from the Flash. +

+

+
Parameters:
sector - The sector number to be read.
buf - A buffer for the storage of the data. +
Throws: +
InvalidFirmwareException - if interface 1 is not supported. +
UsbException - if a communication error occurs. +
CapabilityException - if Flash memory access is not possible.
+
+
+
+ +

+flashWriteSector

+








    +public void flashWriteSector(int sector,








    +                             byte[] buf)








    +                      throws UsbException,








    +                             InvalidFirmwareException,








    +                             CapabilityException
+
+
Writes one sector to the Flash. +

+

+
Parameters:
sector - The sector number to be written.
buf - The data. +
Throws: +
InvalidFirmwareException - if interface 1 is not supported. +
UsbException - if a communication error occurs. +
CapabilityException - if Flash memory access is not possible.
+
+
+
+ +

+flashEnabled

+








    +public boolean flashEnabled()








    +                     throws UsbException,








    +                            InvalidFirmwareException,








    +                            CapabilityException
+
+
Returns true if Flash memory is installed. +

+

+ +
Returns:
true if Flash memory is installed. +
Throws: +
InvalidFirmwareException - if interface 1 is not supported. +
UsbException - if a communication error occurs. +
CapabilityException - if Flash memory access is not supported by the firmware.
+
+
+
+ +

+flashSectorSize

+








    +public int flashSectorSize()








    +                    throws UsbException,








    +                           InvalidFirmwareException,








    +                           CapabilityException
+
+
Returns the sector size of the Flash memory or 0, if no flash memory is installed. + If required, the sector size is determined form the device first. +

+

+ +
Returns:
the sector size of the Flash memory. +
Throws: +
InvalidFirmwareException - if interface 1 is not supported. +
UsbException - if a communication error occurs. +
CapabilityException - if Flash memory access is not supported by the firmware.
+
+
+
+ +

+flashSectors

+








    +public int flashSectors()








    +                 throws UsbException,








    +                        InvalidFirmwareException,








    +                        CapabilityException
+
+
Returns the number of sectors of the Flash memory or 0, if no Flash memory is installed. + If required, the number of sectors is determined form the device first. +

+

+ +
Returns:
the number of sectors of the Flash memory. +
Throws: +
InvalidFirmwareException - if interface 1 is not supported. +
UsbException - if a communication error occurs. +
CapabilityException - if Flash memory access is not supported by the firmware.
+
+
+
+ +

+flashSize

+








    +public long flashSize()








    +               throws UsbException,








    +                      InvalidFirmwareException,








    +                      CapabilityException
+
+
Returns the size of Flash memory or 0, if no Flash memory is installed. + If required, the Flash size is determined form the device first. +

+

+ +
Returns:
the size of Flash memory. +
Throws: +
InvalidFirmwareException - if interface 1 is not supported. +
UsbException - if a communication error occurs. +
CapabilityException - if Flash memory access is not supported by the firmware.
+
+
+
+ +

+printMmcState

+








    +public boolean printMmcState()








    +                      throws UsbException,








    +                             InvalidFirmwareException,








    +                             CapabilityException
+
+
Prints out some debug information about *SD/MMC Flash cards in SPI mode.
+ Only use this method if such kind of Flash is installed. +

+

+ +
Throws: +
InvalidFirmwareException - if interface 1 is not supported. +
UsbException - if a communication error occurs. +
CapabilityException - if Flash memory access is not supported by the firmware.
+
+
+
+ +

+flashUploadBitstream

+








    +public long flashUploadBitstream(java.lang.String fwFileName)








    +                          throws BitstreamReadException,








    +                                 UsbException,








    +                                 InvalidFirmwareException,








    +                                 CapabilityException
+
+
Uploads a Bitstream to the Flash. + This allows the firmware to load the Bitstream from Flash. Together with installation of the firmware in EEPROM + it is possible to construct fully autonomous devices. +

+ Information about the bitstream is stored in sector 0. + This so called boot sector has the following format: +

+ + + + + + + + + + + + + + + + + + + + +
BytesDescription
0..7ID, must be "ZTEXBS",1,1
8..9The number of sectors used to store the Bitstream. 0 means no Bitstream.
10..11The number of bytes in the last sector.
12..sectorSize-1This data is reserved for future use and preserved by this method.
+

+ The total size of the Bitstream is computed as ((bs[8] | (bs[9]<<8) - 1) * flash_sector_size + ((bs[10] | (bs[11]<<8)) + where bs[i] denotes byte i of the boot sector. +

+ The first sector of the Bitstream is sector 1. +

+

+
Parameters:
fwFileName - The file name of the Bitstream. The file can be a regular file or a system resource (e.g. a file from the current jar archive). +
Throws: +
InvalidFirmwareException - if interface 1 is not supported. +
UsbException - if a communication error occurs. +
CapabilityException - if Flash memory access is not possible. +
BitstreamReadException - if an error occurred while attempting to read the Bitstream.
+
+
+
+ +

+flashResetBitstream

+








    +public void flashResetBitstream()








    +                         throws UsbException,








    +                                InvalidFirmwareException,








    +                                CapabilityException
+
+
Clears a Bitstream from the Flash. + This is achieved by writing 0 to bytes 8..9 of the boot sector, see flashUploadBitstream(String). + If no boot sector is installed the method returns without any write action. +

+

+ +
Throws: +
InvalidFirmwareException - if interface 1 is not supported. +
UsbException - if a communication error occurs. +
CapabilityException - if Flash memory access is not possible.
+
+
+
+ +

+flashFirstFreeSector

+








    +public int flashFirstFreeSector()








    +                         throws UsbException,








    +                                InvalidFirmwareException,








    +                                CapabilityException
+
+
Returns the first free sector of the Flash memory. + This is the first sector behind the Bitstream, or 0 if no boot sector is installed (or 1 if a boot sector but no Bitstream is installed). +

+

+ +
Returns:
the first free sector of the Flash memory. +
Throws: +
InvalidFirmwareException - if interface 1 is not supported. +
UsbException - if a communication error occurs. +
CapabilityException - if Flash memory access is not possible.
+
+
+
+ +

+toString

+








    +public java.lang.String toString()
+
+
Returns a lot of useful information about the corresponding device. +

+

+
Overrides:
toString in class Ztex1
+
+
+ +
Returns:
a lot of useful information about the corresponding device.
+
+
+
+ +

+capabilityInfo

+








    +public java.lang.String capabilityInfo(java.lang.String pf)
+
+
Creates a String with capability information. +

+

+
Parameters:
pf - A separator between the single capabilities, e.g. ", " +
Returns:
a string of the supported capabilities.
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ztex/IncompatibleFirmwareException.html =================================================================== --- trunk/docs/java/ztex/IncompatibleFirmwareException.html (nonexistent) +++ trunk/docs/java/ztex/IncompatibleFirmwareException.html (revision 3) @@ -0,0 +1,262 @@ + + + + + + +IncompatibleFirmwareException + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ztex +
+Class IncompatibleFirmwareException

+








    +java.lang.Object








    +  extended by java.lang.Throwable








    +      extended by java.lang.Exception








    +          extended by ztex.IncompatibleFirmwareException








    +
+
+
All Implemented Interfaces:
java.io.Serializable
+
+
+
+
public class IncompatibleFirmwareException
extends java.lang.Exception
+ + +

+Thrown while attempting to overwrite an existing firmware with an incompatible one. +

+ +

+

+
See Also:
Serialized Form
+
+ +

+ + + + +

+ + + + + + + + + +
+Constructor Summary
IncompatibleFirmwareException() + +
+          Constructs an instance using a standard message.
IncompatibleFirmwareException(java.lang.String msg) + +
+          Constructs an instance from the given error message.
+  + + + + + + + +
+Method Summary
+ + + + + + + +
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + +

+ + + +
+Constructor Detail
+ +

+IncompatibleFirmwareException

+








    +public IncompatibleFirmwareException(java.lang.String msg)
+
+
Constructs an instance from the given error message. +

+

+
Parameters:
msg - The error message.
+
+
+ +

+IncompatibleFirmwareException

+








    +public IncompatibleFirmwareException()
+
+
Constructs an instance using a standard message. +

+

+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ztex/package-frame.html =================================================================== --- trunk/docs/java/ztex/package-frame.html (nonexistent) +++ trunk/docs/java/ztex/package-frame.html (revision 3) @@ -0,0 +1,77 @@ + + + + + + +ztex + + + + + + + + + + + +ztex + + + + +
+Classes  + +
+EzUsb +
+IhxFile +
+JInputStream +
+Ztex1 +
+Ztex1v1 +
+ZtexDevice1 +
+ZtexIhxFile1 +
+ZtexScanBus1
+ + + + + + +
+Exceptions  + +
+AlreadyConfiguredException +
+BitstreamReadException +
+BitstreamUploadException +
+CapabilityException +
+DeviceLostException +
+FirmwareUploadException +
+IhxFileDamagedException +
+IhxParseException +
+IncompatibleFirmwareException +
+InvalidFirmwareException +
+UsbException
+ + + + Index: trunk/docs/java/ztex/ZtexIhxFile1.html =================================================================== --- trunk/docs/java/ztex/ZtexIhxFile1.html (nonexistent) +++ trunk/docs/java/ztex/ZtexIhxFile1.html (revision 3) @@ -0,0 +1,556 @@ + + + + + + +ZtexIhxFile1 + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ztex +
+Class ZtexIhxFile1

+








    +java.lang.Object








    +  extended by ztex.IhxFile








    +      extended by ztex.ZtexIhxFile1








    +
+
+
+
public class ZtexIhxFile1
extends IhxFile
+ + +

+Represents a firmware image with ZTEX descriptor 1 loaded from an ihx (Intel Hex format) file.
+ The ZTEX descriptor is usually located at the position 0x6x of the firmware image.
+ A description of the ZTEX descriptor 1 can be found in ZtexDevice1. +

+ +

+

+
See Also:
ZtexDevice1, +Ztex1
+
+ +

+ + + +

+ + + +
+Field Summary
+ + + + + + + +
Fields inherited from class ztex.IhxFile
ihxData
+  + + + + + + + + + + + + + +
+Constructor Summary
ZtexIhxFile1(java.lang.String fileName) + +
+          Constructs an instance from a given file name.
ZtexIhxFile1(java.lang.String fileName, + int pZtexDescriptorOffs) + +
+          Constructs an instance from a given file name and descriptor position.
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ intfwVersion() + +
+          Returns the firmware version.
+ byte[]interfaceCapabilities() + +
+          Returns the interface capabilities (all 6 bytes).
+ intinterfaceCapabilities(int i) + +
+          Returns byte i of the interface capabilities.
+ intinterfaceVersion() + +
+          Returns the interface version.
+ byte[]moduleReserved() + +
+          Returns the application specific information (all 12 bytes).
+ intmoduleReserved(int i) + +
+          Returns byte i of the application specific information.
+ byte[]productId() + +
+          Returns the product ID (all 4 bytes).
+ intproductId(int i) + +
+          Returns byte i of the product ID.
+ voidsetSnString(java.lang.String s) + +
+          Modifies the serial number string.
+ java.lang.StringsnString() + +
+          Returns the serial number string.
+ java.lang.StringtoString() + +
+          Returns a string representation if the instance.
+ + + + + + + +
Methods inherited from class ztex.IhxFile
dataInfo
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + +

+ + + +
+Constructor Detail
+ +

+ZtexIhxFile1

+








    +public ZtexIhxFile1(java.lang.String fileName,








    +                    int pZtexDescriptorOffs)








    +             throws java.io.IOException,








    +                    IhxFileDamagedException,








    +                    IncompatibleFirmwareException
+
+
Constructs an instance from a given file name and descriptor position.
+ This method can also read system resources, e.g. files from the current jar archive. +

+

+
Parameters:
fileName - The file name.
pZtexDescriptorOffs - The position of the descriptor in bytes. The default position is 0x6c. +
Throws: +
java.io.IOException - If an read error occurred. +
IhxFileDamagedException - If the ihx file is damaged. +
IncompatibleFirmwareException - If the firmware image contains no valid ZTEX descriptor 1 at the specified position.
+
+
+ +

+ZtexIhxFile1

+








    +public ZtexIhxFile1(java.lang.String fileName)








    +             throws java.io.IOException,








    +                    IhxFileDamagedException,








    +                    IncompatibleFirmwareException
+
+
Constructs an instance from a given file name. + The ZTEX descriptor 1 is expected to be at the position 0x6c of the firmware image.
+ This method can also read system resources, e.g. files from the current jar archive. +

+

+
Parameters:
fileName - The file name. +
Throws: +
java.io.IOException - If an read error occurred. +
IhxFileDamagedException - If the ihx file is damaged. +
IncompatibleFirmwareException - If the firmware image contains no valid ZTEX descriptor 1 at the specified position.
+
+ + + + + + + + +
+Method Detail
+ +

+productId

+








    +public final byte[] productId()
+
+
Returns the product ID (all 4 bytes). +

+

+ +
Returns:
PRODUCT_ID, see ZtexDevice1.
+
+
+
+ +

+productId

+








    +public int productId(int i)
+
+
Returns byte i of the product ID. +

+

+
Parameters:
i - index +
Returns:
PRODUCT_ID[i], see ZtexDevice1.
+
+
+
+ +

+fwVersion

+








    +public final int fwVersion()
+
+
Returns the firmware version. +

+

+ +
Returns:
FW_VERSION, see ZtexDevice1.
+
+
+
+ +

+interfaceVersion

+








    +public final int interfaceVersion()
+
+
Returns the interface version. +

+

+ +
Returns:
INTERFACE_VERSION, see ZtexDevice1.
+
+
+
+ +

+interfaceCapabilities

+








    +public final byte[] interfaceCapabilities()
+
+
Returns the interface capabilities (all 6 bytes). +

+

+ +
Returns:
INTERFACE_CAPABILITIES, see ZtexDevice1.
+
+
+
+ +

+interfaceCapabilities

+








    +public final int interfaceCapabilities(int i)
+
+
Returns byte i of the interface capabilities. +

+

+
Parameters:
i - index +
Returns:
INTERFACE_CAPABILITIES[i], see ZtexDevice1.
+
+
+
+ +

+moduleReserved

+








    +public final byte[] moduleReserved()
+
+
Returns the application specific information (all 12 bytes). +

+

+ +
Returns:
MODULE_RESERVED, see ZtexDevice1.
+
+
+
+ +

+moduleReserved

+








    +public final int moduleReserved(int i)
+
+
Returns byte i of the application specific information. +

+

+
Parameters:
i - index +
Returns:
MODULE_RESERVED[i], see ZtexDevice1.
+
+
+
+ +

+snString

+








    +public final java.lang.String snString()
+
+
Returns the serial number string. +

+

+ +
Returns:
SN_STRING, see ZtexDevice1.
+
+
+
+ +

+setSnString

+








    +public final void setSnString(java.lang.String s)








    +                       throws IncompatibleFirmwareException
+
+
Modifies the serial number string. +

+

+
Parameters:
s - The new serial number string which must not be longer then 10 characters. +
Throws: +
IncompatibleFirmwareException
+
+
+
+ +

+toString

+








    +public java.lang.String toString()
+
+
Returns a string representation if the instance. +

+

+
Overrides:
toString in class java.lang.Object
+
+
+ +
Returns:
a string representation if the instance.
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ztex/JInputStream.html =================================================================== --- trunk/docs/java/ztex/JInputStream.html (nonexistent) +++ trunk/docs/java/ztex/JInputStream.html (revision 3) @@ -0,0 +1,261 @@ + + + + + + +JInputStream + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ztex +
+Class JInputStream

+








    +java.lang.Object








    +  extended by ztex.JInputStream








    +
+
+
+
public class JInputStream
extends java.lang.Object
+ + +

+Creates an input stream from a regular file or a system resource file (i.e. a file from the current jar file). +

+ +

+


+ +

+ + + + +

+ + + + + + +
+Constructor Summary
JInputStream() + +
+           
+  + + + + + + + + + + + +
+Method Summary
+static java.io.InputStreamgetInputStream(java.lang.String fileName) + +
+          Constructs an instance from a giving file name.
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + +

+ + + +
+Constructor Detail
+ +

+JInputStream

+








    +public JInputStream()
+
+
+ + + + + + + + +
+Method Detail
+ +

+getInputStream

+








    +public static java.io.InputStream getInputStream(java.lang.String fileName)








    +                                          throws java.lang.SecurityException,








    +                                                 java.io.FileNotFoundException
+
+
Constructs an instance from a giving file name. +

+

+
Parameters:
fileName - The file name. +
Throws: +
java.lang.SecurityException - Signals a security violation. +
java.io.FileNotFoundException - Thrown if the file was not found.
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ztex/package-summary.html =================================================================== --- trunk/docs/java/ztex/package-summary.html (nonexistent) +++ trunk/docs/java/ztex/package-summary.html (revision 3) @@ -0,0 +1,321 @@ + + + + + + +ztex + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+

+Package ztex +

+The Java API of the ZTEX EZ-USB SDK. +

+See: +
+          Description +

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class Summary
EzUsbProvides methods for uploading firmware to Cypress EZ-USB devices.
IhxFileA class representing a firmware image loaded from an ihx (Intel Hex format) file.
JInputStreamCreates an input stream from a regular file or a system resource file (i.e. a file from the current jar file).
Ztex1This class implements the interface-independent part of the communication protocol for the interaction with the ZTEX firmware.
Ztex1v1This class implements the communication protocol of the interface version 1 for the interaction with the ZTEX firmware.
ZtexDevice1A class representing an EZ-USB device that supports the ZTEX descriptor 1 or an unconfigured EZ-USB device.
ZtexIhxFile1Represents a firmware image with ZTEX descriptor 1 loaded from an ihx (Intel Hex format) file.
ZtexScanBus1A class used for finding the EZ-USB devices on the USB.
+  + +

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Exception Summary
AlreadyConfiguredExceptionThrown if the FPGA is already configured.
BitstreamReadExceptionSignals that an error occurred while attempting to read a bitstream.
BitstreamUploadExceptionSignals that an error occurred while attempting to upload the bitstream.
CapabilityExceptionThrown is a required capability is not available.
DeviceLostExceptionThrown if a device went lost after renumeration.
FirmwareUploadExceptionSignals that an error occured while attempting to upload the firmware.
IhxFileDamagedExceptionSignals that an ihx file is corrupt.
IhxParseExceptionSignals that an error occurred while attempting to decode the ihx file.
IncompatibleFirmwareExceptionThrown while attempting to overwrite an existing firmware with an incompatible one.
InvalidFirmwareExceptionThrown if a device runs with no or the wrong firmware, i.e. if the ZTEX descriptor is not found or damaged.
UsbExceptionSignals an USB error.
+  + +

+

+Package ztex Description +

+ +

+The Java API of the ZTEX EZ-USB SDK. +

+This API is the host-side counterpart of the Firmware-Kit and allows user software to interact with +EZ-USB devices running with such firmware. It uses libusbJava, a Java wrapper +for the libusb 0.1 and the libusb-win32 USB libraries. This API is known to run on Linux and Windows, but should work on every operating +system which supports libusb and Java. +

+

Features

+The main features are: +
    +
  • Platform independent host software. It is possible to pack all necessary files (libusb libraries, firmware, bitstream) into + one single jar archive which runs on both, Linux and Windows (and other OS's that support libusb and Java)
  • +
  • Licensed as Open Source under GPLv3
  • +
  • Firmware upload directly into the EZ-USB Microcontroller
  • +
  • Access to EEPROM memory
  • +
  • Firmware upload to EEPROM
  • +
  • Support of Flash memory
  • +
  • Bitstream upload directly to the FPGA (for ZTEX USB-FPGA-Modules)
  • +
  • Bitstream upload to Flash memory (for ZTEX USB-FPGA-Modules)
  • +
+ +

+

Interaction with the firmware

+Firmware built using the Firmware Development Kit supports an additional descriptor, the ZTEX descriptor 1. This descriptor +identifies the device and firmware, provides compatibility information (e.g. to avoid that a device is loaded with the wrong firmware) +and specifies the communication protocol. A description of the descriptor is given in ZtexDevice1. +

+The communication protocol defines how the functions provided by the firmware (see main features above) +can be accessed. Currently there is only one protocol implemented, the so called interface 1. +A description of the interface is given in Ztex1v1. +

+The most importand classes for the interaction with the EZ-USB device / firmware are +

+

+ + + + + + + + + + + + +
ZtexDevice1Represents an EZ-USB device that supports ZTEX descriptor 1. These devices can be found using ZtexScanBus1.
Ztex1Implementation of interface-independent part of the communication protocol, e.g. uploading the firmware to the EZ-USB and renumeration management.
Ztex1v1Implemenetaion of the Interface 1, i.e. the interface dependent part of the communication protocol.
+ +

+

System overview

+The following diagram gives an overview about the usage of the different parts of the ZTEX EZ-USB SDK. +

+ZTEX EZ-USB SDK overview for Linux and Windows +

+The host software usually consists of a single jar archive which contains +

    +
  • all necessary Java bytecode;
  • +
  • the libusb Java wrapper libraries for Linux (libusbJava.so) and Windows (libusbJava.dll), which are statically linked against libusb (no libusb installation required);
  • +
  • the firmware for the EZ-USB device (unless not installed in EEPROM);
  • +
  • Bitstream for the FPGA (if required).
  • +
+This single jar archive runs on both, Linux and Windows (or other OS's that support libusb and Java). +

+On Linux this jar archive has no additional software requirements. The libusb(Java) library communicates directly with the EZ-USB device using kernel routines. +

+On Windows a libusb driver is required. (This driver is a part of the ZTEX SDK package). The libusb(Java) library communicates with the EZ-USB device using that driver. + +

Related Resources

+For more information about this project visit the +ZTEX EZ-USB SDK page. +

+ +

+

+
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ztex/EzUsb.html =================================================================== --- trunk/docs/java/ztex/EzUsb.html (nonexistent) +++ trunk/docs/java/ztex/EzUsb.html (revision 3) @@ -0,0 +1,288 @@ + + + + + + +EzUsb + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ztex +
+Class EzUsb

+








    +java.lang.Object








    +  extended by ztex.EzUsb








    +
+
+
+
public class EzUsb
extends java.lang.Object
+ + +

+Provides methods for uploading firmware to Cypress EZ-USB devices. +

+ +

+


+ +

+ + + + +

+ + + + + + +
+Constructor Summary
EzUsb() + +
+           
+  + + + + + + + + + + + + + + + +
+Method Summary
+static voidreset(int handle, + boolean r) + +
+          Controls the reset state of a Cypress EZ-USB device.
+static longuploadFirmware(int handle, + IhxFile ihxFile) + +
+          Uploads the Firmware to a Cypress EZ-USB device.
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + +

+ + + +
+Constructor Detail
+ +

+EzUsb

+








    +public EzUsb()
+
+
+ + + + + + + + +
+Method Detail
+ +

+reset

+








    +public static void reset(int handle,








    +                         boolean r)








    +                  throws FirmwareUploadException
+
+
Controls the reset state of a Cypress EZ-USB device. +

+

+
Parameters:
handle - The handle of the device.
r - The reset state (true means reset). +
Throws: +
FirmwareUploadException - if an error occurred while attempting to control the reset state.
+
+
+
+ +

+uploadFirmware

+








    +public static long uploadFirmware(int handle,








    +                                  IhxFile ihxFile)








    +                           throws FirmwareUploadException
+
+
Uploads the Firmware to a Cypress EZ-USB device. +

+

+
Parameters:
handle - The handle of the device.
ihxFile - The firmware image. +
Returns:
The upload time in ms. +
Throws: +
FirmwareUploadException - if an error occurred while attempting to upload the firmware.
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ztex/package-tree.html =================================================================== --- trunk/docs/java/ztex/package-tree.html (nonexistent) +++ trunk/docs/java/ztex/package-tree.html (revision 3) @@ -0,0 +1,162 @@ + + + + + + +ztex Class Hierarchy + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For Package ztex +

+
+
+
Package Hierarchies:
All Packages
+
+

+Class Hierarchy +

+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ztex/IhxFile.html =================================================================== --- trunk/docs/java/ztex/IhxFile.html (nonexistent) +++ trunk/docs/java/ztex/IhxFile.html (revision 3) @@ -0,0 +1,308 @@ + + + + + + +IhxFile + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ztex +
+Class IhxFile

+








    +java.lang.Object








    +  extended by ztex.IhxFile








    +
+
+
Direct Known Subclasses:
ZtexIhxFile1
+
+
+
+
public class IhxFile
extends java.lang.Object
+ + +

+A class representing a firmware image loaded from an ihx (Intel Hex format) file. +

+ +

+


+ +

+ + + +

+ + + + + + + +
+Field Summary
+ short[]ihxData + +
+          This array stores the firmware image.
+  + + + + + + + + + + +
+Constructor Summary
IhxFile(java.lang.String fileName) + +
+          Constructs an instance from a given file name.
+  + + + + + + + + + + + +
+Method Summary
+ voiddataInfo(java.io.PrintStream out) + +
+          Print out some information about the memory usage.
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + +

+ + + +
+Field Detail
+ +

+ihxData

+








    +public short[] ihxData
+
+
This array stores the firmware image. + Values <0 and >255 mean that the data is undefined. +

+

+
+
+ + + + + + + + +
+Constructor Detail
+ +

+IhxFile

+








    +public IhxFile(java.lang.String fileName)








    +        throws java.io.IOException,








    +               IhxFileDamagedException
+
+
Constructs an instance from a given file name. + This method can also read system resources, e.g. files from the current jar archive. +

+

+
Parameters:
fileName - The file name. +
Throws: +
java.io.IOException - If an read error occurred. +
IhxFileDamagedException - If the ihx file is damaged.
+
+ + + + + + + + +
+Method Detail
+ +

+dataInfo

+








    +public void dataInfo(java.io.PrintStream out)
+
+
Print out some information about the memory usage. +

+

+
Parameters:
out - Where the data is printed out.
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ztex/ZtexScanBus1.html =================================================================== --- trunk/docs/java/ztex/ZtexScanBus1.html (nonexistent) +++ trunk/docs/java/ztex/ZtexScanBus1.html (revision 3) @@ -0,0 +1,394 @@ + + + + + + +ZtexScanBus1 + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ztex +
+Class ZtexScanBus1

+








    +java.lang.Object








    +  extended by ztex.ZtexScanBus1








    +
+
+
+
public class ZtexScanBus1
extends java.lang.Object
+ + +

+A class used for finding the EZ-USB devices on the USB. + The devices found are stored as a list of ZtexDevice1 instances. +

+ +

+

+
See Also:
ZtexDevice1
+
+ +

+ + + + +

+ + + + + + + + + + + + +
+Constructor Summary
ZtexScanBus1(int usbVendorId, + int usbProductId, + boolean scanCypress, + boolean quiet) + +
+          Scans the USB for suitable devices and constructs a list of them.
ZtexScanBus1(int usbVendorId, + int usbProductId, + boolean scanCypress, + boolean quiet, + int interfaceVersion) + +
+          Scans the USB for suitable devices and constructs a list of them.
ZtexScanBus1(int usbVendorId, + int usbProductId, + boolean scanCypress, + boolean quiet, + int interfaceVersion, + int productId0, + int productId1, + int productId2, + int productId3) + +
+          Scans the USB for suitable devices and constructs a list of them.
+  + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ ZtexDevice1device(int i) + +
+          Returns a device from the list of devices.
+ intnumberOfDevices() + +
+          Returns the number of devices found.
+ voidprintBus(java.io.PrintStream out) + +
+          Prints out a list of devices found.
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + +

+ + + +
+Constructor Detail
+ +

+ZtexScanBus1

+








    +public ZtexScanBus1(int usbVendorId,








    +                    int usbProductId,








    +                    boolean scanCypress,








    +                    boolean quiet,








    +                    int interfaceVersion,








    +                    int productId0,








    +                    int productId1,








    +                    int productId2,








    +                    int productId3)
+
+
Scans the USB for suitable devices and constructs a list of them. + Four kinds of search filters can be applied +
    +
  1. usbVendorId and usbProductId can be used to search for devices with a given vendor and product ID. These devices must provide a ZTEX descriptor 1.
  2. +
  3. If a certain interface version is required, it can be specified using interfaceVersion.
  4. +
  5. Incompatible devices can be excluded by the specification of the ZTEX product ID's, see ZtexDevice1.compatible(int,int,int,int).
  6. +
  7. If scanCypress is true, all devices (even unconfigured ones) with Cypress EZ-USB vendor and product ID's are considered.
  8. +
+

+

+
Parameters:
usbVendorId - USB vendor ID of the device to be searched for
usbProductId - USB product ID of the device to be searched for
scanCypress - Include devices with Cypress EZ-USB vendor and product ID's (even unconfigured ones)
quiet - if true, don't print any warnings
interfaceVersion - The required interface version (<0 if no interface version is required)
productId0 - Byte 0 of a given ZTEX product ID (≤0 if not to be considered)
productId1 - Byte 1 of a given ZTEX product ID (≤0 if not to be considered)
productId2 - Byte 2 of a given ZTEX product ID (≤0 if not to be considered)
productId3 - Byte 3 of a given ZTEX product ID (≤0 if not to be considered)
+
+
+ +

+ZtexScanBus1

+








    +public ZtexScanBus1(int usbVendorId,








    +                    int usbProductId,








    +                    boolean scanCypress,








    +                    boolean quiet,








    +                    int interfaceVersion)
+
+
Scans the USB for suitable devices and constructs a list of them. + Three kinds of search filters can be applied +
    +
  1. usbVendorId and usbProductId can be used to search for devices with a given vendor and product ID. These devices must provide a ZTEX descriptor 1.
  2. +
  3. If a certain interface version is required, it can be specified using interfaceVersion.
  4. +
  5. If scanCypress is true, all devices (even unconfigured ones) with Cypress EZ-USB vendor and product ID's are considered.
  6. +
+

+

+
Parameters:
usbVendorId - USB vendor ID of the device to be searched for
usbProductId - USB product ID of the device to be searched for
scanCypress - Include devices with Cypress EZ-USB vendor and product ID's (even unconfigured ones)
quiet - if true, don't print any warnings
interfaceVersion - The required interface version (<0 if no interface version is required)
+
+
+ +

+ZtexScanBus1

+








    +public ZtexScanBus1(int usbVendorId,








    +                    int usbProductId,








    +                    boolean scanCypress,








    +                    boolean quiet)
+
+
Scans the USB for suitable devices and constructs a list of them. + Two kinds of search filters can be applied +
    +
  1. usbVendorId and usbProductId can be used to search for devices with a given vendor and product ID. These devices must provide a ZTEX descriptor 1.
  2. +
  3. If scanCypress is true, all devices (even unconfigured ones) with Cypress EZ-USB vendor and product ID's are considered.
  4. +
+

+

+
Parameters:
usbVendorId - USB vendor ID of the device to be searched for
usbProductId - USB product ID of the device to be searched for
scanCypress - Include devices with Cypress EZ-USB vendor and product ID's (even unconfigured ones)
quiet - if true, don't print any warnings
+
+ + + + + + + + +
+Method Detail
+ +

+printBus

+








    +public void printBus(java.io.PrintStream out)
+
+
Prints out a list of devices found. +

+

+
Parameters:
out - Where the output is to be printed to.
+
+
+
+ +

+numberOfDevices

+








    +public final int numberOfDevices()
+
+
Returns the number of devices found. +

+

+ +
Returns:
the number of devices found.
+
+
+
+ +

+device

+








    +public final ZtexDevice1 device(int i)








    +                         throws java.lang.IndexOutOfBoundsException
+
+
Returns a device from the list of devices. +

+

+
Parameters:
i - The device index. +
Returns:
a device from the list of devices. +
Throws: +
java.lang.IndexOutOfBoundsException - if i<0 or i≥numberOfDevices()
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ztex/ZtexDevice1.html =================================================================== --- trunk/docs/java/ztex/ZtexDevice1.html (nonexistent) +++ trunk/docs/java/ztex/ZtexDevice1.html (revision 3) @@ -0,0 +1,850 @@ + + + + + + +ZtexDevice1 + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ztex +
+Class ZtexDevice1

+








    +java.lang.Object








    +  extended by ztex.ZtexDevice1








    +
+
+
+
public class ZtexDevice1
extends java.lang.Object
+ + +

+A class representing an EZ-USB device that supports the ZTEX descriptor 1 or an unconfigured EZ-USB device.
+ Instances of this class are usually created by ZtexScanBus1. + The following table describes the ZTEX descriptor 1. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Field nameOffsetSizeDescription
ZTEX_DESCRIPTOR_SIZE01Size of the descriptor in bytes; must be 40 for descriptor version 1
ZTEX_DESCRIPTOR_VERSION11Descriptor version; 1 for version 1
ZTEXID24ID; must be "ZTEX"
PRODUCT_ID64Four numbers (0..255) representing the product ID and firmware compatibility information.
+ A firmware can overwrite an installed one
+
if ( INSTALLED.PRODUCTID[0]==0 || PRODUCTID[0]==0 || INSTALLED.PRODUCTID[0]==PRODUCTID[0] ) &&








    +   ( INSTALLED.PRODUCTID[1]==0 || PRODUCTID[1]==0 || INSTALLED.PRODUCTID[1]==PRODUCTID[1] ) &&








    +   ( INSTALLED.PRODUCTID[2]==0 || PRODUCTID[2]==0 || INSTALLED.PRODUCTID[2]==PRODUCTID[2] ) &&








    +   ( INSTALLED.PRODUCTID[3]==0 || PRODUCTID[3]==0 || INSTALLED.PRODUCTID[3]==PRODUCTID[3] ) 
+ Here is a list of the preserved product ID's: +
  + + + + + + +
0.0.0.0 default Product ID (no product specified)
1.*.*.* may be used for experimental purposes
10.*.*.* used for ZTEX products
10.11.*.* ZTEX USB-FPGA-Module 1.2
10.20.*.* ZTEX USB-Module 1.0
+ Please contact me (http://www.ztex.de/contact.e.html) if you want to register or reserve a Product ID (range). +
FW_VERSION101May be used to specify the firmware version.
INTERFACE_VERSION111The interface version. This number specifies the protocol that is used for interfacing the host software. A description of interface version 1 can be found in Ztex1v1
INTERFACE_CAPABILITIES1266 bytes, each bit represents a capability. If set, the capability is supported. A description of the capabilities of interface version 1 can be found in Ztex1v1
MODULE_RESERVED181212 bytes for application specific use, i.e. they depend from the PRODUCT_ID
SN_STRING3010A serial number string of 10 characters. The default SN is "0000000000"
+

+ +

+

+
See Also:
Ztex1, +Ztex1v1, +ZtexScanBus1
+
+ +

+ + + +

+ + + + + + + + + + + +
+Field Summary
+static intcypressProductId + +
+          The EZ-USB product ID 0x8613.
+static intcypressVendorId + +
+          The Cypress vendor ID 0x4b4.
+  + + + + + + + + + + +
+Constructor Summary
ZtexDevice1(Usb_Device p_dev, + int pUsbVendorId, + int pUsbProductId) + +
+          Constructs an instance from a given USB device.
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static java.lang.StringbyteArrayString(byte[] buf) + +
+          Produces a nice string representation of an array of bytes.
+ booleancompatible(int productId0, + int productId1, + int productId2, + int productId3) + +
+          Checks whether the given product ID is compatible to the device.
+ Usb_Devicedev() + +
+          Returns the USB device.
+ intfwVersion() + +
+          Returns the firmware version.
+ byte[]interfaceCapabilities() + +
+          Returns the interface capabilities (all 6 bytes).
+ intinterfaceCapabilities(int i) + +
+          Returns byte i of the interface capabilities.
+ booleaninterfaceCapabilities(int i, + int j) + +
+          Returns byte i, bit j of the interface capabilities.
+ intinterfaceVersion() + +
+          Returns the interface version.
+ booleanisCypress() + +
+          Returns true if the device has Cypress EZ-USB vendor and product ID's (0x4b4 and 0x8613).
+ java.lang.StringmanufacturerString() + +
+          Returns the manufacturer string of the device.
+ byte[]moduleReserved() + +
+          Returns the application specific information (all 12 bytes).
+ intmoduleReserved(int i) + +
+          Returns byte i of the application specific information.
+ byte[]productId() + +
+          Returns the product ID (all 4 bytes).
+ intproductId(int i) + +
+          Returns byte i of the product ID.
+ java.lang.StringproductString() + +
+          Returns the product string of the device.
+ java.lang.StringsnString() + +
+          Returns the serial number string of the device.
+ java.lang.StringtoString() + +
+          Returns a string representation if the device with a lot of useful information.
+ intusbProductId() + +
+          Returns the USB product ID of the device.
+ intusbVendorId() + +
+          Returns the USB vendor ID of the device.
+ booleanvalid() + +
+          Returns true if ZTEX descriptor 1 is available.
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + +

+ + + +
+Field Detail
+ +

+cypressVendorId

+








    +public static final int cypressVendorId
+
+
The Cypress vendor ID 0x4b4. +

+

+
See Also:
Constant Field Values
+
+
+ +

+cypressProductId

+








    +public static final int cypressProductId
+
+
The EZ-USB product ID 0x8613. +

+

+
See Also:
Constant Field Values
+
+ + + + + + + + +
+Constructor Detail
+ +

+ZtexDevice1

+








    +public ZtexDevice1(Usb_Device p_dev,








    +                   int pUsbVendorId,








    +                   int pUsbProductId)








    +            throws UsbException,








    +                   InvalidFirmwareException
+
+
Constructs an instance from a given USB device.
+ If the given vendor and product id's match to the vendor and product id's of the given USB device, + the ZTEX descriptor 1 is attempted to read. If this fails, an InvalidFirmwareException is thrown. + To suppress this behavior (e.g. if the EZ-USB device is known to be unconfigured) the vendor and product id's + can be set to -1. +

+

+
Parameters:
p_dev - The USB device.
pUsbVendorId - The given vendor ID.
pUsbProductId - The given product ID. +
Throws: +
UsbException - if an USB communication error occurs. +
InvalidFirmwareException - if no valid ZTEX descriptor 1 is found.
+
+ + + + + + + + +
+Method Detail
+ +

+byteArrayString

+








    +public static java.lang.String byteArrayString(byte[] buf)
+
+
Produces a nice string representation of an array of bytes. +

+

+
Parameters:
buf - A byte array. +
Returns:
a nice string
+
+
+
+ +

+toString

+








    +public java.lang.String toString()
+
+
Returns a string representation if the device with a lot of useful information. +

+

+
Overrides:
toString in class java.lang.Object
+
+
+ +
Returns:
a string representation if the device with a lot of useful information.
+
+
+
+ +

+compatible

+








    +public final boolean compatible(int productId0,








    +                                int productId1,








    +                                int productId2,








    +                                int productId3)
+
+
Checks whether the given product ID is compatible to the device.
+ The given product ID is compatible +
if ( this.productId(0)==0 || productId0<=0 || this.productId(0)==productId0 ) &&








    +   ( this.productId(0)==0 || productId1<=0 || this.productId(1)==productId1 ) &&








    +   ( this.productId(2)==0 || productId2<=0 || this.productId(2)==productId2 ) &&








    +   ( this.productId(3)==0 || productId3<=0 || this.productId(3)==productId3 ) 
+

+

+
Parameters:
productId0 - Byte 0 of the given product ID
productId1 - Byte 1 of the given product ID
productId2 - Byte 2 of the given product ID
productId3 - Byte 3 of the given product ID +
Returns:
true if the given product ID is compatible
+
+
+
+ +

+dev

+








    +public final Usb_Device dev()
+
+
Returns the USB device. +

+

+ +
Returns:
the USB device.
+
+
+
+ +

+isCypress

+








    +public final boolean isCypress()
+
+
Returns true if the device has Cypress EZ-USB vendor and product ID's (0x4b4 and 0x8613). +

+

+ +
Returns:
true if the device has Cypress EZ-USB vendor and product ID's (0x4b4 and 0x8613).
+
+
+
+ +

+valid

+








    +public final boolean valid()
+
+
Returns true if ZTEX descriptor 1 is available. +

+

+ +
Returns:
true if ZTEX descriptor 1 is available.
+
+
+
+ +

+usbVendorId

+








    +public final int usbVendorId()
+
+
Returns the USB vendor ID of the device. +

+

+ +
Returns:
the USB vendor ID of the device.
+
+
+
+ +

+usbProductId

+








    +public final int usbProductId()
+
+
Returns the USB product ID of the device. +

+

+ +
Returns:
the USB product ID of the device.
+
+
+
+ +

+manufacturerString

+








    +public final java.lang.String manufacturerString()
+
+
Returns the manufacturer string of the device. +

+

+ +
Returns:
the manufacturer string of the device.
+
+
+
+ +

+productString

+








    +public final java.lang.String productString()
+
+
Returns the product string of the device. +

+

+ +
Returns:
the product string of the device.
+
+
+
+ +

+snString

+








    +public final java.lang.String snString()
+
+
Returns the serial number string of the device. +

+

+ +
Returns:
the serial number string of the device.
+
+
+
+ +

+productId

+








    +public final byte[] productId()
+
+
Returns the product ID (all 4 bytes). +

+

+ +
Returns:
PRODUCT_ID, see above.
+
+
+
+ +

+productId

+








    +public int productId(int i)
+
+
Returns byte i of the product ID. +

+

+
Parameters:
i - index +
Returns:
PRODUCT_ID[i], see above.
+
+
+
+ +

+fwVersion

+








    +public final int fwVersion()
+
+
Returns the firmware version. +

+

+ +
Returns:
FW_VERSION, see above.
+
+
+
+ +

+interfaceVersion

+








    +public final int interfaceVersion()
+
+
Returns the interface version. +

+

+ +
Returns:
INTERFACE_VERSION, see above.
+
+
+
+ +

+interfaceCapabilities

+








    +public final byte[] interfaceCapabilities()
+
+
Returns the interface capabilities (all 6 bytes). +

+

+ +
Returns:
INTERFACE_CAPABILITIES, see above.
+
+
+
+ +

+interfaceCapabilities

+








    +public final int interfaceCapabilities(int i)
+
+
Returns byte i of the interface capabilities. +

+

+
Parameters:
i - index +
Returns:
INTERFACE_CAPABILITIES[i], see above.
+
+
+
+ +

+interfaceCapabilities

+








    +public final boolean interfaceCapabilities(int i,








    +                                           int j)
+
+
Returns byte i, bit j of the interface capabilities. +

+

+
Parameters:
i - byte index
j - bit index +
Returns:
INTERFACE_CAPABILITIES[i].j, see above.
+
+
+
+ +

+moduleReserved

+








    +public final byte[] moduleReserved()
+
+
Returns the application specific information (all 12 bytes). +

+

+ +
Returns:
MODULE_RESERVED, see above.
+
+
+
+ +

+moduleReserved

+








    +public final int moduleReserved(int i)
+
+
Returns byte i of the application specific information. +

+

+
Parameters:
i - index +
Returns:
MODULE_RESERVED[i], see above.
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ztex/CapabilityException.html =================================================================== --- trunk/docs/java/ztex/CapabilityException.html (nonexistent) +++ trunk/docs/java/ztex/CapabilityException.html (revision 3) @@ -0,0 +1,248 @@ + + + + + + +CapabilityException + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ztex +
+Class CapabilityException

+








    +java.lang.Object








    +  extended by java.lang.Throwable








    +      extended by java.lang.Exception








    +          extended by ztex.CapabilityException








    +
+
+
All Implemented Interfaces:
java.io.Serializable
+
+
+
+
public class CapabilityException
extends java.lang.Exception
+ + +

+Thrown is a required capability is not available. +

+ +

+

+
See Also:
Serialized Form
+
+ +

+ + + + +

+ + + + + + +
+Constructor Summary
CapabilityException(Ztex1 ztex, + java.lang.String cap) + +
+          Constructs an instance from a givig device and capability string.
+  + + + + + + + +
+Method Summary
+ + + + + + + +
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + +

+ + + +
+Constructor Detail
+ +

+CapabilityException

+








    +public CapabilityException(Ztex1 ztex,








    +                           java.lang.String cap)
+
+
Constructs an instance from a givig device and capability string. +

+

+
Parameters:
ztex - The device.
cap - Capability name.
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ztex/FirmwareUploadException.html =================================================================== --- trunk/docs/java/ztex/FirmwareUploadException.html (nonexistent) +++ trunk/docs/java/ztex/FirmwareUploadException.html (revision 3) @@ -0,0 +1,262 @@ + + + + + + +FirmwareUploadException + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ztex +
+Class FirmwareUploadException

+








    +java.lang.Object








    +  extended by java.lang.Throwable








    +      extended by java.lang.Exception








    +          extended by ztex.FirmwareUploadException








    +
+
+
All Implemented Interfaces:
java.io.Serializable
+
+
+
+
public class FirmwareUploadException
extends java.lang.Exception
+ + +

+Signals that an error occured while attempting to upload the firmware. +

+ +

+

+
See Also:
Serialized Form
+
+ +

+ + + + +

+ + + + + + + + + +
+Constructor Summary
FirmwareUploadException() + +
+          Constructs an instance using a standard message.
FirmwareUploadException(java.lang.String msg) + +
+          Constructs an instance from the given error message.
+  + + + + + + + +
+Method Summary
+ + + + + + + +
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + +

+ + + +
+Constructor Detail
+ +

+FirmwareUploadException

+








    +public FirmwareUploadException(java.lang.String msg)
+
+
Constructs an instance from the given error message. +

+

+
Parameters:
msg - The error message.
+
+
+ +

+FirmwareUploadException

+








    +public FirmwareUploadException()
+
+
Constructs an instance using a standard message. +

+

+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ztex/IhxParseException.html =================================================================== --- trunk/docs/java/ztex/IhxParseException.html (nonexistent) +++ trunk/docs/java/ztex/IhxParseException.html (revision 3) @@ -0,0 +1,246 @@ + + + + + + +IhxParseException + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ztex +
+Class IhxParseException

+








    +java.lang.Object








    +  extended by java.lang.Throwable








    +      extended by java.lang.Exception








    +          extended by ztex.IhxParseException








    +
+
+
All Implemented Interfaces:
java.io.Serializable
+
+
+
+
public class IhxParseException
extends java.lang.Exception
+ + +

+Signals that an error occurred while attempting to decode the ihx file. +

+ +

+

+
See Also:
Serialized Form
+
+ +

+ + + + +

+ + + + + + +
+Constructor Summary
IhxParseException(java.lang.String msg) + +
+          Constructs an instance from the given error message.
+  + + + + + + + +
+Method Summary
+ + + + + + + +
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + +

+ + + +
+Constructor Detail
+ +

+IhxParseException

+








    +public IhxParseException(java.lang.String msg)
+
+
Constructs an instance from the given error message. +

+

+
Parameters:
msg - The error message.
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ztex/InvalidFirmwareException.html =================================================================== --- trunk/docs/java/ztex/InvalidFirmwareException.html (nonexistent) +++ trunk/docs/java/ztex/InvalidFirmwareException.html (revision 3) @@ -0,0 +1,342 @@ + + + + + + +InvalidFirmwareException + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ztex +
+Class InvalidFirmwareException

+








    +java.lang.Object








    +  extended by java.lang.Throwable








    +      extended by java.lang.Exception








    +          extended by ztex.InvalidFirmwareException








    +
+
+
All Implemented Interfaces:
java.io.Serializable
+
+
+
+
public class InvalidFirmwareException
extends java.lang.Exception
+ + +

+Thrown if a device runs with no or the wrong firmware, i.e. if the ZTEX descriptor is not found or damaged. +

+ +

+

+
See Also:
Serialized Form
+
+ +

+ + + + +

+ + + + + + + + + + + + + + + + + + + + + +
+Constructor Summary
InvalidFirmwareException(Usb_Device dev) + +
+          Constructs an instance from the given device and error message.
InvalidFirmwareException(Usb_Device dev, + java.lang.String msg) + +
+          Constructs an instance from the given device and error message.
InvalidFirmwareException(Ztex1 ztex) + +
+          Constructs an instance from the given device and error message.
InvalidFirmwareException(Ztex1 ztex, + java.lang.String msg) + +
+          Constructs an instance from the given device and error message.
InvalidFirmwareException(ZtexDevice1 dev) + +
+          Constructs an instance from the given device and error message.
InvalidFirmwareException(ZtexDevice1 dev, + java.lang.String msg) + +
+          Constructs an instance from the given device and error message.
+  + + + + + + + +
+Method Summary
+ + + + + + + +
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + +

+ + + +
+Constructor Detail
+ +

+InvalidFirmwareException

+








    +public InvalidFirmwareException(Ztex1 ztex,








    +                                java.lang.String msg)
+
+
Constructs an instance from the given device and error message. +

+

+
Parameters:
ztex - The device.
msg - The error message.
+
+
+ +

+InvalidFirmwareException

+








    +public InvalidFirmwareException(ZtexDevice1 dev,








    +                                java.lang.String msg)
+
+
Constructs an instance from the given device and error message. +

+

+
Parameters:
dev - The device.
msg - The error message.
+
+
+ +

+InvalidFirmwareException

+








    +public InvalidFirmwareException(Usb_Device dev,








    +                                java.lang.String msg)
+
+
Constructs an instance from the given device and error message. +

+

+
Parameters:
dev - The device.
msg - The error message.
+
+
+ +

+InvalidFirmwareException

+








    +public InvalidFirmwareException(Ztex1 ztex)
+
+
Constructs an instance from the given device and error message. +

+

+
Parameters:
ztex - The device.
+
+
+ +

+InvalidFirmwareException

+








    +public InvalidFirmwareException(ZtexDevice1 dev)
+
+
Constructs an instance from the given device and error message. +

+

+
Parameters:
dev - The device.
+
+
+ +

+InvalidFirmwareException

+








    +public InvalidFirmwareException(Usb_Device dev)
+
+
Constructs an instance from the given device and error message. +

+

+
Parameters:
dev - The device.
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ztex/BitstreamReadException.html =================================================================== --- trunk/docs/java/ztex/BitstreamReadException.html (nonexistent) +++ trunk/docs/java/ztex/BitstreamReadException.html (revision 3) @@ -0,0 +1,263 @@ + + + + + + +BitstreamReadException + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ztex +
+Class BitstreamReadException

+








    +java.lang.Object








    +  extended by java.lang.Throwable








    +      extended by java.lang.Exception








    +          extended by java.io.IOException








    +              extended by ztex.BitstreamReadException








    +
+
+
All Implemented Interfaces:
java.io.Serializable
+
+
+
+
public class BitstreamReadException
extends java.io.IOException
+ + +

+Signals that an error occurred while attempting to read a bitstream. +

+ +

+

+
See Also:
Serialized Form
+
+ +

+ + + + +

+ + + + + + + + + +
+Constructor Summary
BitstreamReadException() + +
+          Constructs an instance using a standard message.
BitstreamReadException(java.lang.String msg) + +
+          Constructs an instance from the given error message.
+  + + + + + + + +
+Method Summary
+ + + + + + + +
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + +

+ + + +
+Constructor Detail
+ +

+BitstreamReadException

+








    +public BitstreamReadException(java.lang.String msg)
+
+
Constructs an instance from the given error message. +

+

+
Parameters:
msg - The error message.
+
+
+ +

+BitstreamReadException

+








    +public BitstreamReadException()
+
+
Constructs an instance using a standard message. +

+

+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ztex/AlreadyConfiguredException.html =================================================================== --- trunk/docs/java/ztex/AlreadyConfiguredException.html (nonexistent) +++ trunk/docs/java/ztex/AlreadyConfiguredException.html (revision 3) @@ -0,0 +1,262 @@ + + + + + + +AlreadyConfiguredException + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ztex +
+Class AlreadyConfiguredException

+








    +java.lang.Object








    +  extended by java.lang.Throwable








    +      extended by java.lang.Exception








    +          extended by ztex.AlreadyConfiguredException








    +
+
+
All Implemented Interfaces:
java.io.Serializable
+
+
+
+
public class AlreadyConfiguredException
extends java.lang.Exception
+ + +

+Thrown if the FPGA is already configured. +

+ +

+

+
See Also:
Serialized Form
+
+ +

+ + + + +

+ + + + + + + + + +
+Constructor Summary
AlreadyConfiguredException() + +
+          Constructs an instance using a standard message.
AlreadyConfiguredException(java.lang.String msg) + +
+          Constructs an instance from the given input string.
+  + + + + + + + +
+Method Summary
+ + + + + + + +
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + +

+ + + +
+Constructor Detail
+ +

+AlreadyConfiguredException

+








    +public AlreadyConfiguredException(java.lang.String msg)
+
+
Constructs an instance from the given input string. +

+

+
Parameters:
msg - A message.
+
+
+ +

+AlreadyConfiguredException

+








    +public AlreadyConfiguredException()
+
+
Constructs an instance using a standard message. +

+

+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ztex/ZtexDescriptorException.html =================================================================== --- trunk/docs/java/ztex/ZtexDescriptorException.html (nonexistent) +++ trunk/docs/java/ztex/ZtexDescriptorException.html (revision 3) @@ -0,0 +1,254 @@ + + + + + + +ZtexDescriptorException + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ztex +
+Class ZtexDescriptorException

+








    +java.lang.Object








    +  extended by java.lang.Throwable








    +      extended by java.lang.Exception








    +          extended by ztex.ZtexDescriptorException








    +
+
+
All Implemented Interfaces:
java.io.Serializable
+
+
+
+
public class ZtexDescriptorException
extends java.lang.Exception
+ + +

+

+
See Also:
Serialized Form
+
+ +

+ + + + +

+ + + + + + + + + +
+Constructor Summary
ZtexDescriptorException(java.lang.String msg) + +
+           
ZtexDescriptorException(Usb_Device dev, + java.lang.String msg) + +
+           
+  + + + + + + + +
+Method Summary
+ + + + + + + +
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + +

+ + + +
+Constructor Detail
+ +

+ZtexDescriptorException

+








    +public ZtexDescriptorException(java.lang.String msg)
+
+
+
+ +

+ZtexDescriptorException

+








    +public ZtexDescriptorException(Usb_Device dev,








    +                               java.lang.String msg)
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ztex/UsbException.html =================================================================== --- trunk/docs/java/ztex/UsbException.html (nonexistent) +++ trunk/docs/java/ztex/UsbException.html (revision 3) @@ -0,0 +1,266 @@ + + + + + + +UsbException + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ztex +
+Class UsbException

+








    +java.lang.Object








    +  extended by java.lang.Throwable








    +      extended by java.lang.Exception








    +          extended by ztex.UsbException








    +
+
+
All Implemented Interfaces:
java.io.Serializable
+
+
+
+
public class UsbException
extends java.lang.Exception
+ + +

+Signals an USB error. +

+ +

+

+
See Also:
Serialized Form
+
+ +

+ + + + +

+ + + + + + + + + +
+Constructor Summary
UsbException(java.lang.String msg) + +
+          Constructs an instance from the given error message.
UsbException(Usb_Device dev, + java.lang.String msg) + +
+          Constructs an instance from the given device and error message.
+  + + + + + + + +
+Method Summary
+ + + + + + + +
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + +

+ + + +
+Constructor Detail
+ +

+UsbException

+








    +public UsbException(java.lang.String msg)
+
+
Constructs an instance from the given error message. +

+

+
Parameters:
msg - The error message.
+
+
+ +

+UsbException

+








    +public UsbException(Usb_Device dev,








    +                    java.lang.String msg)
+
+
Constructs an instance from the given device and error message. +

+

+
Parameters:
dev - The device.
msg - The error message.
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ztex/IhxFileDamagedException.html =================================================================== --- trunk/docs/java/ztex/IhxFileDamagedException.html (nonexistent) +++ trunk/docs/java/ztex/IhxFileDamagedException.html (revision 3) @@ -0,0 +1,250 @@ + + + + + + +IhxFileDamagedException + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ztex +
+Class IhxFileDamagedException

+








    +java.lang.Object








    +  extended by java.lang.Throwable








    +      extended by java.lang.Exception








    +          extended by ztex.IhxFileDamagedException








    +
+
+
All Implemented Interfaces:
java.io.Serializable
+
+
+
+
public class IhxFileDamagedException
extends java.lang.Exception
+ + +

+Signals that an ihx file is corrupt. +

+ +

+

+
See Also:
Serialized Form
+
+ +

+ + + + +

+ + + + + + +
+Constructor Summary
IhxFileDamagedException(java.lang.String filename, + int line, + java.lang.String msg) + +
+          Constructs an instance from a given file name, line number and error message.
+  + + + + + + + +
+Method Summary
+ + + + + + + +
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + +

+ + + +
+Constructor Detail
+ +

+IhxFileDamagedException

+








    +public IhxFileDamagedException(java.lang.String filename,








    +                               int line,








    +                               java.lang.String msg)
+
+
Constructs an instance from a given file name, line number and error message. +

+

+
Parameters:
filename - The file name.
line - The line number.
msg - An error message.
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/ztex/Ztex1.html =================================================================== --- trunk/docs/java/ztex/Ztex1.html (nonexistent) +++ trunk/docs/java/ztex/Ztex1.html (revision 3) @@ -0,0 +1,790 @@ + + + + + + +Ztex1 + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +ztex +
+Class Ztex1

+








    +java.lang.Object








    +  extended by ztex.Ztex1








    +
+
+
Direct Known Subclasses:
Ztex1v1
+
+
+
+
public class Ztex1
extends java.lang.Object
+ + +

+This class implements the interface-independent part of the communication protocol for the interaction with the ZTEX firmware.

+ All firmware implementations that provide the ZTEX descriptor 1 are supported. + A description of this descriptor can be found in ZtexDevice1. +

+ The most important features of this class are the functions for uploading the firmware + and the renumeration management. +

+ The interface dependent part of the communication protocol (currently only one is supported) + can be found in Ztex1v1. +

+ +

+

+
See Also:
ZtexDevice1, +Ztex1v1
+
+ +

+ + + +

+ + + + + + + + + + + +
+Field Summary
+ booleancertainWorkarounds + +
+          Setting to true will enable certain workarounds, e.g. to deal with bad driver/OS implementations.
+ intcontrolMsgTimeout + +
+          The timeout for control messages in ms.
+  + + + + + + + + + + +
+Constructor Summary
Ztex1(ZtexDevice1 pDev) + +
+          Constructs an instance from a given device.
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voidcheckValid() + +
+          Checks whether ZTEX descriptor 1 is available.
+ ZtexDevice1dev() + +
+          Returns the corresponding ZtexDevice1.
+protected  voidfinalize() + +
+          The destructor closes the USB file handle.
+ inthandle() + +
+          Returns the USB file handle.
+ voidresetEzUsb() + +
+          Resets the EZ-USB and manages the renumeration process.
+ java.lang.StringtoString() + +
+          Returns a lot of useful information about the corresponding device.
+ longuploadFirmware(java.lang.String ihxFileName, + boolean force) + +
+          Uploads the firmware to the EZ-USB and manages the renumeration process.
+ booleanvalid() + +
+          Returns true if ZTEX descriptor 1 is available.
+ intvendorCommand(int cmd, + java.lang.String func) + +
+          Sends a vendor command with no payload data and no setup data to Endpoint 0 of the EZ-USB device.
+ intvendorCommand(int cmd, + java.lang.String func, + int value, + int index) + +
+          Sends a vendor command with no payload data to Endpoint 0 of the EZ-USB device.
+ intvendorCommand(int cmd, + java.lang.String func, + int value, + int index, + byte[] buf, + int length) + +
+          Sends a vendor command to Endpoint 0 of the EZ-USB device.
+ voidvendorCommand2(int cmd, + java.lang.String func, + int value, + int index, + byte[] buf, + int length) + +
+          Sends a vendor command to Endpoint 0 of the EZ-USB device and throws an UsbException if not all of the payload has been sent.
+ intvendorRequest(int cmd, + java.lang.String func, + byte[] buf, + int maxlen) + +
+          Sends a vendor request to Endpoint 0 of the EZ-USB device.
+ intvendorRequest(int cmd, + java.lang.String func, + int value, + int index, + byte[] buf, + int maxlen) + +
+          Sends a vendor request to Endpoint 0 of the EZ-USB device.
+ voidvendorRequest2(int cmd, + java.lang.String func, + byte[] buf, + int maxlen) + +
+          Sends a vendor request to Endpoint 0 of the EZ-USB device and throws an UsbException if not all of the payload has been received.
+ voidvendorRequest2(int cmd, + java.lang.String func, + int value, + int index, + byte[] buf, + int maxlen) + +
+          Sends a vendor request to Endpoint 0 of the EZ-USB device and throws an UsbException if not all of the payload has been received.
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + +

+ + + +
+Field Detail
+ +

+certainWorkarounds

+








    +public boolean certainWorkarounds
+
+
Setting to true will enable certain workarounds, e.g. to deal with bad driver/OS implementations. +

+

+
+
+
+ +

+controlMsgTimeout

+








    +public int controlMsgTimeout
+
+
The timeout for control messages in ms. +

+

+
+
+ + + + + + + + +
+Constructor Detail
+ +

+Ztex1

+








    +public Ztex1(ZtexDevice1 pDev)








    +      throws UsbException
+
+
Constructs an instance from a given device. +

+

+
Parameters:
pDev - The given device. +
Throws: +
UsbException - if an communication error occurred.
+
+ + + + + + + + +
+Method Detail
+ +

+finalize

+








    +protected void finalize()
+
+
The destructor closes the USB file handle. +

+

+
Overrides:
finalize in class java.lang.Object
+
+
+
+
+
+
+ +

+handle

+








    +public final int handle()
+
+
Returns the USB file handle. +

+

+
+
+
+
+ +

+dev

+








    +public final ZtexDevice1 dev()
+
+
Returns the corresponding ZtexDevice1. +

+

+ +
Returns:
the corresponding ZtexDevice1.
+
+
+
+ +

+valid

+








    +public boolean valid()
+
+
Returns true if ZTEX descriptor 1 is available. +

+

+ +
Returns:
true if ZTEX descriptor 1 is available.
+
+
+
+ +

+checkValid

+








    +public void checkValid()








    +                throws InvalidFirmwareException
+
+
Checks whether ZTEX descriptor 1 is available. +

+

+ +
Throws: +
InvalidFirmwareException - if ZTEX descriptor 1 is not available.
+
+
+
+ +

+vendorCommand

+








    +public int vendorCommand(int cmd,








    +                         java.lang.String func,








    +                         int value,








    +                         int index,








    +                         byte[] buf,








    +                         int length)








    +                  throws UsbException
+
+
Sends a vendor command to Endpoint 0 of the EZ-USB device. + The command may be send multiple times until the controlMsgTimeout is reached. +

+

+
Parameters:
cmd - The command number (0..255).
func - The name of the command. This string is used for the generation of error messages.
value - The value (0..65535), i.e bytes 2 and 3 of the setup data.
index - The index (0..65535), i.e. bytes 4 and 5 of the setup data.
length - The size of the payload data (0..65535), i.e. bytes 6 and 7 of the setup data.
buf - The payload data buffer. +
Returns:
the number of bytes sent. +
Throws: +
UsbException - if a communication error occurs.
+
+
+
+ +

+vendorCommand

+








    +public int vendorCommand(int cmd,








    +                         java.lang.String func,








    +                         int value,








    +                         int index)








    +                  throws UsbException
+
+
Sends a vendor command with no payload data to Endpoint 0 of the EZ-USB device. + The command may be send multiple times until the controlMsgTimeout is reached. +

+

+
Parameters:
cmd - The command number (0..255).
func - The name of the command. This string is used for the generation of error messages.
value - The value (0..65535), i.e bytes 2 and 3 of the setup data.
index - The index (0..65535), i.e. bytes 4 and 5 of the setup data. +
Returns:
the number of bytes sent. +
Throws: +
UsbException - if a communication error occurs.
+
+
+
+ +

+vendorCommand

+








    +public int vendorCommand(int cmd,








    +                         java.lang.String func)








    +                  throws UsbException
+
+
Sends a vendor command with no payload data and no setup data to Endpoint 0 of the EZ-USB device. + The command may be send multiple times until the controlMsgTimeout is reached. +

+

+
Parameters:
cmd - The command number (0..255).
func - The name of the command. This string is used for the generation of error messages. +
Returns:
the number of bytes sent. +
Throws: +
UsbException - if a communication error occurs.
+
+
+
+ +

+vendorRequest

+








    +public int vendorRequest(int cmd,








    +                         java.lang.String func,








    +                         int value,








    +                         int index,








    +                         byte[] buf,








    +                         int maxlen)








    +                  throws UsbException
+
+
Sends a vendor request to Endpoint 0 of the EZ-USB device. + The request may be send multiple times until the controlMsgTimeout is reached. +

+

+
Parameters:
cmd - The request number (0..255).
func - The name of the request. This string is used for the generation of error messages.
value - The value (0..65535), i.e bytes 2 and 3 of the setup data.
index - The index (0..65535), i.e. bytes 4 and 5 of the setup data.
maxlen - The size of the requested payload data (0..65535), i.e. bytes 6 and 7 of the setup data.
buf - The payload data buffer. +
Returns:
the number of bytes received. +
Throws: +
UsbException - if a communication error occurs.
+
+
+
+ +

+vendorRequest

+








    +public int vendorRequest(int cmd,








    +                         java.lang.String func,








    +                         byte[] buf,








    +                         int maxlen)








    +                  throws UsbException
+
+
Sends a vendor request to Endpoint 0 of the EZ-USB device. + The request may be send multiple times until the controlMsgTimeout is reached. +

+

+
Parameters:
cmd - The request number (0..255).
func - The name of the request. This string is used for the generation of error messages.
maxlen - The size of the requested payload data (0..65535), i.e. bytes 6 and 7 of the setup data.
buf - The payload data buffer. +
Returns:
the number of bytes sent. +
Throws: +
UsbException - if a communication error occurs.
+
+
+
+ +

+vendorCommand2

+








    +public void vendorCommand2(int cmd,








    +                           java.lang.String func,








    +                           int value,








    +                           int index,








    +                           byte[] buf,








    +                           int length)








    +                    throws UsbException
+
+
Sends a vendor command to Endpoint 0 of the EZ-USB device and throws an UsbException if not all of the payload has been sent. + The command may be send multiple times until the controlMsgTimeout is reached. +

+

+
Parameters:
cmd - The command number (0..255).
func - The name of the command. This string is used for the generation of error messages.
value - The value (0..65535), i.e bytes 2 and 3 of the setup data.
index - The index (0..65535), i.e. bytes 4 and 5 of the setup data.
length - The size of the payload data (0..65535), i.e. bytes 6 and 7 of the setup data.
buf - The payload data buffer. +
Throws: +
UsbException - if a communication error occurs or if not all of the payload has been sent.
+
+
+
+ +

+vendorRequest2

+








    +public void vendorRequest2(int cmd,








    +                           java.lang.String func,








    +                           int value,








    +                           int index,








    +                           byte[] buf,








    +                           int maxlen)








    +                    throws UsbException
+
+
Sends a vendor request to Endpoint 0 of the EZ-USB device and throws an UsbException if not all of the payload has been received. + The request may be send multiple times until the controlMsgTimeout is reached. +

+

+
Parameters:
cmd - The request number (0..255).
func - The name of the request. This string is used for the generation of error messages.
value - The value (0..65535), i.e bytes 2 and 3 of the setup data.
index - The index (0..65535), i.e. bytes 4 and 5 of the setup data.
maxlen - The size of the requested payload data (0..65535), i.e. bytes 6 and 7 of the setup data.
buf - The payload data buffer. +
Throws: +
UsbException - if a communication error occurs or not all of the payload has been received.
+
+
+
+ +

+vendorRequest2

+








    +public void vendorRequest2(int cmd,








    +                           java.lang.String func,








    +                           byte[] buf,








    +                           int maxlen)








    +                    throws UsbException
+
+
Sends a vendor request to Endpoint 0 of the EZ-USB device and throws an UsbException if not all of the payload has been received. + The request may be send multiple times until the controlMsgTimeout is reached. +

+

+
Parameters:
cmd - The request number (0..255).
func - The name of the request. This string is used for the generation of error messages.
maxlen - The size of the requested payload data (0..65535), i.e. bytes 6 and 7 of the setup data.
buf - The payload data buffer. +
Throws: +
UsbException - if a communication error occurs or not all of the payload has been received.
+
+
+
+ +

+uploadFirmware

+








    +public long uploadFirmware(java.lang.String ihxFileName,








    +                           boolean force)








    +                    throws IncompatibleFirmwareException,








    +                           FirmwareUploadException,








    +                           UsbException,








    +                           InvalidFirmwareException,








    +                           DeviceLostException
+
+
Uploads the firmware to the EZ-USB and manages the renumeration process. +

+ Before the firmware is uploaded the device is set into a reset state. + After the upload the firmware is booted and the renumeration starts. + During this process the device disappears from the bus and a new one + occurs which will be assigned to this class automatically (instead of the disappeared one). +

+

+
Parameters:
ihxFileName - The file name of the firmware image in ihx format. The file can be a regular file or a system resource (e.g. a file from the current jar archive).
force - The compatibility check is skipped if true. +
Throws: +
IncompatibleFirmwareException - if the given firmware is not compatible to the installed one, see ZtexDevice1.compatible(int,int,int,int) (Upload can be enforced using the force parameter) +
FirmwareUploadException - If an error occurred while attempting to upload the firmware. +
UsbException - if a communication error occurs. +
InvalidFirmwareException - if ZTEX descriptor 1 is not available. +
DeviceLostException - if a device went lost after renumeration.
+
+
+
+ +

+resetEzUsb

+








    +public void resetEzUsb()








    +                throws FirmwareUploadException,








    +                       UsbException,








    +                       InvalidFirmwareException,








    +                       DeviceLostException
+
+
Resets the EZ-USB and manages the renumeration process. +

+ After the reset the renumeration starts. + During this process the device disappears from the bus and a new one + occurs which will be assigned to this class automatically (instead of the disappeared one). +

+

+ +
Throws: +
FirmwareUploadException - If an error occurred while attempting to upload the firmware. +
UsbException - if a communication error occurs. +
InvalidFirmwareException - if ZTEX descriptor 1 is not available. +
DeviceLostException - if a device went lost after renumeration.
+
+
+
+ +

+toString

+








    +public java.lang.String toString()
+
+
Returns a lot of useful information about the corresponding device. +

+

+
Overrides:
toString in class java.lang.Object
+
+
+ +
Returns:
a lot of useful information about the corresponding device.
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/help-doc.html =================================================================== --- trunk/docs/java/help-doc.html (nonexistent) +++ trunk/docs/java/help-doc.html (revision 3) @@ -0,0 +1,217 @@ + + + + + + +API Help + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+How This API Document Is Organized

+
+This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.

+Overview

+
+ +

+The Overview page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages.

+

+Package

+
+ +

+Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:

    +
  • Interfaces (italic)
  • Classes
  • Enums
  • Exceptions
  • Errors
  • Annotation Types
+
+

+Class/Interface

+
+ +

+Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

    +
  • Class inheritance diagram
  • Direct Subclasses
  • All Known Subinterfaces
  • All Known Implementing Classes
  • Class/interface declaration
  • Class/interface description +

    +

  • Nested Class Summary
  • Field Summary
  • Constructor Summary
  • Method Summary +

    +

  • Field Detail
  • Constructor Detail
  • Method Detail
+Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
+ +

+Annotation Type

+
+ +

+Each annotation type has its own separate page with the following sections:

    +
  • Annotation Type declaration
  • Annotation Type description
  • Required Element Summary
  • Optional Element Summary
  • Element Detail
+
+ +

+Enum

+
+ +

+Each enum has its own separate page with the following sections:

    +
  • Enum declaration
  • Enum description
  • Enum Constant Summary
  • Enum Constant Detail
+
+

+Tree (Class Hierarchy)

+
+There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.
    +
  • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
  • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
+
+

+Deprecated API

+
+The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
+

+Index

+
+The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
+

+Prev/Next

+These links take you to the next or previous class, interface, package, or related page.

+Frames/No Frames

+These links show and hide the HTML frames. All pages are available with or without frames. +

+

+Serialized Form

+Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description. +

+

+Constant Field Values

+The Constant Field Values page lists the static final fields and their values. +

+ + +This help file applies to API documentation generated using the standard doclet. + +
+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/serialized-form.html =================================================================== --- trunk/docs/java/serialized-form.html (nonexistent) +++ trunk/docs/java/serialized-form.html (revision 3) @@ -0,0 +1,307 @@ + + + + + + +Serialized Form + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Serialized Form

+
+
+ + + + + +
+Package ch.ntb.usb
+ +

+ +

+ + + +
+Class ch.ntb.usb.USBException extends java.io.IOException implements Serializable
+ +

+serialVersionUID: 1690857437804284710L + +

+ +

+ +

+ + + +
+Class ch.ntb.usb.USBTimeoutException extends USBException implements Serializable
+ +

+serialVersionUID: -1065328371159778249L + +

+


+ + + + + +
+Package ztex
+ +

+ +

+ + + +
+Class ztex.AlreadyConfiguredException extends java.lang.Exception implements Serializable
+ +

+ +

+ +

+ + + +
+Class ztex.BitstreamReadException extends java.io.IOException implements Serializable
+ +

+ +

+ +

+ + + +
+Class ztex.BitstreamUploadException extends java.lang.Exception implements Serializable
+ +

+ +

+ +

+ + + +
+Class ztex.CapabilityException extends java.lang.Exception implements Serializable
+ +

+ +

+ +

+ + + +
+Class ztex.DeviceLostException extends java.lang.Exception implements Serializable
+ +

+ +

+ +

+ + + +
+Class ztex.FirmwareUploadException extends java.lang.Exception implements Serializable
+ +

+ +

+ +

+ + + +
+Class ztex.IhxFileDamagedException extends java.lang.Exception implements Serializable
+ +

+ +

+ +

+ + + +
+Class ztex.IhxParseException extends java.lang.Exception implements Serializable
+ +

+ +

+ +

+ + + +
+Class ztex.IncompatibleFirmwareException extends java.lang.Exception implements Serializable
+ +

+ +

+ +

+ + + +
+Class ztex.InvalidFirmwareException extends java.lang.Exception implements Serializable
+ +

+ +

+ +

+ + + +
+Class ztex.UsbException extends java.lang.Exception implements Serializable
+ +

+ +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/overview-frame.html =================================================================== --- trunk/docs/java/overview-frame.html (nonexistent) +++ trunk/docs/java/overview-frame.html (revision 3) @@ -0,0 +1,44 @@ + + + + + + +Overview List + + + + + + + + + + + + + + + +
+
+ + + + + +
All Classes +

+ +Packages +
+ch.ntb.usb +
+ztex +
+

+ +

+  + + Index: trunk/docs/java/package-list =================================================================== --- trunk/docs/java/package-list (nonexistent) +++ trunk/docs/java/package-list (revision 3) @@ -0,0 +1,2 @@ +ch.ntb.usb +ztex Index: trunk/docs/java/overview-summary.html =================================================================== --- trunk/docs/java/overview-summary.html (nonexistent) +++ trunk/docs/java/overview-summary.html (revision 3) @@ -0,0 +1,153 @@ + + + + + + +Overview + + + + + + + + + + + + +


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + + + + + + + + + + + +
+Packages
ch.ntb.usbA Java wrapper for the libusb 0.1 and libusb-win32 USB library.
ztexThe Java API of the ZTEX EZ-USB SDK.
+ +


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/overview-tree.html =================================================================== --- trunk/docs/java/overview-tree.html (nonexistent) +++ trunk/docs/java/overview-tree.html (revision 3) @@ -0,0 +1,165 @@ + + + + + + +Class Hierarchy + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For All Packages

+
+
+
Package Hierarchies:
ch.ntb.usb, ztex
+
+

+Class Hierarchy +

+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/resources/inherit.gif =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: trunk/docs/java/resources/inherit.gif =================================================================== --- trunk/docs/java/resources/inherit.gif (nonexistent) +++ trunk/docs/java/resources/inherit.gif (revision 3)
trunk/docs/java/resources/inherit.gif Property changes : Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: trunk/docs/java/index.html =================================================================== --- trunk/docs/java/index.html (nonexistent) +++ trunk/docs/java/index.html (revision 3) @@ -0,0 +1,39 @@ + + + + + + +Generated Documentation (Untitled) + + + + + + + + + + + +<H2> +Frame Alert</H2> + +<P> +This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. +<BR> +Link to<A HREF="overview-summary.html">Non-frame version.</A> + + + Index: trunk/docs/java/deprecated-list.html =================================================================== --- trunk/docs/java/deprecated-list.html (nonexistent) +++ trunk/docs/java/deprecated-list.html (revision 3) @@ -0,0 +1,144 @@ + + + + + + +Deprecated List + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Deprecated API

+
+
+Contents
    +
+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Index: trunk/docs/java/allclasses-noframe.html =================================================================== --- trunk/docs/java/allclasses-noframe.html (nonexistent) +++ trunk/docs/java/allclasses-noframe.html (revision 3) @@ -0,0 +1,97 @@ + + + + + + +All Classes + + + + + + + + + + + +All Classes +
+ + + + + +
AlreadyConfiguredException +
+BitstreamReadException +
+BitstreamUploadException +
+CapabilityException +
+Device +
+DeviceLostException +
+EzUsb +
+FirmwareUploadException +
+IhxFile +
+IhxFileDamagedException +
+IhxParseException +
+IncompatibleFirmwareException +
+InvalidFirmwareException +
+JInputStream +
+LibLoader +
+LibusbJava +
+USB +
+Usb_Bus +
+Usb_Config_Descriptor +
+Usb_Descriptor +
+Usb_Device +
+Usb_Device_Descriptor +
+Usb_Endpoint_Descriptor +
+Usb_Interface +
+Usb_Interface_Descriptor +
+USBException +
+UsbException +
+USBTimeoutException +
+Utils +
+Ztex1 +
+Ztex1v1 +
+ZtexDevice1 +
+ZtexIhxFile1 +
+ZtexScanBus1 +
+
+ + + Index: trunk/docs/index.html =================================================================== --- trunk/docs/index.html (nonexistent) +++ trunk/docs/index.html (revision 3) @@ -0,0 +1,39 @@ + + + + + + + +ZTEX EZ-USB SDK - Documentation + + + +
+

ZTEX EZ-USB SDK - Documentation

+
+ +

Overview

+The ZTEX EZ-USB SDK consists in two parts: +
    +
  • The Firmware Kit which is used for building the firmware for the EZ-USB device
  • +
  • The host software API written in Java.
  • +
+

+The firmware built using the Firmware Development Kit supports an additional descriptor, the ZTEX descriptor 1. This descriptor +identifies the device and firmware, provides compatibility information (e.g. to avoid that a device is loaded with the wrong firmware) +and specifies the communication protocol. A description of the descriptor is given in ZtexDevice1. +

+The communication protocol defines how the functions provided by the firmware +can be accessed. Currently there is only one protocol implemented, the so called interface 1. +A description of the interface is given in Ztex1v1. + +

Detailed documentations

+ + + + Index: trunk/docs/Makefile =================================================================== --- trunk/docs/Makefile (nonexistent) +++ trunk/docs/Makefile (revision 3) @@ -0,0 +1,9 @@ +.PHONY: docs java + +all: java + +java: + javadoc ztex ch.ntb.usb -classpath ../libusbJava-src:../java -d java + +distclean: + rm -fr java Index: trunk/Makefile =================================================================== --- trunk/Makefile (revision 2) +++ trunk/Makefile (revision 3) @@ -1,15 +1,18 @@ DIRS=bmp examples java libusbJava-src -.PHONY: default all clean distclean +.PHONY: default all docs clean distclean default: @echo "This makefile is intended to clean up the project or to build the utilties and examples" - @echo "Usage: make all | clean | distclean" + @echo "Usage: make all | docs | clean | distclean" all: make -C java all make -C examples all +docs: + make -C docs all + clean: for i in $(DIRS); do make -C $$i clean; done
/trunk/bmp/Make.bat
1,4 → 1,4
set PATH=%PATH%;c:\FPC\2.2.2\bin\i386-win32
set PATH=%PATH%;c:\FPC\2.2.4\bin\i386-win32
 
ppc386 -Scgm -O3 -FE. -Xs src\bmp.pas
 
/trunk/bmp/src/bmp.pas
1124,7 → 1124,7
j+=1;
end;
 
if (mode=bm_plain) and ((i4 xor pm_s) and pm_m=0) and (pm_q or matchstr(bc_pm,bm_plain)) and (matchstr(bc_lf+bc_pm) or (buf.d=length(bc_pm)))
if (mode=bm_plain) and ((i4 xor pm_s) and pm_m=0) and (pm_q or matchstr(bc_pm,bm_plain)) and (matchstr(bc_lf+bc_pm) or (buf.d+buf.d0=length(bc_pm)))
then begin
mode:=bm_pm;
setmode(length(bc_pm),bm_plain,mode);
/trunk/bmp/src/textbuf.pas
28,12 → 28,12
 
CTextBuf = class;
CTextBuf = class
buf : pchar; { character buffer }
li : pdword; { line info lineNum shl 12 + file }
lastbuf,d : longint;
allocsize : longint; { allocated size }
last : CTextBuf;
killme : boolean;
buf : pchar; { character buffer }
li : pdword; { line info lineNum shl 12 + file }
lastbuf,d,d0 : longint;
allocsize : longint; { allocated size }
last : CTextBuf;
killme : boolean;
constructor create(var tb:CTextBuf);
constructor create(var tb:CTextBuf; asize:longint);
constructor create(var tb:CTextBuf; cb:pchar; lib:pdword; bufsize:longint);
72,7 → 72,7
constructor CTextBuf.create(var tb:CTextBuf);
begin
lastbuf:=-1;
d:=0;
d:=0; d0:=0;
killme:=false;
last:=tb;
tb:=self;
138,6 → 138,7
b : boolean;
begin
lastbuf:=-1;
d0+=d;
d:=0;
killme:=true;
 
/trunk/examples/usb-fpga-1.2/flashdemo/Readme
0,0 → 1,4
Please go to the directory ../../usb-1.0/flashdemo and replace
"IDENTITY_UM_1_0(10.20.0.0,0);" by "IDENTITY_UFM_1_2(10.11.0.0,0);"
 
 
/trunk/examples/usb-fpga-1.2/ucecho/ucecho.sh
1,4 → 1,3
#make -C ../../../java distclean all || exit
#make || exit
#rm ucecho.ihx
java -cp UCEcho.jar UCEcho $@
/trunk/examples/usb-fpga-1.2/ucecho/UCEcho.java
33,7 → 33,7
" -d <number> Device Number (default: 0)\n" +
" -f Force uploads\n" +
" -p Print bus info\n" +
" -w Enable certain workarounds which may be required for vmware + windows\n"+
" -w Enable certain workarounds\n"+
" -h This help" );
public ParameterException (String msg) {
48,7 → 48,7
 
// ******* UCEcho **************************************************************
// constructor
public UCEcho ( ZtexDevice1 pDev ) throws UsbException, ZtexDescriptorException {
public UCEcho ( ZtexDevice1 pDev ) throws UsbException {
super ( pDev );
}
 
71,7 → 71,7
// writes a string to Endpoint 4, reads it back from Endpoint 2 and writes the output to System.out
public void echo ( String input ) throws UsbException {
byte buf[] = input.getBytes();
int i = LibusbJava.usb_bulk_write(handle, 0x04, buf, buf.length, 1000);
int i = LibusbJava.usb_bulk_write(handle(), 0x04, buf, buf.length, 1000);
if ( i<0 )
throw new UsbException("Error sending data: " + LibusbJava.usb_strerror());
System.out.println("Send "+i+" bytes: `"+input+"'" );
83,7 → 83,7
}
 
buf = new byte[1024];
i = LibusbJava.usb_bulk_read(handle, 0x82, buf, 1024, 1000);
i = LibusbJava.usb_bulk_read(handle(), 0x82, buf, 1024, 1000);
if ( i<0 )
throw new UsbException("Error receiving data: " + LibusbJava.usb_strerror());
System.out.println("Read "+i+" bytes: `"+new String(buf,0,i)+"'" );
/trunk/examples/usb-fpga-1.2/ucecho/ucecho.c
26,8 → 26,8
EP_CONFIG(2,0,BULK,IN,512,2);
EP_CONFIG(4,0,BULK,OUT,512,2);
 
// identify as ZTEX USB FPGA Module 1.2 (Important for FPGA configuration)
IDENTITY_UFM_1_2(1.0.0.0,0);
// select ZTEX USB FPGA Module 1.2 as target (Important for FPGA configuration)
IDENTITY_UFM_1_2(10.11.0.0,0);
 
// give them a nice name
#define[PRODUCT_STRING]["ucecho for USB FPGA MODULE 1.2"]
/trunk/examples/usb-1.0/flashdemo/FlashDemo.java
0,0 → 1,146
/*!
flashdemo -- Flash memory example
Copyright (C) 2008-2009 ZTEX e.K.
http://www.ztex.de
 
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
published by the Free Software Foundation.
 
This program 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; if not, see http://www.gnu.org/licenses/.
!*/
 
import java.io.*;
import java.util.*;
 
import ch.ntb.usb.*;
 
import ztex.*;
 
// *****************************************************************************
// ******* ParameterException **************************************************
// *****************************************************************************
// Exception the prints a help message
class ParameterException extends Exception {
public final static String helpMsg = new String (
"Parameters:\n"+
" -d <number> Device Number (default: 0)\n" +
" -f Force uploads\n" +
" -p Print bus info\n" +
" -ue Upload Firmware to EEPROM\n" +
" -re Reset EEPROM Firmware\n" +
" -w Enable certain workarounds\n" +
" -h This help" );
public ParameterException (String msg) {
super( msg + "\n" + helpMsg );
}
}
 
// *****************************************************************************
// ******* Test0 ***************************************************************
// *****************************************************************************
class FlashDemo extends Ztex1v1 {
 
// ******* FlashDemo ***********************************************************
// constructor
public FlashDemo ( ZtexDevice1 pDev ) throws UsbException {
super ( pDev );
}
 
// ******* main ****************************************************************
public static void main (String args[]) {
int devNum = 0;
boolean force = false;
boolean workarounds = false;
try {
// init USB stuff
LibusbJava.usb_init();
 
// scan the USB bus
ZtexScanBus1 bus = new ZtexScanBus1( ZtexDevice1.cypressVendorId, ZtexDevice1.cypressProductId, true, false, 1);
if ( bus.numberOfDevices() <= 0) {
System.err.println("No devices found");
System.exit(0);
}
// scan the command line arguments
for (int i=0; i<args.length; i++ ) {
if ( args[i].equals("-d") ) {
i++;
try {
if (i>=args.length) throw new Exception();
devNum = Integer.parseInt( args[i] );
}
catch (Exception e) {
throw new ParameterException("Device number expected after -d");
}
}
else if ( args[i].equals("-f") ) {
force = true;
}
else if ( args[i].equals("-p") ) {
bus.printBus(System.out);
System.exit(0);
}
else if ( args[i].equals("-w") ) {
workarounds = true;
}
else if ( args[i].equals("-h") ) {
System.err.println(ParameterException.helpMsg);
System.exit(0);
}
else if ( !args[i].equals("-re") && !args[i].equals("-ue") )
throw new ParameterException("Invalid Parameter: "+args[i]);
}
 
// create the main class
FlashDemo ztex = new FlashDemo ( bus.device(devNum) );
ztex.certainWorkarounds = workarounds;
// upload the firmware if necessary
if ( force || ! ztex.valid() || ! ztex.dev().productString().equals("Flash demo") ) {
System.out.println("Firmware upload time: " + ztex.uploadFirmware( "flashdemo.ihx", force ) + " ms");
}
for (int i=0; i<args.length; i++ ) {
if ( args[i].equals("-re") ) {
ztex.eepromDisable();
}
else if ( args[i].equals("-ue") ) {
System.out.println("Firmware to EEPROM upload time: " + ztex.eepromUpload( "flashdemo.ihx", force ) + " ms");
}
}
// print some information
System.out.println("Capabilities: " + ztex.capabilityInfo(", "));
System.out.println("Enabled: " + ztex.flashEnabled());
System.out.println("Size: " + ztex.flashSize());
byte[] buf = new byte[ztex.flashSectorSize()];
ztex.flashReadSector(0,buf); // read out the las sector;
int sector = (buf[0] & 255) | ((buf[1] & 255) << 8) | ((buf[1] & 255) << 16) | ((buf[1] & 255) << 24);
System.out.println("Last sector: "+sector);
 
ztex.flashReadSector(sector,buf); // read out the string
int i=0;
while ( buf[i] != '\0'&& i < ztex.flashSectorSize() )
i++;
System.out.println("The string: `" + new String(buf,0,i)+ "'");
 
}
catch (Exception e) {
System.out.println("Error: "+e.getLocalizedMessage() );
}
}
}
/trunk/examples/usb-1.0/flashdemo/flashdemo.c
0,0 → 1,68
/*!
flashdemo -- Flash memory example
Copyright (C) 2008-2009 ZTEX e.K.
http://www.ztex.de
 
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
published by the Free Software Foundation.
 
This program 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; if not, see http://www.gnu.org/licenses/.
!*/
 
#include[ztex-conf.h] // Loads the configuration macros, see ztex-conf.h for the available macros
#include[ztex-utils.h] // include basic functions and variables
 
// Cypress vendor ID and product ID may only (!) be used for experimental purposes
SET_VPID(0x4b4,0x8613);
 
// select ZTEX USB Module 1.0 as target (required for FLASH support)
IDENTITY_UM_1_0(10.20.0.0,0);
// uncomment the following line and comment the line above to run this example on ZTEX USB Module 1.2
//IDENTITY_UFM_1_2(10.11.0.0,0);
 
// enable Flash support
ENABLE_FLASH;
 
// this product string is also used for identification of the firmware in FlashDemo.java
#define[PRODUCT_STRING]["Flash demo"]
 
code char flash_string[] = "Hello World!";
 
// include the main part of the firmware kit, define the descriptors, ...
#include[ztex.h]
 
void main(void)
{
xdata DWORD sector;
 
init_USB(); // init everything
if ( flash_enabled ) {
flash_read_init( 0 ); // prepare reading sector 0
flash_read(&sector, 4); // read the number of last sector
flash_read_finish(flash_sector_size - 4); // dummy-read the rest of the sector + finish read operation
sector++;
if ( sector > flash_sectors || sector == 0 ) {
sector = 1;
}
 
flash_write_init( 0 ); // prepare writing sector 0
flash_write(&sector, 4); // write the current sector number
flash_write_finish(flash_sector_size - 4); // dummy-write the rest of the sector + finish write operation
flash_write_init( sector ); // prepare writing sector sector
flash_write((xdata*) flash_string, sizeof(flash_string)); // write the string
flash_write_finish(flash_sector_size - sizeof(flash_string)); // dummy-write the rest of the sector + finish write operation
}
while (1) { } // twiddle thumbs
}
 
/trunk/examples/usb-1.0/flashdemo/flashdemo.bat
0,0 → 1,2
java -cp FlashDemo.jar FlashDemo
pause
/trunk/examples/usb-1.0/flashdemo/flashdemo.sh
0,0 → 1,3
make -C ../../../java distclean all || exit
make distclean all || exit
java -cp FlashDemo.jar FlashDemo $@
trunk/examples/usb-1.0/flashdemo/flashdemo.sh Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: trunk/examples/usb-1.0/flashdemo/Makefile =================================================================== --- trunk/examples/usb-1.0/flashdemo/Makefile (nonexistent) +++ trunk/examples/usb-1.0/flashdemo/Makefile (revision 3) @@ -0,0 +1,21 @@ +######################### +# configuration section # +######################### + +ZTEXPREFIX=../../.. + +JARTARGET=FlashDemo.jar +CLASSTARGETS=FlashDemo.class +CLASSEXTRADEPS= +#CLASSEXTRADEPS:=$(shell echo $(ZTEXPREFIX)/java/ztex/*.java) + +IHXTARGETS=flashdemo.ihx +IHXEXTRADEPS= +#IHXEXTRADEPS:=$(shell echo $(ZTEXPREFIX)/include/*.h) +EXTRAJARFILES=flashdemo.ihx + +################################ +# DO NOT CHANAGE THE FOLLOWING # +################################ + +include $(ZTEXPREFIX)/Makefile.mk Index: trunk/examples/usb-1.0/flashdemo/Readme =================================================================== --- trunk/examples/usb-1.0/flashdemo/Readme (nonexistent) +++ trunk/examples/usb-1.0/flashdemo/Readme (revision 3) @@ -0,0 +1,16 @@ +flashdemo +--------- + +This example demonstrates how data can be read and written to/from the +Flash memory. + +During the start-up the firmware (defined in flashdemo.c) reads the number of +last sector n from sector 0 (dword at position 0) and increments it by one. If n +is larger than or equal to the total amount of sectors, or if it is equal to 0, +n is set to 1. + +Then n is written back to sector 0 and sector n is filled with the string +"Hello World!". + +The host software (defined in FlashDemo.java) reads out the string from the last +sector of the flash memory. Index: trunk/examples/usb-1.0/Makefile =================================================================== --- trunk/examples/usb-1.0/Makefile (nonexistent) +++ trunk/examples/usb-1.0/Makefile (revision 3) @@ -0,0 +1,16 @@ +DIRS=flashdemo + +.PHONY: default all clean distclean + +default: + @echo "This makefile is intended to clean up the project or to build all examples in this subdirectory" + @echo "Usage: make all | clean | distclean" + +all: + for i in $(DIRS); do make -C $$i all; done + +clean: + for i in $(DIRS); do make -C $$i clean; done + +distclean: clean + for i in $(DIRS); do make -C $$i distclean; done Index: trunk/examples/all/ucecho/UCEcho.java =================================================================== --- trunk/examples/all/ucecho/UCEcho.java (revision 2) +++ trunk/examples/all/ucecho/UCEcho.java (revision 3) @@ -33,7 +33,7 @@ " -d Device Number (default: 0)\n" + " -f Force uploads\n" + " -p Print bus info\n" + - " -w Enable certain workarounds which may be required for vmware + windows\n"+ + " -w Enable certain workarounds\n"+ " -h This help" ); public ParameterException (String msg) { @@ -48,7 +48,7 @@ // ******* UCEcho ************************************************************** // constructor - public UCEcho ( ZtexDevice1 pDev ) throws UsbException, ZtexDescriptorException { + public UCEcho ( ZtexDevice1 pDev ) throws UsbException { super ( pDev ); } @@ -71,7 +71,7 @@ // writes a string to Endpoint 4, reads it back from Endpoint 2 and writes the output to System.out public void echo ( String input ) throws UsbException { byte buf[] = input.getBytes(); - int i = LibusbJava.usb_bulk_write(handle, 0x04, buf, buf.length, 1000); + int i = LibusbJava.usb_bulk_write(handle(), 0x04, buf, buf.length, 1000); if ( i<0 ) throw new UsbException("Error sending data: " + LibusbJava.usb_strerror()); System.out.println("Send "+i+" bytes: `"+input+"'" ); @@ -83,7 +83,7 @@ } buf = new byte[1024]; - i = LibusbJava.usb_bulk_read(handle, 0x82, buf, 1024, 1000); + i = LibusbJava.usb_bulk_read(handle(), 0x82, buf, 1024, 1000); if ( i<0 ) throw new UsbException("Error receiving data: " + LibusbJava.usb_strerror()); System.out.println("Read "+i+" bytes: `"+new String(buf,0,i)+"'" );
/trunk/examples/Makefile
1,4 → 1,4
DIRS=all usb-fpga-1.2
DIRS=all usb-fpga-1.2 usb-1.0
 
.PHONY: default all clean distclean
 

powered by: WebSVN 2.1.0

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