public OutputStream getOutputStream() { return out; }
public FtdiBoard() throws Exception {
+ super(24, 24);
chip = new FpslicBoot(new FpslicBootPinsUsb(new FtdiUart(0x6666, 0x3133, 1500 * 1000)));
String bstFile = this.getClass().getName();
bstFile = bstFile.substring(0, bstFile.lastIndexOf('.'));
out = new DataOutputStream(chip.getOutputStream());
for(int i=0; i<255; i++) out.write(0);
out.flush();
+ init();
}
public void reset() throws IOException {
}
}
+ // FIXME: what if init() is called twice?
+ new Thread() {
+ public void run() {
+ while(true) {
+ try {
+ byte b = in.readByte();
+ ByteCallback bc = (ByteCallback)callbacks.remove(0);
+ bc.call(b);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }.start();
}
public synchronized void scanFPGA(boolean on) throws IOException {
public static int retval = 0;
public synchronized int readCount() {
try {
- if (reader != null) {
- reader.start();
- reader = null;
- }
ByteCallback bc = new ByteCallback() {
public synchronized void call(byte b) throws Exception {
retval =
private Vector callbacks = new Vector();
- private Thread reader = new Thread() {
- public void run() {
- System.out.println("*** reader thread begun");
- while(true) {
- try {
- byte b = in.readByte();
- ByteCallback bc = (ByteCallback)callbacks.remove(0);
- bc.call(b);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- };
-
public synchronized void readBus(ByteCallback bc) throws IOException {
callbacks.add(bc);
out.writeByte(2);
out.flush();
- if (reader != null) {
- reader.start();
- reader = null;
- }
}
public synchronized void readInterrupts(ByteCallback bc) throws IOException {
callbacks.add(bc);
out.writeByte(6);
out.flush();
- if (reader != null) {
- reader.start();
- reader = null;
- }
}
private byte[][][] cache = new byte[24][][];