- structural changes (Device, BDI, IMCBTargetBoard as instances)

git-svn-id: https://svn.code.sf.net/p/libusbjava/code/trunk@102 94ad28fe-ef68-46b1-9651-e7ae4fcf1c4c
This commit is contained in:
schlaepfer
2006-02-17 17:05:23 +00:00
parent 438202bfef
commit ecbc5c4b77
9 changed files with 1103 additions and 546 deletions

View File

@@ -6,6 +6,7 @@ import ch.ntb.mcdp.usb.DispatchException;
import ch.ntb.mcdp.usb.USBDevice; import ch.ntb.mcdp.usb.USBDevice;
import ch.ntb.mcdp.utils.logger.LogUtil; import ch.ntb.mcdp.utils.logger.LogUtil;
import ch.ntb.mcdp.utils.logger.McdpLogger; import ch.ntb.mcdp.utils.logger.McdpLogger;
import ch.ntb.usb.Device;
import ch.ntb.usb.USB; import ch.ntb.usb.USB;
import ch.ntb.usb.USBException; import ch.ntb.usb.USBException;
@@ -199,33 +200,37 @@ public class MC68332 {
* download (fill) or read (dump). <br> * download (fill) or read (dump). <br>
* Note that no status bit is used. Therefore one data entity is only 16 * Note that no status bit is used. Therefore one data entity is only 16
* bits wide (not 17 bits like normal commands). <br> * bits wide (not 17 bits like normal commands). <br>
* <code>MAX_NOF_WORDS_FAST_DOWNLOAD</code> is a multiple of 4 (FILLB/W + * <code>maxNofWordsFastDownload</code> is a multiple of 4 (FILLB/W +
* data). * data).
*/ */
public static final int MAX_NOF_BYTES_WORDS = (USB.MAX_DATA_SIZE private int maxNofBytesWords;
- DataPacket.PACKET_MIN_LENGTH - 2) / 4;
/** /**
* Maximal number of longs (4 bytes) for one usb-packet to download (fill) * Maximal number of longs (4 bytes) for one usb-packet to download (fill)
* or read (dump).<br> * or read (dump).<br>
* Note that no status bit is used. Therefore one data entity is only 16 * Note that no status bit is used. Therefore one data entity is only 16
* bits wide (not 17 bits like normal commands). <br> * bits wide (not 17 bits like normal commands). <br>
* <code>MAX_NOF_WORDS_FAST_DOWNLOAD</code> is a multiple of 6 (FILLW + MS * <code>maxNofLongs</code> is a multiple of 6 (FILLW + MS data + LS
* data + LS data). * data).
*/ */
public static final int MAX_NOF_LONGS = (USB.MAX_DATA_SIZE private int maxNofLongs;
- DataPacket.PACKET_MIN_LENGTH - 2) / 6;
private static boolean targetInDebugMode = false; private boolean targetInDebugMode = false;
private static byte[] sendData; private byte[] sendData;
private static int readMemSize = 0, writeMemSize = 0; private int readMemSize, writeMemSize;
private static boolean ignoreResult = false; private boolean ignoreResult;
static { public MC68332(Device device) {
sendData = new byte[USB.MAX_DATA_SIZE]; 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;
} }
/** /**
@@ -241,7 +246,7 @@ public class MC68332 {
* @throws DispatchException * @throws DispatchException
* @throws BDIException * @throws BDIException
*/ */
private static DataPacket transmit(byte STYPE, int dataLength) private DataPacket transmit(byte STYPE, int dataLength)
throws USBException, DispatchException, BDIException { throws USBException, DispatchException, BDIException {
// initialize packet // initialize packet
sendData[0] = DataPacket.PACKET_HEADER; sendData[0] = DataPacket.PACKET_HEADER;
@@ -271,7 +276,7 @@ public class MC68332 {
* @param offset * @param offset
* the offset from the beginning of the data * the offset from the beginning of the data
*/ */
private static void fillPacket(int data, int offset) { private void fillPacket(int data, int offset) {
// refer to CPU32 Reference Manual, Section 7.2.7 // refer to CPU32 Reference Manual, Section 7.2.7
// bit16 = 0 + 16 bits of data (bit15 .. bit0) // bit16 = 0 + 16 bits of data (bit15 .. bit0)
@@ -290,7 +295,7 @@ public class MC68332 {
* @throws DispatchException * @throws DispatchException
* @throws BDIException * @throws BDIException
*/ */
public static DataPacket transfer(int data) throws USBException, public DataPacket transfer(int data) throws USBException,
DispatchException, BDIException { DispatchException, BDIException {
fillPacket(data, 0); fillPacket(data, 0);
@@ -309,7 +314,7 @@ public class MC68332 {
* @throws USBException * @throws USBException
* @throws DispatchException * @throws DispatchException
*/ */
private static int parseResult17(DataPacket data) throws BDIException, private int parseResult17(DataPacket data) throws BDIException,
USBException, DispatchException { USBException, DispatchException {
if (data.subtype != STYPE_BDI_17OUT) { if (data.subtype != STYPE_BDI_17OUT) {
throw new BDIException("wrong subtype: " + data.subtype); throw new BDIException("wrong subtype: " + data.subtype);
@@ -360,7 +365,7 @@ public class MC68332 {
* @throws DispatchException * @throws DispatchException
* @throws BDIException * @throws BDIException
*/ */
private static int transferAndParse17(int data) throws USBException, private int transferAndParse17(int data) throws USBException,
DispatchException, BDIException { DispatchException, BDIException {
return parseResult17(transfer(data)); return parseResult17(transfer(data));
} }
@@ -373,7 +378,7 @@ public class MC68332 {
* @throws DispatchException * @throws DispatchException
* @throws BDIException * @throws BDIException
*/ */
public static void nopsToLegalCmd() throws USBException, DispatchException, public void nopsToLegalCmd() throws USBException, DispatchException,
BDIException { BDIException {
final int NOF_NOPS_TO_LEGAL_CMD = 4; final int NOF_NOPS_TO_LEGAL_CMD = 4;
for (int i = 0; i < NOF_NOPS_TO_LEGAL_CMD; i++) { for (int i = 0; i < NOF_NOPS_TO_LEGAL_CMD; i++) {
@@ -392,8 +397,7 @@ public class MC68332 {
* @throws DispatchException * @throws DispatchException
* @throws BDIException * @throws BDIException
*/ */
public static void break_() throws USBException, DispatchException, public void break_() throws USBException, DispatchException, BDIException {
BDIException {
// FIXME: this may be wrong, but works // FIXME: this may be wrong, but works
// ignore the result of the first transaction // ignore the result of the first transaction
ignoreResult = true; ignoreResult = true;
@@ -411,8 +415,7 @@ public class MC68332 {
* @throws DispatchException * @throws DispatchException
* @throws BDIException * @throws BDIException
*/ */
public static void go() throws USBException, DispatchException, public void go() throws USBException, DispatchException, BDIException {
BDIException {
if (!targetInDebugMode) { if (!targetInDebugMode) {
throw new BDIException("target not in debug mode"); throw new BDIException("target not in debug mode");
} }
@@ -428,7 +431,7 @@ public class MC68332 {
* @throws DispatchException * @throws DispatchException
* @throws BDIException * @throws BDIException
*/ */
private static void hard_reset() throws USBException, DispatchException, private void hard_reset() throws USBException, DispatchException,
BDIException { BDIException {
DataPacket data = transmit(STYPE_BDI_HARD_RESET_332, 0); DataPacket data = transmit(STYPE_BDI_HARD_RESET_332, 0);
if (data == null) { if (data == null) {
@@ -446,7 +449,7 @@ public class MC68332 {
* @throws DispatchException * @throws DispatchException
* @throws BDIException * @throws BDIException
*/ */
public static void reset_target() throws USBException, DispatchException, public void reset_target() throws USBException, DispatchException,
BDIException { BDIException {
// hard reset // hard reset
hard_reset(); hard_reset();
@@ -461,8 +464,8 @@ public class MC68332 {
* @throws DispatchException * @throws DispatchException
* @throws BDIException * @throws BDIException
*/ */
public static void reset_peripherals() throws USBException, public void reset_peripherals() throws USBException, DispatchException,
DispatchException, BDIException { BDIException {
// hard reset // hard reset
transferAndParse17(RST); transferAndParse17(RST);
// wait for 50ms // wait for 50ms
@@ -484,8 +487,8 @@ public class MC68332 {
* @throws DispatchException * @throws DispatchException
* @throws BDIException * @throws BDIException
*/ */
public static boolean isFreezeAsserted() throws USBException, public boolean isFreezeAsserted() throws USBException, DispatchException,
DispatchException, BDIException { BDIException {
DataPacket data = transmit(STYPE_BDI_GET_FREEZE, 0); DataPacket data = transmit(STYPE_BDI_GET_FREEZE, 0);
if (data == null) { if (data == null) {
throw new BDIException("no data from device"); throw new BDIException("no data from device");
@@ -520,7 +523,7 @@ public class MC68332 {
* @throws DispatchException * @throws DispatchException
* @throws USBException * @throws USBException
*/ */
public static void fillMem(int[] downloadData, int dataLength) public void fillMem(int[] downloadData, int dataLength)
throws BDIException, USBException, DispatchException { throws BDIException, USBException, DispatchException {
// check if data fits into USB-packet // check if data fits into USB-packet
int currentIndex = 0; int currentIndex = 0;
@@ -528,7 +531,7 @@ public class MC68332 {
logger.finer("dataLength: " + dataLength); logger.finer("dataLength: " + dataLength);
switch (writeMemSize) { switch (writeMemSize) {
case 1: case 1:
if (dataLength > MAX_NOF_BYTES_WORDS) { if (dataLength > maxNofBytesWords) {
throw new BDIException( throw new BDIException(
"data larger than MAX_NOF_WORDS_FAST_DOWNLOAD_BYTE_WORD"); "data larger than MAX_NOF_WORDS_FAST_DOWNLOAD_BYTE_WORD");
} }
@@ -547,7 +550,7 @@ public class MC68332 {
data = transmit(STYPE_BDI_17FILL_BYTE_WORD, dataLength * 4 + 2); data = transmit(STYPE_BDI_17FILL_BYTE_WORD, dataLength * 4 + 2);
break; break;
case 2: case 2:
if (dataLength > MAX_NOF_BYTES_WORDS) { if (dataLength > maxNofBytesWords) {
throw new BDIException( throw new BDIException(
"data larger than MAX_NOF_WORDS_FAST_DOWNLOAD_BYTE_WORD"); "data larger than MAX_NOF_WORDS_FAST_DOWNLOAD_BYTE_WORD");
} }
@@ -566,7 +569,7 @@ public class MC68332 {
data = transmit(STYPE_BDI_17FILL_BYTE_WORD, dataLength * 4 + 2); data = transmit(STYPE_BDI_17FILL_BYTE_WORD, dataLength * 4 + 2);
break; break;
case 4: case 4:
if (dataLength > (MAX_NOF_LONGS)) { if (dataLength > (maxNofLongs)) {
throw new BDIException( throw new BDIException(
"data larger than MAX_NOF_WORDS_FAST_DOWNLOAD_LONG"); "data larger than MAX_NOF_WORDS_FAST_DOWNLOAD_LONG");
} }
@@ -623,15 +626,15 @@ public class MC68332 {
* @throws DispatchException * @throws DispatchException
* @throws BDIException * @throws BDIException
*/ */
public static int[] dumpMem(int nofData) throws USBException, public int[] dumpMem(int nofData) throws USBException, DispatchException,
DispatchException, BDIException { BDIException {
// TODO: adjust MAX_NOF_XX_DUMP // TODO: adjust MAX_NOF_XX_DUMP
int dataSize; int dataSize;
switch (readMemSize) { switch (readMemSize) {
case 1: case 1:
if (nofData > MAX_NOF_BYTES_WORDS) if (nofData > maxNofBytesWords)
nofData = MAX_NOF_BYTES_WORDS; nofData = maxNofBytesWords;
// fill the packet with {DUMPB} + 1 NOP at the end // fill the packet with {DUMPB} + 1 NOP at the end
int i; int i;
for (i = 0; i < nofData; i++) { for (i = 0; i < nofData; i++) {
@@ -643,8 +646,8 @@ public class MC68332 {
dataSize = i * 2 + 2; dataSize = i * 2 + 2;
break; break;
case 2: case 2:
if (nofData > MAX_NOF_BYTES_WORDS) if (nofData > maxNofBytesWords)
nofData = MAX_NOF_BYTES_WORDS; nofData = maxNofBytesWords;
// fill the packet with {DUMPW} + 1 NOP at the end // fill the packet with {DUMPW} + 1 NOP at the end
for (i = 0; i < nofData; i++) { for (i = 0; i < nofData; i++) {
sendData[DataPacket.PACKET_DATA_OFFSET + i * 2] = (byte) ((DUMPW >>> 8) & 0xFF); sendData[DataPacket.PACKET_DATA_OFFSET + i * 2] = (byte) ((DUMPW >>> 8) & 0xFF);
@@ -655,8 +658,8 @@ public class MC68332 {
dataSize = i * 2 + 2; dataSize = i * 2 + 2;
break; break;
case 4: case 4:
if (nofData > MAX_NOF_LONGS) if (nofData > maxNofLongs)
nofData = MAX_NOF_LONGS; nofData = maxNofLongs;
// fill the packet with {DUMPL + NOP} + 1 NOP at the end // fill the packet with {DUMPL + NOP} + 1 NOP at the end
for (i = 0; i < nofData; i++) { for (i = 0; i < nofData; i++) {
sendData[DataPacket.PACKET_DATA_OFFSET + i * 4] = (byte) ((DUMPL >>> 8) & 0xFF); sendData[DataPacket.PACKET_DATA_OFFSET + i * 4] = (byte) ((DUMPL >>> 8) & 0xFF);
@@ -732,8 +735,8 @@ public class MC68332 {
* @throws DispatchException * @throws DispatchException
* @throws BDIException * @throws BDIException
*/ */
public static void writeMem(int addr, int value, int size) public void writeMem(int addr, int value, int size) throws USBException,
throws USBException, DispatchException, BDIException { DispatchException, BDIException {
if (!targetInDebugMode) { if (!targetInDebugMode) {
throw new BDIException("target not in debug mode"); throw new BDIException("target not in debug mode");
@@ -800,7 +803,7 @@ public class MC68332 {
* @throws DispatchException * @throws DispatchException
* @throws BDIException * @throws BDIException
*/ */
public static int readMem(int addr, int size) throws USBException, public int readMem(int addr, int size) throws USBException,
DispatchException, BDIException { DispatchException, BDIException {
if (!targetInDebugMode) { if (!targetInDebugMode) {
@@ -860,8 +863,8 @@ public class MC68332 {
* @throws DispatchException * @throws DispatchException
* @throws BDIException * @throws BDIException
*/ */
public static int readUserReg(int reg) throws USBException, public int readUserReg(int reg) throws USBException, DispatchException,
DispatchException, BDIException { BDIException {
if (!targetInDebugMode) { if (!targetInDebugMode) {
throw new BDIException("target not in debug mode"); throw new BDIException("target not in debug mode");
@@ -888,7 +891,7 @@ public class MC68332 {
* @throws DispatchException * @throws DispatchException
* @throws BDIException * @throws BDIException
*/ */
public static void writeUserReg(int reg, int value) throws USBException, public void writeUserReg(int reg, int value) throws USBException,
DispatchException, BDIException { DispatchException, BDIException {
if (!targetInDebugMode) { if (!targetInDebugMode) {
@@ -919,8 +922,8 @@ public class MC68332 {
* @throws DispatchException * @throws DispatchException
* @throws BDIException * @throws BDIException
*/ */
public static int readSysReg(int reg) throws USBException, public int readSysReg(int reg) throws USBException, DispatchException,
DispatchException, BDIException { BDIException {
if (!targetInDebugMode) { if (!targetInDebugMode) {
throw new BDIException("target not in debug mode"); throw new BDIException("target not in debug mode");
@@ -947,7 +950,7 @@ public class MC68332 {
* @throws DispatchException * @throws DispatchException
* @throws BDIException * @throws BDIException
*/ */
public static void writeSysReg(int reg, int value) throws USBException, public void writeSysReg(int reg, int value) throws USBException,
DispatchException, BDIException { DispatchException, BDIException {
if (!targetInDebugMode) { if (!targetInDebugMode) {
@@ -972,8 +975,7 @@ public class MC68332 {
} }
// TODO: remove // TODO: remove
public static void nop() throws USBException, DispatchException, public void nop() throws USBException, DispatchException, BDIException {
BDIException {
logger logger
.info("result: 0x" .info("result: 0x"
+ Integer.toHexString(transferAndParse17(NOP))); + Integer.toHexString(transferAndParse17(NOP)));
@@ -988,7 +990,35 @@ public class MC68332 {
* *
* @return the last known state of the freeze signal * @return the last known state of the freeze signal
*/ */
public static boolean isTargetInDebugMode() { public boolean isTargetInDebugMode() {
return targetInDebugMode; return targetInDebugMode;
} }
/**
* Maximal number of words or bytes (1 or 2 bytes) for one usb-packet to
* download (fill) or read (dump). <br>
* Note that no status bit is used. Therefore one data entity is only 16
* bits wide (not 17 bits like normal commands). <br>
* <code>maxNofWordsFastDownload</code> is a multiple of 4 (FILLB/W +
* data).
*
* @return
*/
public int getMaxNofBytesWords() {
return maxNofBytesWords;
}
/**
* Maximal number of longs (4 bytes) for one usb-packet to download (fill)
* or read (dump).<br>
* Note that no status bit is used. Therefore one data entity is only 16
* bits wide (not 17 bits like normal commands). <br>
* <code>maxNofLongs</code> is a multiple of 6 (FILLW + MS data + LS
* data).
*
* @return
*/
public int getMaxNofLongs() {
return maxNofLongs;
}
} }

View File

@@ -6,6 +6,7 @@ import ch.ntb.mcdp.usb.DispatchException;
import ch.ntb.mcdp.usb.USBDevice; import ch.ntb.mcdp.usb.USBDevice;
import ch.ntb.mcdp.utils.logger.LogUtil; import ch.ntb.mcdp.utils.logger.LogUtil;
import ch.ntb.mcdp.utils.logger.McdpLogger; import ch.ntb.mcdp.utils.logger.McdpLogger;
import ch.ntb.usb.Device;
import ch.ntb.usb.USB; import ch.ntb.usb.USB;
import ch.ntb.usb.USBException; import ch.ntb.usb.USBException;
@@ -74,6 +75,9 @@ public class MPC555 {
*/ */
private static final byte STYPE_BDI_ERROR_TIMEOUT = 0x73; private static final byte STYPE_BDI_ERROR_TIMEOUT = 0x73;
/**
* number of bytes per BDI transfer (35 bits)
*/
private static final int BDI_DATA35_LENGTH = 5; private static final int BDI_DATA35_LENGTH = 5;
/** /**
@@ -111,23 +115,29 @@ public class MPC555 {
*/ */
private static final int MTBRTR30 = 0x7FC002E6; private static final int MTBRTR30 = 0x7FC002E6;
/**
* Null indication result of a BDI transaction
*/
private static final int NULL_INDICATION = -1; private static final int NULL_INDICATION = -1;
public static final int MAX_NOF_WORDS_FAST_DOWNLOAD = ((USB.MAX_DATA_SIZE - DataPacket.PACKET_MIN_LENGTH) / BDI_DATA35_LENGTH); private final int maxNofWordsFastDownload;
private static boolean fastDownloadStarted = false; private boolean fastDownloadStarted;
private static boolean targetInDebugMode = false; private boolean targetInDebugMode;
private static byte[] sendData; private byte[] sendData;
private static int gpr30, gpr31, ecr; private int gpr30, gpr31, ecr;
static { public MPC555(Device device) {
sendData = new byte[USB.MAX_DATA_SIZE]; targetInDebugMode = false;
fastDownloadStarted = false;
maxNofWordsFastDownload = ((device.getMaxPacketSize() - DataPacket.PACKET_MIN_LENGTH) / BDI_DATA35_LENGTH);
sendData = new byte[USB.HIGHSPEED_MAX_BULK_PACKET_SIZE];
} }
private static void initPacket(byte STYPE, int dataLength) { private void initPacket(byte STYPE, int dataLength) {
logger.finest("initPacket(0x" + Integer.toHexString(STYPE) + ", " logger.finest("initPacket(0x" + Integer.toHexString(STYPE) + ", "
+ dataLength + ")"); + dataLength + ")");
sendData[0] = DataPacket.PACKET_HEADER; sendData[0] = DataPacket.PACKET_HEADER;
@@ -138,7 +148,7 @@ public class MPC555 {
sendData[DataPacket.PACKET_DATA_OFFSET + dataLength] = DataPacket.PACKET_END; sendData[DataPacket.PACKET_DATA_OFFSET + dataLength] = DataPacket.PACKET_END;
} }
private static DataPacket transmit(int dataLength) throws USBException, private DataPacket transmit(int dataLength) throws USBException,
DispatchException, BDIException { DispatchException, BDIException {
// write USB-command // write USB-command
USBDevice USBDevice
@@ -156,8 +166,8 @@ public class MPC555 {
return data; return data;
} }
private static void fillPacket(boolean modeBit, boolean controlBit, private void fillPacket(boolean modeBit, boolean controlBit, int data,
int data, int offset) { int offset) {
// startBit = 1 | modeBit | controlBit | 32 bits of data // startBit = 1 | modeBit | controlBit | 32 bits of data
byte b = (byte) 0x80; byte b = (byte) 0x80;
@@ -175,8 +185,8 @@ public class MPC555 {
sendData[DataPacket.PACKET_DATA_OFFSET + offset + 4] = (byte) ((data & 0x07) << 5); sendData[DataPacket.PACKET_DATA_OFFSET + offset + 4] = (byte) ((data & 0x07) << 5);
} }
private static DataPacket transfer(boolean modeBit, boolean controlBit, private DataPacket transfer(boolean modeBit, boolean controlBit, int data)
int data) throws USBException, DispatchException, BDIException { throws USBException, DispatchException, BDIException {
initPacket(STYPE_BDI_35IN, BDI_DATA35_LENGTH); initPacket(STYPE_BDI_35IN, BDI_DATA35_LENGTH);
@@ -185,7 +195,7 @@ public class MPC555 {
return transmit(BDI_DATA35_LENGTH); return transmit(BDI_DATA35_LENGTH);
} }
private static int parseResult35(DataPacket data) throws BDIException { private int parseResult35(DataPacket data) throws BDIException {
if (data.subtype != STYPE_BDI_35OUT) { if (data.subtype != STYPE_BDI_35OUT) {
throw new BDIException("wrong subtype: " + data.subtype); throw new BDIException("wrong subtype: " + data.subtype);
} }
@@ -219,12 +229,12 @@ public class MPC555 {
} }
} }
private static int transferAndParse35(boolean modeBit, boolean controlBit, private int transferAndParse35(boolean modeBit, boolean controlBit, int data)
int data) throws USBException, DispatchException, BDIException { throws USBException, DispatchException, BDIException {
return parseResult35(transfer(modeBit, controlBit, data)); return parseResult35(transfer(modeBit, controlBit, data));
} }
private static void epilogue() throws USBException, DispatchException, private void epilogue() throws USBException, DispatchException,
BDIException { BDIException {
logger.fine("epilogue()"); logger.fine("epilogue()");
@@ -249,7 +259,7 @@ public class MPC555 {
transferAndParse35(false, false, RFI); transferAndParse35(false, false, RFI);
} }
private static void prologue() throws USBException, DispatchException, private void prologue() throws USBException, DispatchException,
BDIException { BDIException {
final int EBRK_bit = 1; final int EBRK_bit = 1;
@@ -293,8 +303,7 @@ public class MPC555 {
* @throws DispatchException * @throws DispatchException
* @throws BDIException * @throws BDIException
*/ */
public static void break_() throws USBException, DispatchException, public void break_() throws USBException, DispatchException, BDIException {
BDIException {
logger.fine("break_()"); logger.fine("break_()");
// assert maskable breakpoint // assert maskable breakpoint
if (transferAndParse35(true, true, 0x7E000000) == NULL_INDICATION) { if (transferAndParse35(true, true, 0x7E000000) == NULL_INDICATION) {
@@ -313,8 +322,7 @@ public class MPC555 {
* @throws DispatchException * @throws DispatchException
* @throws BDIException * @throws BDIException
*/ */
public static void go() throws USBException, DispatchException, public void go() throws USBException, DispatchException, BDIException {
BDIException {
logger.fine("go()"); logger.fine("go()");
if (!targetInDebugMode) { if (!targetInDebugMode) {
throw new BDIException("target not in debug mode"); throw new BDIException("target not in debug mode");
@@ -332,7 +340,7 @@ public class MPC555 {
* @throws DispatchException * @throws DispatchException
* @throws BDIException * @throws BDIException
*/ */
private static void hard_reset() throws USBException, DispatchException, private void hard_reset() throws USBException, DispatchException,
BDIException { BDIException {
initPacket(STYPE_BDI_HARD_RESET_555, 0); initPacket(STYPE_BDI_HARD_RESET_555, 0);
DataPacket data = transmit(0); DataPacket data = transmit(0);
@@ -352,7 +360,7 @@ public class MPC555 {
* @throws DispatchException * @throws DispatchException
* @throws BDIException * @throws BDIException
*/ */
public static void reset_target() throws USBException, DispatchException, public void reset_target() throws USBException, DispatchException,
BDIException { BDIException {
logger.fine("reset_target()"); logger.fine("reset_target()");
// hard reset // hard reset
@@ -383,8 +391,8 @@ public class MPC555 {
* @throws DispatchException * @throws DispatchException
* @throws BDIException * @throws BDIException
*/ */
public static boolean isFreezeAsserted() throws USBException, public boolean isFreezeAsserted() throws USBException, DispatchException,
DispatchException, BDIException { BDIException {
initPacket(STYPE_BDI_GET_FREEZE, 0); initPacket(STYPE_BDI_GET_FREEZE, 0);
logger.fine("isFreezeAsserted()"); logger.fine("isFreezeAsserted()");
DataPacket data = transmit(0); DataPacket data = transmit(0);
@@ -410,7 +418,7 @@ public class MPC555 {
* @throws DispatchException * @throws DispatchException
* @throws BDIException * @throws BDIException
*/ */
public static void startFastDownload(int startAddr) throws USBException, public void startFastDownload(int startAddr) throws USBException,
DispatchException, BDIException { DispatchException, BDIException {
logger.fine("startFastDownload(" + startAddr + ")"); logger.fine("startFastDownload(" + startAddr + ")");
if (!targetInDebugMode) { if (!targetInDebugMode) {
@@ -433,7 +441,7 @@ public class MPC555 {
/** /**
* Fill one USB-Packet with data to download. The maximal number of words is * Fill one USB-Packet with data to download. The maximal number of words is
* defined by <code>MAX_NOF_WORDS_FAST_DOWNLOAD</code><br> * defined by <code>maxNofWordsFastDownload</code><br>
* <code>startFastDownload</code> has to be called before to set up the * <code>startFastDownload</code> has to be called before to set up the
* start address. * start address.
* *
@@ -445,16 +453,15 @@ public class MPC555 {
* @throws DispatchException * @throws DispatchException
* @throws USBException * @throws USBException
*/ */
public static void fastDownload(int[] downloadData, int dataLength) public void fastDownload(int[] downloadData, int dataLength)
throws BDIException, USBException, DispatchException { throws BDIException, USBException, DispatchException {
logger.fine("fastDownload(int[], " + dataLength + ")"); logger.fine("fastDownload(int[], " + dataLength + ")");
if (!fastDownloadStarted) { if (!fastDownloadStarted) {
throw new BDIException("start fast download first"); throw new BDIException("start fast download first");
} }
// check if data fits into USB-packet // check if data fits into USB-packet
if (dataLength > MAX_NOF_WORDS_FAST_DOWNLOAD) { if (dataLength > maxNofWordsFastDownload) {
throw new BDIException( throw new BDIException("data larger than maxNofWordsFastDownload");
"data larger than MAX_NOF_WORDS_FAST_DOWNLOAD");
} }
int currentIndex = 0; int currentIndex = 0;
initPacket(STYPE_BDI_35FD_DATA, dataLength * BDI_DATA35_LENGTH); initPacket(STYPE_BDI_35FD_DATA, dataLength * BDI_DATA35_LENGTH);
@@ -491,8 +498,8 @@ public class MPC555 {
* @throws DispatchException * @throws DispatchException
* @throws BDIException * @throws BDIException
*/ */
public static void stopFastDownload() throws USBException, public void stopFastDownload() throws USBException, DispatchException,
DispatchException, BDIException { BDIException {
fastDownloadStarted = false; fastDownloadStarted = false;
logger.fine("stopFastDownload()"); logger.fine("stopFastDownload()");
// stop fast download // stop fast download
@@ -507,8 +514,8 @@ public class MPC555 {
transferAndParse35(false, true, 0x0); transferAndParse35(false, true, 0x0);
} }
public static void writeMem(int addr, int value, int size) public void writeMem(int addr, int value, int size) throws USBException,
throws USBException, DispatchException, BDIException { DispatchException, BDIException {
logger.fine("writeMem(0x" + Integer.toHexString(addr) + ", 0x" logger.fine("writeMem(0x" + Integer.toHexString(addr) + ", 0x"
+ Integer.toHexString(value) + ", " + size + ")"); + Integer.toHexString(value) + ", " + size + ")");
if (!targetInDebugMode) { if (!targetInDebugMode) {
@@ -542,7 +549,7 @@ public class MPC555 {
} }
} }
public static int readMem(int addr, int size) throws USBException, public int readMem(int addr, int size) throws USBException,
DispatchException, BDIException { DispatchException, BDIException {
logger.fine("readMem(0x" + Integer.toHexString(addr) + ", " + size logger.fine("readMem(0x" + Integer.toHexString(addr) + ", " + size
+ ")"); + ")");
@@ -577,7 +584,7 @@ public class MPC555 {
return transferAndParse35(false, false, NOP); return transferAndParse35(false, false, NOP);
} }
public static void writeMemSeq(int value, int size) throws USBException, public void writeMemSeq(int value, int size) throws USBException,
DispatchException, BDIException { DispatchException, BDIException {
logger.fine("writeMemSeq(int, int)"); logger.fine("writeMemSeq(int, int)");
if (!targetInDebugMode) { if (!targetInDebugMode) {
@@ -607,8 +614,8 @@ public class MPC555 {
} }
} }
public static int readMemSeq(int size) throws USBException, public int readMemSeq(int size) throws USBException, DispatchException,
DispatchException, BDIException { BDIException {
logger.fine("readMemSeq(int)"); logger.fine("readMemSeq(int)");
if (!targetInDebugMode) { if (!targetInDebugMode) {
throw new BDIException("target not in debug mode"); throw new BDIException("target not in debug mode");
@@ -637,7 +644,7 @@ public class MPC555 {
return transferAndParse35(false, false, NOP); return transferAndParse35(false, false, NOP);
} }
public static int readGPR(int gpr) throws USBException, DispatchException, public int readGPR(int gpr) throws USBException, DispatchException,
BDIException { BDIException {
logger.fine("readGPR(" + gpr + ")"); logger.fine("readGPR(" + gpr + ")");
if (!targetInDebugMode) { if (!targetInDebugMode) {
@@ -657,7 +664,7 @@ public class MPC555 {
return transferAndParse35(false, false, NOP); return transferAndParse35(false, false, NOP);
} }
public static void writeGPR(int gpr, int value) throws USBException, public void writeGPR(int gpr, int value) throws USBException,
DispatchException, BDIException { DispatchException, BDIException {
logger.fine("writeGPR(" + gpr + ", 0x" + Integer.toHexString(value) logger.fine("writeGPR(" + gpr + ", 0x" + Integer.toHexString(value)
+ ")"); + ")");
@@ -680,7 +687,7 @@ public class MPC555 {
transferAndParse35(false, true, value); transferAndParse35(false, true, value);
} }
public static int readSPR(int spr) throws USBException, DispatchException, public int readSPR(int spr) throws USBException, DispatchException,
BDIException { BDIException {
logger.fine("readSPR(" + spr + ")"); logger.fine("readSPR(" + spr + ")");
if (!targetInDebugMode) { if (!targetInDebugMode) {
@@ -702,7 +709,7 @@ public class MPC555 {
return transferAndParse35(false, false, NOP); return transferAndParse35(false, false, NOP);
} }
public static void writeSPR(int spr, int value) throws USBException, public void writeSPR(int spr, int value) throws USBException,
DispatchException, BDIException { DispatchException, BDIException {
logger.fine("writeSPR(" + spr + ", 0x" + Integer.toHexString(value) logger.fine("writeSPR(" + spr + ", 0x" + Integer.toHexString(value)
+ ")"); + ")");
@@ -719,8 +726,7 @@ public class MPC555 {
transferAndParse35(false, false, cmd); transferAndParse35(false, false, cmd);
} }
public static int readMSR() throws USBException, DispatchException, public int readMSR() throws USBException, DispatchException, BDIException {
BDIException {
logger.fine("readMSR()"); logger.fine("readMSR()");
if (!targetInDebugMode) { if (!targetInDebugMode) {
throw new BDIException("target not in debug mode"); throw new BDIException("target not in debug mode");
@@ -734,8 +740,8 @@ public class MPC555 {
return transferAndParse35(false, false, NOP); return transferAndParse35(false, false, NOP);
} }
public static void writeMSR(int value) throws USBException, public void writeMSR(int value) throws USBException, DispatchException,
DispatchException, BDIException { BDIException {
logger.fine("writeMSR(0x" + Integer.toHexString(value) + ")"); logger.fine("writeMSR(0x" + Integer.toHexString(value) + ")");
if (!targetInDebugMode) { if (!targetInDebugMode) {
throw new BDIException("target not in debug mode"); throw new BDIException("target not in debug mode");
@@ -748,7 +754,7 @@ public class MPC555 {
transferAndParse35(false, false, 0x7FC00124); transferAndParse35(false, false, 0x7FC00124);
} }
public static long readFPR(int fpr, int tmpMemAddr) throws USBException, public long readFPR(int fpr, int tmpMemAddr) throws USBException,
DispatchException, BDIException { DispatchException, BDIException {
logger.fine("readFPR(" + fpr + ", 0x" + Integer.toHexString(tmpMemAddr) logger.fine("readFPR(" + fpr + ", 0x" + Integer.toHexString(tmpMemAddr)
+ ")"); + ")");
@@ -771,7 +777,7 @@ public class MPC555 {
+ readMem(tmpMemAddr + 4, 4); + readMem(tmpMemAddr + 4, 4);
} }
public static void writeFPR(int fpr, int tmpMemAddr, long value) public void writeFPR(int fpr, int tmpMemAddr, long value)
throws USBException, DispatchException, BDIException { throws USBException, DispatchException, BDIException {
logger.fine("writeFPR(" + fpr + ", 0x" logger.fine("writeFPR(" + fpr + ", 0x"
+ Integer.toHexString(tmpMemAddr) + ", 0x" + Integer.toHexString(tmpMemAddr) + ", 0x"
@@ -798,8 +804,7 @@ public class MPC555 {
transferAndParse35(false, false, NOP); transferAndParse35(false, false, NOP);
} }
public static int readCR() throws USBException, DispatchException, public int readCR() throws USBException, DispatchException, BDIException {
BDIException {
logger.fine("readCR()"); logger.fine("readCR()");
if (!targetInDebugMode) { if (!targetInDebugMode) {
throw new BDIException("target not in debug mode"); throw new BDIException("target not in debug mode");
@@ -813,8 +818,8 @@ public class MPC555 {
return transferAndParse35(false, false, NOP); return transferAndParse35(false, false, NOP);
} }
public static void writeCR(int value) throws USBException, public void writeCR(int value) throws USBException, DispatchException,
DispatchException, BDIException { BDIException {
logger.fine("writeCR(0x" + Integer.toHexString(value) + ")"); logger.fine("writeCR(0x" + Integer.toHexString(value) + ")");
if (!targetInDebugMode) { if (!targetInDebugMode) {
throw new BDIException("target not in debug mode"); throw new BDIException("target not in debug mode");
@@ -828,8 +833,7 @@ public class MPC555 {
transferAndParse35(false, false, 0x7FCFF120); transferAndParse35(false, false, 0x7FCFF120);
} }
public static int readFPSCR() throws USBException, DispatchException, public int readFPSCR() throws USBException, DispatchException, BDIException {
BDIException {
logger.fine("readFPSCR()"); logger.fine("readFPSCR()");
if (!targetInDebugMode) { if (!targetInDebugMode) {
throw new BDIException("target not in debug mode"); throw new BDIException("target not in debug mode");
@@ -859,8 +863,8 @@ public class MPC555 {
return retVal; return retVal;
} }
public static void writeFPSCR(int value) throws USBException, public void writeFPSCR(int value) throws USBException, DispatchException,
DispatchException, BDIException { BDIException {
logger.fine("writeFPSCR(0x" + Integer.toHexString(value) + ")"); logger.fine("writeFPSCR(0x" + Integer.toHexString(value) + ")");
if (!targetInDebugMode) { if (!targetInDebugMode) {
throw new BDIException("target not in debug mode"); throw new BDIException("target not in debug mode");
@@ -884,7 +888,7 @@ public class MPC555 {
* *
* @return the last known state of the freeze signal * @return the last known state of the freeze signal
*/ */
public static boolean isTargetInDebugMode() { public boolean isTargetInDebugMode() {
return targetInDebugMode; return targetInDebugMode;
} }
@@ -894,7 +898,7 @@ public class MPC555 {
* *
* @return the store value of this register * @return the store value of this register
*/ */
public static int getGpr30() { public int getGpr30() {
return gpr30; return gpr30;
} }
@@ -906,9 +910,9 @@ public class MPC555 {
* @param value * @param value
* value to write to the register * value to write to the register
*/ */
public static void setGpr30(int value) { public void setGpr30(int value) {
logger.fine("gpr30: 0x" + Integer.toHexString(value)); logger.fine("gpr30: 0x" + Integer.toHexString(value));
MPC555.gpr30 = value; gpr30 = value;
} }
/** /**
@@ -917,7 +921,7 @@ public class MPC555 {
* *
* @return the store value of this register * @return the store value of this register
*/ */
public static int getGpr31() { public int getGpr31() {
return gpr31; return gpr31;
} }
@@ -929,8 +933,16 @@ public class MPC555 {
* @param value * @param value
* value to write to the register * value to write to the register
*/ */
public static void setGpr31(int value) { public void setGpr31(int value) {
logger.fine("gpr31: 0x" + Integer.toHexString(value)); logger.fine("gpr31: 0x" + Integer.toHexString(value));
MPC555.gpr31 = value; gpr31 = value;
}
/**
* @return number of maximal words used in the <code>fastDownload</code>
* procedure
*/
public int getMaxNofWordsFastDownload() {
return maxNofWordsFastDownload;
} }
} }

View File

@@ -0,0 +1,256 @@
package ch.ntb.mcdp.bdi.blackbox;
import ch.ntb.mcdp.bdi.BDIException;
import ch.ntb.mcdp.usb.DispatchException;
import ch.ntb.mcdp.usb.USBDevice;
import ch.ntb.usb.USBException;
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.
*/
public static void initialise() {
bdi = new ch.ntb.mcdp.bdi.MC68332(USBDevice.getDevice());
}
/**
* Sends NOPs to the target until a <code>STATUS_OK</code> result is
* received.
*
* @throws USBException
* @throws DispatchException
* @throws BDIException
*/
public static void nopsToLegalCmd() throws USBException, DispatchException,
BDIException {
bdi.nopsToLegalCmd();
}
/**
* Signals a breakpoint and enters debug mode.
*
* @throws USBException
* @throws DispatchException
* @throws BDIException
*/
public static void break_() throws USBException, DispatchException,
BDIException {
bdi.break_();
}
/**
* Resume from debug mode.
*
* @throws USBException
* @throws DispatchException
* @throws BDIException
*/
public static void go() throws USBException, DispatchException,
BDIException {
bdi.go();
}
/**
* Reset the target and put it into debug mode.
*
* @throws USBException
* @throws DispatchException
* @throws BDIException
*/
public static void reset_target() throws USBException, DispatchException,
BDIException {
bdi.reset_target();
}
/**
* Send the <b>RST</b> command (reset peripherals) to the microcontroller.
*
* @throws USBException
* @throws DispatchException
* @throws BDIException
*/
public static void reset_peripherals() throws USBException,
DispatchException, BDIException {
bdi.reset_peripherals();
}
/**
* Check if the freeze signal is asserted.<br>
* The freeze siganl is asserted if the target is in debug mode.
*
* @return
* @throws USBException
* @throws DispatchException
* @throws BDIException
*/
public static boolean isFreezeAsserted() throws USBException,
DispatchException, BDIException {
return bdi.isFreezeAsserted();
}
/**
* Fill large blocks of memory.<br>
* Fill is used in conjunction with the <code>writeMem</code> command. The
* maximal number of words is defined by
* <code>MAX_NOF_WORDS_FAST_DOWNLOAD</code> for 1 and 2 byte (word) data.
* For 4 byte (long) data, only half the size of
* <code>MAX_NOF_WORDS_FAST_DOWNLOAD</code> is available as 4 bytes of
* data has to be split in two packets (2 x 2 bytes).<br>
* Befor using <code>fillMem</code>, <code>writeMem</code> has to be
* called to set up the start address and size.
*
* @param downloadData
* Data to be downloaded (size depending on size set up with
* <code>writeMem</code>)
* @param dataLength
* Number of bytes, words or longs (1, 2, 4 bytes)
* @throws BDIException
* @throws DispatchException
* @throws USBException
*/
public static void fillMem(int[] downloadData, int dataLength)
throws BDIException, USBException, DispatchException {
bdi.fillMem(downloadData, dataLength);
}
/**
* Dump large blocks of memory. <br>
* Dump is used in conjunction with the <code>readMem(...)</code> command.
* The size depends on the size set up with <code>readMem(...)</code> and
* is internally stored.
*
* @param nofData
* number of bytes/words/longs to read (depends on the size set
* up with <code>readMem(...)</code>)
* @return read values
* @throws USBException
* @throws DispatchException
* @throws BDIException
*/
public static int[] dumpMem(int nofData) throws USBException,
DispatchException, BDIException {
return bdi.dumpMem(nofData);
}
/**
* Write to a specified memory address.<br>
*
* @param addr
* address to write
* @param value
* value to write
* @param size
* number of bytes to read
* @throws USBException
* @throws DispatchException
* @throws BDIException
*/
public static void writeMem(int addr, int value, int size)
throws USBException, DispatchException, BDIException {
bdi.writeMem(addr, value, size);
}
/**
* Read the value of a specified memory address.<br>
*
* @param addr
* address to read
* @param size
* number of bytes to read
* @return value of this memory address
* @throws USBException
* @throws DispatchException
* @throws BDIException
*/
public static int readMem(int addr, int size) throws USBException,
DispatchException, BDIException {
return bdi.readMem(addr, size);
}
/**
* Read a specified value from a user register. <br>
* See the <b>registerDictionary.xml</b> file for valid registers. This
* file can be found in the <b>mc68332 resource</b>-section.
*
* @param reg
* register to read
* @return value of register
* @throws USBException
* @throws DispatchException
* @throws BDIException
*/
public static int readUserReg(int reg) throws USBException,
DispatchException, BDIException {
return bdi.readUserReg(reg);
}
/**
* Write a specified value to user register. <br>
* See the <b>registerDictionary.xml</b> file for valid registers. This
* file can be found in the <b>mc68332 resource</b>-section.
*
* @param reg
* register to write
* @param value
* value to write to register
* @throws USBException
* @throws DispatchException
* @throws BDIException
*/
public static void writeUserReg(int reg, int value) throws USBException,
DispatchException, BDIException {
bdi.writeUserReg(reg, value);
}
/**
* Read a specified value from a system register. <br>
* See the <b>registerDictionary.xml</b> file for valid registers. This
* file can be found in the <b>mc68332 resource</b>-section.
*
* @param reg
* register to read
* @return value of register
* @throws USBException
* @throws DispatchException
* @throws BDIException
*/
public static int readSysReg(int reg) throws USBException,
DispatchException, BDIException {
return bdi.readSysReg(reg);
}
/**
* Write a specified value to system register. <br>
* See the <b>registerDictionary.xml</b> file for valid registers. This
* file can be found in the <b>mc68332 resource</b>-section.
*
* @param reg
* register to write
* @param value
* value to write to register
* @throws USBException
* @throws DispatchException
* @throws BDIException
*/
public static void writeSysReg(int reg, int value) throws USBException,
DispatchException, BDIException {
bdi.writeSysReg(reg, value);
}
/**
* 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
* meanwhile. To get the up to date value use <code>isFreezeAsserted</code>
* which will issue an USB request, read the freeze signal and update the
* internal value returned by this method.
*
* @return the last known state of the freeze signal
*/
public static boolean isTargetInDebugMode() {
return bdi.isTargetInDebugMode();
}
}

View File

@@ -0,0 +1,253 @@
package ch.ntb.mcdp.bdi.blackbox;
import ch.ntb.mcdp.bdi.BDIException;
import ch.ntb.mcdp.usb.DispatchException;
import ch.ntb.mcdp.usb.USBDevice;
import ch.ntb.usb.USBException;
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.
*/
public static void initialise() {
bdi = new ch.ntb.mcdp.bdi.MPC555(USBDevice.getDevice());
}
/**
* Signals a breakpoint and enters debug mode.
*
* @throws USBException
* @throws DispatchException
* @throws BDIException
*/
public static void break_() throws USBException, DispatchException,
BDIException {
bdi.break_();
}
/**
* Resume from debug mode.
*
* @throws USBException
* @throws DispatchException
* @throws BDIException
*/
public static void go() throws USBException, DispatchException,
BDIException {
bdi.go();
}
/**
* Reset the target and put it into debug mode.
*
* @throws USBException
* @throws DispatchException
* @throws BDIException
*/
public static void reset_target() throws USBException, DispatchException,
BDIException {
bdi.reset_target();
}
/**
* Check if the freeze signal is asserted.<br>
* The freeze siganl is asserted if the target is in debug mode.
*
* @return
* @throws USBException
* @throws DispatchException
* @throws BDIException
*/
public static boolean isFreezeAsserted() throws USBException,
DispatchException, BDIException {
return bdi.isFreezeAsserted();
}
/**
* Called to start the fast download procedure.
*
* @param startAddr
* Address to which the data will be downloaded.
* @throws USBException
* @throws DispatchException
* @throws BDIException
*/
public static void startFastDownload(int startAddr) throws USBException,
DispatchException, BDIException {
bdi.startFastDownload(startAddr);
}
/**
* Fill one USB-Packet with data to download. The maximal number of words is
* defined by <code>MAX_NOF_WORDS_FAST_DOWNLOAD</code><br>
* <code>startFastDownload</code> has to be called before to set up the
* start address.
*
* @param downloadData
* Data to be downloaded (32 bit wide)
* @param dataLength
* Length of the data to download (words)
* @throws BDIException
* @throws DispatchException
* @throws USBException
*/
public static void fastDownload(int[] downloadData, int dataLength)
throws BDIException, USBException, DispatchException {
bdi.fastDownload(downloadData, dataLength);
}
/**
* Stop the fast download procedure.<br>
* Use this command after <code>startFastDownload(...)</code> and
* <code>fastDownload(...)</code>.
*
* @throws USBException
* @throws DispatchException
* @throws BDIException
*/
public static void stopFastDownload() throws USBException,
DispatchException, BDIException {
bdi.stopFastDownload();
}
public static void writeMem(int addr, int value, int size)
throws USBException, DispatchException, BDIException {
bdi.writeMem(addr, value, size);
}
public static int readMem(int addr, int size) throws USBException,
DispatchException, BDIException {
return bdi.readMem(addr, size);
}
public static void writeMemSeq(int value, int size) throws USBException,
DispatchException, BDIException {
bdi.writeMemSeq(value, size);
}
public static int readMemSeq(int size) throws USBException,
DispatchException, BDIException {
return bdi.readMemSeq(size);
}
public static int readGPR(int gpr) throws USBException, DispatchException,
BDIException {
return bdi.readGPR(gpr);
}
public static void writeGPR(int gpr, int value) throws USBException,
DispatchException, BDIException {
bdi.writeGPR(gpr, value);
}
public static int readSPR(int spr) throws USBException, DispatchException,
BDIException {
return bdi.readSPR(spr);
}
public static void writeSPR(int spr, int value) throws USBException,
DispatchException, BDIException {
bdi.writeSPR(spr, value);
}
public static int readMSR() throws USBException, DispatchException,
BDIException {
return bdi.readMSR();
}
public static void writeMSR(int value) throws USBException,
DispatchException, BDIException {
bdi.writeMSR(value);
}
public static long readFPR(int fpr, int tmpMemAddr) throws USBException,
DispatchException, BDIException {
return bdi.readFPR(fpr, tmpMemAddr);
}
public static void writeFPR(int fpr, int tmpMemAddr, long value)
throws USBException, DispatchException, BDIException {
bdi.writeFPR(fpr, tmpMemAddr, value);
}
public static int readCR() throws USBException, DispatchException,
BDIException {
return bdi.readCR();
}
public static void writeCR(int value) throws USBException,
DispatchException, BDIException {
bdi.writeCR(value);
}
public static int readFPSCR() throws USBException, DispatchException,
BDIException {
return bdi.readFPSCR();
}
public static void writeFPSCR(int value) throws USBException,
DispatchException, BDIException {
bdi.writeFPSCR(value);
}
/**
* Return the last known state of the freeze signal. This value may not be
* up to date as the target state may have changed meanwhile. To get the up
* to date value use <code>isFreezeAsserted</code> which will issue an USB
* request, read the freeze signal and update the internal value returned by
* this method.
*
* @return the last known state of the freeze signal
*/
public static boolean isTargetInDebugMode() {
return bdi.isTargetInDebugMode();
}
/**
* Read the currently stored value of the GPR 30 register.<br>
* This value is updated when entering debug mode (break -> prologue).
*
* @return the store value of this register
*/
public static int getGpr30() {
return bdi.getGpr30();
}
/**
* Set the value of the GPR 30 register.<br>
* This value is written to the GPR30 register when the microcontroller
* resumes from debug mode (go -> epilogue).
*
* @param value
* value to write to the register
*/
public static void setGpr30(int value) {
bdi.setGpr30(value);
}
/**
* Read the currently stored value of the GPR 31 register.<br>
* This value is updated when entering debug mode (break -> prologue).
*
* @return the store value of this register
*/
public static int getGpr31() {
return bdi.getGpr31();
}
/**
* Set the value of the GPR 31 register.<br>
* This value is written to the GPR31 register when the microcontroller
* resumes from debug mode (go -> epilogue).
*
* @param value
* value to write to the register
*/
public static void setGpr31(int value) {
bdi.setGpr31(value);
}
}

View File

@@ -1,11 +1,5 @@
package ch.ntb.mcdp.bdi.test; package ch.ntb.mcdp.bdi.test;
import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;
import ch.ntb.mcdp.bdi.BDIException; import ch.ntb.mcdp.bdi.BDIException;
import ch.ntb.mcdp.bdi.MC68332; import ch.ntb.mcdp.bdi.MC68332;
import ch.ntb.mcdp.mc68332.IMCBTargetBoard; import ch.ntb.mcdp.mc68332.IMCBTargetBoard;
@@ -20,11 +14,13 @@ public class BDI332test {
private static McdpLogger logger = LogUtil.ch_ntb_mcdp_bdi_test; private static McdpLogger logger = LogUtil.ch_ntb_mcdp_bdi_test;
public static MC68332 bdi;
private static void testBdiTransaction() { private static void testBdiTransaction() {
// test bdi transaction // test bdi transaction
DataPacket result = null; DataPacket result = null;
try { try {
result = MC68332.transfer(0x0C00); result = bdi.transfer(0x0C00);
} catch (USBException e1) { } catch (USBException e1) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
@@ -42,7 +38,7 @@ public class BDI332test {
private static void reset_target() { private static void reset_target() {
try { try {
MC68332.reset_target(); bdi.reset_target();
} catch (USBException e1) { } catch (USBException e1) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
@@ -57,7 +53,7 @@ public class BDI332test {
private static void freeze() { private static void freeze() {
try { try {
logger.info("isFreezeAsserted: " + MC68332.isFreezeAsserted()); logger.info("isFreezeAsserted: " + bdi.isFreezeAsserted());
} catch (USBException e) { } catch (USBException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@@ -73,7 +69,7 @@ public class BDI332test {
private static void break_() { private static void break_() {
try { try {
MC68332.break_(); bdi.break_();
} catch (USBException e) { } catch (USBException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@@ -88,7 +84,7 @@ public class BDI332test {
private static void go() { private static void go() {
try { try {
MC68332.go(); bdi.go();
} catch (USBException e) { } catch (USBException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@@ -104,9 +100,9 @@ public class BDI332test {
private static void writeMem() { private static void writeMem() {
final int BASE_ADDR = 0x105624; final int BASE_ADDR = 0x105624;
try { try {
MC68332.writeMem(BASE_ADDR, 0x123456, 4); bdi.writeMem(BASE_ADDR, 0x123456, 4);
MC68332.writeMem(BASE_ADDR + 4, 0x123457, 4); bdi.writeMem(BASE_ADDR + 4, 0x123457, 4);
MC68332.writeMem(BASE_ADDR + 8, 0x123458, 4); bdi.writeMem(BASE_ADDR + 8, 0x123458, 4);
} catch (USBException e) { } catch (USBException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@@ -123,12 +119,10 @@ public class BDI332test {
final int BASE_ADDR = 0x105624; final int BASE_ADDR = 0x105624;
try { try {
StringBuffer sb = new StringBuffer("0x" StringBuffer sb = new StringBuffer("0x"
+ Integer.toHexString(MC68332.readMem(BASE_ADDR, 4)) + "\n"); + Integer.toHexString(bdi.readMem(BASE_ADDR, 4)) + "\n");
sb.append("0x" sb.append("0x" + Integer.toHexString(bdi.readMem(BASE_ADDR + 4, 4))
+ Integer.toHexString(MC68332.readMem(BASE_ADDR + 4, 4))
+ "\n"); + "\n");
sb.append("0x" sb.append("0x" + Integer.toHexString(bdi.readMem(BASE_ADDR + 8, 4))
+ Integer.toHexString(MC68332.readMem(BASE_ADDR + 8, 4))
+ "\n"); + "\n");
logger.info(sb.toString()); logger.info(sb.toString());
} catch (USBException e) { } catch (USBException e) {
@@ -229,8 +223,8 @@ public class BDI332test {
logger.info("dump()"); logger.info("dump()");
try { try {
logger.info("Data: 0x" logger.info("Data: 0x"
+ Integer.toHexString(MC68332.readMem(BASE_ADDR, 4)) + " "); + Integer.toHexString(bdi.readMem(BASE_ADDR, 4)) + " ");
result = MC68332.dumpMem(MC68332.MAX_NOF_LONGS); result = bdi.dumpMem(bdi.getMaxNofLongs());
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
sb.append("0x" + Integer.toHexString(result[i]) + " "); sb.append("0x" + Integer.toHexString(result[i]) + " ");
@@ -251,7 +245,7 @@ public class BDI332test {
public static void button9() { public static void button9() {
try { try {
MC68332.nop(); bdi.nop();
} catch (USBException e) { } catch (USBException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@@ -270,12 +264,12 @@ public class BDI332test {
logger.info("fill"); logger.info("fill");
try { try {
MC68332.writeMem(BASE_ADDR, 0, 4); bdi.writeMem(BASE_ADDR, 0, 4);
int[] data = new int[MC68332.MAX_NOF_LONGS]; int[] data = new int[bdi.getMaxNofLongs()];
for (int i = 0; i < data.length; i++) { for (int i = 0; i < data.length; i++) {
data[i] = i; data[i] = i;
} }
MC68332.fillMem(data, data.length); bdi.fillMem(data, data.length);
} catch (USBException e) { } catch (USBException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@@ -291,7 +285,8 @@ public class BDI332test {
public static void button11() { public static void button11() {
logger.info("initTarget()"); logger.info("initTarget()");
try { try {
IMCBTargetBoard.init(); IMCBTargetBoard imcb = new IMCBTargetBoard(bdi);
imcb.init();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -306,24 +301,24 @@ public class BDI332test {
try { try {
logger.info("Fill (1 to data.length)"); logger.info("Fill (1 to data.length)");
MC68332.writeMem(BASE_ADDR, 0, 4); bdi.writeMem(BASE_ADDR, 0, 4);
int[] data = new int[MC68332.MAX_NOF_LONGS]; int[] data = new int[bdi.getMaxNofLongs()];
for (int i = 0; i < data.length; i++) { for (int i = 0; i < data.length; i++) {
data[i] = i + 1; data[i] = i + 1;
} }
MC68332.fillMem(data, data.length); bdi.fillMem(data, data.length);
logger.info("writing byte " + (OFFSET / 4) + " to " logger.info("writing byte " + (OFFSET / 4) + " to "
+ ((OFFSET / 4) + LENGTH) + " with 0x" + ((OFFSET / 4) + LENGTH) + " with 0x"
+ Integer.toHexString(DATA)); + Integer.toHexString(DATA));
MC68332.writeMem(BASE_ADDR + OFFSET, DATA, 4); bdi.writeMem(BASE_ADDR + OFFSET, DATA, 4);
for (int i = 0; i < LENGTH; i++) { for (int i = 0; i < LENGTH; i++) {
data[i] = DATA; data[i] = DATA;
} }
MC68332.fillMem(data, LENGTH); bdi.fillMem(data, LENGTH);
logger.info((LENGTH + 1) + " bytes written"); logger.info((LENGTH + 1) + " bytes written");
logger.info("dump data"); logger.info("dump data");
int firstInt = MC68332.readMem(BASE_ADDR, 4); int firstInt = bdi.readMem(BASE_ADDR, 4);
int[] result = MC68332.dumpMem(MC68332.MAX_NOF_LONGS); int[] result = bdi.dumpMem(bdi.getMaxNofLongs());
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
sb.append("0x" + Integer.toHexString(result[i]) + " "); sb.append("0x" + Integer.toHexString(result[i]) + " ");
@@ -346,23 +341,23 @@ public class BDI332test {
try { try {
logger.info("initialize data"); logger.info("initialize data");
MC68332.writeMem(BASE_ADDR, FIRST_VAL, 4); bdi.writeMem(BASE_ADDR, FIRST_VAL, 4);
int[] data = new int[MC68332.MAX_NOF_LONGS]; int[] data = new int[bdi.getMaxNofLongs()];
for (int i = 0; i < data.length; i++) { for (int i = 0; i < data.length; i++) {
data[i] = 5; data[i] = 5;
} }
MC68332.fillMem(data, data.length); bdi.fillMem(data, data.length);
logger.info("write data"); logger.info("write data");
MC68332.writeMem(BASE_ADDR, FIRST_VAL, 4); bdi.writeMem(BASE_ADDR, FIRST_VAL, 4);
data = new int[10]; data = new int[10];
for (int i = 0; i < data.length; i++) { for (int i = 0; i < data.length; i++) {
data[i] = i; data[i] = i;
} }
MC68332.fillMem(data, data.length); bdi.fillMem(data, data.length);
logger.info("Fill done"); logger.info("Fill done");
logger.info("read back data"); logger.info("read back data");
int firstResult = MC68332.readMem(BASE_ADDR, 4); int firstResult = bdi.readMem(BASE_ADDR, 4);
if (firstResult != FIRST_VAL) { if (firstResult != FIRST_VAL) {
logger.warning("Error at 0: 0x" logger.warning("Error at 0: 0x"
+ Integer.toHexString(firstResult) + " instead of 0x" + Integer.toHexString(firstResult) + " instead of 0x"
@@ -370,7 +365,7 @@ public class BDI332test {
} }
logger.fine("Compare first 0x" + Integer.toHexString(firstResult) logger.fine("Compare first 0x" + Integer.toHexString(firstResult)
+ " == 0x" + Integer.toHexString(FIRST_VAL)); + " == 0x" + Integer.toHexString(FIRST_VAL));
int[] result = MC68332.dumpMem(MC68332.MAX_NOF_LONGS); int[] result = bdi.dumpMem(bdi.getMaxNofLongs());
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
logger.fine("Compare " + i + ": 0x" logger.fine("Compare " + i + ": 0x"
+ Integer.toHexString(result[i])); + Integer.toHexString(result[i]));
@@ -395,15 +390,15 @@ public class BDI332test {
logger.info("write data"); logger.info("write data");
try { try {
MC68332.writeMem(BASE_ADDR, FIRST_VAL, 4); bdi.writeMem(BASE_ADDR, FIRST_VAL, 4);
int[] data = new int[MC68332.MAX_NOF_LONGS]; int[] data = new int[bdi.getMaxNofLongs()];
for (int i = 0; i < data.length; i++) { for (int i = 0; i < data.length; i++) {
data[i] = i; data[i] = i;
} }
MC68332.fillMem(data, data.length); bdi.fillMem(data, data.length);
logger.info("Fill done"); logger.info("Fill done");
logger.info("read back data"); logger.info("read back data");
int firstResult = MC68332.readMem(BASE_ADDR, 4); int firstResult = bdi.readMem(BASE_ADDR, 4);
if (firstResult != FIRST_VAL) { if (firstResult != FIRST_VAL) {
logger.warning("Error at 0: 0x" logger.warning("Error at 0: 0x"
+ Integer.toHexString(firstResult) + " instead of 0x" + Integer.toHexString(firstResult) + " instead of 0x"
@@ -411,7 +406,7 @@ public class BDI332test {
} }
logger.fine("Compare first 0x" + Integer.toHexString(firstResult) logger.fine("Compare first 0x" + Integer.toHexString(firstResult)
+ " == 0x" + Integer.toHexString(FIRST_VAL)); + " == 0x" + Integer.toHexString(FIRST_VAL));
int[] result = MC68332.dumpMem(MC68332.MAX_NOF_LONGS); int[] result = bdi.dumpMem(bdi.getMaxNofLongs());
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
if (data[i] != result[i]) { if (data[i] != result[i]) {
logger.warning("Error at " + i + ": 0x" logger.warning("Error at " + i + ": 0x"
@@ -454,28 +449,28 @@ public class BDI332test {
public static void button16() { public static void button16() {
final int BASE_ADDR = 0x105624; final int BASE_ADDR = 0x105624;
final int DATA = 0x00ff00ff; final int DATA = 0x00ff00ff;
final int OFFSET = (MC68332.MAX_NOF_LONGS - 2) * 4; final int OFFSET = (bdi.getMaxNofLongs() - 2) * 4;
final int LENGTH = 0x04; final int LENGTH = 0x04;
final int DUMP_BASE = BASE_ADDR + (MC68332.MAX_NOF_LONGS / 2) * 4; final int DUMP_BASE = BASE_ADDR + (bdi.getMaxNofLongs() / 2) * 4;
try { try {
logger.info("REPLACE at the end"); logger.info("REPLACE at the end");
logger.info("Fill first"); logger.info("Fill first");
MC68332.writeMem(BASE_ADDR, 0, 4); bdi.writeMem(BASE_ADDR, 0, 4);
int[] data = new int[MC68332.MAX_NOF_LONGS]; int[] data = new int[bdi.getMaxNofLongs()];
for (int i = 0; i < data.length; i++) { for (int i = 0; i < data.length; i++) {
data[i] = i + 1; data[i] = i + 1;
} }
MC68332.fillMem(data, data.length); bdi.fillMem(data, data.length);
logger.info("Fill second"); logger.info("Fill second");
MC68332.writeMem(BASE_ADDR + (MC68332.MAX_NOF_LONGS + 1) * 4, 0, 4); bdi.writeMem(BASE_ADDR + (bdi.getMaxNofLongs() + 1) * 4, 0, 4);
for (int i = 0; i < data.length; i++) { for (int i = 0; i < data.length; i++) {
data[i] = MC68332.MAX_NOF_LONGS + i + 2; data[i] = bdi.getMaxNofLongs() + i + 2;
} }
MC68332.fillMem(data, data.length); bdi.fillMem(data, data.length);
logger.info("Dump from base: 0x" + Integer.toHexString(DUMP_BASE)); logger.info("Dump from base: 0x" + Integer.toHexString(DUMP_BASE));
int firstInt = MC68332.readMem(DUMP_BASE, 4); int firstInt = bdi.readMem(DUMP_BASE, 4);
int[] result = MC68332.dumpMem(MC68332.MAX_NOF_LONGS); int[] result = bdi.dumpMem(bdi.getMaxNofLongs());
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
sb.append("0x" + Integer.toHexString(result[i]) + " "); sb.append("0x" + Integer.toHexString(result[i]) + " ");
@@ -486,16 +481,16 @@ public class BDI332test {
logger.info("writing byte " + (OFFSET / 4) + " to " logger.info("writing byte " + (OFFSET / 4) + " to "
+ ((OFFSET / 4) + LENGTH) + " with 0x" + ((OFFSET / 4) + LENGTH) + " with 0x"
+ Integer.toHexString(DATA)); + Integer.toHexString(DATA));
MC68332.writeMem(BASE_ADDR + OFFSET, DATA, 4); bdi.writeMem(BASE_ADDR + OFFSET, DATA, 4);
for (int i = 0; i < LENGTH; i++) { for (int i = 0; i < LENGTH; i++) {
data[i] = DATA; data[i] = DATA;
} }
MC68332.fillMem(data, LENGTH); bdi.fillMem(data, LENGTH);
logger.info((LENGTH + 1) + " bytes written"); logger.info((LENGTH + 1) + " bytes written");
logger.info("dump data from base: 0x" logger.info("dump data from base: 0x"
+ Integer.toHexString(DUMP_BASE)); + Integer.toHexString(DUMP_BASE));
firstInt = MC68332.readMem(DUMP_BASE, 4); firstInt = bdi.readMem(DUMP_BASE, 4);
result = MC68332.dumpMem(MC68332.MAX_NOF_LONGS); result = bdi.dumpMem(bdi.getMaxNofLongs());
sb = new StringBuffer(); sb = new StringBuffer();
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
sb.append("0x" + Integer.toHexString(result[i]) + " "); sb.append("0x" + Integer.toHexString(result[i]) + " ");
@@ -521,31 +516,31 @@ public class BDI332test {
try { try {
logger.info("read 4 bytes at: 0x" + Integer.toHexString(BASE_ADDR) logger.info("read 4 bytes at: 0x" + Integer.toHexString(BASE_ADDR)
+ ", value: 0x" + ", value: 0x"
+ Integer.toHexString(MC68332.readMem(BASE_ADDR, 4))); + Integer.toHexString(bdi.readMem(BASE_ADDR, 4)));
logger.info("read 2 bytes at: 0x" + Integer.toHexString(BASE_ADDR) logger.info("read 2 bytes at: 0x" + Integer.toHexString(BASE_ADDR)
+ ", value: 0x" + ", value: 0x"
+ Integer.toHexString(MC68332.readMem(BASE_ADDR, 2))); + Integer.toHexString(bdi.readMem(BASE_ADDR, 2)));
logger.info("read 1 byte at: 0x" + Integer.toHexString(BASE_ADDR) logger.info("read 1 byte at: 0x" + Integer.toHexString(BASE_ADDR)
+ ", value: 0x" + ", value: 0x"
+ Integer.toHexString(MC68332.readMem(BASE_ADDR, 1))); + Integer.toHexString(bdi.readMem(BASE_ADDR, 1)));
logger.info("write 1 byte at: 0x" + Integer.toHexString(BASE_ADDR) logger.info("write 1 byte at: 0x" + Integer.toHexString(BASE_ADDR)
+ ", value: 0x" + Integer.toHexString(DATA)); + ", value: 0x" + Integer.toHexString(DATA));
MC68332.writeMem(BASE_ADDR, DATA, 1); bdi.writeMem(BASE_ADDR, DATA, 1);
logger.info("read 4 bytes at: 0x" + Integer.toHexString(BASE_ADDR) logger.info("read 4 bytes at: 0x" + Integer.toHexString(BASE_ADDR)
+ ", value: 0x" + ", value: 0x"
+ Integer.toHexString(MC68332.readMem(BASE_ADDR, 4))); + Integer.toHexString(bdi.readMem(BASE_ADDR, 4)));
logger.info("write 2 byte at: 0x" + Integer.toHexString(BASE_ADDR) logger.info("write 2 byte at: 0x" + Integer.toHexString(BASE_ADDR)
+ ", value: 0x" + Integer.toHexString(DATA)); + ", value: 0x" + Integer.toHexString(DATA));
MC68332.writeMem(BASE_ADDR, DATA, 2); bdi.writeMem(BASE_ADDR, DATA, 2);
logger.info("read 4 bytes at: 0x" + Integer.toHexString(BASE_ADDR) logger.info("read 4 bytes at: 0x" + Integer.toHexString(BASE_ADDR)
+ ", value: 0x" + ", value: 0x"
+ Integer.toHexString(MC68332.readMem(BASE_ADDR, 4))); + Integer.toHexString(bdi.readMem(BASE_ADDR, 4)));
logger.info("write 4 byte at: 0x" + Integer.toHexString(BASE_ADDR) logger.info("write 4 byte at: 0x" + Integer.toHexString(BASE_ADDR)
+ ", value: 0x" + Integer.toHexString(DATA)); + ", value: 0x" + Integer.toHexString(DATA));
MC68332.writeMem(BASE_ADDR, DATA, 4); bdi.writeMem(BASE_ADDR, DATA, 4);
logger.info("read 4 bytes at: 0x" + Integer.toHexString(BASE_ADDR) logger.info("read 4 bytes at: 0x" + Integer.toHexString(BASE_ADDR)
+ ", value: 0x" + ", value: 0x"
+ Integer.toHexString(MC68332.readMem(BASE_ADDR, 4))); + Integer.toHexString(bdi.readMem(BASE_ADDR, 4)));
} catch (USBException e) { } catch (USBException e) {
e.printStackTrace(); e.printStackTrace();
} catch (DispatchException e) { } catch (DispatchException e) {
@@ -560,14 +555,14 @@ public class BDI332test {
DispatchException, BDIException { DispatchException, BDIException {
int dumpSize = 0; int dumpSize = 0;
if (size > 2) { if (size > 2) {
dumpSize = MC68332.MAX_NOF_LONGS; dumpSize = bdi.getMaxNofLongs();
} else { } else {
dumpSize = MC68332.MAX_NOF_BYTES_WORDS; dumpSize = bdi.getMaxNofBytesWords();
} }
logger.info("read " + size + " byte(s) at 0x" logger.info("read " + size + " byte(s) at 0x"
+ Integer.toHexString(baseAddr) + ", value: " + Integer.toHexString(baseAddr) + ", value: "
+ Integer.toHexString(MC68332.readMem(baseAddr, size))); + Integer.toHexString(bdi.readMem(baseAddr, size)));
int[] result = MC68332.dumpMem(dumpSize); int[] result = bdi.dumpMem(dumpSize);
StringBuffer sb = new StringBuffer("data: "); StringBuffer sb = new StringBuffer("data: ");
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
sb.append("0x" + Integer.toHexString(result[i]) + " "); sb.append("0x" + Integer.toHexString(result[i]) + " ");
@@ -579,9 +574,9 @@ public class BDI332test {
DispatchException, BDIException { DispatchException, BDIException {
int fillSize = 0; int fillSize = 0;
if (size > 2) { if (size > 2) {
fillSize = MC68332.MAX_NOF_LONGS; fillSize = bdi.getMaxNofLongs();
} else { } else {
fillSize = MC68332.MAX_NOF_BYTES_WORDS; fillSize = bdi.getMaxNofBytesWords();
} }
int[] data = new int[fillSize]; int[] data = new int[fillSize];
for (int i = 0; i < data.length; i++) { for (int i = 0; i < data.length; i++) {
@@ -589,30 +584,31 @@ public class BDI332test {
} }
logger.info("fill " + data.length + " integers with size " + size logger.info("fill " + data.length + " integers with size " + size
+ " byte(s)"); + " byte(s)");
MC68332.writeMem(baseAddr, 0, size); bdi.writeMem(baseAddr, 0, size);
MC68332.fillMem(data, data.length); bdi.fillMem(data, data.length);
} }
public static void button18() { public static void button18() {
final int BASE_ADDR = 0x105624; final int BASE_ADDR = 0x105624;
int[] data = new int[MC68332.MAX_NOF_BYTES_WORDS]; int[] data = new int[bdi.getMaxNofBytesWords()];
for (int i = 0; i < data.length; i++) { for (int i = 0; i < data.length; i++) {
data[i] = i; data[i] = i;
} }
try { try {
IMCBTargetBoard.init(); IMCBTargetBoard imcb = new IMCBTargetBoard(bdi);
imcb.init();
fill(BASE_ADDR, 4); fill(BASE_ADDR, 4);
// TODO: this does produce an error why??? // TODO: this does produce an error why???
IMCBTargetBoard.init(); imcb.init();
dump(BASE_ADDR, 4); dump(BASE_ADDR, 4);
IMCBTargetBoard.init(); imcb.init();
fill(BASE_ADDR, 2); fill(BASE_ADDR, 2);
IMCBTargetBoard.init(); imcb.init();
dump(BASE_ADDR, 2); dump(BASE_ADDR, 2);
IMCBTargetBoard.init(); imcb.init();
fill(BASE_ADDR, 1); fill(BASE_ADDR, 1);
IMCBTargetBoard.init(); imcb.init();
dump(BASE_ADDR, 1); dump(BASE_ADDR, 1);
} catch (Exception e) { } catch (Exception e) {
@@ -628,28 +624,28 @@ public class BDI332test {
int REG = 0x8; int REG = 0x8;
int VALUE = 0x12345; int VALUE = 0x12345;
logger.info("test SysReg (ATEMP)"); logger.info("test SysReg (ATEMP)");
MC68332.writeSysReg(REG, VALUE); bdi.writeSysReg(REG, VALUE);
int result = MC68332.readSysReg(REG); int result = bdi.readSysReg(REG);
checkResult(VALUE, result); checkResult(VALUE, result);
REG = 0x5; REG = 0x5;
logger.info("test UserReg (D5)"); logger.info("test UserReg (D5)");
MC68332.writeUserReg(REG, VALUE); bdi.writeUserReg(REG, VALUE);
result = MC68332.readUserReg(REG); result = bdi.readUserReg(REG);
checkResult(VALUE, result); checkResult(VALUE, result);
REG = 0xD; REG = 0xD;
logger.info("test UserReg (A5)"); logger.info("test UserReg (A5)");
MC68332.writeUserReg(REG, VALUE); bdi.writeUserReg(REG, VALUE);
result = MC68332.readUserReg(REG); result = bdi.readUserReg(REG);
checkResult(VALUE, result); checkResult(VALUE, result);
// Does only work after LoadRam! // Does only work after LoadRam!
// //
// REG = 0xFFFFFA00; // REG = 0xFFFFFA00;
// logger.info("test ctrlReg (SIMCR)"); // logger.info("test ctrlReg (SIMCR)");
// MC68332.writeMem(REG, VALUE, 4); // bdi.writeMem(REG, VALUE, 4);
// result = MC68332.readMem(REG, 4); // result = bdi.readMem(REG, 4);
// checkResult(VALUE, result); // checkResult(VALUE, result);
} catch (USBException e) { } catch (USBException e) {
@@ -677,12 +673,10 @@ public class BDI332test {
final int BASE_ADDR = 0x01004E0; final int BASE_ADDR = 0x01004E0;
try { try {
StringBuffer sb = new StringBuffer("0x" StringBuffer sb = new StringBuffer("0x"
+ Integer.toHexString(MC68332.readMem(BASE_ADDR, 4)) + "\n"); + Integer.toHexString(bdi.readMem(BASE_ADDR, 4)) + "\n");
sb.append("0x" sb.append("0x" + Integer.toHexString(bdi.readMem(BASE_ADDR + 4, 4))
+ Integer.toHexString(MC68332.readMem(BASE_ADDR + 4, 4))
+ "\n"); + "\n");
sb.append("0x" sb.append("0x" + Integer.toHexString(bdi.readMem(BASE_ADDR + 8, 4))
+ Integer.toHexString(MC68332.readMem(BASE_ADDR + 8, 4))
+ "\n"); + "\n");
logger.info(sb.toString()); logger.info(sb.toString());
} catch (USBException e) { } catch (USBException e) {

View File

@@ -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.MPC555;
import ch.ntb.mcdp.usb.USBDevice; import ch.ntb.mcdp.usb.USBDevice;
import ch.ntb.usb.USBException; import ch.ntb.usb.USBException;
@@ -197,6 +198,7 @@ public class BDI555App {
try { try {
USBDevice.open(); USBDevice.open();
BDI555test.bdi = new MPC555(USBDevice.getDevice());
} catch (USBException e) { } catch (USBException e) {
e.printStackTrace(); e.printStackTrace();
return; return;

View File

@@ -13,6 +13,8 @@ public class BDI555test {
private static McdpLogger logger = LogUtil.ch_ntb_mcdp_bdi_test; private static McdpLogger logger = LogUtil.ch_ntb_mcdp_bdi_test;
public static MPC555 bdi;
// private static void testBdiTransaction() { // private static void testBdiTransaction() {
// // test bdi transaction // // test bdi transaction
// DataPacket result = null; // DataPacket result = null;
@@ -36,14 +38,14 @@ public class BDI555test {
private static void reset_target() { private static void reset_target() {
try { try {
MPC555.reset_target(); bdi.reset_target();
// assign pin to Freeze output // assign pin to Freeze output
MPC555.writeMem(0x02FC000, 0x40000, 4); bdi.writeMem(0x02FC000, 0x40000, 4);
// enable bus monitor, disable watchdog timer // enable bus monitor, disable watchdog timer
MPC555.writeMem(0x02FC004, 0x0FFFFFF83, 4); bdi.writeMem(0x02FC004, 0x0FFFFFF83, 4);
// SCCR, switch off EECLK for download // SCCR, switch off EECLK for download
MPC555.writeMem(0x02FC280, 0x08121C100, 4); bdi.writeMem(0x02FC280, 0x08121C100, 4);
logger.info("Is freeze asserted: " + MPC555.isFreezeAsserted()); logger.info("Is freeze asserted: " + bdi.isFreezeAsserted());
} catch (USBException e1) { } catch (USBException e1) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
@@ -58,7 +60,7 @@ public class BDI555test {
private static void freeze() { private static void freeze() {
try { try {
logger.info("isFreezeAsserted: " + MPC555.isFreezeAsserted()); logger.info("isFreezeAsserted: " + bdi.isFreezeAsserted());
} catch (USBException e) { } catch (USBException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@@ -74,7 +76,7 @@ public class BDI555test {
private static void break_() { private static void break_() {
try { try {
MPC555.break_(); bdi.break_();
logger.info("break"); logger.info("break");
} catch (USBException e) { } catch (USBException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
@@ -90,7 +92,7 @@ public class BDI555test {
private static void go() { private static void go() {
try { try {
MPC555.go(); bdi.go();
logger.info("go"); logger.info("go");
} catch (USBException e) { } catch (USBException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
@@ -107,7 +109,7 @@ public class BDI555test {
private static void writeMem() { private static void writeMem() {
final int BASE_ADDR = 0x800000, VALUE = 0x123456; final int BASE_ADDR = 0x800000, VALUE = 0x123456;
try { try {
MPC555.writeMem(BASE_ADDR, VALUE, 4); bdi.writeMem(BASE_ADDR, VALUE, 4);
logger.info("writeMem: BASE_ADDR = 0x" logger.info("writeMem: BASE_ADDR = 0x"
+ Integer.toHexString(BASE_ADDR) + ", value = 0x" + Integer.toHexString(BASE_ADDR) + ", value = 0x"
+ Integer.toHexString(VALUE)); + Integer.toHexString(VALUE));
@@ -130,8 +132,9 @@ public class BDI555test {
+ Integer.toHexString(BASE_ADDR) + ", value = "); + Integer.toHexString(BASE_ADDR) + ", value = ");
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
sb.append("0x" sb.append("0x"
+ Integer.toHexString(MPC555.readMem(BASE_ADDR + i * 4, + Integer
4)) + "\n"); .toHexString(bdi.readMem(BASE_ADDR + i * 4, 4))
+ "\n");
} }
logger.info(sb.toString()); logger.info(sb.toString());
} catch (USBException e) { } catch (USBException e) {
@@ -148,17 +151,17 @@ public class BDI555test {
private static void fastDownload() { private static void fastDownload() {
final int BASE_ADDR = 0x800000; final int BASE_ADDR = 0x800000;
int[] testData = new int[MPC555.MAX_NOF_WORDS_FAST_DOWNLOAD]; int[] testData = new int[bdi.getMaxNofWordsFastDownload()];
for (int i = 0; i < testData.length; i++) { for (int i = 0; i < testData.length; i++) {
testData[i] = i; testData[i] = i;
} }
try { try {
logger.info("fastDownload at BASE_ADDR = 0x" logger.info("fastDownload at BASE_ADDR = 0x"
+ Integer.toHexString(BASE_ADDR) + ", length = " + Integer.toHexString(BASE_ADDR) + ", length = "
+ MPC555.MAX_NOF_WORDS_FAST_DOWNLOAD); + bdi.getMaxNofWordsFastDownload());
MPC555.startFastDownload(BASE_ADDR); bdi.startFastDownload(BASE_ADDR);
MPC555.fastDownload(testData, MPC555.MAX_NOF_WORDS_FAST_DOWNLOAD); bdi.fastDownload(testData, bdi.getMaxNofWordsFastDownload());
MPC555.stopFastDownload(); bdi.stopFastDownload();
} catch (USBException e) { } catch (USBException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@@ -176,10 +179,10 @@ public class BDI555test {
try { try {
StringBuffer sb = new StringBuffer("readMemSeq: BASE_ADDR = 0x" StringBuffer sb = new StringBuffer("readMemSeq: BASE_ADDR = 0x"
+ Integer.toHexString(BASE_ADDR) + "\n" + 0 + "\tData: 0x" + Integer.toHexString(BASE_ADDR) + "\n" + 0 + "\tData: 0x"
+ Integer.toHexString(MPC555.readMem(BASE_ADDR, 4)) + "\n"); + Integer.toHexString(bdi.readMem(BASE_ADDR, 4)) + "\n");
for (int i = 1; i < 120; i++) { for (int i = 1; i < 120; i++) {
sb.append(i + "\tData: 0x" sb.append(i + "\tData: 0x"
+ Integer.toHexString(MPC555.readMemSeq(4)) + "\n"); + Integer.toHexString(bdi.readMemSeq(4)) + "\n");
} }
logger.info(sb.toString()); logger.info(sb.toString());
} catch (USBException e) { } catch (USBException e) {
@@ -231,13 +234,13 @@ public class BDI555test {
final int SPR = 158; final int SPR = 158;
final int VALUE = 0x12345; final int VALUE = 0x12345;
try { try {
int result = MPC555.readSPR(SPR); int result = bdi.readSPR(SPR);
logger.info("readSPR(" + SPR + ") = 0x" logger.info("readSPR(" + SPR + ") = 0x"
+ Integer.toHexString(result)); + Integer.toHexString(result));
MPC555.writeSPR(SPR, VALUE); bdi.writeSPR(SPR, VALUE);
logger.info("writeSPR(" + SPR + ", 0x" + Integer.toHexString(VALUE) logger.info("writeSPR(" + SPR + ", 0x" + Integer.toHexString(VALUE)
+ ")"); + ")");
result = MPC555.readSPR(SPR); result = bdi.readSPR(SPR);
logger.info("readSPR(" + SPR + ") = 0x" logger.info("readSPR(" + SPR + ") = 0x"
+ Integer.toHexString(result)); + Integer.toHexString(result));
} catch (USBException e) { } catch (USBException e) {
@@ -255,7 +258,7 @@ public class BDI555test {
// logger.info("hard_reset()"); // logger.info("hard_reset()");
// try { // try {
// MPC555.hard_reset(); // bdi.hard_reset();
// } catch (USBException e) { // } catch (USBException e) {
// e.printStackTrace(); // e.printStackTrace();
// } catch (DispatchException e) { // } catch (DispatchException e) {
@@ -290,21 +293,21 @@ public class BDI555test {
int REG = 152; int REG = 152;
int VALUE = 0x12345; int VALUE = 0x12345;
MPC555.writeSPR(REG, VALUE); bdi.writeSPR(REG, VALUE);
int result = MPC555.readSPR(REG); int result = bdi.readSPR(REG);
checkResult(VALUE, result); checkResult(VALUE, result);
logger.info("test GPR"); logger.info("test GPR");
REG = 5; REG = 5;
MPC555.writeGPR(REG, VALUE); bdi.writeGPR(REG, VALUE);
result = MPC555.readGPR(REG); result = bdi.readGPR(REG);
checkResult(VALUE, result); checkResult(VALUE, result);
logger.info("test FPR"); logger.info("test FPR");
int TMP_MEM_ADDR = 0x800000; int TMP_MEM_ADDR = 0x800000;
long LONG_VAL = 0x12345012345L; long LONG_VAL = 0x12345012345L;
MPC555.writeFPR(REG, TMP_MEM_ADDR, LONG_VAL); bdi.writeFPR(REG, TMP_MEM_ADDR, LONG_VAL);
long fprResult = MPC555.readFPR(REG, TMP_MEM_ADDR); long fprResult = bdi.readFPR(REG, TMP_MEM_ADDR);
if (fprResult != LONG_VAL) { if (fprResult != LONG_VAL) {
logger.severe("value: 0x" + Long.toHexString(LONG_VAL) logger.severe("value: 0x" + Long.toHexString(LONG_VAL)
+ ", result: 0x" + Long.toHexString(fprResult)); + ", result: 0x" + Long.toHexString(fprResult));
@@ -315,19 +318,19 @@ public class BDI555test {
} }
logger.info("test MSR"); logger.info("test MSR");
MPC555.writeMSR(VALUE); bdi.writeMSR(VALUE);
result = MPC555.readMSR(); result = bdi.readMSR();
checkResult(VALUE, result); checkResult(VALUE, result);
logger.info("test CR"); logger.info("test CR");
MPC555.writeCR(VALUE); bdi.writeCR(VALUE);
result = MPC555.readCR(); result = bdi.readCR();
checkResult(VALUE, result); checkResult(VALUE, result);
logger.info("test CtrlReg"); logger.info("test CtrlReg");
int MEM_ADDR = 0x2FC100; int MEM_ADDR = 0x2FC100;
MPC555.writeMem(MEM_ADDR, VALUE, 4); bdi.writeMem(MEM_ADDR, VALUE, 4);
result = MPC555.readMem(MEM_ADDR, 4); result = bdi.readMem(MEM_ADDR, 4);
checkResult(VALUE, result); checkResult(VALUE, result);
} catch (USBException e) { } catch (USBException e) {
@@ -356,7 +359,7 @@ public class BDI555test {
public static void button12() { public static void button12() {
final int BASE_ADDR = 0x3f9bf0; final int BASE_ADDR = 0x3f9bf0;
int[] data = new int[MPC555.MAX_NOF_WORDS_FAST_DOWNLOAD]; int[] data = new int[bdi.getMaxNofWordsFastDownload()];
data[0] = 0x9421ffb0; data[0] = 0x9421ffb0;
data[1] = 0xbf810040; data[1] = 0xbf810040;
@@ -463,26 +466,26 @@ public class BDI555test {
try { try {
StringBuffer sb = new StringBuffer("dumpData: BASE_ADDR = 0x" StringBuffer sb = new StringBuffer("dumpData: BASE_ADDR = 0x"
+ Integer.toHexString(BASE_ADDR) + "\n" + 0 + "\tData: 0x" + Integer.toHexString(BASE_ADDR) + "\n" + 0 + "\tData: 0x"
+ Integer.toHexString(MPC555.readMem(BASE_ADDR, 4)) + "\n"); + Integer.toHexString(bdi.readMem(BASE_ADDR, 4)) + "\n");
for (int i = 1; i < 120; i++) { for (int i = 1; i < 120; i++) {
sb.append(i + "\tData: 0x" sb.append(i + "\tData: 0x"
+ Integer.toHexString(MPC555.readMemSeq(4)) + "\n"); + Integer.toHexString(bdi.readMemSeq(4)) + "\n");
} }
logger.info(sb.toString()); logger.info(sb.toString());
logger.info("fastDownload at BASE_ADDR = 0x" logger.info("fastDownload at BASE_ADDR = 0x"
+ Integer.toHexString(BASE_ADDR) + ", length = " + Integer.toHexString(BASE_ADDR) + ", length = "
+ MPC555.MAX_NOF_WORDS_FAST_DOWNLOAD); + bdi.getMaxNofWordsFastDownload());
MPC555.startFastDownload(BASE_ADDR); bdi.startFastDownload(BASE_ADDR);
MPC555.fastDownload(data, MPC555.MAX_NOF_WORDS_FAST_DOWNLOAD); bdi.fastDownload(data, bdi.getMaxNofWordsFastDownload());
MPC555.stopFastDownload(); bdi.stopFastDownload();
sb = new StringBuffer("dumpData: BASE_ADDR = 0x" sb = new StringBuffer("dumpData: BASE_ADDR = 0x"
+ Integer.toHexString(BASE_ADDR) + "\n" + 0 + "\tData: 0x" + Integer.toHexString(BASE_ADDR) + "\n" + 0 + "\tData: 0x"
+ Integer.toHexString(MPC555.readMem(BASE_ADDR, 4)) + "\n"); + Integer.toHexString(bdi.readMem(BASE_ADDR, 4)) + "\n");
for (int i = 1; i < 120; i++) { for (int i = 1; i < 120; i++) {
sb.append(i + "\tData: 0x" sb.append(i + "\tData: 0x"
+ Integer.toHexString(MPC555.readMemSeq(4)) + "\n"); + Integer.toHexString(bdi.readMemSeq(4)) + "\n");
} }
logger.info(sb.toString()); logger.info(sb.toString());
} catch (USBException e) { } catch (USBException e) {
@@ -509,20 +512,20 @@ public class BDI555test {
private static void testFill(int baseAddr) throws USBException, private static void testFill(int baseAddr) throws USBException,
DispatchException, BDIException { DispatchException, BDIException {
// int length = (int) (1 + Math.random() // int length = (int) (1 + Math.random()
// * (MPC555.MAX_NOF_WORDS_FAST_DOWNLOAD - 1)); // * (bdi.getMaxNofWordsFastDownload() - 1));
int length = 101; int length = 101;
int[] data = getSampleData(length); int[] data = getSampleData(length);
logger.info("BaseAddr: 0x" + Integer.toHexString(baseAddr) logger.info("BaseAddr: 0x" + Integer.toHexString(baseAddr)
+ ", dataLength: " + data.length); + ", dataLength: " + data.length);
// download data // download data
MPC555.startFastDownload(baseAddr); bdi.startFastDownload(baseAddr);
MPC555.fastDownload(data, data.length); bdi.fastDownload(data, data.length);
MPC555.stopFastDownload(); bdi.stopFastDownload();
// read back data // read back data
int[] compare = new int[data.length]; int[] compare = new int[data.length];
compare[0] = MPC555.readMem(baseAddr, 4); compare[0] = bdi.readMem(baseAddr, 4);
for (int i = 1; i < compare.length; i++) { for (int i = 1; i < compare.length; i++) {
compare[i] = MPC555.readMemSeq(4); compare[i] = bdi.readMemSeq(4);
} }
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
for (int i = 0; i < compare.length; i++) { for (int i = 0; i < compare.length; i++) {
@@ -551,16 +554,16 @@ public class BDI555test {
// DER = 031C7400FH(* 835141647*) // DER = 031C7400FH(* 835141647*)
// SRR1 = 03802H(* 14338*) // SRR1 = 03802H(* 14338*)
MPC555.writeMem(0x2FC100, 0x01000003, 4); bdi.writeMem(0x2FC100, 0x01000003, 4);
MPC555.writeMem(0x2FC104, 0x0FFC00020, 4); bdi.writeMem(0x2FC104, 0x0FFC00020, 4);
MPC555.writeMem(0x2FC108, 0x0800003, 4); bdi.writeMem(0x2FC108, 0x0800003, 4);
MPC555.writeMem(0x2FC10C, 0x0FFE00020, 4); bdi.writeMem(0x2FC10C, 0x0FFE00020, 4);
MPC555.writeMem(0x2FC140, 3, 4); bdi.writeMem(0x2FC140, 3, 4);
MPC555.writeMem(0x2FC144, 0x7E000000, 4); bdi.writeMem(0x2FC144, 0x7E000000, 4);
MPC555.writeSPR(158, 0x07); bdi.writeSPR(158, 0x07);
MPC555.writeMem(0x2FC288, -1, 4); bdi.writeMem(0x2FC288, -1, 4);
MPC555.writeSPR(149, 0x031C7400F); bdi.writeSPR(149, 0x031C7400F);
MPC555.writeSPR(27, 0x03802); bdi.writeSPR(27, 0x03802);
for (int i = 0; i < nofRuns; i++) { for (int i = 0; i < nofRuns; i++) {
testFill(0x03F9800); testFill(0x03F9800);

File diff suppressed because it is too large Load Diff

View File

@@ -15,53 +15,58 @@ import ch.ntb.usb.USBException;
public class IMCBTargetBoard { public class IMCBTargetBoard {
static final McdpLogger logger = LogUtil.ch_ntb_mcdp_mc68332; private static final McdpLogger logger = LogUtil.ch_ntb_mcdp_mc68332;
final static String dictionaryPath = "resources/targets/mc68332/registerDictionary.xml"; private final static String dictionaryPath = "resources/targets/mc68332/registerDictionary.xml";
static MC68332RegisterDict regDict = new MC68332RegisterDict(); private static MC68332RegisterDict regDict = new MC68332RegisterDict();
private static void writeRegister(String name, int value) private MC68332 bdi;
throws USBException, DispatchException, BDIException {
public IMCBTargetBoard(MC68332 bdi) {
this.bdi = bdi;
}
public void writeRegister(String name, int value) throws USBException,
DispatchException, BDIException {
logger.info("writeRegister: " + name + ", value: 0x" logger.info("writeRegister: " + name + ", value: 0x"
+ Integer.toHexString(value)); + Integer.toHexString(value));
MC68332Register r = (MC68332Register) regDict.getRegister(name); MC68332Register r = (MC68332Register) regDict.getRegister(name);
switch (r.type) { switch (r.type) {
case MC68332Register.CtrlReg: case MC68332Register.CtrlReg:
MC68332.writeMem(r.value, value, r.size); bdi.writeMem(r.value, value, r.size);
break; break;
case MC68332Register.SysReg: case MC68332Register.SysReg:
MC68332.writeSysReg(r.value, value); bdi.writeSysReg(r.value, value);
break; break;
case MC68332Register.UserReg: case MC68332Register.UserReg:
MC68332.writeUserReg(r.value, value); bdi.writeUserReg(r.value, value);
break; break;
} }
} }
private static int readRegister(String name) throws USBException, public int readRegister(String name) throws USBException,
DispatchException, BDIException { DispatchException, BDIException {
logger.info("readRegister: " + name); logger.info("readRegister: " + name);
MC68332Register r = (MC68332Register) regDict.getRegister(name); MC68332Register r = (MC68332Register) regDict.getRegister(name);
switch (r.type) { switch (r.type) {
case MC68332Register.CtrlReg: case MC68332Register.CtrlReg:
return MC68332.readMem(r.value, r.size); return bdi.readMem(r.value, r.size);
case MC68332Register.SysReg: case MC68332Register.SysReg:
return MC68332.readSysReg(r.value); return bdi.readSysReg(r.value);
case MC68332Register.UserReg: case MC68332Register.UserReg:
return MC68332.readUserReg(r.value); return bdi.readUserReg(r.value);
} }
return -1; return -1;
} }
public static void init() throws USBException, DispatchException, public void init() throws USBException, DispatchException, BDIException,
BDIException, IOException, ParserConfigurationException, IOException, ParserConfigurationException, SAXException {
SAXException {
logger.info("reading dictionary file from " + dictionaryPath); logger.info("reading dictionary file from " + dictionaryPath);
regDict.addRegistersFromFile(dictionaryPath); regDict.addRegistersFromFile(dictionaryPath);
MC68332.reset_target(); bdi.reset_target();
// regDict.printRegisters(); // regDict.printRegisters();