Line 1... |
Line 1... |
/*!
|
/*!
|
Java Driver API for the ZTEX Firmware Kit
|
Java host software API of ZTEX EZ-USB FX2 SDK
|
Copyright (C) 2009-2010 ZTEX e.K.
|
Copyright (C) 2009-2011 ZTEX GmbH.
|
http://www.ztex.de
|
http://www.ztex.de
|
|
|
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
it under the terms of the GNU General Public License version 3 as
|
it under the terms of the GNU General Public License version 3 as
|
published by the Free Software Foundation.
|
published by the Free Software Foundation.
|
Line 32... |
Line 32... |
* Controls the reset state of a Cypress EZ-USB device.
|
* Controls the reset state of a Cypress EZ-USB device.
|
* @param handle The handle of the device.
|
* @param handle The handle of the device.
|
* @param r The reset state (true means reset).
|
* @param r The reset state (true means reset).
|
* @throws FirmwareUploadException if an error occurred while attempting to control the reset state.
|
* @throws FirmwareUploadException if an error occurred while attempting to control the reset state.
|
*/
|
*/
|
public static void reset ( int handle, boolean r ) throws FirmwareUploadException {
|
public static void reset ( long handle, boolean r ) throws FirmwareUploadException {
|
byte buffer[] = { (byte) (r ? 1 : 0) };
|
byte buffer[] = { (byte) (r ? 1 : 0) };
|
int k = LibusbJava.usb_control_msg(handle, 0x40, 0xA0, 0xE600, 0, buffer, 1, 1000); // upload j bytes
|
int k = LibusbJava.usb_control_msg(handle, 0x40, 0xA0, 0xE600, 0, buffer, 1, 1000); // upload j bytes
|
if ( k<0 )
|
if ( k<0 )
|
throw new FirmwareUploadException( LibusbJava.usb_strerror() + ": unable to set reset="+buffer[0] );
|
throw new FirmwareUploadException( LibusbJava.usb_strerror() + ": unable to set reset="+buffer[0] );
|
else if ( k!=1 )
|
else if ( k!=1 )
|
Line 54... |
Line 54... |
* @param handle The handle of the device.
|
* @param handle The handle of the device.
|
* @param ihxFile The firmware image.
|
* @param ihxFile The firmware image.
|
* @return the upload time in ms.
|
* @return the upload time in ms.
|
* @throws FirmwareUploadException if an error occurred while attempting to upload the firmware.
|
* @throws FirmwareUploadException if an error occurred while attempting to upload the firmware.
|
*/
|
*/
|
public static long uploadFirmware (int handle, IhxFile ihxFile ) throws FirmwareUploadException {
|
public static long uploadFirmware (long handle, IhxFile ihxFile ) throws FirmwareUploadException {
|
final int transactionBytes = 256;
|
final int transactionBytes = 256;
|
byte[] buffer = new byte[transactionBytes];
|
byte[] buffer = new byte[transactionBytes];
|
|
|
reset( handle, true ); // reset = 1
|
reset( handle, true ); // reset = 1
|
|
|