X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fslipway%2FFtdiBoard.java;h=d84afa139116fb55dd51e92fd1b5555b4b818117;hb=9c336acf3a9eefed8bcb09f7f094fd709d9a2073;hp=dafc38f0734b82633dad076e9999d72a548017c9;hpb=c2fe2c6460fa3ad7b73ef431edf21cfb38a11b27;p=slipway.git diff --git a/src/edu/berkeley/slipway/FtdiBoard.java b/src/edu/berkeley/slipway/FtdiBoard.java index dafc38f..d84afa1 100644 --- a/src/edu/berkeley/slipway/FtdiBoard.java +++ b/src/edu/berkeley/slipway/FtdiBoard.java @@ -1,5 +1,6 @@ package edu.berkeley.slipway; +import com.ftdi.usb.*; import com.atmel.fpslic.*; import edu.berkeley.obits.*; import org.ibex.util.Log; @@ -13,7 +14,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 +22,7 @@ public class FtdiBoard extends Board { public OutputStream getOutputStream() { return out; } public FtdiBoard() throws Exception { - chip = new ChipImpl(); + chip = new FpslicRawUsb(new FtdiUart(0x6666, 0x3133, 1500 * 1000)); String bstFile = this.getClass().getName(); bstFile = bstFile.substring(0, bstFile.lastIndexOf('.')); bstFile = bstFile.replace('.', '/')+"/slipway_drone.bst"; @@ -33,60 +34,28 @@ 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(); int bytes = 0; 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"); - d.rcon(); } } - - d.flush(); - if (!d.initErr()) - throw new RuntimeException("initialization failed at " + bytes); - - for(int i=0; i<100; i++) { - d.flush(); - if (!d.initErr()) - throw new RuntimeException("initialization failed at " + bytes); - try { Thread.sleep(20); } catch (Exception e) { } - d.config(0,1); - } - - System.out.println(); - System.out.println("avr reset => false"); - d.avrrst(false); - try { Thread.sleep(500); } catch (Exception e) { } - //System.out.println("cts="+""+" pins=" + pad(Integer.toString(d.readPins()&0xff,2),8)); - - //((Chip)d).avr(); - - //System.out.println("avr reset => true"); - ((ChipImpl)chip).purge(); - ((ChipImpl)chip).uart_and_cbus_mode(1<<1, 1<<1); - - //d.avrrst(true); - //try { Thread.sleep(500); } catch (Exception e) { } - //System.out.println("cts="+""+" pins=" + pad(Integer.toString(d.readPins()&0xff,2),8)); + os.close(); } public static String pad(String s, int i) {