checkpoint
[slipway.git] / src / com / atmel / fpslic / FpslicRawUsb.java
index f8011e5..61b687b 100644 (file)
@@ -35,19 +35,12 @@ public class FpslicRawUsb implements FpslicRaw {
             (1<<5) |
             (1<<6) |
             (1<<7);
-        avrrst(false);
-
-        flush();
-        //purge();
-
         ftdiuart.dbus_mode(dmask);
-        flush();
 
+        avrrst(false);
         clk(false);
         data(false);
         con(false);
-        flush();
-        //try { Thread.sleep(500); } catch (Exception e) { }
 
         reset(false);
         flush();
@@ -124,13 +117,11 @@ public class FpslicRawUsb implements FpslicRaw {
         pin = initErr();
         System.out.println("good preamble   => " + pin + " " + (pin ? green("good") : red("BAD")));
 
-        reset();
-        try { Thread.sleep(100); } catch (Exception e) { }
-        config(0,3);
+        getConfigStream();
+        config(0,1);
         con();
         config(0,6);
         flush();
-        // one too many
         config(Integer.parseInt("10110111", 2), 8);
         config(0, 2);
         flush();
@@ -138,8 +129,6 @@ public class FpslicRawUsb implements FpslicRaw {
         pin = initErr();
         System.out.println("bad preamble #2 => " + pin + " " + (pin ? red("BAD") : green("good")));
 
-        reset();
-        try { Thread.sleep(100); } catch (Exception e) { }
         getConfigStream();
         config(0,1);
         con();
@@ -169,7 +158,7 @@ public class FpslicRawUsb implements FpslicRaw {
             boolean bit = (dat & (1<<i)) != 0;
             data(bit);
             clk(true);
-            clk(false);
+            dbits &= ~(1<<6);  // let the clock fall with the next data bit, whenever it goes out
         }
     }