- 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:
@@ -120,7 +120,7 @@ public class MPC555 {
|
|||||||
*/
|
*/
|
||||||
private static final int NULL_INDICATION = -1;
|
private static final int NULL_INDICATION = -1;
|
||||||
|
|
||||||
private final int maxNofWordsFastDownload;
|
private int maxNofWordsFastDownload;
|
||||||
|
|
||||||
private boolean fastDownloadStarted;
|
private boolean fastDownloadStarted;
|
||||||
|
|
||||||
@@ -130,10 +130,12 @@ public class MPC555 {
|
|||||||
|
|
||||||
private int gpr30, gpr31, ecr;
|
private int gpr30, gpr31, ecr;
|
||||||
|
|
||||||
|
private Device device;
|
||||||
|
|
||||||
public MPC555(Device device) {
|
public MPC555(Device device) {
|
||||||
targetInDebugMode = false;
|
targetInDebugMode = false;
|
||||||
fastDownloadStarted = 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];
|
sendData = new byte[USB.HIGHSPEED_MAX_BULK_PACKET_SIZE];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -459,9 +461,14 @@ public class MPC555 {
|
|||||||
if (!fastDownloadStarted) {
|
if (!fastDownloadStarted) {
|
||||||
throw new BDIException("start fast download first");
|
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
|
// check if data fits into USB-packet
|
||||||
if (dataLength > maxNofWordsFastDownload) {
|
if (dataLength > maxNofWordsFastDownload) {
|
||||||
throw new BDIException("data larger than maxNofWordsFastDownload");
|
throw new BDIException("data larger than maxNofWordsFastDownload: "
|
||||||
|
+ dataLength + " > " + maxNofWordsFastDownload);
|
||||||
}
|
}
|
||||||
int currentIndex = 0;
|
int currentIndex = 0;
|
||||||
initPacket(STYPE_BDI_35FD_DATA, dataLength * BDI_DATA35_LENGTH);
|
initPacket(STYPE_BDI_35FD_DATA, dataLength * BDI_DATA35_LENGTH);
|
||||||
|
|||||||
@@ -10,10 +10,9 @@ public class MC68332 {
|
|||||||
private static ch.ntb.mcdp.bdi.MC68332 bdi;
|
private static ch.ntb.mcdp.bdi.MC68332 bdi;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new BDI instance. This procedure has to be called AFTER opening
|
* Create a new BDI instance.
|
||||||
* the USB device and BEFORE using any BDI commands.
|
|
||||||
*/
|
*/
|
||||||
public static void initialise() {
|
static {
|
||||||
bdi = new ch.ntb.mcdp.bdi.MC68332(USBDevice.getDevice());
|
bdi = new ch.ntb.mcdp.bdi.MC68332(USBDevice.getDevice());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,10 +10,9 @@ public class MPC555 {
|
|||||||
private static ch.ntb.mcdp.bdi.MPC555 bdi;
|
private static ch.ntb.mcdp.bdi.MPC555 bdi;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new BDI instance. This procedure has to be called AFTER opening
|
* Create a new BDI instance.
|
||||||
* the USB device and BEFORE using any BDI commands.
|
|
||||||
*/
|
*/
|
||||||
public static void initialise() {
|
static {
|
||||||
bdi = new ch.ntb.mcdp.bdi.MPC555(USBDevice.getDevice());
|
bdi = new ch.ntb.mcdp.bdi.MPC555(USBDevice.getDevice());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import org.eclipse.swt.widgets.Button;
|
|||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
|
import ch.ntb.mcdp.bdi.MC68332;
|
||||||
import ch.ntb.mcdp.usb.USBDevice;
|
import ch.ntb.mcdp.usb.USBDevice;
|
||||||
import ch.ntb.usb.USBException;
|
import ch.ntb.usb.USBException;
|
||||||
|
|
||||||
@@ -194,7 +195,7 @@ public class BDI332App {
|
|||||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||||
public void widgetSelected(
|
public void widgetSelected(
|
||||||
org.eclipse.swt.events.SelectionEvent e) {
|
org.eclipse.swt.events.SelectionEvent e) {
|
||||||
BDI332test.button19();
|
Dump332.dumpToBin();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
button20 = new Button(sShell, SWT.NONE);
|
button20 = new Button(sShell, SWT.NONE);
|
||||||
@@ -203,7 +204,7 @@ public class BDI332App {
|
|||||||
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||||
public void widgetSelected(
|
public void widgetSelected(
|
||||||
org.eclipse.swt.events.SelectionEvent e) {
|
org.eclipse.swt.events.SelectionEvent e) {
|
||||||
BDI332test.button20();
|
Dump332.dumpToHex();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
button15
|
button15
|
||||||
@@ -252,6 +253,9 @@ public class BDI332App {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
USBDevice.open();
|
USBDevice.open();
|
||||||
|
MC68332 bdi = new MC68332(USBDevice.getDevice());
|
||||||
|
BDI332test.bdi = bdi;
|
||||||
|
Dump332.bdi = bdi;
|
||||||
System.out.println("open device...");
|
System.out.println("open device...");
|
||||||
} catch (USBException e) {
|
} catch (USBException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
Reference in New Issue
Block a user