- 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:
schlaepfer
2006-03-10 12:25:27 +00:00
parent 21dd40ea51
commit 1b54b86f64
2 changed files with 38 additions and 28 deletions

View File

@@ -223,14 +223,14 @@ public class MC68332 {
private boolean ignoreResult; private boolean ignoreResult;
private Device device;
public MC68332(Device device) { public MC68332(Device device) {
ignoreResult = false; ignoreResult = false;
readMemSize = 0; readMemSize = 0;
writeMemSize = 0; writeMemSize = 0;
sendData = new byte[USB.HIGHSPEED_MAX_BULK_PACKET_SIZE]; sendData = new byte[USB.HIGHSPEED_MAX_BULK_PACKET_SIZE];
maxNofLongs = (device.getMaxPacketSize() - DataPacket.PACKET_MIN_LENGTH - 2) / 6; this.device = device;
maxNofBytesWords = (device.getMaxPacketSize()
- DataPacket.PACKET_MIN_LENGTH - 2) / 4;
} }
/** /**
@@ -503,6 +503,18 @@ public class MC68332 {
return targetInDebugMode; 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 large blocks of memory.<br>
* Fill is used in conjunction with the <code>writeMem</code> command. The * Fill is used in conjunction with the <code>writeMem</code> command. The
@@ -529,11 +541,13 @@ public class MC68332 {
int currentIndex = 0; int currentIndex = 0;
DataPacket data; DataPacket data;
logger.finer("dataLength: " + dataLength); logger.finer("dataLength: " + dataLength);
updateMaxValues();
switch (writeMemSize) { switch (writeMemSize) {
case 1: case 1:
if (dataLength > maxNofBytesWords) { if (dataLength > maxNofBytesWords) {
throw new BDIException( throw new BDIException("data length (" + dataLength
"data larger than MAX_NOF_WORDS_FAST_DOWNLOAD_BYTE_WORD"); + ") larger than maxNofBytesWords (" + maxNofBytesWords
+ ")");
} }
while (currentIndex < dataLength) { while (currentIndex < dataLength) {
// FILLB // FILLB
@@ -551,8 +565,9 @@ public class MC68332 {
break; break;
case 2: case 2:
if (dataLength > maxNofBytesWords) { if (dataLength > maxNofBytesWords) {
throw new BDIException( throw new BDIException("data length (" + dataLength
"data larger than MAX_NOF_WORDS_FAST_DOWNLOAD_BYTE_WORD"); + ") larger than maxNofBytesWords (" + maxNofBytesWords
+ ")");
} }
while (currentIndex < dataLength) { while (currentIndex < dataLength) {
// FILLW // FILLW
@@ -570,8 +585,8 @@ public class MC68332 {
break; break;
case 4: case 4:
if (dataLength > (maxNofLongs)) { if (dataLength > (maxNofLongs)) {
throw new BDIException( throw new BDIException("data length (" + dataLength
"data larger than MAX_NOF_WORDS_FAST_DOWNLOAD_LONG"); + ") larger than maxNofLongs (" + maxNofLongs + ")");
} }
while (currentIndex < dataLength) { while (currentIndex < dataLength) {
// FILL // FILL
@@ -630,6 +645,7 @@ public class MC68332 {
BDIException { BDIException {
// TODO: adjust MAX_NOF_XX_DUMP // TODO: adjust MAX_NOF_XX_DUMP
updateMaxValues();
int dataSize; int dataSize;
switch (readMemSize) { switch (readMemSize) {
case 1: 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> * 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 * This value may not be up to date as the target state may have changed

View File

@@ -244,18 +244,19 @@ public class BDI332test {
} }
public static void button9() { public static void button9() {
try { logger.info("not implemented");
bdi.nop(); // try {
} catch (USBException e) { // bdi.nop();
// TODO Auto-generated catch block // } catch (USBException e) {
e.printStackTrace(); // // TODO Auto-generated catch block
} catch (DispatchException e) { // e.printStackTrace();
// TODO Auto-generated catch block // } catch (DispatchException e) {
e.printStackTrace(); // // TODO Auto-generated catch block
} catch (BDIException e) { // e.printStackTrace();
// TODO Auto-generated catch block // } catch (BDIException e) {
e.printStackTrace(); // // TODO Auto-generated catch block
} // e.printStackTrace();
// }
} }
public static void button10() { public static void button10() {