From 1b54b86f64557a83304ea4a41c90ba20043b7d00 Mon Sep 17 00:00:00 2001 From: schlaepfer Date: Fri, 10 Mar 2006 12:25:27 +0000 Subject: [PATCH] - 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 --- mcdp/src/ch/ntb/mcdp/bdi/MC68332.java | 41 +++++++++++-------- mcdp/src/ch/ntb/mcdp/bdi/test/BDI332test.java | 25 +++++------ 2 files changed, 38 insertions(+), 28 deletions(-) diff --git a/mcdp/src/ch/ntb/mcdp/bdi/MC68332.java b/mcdp/src/ch/ntb/mcdp/bdi/MC68332.java index e2a0844..7fbc1b4 100644 --- a/mcdp/src/ch/ntb/mcdp/bdi/MC68332.java +++ b/mcdp/src/ch/ntb/mcdp/bdi/MC68332.java @@ -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.
* Fill is used in conjunction with the writeMem 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.
* This value may not be up to date as the target state may have changed diff --git a/mcdp/src/ch/ntb/mcdp/bdi/test/BDI332test.java b/mcdp/src/ch/ntb/mcdp/bdi/test/BDI332test.java index 51e5658..e5f831c 100644 --- a/mcdp/src/ch/ntb/mcdp/bdi/test/BDI332test.java +++ b/mcdp/src/ch/ntb/mcdp/bdi/test/BDI332test.java @@ -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() {