X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Fcom%2Fatmel%2Ffpslic%2FChipImpl.java;h=dedc4b04b32c95bcec41ec3dd6fec684291eb7b3;hb=3212d3617ec8c1b2dce1e8a0991f196f03236ef9;hp=84a41c5579b5503073199616acb8dd3ebe6c1732;hpb=423974291c90fbba82ed586499e01c774ee96ae0;p=slipway.git diff --git a/src/com/atmel/fpslic/ChipImpl.java b/src/com/atmel/fpslic/ChipImpl.java index 84a41c5..dedc4b0 100644 --- a/src/com/atmel/fpslic/ChipImpl.java +++ b/src/com/atmel/fpslic/ChipImpl.java @@ -19,11 +19,7 @@ public class ChipImpl extends FtdiUart implements Chip { doReset(); } - public void flush() throws IOException { - try { - getOutputStream().flush(); - } catch (Exception e) { throw new RuntimeException(e); } - } + public void flush() throws IOException { getOutputStream().flush(); } protected int dbits = 0; protected synchronized void dbang(int bit, boolean val) throws IOException { @@ -62,13 +58,12 @@ public class ChipImpl extends FtdiUart implements Chip { flush(); try { Thread.sleep(500); } catch (Exception e) { } if (initErr()) throw new RuntimeException("INIT was still high after pulling RESET low"); - //System.out.println("0 con() = " + con()); reset(true); flush(); try { Thread.sleep(500); } catch (Exception e) { } if (!initErr()) throw new RuntimeException("INIT was still low after releasing RESET"); - //System.out.println("1 con() = " + con()); + con(false); } @@ -119,4 +114,90 @@ public class ChipImpl extends FtdiUart implements Chip { dbang(0, on); dbus_mode(dmask); } + + public OutputStream getConfigStream() throws IOException { + doReset(); + config(0,10); + con(); + return new OutputStream() { + int bytes = 0; + public void write(int in) throws IOException { + bytes++; + for(int i=7; i>=0; i--) { + config((((in & 0xff) & (1< " + pin + " " + (pin ? green("good") : red("BAD"))); + + d.doReset(); + try { Thread.sleep(100); } catch (Exception e) { } + d.config(0,3); + d.con(); + d.config(0,6); + d.flush(); + //d.flush(); + d.config(Integer.parseInt("10110111", 2), 8); + d.config(0, 2); + d.flush(); + try { Thread.sleep(100); } catch (Exception e) { } + pin = d.initErr(); + System.out.println("bad preamble #2 => " + pin + " " + (pin ? red("BAD") : green("good"))); + + d.doReset(); + try { Thread.sleep(100); } catch (Exception e) { } + d.config(0,3); + d.con(); + d.config(0,7); + d.flush(); + //d.flush(); + d.config(Integer.parseInt("11110111", 2), 8); + d.config(0, 1); + d.flush(); + try { Thread.sleep(100); } catch (Exception e) { } + pin = d.initErr(); + System.out.println("bad preamble #1 => " + pin + " " + (pin ? red("BAD") : green("good"))); + } }