- test for read/write all type of registers
git-svn-id: https://svn.code.sf.net/p/libusbjava/code/trunk@82 94ad28fe-ef68-46b1-9651-e7ae4fcf1c4c
This commit is contained in:
@@ -33,6 +33,8 @@ public class BDI555App {
|
|||||||
|
|
||||||
private Button button10 = null;
|
private Button button10 = null;
|
||||||
|
|
||||||
|
private Button button11 = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method initializes sShell
|
* This method initializes sShell
|
||||||
*/
|
*/
|
||||||
@@ -40,7 +42,7 @@ public class BDI555App {
|
|||||||
sShell = new Shell();
|
sShell = new Shell();
|
||||||
sShell.setText("Shell");
|
sShell.setText("Shell");
|
||||||
sShell.setLayout(new RowLayout());
|
sShell.setLayout(new RowLayout());
|
||||||
sShell.setSize(new org.eclipse.swt.graphics.Point(348,83));
|
sShell.setSize(new org.eclipse.swt.graphics.Point(348,108));
|
||||||
button1 = new Button(sShell, SWT.NONE);
|
button1 = new Button(sShell, SWT.NONE);
|
||||||
button1.setText("testBdiTransaction");
|
button1.setText("testBdiTransaction");
|
||||||
button1
|
button1
|
||||||
@@ -99,6 +101,13 @@ public class BDI555App {
|
|||||||
button9.setText("Button9");
|
button9.setText("Button9");
|
||||||
button10 = new Button(sShell, SWT.NONE);
|
button10 = new Button(sShell, SWT.NONE);
|
||||||
button10.setText("fastDownload");
|
button10.setText("fastDownload");
|
||||||
|
button11 = new Button(sShell, SWT.NONE);
|
||||||
|
button11.setText("read/write Registers");
|
||||||
|
button11.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||||
|
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
|
||||||
|
BDI555test.button11();
|
||||||
|
}
|
||||||
|
});
|
||||||
button10.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
button10.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
||||||
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
|
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
|
||||||
BDI555test.button10();
|
BDI555test.button10();
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package ch.ntb.mcdp.bdi.test;
|
package ch.ntb.mcdp.bdi.test;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
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;
|
||||||
@@ -226,7 +228,31 @@ public class BDI555test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void button9() {
|
public static void button9() {
|
||||||
logger.info("not implemented!");
|
final int SPR = 158;
|
||||||
|
final int VALUE = 0x12345;
|
||||||
|
try {
|
||||||
|
int result = MPC555.readSPR(SPR);
|
||||||
|
logger.info("readSPR(" + SPR + ") = 0x"
|
||||||
|
+ Integer.toHexString(result));
|
||||||
|
MPC555.writeSPR(SPR, VALUE);
|
||||||
|
logger.info("writeSPR(" + SPR + ", 0x" + Integer.toHexString(VALUE)
|
||||||
|
+ ")");
|
||||||
|
result = MPC555.readSPR(SPR);
|
||||||
|
logger.info("readSPR(" + SPR + ") = 0x"
|
||||||
|
+ Integer.toHexString(result));
|
||||||
|
} catch (USBException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (DispatchException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (BDIException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
// logger.info("not implemented!");
|
||||||
|
|
||||||
// logger.info("hard_reset()");
|
// logger.info("hard_reset()");
|
||||||
// try {
|
// try {
|
||||||
// MPC555.hard_reset();
|
// MPC555.hard_reset();
|
||||||
@@ -243,22 +269,87 @@ public class BDI555test {
|
|||||||
fastDownload();
|
fastDownload();
|
||||||
}
|
}
|
||||||
|
|
||||||
// public static void main(String[] args) {
|
public static void button11() {
|
||||||
// boolean testRunning = true;
|
Level oldLevel = LogUtil.ch_ntb_mcdp_bdi.getLevel();
|
||||||
//
|
LogUtil.setLevel(LogUtil.ch_ntb_mcdp_bdi, Level.ALL);
|
||||||
// while (testRunning) {
|
try {
|
||||||
// // testBdiTransaction();
|
logger.info("test SPR");
|
||||||
// // reset_target();
|
|
||||||
// // freeze();
|
// valid spr registers:
|
||||||
// // go();
|
// CMPA<EFBFBD>CMPD SPR 144 <20> SPR 147
|
||||||
// // System.out.println();
|
// CMPE<EFBFBD>CMPF SPR 152, 153
|
||||||
//
|
// CMPG<50>CMPH SPR 154, 155
|
||||||
// try {
|
// ICTRL SPR 158
|
||||||
// Thread.sleep(5000);
|
// LCTRL1 SPR 156
|
||||||
// } catch (InterruptedException e) {
|
// LCTRL2 SPR 157
|
||||||
// e.printStackTrace();
|
// COUNTA SPR 150
|
||||||
// }
|
// COUNTB SPR 151
|
||||||
// }
|
// ECR SPR 148
|
||||||
//
|
// DER SPR 149
|
||||||
// }
|
|
||||||
|
int REG = 152;
|
||||||
|
int VALUE = 0x12345;
|
||||||
|
MPC555.writeSPR(REG, VALUE);
|
||||||
|
int result = MPC555.readSPR(REG);
|
||||||
|
checkResult(VALUE, result);
|
||||||
|
|
||||||
|
logger.info("test GPR");
|
||||||
|
REG = 5;
|
||||||
|
MPC555.writeGPR(REG, VALUE);
|
||||||
|
result = MPC555.readGPR(REG);
|
||||||
|
checkResult(VALUE, result);
|
||||||
|
|
||||||
|
logger.info("test FPR");
|
||||||
|
int TMP_MEM_ADDR = 0x800000;
|
||||||
|
long LONG_VAL = 0x12345012345L;
|
||||||
|
MPC555.writeFPR(REG, TMP_MEM_ADDR, LONG_VAL);
|
||||||
|
long fprResult = MPC555.readFPR(REG, TMP_MEM_ADDR);
|
||||||
|
if (fprResult != LONG_VAL) {
|
||||||
|
logger.severe("value: 0x" + Long.toHexString(LONG_VAL)
|
||||||
|
+ ", result: 0x" + Long.toHexString(fprResult));
|
||||||
|
} else {
|
||||||
|
logger
|
||||||
|
.info("test ok: result: 0x"
|
||||||
|
+ Long.toHexString(fprResult));
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info("test MSR");
|
||||||
|
MPC555.writeMSR(VALUE);
|
||||||
|
result = MPC555.readMSR();
|
||||||
|
checkResult(VALUE, result);
|
||||||
|
|
||||||
|
logger.info("test CR");
|
||||||
|
MPC555.writeCR(VALUE);
|
||||||
|
result = MPC555.readCR();
|
||||||
|
checkResult(VALUE, result);
|
||||||
|
|
||||||
|
logger.info("test CtrlReg");
|
||||||
|
int MEM_ADDR = 0x2FC100;
|
||||||
|
MPC555.writeMem(MEM_ADDR, VALUE, 4);
|
||||||
|
result = MPC555.readMem(MEM_ADDR, 4);
|
||||||
|
checkResult(VALUE, result);
|
||||||
|
|
||||||
|
} catch (USBException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (DispatchException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (BDIException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
LogUtil.setLevel(LogUtil.ch_ntb_mcdp_bdi, oldLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void checkResult(int value, int result) {
|
||||||
|
if (value != result) {
|
||||||
|
logger.severe("value: 0x" + Integer.toHexString(value)
|
||||||
|
+ ", result: 0x" + Integer.toHexString(result));
|
||||||
|
} else {
|
||||||
|
logger.info("test ok: result: 0x" + Integer.toHexString(result));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user