From 75fe11ac15f5de917698dc6649b862e38b087564 Mon Sep 17 00:00:00 2001 From: adam Date: Thu, 21 Sep 2006 15:07:48 +0100 Subject: [PATCH] checkpoint --- src/com/atmel/fpslic/Chip.java | 26 ----------- src/com/atmel/fpslic/FpslicRaw.java | 17 +++++++ .../fpslic/{ChipImpl.java => FpslicRawUsb.java} | 48 ++++++++++---------- src/edu/berkeley/slipway/FtdiBoard.java | 15 +++--- 4 files changed, 47 insertions(+), 59 deletions(-) delete mode 100644 src/com/atmel/fpslic/Chip.java create mode 100644 src/com/atmel/fpslic/FpslicRaw.java rename src/com/atmel/fpslic/{ChipImpl.java => FpslicRawUsb.java} (80%) diff --git a/src/com/atmel/fpslic/Chip.java b/src/com/atmel/fpslic/Chip.java deleted file mode 100644 index 57c9d98..0000000 --- a/src/com/atmel/fpslic/Chip.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.atmel.fpslic; - -import com.ftdi.usb.*; -import java.io.*; - -public interface Chip { - - public void doReset() throws IOException; - public void reset(boolean on) throws IOException; - public void avrrst(boolean on) throws IOException; - public void config(boolean bit) throws IOException; - public void config(int data, int numbits) throws IOException; - public boolean initErr() throws IOException; - - public void con(boolean b) throws IOException; - public boolean con() throws IOException; - public boolean rcon() throws IOException; - - //remove - public void flush() throws IOException; - public InputStream getInputStream(); - public OutputStream getOutputStream(); - public void selfTest() throws Exception; - public OutputStream getConfigStream() throws IOException; - -} diff --git a/src/com/atmel/fpslic/FpslicRaw.java b/src/com/atmel/fpslic/FpslicRaw.java new file mode 100644 index 0000000..5113f5c --- /dev/null +++ b/src/com/atmel/fpslic/FpslicRaw.java @@ -0,0 +1,17 @@ +package com.atmel.fpslic; + +import com.ftdi.usb.*; +import java.io.*; + +/** + * "Raw" access to an unconfigured FPSLIC -- used to load the initial bitstream. + */ +public interface FpslicRaw { + + public InputStream getInputStream(); + public OutputStream getOutputStream(); + public OutputStream getConfigStream() throws IOException; + public void reset() throws IOException; + public void selfTest() throws Exception; + +} diff --git a/src/com/atmel/fpslic/ChipImpl.java b/src/com/atmel/fpslic/FpslicRawUsb.java similarity index 80% rename from src/com/atmel/fpslic/ChipImpl.java rename to src/com/atmel/fpslic/FpslicRawUsb.java index dedc4b0..a459e8d 100644 --- a/src/com/atmel/fpslic/ChipImpl.java +++ b/src/com/atmel/fpslic/FpslicRawUsb.java @@ -2,7 +2,7 @@ package com.atmel.fpslic; import com.ftdi.usb.*; import java.io.*; -public class ChipImpl extends FtdiUart implements Chip { +public class FpslicRawUsb extends FtdiUart implements FpslicRaw { private int dmask = (1<<0) | @@ -14,12 +14,12 @@ public class ChipImpl extends FtdiUart implements Chip { (1<<6) | (1<<7); - public ChipImpl() throws IOException { + public FpslicRawUsb() throws IOException { super(0x6666, 0x3133, 1500 * 1000); - doReset(); + reset(); } - public void flush() throws IOException { getOutputStream().flush(); } + void flush() throws IOException { getOutputStream().flush(); } protected int dbits = 0; protected synchronized void dbang(int bit, boolean val) throws IOException { @@ -29,7 +29,7 @@ public class ChipImpl extends FtdiUart implements Chip { } catch (IOException e) { throw new RuntimeException(e); } } - public void doReset() throws IOException { + public void reset() throws IOException { dmask = (1<<0) | @@ -67,9 +67,9 @@ public class ChipImpl extends FtdiUart implements Chip { con(false); } - public void config(boolean bit) throws IOException { config(bit?1:0, 1); } - public void config(int dat) throws IOException { config(dat, 8); } - public void config(int dat, int numbits) throws IOException { + void config(boolean bit) throws IOException { config(bit?1:0, 1); } + void config(int dat) throws IOException { config(dat, 8); } + void config(int dat, int numbits) throws IOException { for(int i=(numbits-1); i>=0; i--) { boolean bit = (dat & (1< " + pin + " " + (pin ? green("good") : red("BAD"))); - d.doReset(); + d.reset(); try { Thread.sleep(100); } catch (Exception e) { } d.config(0,3); d.con(); @@ -186,7 +186,7 @@ public class ChipImpl extends FtdiUart implements Chip { pin = d.initErr(); System.out.println("bad preamble #2 => " + pin + " " + (pin ? red("BAD") : green("good"))); - d.doReset(); + d.reset(); try { Thread.sleep(100); } catch (Exception e) { } d.config(0,3); d.con(); diff --git a/src/edu/berkeley/slipway/FtdiBoard.java b/src/edu/berkeley/slipway/FtdiBoard.java index 283a626..4b6088f 100644 --- a/src/edu/berkeley/slipway/FtdiBoard.java +++ b/src/edu/berkeley/slipway/FtdiBoard.java @@ -13,7 +13,7 @@ public class FtdiBoard extends Board { System.load(new File("build/"+System.mapLibraryName("FtdiUartNative")).getAbsolutePath()); } - private final Chip chip; + private final FpslicRaw chip; private final InputStream in; private final OutputStream out; @@ -21,7 +21,7 @@ public class FtdiBoard extends Board { public OutputStream getOutputStream() { return out; } public FtdiBoard() throws Exception { - chip = new ChipImpl(); + chip = new FpslicRawUsb(); String bstFile = this.getClass().getName(); bstFile = bstFile.substring(0, bstFile.lastIndexOf('.')); bstFile = bstFile.replace('.', '/')+"/slipway_drone.bst"; @@ -33,16 +33,14 @@ public class FtdiBoard extends Board { } public void reset() throws IOException { - chip.doReset(); + chip.reset(); } public void boot(Reader r) throws Exception { - Chip d = chip; - d.selfTest(); - - OutputStream os = d.getConfigStream(); + chip.selfTest(); + OutputStream os = chip.getConfigStream(); BufferedReader br = new BufferedReader(r); br.readLine(); @@ -50,9 +48,8 @@ public class FtdiBoard extends Board { while(true) { String s = br.readLine(); if (s==null) break; - int in = Integer.parseInt(s, 2); bytes++; - os.write((byte)in); + os.write((byte)Integer.parseInt(s, 2)); if ((bytes % 1000)==0) { os.flush(); System.out.print("wrote " + bytes + " bytes\r"); -- 1.7.10.4