- logger added

git-svn-id: https://svn.code.sf.net/p/libusbjava/code/trunk@68 94ad28fe-ef68-46b1-9651-e7ae4fcf1c4c
This commit is contained in:
schlaepfer
2006-01-09 08:52:55 +00:00
parent 892a9a39f1
commit 9f85a64c0d

View File

@@ -3,10 +3,14 @@ package ch.ntb.mcdp.bdi.test;
import ch.ntb.mcdp.bdi.BDIException; import ch.ntb.mcdp.bdi.BDIException;
import ch.ntb.mcdp.bdi.MPC555; import ch.ntb.mcdp.bdi.MPC555;
import ch.ntb.mcdp.usb.DispatchException; import ch.ntb.mcdp.usb.DispatchException;
import ch.ntb.mcdp.utils.logger.LogUtil;
import ch.ntb.mcdp.utils.logger.McdpLogger;
import ch.ntb.usb.USBException; import ch.ntb.usb.USBException;
public class BDI555test { public class BDI555test {
private static McdpLogger logger = LogUtil.ch_ntb_mcdp_bdi_test;
// private static void testBdiTransaction() { // private static void testBdiTransaction() {
// // test bdi transaction // // test bdi transaction
// DataPacket result = null; // DataPacket result = null;
@@ -37,6 +41,7 @@ public class BDI555test {
MPC555.writeMem(0x02FC004, 0x0FFFFFF83, 4); MPC555.writeMem(0x02FC004, 0x0FFFFFF83, 4);
// SCCR, switch off EECLK for download // SCCR, switch off EECLK for download
MPC555.writeMem(0x02FC280, 0x08121C100, 4); MPC555.writeMem(0x02FC280, 0x08121C100, 4);
logger.info("Is freeze asserted: " + MPC555.isFreezeAsserted());
} catch (USBException e1) { } catch (USBException e1) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
@@ -51,8 +56,7 @@ public class BDI555test {
private static void freeze() { private static void freeze() {
try { try {
System.out logger.info("isFreezeAsserted: " + MPC555.isFreezeAsserted());
.println("isFreezeAsserted: " + MPC555.isFreezeAsserted());
} catch (USBException e) { } catch (USBException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@@ -69,6 +73,7 @@ public class BDI555test {
private static void break_() { private static void break_() {
try { try {
MPC555.break_(); MPC555.break_();
logger.info("break");
} catch (USBException e) { } catch (USBException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@@ -84,6 +89,7 @@ public class BDI555test {
private static void go() { private static void go() {
try { try {
MPC555.go(); MPC555.go();
logger.info("go");
} catch (USBException e) { } catch (USBException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@@ -97,9 +103,12 @@ public class BDI555test {
} }
private static void writeMem() { private static void writeMem() {
final int BASE_ADDR = 0x800000; final int BASE_ADDR = 0x800000, VALUE = 0x123456;
try { try {
MPC555.writeMem(BASE_ADDR, 0x123456, 4); MPC555.writeMem(BASE_ADDR, VALUE, 4);
logger.info("writeMem: BASE_ADDR = 0x"
+ Integer.toHexString(BASE_ADDR) + ", value = 0x"
+ Integer.toHexString(VALUE));
} catch (USBException e) { } catch (USBException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@@ -115,13 +124,14 @@ public class BDI555test {
private static void readMem() { private static void readMem() {
final int BASE_ADDR = 0x800000; final int BASE_ADDR = 0x800000;
try { try {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer("readMem: BASE_ADDR = 0x"
+ 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, 4)) + Integer.toHexString(MPC555.readMem(BASE_ADDR + i * 4,
+ "\n"); 4)) + "\n");
} }
System.out.println(sb.toString()); logger.info(sb.toString());
} catch (USBException e) { } catch (USBException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@@ -136,11 +146,14 @@ 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[120]; int[] testData = new int[MPC555.MAX_NOF_WORDS_FAST_DOWNLOAD];
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"
+ Integer.toHexString(BASE_ADDR) + ", length = "
+ MPC555.MAX_NOF_WORDS_FAST_DOWNLOAD);
MPC555.startFastDownload(BASE_ADDR); MPC555.startFastDownload(BASE_ADDR);
MPC555.fastDownload(testData, MPC555.MAX_NOF_WORDS_FAST_DOWNLOAD); MPC555.fastDownload(testData, MPC555.MAX_NOF_WORDS_FAST_DOWNLOAD);
MPC555.stopFastDownload(); MPC555.stopFastDownload();
@@ -159,13 +172,14 @@ public class BDI555test {
private static void readMemSeq() { private static void readMemSeq() {
final int BASE_ADDR = 0x800000; final int BASE_ADDR = 0x800000;
try { try {
StringBuffer sb = new StringBuffer(0 + "\tData: 0x" StringBuffer sb = new StringBuffer("readMemSeq: BASE_ADDR = 0x"
+ Integer.toHexString(BASE_ADDR) + "\n" + 0 + "\tData: 0x"
+ Integer.toHexString(MPC555.readMem(BASE_ADDR, 4)) + "\n"); + Integer.toHexString(MPC555.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(MPC555.readMemSeq(4)) + "\n");
} }
System.out.println(sb.toString()); logger.info(sb.toString());
} catch (USBException e) { } catch (USBException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@@ -184,46 +198,48 @@ public class BDI555test {
} }
public static void button2() { public static void button2() {
System.out.println("reset_target()");
reset_target(); reset_target();
} }
public static void button3() { public static void button3() {
System.out.println("go()");
go(); go();
} }
public static void button4() { public static void button4() {
System.out.println("break_()");
break_(); break_();
} }
public static void button5() { public static void button5() {
System.out.println("freeze()");
freeze(); freeze();
} }
public static void button6() { public static void button6() {
System.out.println("writeMem()");
writeMem(); writeMem();
} }
public static void button7() { public static void button7() {
System.out.println("readMem()");
readMem(); readMem();
} }
public static void button8() { public static void button8() {
System.out.println("readMemSeq()");
readMemSeq(); readMemSeq();
} }
public static void button9() { public static void button9() {
System.out.println(""); logger.info("not implemented!");
// logger.info("hard_reset()");
// try {
// MPC555.hard_reset();
// } catch (USBException e) {
// e.printStackTrace();
// } catch (DispatchException e) {
// e.printStackTrace();
// } catch (BDIException e) {
// e.printStackTrace();
// }
} }
public static void button10() { public static void button10() {
System.out.println("fastDownload()");
fastDownload(); fastDownload();
} }