1 package edu.berkeley.slipway;
4 import com.atmel.fpslic.*;
5 import edu.berkeley.obits.*;
6 import org.ibex.util.Log;
11 public class FtdiBoard extends Board {
14 System.load(new File("build/"+System.mapLibraryName("FtdiUartNative")).getAbsolutePath());
17 private final FpslicRaw chip;
18 private final InputStream in;
19 private final OutputStream out;
21 public InputStream getInputStream() { return in; }
22 public OutputStream getOutputStream() { return out; }
24 public FtdiBoard() throws Exception {
25 chip = new FpslicRawUsb(new FtdiUart(0x6666, 0x3133, 1500 * 1000));
26 String bstFile = this.getClass().getName();
27 bstFile = bstFile.substring(0, bstFile.lastIndexOf('.'));
28 bstFile = bstFile.replace('.', '/')+"/slipway_drone.bst";
29 boot(new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream(bstFile)));
30 in = chip.getInputStream();
31 out = chip.getOutputStream();
32 for(int i=0; i<255; i++) out.write(0);
36 public void reset() throws IOException {
40 public void boot(Reader r) throws Exception {
44 OutputStream os = chip.getConfigStream();
45 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);