- update the maximal values for fill and dump
- nop() method removed git-svn-id: https://svn.code.sf.net/p/libusbjava/code/trunk@112 94ad28fe-ef68-46b1-9651-e7ae4fcf1c4c
This commit is contained in:
@@ -223,14 +223,14 @@ public class MC68332 {
|
||||
|
||||
private boolean ignoreResult;
|
||||
|
||||
private Device device;
|
||||
|
||||
public MC68332(Device device) {
|
||||
ignoreResult = false;
|
||||
readMemSize = 0;
|
||||
writeMemSize = 0;
|
||||
sendData = new byte[USB.HIGHSPEED_MAX_BULK_PACKET_SIZE];
|
||||
maxNofLongs = (device.getMaxPacketSize() - DataPacket.PACKET_MIN_LENGTH - 2) / 6;
|
||||
maxNofBytesWords = (device.getMaxPacketSize()
|
||||
- DataPacket.PACKET_MIN_LENGTH - 2) / 4;
|
||||
this.device = device;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -503,6 +503,18 @@ public class MC68332 {
|
||||
return targetInDebugMode;
|
||||
}
|
||||
|
||||
private void updateMaxValues() {
|
||||
// update the values (now the device should be connected)
|
||||
if ((maxNofLongs <= 0) | (maxNofBytesWords <= 0)) {
|
||||
maxNofLongs = (device.getMaxPacketSize()
|
||||
- DataPacket.PACKET_MIN_LENGTH - 2) / 6;
|
||||
maxNofBytesWords = (device.getMaxPacketSize()
|
||||
- DataPacket.PACKET_MIN_LENGTH - 2) / 4;
|
||||
logger.finer("update maxNofLongs: " + maxNofLongs
|
||||
+ ", maxNofBytesWords: " + maxNofBytesWords);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill large blocks of memory.<br>
|
||||
* Fill is used in conjunction with the <code>writeMem</code> command. The
|
||||
@@ -529,11 +541,13 @@ public class MC68332 {
|
||||
int currentIndex = 0;
|
||||
DataPacket data;
|
||||
logger.finer("dataLength: " + dataLength);
|
||||
updateMaxValues();
|
||||
switch (writeMemSize) {
|
||||
case 1:
|
||||
if (dataLength > maxNofBytesWords) {
|
||||
throw new BDIException(
|
||||
"data larger than MAX_NOF_WORDS_FAST_DOWNLOAD_BYTE_WORD");
|
||||
throw new BDIException("data length (" + dataLength
|
||||
+ ") larger than maxNofBytesWords (" + maxNofBytesWords
|
||||
+ ")");
|
||||
}
|
||||
while (currentIndex < dataLength) {
|
||||
// FILLB
|
||||
@@ -551,8 +565,9 @@ public class MC68332 {
|
||||
break;
|
||||
case 2:
|
||||
if (dataLength > maxNofBytesWords) {
|
||||
throw new BDIException(
|
||||
"data larger than MAX_NOF_WORDS_FAST_DOWNLOAD_BYTE_WORD");
|
||||
throw new BDIException("data length (" + dataLength
|
||||
+ ") larger than maxNofBytesWords (" + maxNofBytesWords
|
||||
+ ")");
|
||||
}
|
||||
while (currentIndex < dataLength) {
|
||||
// FILLW
|
||||
@@ -570,8 +585,8 @@ public class MC68332 {
|
||||
break;
|
||||
case 4:
|
||||
if (dataLength > (maxNofLongs)) {
|
||||
throw new BDIException(
|
||||
"data larger than MAX_NOF_WORDS_FAST_DOWNLOAD_LONG");
|
||||
throw new BDIException("data length (" + dataLength
|
||||
+ ") larger than maxNofLongs (" + maxNofLongs + ")");
|
||||
}
|
||||
while (currentIndex < dataLength) {
|
||||
// FILL
|
||||
@@ -630,6 +645,7 @@ public class MC68332 {
|
||||
BDIException {
|
||||
|
||||
// TODO: adjust MAX_NOF_XX_DUMP
|
||||
updateMaxValues();
|
||||
int dataSize;
|
||||
switch (readMemSize) {
|
||||
case 1:
|
||||
@@ -974,13 +990,6 @@ public class MC68332 {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: remove
|
||||
public void nop() throws USBException, DispatchException, BDIException {
|
||||
logger
|
||||
.info("result: 0x"
|
||||
+ Integer.toHexString(transferAndParse17(NOP)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the last known state of the freeze signal.<br>
|
||||
* This value may not be up to date as the target state may have changed
|
||||
|
||||
@@ -244,18 +244,19 @@ public class BDI332test {
|
||||
}
|
||||
|
||||
public static void button9() {
|
||||
try {
|
||||
bdi.nop();
|
||||
} catch (USBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (DispatchException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (BDIException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
logger.info("not implemented");
|
||||
// try {
|
||||
// bdi.nop();
|
||||
// } catch (USBException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// } catch (DispatchException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// } catch (BDIException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
}
|
||||
|
||||
public static void button10() {
|
||||
|
||||
Reference in New Issue
Block a user