From f82b4cbc1c81ff33e7adccc93bd6dca6f187ce80 Mon Sep 17 00:00:00 2001 From: adam Date: Thu, 21 Sep 2006 15:50:38 +0100 Subject: [PATCH] checkpoint --- src/com/atmel/fpslic/FpslicRawUsb.java | 50 ++++++++------------------------ 1 file changed, 12 insertions(+), 38 deletions(-) diff --git a/src/com/atmel/fpslic/FpslicRawUsb.java b/src/com/atmel/fpslic/FpslicRawUsb.java index 689dde5..cbc6e80 100644 --- a/src/com/atmel/fpslic/FpslicRawUsb.java +++ b/src/com/atmel/fpslic/FpslicRawUsb.java @@ -40,25 +40,26 @@ public class FpslicRawUsb implements FpslicRaw { avrrst(false); clk(false); data(false); - con(false); - reset(false); flush(); + dmask |= (1<<0); + dbang(0, false); + ftdiuart.dbus_mode(dmask); + + reset(false); try { Thread.sleep(500); } catch (Exception e) { } if (initErr()) throw new RuntimeException("INIT was still high after pulling RESET low"); reset(true); - flush(); try { Thread.sleep(500); } catch (Exception e) { } if (!initErr()) throw new RuntimeException("INIT was still low after releasing RESET"); - con(false); + config(0,2); + flush(); } public OutputStream getConfigStream() throws IOException { reset(); - config(0,2); - flush(); return new OutputStream() { int bytes = 0; int bits = 0; @@ -66,7 +67,6 @@ public class FpslicRawUsb implements FpslicRaw { for(int i=7; i>=0; i--) { bits++; config((((in & 0xff) & (1< " + pin + " " + (pin ? green("good") : red("BAD"))); getConfigStream(); - config(0,1); - con(); - config(0,6); - flush(); + config(Integer.parseInt("0000000", 2), 7); config(Integer.parseInt("10110111", 2), 8); config(0, 2); flush(); @@ -130,9 +121,7 @@ public class FpslicRawUsb implements FpslicRaw { System.out.println("bad preamble #2 => " + pin + " " + (pin ? red("BAD") : green("good"))); getConfigStream(); - config(0,1); - con(); - config(0,7); + config(Integer.parseInt("00000000", 2), 8); config(Integer.parseInt("11110111", 2), 8); config(0, 1); flush(); @@ -179,24 +168,9 @@ public class FpslicRawUsb implements FpslicRaw { private void data(boolean on) throws IOException { dbang(5, on); } private boolean initErr() throws IOException { flush(); return (ftdiuart.readPins() & (1<<4))!=0; } - private boolean con() throws IOException { - flush(); - //dmask &= ~(1<<0); - ftdiuart.dbus_mode(dmask); - return (ftdiuart.readPins() & (1<<0)) != 0; - } - - private boolean rcon() throws IOException { - flush(); + private void rcon() throws IOException { dmask &= ~(1<<0); ftdiuart.dbus_mode(dmask); - return (ftdiuart.readPins() & (1<<0)) != 0; - } - private void con(boolean on) throws IOException { - flush(); - dmask |= (1<<0); - dbang(0, on); - ftdiuart.dbus_mode(dmask); } private static String red(Object o) { return "\033[31m"+o+"\033[0m"; } -- 1.7.10.4