|
@@ -4,6 +4,7 @@ import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
import net.hkzlab.devices.PALSpecs;
|
|
import net.hkzlab.devices.PALSpecs;
|
|
|
|
+import net.hkzlab.dupal.dupalproto.DuPALProto;
|
|
|
|
|
|
public class DuPALAnalyzer {
|
|
public class DuPALAnalyzer {
|
|
private final Logger logger = LoggerFactory.getLogger(DuPALAnalyzer.class);
|
|
private final Logger logger = LoggerFactory.getLogger(DuPALAnalyzer.class);
|
|
@@ -32,6 +33,34 @@ public class DuPALAnalyzer {
|
|
}
|
|
}
|
|
|
|
|
|
private void guessIOs() {
|
|
private void guessIOs() {
|
|
|
|
+ int inmask = pspecs.getINMask() | pspecs.getIO_WRITEMask();
|
|
|
|
|
|
|
|
+ int read, out_pins = 0;
|
|
|
|
+ for(int idx = 0; idx <= inmask; idx++) {
|
|
|
|
+ if((idx & ~inmask) != 0) continue; // We need to skip this round
|
|
|
|
+
|
|
|
|
+ for(int i_idx = 0; i_idx <= inmask; i_idx++) {
|
|
|
|
+ if((i_idx & ~inmask) != 0) continue; // We need to skip this round
|
|
|
|
+
|
|
|
|
+ dpm.writeCommand(DuPALProto.buildWRITECommand((i_idx | pspecs.getIO_WRITEMask()) & ~(pspecs.getOEPinMask() | pspecs.getCLKPinMask() )));
|
|
|
|
+ dpm.writeCommand(DuPALProto.buildREADCommand());
|
|
|
|
+ read = DuPALProto.handleREADResponse(dpm.readResponse());
|
|
|
|
+ out_pins |= (read ^ pspecs.getIO_READMask());
|
|
|
|
+
|
|
|
|
+ dpm.writeCommand(DuPALProto.buildWRITECommand(i_idx & ~(pspecs.getOEPinMask() | pspecs.getCLKPinMask() | pspecs.getIO_WRITEMask())));
|
|
|
|
+ dpm.writeCommand(DuPALProto.buildREADCommand());
|
|
|
|
+ read = DuPALProto.handleREADResponse(dpm.readResponse());
|
|
|
|
+ out_pins |= ((read ^ ~pspecs.getIO_READMask()) & pspecs.getIO_READMask());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ pulseClock(idx & ~pspecs.getOEPinMask());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ System.out.println("TEST - guessIO: " + Integer.toHexString(out_pins));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void pulseClock(int addr) {
|
|
|
|
+ dpm.writeCommand(DuPALProto.buildWRITECommand((addr | pspecs.getCLKPinMask()) & ~pspecs.getOEPinMask())); // Clock high,
|
|
|
|
+ dpm.writeCommand(DuPALProto.buildWRITECommand(addr & ~(pspecs.getOEPinMask() | pspecs.getCLKPinMask()))); // Clock low
|
|
}
|
|
}
|
|
}
|
|
}
|