- create instance of BDIxx when loading class

- get maxNofWordsFastDownload when connected

git-svn-id: https://svn.code.sf.net/p/libusbjava/code/trunk@108 94ad28fe-ef68-46b1-9651-e7ae4fcf1c4c
This commit is contained in:
schlaepfer
2006-03-08 11:57:55 +00:00
parent f3693f284b
commit 95c53d0da3
4 changed files with 20 additions and 11 deletions

View File

@@ -120,7 +120,7 @@ public class MPC555 {
*/
private static final int NULL_INDICATION = -1;
private final int maxNofWordsFastDownload;
private int maxNofWordsFastDownload;
private boolean fastDownloadStarted;
@@ -130,10 +130,12 @@ public class MPC555 {
private int gpr30, gpr31, ecr;
private Device device;
public MPC555(Device device) {
targetInDebugMode = false;
fastDownloadStarted = false;
maxNofWordsFastDownload = ((device.getMaxPacketSize() - DataPacket.PACKET_MIN_LENGTH) / BDI_DATA35_LENGTH);
this.device = device;
sendData = new byte[USB.HIGHSPEED_MAX_BULK_PACKET_SIZE];
}
@@ -459,9 +461,14 @@ public class MPC555 {
if (!fastDownloadStarted) {
throw new BDIException("start fast download first");
}
// update the value (now the device should be connected)
if (maxNofWordsFastDownload <= 0) {
maxNofWordsFastDownload = ((device.getMaxPacketSize() - DataPacket.PACKET_MIN_LENGTH) / BDI_DATA35_LENGTH);
}
// check if data fits into USB-packet
if (dataLength > maxNofWordsFastDownload) {
throw new BDIException("data larger than maxNofWordsFastDownload");
throw new BDIException("data larger than maxNofWordsFastDownload: "
+ dataLength + " > " + maxNofWordsFastDownload);
}
int currentIndex = 0;
initPacket(STYPE_BDI_35FD_DATA, dataLength * BDI_DATA35_LENGTH);

View File

@@ -10,10 +10,9 @@ public class MC68332 {
private static ch.ntb.mcdp.bdi.MC68332 bdi;
/**
* Create a new BDI instance. This procedure has to be called AFTER opening
* the USB device and BEFORE using any BDI commands.
* Create a new BDI instance.
*/
public static void initialise() {
static {
bdi = new ch.ntb.mcdp.bdi.MC68332(USBDevice.getDevice());
}

View File

@@ -10,10 +10,9 @@ public class MPC555 {
private static ch.ntb.mcdp.bdi.MPC555 bdi;
/**
* Create a new BDI instance. This procedure has to be called AFTER opening
* the USB device and BEFORE using any BDI commands.
* Create a new BDI instance.
*/
public static void initialise() {
static {
bdi = new ch.ntb.mcdp.bdi.MPC555(USBDevice.getDevice());
}

View File

@@ -6,6 +6,7 @@ import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import ch.ntb.mcdp.bdi.MC68332;
import ch.ntb.mcdp.usb.USBDevice;
import ch.ntb.usb.USBException;
@@ -194,7 +195,7 @@ public class BDI332App {
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
public void widgetSelected(
org.eclipse.swt.events.SelectionEvent e) {
BDI332test.button19();
Dump332.dumpToBin();
}
});
button20 = new Button(sShell, SWT.NONE);
@@ -203,7 +204,7 @@ public class BDI332App {
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
public void widgetSelected(
org.eclipse.swt.events.SelectionEvent e) {
BDI332test.button20();
Dump332.dumpToHex();
}
});
button15
@@ -252,6 +253,9 @@ public class BDI332App {
try {
USBDevice.open();
MC68332 bdi = new MC68332(USBDevice.getDevice());
BDI332test.bdi = bdi;
Dump332.bdi = bdi;
System.out.println("open device...");
} catch (USBException e) {
e.printStackTrace();