X-Git-Url: http://git.megacz.com/?p=slipway.git;a=blobdiff_plain;f=src%2Fcom%2Fatmel%2Ffpslic%2FFpslicRaw.java;h=fe392932c8340cb8c4a7ff1e735199b95a252399;hp=e1e988352567ab60444b9eeb269d7b15b56d35fb;hb=6e3baea580262d8ec8074350dfcc3308286ae669;hpb=d44022802297d495dfb0de032251f62d0021a1f6
diff --git a/src/com/atmel/fpslic/FpslicRaw.java b/src/com/atmel/fpslic/FpslicRaw.java
index e1e9883..fe39293 100644
--- a/src/com/atmel/fpslic/FpslicRaw.java
+++ b/src/com/atmel/fpslic/FpslicRaw.java
@@ -6,12 +6,140 @@ import java.io.*;
/**
* "Raw" access to an unconfigured FPSLIC -- used to load the initial bitstream.
*/
-public interface FpslicRaw {
+public class FpslicRaw {
- public InputStream getInputStream() throws IOException;
- public OutputStream getOutputStream() throws IOException;
- public OutputStream getConfigStream() throws IOException;
- public void reset() throws IOException;
- public void selfTest() throws Exception;
+ private FpslicPins pins;
+
+ public FpslicRaw(FpslicPins pins) throws IOException {
+ this.pins = pins;
+ reset();
+ }
+
+ public void reset() throws IOException {
+
+ pins.avrrstPin(false);
+ pins.configDataPin(false);
+ pins.resetPin(false);
+ pins.cclkPin(false);
+
+ pins.conPin(false);
+ pins.flush();
+
+ pins.resetPin(false);
+ try { Thread.sleep(500); } catch (Exception e) { }
+ if (pins.initPin()) throw new RuntimeException("INIT was still high after pulling RESET low");
+
+ pins.resetPin(true);
+ try { Thread.sleep(500); } catch (Exception e) { }
+ if (!pins.initPin()) throw new RuntimeException("INIT was still low after releasing RESET");
+
+ sendConfigBits(0,2);
+ pins.flush();
+ }
+
+ public OutputStream getConfigStream() throws IOException {
+ reset();
+ return new OutputStream() {
+ int bytes = 0;
+ int bits = 0;
+ public void write(int in) throws IOException {
+ for(int i=7; i>=0; i--) {
+ bits++;
+ sendConfigBits((((in & 0xff) & (1<=0; i--) {
+ boolean bit = (dat & (1<