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 bit Description
0.0 EEPROM support

Vendor request (VR)
or command (VC)
Description
VR 0x38 Read from EEPROM
VC 0x39 Write to EEPROM
VR 0x3a Get EEPROM state. Returns:
Bytes Description
0-1 Number of bytes written.
2 Checksum
3 0:idle, 1:busy or error
0.1 FPGA Configuration

Vendor request (VR)
or command (VC)
Description
VR 0x30 Get FPGA state. Returns:
Bytes Description
0 1: unconfigured, 0:configured
1 Checksum
2-5 Number of bytes transferred.
6 INIT_B states.
7 Flash configuration result.
8 Flash Bitstreambit order (1=swapped).
VC 0x31 Reset FPGA
VR 0x32 Send Bitstream
0.2 Flash memory support

Vendor request (VR)
or command (VC)
Description
VR 0x40 Get Flash state. Returns:
Bytes Description
0 1:enabled, 0:disabled
1-2 Sector size
3-6 Number of sectors
7 Error code
VR 0x41 Read one sector from Flash
VC 0x42 Write one sector to Flash
0.3 Debug helper support

Vendor request (VR)
or command (VC)
Description
VR 0x28 Get debug data. Returns:
Bytes Description
0-1 Number of the last message
2 Stack size in messages
3 Message size in bytes
≥4 Message stack
0.4 XMEGA support

Vendor request (VR)
or command (VC)
Description
VR 0x48 Read XMEGA status information. Returns:
Bytes Description
0 Error code
1-2 Flash size in pages
3-4 EEPROM sie in pages
5 Flash page size as power of two (e.g. 9 means 512 bytes)
6 EEPROM page size as power of two
VC 0x49 Reset XMEGA
VRs 0x4A, 0x4B, 0x4C, 0x4D Read XMEGA NVM using PDI address space / relative to Flash address base / EEPROM address base / Fuse address base
VCs 0x4B, 0x4C Write exactly one Flash / EEPROM page
VCs 0x4D Write Fuse
0.5 High speed FPGA configuration support

Vendor request (VR)
or command (VC)
Description
VR 0x33 Read Endpoint settings. Returns:
Bytes Description
0 Endpoint number
1 Interface number
VR 0x34 Start FPGA configuration
VC 0x35 Finish FPGA configuration
0.6 MAC EEPROM support

Vendor request (VR)
or command (VC)
Description
VR 0x3B Read from MAC EEPROM
VC 0x3C Write to MAC EEPROM
VR 0x3D Get MAC EEPROM state. Returns:
Bytes Description
0 0:idle, 1:busy or error
0.7 Multi-FPGA support

Vendor request (VR)
or command (VC)
Description
VR 0x50 Return multi-FPGA information:
Bytes Description
0 Number of FPGA's - 1
1 Selected FPGA - 1
2 Parallel configuration support (0:no, 1:yes)
VC 0x51 Parameters:
Parameter Description
index Select command
0: Select single FPGA
1: Select all FPGA's for configuration
value FPGA to select - 1
1.0 Temperature sensor support

Vendor request (VR)
or command (VC)
Description
VR 0x58 Return temperature data:
Bytes Description
0 Protocol
1..n Data
1.1 Flash 2 support

Vendor request (VR)
or command (VC)
Description
VR 0x40 Get Flash state. Returns:
Bytes Description
0 1:enabled, 0:disabled
1-2 Sector size
3-6 Number of sectors
7 Error code
VR 0x41 Read one sector from Flash
VC 0x42 Write one sector to Flash

See Also:
ZtexDevice1, Ztex1

Field Summary
static int CAPABILITY_DEBUG
          Capability index for DEBUG helper support.
static int CAPABILITY_EEPROM
          Capability index for EEPROM support.
static int CAPABILITY_FLASH
          Capability index for FLASH memory support.
static int CAPABILITY_FLASH2
          Capability index for 2nd FLASH memory support.
static int CAPABILITY_FPGA
          Capability index for FPGA configuration support.
static int CAPABILITY_HS_FPGA
          Capability index for AVR XMEGA support.
static int CAPABILITY_MAC_EEPROM
          Capability index for AVR XMEGA support.
static int CAPABILITY_MULTI_FPGA
          Capability index for multi FPGA support
static int CAPABILITY_TEMP_SENSOR
          Capability index for Temperature sensor support
static int CAPABILITY_XMEGA
          Capability index for AVR XMEGA support.
static java.lang.String[] capabilityStrings
          The names of the capabilities
 ConfigData config
          The configuration data structure is initialized if this kind of data is present in MAC EEPROM.
 int debugNewMessages
          Is set by debugReadMessages(boolean,byte[]) and contains the number of new messages.
 int eepromBytes
          Number of bytes written to EEPROM.
 int eepromChecksum
          Checksum of the last EEPROM transfer.
 boolean enableExtraFpgaConfigurationChecks
          Enables extra FPGA configuration checks.
static int FLASH_EC_BUSY
          Signals that Flash memory it busy.
static int FLASH_EC_CMD_ERROR
          Signals an error while attempting to execute a command.
static int FLASH_EC_NO_ERROR
          Means no error.
static int FLASH_EC_NOTSUPPORTED
          Signals the the installed Flash memory is not supported.
static int FLASH_EC_PENDING
          Signals that another Flash operation is pending.
static int FLASH_EC_READ_ERROR
          Signals an error while attempting to read from Flash.
static int FLASH_EC_TIMEOUT
          Signals that a timeout occurred.
static int FLASH_EC_WRITE_ERROR
          Signals an error while attempting to write to Flash.
 int flash2EC
          Last 2nd Flash error code obtained by flashState().
 int flashEC
          Last Flash error code obtained by flashState().
 int tempSensorUpdateInterval
          smallest temperature sensor update interval in ms
static int XMEGA_EC_ADDRESS_ERROR
          Signals an address error (invalid address or wrong page size).
static int XMEGA_EC_INVALID_DEVICE
          Signals that the ATxmega controller is not supported.
static int XMEGA_EC_NO_ERROR
          Means no error.
static int XMEGA_EC_NVM_BUSY
          Signals that the NVM is busy.
static int XMEGA_EC_NVM_TIMEOUT
          Signals that an NVM timeout occurred.
static int XMEGA_EC_PDI_READ_ERROR
          Signals a PDI read error.
 int xmegaEC
          Last ATxmega error code obtained by xmegaState().
 
Fields inherited from class ztex.Ztex1
certainWorkarounds, controlMsgTimeout
 
Constructor Summary
Ztex1v1(ZtexDevice1 pDev)
          Constructs an instance from a given device.
 
Method Summary
 java.lang.String capabilityInfo(java.lang.String pf)
          Creates a String with capability information.
 void checkCapability(int i)
          Checks whether ZTEX descriptor 1 is available and interface 1 and a given capability are supported.
 void checkCapability(int i, int j)
          Checks whether ZTEX descriptor 1 is available and interface 1 and a given capability are supported.
 void checkCompatible(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.
 void checkValid()
          Checks whether ZTEX descriptor 1 is available and interface 1 is supported.
 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.
 long configureFpga(java.io.InputStream inputStream, boolean force, int bs)
          Upload a Bitstream to the FPGA using high speed mode (if available) or low speed mode.
 long configureFpga(java.lang.String fwFileName, boolean force)
          Upload a Bitstream to the FPGA using high speed mode (if available) or low speed mode.
 long configureFpga(java.lang.String fwFileName, boolean force, int bs)
          Upload a Bitstream to the FPGA using high speed mode (if available) or low speed mode.
 long configureFpgaHS(java.io.InputStream inputStream, boolean force, int bs)
          Upload a Bitstream to the FPGA using high speed mode.
 long configureFpgaHS(java.lang.String fwFileName, boolean force, int bs)
          Upload a Bitstream to the FPGA using high speed mode.
 long configureFpgaLS(java.io.InputStream inputStream, boolean force, int bs)
          Upload a Bitstream to the FPGA using low speed mode.
 long configureFpgaLS(java.lang.String fwFileName, boolean force, int bs)
          Upload a Bitstream to the FPGA using low speed mode.
 int debugLastMsg()
          Returns the number of the last message read out by debugReadMessages(boolean,byte[])
 int debugMsgSize()
          Returns the size of messages in bytes.
 int debugReadMessages(boolean all, byte[] buf)
          Reads debug messages from message stack.
 int debugStackSize()
          Returns the size of message stack in messages.
 void eepromDisable()
          Disables the firmware stored in the EEPROM.
 void eepromRead(int addr, byte[] buf, int length)
          Reads data from the EEPROM.
 boolean eepromState()
          Reads the current EEPROM status.
 long eepromUpload(java.lang.String ihxFileName, boolean force)
          Upload the firmware to the EEPROM.
 long eepromUpload(ZtexIhxFile1 ihxFile, boolean force)
          Upload the firmware to the EEPROM.
 void eepromWrite(int addr, byte[] buf, int length)
          Writes data to the EEPROM.
 boolean flash2Enabled()
          Returns true if 2nd Flash memory is installed.
 java.lang.String flash2Info()
          Returns information about 2nd Flash memory.
 void flash2ReadSector(int sector, byte[] buf)
          Reads one sector from the 2nd Flash memory.
 void flash2ReadSector(int sector, int num, byte[] buf)
          Reads a integer number of sectors from the 2nd Flash memory.
 int flash2Sectors()
          Returns the number of sectors of the 2nd Flash memory or 0, if no 2nd Flash is installed.
 int flash2SectorSize()
          Returns the sector size of the 2nd Flash memory or 0, if no 2nd Flash is installed.
 long flash2Size()
          Returns the size of 2nd Flash memory or 0, if no 2nd Flash memory is installed.
 boolean flash2State()
          Reads the the 2nd Flash memory status and information.
 java.lang.String flash2StrError()
          Gets the last 2nd Flash error from the device.
 void flash2WriteSector(int sector, byte[] buf)
          Writes one sector to the 2nd Flash memory.
 void flash2WriteSector(int sector, int num, byte[] buf)
          Writes a integer number of sectors to the 2nd Flash.
 boolean flashEnabled()
          Returns true if Flash memory is installed.
 int flashFirstFreeSector()
          Returns the first free sector of the Flash memory.
 java.lang.String flashInfo()
          Returns information about Flash memory.
 void flashReadSector(int sector, byte[] buf)
          Reads one sector from the Flash.
 void flashReadSector(int sector, int num, byte[] buf)
          Reads a integer number of sectors from the Flash.
 void flashResetBitstream()
          Clears a Bitstream from the Flash.
 int flashSectors()
          Returns the number of sectors of the Flash memory or 0, if no Flash memory is installed.
 int flashSectorSize()
          Returns the sector size of the Flash memory or 0, if no Flash is installed.
 long flashSize()
          Returns the size of Flash memory or 0, if no Flash memory is installed.
 boolean flashState()
          Reads the the Flash memory status and information.
 java.lang.String flashStrError()
          Gets the last Flash error from the device.
static java.lang.String flashStrError(int errNum)
          Converts a given error code into a String.
 long flashUploadBitstream(java.io.InputStream inputStream, int bs)
          Uploads a Bitstream to the Flash.
 long flashUploadBitstream(java.lang.String fwFileName)
          Uploads a Bitstream to the Flash.
 long flashUploadBitstream(java.lang.String fwFileName, int bs)
          Uploads a Bitstream to the Flash.
 void flashWriteSector(int sector, byte[] buf)
          Writes one sector to the Flash.
 void flashWriteSector(int sector, int num, byte[] buf)
          Writes a integer number of sectors to the Flash.
 int getFlash2EC()
          Gets the last 2nd Flash memory error from the device.
 int getFlashEC()
          Gets the last Flash error from the device.
 boolean getFpgaConfiguration()
          Returns true if the FPGA is configured.
 java.lang.String getFpgaConfigurationStr()
          Returns a string that indicates the FPGA configuration status.
protected  void init()
          Initializates the class.
 boolean InterfaceCapabilities(int i)
          Returns interface capability bit.
 void macEepromRead(int addr, byte[] buf, int length)
          Reads data from the MAC EEPROM.
 boolean macEepromState()
          Reads the current MAC EEPROM status.
 void macEepromWrite(int addr, byte[] buf, int length)
          Writes data to the MAC EEPROM.
 void macRead(byte[] buf)
          Reads MAC address from MAC EEPROM.
 int numberOfFpgas()
          Returns the number of FPGA's
 void printFpgaState()
          Prints out the FPGA state.
 boolean printMmc2State()
          Prints out some debug information about *SD/MMC Flash cards in SPI mode.
 boolean printMmcState()
          Prints out some debug information about *SD/MMC Flash cards in SPI mode.
 boolean printSpiState()
          Prints out some debug information about SPI Flash.
 void resetFpga()
          Resets the FPGA.
 void selectFpga(int num)
          Select a FPGA
 double tempSensorRead(int idx)
          Read temperature sensor data.
 java.lang.String toString()
          Returns a lot of useful information about the corresponding device.
 boolean valid()
          Returns true if ZTEX interface 1 is available.
 boolean valid(int i, int j)
          Returns true if ZTEX interface 1 and capability i.j are available.
 int xmegaEepromPages()
          Returns the number of the ATxmega EEPROM pages.
 int xmegaEepromPageSize()
          Returns the size of the ATXmega EEPROM pages.
 void xmegaEepromPageWrite(int addr, byte[] buf)
          Writes data to EEPROM memory of ATxmega.
 void xmegaEepromRead(int addr, byte[] buf, int length)
          Reads data from EEPROM memory of ATxmega.
 boolean xmegaEnabled()
          Returns true if ATxmega controller is available.
 int xmegaFlashPages()
          Returns the number of the ATxmega Flash pages.
 int xmegaFlashPageSize()
          Returns the size of the ATxmega Flash pages.
 void xmegaFlashPageWrite(int addr, byte[] buf)
          Writes data to Flash memory of ATxmega.
 void xmegaFlashRead(int addr, byte[] buf, int length)
          Reads data from Flash memory of ATxmega.
 int xmegaFuseRead(int addr)
          Reads data one Fuse of ATxmega.
 void xmegaFuseRead(int addr, byte[] buf, int length)
          Reads data from Fuse memory of ATxmega.
 void xmegaFuseWrite(int addr, int val)
          Writes one Fuse of the ATxmega.
 void xmegaNvmRead(int addr, byte[] buf, int length)
          Reads data from the NVM of ATxmega.
 void xmegaReset()
          Resets the ATxmega.
 int xmegaState()
          Read ATxmega error and status information from the device.
 java.lang.String xmegaStrError()
          Gets the last ATxmega error from the device.
 java.lang.String xmegaStrError(int errNum)
          Converts a given error code into a String.
 long xmegaWriteEeprom(IhxFile ihxFile)
          Uploads data to the EEPROM memory
 long xmegaWriteFirmware(IhxFile ihxFile)
          Uploads firmware to the flash memory
 
Methods inherited from class ztex.Ztex1
claimInterface, dev, finalize, getInterfaceClaimed, handle, releaseInterface, resetEzUsb, setConfiguration, trySetConfiguration, uploadFirmware, uploadFirmware, 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

CAPABILITY_EEPROM

public static final int CAPABILITY_EEPROM
Capability index for EEPROM support.

See Also:
Constant Field Values

CAPABILITY_FPGA

public static final int CAPABILITY_FPGA
Capability index for FPGA configuration support.

See Also:
Constant Field Values

CAPABILITY_FLASH

public static final int CAPABILITY_FLASH
Capability index for FLASH memory support.

See Also:
Constant Field Values

CAPABILITY_DEBUG

public static final int CAPABILITY_DEBUG
Capability index for DEBUG helper support.

See Also:
Constant Field Values

CAPABILITY_XMEGA

public static final int CAPABILITY_XMEGA
Capability index for AVR XMEGA support.

See Also:
Constant Field Values

CAPABILITY_HS_FPGA

public static final int CAPABILITY_HS_FPGA
Capability index for AVR XMEGA support.

See Also:
Constant Field Values

CAPABILITY_MAC_EEPROM

public static final int CAPABILITY_MAC_EEPROM
Capability index for AVR XMEGA support.

See Also:
Constant Field Values

CAPABILITY_MULTI_FPGA

public static final int CAPABILITY_MULTI_FPGA
Capability index for multi FPGA support

See Also:
Constant Field Values

CAPABILITY_TEMP_SENSOR

public static final int CAPABILITY_TEMP_SENSOR
Capability index for Temperature sensor support

See Also:
Constant Field Values

CAPABILITY_FLASH2

public static final int CAPABILITY_FLASH2
Capability index for 2nd FLASH memory support.

See Also:
Constant Field Values

capabilityStrings

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


enableExtraFpgaConfigurationChecks

public boolean enableExtraFpgaConfigurationChecks
Enables extra FPGA configuration checks. Certain Bistream settings may cause false warnings.


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.


flash2EC

public int flash2EC
Last 2nd 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

FLASH_EC_NOTSUPPORTED

public static final int FLASH_EC_NOTSUPPORTED
Signals the the installed Flash memory is not supported.

See Also:
Constant Field Values

debugNewMessages

public int debugNewMessages
Is set by debugReadMessages(boolean,byte[]) and contains the number of new messages.


xmegaEC

public int xmegaEC
Last ATxmega error code obtained by xmegaState(). See XMEGA_EC_* for possible error codes.


XMEGA_EC_NO_ERROR

public static final int XMEGA_EC_NO_ERROR
Means no error.

See Also:
Constant Field Values

XMEGA_EC_PDI_READ_ERROR

public static final int XMEGA_EC_PDI_READ_ERROR
Signals a PDI read error.

See Also:
Constant Field Values

XMEGA_EC_NVM_TIMEOUT

public static final int XMEGA_EC_NVM_TIMEOUT
Signals that an NVM timeout occurred.

See Also:
Constant Field Values

XMEGA_EC_INVALID_DEVICE

public static final int XMEGA_EC_INVALID_DEVICE
Signals that the ATxmega controller is not supported.

See Also:
Constant Field Values

XMEGA_EC_ADDRESS_ERROR

public static final int XMEGA_EC_ADDRESS_ERROR
Signals an address error (invalid address or wrong page size).

See Also:
Constant Field Values

XMEGA_EC_NVM_BUSY

public static final int XMEGA_EC_NVM_BUSY
Signals that the NVM is busy.

See Also:
Constant Field Values

tempSensorUpdateInterval

public int tempSensorUpdateInterval
smallest temperature sensor update interval in ms


config

public ConfigData config
The configuration data structure is initialized if this kind of data is present in MAC EEPROM. In this case MAC EEPROM writes to addresses 0 to 79 are disabled, see macEepromWrite(int,byte[],int). In order to override this behavior set this variable to null. If no configuration data is present config is null.

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

init

protected void init()
             throws UsbException
Initializates the class.

Overrides:
init in class Ztex1
Throws:
UsbException - if an communication error occurred.

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.

checkCapability

public void checkCapability(int i)
                     throws InvalidFirmwareException,
                            CapabilityException
Checks whether ZTEX descriptor 1 is available and interface 1 and a given capability are supported.

Parameters:
i - capability index (0..47)
Throws:
InvalidFirmwareException - if ZTEX descriptor 1 is not available or interface 1 is not supported.
CapabilityException - if the given capability is not supported.

InterfaceCapabilities

public boolean InterfaceCapabilities(int i)
Returns interface capability bit.

Parameters:
i - capability index (0..47)
Returns:
interface capability bit.

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.

configureFpgaLS

public long configureFpgaLS(java.io.InputStream inputStream,
                            boolean force,
                            int bs)
                     throws BitstreamReadException,
                            UsbException,
                            BitstreamUploadException,
                            AlreadyConfiguredException,
                            InvalidFirmwareException,
                            CapabilityException
Upload a Bitstream to the FPGA using low speed mode.

Parameters:
inputStream - for reading the Bitstream.
force - If set to true existing configurations will be overwritten. (By default an AlreadyConfiguredException is thrown).
bs - 0: disable bit swapping, 1: enable bit swapping, all other values: automatic detection of bit order.
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.

configureFpgaLS

public long configureFpgaLS(java.lang.String fwFileName,
                            boolean force,
                            int bs)
                     throws BitstreamReadException,
                            UsbException,
                            BitstreamUploadException,
                            AlreadyConfiguredException,
                            InvalidFirmwareException,
                            CapabilityException
Upload a Bitstream to the FPGA using low speed mode.

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).
bs - 0: disable bit swapping, 1: enable bit swapping, all other values: automatic detection of bit order.
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(ZtexIhxFile1 ihxFile,
                         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:
ihxFile - The firmware image.
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.

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.

flash2StrError

public java.lang.String flash2StrError()
Gets the last 2nd 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.

flash2State

public boolean flash2State()
                    throws UsbException,
                           InvalidFirmwareException,
                           CapabilityException
Reads the the 2nd Flash memory status and information. This method also sets the variables flash2Enabled(), flash2SectorSize() and flash2Sectors().

Returns:
true if 2nd Flash memory is installed.
Throws:
InvalidFirmwareException - if interface 1 is not supported.
UsbException - if a communication error occurs.
CapabilityException - if 2nd 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.

Returns:
The last error code.
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.

getFlash2EC

public int getFlash2EC()
                throws UsbException,
                       InvalidFirmwareException,
                       CapabilityException
Gets the last 2nd Flash memory error from the device.

Returns:
The last error code.
Throws:
InvalidFirmwareException - if interface 1 is not supported.
UsbException - if a communication error occurs.
CapabilityException - if 2nd Flash memory access is not supported by the firmware.

flashReadSector

public void flashReadSector(int sector,
                            int num,
                            byte[] buf)
                     throws UsbException,
                            InvalidFirmwareException,
                            CapabilityException,
                            java.lang.IndexOutOfBoundsException
Reads a integer number of sectors from the Flash.

Parameters:
sector - The number of the first sector to be read.
num - The number of sectors 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.
java.lang.IndexOutOfBoundsException - If the buffer is to small.

flashReadSector

public void flashReadSector(int sector,
                            byte[] buf)
                     throws UsbException,
                            InvalidFirmwareException,
                            CapabilityException,
                            java.lang.IndexOutOfBoundsException
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.
java.lang.IndexOutOfBoundsException - If the buffer is smaller than the Flash sector size.

flash2ReadSector

public void flash2ReadSector(int sector,
                             int num,
                             byte[] buf)
                      throws UsbException,
                             InvalidFirmwareException,
                             CapabilityException,
                             java.lang.IndexOutOfBoundsException
Reads a integer number of sectors from the 2nd Flash memory.

Parameters:
sector - The number of the first sector to be read.
num - The number of sectors 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 2nd Flash access is not possible.
java.lang.IndexOutOfBoundsException - If the buffer is to small.

flash2ReadSector

public void flash2ReadSector(int sector,
                             byte[] buf)
                      throws UsbException,
                             InvalidFirmwareException,
                             CapabilityException,
                             java.lang.IndexOutOfBoundsException
Reads one sector from the 2nd Flash memory.

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 2nd Flash memory access is not possible.
java.lang.IndexOutOfBoundsException - If the buffer is smaller than the 2nd Flash sector size.

flashWriteSector

public void flashWriteSector(int sector,
                             int num,
                             byte[] buf)
                      throws UsbException,
                             InvalidFirmwareException,
                             CapabilityException,
                             java.lang.IndexOutOfBoundsException
Writes a integer number of sectors to the Flash.

Parameters:
sector - The sector number to be written.
num - The number of sectors to be read.
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.
java.lang.IndexOutOfBoundsException - If the buffer is to small.

flashWriteSector

public void flashWriteSector(int sector,
                             byte[] buf)
                      throws UsbException,
                             InvalidFirmwareException,
                             CapabilityException,
                             java.lang.IndexOutOfBoundsException
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.
java.lang.IndexOutOfBoundsException - If the buffer is smaller than the Flash sector size.

flash2WriteSector

public void flash2WriteSector(int sector,
                              int num,
                              byte[] buf)
                       throws UsbException,
                              InvalidFirmwareException,
                              CapabilityException,
                              java.lang.IndexOutOfBoundsException
Writes a integer number of sectors to the 2nd Flash.

Parameters:
sector - The sector number to be written.
num - The number of sectors to be read.
buf - The data.
Throws:
InvalidFirmwareException - if interface 1 is not supported.
UsbException - if a communication error occurs.
CapabilityException - if 2nd Flash memory access is not possible.
java.lang.IndexOutOfBoundsException - If the buffer is to small.

flash2WriteSector

public void flash2WriteSector(int sector,
                              byte[] buf)
                       throws UsbException,
                              InvalidFirmwareException,
                              CapabilityException,
                              java.lang.IndexOutOfBoundsException
Writes one sector to the 2nd Flash memory.

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 2nd Flash access is not possible.
java.lang.IndexOutOfBoundsException - If the buffer is smaller than the 2nd Flash sector size.

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.

flash2Enabled

public boolean flash2Enabled()
                      throws UsbException,
                             InvalidFirmwareException,
                             CapabilityException
Returns true if 2nd Flash memory is installed.

Returns:
true if 2nd Flash memory is installed.
Throws:
InvalidFirmwareException - if interface 1 is not supported.
UsbException - if a communication error occurs.
CapabilityException - if 2nd 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 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.

flash2SectorSize

public int flash2SectorSize()
                     throws UsbException,
                            InvalidFirmwareException,
                            CapabilityException
Returns the sector size of the 2nd Flash memory or 0, if no 2nd Flash is installed. If required, the sector size is determined form the device first.

Returns:
the sector size of the 2nd Flash.
Throws:
InvalidFirmwareException - if interface 1 is not supported.
UsbException - if a communication error occurs.
CapabilityException - if 2nd Flash 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.

flash2Sectors

public int flash2Sectors()
                  throws UsbException,
                         InvalidFirmwareException,
                         CapabilityException
Returns the number of sectors of the 2nd Flash memory or 0, if no 2nd Flash is installed. If required, the number of sectors is determined form the device first.

Returns:
the number of sectors of the 2nd Flash memory.
Throws:
InvalidFirmwareException - if interface 1 is not supported.
UsbException - if a communication error occurs.
CapabilityException - if 2nd 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.

flash2Size

public long flash2Size()
                throws UsbException,
                       InvalidFirmwareException,
                       CapabilityException
Returns the size of 2nd Flash memory or 0, if no 2nd Flash memory is installed. If required, the 2nd 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 2nd 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.

printMmc2State

public boolean printMmc2State()
                       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 as 2nd Flash memory.

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

flashUploadBitstream

public long flashUploadBitstream(java.io.InputStream inputStream,
                                 int bs)
                          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.

If configuration data is present information about bitstream are stored there and Bitstream starts at sector 0.

On all other devices the information about the bitstream is stored in sector 0. This so called boot sector has the following format:

Bytes Description
0..7 ID, must be "ZTEXBS",1,1
8..9 The number of sectors used to store the Bitstream. 0 means no Bitstream.
10..11 The number of bytes in the last sector.
12..sectorSize-1 This 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:
inputStream - for reading the Bitstream.
bs - 0: disable bit swapping, 1: enable bit swapping, all other values: automatic detection of bit order.
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.

flashUploadBitstream

public long flashUploadBitstream(java.lang.String fwFileName,
                                 int bs)
                          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. See flashUploadBitstream(InputStream,int) for further details.

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).
bs - 0: disable bit swapping, 1: enable bit swapping, all other values: automatic detection of bit order.
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.

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. See flashUploadBitstream(InputStream,int) for further details.

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.

flashInfo

public java.lang.String flashInfo()
Returns information about Flash memory. The result contains the size and how much of the Flash is us used / reserved for / by the Bitstream. If no Flash memeory is suppported an empty string is returned. Returns Information about Flash memory.


flash2Info

public java.lang.String flash2Info()
Returns information about 2nd Flash memory. The result contains the size and how much of the Flash is us used / reserved for / by the Bitstream. If no 2nd Flash memeory is suppported an empty string is returned. Returns Information about 2nd Flash memory.


debugStackSize

public int debugStackSize()
                   throws UsbException,
                          InvalidFirmwareException,
                          CapabilityException
Returns the size of message stack in messages.

Returns:
the size of message stack in messages.
Throws:
InvalidFirmwareException - if interface 1 is not supported.
UsbException - if a communication error occurs.
CapabilityException - if Flash memory access is not possible.

debugMsgSize

public int debugMsgSize()
                 throws UsbException,
                        InvalidFirmwareException,
                        CapabilityException
Returns the size of messages in bytes.

Returns:
the size of messages in bytes.
Throws:
InvalidFirmwareException - if interface 1 is not supported.
UsbException - if a communication error occurs.
CapabilityException - if Flash memory access is not possible.

debugLastMsg

public final int debugLastMsg()
Returns the number of the last message read out by debugReadMessages(boolean,byte[])

Returns:
the number of the last message read out by debugReadMessages(boolean,byte[])

debugReadMessages

public int debugReadMessages(boolean all,
                             byte[] buf)
                      throws UsbException,
                             InvalidFirmwareException,
                             CapabilityException
Reads debug messages from message stack. The number of messages stored in buf is returned. The total number of new messages is stored in debugNewMessages. The number of the latest message is returned by debugLastMsg().

Parameters:
all - If true, all messages from stack are written to buf. If it is false, only the new messages are written to buf.
buf - The buffer to store the messages.
Returns:
the size of messages stored in buffer.
Throws:
InvalidFirmwareException - if interface 1 is not supported.
UsbException - if a communication error occurs.
CapabilityException - if Flash memory access is not possible.

xmegaStrError

public java.lang.String xmegaStrError(int errNum)
Converts a given error code into a String.

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

xmegaStrError

public java.lang.String xmegaStrError()
Gets the last ATxmega error from the device.

Returns:
an error message.

xmegaState

public int xmegaState()
               throws UsbException,
                      InvalidFirmwareException,
                      CapabilityException
Read ATxmega error and status information from the device.

Returns:
The last error code.
Throws:
InvalidFirmwareException - if interface 1 is not supported.
UsbException - if a communication error occurs.
CapabilityException - if ATxmega controllers are not supported by the firmware.

xmegaEnabled

public boolean xmegaEnabled()
                     throws UsbException,
                            InvalidFirmwareException,
                            CapabilityException
Returns true if ATxmega controller is available.

Returns:
true if ATxmega controller is available.
Throws:
InvalidFirmwareException - if interface 1 is not supported.
UsbException - if a communication error occurs.
CapabilityException - if ATxmega controllers are not supported by the firmware.

xmegaFlashPages

public int xmegaFlashPages()
                    throws UsbException,
                           InvalidFirmwareException,
                           CapabilityException
Returns the number of the ATxmega Flash pages.

Returns:
The number of the ATxmega Flash pages.
Throws:
InvalidFirmwareException - if interface 1 is not supported.
UsbException - if a communication error occurs.
CapabilityException - if ATxmega controllers are not supported by the firmware.

xmegaEepromPages

public int xmegaEepromPages()
                     throws UsbException,
                            InvalidFirmwareException,
                            CapabilityException
Returns the number of the ATxmega EEPROM pages.

Returns:
The number of the ATxmega EEPROM pages.
Throws:
InvalidFirmwareException - if interface 1 is not supported.
UsbException - if a communication error occurs.
CapabilityException - if ATxmega controllers are not supported by the firmware.

xmegaFlashPageSize

public int xmegaFlashPageSize()
                       throws UsbException,
                              InvalidFirmwareException,
                              CapabilityException
Returns the size of the ATxmega Flash pages.

Returns:
The size of the ATxmega Flash pages.
Throws:
InvalidFirmwareException - if interface 1 is not supported.
UsbException - if a communication error occurs.
CapabilityException - if ATxmega controllers are not supported by the firmware.

xmegaEepromPageSize

public int xmegaEepromPageSize()
                        throws UsbException,
                               InvalidFirmwareException,
                               CapabilityException
Returns the size of the ATXmega EEPROM pages.

Returns:
The size of the ATXmega EEPROM pages.
Throws:
InvalidFirmwareException - if interface 1 is not supported.
UsbException - if a communication error occurs.
CapabilityException - if ATXmega controllers are not supported by the firmware.

xmegaReset

public void xmegaReset()
                throws UsbException,
                       InvalidFirmwareException,
                       CapabilityException
Resets the ATxmega.

Throws:
InvalidFirmwareException - if interface 1 is not supported.
UsbException - if a communication error occurs.
CapabilityException - if NVRAM access to ATxmega is not supported by the firmware.

xmegaNvmRead

public void xmegaNvmRead(int addr,
                         byte[] buf,
                         int length)
                  throws UsbException,
                         InvalidFirmwareException,
                         CapabilityException
Reads data from the NVM of ATxmega.

Parameters:
addr - The source address of the NVM (PDI address space).
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 NVRAM access to ATxmega is not supported by the firmware.

xmegaFlashRead

public void xmegaFlashRead(int addr,
                           byte[] buf,
                           int length)
                    throws UsbException,
                           InvalidFirmwareException,
                           CapabilityException
Reads data from Flash memory of ATxmega.

Parameters:
addr - The source address relative to the Flash memory base.
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 NVRAM access to ATxmega is not supported by the firmware.

xmegaEepromRead

public void xmegaEepromRead(int addr,
                            byte[] buf,
                            int length)
                     throws UsbException,
                            InvalidFirmwareException,
                            CapabilityException
Reads data from EEPROM memory of ATxmega.

Parameters:
addr - The source address relative to the EEPROM memory base.
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 NVRAM access to ATxmega is not supported by the firmware.

xmegaFuseRead

public void xmegaFuseRead(int addr,
                          byte[] buf,
                          int length)
                   throws UsbException,
                          InvalidFirmwareException,
                          CapabilityException
Reads data from Fuse memory of ATxmega.

Parameters:
addr - The source address relative to the Fuse memory base.
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 NVRAM access to ATxmega is not supported by the firmware.

xmegaFuseRead

public int xmegaFuseRead(int addr)
                  throws UsbException,
                         InvalidFirmwareException,
                         CapabilityException
Reads data one Fuse of ATxmega.

Parameters:
addr - The index of th Fuse.
Returns:
The Fuse read.
Throws:
InvalidFirmwareException - if interface 1 is not supported.
UsbException - If a communication error occurs.
CapabilityException - If NVRAM access to ATxmega is not supported by the firmware.

xmegaFlashPageWrite

public void xmegaFlashPageWrite(int addr,
                                byte[] buf)
                         throws UsbException,
                                InvalidFirmwareException,
                                CapabilityException,
                                java.lang.IndexOutOfBoundsException
Writes data to Flash memory of ATxmega.

Parameters:
addr - The source address relative to the Flash memory base.
buf - A buffer that stores the data.
Throws:
InvalidFirmwareException - if interface 1 is not supported.
UsbException - if a communication error occurs.
CapabilityException - if NVRAM access to ATxmega is not supported by the firmware.
java.lang.IndexOutOfBoundsException - If the buffer is smaller than the Flash page size.

xmegaEepromPageWrite

public void xmegaEepromPageWrite(int addr,
                                 byte[] buf)
                          throws UsbException,
                                 InvalidFirmwareException,
                                 CapabilityException,
                                 java.lang.IndexOutOfBoundsException
Writes data to EEPROM memory of ATxmega.

Parameters:
addr - The source address relative to the EEPROM memory base.
buf - A buffer that stores the data.
Throws:
InvalidFirmwareException - if interface 1 is not supported.
UsbException - if a communication error occurs.
CapabilityException - if NVRAM access to ATxmega is not supported by the firmware.
java.lang.IndexOutOfBoundsException - If the buffer is smaller than the EEPROM page size.

xmegaFuseWrite

public void xmegaFuseWrite(int addr,
                           int val)
                    throws UsbException,
                           InvalidFirmwareException,
                           CapabilityException
Writes one Fuse of the ATxmega.

Parameters:
addr - The index of th Fuse.
val - The value of th Fuse.
Throws:
InvalidFirmwareException - if interface 1 is not supported.
UsbException - if a communication error occurs.
CapabilityException - if NVRAM access to ATxmega is not supported by the firmware.

xmegaWriteFirmware

public long xmegaWriteFirmware(IhxFile ihxFile)
                        throws UsbException,
                               InvalidFirmwareException,
                               CapabilityException,
                               FirmwareUploadException
Uploads firmware to the flash memory

Parameters:
ihxFile - The firmware / data image.
Returns:
the upload time in ms.
Throws:
InvalidFirmwareException - if interface 1 is not supported.
UsbException - if a communication error occurs.
CapabilityException - if NVRAM access to ATxmega is not supported by the firmware.
FirmwareUploadException - if the verification fails.

xmegaWriteEeprom

public long xmegaWriteEeprom(IhxFile ihxFile)
                      throws UsbException,
                             InvalidFirmwareException,
                             CapabilityException,
                             FirmwareUploadException
Uploads data to the EEPROM memory

Parameters:
ihxFile - The firmware / data image.
Returns:
the upload time in ms.
Throws:
InvalidFirmwareException - if interface 1 is not supported.
UsbException - if a communication error occurs.
CapabilityException - if NVRAM access to ATxmega is not supported by the firmware.
FirmwareUploadException - if the verification fails.

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.

configureFpgaHS

public long configureFpgaHS(java.io.InputStream inputStream,
                            boolean force,
                            int bs)
                     throws BitstreamReadException,
                            UsbException,
                            BitstreamUploadException,
                            AlreadyConfiguredException,
                            InvalidFirmwareException,
                            CapabilityException
Upload a Bitstream to the FPGA using high speed mode.

Parameters:
inputStream - for reading the Bitstream.
force - If set to true existing configurations will be overwritten. (By default an AlreadyConfiguredException is thrown).
bs - 0: disable bit swapping, 1: enable bit swapping, all other values: automatic detection of bit order.
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.

configureFpgaHS

public long configureFpgaHS(java.lang.String fwFileName,
                            boolean force,
                            int bs)
                     throws BitstreamReadException,
                            UsbException,
                            BitstreamUploadException,
                            AlreadyConfiguredException,
                            InvalidFirmwareException,
                            CapabilityException
Upload a Bitstream to the FPGA using high speed mode.

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).
bs - 0: disable bit swapping, 1: enable bit swapping, all other values: automatic detection of bit order.
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.

configureFpga

public long configureFpga(java.io.InputStream inputStream,
                          boolean force,
                          int bs)
                   throws BitstreamReadException,
                          UsbException,
                          BitstreamUploadException,
                          AlreadyConfiguredException,
                          InvalidFirmwareException,
                          CapabilityException,
                          java.io.IOException
Upload a Bitstream to the FPGA using high speed mode (if available) or low speed mode.

Parameters:
inputStream - for reading the Bitstream.
force - If set to true existing configurations will be overwritten. (By default an AlreadyConfiguredException is thrown).
bs - 0: disable bit swapping, 1: enable bit swapping, all other values: automatic detection of bit order.
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.
java.io.IOException - if mark/reset is not supported

configureFpga

public long configureFpga(java.lang.String fwFileName,
                          boolean force,
                          int bs)
                   throws BitstreamReadException,
                          UsbException,
                          BitstreamUploadException,
                          AlreadyConfiguredException,
                          InvalidFirmwareException,
                          CapabilityException
Upload a Bitstream to the FPGA using high speed mode (if available) or low speed mode.

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).
bs - 0: disable bit swapping, 1: enable bit swapping, all other values: automatic detection of bit order.
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.

configureFpga

public long configureFpga(java.lang.String fwFileName,
                          boolean force)
                   throws BitstreamReadException,
                          UsbException,
                          BitstreamUploadException,
                          AlreadyConfiguredException,
                          InvalidFirmwareException,
                          CapabilityException
Upload a Bitstream to the FPGA using high speed mode (if available) or low speed mode.

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.

macEepromWrite

public void macEepromWrite(int addr,
                           byte[] buf,
                           int length)
                    throws UsbException,
                           InvalidFirmwareException,
                           CapabilityException
Writes data to the MAC EEPROM.

Parameters:
addr - The destination address of the MAC 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 MAC EEPROM access is not supported by the firmware or if configuration data is present and there is a write to addresses 0 to 79. In order to override this behavior set config variable to null.

macEepromRead

public void macEepromRead(int addr,
                          byte[] buf,
                          int length)
                   throws UsbException,
                          InvalidFirmwareException,
                          CapabilityException
Reads data from the MAC EEPROM.

Parameters:
addr - The source address of the MAC 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 MAC EEPROM access is not supported by the firmware.

macEepromState

public boolean macEepromState()
                       throws UsbException,
                              InvalidFirmwareException,
                              CapabilityException
Reads the current MAC EEPROM status.

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

macRead

public void macRead(byte[] buf)
             throws UsbException,
                    InvalidFirmwareException,
                    CapabilityException,
                    java.lang.IndexOutOfBoundsException
Reads MAC address from MAC EEPROM.

Parameters:
buf - A buffer with a minimum size of 6 bytes.
Throws:
InvalidFirmwareException - if interface 1 is not supported.
UsbException - if a communication error occurs.
CapabilityException - if MAC EEPROM access is not supported by the firmware.
java.lang.IndexOutOfBoundsException - If the buffer is smaller than 6 bytes.

numberOfFpgas

public int numberOfFpgas()
                  throws UsbException,
                         InvalidFirmwareException
Returns the number of FPGA's

Returns:
number of FPGA's
Throws:
InvalidFirmwareException - if interface 1 is not supported.
UsbException - if a communication error occurs.

selectFpga

public void selectFpga(int num)
                throws UsbException,
                       InvalidFirmwareException,
                       java.lang.IndexOutOfBoundsException
Select a FPGA

Parameters:
num - FPGA to select. Valid values are 0 to numberOfFpgas()-1
Throws:
InvalidFirmwareException - if interface 1 is not supported.
UsbException - if a communication error occurs.
java.lang.IndexOutOfBoundsException - If FPGA number is not in range.

tempSensorRead

public double tempSensorRead(int idx)
                      throws UsbException,
                             InvalidFirmwareException,
                             CapabilityException,
                             java.lang.IndexOutOfBoundsException
Read temperature sensor data.

Parameters:
idx - Temperature sensor index
Returns:
Temperature in deg. C
Throws:
InvalidFirmwareException - If interface 1 or temperature sensor protocol is not supported.
UsbException - If a communication error occurs.
CapabilityException - If NVRAM access to ATxmega is not supported by the firmware.
java.lang.IndexOutOfBoundsException - If idx is not in range.

printSpiState

public boolean printSpiState()
                      throws UsbException,
                             InvalidFirmwareException,
                             CapabilityException
Prints out some debug information about SPI Flash.
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.