From 6e3baea580262d8ec8074350dfcc3308286ae669 Mon Sep 17 00:00:00 2001 From: adam Date: Fri, 22 Sep 2006 04:06:14 +0100 Subject: [PATCH] checkpoint --- src/com/atmel/fpslic/FpslicRaw.java | 140 ++++++++++++++++++++++++++++-- src/com/atmel/fpslic/FpslicRawUsb.java | 143 ------------------------------- src/edu/berkeley/slipway/FtdiBoard.java | 2 +- 3 files changed, 135 insertions(+), 150 deletions(-) delete mode 100644 src/com/atmel/fpslic/FpslicRawUsb.java 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<=0; i--) { - bits++; - sendConfigBits((((in & 0xff) & (1<=0; i--) { - boolean bit = (dat & (1<