1 package com.atmel.fpslic;
5 public class ChipImpl extends FtdiUart implements Chip {
17 public ChipImpl() throws IOException {
18 super(0x6666, 0x3133, 1500 * 1000);
22 public void flush() throws IOException {
24 getOutputStream().flush();
25 } catch (Exception e) { throw new RuntimeException(e); }
28 protected int dbits = 0;
29 protected synchronized void dbang(int bit, boolean val) throws IOException {
30 dbits = val ? (dbits | (1 << bit)) : (dbits & (~(1 << bit)));
32 getOutputStream().write((byte)dbits);
33 } catch (IOException e) { throw new RuntimeException(e); }
36 public void doReset() throws IOException {
59 //try { Thread.sleep(500); } catch (Exception e) { }
63 try { Thread.sleep(500); } catch (Exception e) { }
64 if (initErr()) throw new RuntimeException("INIT was still high after pulling RESET low");
65 //System.out.println("0 con() = " + con());
69 try { Thread.sleep(500); } catch (Exception e) { }
70 if (!initErr()) throw new RuntimeException("INIT was still low after releasing RESET");
71 //System.out.println("1 con() = " + con());
75 public void config(boolean bit) throws IOException { config(bit?1:0, 1); }
76 public void config(int dat) throws IOException { config(dat, 8); }
77 public void config(int dat, int numbits) throws IOException {
78 for(int i=(numbits-1); i>=0; i--) {
79 boolean bit = (dat & (1<<i)) != 0;
86 // tricky: RESET has a weak pull-up, and is wired to a CBUS line. So,
87 // we can pull it down (assert reset) from uart-mode, or we can
88 // let it float upward from either mode.
89 public void reset(boolean on) throws IOException {
90 uart_and_cbus_mode(1<<1, on ? (1<<1) : 0);
98 public void avrrst(boolean on) throws IOException { dbang(7, on); }
99 public void clk(boolean on) throws IOException { dbang(6, on); }
100 public void data(boolean on) throws IOException { dbang(5, on); }
102 public boolean initErr() throws IOException { flush(); return (readPins() & (1<<4))!=0; }
104 public boolean con() throws IOException {
108 return (readPins() & (1<<0)) != 0;
110 public boolean rcon() throws IOException {
114 return (readPins() & (1<<0)) != 0;
116 public void con(boolean on) throws IOException {