1 package edu.berkeley.slipway;
3 import com.atmel.fpslic.*;
4 import edu.berkeley.obits.*;
5 import org.ibex.util.Log;
10 public class FtdiBoard extends Board {
13 System.load(new File("build/"+System.mapLibraryName("FtdiUartNative")).getAbsolutePath());
16 private final FpslicRaw chip;
17 private final InputStream in;
18 private final OutputStream out;
20 public InputStream getInputStream() { return in; }
21 public OutputStream getOutputStream() { return out; }
23 public FtdiBoard() throws Exception {
24 chip = new FpslicRawUsb();
25 String bstFile = this.getClass().getName();
26 bstFile = bstFile.substring(0, bstFile.lastIndexOf('.'));
27 bstFile = bstFile.replace('.', '/')+"/slipway_drone.bst";
28 boot(new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream(bstFile)));
29 in = chip.getInputStream();
30 out = chip.getOutputStream();
31 for(int i=0; i<255; i++) out.write(0);
35 public void reset() throws IOException {
39 public void boot(Reader r) throws Exception {
43 OutputStream os = chip.getConfigStream();
44 BufferedReader br = new BufferedReader(r);
49 String s = br.readLine();
52 os.write((byte)Integer.parseInt(s, 2));
53 if ((bytes % 1000)==0) {
55 System.out.print("wrote " + bytes + " bytes\r");
61 public static String pad(String s, int i) {
62 if (s.length() >= i) return s;
63 return "0"+pad(s, i-1);